Open Source (Quell-Text):


Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form21Colors.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form21Colors.class
152 KB
' Gambas class file

Public F_bESCpressedON As Boolean
Public F_bMemoryColorsPanelON As Boolean
Public F_bMovingON As Boolean
Public F_fX1 As Float
Public F_fY1 As Float
Public F_fZoomFactor As Float = 10
Public F_iBackground As Integer = 3 'Wood
Public F_iBackgroundColorEnter As Integer 
Public F_sBackgroundColorOrPathUndo As String 
Public F_iColorBoxesPointer As Integer = 0  'Number Box > .Max
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220)
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150) 
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)

Public F_iColorPicker As Integer
Public F_iColorsCount As Integer = 10
Public F_iColumn12Sort As Integer = 12  'Name=name=Hex=RGB=Dezi=...
Public F_iColumns13Undo As Integer = 13
Public F_iColumns14Count As Integer = 14
Public F_iiIconClockColorsA As Integer[]
Public F_iiIconClockColorsB As Integer[]
Public F_iiPanelMemoryColorsUndo As Integer[]
Public F_iLastColor As Integer
Public F_iLastSide As Integer
Public F_iLastSideBefore As Integer
Public F_imgScreen As Image
Public F_imgZoom As Image
Public F_iOnly1x As Integer
Public F_iSaveQualityJPG As Integer = 80 '80%
Public F_iUndoRedoPhotosPointer As Integer
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_ooPicBoxesColorsA As Object[]
Public F_ooPicBoxesColorsB As Object[]
Public F_ooPicBoxesColorsBgrid As Object[]
Public F_ooUndoRedoPhoto As Object[] 
Public F_oPicBoxColorFind As Object
Public F_oPicBoxColorLast As Object
Public F_picPhotoLastUndo As Picture
Public F_picScreen As Picture
Public F_pointPickerXY As Point
Public F_sBackgroundColorOrPath As String 
Public F_sBackgroundColorOrPathEnter As String
Public F_sColorChangeLineUser As String
Public F_sColorValueUndo1 As String
Public F_sColorValueUndo2 As String
Public F_sColorValueUndo3 As String
Public F_sForm As String = Me.Name
Public F_sForm21ColorsText As String
Public F_sPathScreenphotoPNG As String
Public F_sSaveFormat As String
Public F_ssColorNames As String[] 
Public F_sTitleBasicText As String = Me.Window.Title
Public F_sURLblankempty As String = "about:blank" 'empty (leer) 
Public F_ooUndoRedoColors As Object[]
Public F_iUndoRedoColorsPointer As Integer
Public F_rectZoom As Rect
Public F_iSearchPosWeb As Integer
Public F_iSearchPosText As Integer
Public F_iSearchPosCode As Integer
Public F_iColumnUndo As Integer
Public F_iSearchPosColumnView As Integer

Public Function FilePathForm() As String 
  
  ' Return User.Home &/ Application.Name &/ Application.Name & "_" & "colors.txt"
  Return Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  ''Form-Title
  Me.Caption = Application.Name & " - " & ("Farbe wählen oder ändern") & Space(1) & ("(Pipette, Color-Picker)")
  Menu1.Visible = False
  MenuWeb.Visible = False
  
  ColorChooser1.ShowColorMap = True                                                       'Colors
  ColorChooser1.ShowCustom = True                                                         'User-Colors
  ColorChooser1.ShowAlpha = True                                                          'Alpha-channel, Transparent
  
  SettingsReadSave("read")                                          'read  'Start behind open 1x
  
  ''Cursor
  WindowStretchCursor()
  
  'Examples:
  'IconCutter.Background = ImageView1.Image[ImageView1.X, ImageView1.Y]                   'as Integer  Pipette
  'Me.Cursor = New Cursor(Picture["icon:/large/color-picker"])                            ' as Picture, x, y
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    PicturePhoto.Visible = False '—▶Timer
    TimerZoomLupe.Enabled = False
    Form_Resize()
    If F_sForm21ColorsText Then LabelInfo.Text = F_sForm21ColorsText
    
    ''Form-Background: Color or Wood or Metal
    FormBackgroundColor()
    
    F_sBackgroundColorOrPathEnter = M01Functions.CheckFormBackgroundColorValue() 'as String
    F_iBackgroundColorEnter = Settings[FMain.Name &/ "ColorButton1.Value", Color.Background] 
    F_sBackgroundColorOrPath = F_sBackgroundColorOrPathEnter
    F_sPathScreenphotoPNG = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG] 
    If IsDir(File.Dir(F_sPathScreenphotoPNG)) = False Then M01Functions.CheckDirAppName(File.Dir(F_sPathScreenphotoPNG), False)
    
    CheckFormBackgroundColor() '□ ■ □
    CreatePanelMemoryColors()
    ' ''Fill first array [0,....]
    If F_iiIconClockColorsB Then UndoRedoColorsAdd(F_iiIconClockColorsB)
    PhotoColorPickerLatest("load")
    LabelZoomTextG()
    AplusG()
    If F_bMemoryColorsPanelON = True Then PicBoxMemoryColors.Background = Color.Green
    ' ReadG()
    ' LoadColorNames() () 'only 1x for programmer, save files
    ' TimerZoomLupe.Enabled = True
    
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click
  If Key.Code = Key.F11 Then FullScreenONoff()
  If Key.Code = Key.Down Or Key.Code = Key.Right Or Key.Text = "+" Then
    ZoomHasFocus(True)
  Else If Key.Code = Key.Up Or Key.Code = Key.Left Or Key.Text = "-" Then
    ZoomHasFocus(False)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  TimerZoomLupe.Stop()
  SideG(1)
  
  Me.FullScreen = False
  Wait 0.1
  
  ''Reset:
  IconError.Visible = False
  
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then 
    Me.Title = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") 
    PicturePhoto.Visible = False
    PanelCopyImage.Visible = False
    ColorChooser1.Visible = True 
  Else
    Me.Title = F_sTitleBasicText
  Endif 
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub RaiseOrder() ''▲foreground▲ or ▼background▼
  
  PicBackground.Lower() '.Lower ↓  ▼BackGround▼
  PicturePhoto.Lower() 'ForeGround
  LabelBgSearch.Lower()
  PicBoxColorSelectBGGrid.Lower()
  
  IconError.Raise()
  PanelColorZoom.Raise()
  PicBoxZoomCross.Raise()
  PicBoxColorApplyTop.Raise()
  PicBoxWoodTop.Raise()
  PicBoxMetalTop.Raise()
  PanelMemoryColors.Raise()
  ArrowR.Raise()
  WindowStretch.Raise()
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iPH, iPH2, iPHX, iBW, iBH, iDis, iTop As Integer
  Dim fPart, fText As Float
  
  If Me.W < 100 Then Me.W = 100
  If Me.H < 100 Then Me.H = 100                                                           'min.
  iDis = 10 'Pixel
  iPH = 46 'ButtonK1.Height
  iPH2 = iPH / 2
  
  PicBackground.Move(0, 0, Me.ClientWidth, Me.ClientHeight) 'Hintergrund Aluminium, Holz oder Farbe

  iBW = PicBackground.Width / 100 * 3 ' Border Width (Randbreite)
  iBH = PicBackground.Height / 100 * 3 'Border Height
  
  IconError.Move(Me.ClientW - iPH, 0, iPH, iPH)
  
  PanelBorder.Move(iBW, iBH, PicBackground.W - (iBW * 2), PicBackground.H - (iBH * 2)) '□
  
  If F_bMovingON = False Then
    If F_bMemoryColorsPanelON = True Then 
      PanelColor.Move(0, 0, PanelBorder.W, PanelBorder.H - (iPH * 4.5))
      iTop = iPH + iPH2
    Else 
      PanelColor.Move(0, 0, PanelBorder.W, PanelBorder.H - (iPH * 3))
      iTop = 0
    Endif
    PanelMenuColor.Move(iPH * 3, PanelColor.Top + PanelColor.H + iTop, PanelBorder.W - (iPH * 3), iPH * 3)
    PanelMemoryColors.Move(0, PanelColor.Top + PanelColor.H, PanelColor.W, iTop)
    PanelMemoryColors.Visible = F_bMemoryColorsPanelON
    
    ColorChooser1.Move(0, 0, PanelColor.W, PanelColor.H - iDis)
    PicturePhoto.Move(0, 0, PanelColor.W, PanelColor.H - iDis)
    PanelWebTextCode.Move(0, 0, PanelColor.W, PanelColor.H - iDis)
    
    ''Panel WebView, Text, Code, ColumnView
    WebView1.Move(0, 0, PanelWebTextCode.W, PanelWebTextCode.H - (iPH * 1.5))
    TextAreaText.Move(0, 0, WebView1.W, WebView1.H)
    TextAreaCode.Move(0, 0, WebView1.W, WebView1.H)
    ColumnView1.Move(0, 0, WebView1.W, WebView1.H)
    
    iPHX = PanelWebTextCode.W / 12
    LabelCopyExample.Move(0, WebView1.Top + WebView1.H, PanelWebTextCode.W, iPH * 0.5)
    PanelSearch.Move(0, LabelCopyExample.Top + LabelCopyExample.H, PanelWebTextCode.W, iPH)
    PicBoxSearchPaste.Move(0, 0, iPH, iPH)
    TextAreaSearch.Move(PicBoxSearchPaste.Left + PicBoxSearchPaste.W, 0, iPHX * 3, iPH)
    LabelBgSearch.Move(TextAreaSearch.Left, TextAreaSearch.Top, TextAreaSearch.W, TextAreaSearch.H)
    ButtonSearch.Move(TextAreaSearch.Left + TextAreaSearch.W, 0, iPHX * 2, iPH)
    ButtonSearchBack.Move(ButtonSearch.Left + ButtonSearch.W, 0, iPHX * 2, iPH)
    ButtonCancelWebTextCode.Move(ButtonSearchBack.Left + ButtonSearchBack.W, 0, PanelWebTextCode.W - (ButtonSearchBack.Left + ButtonSearchBack.W), iPH)
    
    ''Copy Image from Clipboard.Paste()
    PanelCopyImage.Move(0, 0, PicturePhoto.W, PicturePhoto.H)
    PicBoxCopyImage.Move(0, 0, PanelCopyImage.W, PanelCopyImage.H - (iPH * 2)) 
    ImageView1.Move(0, 0, PanelCopyImage.W, PanelCopyImage.H - (iPH * 2)) 
    LabelCopyImageInfo.Move(0, PicBoxCopyImage.Top + PicBoxCopyImage.H, PanelCopyImage.W, iPH) 
    ButtonCopyImageReload.Move(0, LabelCopyImageInfo.Top + LabelCopyImageInfo.H, iPH, iPH) 
    ButtonCancelCopyImage.Move(ButtonCopyImageReload.Left + ButtonCopyImageReload.W, LabelCopyImageInfo.Top + LabelCopyImageInfo.H, PanelCopyImage.W - (ButtonCopyImageReload.Left + ButtonCopyImageReload.W), iPH) 
    
    PanelColorZoom.Move(PanelBorder.Left, PanelBorder.Top + PanelMenuColor.Top, iPH * 3, iPH * 3)
    PicBoxZoomLupe.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)
    PicBoxZoomCross.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)'1:1
    
    PicBoxPickerColor.Move(0, 0, iPH, iPH)
    PicBoxPhoto.Move(PicBoxPickerColor.Left, PicBoxPickerColor.Top + PicBoxPickerColor.H, iPH, iPH)
    PicBoxMenu.Move(PicBoxPickerColor.Left, PicBoxPhoto.Top + PicBoxPhoto.H, iPH, iPH)
    
    fPart = PanelMenuColor.W / 10 
    LabelZoom.Move(PicBoxPickerColor.Left + PicBoxPickerColor.W, 0, iPH * 4, iPH)
    LabelInfo.Move(LabelZoom.Left + LabelZoom.W, 0, PanelMenuColor.W - (iPH * 16), iPH)
    
    ''Panel Memory + color
    iPHX = PanelMemoryColors.H - 4
    PicBoxColorSelectBGGrid.Move(0, 0, iPH, PanelMemoryColors.H)
    PicBoxColorSelectFG.Move(PicBoxColorSelectBGGrid.Left, PicBoxColorSelectBGGrid.Top, PicBoxColorSelectBGGrid.W, PicBoxColorSelectBGGrid.H)
    PicBoxColorMemoryTop.Move(iPH, 0, iPHX * 0.5, iPHX * 0.5)
    PicBoxColorMemoryBottom.Move(iPH, PicBoxColorMemoryTop.Top + PicBoxColorMemoryTop.H, iPHX * 0.5, iPHX * 0.5)
    ScrollViewMemoryColors.Move(PicBoxColorMemoryBottom.Left + PicBoxColorMemoryBottom.W, 0, PanelMemoryColors.W - (iPHX * 7.5), iPHX)
    PicBoxResetMemoryColors.Move(ScrollViewMemoryColors.Left + ScrollViewMemoryColors.W, 0, iPHX, iPHX)   
    PanelColorsUndoRedo.Move(PicBoxResetMemoryColors.Left + PicBoxResetMemoryColors.W, 0, iPHX * 3, iPHX)
    PicBoxColorsUndo.Move(0, 0, iPHX, iPHX)
    ListBackupCounter2.Move(PicBoxColorsUndo.Left + PicBoxColorsUndo.W, 0, iPHX, iPHX)
    PicBoxColorsRedo.Move(ListBackupCounter2.Left + ListBackupCounter2.W, 0, iPHX, iPHX)
    PicBoxOpenColors.Move(PanelColorsUndoRedo.Left + PanelColorsUndoRedo.W, 0, iPHX, iPHX)
    PicBoxSaveColors.Move(PicBoxOpenColors.Left + PicBoxOpenColors.W, 0, iPHX, iPHX)
    ButtonCancelMemoryColors.Move(PicBoxSaveColors.Left + PicBoxSaveColors.W, 0, PanelMemoryColors.W - (PicBoxSaveColors.Left + PicBoxSaveColors.W), iPHX)
    
    
    ''Menu Color Background
    PanelColorBackground.Move(LabelInfo.Left + LabelInfo.W, 0, iPH * 3, iPH)
    PicBoxColorApply.Move(0, 0, iPH, iPH)
    PicBoxWood.Move(PicBoxColorApply.Left + PicBoxColorApply.W, 0, iPH, iPH)
    PicBoxMetal.Move(PicBoxWood.Left + PicBoxWood.W, 0, iPH, iPH)
    
    PicBoxColorApplyTop.Move(0, 0, iPH, iPH)
    PicBoxWoodTop.Move(PicBoxColorApply.Left + PicBoxColorApply.W, 0, iPH, iPH)
    PicBoxMetalTop.Move(PicBoxWood.Left + PicBoxWood.W, 0, iPH, iPH)
    
    ''Menu
    PicBoxResetstart.Move(PanelColorBackground.Left + PanelColorBackground.W, 0, iPH, iPH)
    ListAplus.Move(PicBoxResetstart.Left + PicBoxResetstart.W, 0, iPH, iPH)
    PicBoxPlus.Move(ListAplus.Left + ListAplus.W, 0, iPH, iPH)
    
    PicBoxWebColorNamesSort.Move(PicBoxPlus.Left + PicBoxPlus.W + iPH, 0, iPH, iPH)
    PicBoxColumnviewColorNamesFind.Move(PicBoxWebColorNamesSort.Left + PicBoxWebColorNamesSort.W, 0, iPH, iPH)
    PicBoxColorChooser.Move(PicBoxColumnviewColorNamesFind.Left + PicBoxColumnviewColorNamesFind.W, 0, iPH, iPH)
    PicBoxMemoryColors.Move(PicBoxColorChooser.Left + PicBoxColorChooser.W, 0, iPH, iPH)
        
    PanelPhotoUndoRedo.Move(PicBoxPhoto.Left + PicBoxPhoto.W, LabelZoom.Top + LabelZoom.H, (iPH * 4), iPH)
    ListUndo.Move(0, 0, iPH, iPH)
    ListBackupCounter1.Move(ListUndo.Left + ListUndo.W, 0, iPH * 2, iPh)
    ListRedo.Move(ListBackupCounter1.Left + ListBackupCounter1.W, 0, iPH, iPh)

    TextBoxHTML.Move(PanelPhotoUndoRedo.Left + PanelPhotoUndoRedo.W, LabelInfo.Top + LabelInfo.H, PanelMenuColor.W - (iPH * 17), iPH)
    WindowT5plus.Move(TextBoxHTML.Left + TextBoxHTML.W, TextBoxHTML.Top, iPH, iPH)
    TextBoxColorName.Move(WindowT5plus.Left + WindowT5plus.W, TextBoxHTML.Top, iPH * 6, iPH)
    ButtonCopy1.Move(TextBoxColorName.Left + TextBoxColorName.W, TextBoxHTML.Top, iPH, iPH)
    
    fText = TextBoxHTML.W / 2
    ButtonInsert.Move(PicBoxMenu.Left + PicBoxMenu.W, PanelPhotoUndoRedo.Top + PanelPhotoUndoRedo.H, iPH * 4, iPH) 
    TextBoxDezi.Move(ButtonInsert.Left + ButtonInsert.W, ButtonInsert.Top, fText, iPH)
    TextBoxHexa.Move(TextBoxDezi.Left + TextBoxDezi.W, ButtonInsert.Top, fText, iPH) 
    TextBoxHexaHTML.Move(TextBoxHexa.Left + TextBoxHexa.W + iPH, ButtonInsert.Top, iPH * 6, iPH)
    
    ButtonCopy2.Move(TextBoxHexaHTML.Left + TextBoxHexaHTML.W, TextBoxDezi.Top, iPH, iPH) 
    
    ButtonApply.Move(ButtonCopy1.Left + ButtonCopy1.W, ButtonCopy1.Top, iPH * 3, iPH * 2) 
    ButtonCancel.Move(ButtonApply.Left + ButtonApply.W, ButtonCopy1.Top, iPH, iPH) 
    
    ArrowR.Move(PanelBorder.Left + PanelBorder.W, PanelBorder.Top, iBW, PanelColor.H)
    
    WindowStretch.Move(Me.ClientW - iPH - iBW, Me.ClientH - iPH - iBH, iPH, iPH)
  Endif 
  RaiseOrder()
  If F_ooPicBoxesColorsA Then ResizeColorBoxes() 'A and B
  If ColumnView1.Visible = True Then ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoScreen() 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  
  Dim imgScreen As Image
  Dim picScreen As Picture
  
  TimerZoomLupe.Stop()
  Form21Colors.Window.Visible = False 
  
  Wait 0.3
  '**********************************************
  ' picScreen = Desktop.Screenshot() 'as Picture!
  picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  If picScreen Then imgScreen = picScreen.Image
  '**********************************************
  
  ''Missing? Alternative:
  If M01Functions.ScreenshotImageExist(imgScreen) = False Then 
    imgScreen = M01Functions.ScreenshotImageAlternative()
    If Not imgScreen Then imgScreen = M01Functions.ScreenshotImageDemo(PicBackground.ScreenX, PicBackground.ScreenY, PicBackground.W, PicBackground.H)
    ' ZoomArea()
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  If imgScreen Then 
    F_picScreen = imgScreen.Picture
    ' F_imgScreen = imgScreen.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicturePhoto.Picture = F_picScreen
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
  Endif 
  Form21Colors.Window.Visible = True 
  F_imgScreen = Null 'Reset
  TimerZoomLupe.Start()
  
Catch 
  FMain.ErrorText
  Form21Colors.Window.Visible = True 
  
End 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Public Sub TimerZoomLupe_Timer()
  '.Delay = 100 ?     1000=1sec.
  
  ''Pick Color:
  ' If PicturePhoto.Visible = True Then   'PicBoxScreenshot
  If PicturePhoto.Visible = True Then 
    PicBoxPickerColor.Background = Color.Green 
    PicBoxZoomLupe.Visible = True 
    ZoomArea()
  Else 
    ' TimerZoomLupe.Stop()
    PicBoxPickerColor.Background = Color.Default
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyButtonG(Optional sFullOrZoom As String = "full")
  
  Dim Img As Image
  
  Select Case sFullOrZoom
    Case "full"
      If PicturePhoto.Picture Then Img = PicturePhoto.Picture.Image
    Case "zoom"
      ' If PicBoxZoomLupe.Picture Then Img = PicBoxZoomLupe.Picture.Image.Copy(Mouse.ScreenX - F_iX1 - (PanelColorZoom.W / 2), F_iY1 - Mouse.ScreenY - (PanelColorZoom.H / 2), PanelColorZoom.W, PanelColorZoom.H)
      ' PicturePhoto.Picture = Img.Picture 
      If PicturePhoto.Picture Then Img = PicturePhoto.Picture.Image
  End Select
  
  If Img Then 
    Clipboard.Clear() 'no longer?
    ' '??? libpng error: Read Error
    Wait 0.5
    Clipboard.Copy(Img) 'Copy In Clipboard(Zwischenablage)
  Endif 
  
  Img = Null
  Img = M01Functions.ClipboardImage() 'as Image
  ' If M01Functions.ClipboardImageExist() = False Then Img = ""
  
  If Img Then 
    ' If Clipboard.Type = Clipboard.Image Then
    ' PicBoxCopyImage.Picture = Img.Picture
    ImageView1.Update(Img)  
    ImageView1.ZoomFit()
    ' ImageView1.Zoom = 1
    If sFullOrZoom = "full" Then
      LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & Img.W & " x " & Img.H & " px"
      ' PicBoxCopyImage.Stretch = True 
    Else 
      LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & Img.W & " x " & Img.H & " px"
      ' LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & ("Zoom") & Space(1) & F_fZoomFactor & "x, " & Img.W & " x " & Img.H & " px"
      ' PicBoxCopyImage.Stretch = False 
    Endif 
    LabelCopyImageInfo.Foreground = Color.Blue
  Else
    PicBoxCopyImage.Picture = Null 'Picture[""] 'sichtbar leeren
    LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild fehlt")
    LabelCopyImageInfo.Foreground = Color.Red
  Endif
  PanelCopyImage.Visible = True 
  PanelCopyImage.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFontForeground()
  '■=■ > □=■
  ''Example: Black-Foreground-Font in Black-Background = no visible —▶ more difference in Color
  
  If M01Functions.ColorInfoRGB(F_iColorPicker, "L") < 150 And M01Functions.ColorInfoRGB(F_iColorPicker, "A") < 150 Then LabelInfo.Foreground = Color.White Else LabelInfo.Foreground = Color.Black
  
  If F_iColorPicker = Color.Default Or F_iColorPicker = Color.Transparent Then LabelInfo.Foreground = Color.Black
  ' LabelZoom.Foreground = LabelInfo.Foreground
  
Catch 
  FMain.ErrorText 
  
End

Public Sub ZoomArea()
  
  If Not F_picScreen Then
    If PicturePhoto.Picture Then 
      F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
      F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
      PicBoxZoomLupe.Picture = F_picScreen
    Endif 
  Endif 
  
  If F_picScreen Then    
    ' If Not F_imgScreen Then 
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    If String.LCase(Desktop.Platform) = "wayland" Then 
      F_fX1 = Mouse.ScreenX - PanelBorder.Left 
      F_fY1 = Mouse.ScreenY - PanelBorder.Top ' Desktop.Y '= Screens[0].AvailableY = 0
    Else 'If String.LCase(Desktop.Platform) = "x11" Then 
      F_fX1 = Mouse.ScreenX - PanelBorder.ScreenX
      F_fY1 = Mouse.ScreenY - PanelBorder.ScreenY ' Desktop.Y '= Screens[0].AvailableY = 0
    Endif 
    
    ''Pick Color Pixel-Point:
    F_iColorPicker = F_imgScreen[F_fX1, F_fY1] 'as Integer
    PicBoxColorSelectFG.Background = F_iColorPicker
    ZoomLupeG()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ZoomLupeG()
  
  PicBoxZoomLupe.Move((-F_fX1 * F_fZoomFactor) + (PanelColorZoom.W / 2), (-F_fY1 * F_fZoomFactor) + (PanelColorZoom.H / 2), PicturePhoto.W * F_fZoomFactor, PicturePhoto.H * F_fZoomFactor)
  F_rectZoom = Rect(PicBoxZoomLupe.Left, PicBoxZoomLupe.Top, PicBoxZoomLupe.W, PicBoxZoomLupe.H)
  ZoomImage()

Catch
  FMain.ErrorText
  
End

Public Sub ZoomImage()
  
  If Not PicturePhoto.Picture Then 
    LabelInfo.Text = ("Fehlt: Bildschirm-Foto")
  Else  
    ''Refresh ColorPicker:
    ' If PicturePhoto.Visible = True Then 
    CursorFill()
    
    ''Show Color:
    LabelInfo.Background = F_iColorPicker
    CheckFontForeground()
    
    LabelZoomTextG()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelZoomTextG()
  
  LabelZoom.Text = ("Zoom") & Space(1) & Round(F_fZoomFactor, -1) & "x" & Space(1) & ("im Foto") & gb.NewLine & ("Maus-Rad - +")' Example Round —▶ 1.2
  LabelZoom.Tooltip = LabelZoom.Text & gb.NewLine & ("Klick=Reset: Zoom") & Space(1) & Str(F_fZoomFactor) & "x"
  
Catch
  FMain.ErrorText
  
End

Public Sub CursorFill()
  
  ''ColorPicker 'Change ●
  PicturePhoto.Cursor = New Cursor(PicBoxPickerColor.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 'as Picture, x, y
  PicturePhoto.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")                                                                'save
  CheckSaveG()
  PhotoColorPickerLatest("save")
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckSaveG() As Boolean
  
  Dim sMessage, sColorSquare As String  
  
  ' Path1 = "images/bg_aluminium1.png"
  ' Path2 = "images/bg_holz2.png"
  
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then 
    If Not PicBackground.Picture Then sColorSquare = "<font size=7 color=#" & Hex(PicBackground.Background, 6) & ">" & "■" & "</font>" 
    sMessage = "<h2><font color=red>" & ("Speichern?") & "</font></h2>"
    sMessage &= "<h3>" & sColorSquare & Space(1) & "<font color=blue>" & ("Hintergrund") & ": " & ("Auswahl anwenden") & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("Speichern"), ("Nein"), ("Abbrechen"))
      Case 1 'Save
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath   'Path or Color  
        Settings[FMain.Name &/ "ColorButton1.Value"] = PicBackground.Background
        
      Case 2, 3 'Reset, Cancel
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPathUndo   'Path or Color  
        Settings[FMain.Name &/ "ColorButton1.Value"] = F_iBackgroundColorEnter
        
    End Select
    
    M01Functions.FormsBackgroundColorAll()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorChooser1_Change()
  
  ColorSelected()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorSelected()
  
  Dim sText, sLine, sColorName, sAlpha As String
  Dim iFound, iColor, iR, iG, iB, iColorRGB, iAlpha As Integer
  Dim ssSpli As String[]
  Dim hColorInfo As ColorInfo
  
  iColor = ColorChooser1.SelectedColor
  iColorRGB = Color.SetAlpha(iColor, 0)
  
  hColorInfo = Color[iColor]
  iR = hColorInfo.Red
  iG = hColorInfo.Green
  iB = hColorInfo.Blue
  iAlpha = hColorInfo.Alpha 'Transparent

  ' sColorName = Quote(("Ein Name für die Farbe"))
  sColorName = Quote(("Kein Name"))
  
  If Not F_ssColorNames Then LoadColorNames()
  
  If F_ssColorNames Then 
    iFound = F_ssColorNames.Find("*=#" & Str(Hex(iColorRGB, 6)) & "=*", gb.Like) '-1 not found 
    If iFound > -1 Then 
      sLine = F_ssColorNames[iFound]
      ssSpli = Split(sLine & String(F_iColumns14Count, "="), "=")
      sColorName = ssSpli[0] 
    Endif 
  Endif 
  
  sText = "RGB" & "(" & iR & "," & iG & "," & iB & "," & iAlpha & ")" & gb.NewLine
  sText &= ("(Rot, Grün, Blau, Transparenz)") & Space(1) & ("Werte 0 bis 255") & gb.NewLine
  sText &= "<font color=" & Quote("#" & Str(Hex(iColorRGB, 6))) & ">...</font>" & gb.NewLine
  sText &= "<draw:color draw:name=" & sColorName & " draw:color=" & Chr(34) & "#" & Str(Hex(iColor, 6)) & Chr(34) & "/>" 'Chr() siehe ASCII-Tabelle 
  
  TextBoxHTML.SelectAll()
  TextBoxHTML.Insert(sText)
  TextBoxHTML.Background = Color.Default
  TextBoxHTML.Pos = 1
  
  TextBoxColorName.SelectAll()
  TextBoxColorName.Insert(sColorName)
  TextBoxColorName.Background = iColor
  
  TextBoxDezi.SelectAll()
  TextBoxDezi.Insert(iColor) '0123456789
  TextBoxDezi.Background = Color.Default
  
  TextBoxHexa.SelectAll()
  TextBoxHexa.Insert("&H" & Str(Hex(iColor, 8)) & "&")   '&H40678DB2& transparent blue
  TextBoxHexa.Background = Color.Default
  
  TextBoxHexaHTML.SelectAll()
  TextBoxHexaHTML.Insert("#" & Str(Hex(iColorRGB, 6))) '#678DB2
  TextBoxHexaHTML.Background = iColorRGB '=.Value =.SelectedColor
  
  F_iColorPicker = iColor
  LabelInfo.Background = F_iColorPicker
  PicBoxColorApply.Background = F_iColorPicker
  PicBoxColorApplyTop.Background = F_iColorPicker
  CheckFontForeground()
  TextBoxColorName.ForeGround = LabelInfo.Foreground
  TextBoxHexaHTML.ForeGround = LabelInfo.Foreground
  PicBoxColorMemoryBottom.Picture = PicTemplateColorPotCross.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture
  PicBoxPlus.Picture = PicTemplateColorPlus.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture
  'Only color, without Transparent (Alpha). Example: Hex(Color.White, 6) = > "FFFFFF"   not forget &H...&
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  
  If iAlpha > 0 Then sAlpha = " +" & Str(iAlpha) & Space(1) & ("Alpha=Glas") 
  
  If iFound > -1 Then 
    LabelInfo.Text = ("Info") & ": " & sColorName & sAlpha
  Else 
    LabelInfo.Text = ("Info") & ": " & Str(Hex(iColor, 8)) & sAlpha
  Endif 
  
  LabelInfo.Tooltip = LabelInfo.Text
  ' If ColorChooser1.Visible = False Then SideG(1)
  ColorFindSelected()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm & "Left", Me.Left]
      iY = Settings[F_sForm & "Top", Me.Top]
      iW = Settings[F_sForm & "Width", Me.W]
      iH = Settings[F_sForm & "Height", Me.H]
      Me.Move(iX, iY, iW, iH)
      ' PicBoxColorMemory1.Background = Settings[F_sForm &/ PicBoxColorMemory1.Tag, Color.White]
      ' PicBoxColorMemory2.Background = Settings[F_sForm &/ PicBoxColorMemory2.Tag, Color.White]
      ' PicBoxColorMemory3.Background = Settings[F_sForm &/ PicBoxColorMemory3.Tag, Color.White]
      F_iLastSide = Settings[F_sForm &/ "F_iLastSide", 1]
      F_iLastColor = Settings[F_sForm &/ "F_iLastColor", F_iColorPicker]
      F_iColorPicker = F_iLastColor
      F_bMemoryColorsPanelON = Settings[F_sForm &/ "F_bMemoryColorsPanelON", F_bMemoryColorsPanelON]
      ColorChooser1.SelectedColor = F_iLastColor
      F_iColorBoxesPointer = Settings[F_sForm &/ "F_iColorBoxesPointer", F_iColorBoxesPointer]
      ' SettingsColorsUserReadSave("read")
      ColumnView1.Font.Size = Settings[F_sForm &/ "ColumnView1.Font.Size", ColumnView1.Font.Size] 
      F_sBackgroundColorOrPathUndo = Settings[F_sForm &/ "F_sBackgroundColorOrPathUndo", "wood"]  'Path or Color
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm & "Left"] = Me.Left
      Settings[F_sForm & "Top"] = Me.Top
      Settings[F_sForm & "Width"] = Me.Width
      Settings[F_sForm & "Height"] = Me.Height
      
      Settings[F_sForm &/ "F_iLastSide"] = F_iLastSide
      Settings[F_sForm &/ "F_iLastColor"] = ColorChooser1.SelectedColor
      Settings[F_sForm &/ "F_bMemoryColorsPanelON"] = F_bMemoryColorsPanelON
      Settings[F_sForm &/ "F_iColorBoxesPointer"] = F_iColorBoxesPointer
      Settings[F_sForm &/ "ColumnView1.Font.Size"] = ColumnView1.Font.Size
      Settings[F_sForm &/ "F_sBackgroundColorOrPathUndo"] = F_sBackgroundColorOrPathUndo 'Path or Color
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Me.Maximized = Not Me.Maximized 
  If Me.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Me.FullScreen = True Or Me.Maximized = True Then 
      F_bMovingON = False
      Me.FullScreen = False
      Me.Maximized = False
      If Me.Left + Me.W > Screen.AvailableWidth Then Me.Move(Me.Left, Me.Top, Screen.AvailableWidth - Me.Left, Screen.AvailableHeight - Me.Top)
    Else
      F_bMovingON = True
      Me.FullScreen = False
      Me.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Me.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Me.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Me.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Me.W = Mouse.ScreenX - F_iX1
    Me.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
    WindowStretch.Raise()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Me.Maximized = Not Me.Maximized 
    If Me.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Me.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Me.FullScreen = False Then 
    Me.Maximized = True
    Me.FullScreen = True  
  Else
    Me.Maximized = False
    Me.FullScreen = False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyText(Optional sText As String = "")
  
  If sText Then 
    Clipboard.Clear
    Clipboard.Copy(sText)                                                                 'Copy x----
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxHexa_KeyPress()
  
  If Key.Code = Key.Return Then PasteTextboxColor(TextBoxHexa.Text)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxDezi_KeyPress()
  
  Dim iColor As Integer
  Dim sHex As String
  
  If Key.Code = Key.Return Then 
    If IsInteger(TextBoxDezi.Text) Then 
      iColor = CInteger(TextBoxDezi.Text)
      sHex = "#" & Hex(iColor, 6)
      PasteTextboxColor(sHex)
    Else 
      PasteTextboxColor(TextBoxDezi.Text)
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.IconError()
  
End

Public Sub ClipboardImagePaste()
  
  Dim Img As Image
  Dim sPathScreenshot, sMessage As String
  
  'If Clipboard.Type = Clipboard.Image Then 'check, '0=empty, 1=Text, 2=Image, Clipboard.Text for some text, Clipboard.Image for an image.
  
  If Not Img Then Img = M01Functions.ClipboardImage()  'as Image
  sPathScreenshot = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", ""]
  If IsDir(File.Dir(sPathScreenshot)) = False Then M01Functions.CheckDirAppName(File.Dir(sPathScreenshot), False)
  If Not Img And Exist(sPathScreenshot) = True Then Img = Image.Load(F_sPathScreenphotoPNG)
  
  If Img Then 
    PicturePhoto.Picture = Img.Picture
  Else 
    Img = M01Functions.ScreenshotImageDemo()
    If Img Then PicturePhoto.Picture = Img.Picture
    LabelInfo.Text = ("Fehlt: Bild aus der [Zwischenablage]")
    sMessage = "<h3><font color=red>" & ("Ohne Bild") & "</font></h3>"
    sMessage &= "<h3><font color=gray>" & ("Die [Zwischenablage] ist (noch) leer.") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif
  If PicturePhoto.Picture Then 
    F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub PastePictureOpen()
  
  Dim sPathFoto, sFilter1, sFilterText1 As String 
  Dim sPath, sDir As String
  Dim Img As Image
  
  'Beispiel--------------------------
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  'Dialog.Filter = ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .Save(JPG-Datei, Qualität 1 bis 100)
  
  sPathFoto = Settings[FMain.Name &/ "sPathFoto", sPathFoto]
  If Exist(sPathFoto) = True Then 
    sFilter1 = "*" & String.Left(File.BaseName(sPathFoto), 10) & "*." & File.Ext(sPathFoto)
    sFilterText1 = ("letzte Speicherung")
  Endif 
  If Exist(sPathFoto) = False Then 
    sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
    sPathFoto = sDir &/ ("BildDatei.png")
    sFilter1 = "*.png;*.jpg;"
    sFilterText1 = ("Bilder")
  Endif
  sPath = M01Functions.FileDialogOpen(sPathFoto, [sFilter1, sFilterText1, "*.jpeg;*.jpg;*.png;*.bmp;*.xpm;*.svg;", ("Bilder")], ("Einfügen aus Bild-Datei..."))
  If Exist(sPath) = True Then 'Null is Canceled
    PicturePhoto.Picture = Picture.Load(sPath)
    ' PhotoCutArea()
  Else 
    Img = M01Functions.ScreenshotImageDemo()
    If Img Then PicturePhoto.Picture = Img.Picture
    LabelInfo.Text = ("Fehlt: Bild aus der Datei")
  Endif
  If PicturePhoto.Picture Then 
    F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
    SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebViewURL(Optional sFile As String = "colornamessort.htm")
  
  Dim sDirFile, sDir, sFaviconPNG As String 
  
  sDir = "text"
  If Exist(sDir &/ sFile) = False Then sFile = "colornamessort.htm"
  sDirFile = sDir &/ sFile 
  sDirFile = M01Functions.FileRootToTemp(sDirFile)
  If Exist(sDirFile) = True Then 
    WebView1.Url = "file://" & sDirFile
    sFaviconPNG = "text" &/ "favicon.png"
    sFaviconPNG = M01Functions.FileRootToTemp(sFaviconPNG)
    Wait 0.3
  Else 
    WebView1.Url = F_sURLblankempty
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG()
  
  Dim sPathBefore, sDirFile, sDir, sFile, sJPGQuality, sMessage As String
  Dim ssFilter As String[]
  
  F_sSaveFormat = Settings[Form15Foto.Name &/ "F_sSaveFormat", "png"]
  F_iSaveQualityJPG = Settings[Form15Foto.Name &/ "F_iSaveQualityJPG", F_iSaveQualityJPG]
  If F_sSaveFormat = "jpg" Then sJPGQuality = Space(1) & ("Komprimierung=") & F_iSaveQualityJPG & "%"
  
  ''Directory:
  sDir = Desktop.GetDirectory("PICTURES") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If IsDir(sDir) = False Then 
    If IsDir(FMain.F_sDirAppName) = False Then FMain.F_sDirAppName = M01Functions.CheckDirAppName() 'as String
    sDir = FMain.F_sDirAppName
  Endif 
  
  ''New Name:
  sFile = ("BildschirmFoto") & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & "." & F_sSaveFormat
  sDirFile = sDir &/ sFile '"Bildschirmfoto~.tmp.png"
  sPathBefore = Settings[FMain.Name &/ "sPathFoto", sDirFile]
  
  'Dialog DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  ssFilter = New String[]
  
  ssFilter.Add("*" & "." & F_sSaveFormat) '"" Null > Error
  ssFilter.Add(("Neue Speicherung") & Space(1) & ("mit Name+Uhrzeit") & sJPGQuality) 'Text
  
  ssFilter.Add("*" & File.Name(sPathBefore)) 'Filter
  ssFilter.Add(("letzte Speicherung")) 'Text
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Heute") & Space(1) & Format(Now, "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Day, -1), "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Gestern") & Space(1) & Format(DateAdd(Date, gb.Day, -1), "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Monat") & Space(1) & Format(Now, "mmmm"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(Now, "yyyy"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Year, -1), "yyyy-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(DateAdd(Date, gb.Year, -1), "yyyy"))
  
  ssFilter.Add("*.jpg;*.jpeg")
  ssFilter.Add(("Format JPG") & sJPGQuality)
  
  ssFilter.Add("*.gif")
  ssFilter.Add(("Format GIF"))
  
  ssFilter.Add("*.bmp")
  ssFilter.Add(("Format BMP"))
  
  ssFilter.Add("*.xpm")
  ssFilter.Add(("Format XPM"))
  
  ssFilter.Add("*.png") 'Filter
  ssFilter.Add(("Format PNG")) 'Text
  'Dialog.Filter = ["*.png", ("Format PNG"), "*.jpeg", "Format JPG", "*.bmp", "Bitmap BMP", "*.gif", "Format GIF", "*.xpm", "Format XPM", "All files(*.*)"]
  Dialog.Filter = ssFilter '(*), All files wird autom. angehängt
  Dialog.Path = sDir &/ File.BaseName(sFile)
  Dialog.Title = (("Bild speichern..."))
  Dialog.AutoExt = True ''needs component: gb.form.dialog ' Datei.xyz xyz-Ext, extension automatically
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  'nicht abgebrochen,  speichern siehe unten  .Picture.Save
  sDirFile = Dialog.Path
  
  'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  
  If PicturePhoto.Picture Then 
    If LCase(File.Ext(sDirFile)) = "jpg" Then
      PicturePhoto.Picture.Save(sDirFile, F_iSaveQualityJPG) 'only jpg
    Else
      PicturePhoto.Picture.Save(sDirFile)
    Endif
    If Exist(sDirFile) = False Then
      Message.Info(("Fehler. Datei nicht gespeichert"), ("Abbrechen"))
    Else
      Settings[FMain.Name &/ "sPathFoto"] = sDirFile '/sDir/File.xyz
      
      sMessage = "<h3><font color=darkgreen>" & ("Gespeichert") & ":" & "</font></h3>"
      sMessage &= "<font color=gray>" & sDirFile & "</font><br>"
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) 
      
      Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
        Case 1
          M01Functions.FileManagerOpen(sDirFile)
        Case 2
          ''...
      End Select  
      
      LabelInfo.Text = sDirFile 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub CButtons_Enter()
  
  Last.Background = Color.Green
  
  Select Case Last.Tag 
    Case "copy1"
      TextBoxColorName.Background = F_iColorGreenAlpha150
    Case "copy2"
      TextBoxHexaHTML.Background = F_iColorGreenAlpha150
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CButtons_Leave()
  
  Last.Background = Color.Default 
  
  Select Case Last.Tag 
    Case "copy1"
      TextBoxColorName.Background = LabelInfo.Background 
      TextBoxColorName.ForeGround = LabelInfo.ForeGround
    Case "copy2"
      TextBoxHexaHTML.Background = Color.SetAlpha(LabelInfo.Background, 0)
      ' TextBoxHexaHTML.ForeGround = LabelInfo.ForeGround
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CButtons_Click()
  
  Dim iColor As Integer
  
  iColor = Color.SetAlpha(ColorChooser1.SelectedColor, 150)
  
  Select Case Last.Tag 
    
    Case "insert"
      PasteTextBoxColor()
      
    Case "copy1"
      CopyText(TextBoxColorName.Text)
      TextBoxColorName.Background = iColor
      
    Case "copy2"
      CopyText(TextBoxHexaHTML.Text)
      TextBoxHexaHTML.Background = iColor
      
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() 'Top▲ 
  
End 

Public Sub PasteTextBoxColor(Optional sFind As String = Null)
  
  Dim iColor, iRed, iGreen, iBlue, iAlpha, iFound As Integer
  Dim ssSpliLine As String[]
  Dim sLine, sDezi, sValue As String
  Dim hColorInfo As ColorInfo
  Dim sAlpha As String
  
  'sGrad = "°" 'sGrad = chr(176) 'ASCCI only 0 > 128
  
  If Not sFind Then 
    If Clipboard.Type = Clipboard.Text Then 
      sFind = Clipboard.Paste("text/plain")
      ' Wait 0.3
      If Not sFind Then 
        sFind = Clipboard.Paste()
        ' Wait 1
      Endif 
    Endif 
  Endif 
  
  If Not F_ssColorNames Then LoadColorNames()
  
  iFound = -1
  If F_ssColorNames Then 
    sFind = UnQuote(sFind)
    sValue = "*=" & sFind & "=*"
    iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
    If iFound > -1 Then Goto JumpSelect
    
    ''RGB(0,0,0)
    If String.InStr(sFind, ",") > 0 Then ssSpliLine = Split(sFind & String(3, ","), ",")
    If String.InStr(sFind, Space(1)) > 0 Then ssSpliLine = Split(sFind & String(3, Space(1)), Space(1))
    If ssSpliLine Then 
      If IsInteger(ssSpliLine[0]) = True Then iRed = CInteger(ssSpliLine[0])
      If IsInteger(ssSpliLine[1]) = True Then iGreen = CInteger(ssSpliLine[1])
      If IsInteger(ssSpliLine[2]) = True Then iBlue = CInteger(ssSpliLine[2])
      If IsInteger(ssSpliLine[3]) = True Then iAlpha = CInteger(ssSpliLine[3])
      iColor = Color.RGB(iRed, iGreen, iBlue, iAlpha)
      sValue = "*" & Str(iColor) & "*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    sFind = Replace(sFind, Space(1), "")
       
    ''&H00F0F8FF&, #F0F8FF, F0F8FF
    If IsHexa(sFind) Or String.InStr(sFind, "&") > 0 Or String.InStr(sFind, "#") > 0 Then 
      sValue = Replace(sFind, "&H00", "")
      sValue = Replace(sValue, "&H", "")
      sValue = Replace(sValue, "&", "")
      sValue = Replace(sValue, "#", "")
      If IsInteger(sValue) = False And IsHexa(sValue) Then 
        ''Hexa: 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
        iColor = CInteger(Val("&H" & sValue))
        sValue = "*" & Str("&H" & sValue) & "*"
        iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
        If iFound > -1 Then Goto JumpSelect
      Endif 
    Endif
    
    ''0123456789
    If IsDigit(Str(sFind)) Then 
      sValue = sFind
      If IsInteger(sValue) = True Then iColor = CInteger(sValue)
      sValue = "*=" & Str(iColor) & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''Abc...
    If IsAscii(Str(sFind)) And IsInteger(sFind) = False Then 
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsHexa(sValue) Then 
        iColor = CInteger(Val("&H" & sValue))
        ' sValue = String.Right(sValue, 6)
        sValue = "*=" & Str(iColor) & "=*"
        iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
        If iFound > -1 Then Goto JumpSelect
      Endif 
    Endif
    
    ''0123456789
    If IsInteger(sFind) Then 
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsInteger(sValue) Then iColor = CInteger(sValue)
      sValue = "*=" & sValue & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''ABCabc..
    If IsLetter(sFind) Then 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
      If String.Len(sFind) > 6 Then sValue = String.Right(sFind, 8) Else sValue = sFind
      If IsHexa(sValue) Then iColor = CInteger(Val("&H" & sValue))
      sValue = "*" & sValue & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''Hexa: 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
    If IsHexa(sFind) Then  'not IsHexa(...)=True
      sValue = "*=" & sFind & "=*" 
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsInteger(sValue) = True Then 
        iColor = CInteger(sValue)
      Else
        If IsHexa(sValue) Then iColor = CInteger(Val("&H" & sValue))
      Endif 
      ' If String.Len(sValue) > 6 Then sValue = String.Right(sValue, 6) ''#00FF00
      sValue = "*=" & iColor & "=*" 
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
  Endif 
  
JumpSelect:
  If iFound > -1 Then 
    sLine = F_ssColorNames[iFound] 
    ''Example line: "AliceBlue=aliceblue=F0F8FF=240,248,255=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    If sLine Then 
      sLine = Replace(sLine, Space(1), "")
      ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
      ' sColorName = ssSpliLine[0]
      ' sColorNameLower = ssSpliLine[1]
      ' sHex = ssSpliLine[2]
      ' sRGB = ssSpliLine[3]
      sDezi = ssSpliLine[4]
      If IsInteger(sDezi) = True Then 
        iColor = CInteger(sDezi)
        ColorChooser1.SelectedColor = iColor
      Endif 
    Endif 
  Else If IsInteger(Str(iColor)) = True Then 
    ColorChooser1.SelectedColor = iColor
  Else 
    TextBoxHTML.SelectAll()
    TextBoxHTML.Insert(("Kein Farb-Format erkannt") & ": " & gb.NewLine)
    TextBoxDezi.SelectAll()
    TextBoxDezi.Insert("0")
    TextBoxHexa.SelectAll()
    TextBoxHexa.Insert("&H")
    TextBoxHexaHTML.SelectAll()
    TextBoxHexaHTML.Insert("#")
    ' ColorChooser1.SelectedColor = iColor
  Endif  
  
  hColorInfo = Color[ColorChooser1.SelectedColor]
  iAlpha = hColorInfo.Alpha 'Transparent
  If iAlpha > 0 Then sAlpha = " +" & Str(iAlpha) & Space(1) & ("Alpha=Glas") 
  
  LabelInfo.Text = ("Auswahl") & ": " & String.Left(sFind, 20) & sAlpha
  LabelInfo.Tooltip = ("Auswahl") & ": " & String.Left(sFind, 200) & sAlpha
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadColorNames() 
  
  Dim sPath, sText As String 
  
  If Not F_ssColorNames Then 
    sPath = "text/colornames.txt"
    If Exist(sPath) = True Then 
      sText = File.Load(sPath)
      F_ssColorNames = Split(sText & gb.NewLine, gb.NewLine) 'Abc
      F_ssColorNames.Sort()
    Endif 
  Endif 
  
  ''For programmer:
  '.............................
  ' CreateColorNamesHexRGBDezimalSave() '1x if not exist
  ' CreateColorNamesTableHTMLsave() '1x if not exist 
  ' CreateColorNamesTableHTMLColumnView1Save() '1x in file
  ' CreateColorNamesTableHTMLSortsave() '1x in file
  '.............................
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesHexRGBDezimalSave() '1x in file
  
  Dim sDirFile, sDir, sLine, sText As String 
  Dim sColorName, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli As String[]
  Dim iR, iG, iB, iRGB As Integer
  Dim hColorInfo As ColorInfo
  
  If F_ssColorNames Then 
    sText = "#Color-Names html Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & gb.NewLine
    sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
    sDirFile = sDir &/ "colornames.txt"
    For Each sLine In F_ssColorNames
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpli = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpli[0]
        sHex = ssSpli[1]
        ''Example: "#8000"
        Print sHex
        
        If sHex Begins "#" Then 
          sHex = Replace(sHex, "#", "")
          iRGB = CInt(Val("&H" & sHex)) 'ssSpli[2]
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha '0
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          ''Example: "Green=008000=0,128,0=32768="
          sLine = sColorName & "=" & String.UCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    File.Save(sDirFile, sText)
    Print sText
    Desktop.Open(sDirFile)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLsave() '1x in file
  
  Dim sDirFile, sDirFileHTML, sStyle, sDir, sLine, sText, sHTML, sInfo As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli, ssSpliLine As String[]
  Dim iR, iG, iB, iRGB, iCounter As Integer
  Dim hColorInfo As ColorInfo
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDirFile = sDir &/ "colornames.txt"
  sDirFileHTML = File.SetExt(sDirFile, "htm")
  
  If Exist(sDirFile) = True Then 
    sText = File.Load(sDirFile)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    
    sInfo = ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "gray = grey, aqua = cyan, fuchsia = magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote("2024 color-table: design-cad.de (Freeware)") & ">" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '" text / css ""
    ' sStyle &= "strong  {width: 90%; color: limegreen;}" & gb.NewLine 
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; font-weight: normal;}" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; text-decoration: none;}" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    sHTML &= "<h1>" & ("Farb-Tabelle mit Namen") & "</h1>" & gb.NewLine
    sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
    sHTML &= "<tr>" & gb.NewLine
    sHTML &= "<td colspan=1 align=right valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=2 align=left valign=top>" & "<b>" & ("Farbe") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=3 align=left valign=top>" & "<b>" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=4 align=left valign=top>" & "<b>" & ("Name") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=5 align=left valign=top>" & "<b>" & ("RGB(0,0,0)") & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=6 align=right valign=top>" & "<b>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=7 align=right valign=top>" & "<b>" & ("Luminance") & "</b>" & "<br>" & ("Helligkeit") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=8 align=right valign=top>" & "<b>" & ("Saturation") & "</b>" & "<br>" & ("Sättigung") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=9 align=right valign=top>" & "<b>" & ("HUE") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "</tr>" & gb.NewLine
    
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpliLine[0]
        sHex = ssSpliLine[2]  ''Example: "F0F8FF"
        sHex = Replace(sHex, "#", "")
        sHex = Replace(sHex, "&H", "")
        sHex = Replace(sHex, "&", "")
        sHex = "#" & sHex
        ' sRGB = ssSpliLine[2]
        sDezi = ssSpliLine[4]
        
        If IsInteger(sDezi) = True Then 
          iRGB = CInteger(sDezi)
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha 
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          If hColorInfo.Luminance < 150 Then 
            sColorNameFG = "<font color=white>" & sColorName & "</font>" 
          Else 
            sColorNameFG = "<font color=black>" & sColorName & "</font>"
          Endif 
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          iCounter = iCounter + 1
          ''Example: "Green=008000=0,128,0=32768="
          sHTML &= "<tr>" & gb.NewLine
          sHTML &= "<td colspan=1 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
          sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
          sHTML &= "<td colspan=3 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
          sHTML &= "<td colspan=4 align=left valign=top>" & sColorName & "</td>" & gb.NewLine
          sHTML &= "<td colspan=5 align=left valign=top>" & sRGB & "</td>" & gb.NewLine
          sHTML &= "<td colspan=6 align=right valign=top>" & sDezi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=7 align=right valign=top>" & sLumi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=8 align=right valign=top>" & sSatu & "</td>" & gb.NewLine
          sHTML &= "<td colspan=9 align=right valign=top>" & sHue & "</td>" & gb.NewLine
          sHTML &= "</tr>" & gb.NewLine
          sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    sHTML &= "</table>" & gb.NewLine
    sHTML &= "<br>" & gb.NewLine
    sHTML &= sInfo
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    ''Save:
    File.Save(sDirFileHTML, sHTML)
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    File.Save(sDirFileHTML & ".txt", sText)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    
    ''Show:
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLSortsave() '1x in file
  
  Dim sDirFile, sDirFileHTML, sStyle, sDir, sLine, sText, sHTML, sInfo As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli, ssSpliLine As String[]
  Dim iR, iG, iB, iRGB, iCounter As Integer
  Dim hColorInfo As ColorInfo
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDirFile = sDir &/ "colornames.txt"
  sDirFileHTML = File.SetExt(sDirFile, "htm")
  
  If Exist(sDirFile) = True Then 
    sText = File.Load(sDirFile)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    
    sInfo = ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "gray = grey, aqua = cyan, fuchsia = magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote("2024 color-table: design-cad.de (Freeware)") & ">" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '" text / css ""
    ' sStyle &= "strong  {width: 90%; color: limegreen;}" & gb.NewLine 
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; font-weight: normal;}" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; text-decoration: none;}" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    sHTML &= "<h1>" & ("Farb-Tabelle mit Namen") & "</h1>" & gb.NewLine
    sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
    sHTML &= "<tr>" & gb.NewLine
    sHTML &= "<td colspan=1 align=right valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=2 align=left valign=top>" & "<b>" & ("Farbe") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=3 align=left valign=top>" & "<b>" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=4 align=left valign=top>" & "<b>" & ("Name") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=5 align=left valign=top>" & "<b>" & ("RGB(0,0,0)") & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=6 align=right valign=top>" & "<b>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=7 align=right valign=top>" & "<b>" & ("Luminance") & "</b>" & "<br>" & ("Helligkeit") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=8 align=right valign=top>" & "<b>" & ("Saturation") & "</b>" & "<br>" & ("Sättigung") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=9 align=right valign=top>" & "<b>" & ("HUE") & "</b>" & "<br>" & ("360°") & "</td>" & gb.NewLine
    sHTML &= "</tr>" & gb.NewLine
    
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpliLine[0]
        sHex = ssSpliLine[2]  ''Example: "F0F8FF"
        sHex = Replace(sHex, "#", "")
        sHex = Replace(sHex, "&H", "")
        sHex = Replace(sHex, "&", "")
        sHex = "#" & sHex
        ' sRGB = ssSpliLine[2]
        sDezi = ssSpliLine[4]
        
        If IsInteger(sDezi) = True Then 
          iRGB = CInteger(sDezi)
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha 
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          If hColorInfo.Luminance < 150 Then 
            sColorNameFG = "<font color=white>" & sColorName & "</font>" 
          Else 
            sColorNameFG = "<font color=black>" & sColorName & "</font>"
          Endif 
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          iCounter = iCounter + 1
          ''Example: "Green=008000=0,128,0=32768="
          sHTML &= "<tr>" & gb.NewLine
          sHTML &= "<td colspan=1 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
          sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
          sHTML &= "<td colspan=3 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
          sHTML &= "<td colspan=4 align=left valign=top>" & sColorName & "</td>" & gb.NewLine
          sHTML &= "<td colspan=5 align=left valign=top>" & sRGB & "</td>" & gb.NewLine
          sHTML &= "<td colspan=6 align=right valign=top>" & sDezi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=7 align=right valign=top>" & sLumi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=8 align=right valign=top>" & sSatu & "</td>" & gb.NewLine
          sHTML &= "<td colspan=9 align=right valign=top>" & sHue & "</td>" & gb.NewLine
          sHTML &= "</tr>" & gb.NewLine
          sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    sHTML &= "</table>" & gb.NewLine
    sHTML &= "<br>" & gb.NewLine
    sHTML &= sInfo
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    ''Save:
    File.Save(sDirFileHTML, sHTML)
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    File.Save(sDirFileHTML & ".txt", sText)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    
    ''Show:
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColorGroup_Click()
  
  F_sBackgroundColorOrPath = M01Functions.CheckFormBackgroundColorValue(Last.Tag) 'as String  
  FormBackgroundColor()
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  CheckFormBackgroundColor()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Menu1_Show()
  
  Dim it As Integer
  
  CreateMenuColorPicture()
  
  ''Checked:
  For it = 0 To Menu1.Children.Count - 1
    If Menu1.Children[it].Tag And F_sBackgroundColorOrPath Like "*" & Menu1.Children[it].Tag & "*" Then Menu1.Children[it].Checked = True Else Menu1.Children[it].Checked = False
  Next 
  If IsInteger(F_sBackgroundColorOrPath) = True Then MenuBackgroundMyColor.Checked = True Else MenuBackgroundMyColor.Checked = False
  
  mnuKopieren02.Text = mnuKopieren01.Text & Space(1) & ("Zoom") & Space(1) & F_fZoomFactor & "x"
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateMenuColorPicture()
  
  Dim Img As Image 
  Dim iColor As Integer
  
  iColor = Settings[FMain.Name &/ "ColorButton1.Value", Color.Background]
  
  Img = M01Functions.ColorCreateButton(32, 32, iColor) ' as Image
  
  MenuBackgroundMyColor.Picture = Img.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFormBackgroundColor()
  
  PicBoxColorApplyTop.Picture = PicTemplateCheckoff.Picture
  PicBoxWoodTop.Picture = PicTemplateCheckoff.Picture
  PicBoxMetalTop.Picture = PicTemplateCheckoff.Picture
  
  Select Case F_sBackgroundColorOrPath
    Case Like "*wood*"
      PicBoxWoodTop.Picture = PicTemplateCheckON.Picture
    Case Like "*holz*"
      PicBoxWoodTop.Picture = PicTemplateCheckON.Picture
      
    Case Like "*metal*"
      PicBoxMetalTop.Picture = PicTemplateCheckON.Picture
    Case Like "*alu*"
      PicBoxMetalTop.Picture = PicTemplateCheckON.Picture
      
    Case CInteger(PicBackground.Background)
      PicBoxColorApplyTop.Picture = PicTemplateCheckON.Picture
      PicBoxColorApplyTop.Background = PicBackground.Background
    Case Else 
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ApplyG()
  
  Dim iColor As Integer
  
  If PicBackground.Picture Then 
    If Not F_sBackgroundColorOrPath Then F_sBackgroundColorOrPath = "wood"
    Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
  Else 
    iColor = ColorChooser1.SelectedColor
    F_sBackgroundColorOrPath = iColor
    PicBoxColorApplyTop.Background = iColor
    Settings[FMain.Name &/ "FormBackgroundColor"] = iColor   'Path or Color  
    Settings[FMain.Name &/ "ColorButton1.Value"] = iColor
  Endif 
  
  M01Functions.FormsBackgroundColorAll()
  ' F_sBackgroundColorOrPathEnter = F_sBackgroundColorOrPath
  F_iBackgroundColorEnter = PicBackground.Background
  ButtonApply.Picture = PicTemplateCheckON.Picture
  Wait 0.5 'show effect
  ButtonApply.Background = Color.Default 
  ButtonApply.Picture = PicTemplateApply.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomHasFocus(Optional bMouseForward As Boolean = True)
  
  ' If PicturePhoto.HasFocus = True Then 
  If F_fZoomFactor < 1.2 Then 
    If bMouseForward = False Then 
      F_fZoomFactor = F_fZoomFactor - 0.1
    Else
      F_fZoomFactor = F_fZoomFactor + 0.1
    Endif
  Else 
    If bMouseForward = False Then 
      F_fZoomFactor = F_fZoomFactor - 0.5
    Else
      F_fZoomFactor = F_fZoomFactor + 0.5
    Endif  
  Endif 
  If F_fZoomFactor < 0.2 Then F_fZoomFactor = 0.2  'Min.
  Me.Title = Application.Name & " - " & ("Zoom") & ": " & Round(F_fZoomFactor, -1) 'Example: 1.2
  ' Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicturePhoto_Enter()
  
  PicBoxZoomCross.Picture = PicTemplateZoomCross.Picture
  PicBoxZoomCross.Visible = True 
  PicturePhoto.Visible = True 
  PicturePhoto.Background = Color.Transparent
  LabelInfo.Text = ("Einen Farbpunkt auswählen")
  If F_sForm21ColorsText Then LabelInfo.Text &= gb.NewLine & F_sForm21ColorsText
  
Catch
  FMain.ErrorText
  
End 

Public Sub PicturePhoto_Leave()
  ' If F_imgZoomLupe Then PicBoxZoomCross.Picture = F_imgZoomLupe.Picture
  
  PicBoxZoomCross.Visible = False 
  ' PicturePhoto.Visible = False  
  PicturePhoto.Background = Color.Default
  LabelInfo.Text = ("Farbpunkt aus Foto")
  ' TimerZoomLupe.Stop()
  
Catch
  FMain.ErrorText
  
End

Public Sub PicturePhoto_MouseDown()
  
  Dim Img As Image
  
  If Mouse.Left Then 
    If PicturePhoto.Picture Then
      Img = PicturePhoto.Picture.Image.Stretch(PicturePhoto.W, PicturePhoto.H) 
      F_iColorPicker = Img[Mouse.X, Mouse.Y]
      F_imgScreen = Img.Copy()
      ColorChooser1.SelectedColor = F_iColorPicker
      SideG(1)
    Endif 
    F_pointPickerXY = Point(Mouse.X, Mouse.Y) 
  Endif 
  ' If Mouse.Right Then Menu1.Popup() 'PhotoColorPickerG() 'siehe Eigenschaften
  
Catch
  FMain.ErrorText
  
End

Public Sub ColorFindSelected()
  
  Dim it As Integer = -1
  
  If F_oPicBoxColorFind Then 
    
    If F_iiIconClockColorsB Then it = F_iiIconClockColorsB.Find(ColorChooser1.SelectedColor) '-1 not found
    
    If it > -1 Then 
      If F_ooPicBoxesColorsA And F_ooPicBoxesColorsB Then 
        F_oPicBoxColorFind.Move(F_ooPicBoxesColorsB[it].Left, F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H, F_ooPicBoxesColorsB[it].W, F_ooPicBoxesColorsB[it].Top - (F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H))
      Else 
        it = -1
      Endif 
    Endif
    If it = -1 Then F_oPicBoxColorFind.Visible = False Else F_oPicBoxColorFind.Visible = True
  Endif 
  
  
  If F_oPicBoxColorLast Then
    If F_iColorBoxesPointer > -1 Then it = F_iColorBoxesPointer Else it = 0
    If F_ooPicBoxesColorsA And F_ooPicBoxesColorsB Then 
      F_oPicBoxColorLast.Move(F_ooPicBoxesColorsB[it].Left, F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H, F_ooPicBoxesColorsB[it].W, F_ooPicBoxesColorsB[it].Top - (F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H))
    Else 
      it = -1
    Endif 
    If it = -1 Then F_oPicBoxColorLast.Visible = False Else F_oPicBoxColorLast.Visible = True
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub PicturePhoto_MouseWheel()
  
  ZoomHasFocus(Mouse.Forward)   '.Forward as Boolean True/False
  
Catch 
  FMain.ErrorText  
  
End

Public Sub PicBoxZoomLupe_MouseWheel()
  
  ZoomHasFocus(Mouse.Forward)   '.Forward as Boolean True/False
  
  ZoomLupeG()
  
Catch 
  FMain.ErrorText  
  
End

Public Sub PicBoxZoomLupe_MouseDown()
  
  Dim Img As Image
  
  If Mouse.Left Then 
    If PicBoxZoomLupe.Picture Then 
      Img = PicBoxZoomLupe.Picture.Image.Stretch(PicBoxZoomLupe.W, PicBoxZoomLupe.H)
      F_iColorPicker = Img[Mouse.X, Mouse.Y]
      ColorChooser1.SelectedColor = F_iColorPicker
      LabelInfo.Background = F_iColorPicker
      CheckFontForeground()
      SideG(1)
    Endif
  Endif 
  
  If Mouse.Right And PicBoxZoomLupe.Picture Then 
    ' Img = PicBoxZoomLupe.Picture.Image.Stretch(PicBoxZoomLupe.W, PicBoxZoomLupe.H)
    ' PicBoxCopyImage.Picture = Img.Picture '.Copy(Mouse.ScreenX - (PanelColorZoom.W / 2), Mouse.ScreenY - (PanelColorZoom.H / 2)).Picture
    CopyButtonG("zoom")
  Endif 
  
Catch 
  FMain.ErrorText  
  
End

Public Sub PhotoG()
  
  PhotoScreen()
  SideG(2)
  TimerZoomLupe.Start()
  LabelInfo.Text = ("Pipette: Einen Farbpunkt auswählen")
  ' PicturePhoto.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoColorPickerG()
  
  PanelCopyImage.Visible = False 
  ' PicturePhoto.Visible = True 
  PanelWebTextCode.Visible = False 
  ColumnView1.Visible = False
  ColorChooser1.Visible = False 
  
  If PicturePhoto.Visible = False Then 
    PicturePhoto.Visible = True
    If Not PicturePhoto.Picture Then PhotoScreen()
    TimerZoomLupe.Start()
    LabelInfo.Text = ("Pipette: Einen Farbpunkt auswählen")
  Else 
    PicturePhoto.Visible = False
    ' TimerZoomLupe.Stop()
    ColorChooser1.Visible = True  
    ColorChooser1.SelectedColor = F_iColorPicker
    LabelInfo.Text = ("Farbwahl nacharbeiten")
  Endif 
  If F_sForm21ColorsText Then LabelInfo.Text &= gb.NewLine & F_sForm21ColorsText
  
Catch 
  FMain.ErrorText
  
End

Public Sub SidePhotoG(Optional sPhoto As String = "")
  
  PanelCopyImage.Visible = False
  PanelWebTextCode.Visible = False
  ColumnView1.Visible = False 
  ColorChooser1.Visible = False 
  
  If sPhoto = "photo" Or PicturePhoto.Visible = False Then 
    PicturePhoto.Visible = True
    PicturePhoto.Raise()
    TimerZoomLupe.Start()
  Else 
    PicturePhoto.Visible = False
    ColorChooser1.Visible = True 
    ' TimerZoomLupe.Stop()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideG(Optional iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 As Integer = 0)
  TimerZoomLupe.Stop()
  ColorChooser1.Visible = False 
  PicturePhoto.Visible = False
  PanelWebTextCode.Visible = False
  PanelCopyImage.Visible = False
  WebView1.Visible = False 
  TextAreaText.Visible = False 
  TextAreaCode.Visible = False
  ColumnView1.Visible = False 
  PicBoxWebColorNamesSort.Border = Border.None
  PicBoxColumnviewColorNamesFind.Border = Border.None
  PicBoxColorChooser.Border = Border.None
  ' PicBoxMemoryColors.Border = Border.None
  WindowT5plus.Picture = PicTemplatePageMini.Picture
  
  ' If F_iLastSide = iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 Then 
  '   iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 = 2
  ' Endif
  
  Select Case F_iLastSide
    Case 1
      PicBoxColorChooser.Border = Border.Plain
    Case 3
      PicBoxColumnviewColorNamesFind.Border = Border.Plain
    Case 4
      PicBoxWebColorNamesSort.Border = Border.Plain
  End Select
  
  Select Case iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
    Case 0
      ''...
    Case 1 ''ColorChooser
      ColorChooser1.Visible = True  
      PicBoxColorChooser.Border = Border.Plain
      F_iLastSideBefore = F_iLastSide
    Case 2 ''Photo
      PicturePhoto.Visible = True
      TimerZoomLupe.Start()
      F_iLastSideBefore = F_iLastSide
    Case 3 ''ColumnView
      PanelWebTextCode.Visible = True 
      ColumnView1.Visible = True  
      PicBoxColumnviewColorNamesFind.Border = Border.Plain
      If ColumnView1.Columns.Max < F_iColumns14Count Then 
        ColumnView1.Clear
        ReadG()
        ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      Endif 
      F_iLastSideBefore = F_iLastSide
    Case 4  ''Web, HTML
      PanelWebTextCode.Visible = True 
      WebView1.Visible = True 
      WebView1.FindText(TextBoxHexaHTML.Text, False, True, False) 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      PanelWebTextCode.Raise()
      TextAreaSearch.SelectAll()
      TextAreaSearch.Insert(TextBoxColorName.Text)
      PicBoxWebColorNamesSort.Border = Border.Plain
      F_iLastSideBefore = F_iLastSide
    Case 5 ''CopyImage
      PanelCopyImage.Visible = True 
    Case 6 ''Text
      PanelWebTextCode.Visible = True 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      TextAreaText.Wrap = False '---line---->|
      TextAreaText.Visible = True 
      TextAreaText.SelectAll()
      TextAreaText.Insert(TextBoxHTML.Text & gb.NewLine & gb.NewLine & ColorRGBtoHUEinfo(ColorChooser1.SelectedColor) & gb.NewLine & gb.NewLine & WebView1.Text)
      TextAreaText.Pos = 1
      WindowT5plus.Picture = PicTemplatePageMaxi.Picture
      F_iLastSideBefore = F_iLastSide
      
    Case 7 ''Code
      PanelWebTextCode.Visible = True 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      TextAreaCode.Visible = True 
      TextAreaCode.SelectAll()
      TextAreaCode.Insert(WebView1.Document.HTML)
      TextAreaCode.Pos = 1
      F_iLastSideBefore = F_iLastSide
    Case Else 
      ''...
  End Select
  
  F_iLastSide = iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  
  If PicturePhoto.Visible = False And F_rectZoom Then 
    PicBoxZoomLupe.Picture = PicturePhoto.Picture
    ' PicBoxZoomLupe.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)
    PicBoxZoomLupe.Move(F_rectZoom.X, F_rectZoom.Y, F_rectZoom.W, F_rectZoom.H)
    PicBoxZoomLupe.Visible = True 
  Endif 

  If ColorChooser1.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
  If PicturePhoto.Visible = False Then PicBoxPickerColor.Background = Color.Default
  If Not PicturePhoto.Picture Then 
    F_picScreen = PicBoxPhoto.Picture
    PicturePhoto.Picture = F_picScreen
    PicBoxZoomLupe.Picture = F_picScreen
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function ColorRGBtoHUEinfo(Optional iColorDezi As Integer = 0) As String 
  
  Dim hColorInfo As ColorInfo
  Dim sText As String 
  hColorInfo = color[iColorDezi]
  sText = "Color.RGB(" & hColorInfo.Red & ", " & hColorInfo.Green & ", " & hColorInfo.Blue & ", " & hColorInfo.Alpha & ")" & gb.NewLine & ("RGBA(Red, Green, Blue, Alpha)") & Space(5) & ("0 bis 255") & gb.NewLine & ("RGBA(Rot, Grün, Blau, Transparenz (Durchsichtigkeit))") & gb.NewLine & gb.NewLine
  sText &= "Color.HSV(" & hColorInfo.Hue & ", " & hColorInfo.Saturation & ", " & hColorInfo.Luminance & ")" & gb.NewLine & "HSV(HUE, Saturation, Luminance)" & Space(5) & "360°" & gb.NewLine & "HSV(Farbwert, Sättigung, Luminance Helligkeit)" & gb.NewLine

  Return sText
  
  Catch 
  FMain.ErrorText
  
End

Public Sub PhotoColorPickerLatest(Optional sLoadSaveReset As String = "load")
  
  Dim sDir, sFile, sDirFile As String 
  Dim picPhoto As Picture
  
  sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  sFile = "photocolorpickerlatest.png"
  sDirFile = sDir &/ sFile
  
  Select Case sLoadSaveReset
    Case "save"
      If IsDir(sDir) = True And PicturePhoto.Picture Then 
        PicturePhoto.Picture.Save(sDirFile)
      Endif
      
    Case "load"
      If Exist(sDirFile) = True Then 
        picPhoto = Picture.Load(sDirFile)
        If picPhoto Then 
          PicturePhoto.Picture = picPhoto.Copy()
          F_picScreen = PicturePhoto.Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
          UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
        Endif 
      Endif
      SideG(2)  'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "reset"
      F_iLastSide = 1
      SideG(2)  'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      If Not F_picPhotoLastUndo Then 
        F_sBackgroundColorOrPathUndo = F_sBackgroundColorOrPath
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
        F_picPhotoLastUndo = PicturePhoto.Picture
        F_sColorValueUndo1 = TextBoxHTML.Text
        F_sColorValueUndo2 = TextBoxHexa.Text
        F_sColorValueUndo3 = TextBoxDezi.Text
        PicturePhoto.Picture = Null
        PicBoxZoomLupe.Picture = Null
        If Exist(sDirFile) = True Then Kill sDirFile
        TextBoxHTML.Clear
        TextBoxHexa.Clear
        TextBoxDezi.Clear
        TextBoxColorName.Clear
        TextBoxHexaHTML.Clear
        TextBoxColorName.Background = Color.Default 
        TextBoxColorName.Foreground = Color.Default
        TextBoxHexaHTML.Background = Color.Default 
        TextBoxHexaHTML.Foreground = Color.Default
        F_imgScreen = M01Functions.ScreenshotImageDemo(PicBackground.ScreenX, PicBackground.ScreenY, PicBackground.W, PicBackground.H)
        If F_imgScreen Then 
          PicturePhoto.Picture = F_imgScreen.Picture
          F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          F_picScreen = F_imgScreen.Picture
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
        Endif
        LabelInfo.Text = "-1x" & Space(1) & ("Reset") & "=Null"
      Else 
        F_sBackgroundColorOrPath = F_sBackgroundColorOrPathUndo
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
        F_imgScreen = F_picPhotoLastUndo.Image
        If F_imgScreen Then 
          PicturePhoto.Picture = F_imgScreen.Picture
          F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          F_picScreen = F_imgScreen.Picture
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
        Endif
        ' F_picScreen = F_picPhotoLastUndo
        ' If F_picScreen Then F_imgScreen = F_picScreen.Image
        TextBoxHTML.SelectAll()
        TextBoxHTML.Insert(F_sColorValueUndo1)
        TextBoxHexa.SelectAll()
        TextBoxHexa.Insert(F_sColorValueUndo2)
        TextBoxDezi.SelectAll()
        TextBoxDezi.Insert(F_sColorValueUndo3)
        ColorSelected()
        F_picPhotoLastUndo = Null
        LabelInfo.Text = "+1x" & Space(1) & ("Wiederherstellung")
      Endif 
      LabelInfo.Tooltip = ("Info-Zeile")
      FormBackgroundColor()
      If F_sBackgroundColorOrPath <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      TimerZoomLupe.Start()
  End Select
  
Catch 
  FMain.ErrorText
  
End 

Public Sub ColumnView1_Click()
  
  If ColumnView1.Current Then 
    LabelInfo.Text = ("Auswahl") & ": " & ColumnView1.Current[1]
    LabelInfo.Tooltip = LabelInfo.Text
    PasteTextBoxColor(ColumnView1.Current[1])
    ' TextBoxHTML.SelectAll()
    ' TextBoxHTML.Insert(ColumnView1.Current[1])
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_MouseUp() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    If WebView1.SelectedText Then 
      LabelInfo.Text = ("Auswahl") & ": " & WebView1.SelectedText 
      LabelInfo.Tooltip = ("Auswahl") & ": " & String.Left(WebView1.SelectedText, 200) 
      LabelCopyExample.Text = LabelInfo.Text
      If WebView1.SelectedText Then 
        PasteTextBoxColor(WebView1.SelectedText)
        ' TextBoxHTML.SelectAll()
        ' TextBoxHTML.Insert(WebView1.SelectedText)
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  If ColumnView1.Columns.Count < F_iColumns14Count Then  
    ColumnView1.Columns.Count = F_iColumns14Count     'Columns:|0|1|2|3|...|max|
  Endif 
  ColumnView1.Header = True                            'Title, Row index=0
  ColumnView1.Mode = Select.Single
  ColumnView1.AutoResize = True                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ' ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[1].Alignment = Align.Left                                           '|123  |
  ColumnView1.Columns[2].Alignment = Align.Left                                           '|123  |
  ColumnView1.Columns[3].Alignment = Align.Left                                         
  ColumnView1.Columns[4].Alignment = Align.Left                                         
  
  ''Name, name, Hex, RGB, Dezi, Lumi, Satu, HUE
  ColumnView1.Columns[0].Title = "▲▽" & ("Zeile")
  ColumnView1.Columns[1].Title = ("Farb-Name" & String(20, Space(1)))     'SpringGreen
  ColumnView1.Columns[2].Title = ""   'Name lcase
  ColumnView1.Columns[3].Title = ("#Hexadezimal")    '
  ColumnView1.Columns[4].Title = ("RGB(0,0,0)")    '
  ColumnView1.Columns[5].Title = ("Dezimal")       '
  ColumnView1.Columns[6].Title = ("□Helligkeit")       '
  ColumnView1.Columns[7].Title = ("■Sättigung")     
  ColumnView1.Columns[8].Title = ("HUE°")  
  ColumnView1.Columns[9].Title = ("○Rot")    
  ColumnView1.Columns[10].Title = ("○Grün")       '
  ColumnView1.Columns[11].Title = ("○Blau")       '
  ' ColumnView1.Columns[F_iColumn12Sort].Title = ("Sort") 
  ColumnView1.Columns[13].Title = ""    'Undo Line
  
  ' For it = 0 To ColumnView1.Columns.Max     '>9 or >13
  '   ' ColumnView1.Columns[it].Title = ""         'ColumnsUndo
  '   ColumnView1.Columns[it].Alignment = Align.Right   
  ' Next 
  '.AutoResize width = longest filename
  ' ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[F_iColumnUndo].Left 
  
  ' ColumnViewAscending()
  ColumnView1.AutoResize = False 
  ColumnView1.Columns[2].Width = 0  'Name lcase
  ColumnView1.Columns[13].Width = 0
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ReadG()
  
  Dim sKey, sPath, sText, sLine, sRGB, sR, sG, sB, sLineUndo As String 
  Dim ssSpli, ssColumns, ssRGB As String[]
  Dim it, iNr, iColor As Integer
  
  ColumnView1.Clear()
  ColumnView1Resize()
  
  sPath = "text" &/ "colornames.txt"   ''Load from program directory
  ColumnView1.Columns.Sort = 1'F_iColumn12Sort
  ColumnView1.Sorted = True 
  
  If Exist(sPath) = False Then ColumnView1.Columns[1].Title = ("Fehlt") & ": " & sPath
  
  If Exist(sPath) = True Then 
    sText = File.Load(sPath)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    'Example Line: 1= "AliceBlue=aliceblue=#F0F8FF=240,248,255=15792383=246=15=208="
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If String.InStr(sLine, "=") > 0 Then 
        iNr = iNr + 1
        ssColumns = Split(Str(iNr) & "=" & sLine & String(F_iColumns14Count, "="), "=")
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
        sKey = Str(ColumnView1.Count + 1)
        ColumnView1.Add(sKey, "")
        
        sLineUndo = ""
        For it = 0 To F_iColumns14Count - 1 
          ColumnView1[sKey][it] = UnQuote(ssColumns[it])
          sLineUndo &= ColumnView1[sKey][it] & gb.Tab
        Next
        ColumnView1[sKey][F_iColumns13Undo] = sLineUndo
        sRGB = ColumnView1[sKey][4]
        ssRGB = Split(sRGB & String(2, ","), ",")
        sR = ssRGB[0]
        sG = ssRGB[1]
        sB = ssRGB[2]
        ColumnView1[sKey][9] = sR
        ColumnView1[sKey][10] = sG
        ColumnView1[sKey][11] = sB
        iColor = CInteger(ColumnView1[sKey][5]) 
        ColumnView1[sKey].Background = iColor
        If M01Functions.ColorInfoRGB(iColor, "L") < 150 Then ColumnView1[sKey].Foreground = Color.White Else ColumnView1[sKey].Foreground = Color.Black
      Endif 
    Next
    For it = 4 To ColumnView1.Columns.Max   
      ColumnView1.Columns[it].Alignment = Align.Right   
    Next 
    ' ColumnView1Resize()
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0) 'unused?
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView1.Visible = False Then 
    If iSortColumnNr < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True 'Important (wichtig)
      ' If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView1.Columns.Sort <> iSortColumnNr Then ColumnView1.Columns.Sort = iSortColumnNr 
      If ColumnView1.Selection.Max > -1 Then
        sKey = ColumnView1.Selection.Last  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function ColumnView1SortReturnText(Optional iSort As Integer = 0) As String
  
  Dim sKey, sText As String 
  Dim M As Integer = -1
  Dim it, it2, iLine, iNumber As Integer
  
  If ColumnView1.Columns.Max < F_iColumns14Count Then '|0|1|2|3|4|5|6|7|8|9|10|11|12|13| 
    ColumnView1.Clear
    ReadG()
    ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
  Endif 
  If iSort < 0 Then iSort = 0 
  If iSort > ColumnView1.Columns.Max Then iSort = ColumnView1.Columns.Max
  
  If ColumnView1.Columns.Count >= F_iColumns14Count Then 
    ColumnView1.Sorted = False            ' sortieren
    ' ColumnView1.Columns.Ascending = True ' A —▶ Z
    For Each sKey In ColumnView1.Keys
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView1[sKey][F_iColumn12Sort] = ColumnView1[sKey][iSort]
      If IsInteger(ColumnView1[sKey][F_iColumn12Sort]) = True Then 
        iNumber = ColumnView1[sKey][F_iColumn12Sort]
        ColumnView1[sKey][F_iColumn12Sort] = Format(iNumber, String(11, "0"))
      Else If IsHexa(Replace(ColumnView1[sKey][F_iColumn12Sort], "#", "")) Then  'without = TRUE!
        ColumnView1[sKey][F_iColumn12Sort] = Replace(ColumnView1[sKey][F_iColumn12Sort], "#", "")
      Endif 
    Next
    ColumnView1.Sorted = True
    ' ColumnView1.Columns.Sort = 0
    ' ColumnView1.Columns.Sort = ColumnView1.Columns.Max '12
    ''...........................................
    ColumnView1.Columns.Sort = F_iColumn12Sort 'Sortiert nach Spalte   0|1|2|3|4|5|6|7|8|9|10|11|12|...
    ''...........................................
    
    sText = Null
    M = ColumnView1.MoveFirst()
    ' For Each sKey In ColumnView1.Keys
    For it = 1 To ColumnView1.Count - 1
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If it = 0 Then 
        M = ColumnView1.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
      Else 
        M = ColumnView1.MoveBelow() '▼down
      Endif 
      If M = 0 Then 
        sKey = ColumnView1.Item.Key 'Gambas3: "Returns the item pointed by the internal cursor, or NULL if the internal cursor is not available."
        ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
        For it2 = 1 To ColumnView1.Columns.Max
          sText &= ColumnView1[sKey][it2] & "="
        Next  
        sText &= gb.NewLine
      Endif  
    Next 
    Print sText 
    ' File.Save(sDirFile, sText)
  Endif 
  
  Return sText 
  
Catch
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLColumnView1Save() '1x in file
  
  Dim sPathFaviconPNG, sPathProgram, sDirFile, sDirFileHTML, sDir, sFile, sFileHTML, sLine, sTitle, sText, sText2, sTextTXT, sTextCSV As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue, sRGBfont As String
  Dim ssSpli, ssSpliLine, ssBG As String[]
  Dim iR, iG, iB, iRGB, iCounter, iTable As Integer
  Dim hColorInfo As ColorInfo
  Dim sStyle, sHTML, sInfo As String
  
  sRGBfont = "<font color=red>" & "0" & "</font>,<font color=green>" & "0" & "</font>,<font color=blue>" & "0" & "</font>"
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] 'Example: /home/<user>/terminwecker/...
  sFile = "colornames.txt"
  sDirFile = sDir &/ sFile
  
  If Exist(sDirFile) = True Then Kill sDirFile
  sPathProgram = "text" &/ sFile 'Path relativ
  Copy sPathProgram To sDirFile
  sPathFaviconPNG = sDir &/ "favicon.png"
  sPathProgram = "text" &/ "favicon.png"
  If Exist(sPathFaviconPNG) = True Then Kill sPathFaviconPNG
  Copy sPathProgram To sPathFaviconPNG
  
  sDirFileHTML = sDir &/ File.BaseName(sDirFile) & "sort" & ".htm"
  sFileHTML = File.Name(sDirFileHTML)
  
  ''Tabellenprogramm autom. Spalte mit gb.Tab, Kommata ",", ";" Voreinstellung?
  sTitle = "#" & "Farb-Name|abc|#Hexadezimal|RGB(0+0+0)|Dezimal|□Helligkeit|■Sättigung|HUE360°|○Rot|○Grün|○Blau-Anteil|" & gb.NewLine
  
  If IsDir(sDir) = True Then    
    sInfo = ("(Color names, Source reference)") & ", " & ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "*gray = *grey, Aqua = Cyan, Fuchsia = Magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & Space(1) & Application.Name & String.Left(Application.Version, 1) & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote(("Color table created by: 2024 design-cad.de (Freeware)") & Space(1) & Application.Name & String.Left(Application.Version, 1)) & ">" & gb.NewLine
    sHTML &= "<meta name=author content=design-cad.de>" & gb.NewLine
    sHTML &= "<meta name=Keywords lang=de content=" & Quote("Farb-Namen, Farben, Tabelle, HTML") & ">" & gb.NewLine
    sHTML &= "<link rel=icon href=favicon.png type=image/png>" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '"text/css"
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; }" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; }" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''............................................................
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    For iTable = 0 To 10
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      If iTable = 1 Then Continue 'with iTable=2
      iCounter = 0 'Reset
      sText = Null
      
      ''++++++++++++++++++++++++++++++++++++++++++++++++++++++
      sText = ColumnView1SortReturnText(iTable + 1)
      ' Print sText
      ''++++++++++++++++++++++++++++++++++++++++++++++++++++++
      
      ssSpli = Split(sText & gb.NewLine, gb.NewLine)
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      ''Title:
      sHTML &= gb.NewLine
      sHTML &= "<!-- Next table.............................................. -->" & gb.NewLine
      sHTML &= "<a name=jump" & Str(iTable) & "></a>" & gb.NewLine
      If iTable = 0 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Namen") & " Abc" & "</a> <img src=favicon.png width=30 height=30 alt=Logo></h1>" & gb.NewLine
      If iTable = 1 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach namen") & " abc" & "</a></h1>" & gb.NewLine
      If iTable = 2 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Hexadezimal") & " #" & "</a></h1>" & gb.NewLine
      If iTable = 3 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach RGB") & " (R,G,B)" & "</a></h1>" & gb.NewLine
      If iTable = 4 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Dezimal-Zahl") & " 0123" & "</a></h1>" & gb.NewLine
      If iTable = 5 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Helligkeit") & " □" & "</a></h1>" & gb.NewLine
      If iTable = 6 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Sättigung") & " ■" & "</a></h1>" & gb.NewLine
      If iTable = 7 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach HUE") & " 360°" & "</a></h1>" & gb.NewLine
      If iTable = 8 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Rot-Anteil") & " RGB(<font Color=Red>●</font>" & " ○ ○" & ")</a></h1>" & gb.NewLine
      If iTable = 9 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Grün-Anteil") & " RGB(○ <font Color=Green>●</font>" & " ○" & ")</a></h1>" & gb.NewLine
      If iTable = 10 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Blau-Anteil") & " RGB(○ ○ <font Color=Blue>●</font>" & ")</a></h1>" & gb.NewLine
      
      ''Title line
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
      sHTML &= "<tr>" & gb.NewLine
      sHTML &= "<td colspan=0 align=left valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=1 align=left valign=top>" & "<b><a href=#jump0>" & ("Name") & "</a></b>" & "</td>" & gb.NewLine
      ' sHTML &= "<td colspan=1 align=left valign=top>" & "<b><a href=#jump1>" & ("name") & "</a></b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=2 align=left valign=top>" & "<b><a href=#jump2>" & "#" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=3 align=left valign=top>" & "<b><a href=#jump3>" & "RGB(" & sRGBfont & ")" & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=4 align=right valign=top>" & "<b><a href=#jump4>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=5 align=right valign=top>" & "<b><a href=#jump5>" & ("Luminance") & "</b>" & "<br>" & "□ " & ("Helligkeit") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=6 align=right valign=top>" & "<b><a href=#jump6>" & ("Saturation") & "</b>" & "<br>" & "■ " & ("Sättigung") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=7 align=right valign=top>" & "<b><a href=#jump7>" & ("HUE") & "</b>" & "<br>" & ("360°") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=8 align=right valign=top>" & "<b><a href=#jump8>" & ("Rot") & "</b>" & "<br>" & "<font color=red>●</font>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=9 align=right valign=top>" & "<b><a href=#jump9>" & ("Grün") & "</b>" "<br>" & "<font color=green>●</font>" & "</td>" & gb.NewLine 
      sHTML &= "<td colspan=10 align=right valign=top>" & "<b><a href=#jump10>" & ("Blau") & "</b>" "<br>" & "<font color=blue>●</font>" & "</td>" & gb.NewLine
      sHTML &= "</tr>" & gb.NewLine
      
      ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      For Each sLine In ssSpli
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If sLine = "" Or sLine Begins "#" Then
          '...
        Else 
          ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
          sColorName = ssSpliLine[0]
          sHex = ssSpliLine[2]  ''Example: "F0F8FF"
          sHex = Replace(sHex, "#", "")
          sHex = Replace(sHex, "&H", "")
          sHex = Replace(sHex, "&", "")
          
          ssBG = New String[] 
          ssBG.Resize(F_iColumn12Sort)
          If iTable > 2 Then ssBG[iTable] = Space(1) & "bgcolor=#" & "F1F1F1"
          
          sHex = "#" & sHex
          ' sRGB = ssSpliLine[2]
          
          ''..................................
          sDezi = ssSpliLine[4]
          ''..................................
          
          If IsInteger(sDezi) = True Then 
            iRGB = CInteger(sDezi)
            hColorInfo = Color[iRGB]
            iR = hColorInfo.Red
            iG = hColorInfo.Green
            iB = hColorInfo.Blue
            ' iA = hColorInfo.Alpha 
            sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
            sDezi = Str(hColorInfo.Color)
            sLumi = hColorInfo.Luminance
            If hColorInfo.Luminance < 150 Then 
              sColorNameFG = "<font color=white>" & sColorName & "</font>" 
            Else 
              sColorNameFG = "<font color=black>" & sColorName & "</font>"
            Endif 
            sSatu = hColorInfo.Saturation
            sHue = hColorInfo.Hue 
            iCounter = iCounter + 1
            ''Example: "Green=008000=0,128,0=32768="
            sHTML &= "<tr>" & gb.NewLine
            sHTML &= "<td colspan=0 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=1 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
            sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
            sHTML &= "<td colspan=3 align=left valign=top" & ssBG[3] & ">" & sRGB & "</td>" & gb.NewLine
            sHTML &= "<td colspan=4 align=right valign=top" & ssBG[4] & ">" & sDezi & "</td>" & gb.NewLine
            sHTML &= "<td colspan=5 align=right valign=top" & ssBG[5] & ">" & sLumi & "</td>" & gb.NewLine
            sHTML &= "<td colspan=6 align=right valign=top" & ssBG[6] & ">" & sSatu & "</td>" & gb.NewLine
            sHTML &= "<td colspan=7 align=right valign=top" & ssBG[7] & ">" & sHue & "</td>" & gb.NewLine
            sHTML &= "<td colspan=8 align=right valign=top" & ssBG[8] & ">" & Str(iR) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=9 align=right valign=top" & ssBG[9] & ">" & Str(iG) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=10 align=right valign=top" & ssBG[10] & ">" & Str(iB) & "</td>" & gb.NewLine
            sHTML &= "</tr>" & gb.NewLine
            
            sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & Quote(sRGB) & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & Str(iR) & "=" & Str(iG) & "=" & Str(iB) & "=" & gb.NewLine 
            If iTable = 0 Then sText2 &= sLine
          Endif 
        Endif 
      Next
      sHTML &= "</table>" & gb.NewLine
      sHTML &= "<br>" & gb.NewLine
      sHTML &= sInfo
    Next 'iTable
    
    ''............................................................
    
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    If F_bESCpressedON = True Then Return 
    
    ''Save:
    sText2 = sTitle & sText2
    sTextTXT = sText2
    File.Save(sDirFile, sTextTXT)
    
    sTextCSV = Replace(sText2, "|", gb.Tab)
    sTextCSV = Replace(sTextCSV, "=", gb.Tab) & gb.NewLine 
    sTextCSV &= gb.NewLine 
    sTextCSV &= Replace("Name0|name1|Hexadezimal2|RGB(0+0+0)3|Dezimal4|Luminance5|Saturation6|HUE7|Red8|Green9|Blue10|", "|", gb.Tab) & gb.NewLine 
    sTextCSV &= Replace("Farb-Name|abc|Hexadezimal|RGB(0+0+0)|Dezimal|Helligkeit|Sättigung|HUE|Rot|Grün|Blau-Anteil|", "|", gb.Tab) & gb.NewLine 
    sTextCSV &= gb.NewLine
    sTextCSV &= Replace("#" & sInfo, "<br>", gb.NewLine)
    sTextCSV = Replace(sTextCSV, gb.NewLine, gb.CrLf) ' Chr$(13) & Chr$(10) = "\r\n"  ->windows + linux (read)
    
    ''File Format  *.csv
    File.Save(File.SetExt(sDirFile, "csv"), sTextCSV) 'Office Calc Table"
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    ''File Format *.htm
    File.Save(sDirFileHTML, sHTML)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    
    ''Show:
    ''Yellow=yellow=#FFFF00=255,255,0=16776960=226=255=60=255=255=0==
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotoImageAdd(Optional Img As Image = Null)
  
  If Img Then 
    If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
    F_ooUndoRedoPhoto.Add(Img) '(Img, 1)
    ListBackupCounter1.Text = F_ooUndoRedoPhoto.Count & Space(1) & ("von") & Space(1) & F_ooUndoRedoPhoto.Count
    ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
    F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotosPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim Img As Image
  
  If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer - 1
      
    Case "r", "redo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer + 1
      
    Case "m", "max"
      F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      
    Case "s", "select"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoPhotosPointer < 0 Then F_iUndoRedoPhotosPointer = -1
  If F_iUndoRedoPhotosPointer > F_ooUndoRedoPhoto.Max Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  
  If F_iUndoRedoPhotosPointer > -1 Then 
    Img = F_ooUndoRedoPhoto[F_iUndoRedoPhotosPointer] 'Object Image
    PicturePhoto.Picture = Img.Picture
  Else 
    PicturePhoto.Picture = Null
  Endif 
  
  ' If PicturePhoto.Picture Then 
  '   ImageViewPhoto.Update(Img) 
  ' Else 
  '   ImageViewPhoto.Update(PicTemplateQuestion256.Picture.Image.Stretch(Screen.W, Screen.H))
  ' Endif 
  
  PicBoxZoomLupe.Picture = PicturePhoto.Picture
  
  ListBackupCounter1.Text = Str(F_iUndoRedoPhotosPointer + 1) & Space(1) & ("von") & Space(1) & Str(F_ooUndoRedoPhoto.Max + 1)
  ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
  SideG(2)
  If Not PicturePhoto.Picture Then LabelInfo.Text = ("Fehlt: Bildschirm-Foto") Else LabelInfo.Text = ("Info") 
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreatePanelMemoryColors()
  
  Dim hLabel As Label
  Dim hPicBox As PictureBox
  Dim it, iW, iH, iColorsCount As Integer
  Dim iiColors As Integer[]
  
  iColorsCount = F_iColorsCount '= 10 '0,1,2... n-1    '0...10=11
  iiColors = New Integer[] 
  iiColors.Resize(iColorsCount)
  iiColors.Fill(Color.White, 0, -1) 'all -1
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = Settings[F_sForm &/ "F_iiIconClockColorsA", Null]
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = iiColors.Copy()
  
  If F_iiIconClockColorsA Then 
    If F_iiIconClockColorsA.Count < iColorsCount Then F_iiIconClockColorsA.Resize(iColorsCount)
    
    ''Colors A: Default □□□□□□□□□□
    ScrollViewMemoryColors.Children.Clear()
    F_ooPicBoxesColorsA = New Object[]
    F_ooPicBoxesColorsB = New Object[]
    F_ooPicBoxesColorsBgrid = New Object[]
    
    iW = PanelMemoryColors.H - 2
    iH = iW / 2
    
    For it = 0 To iColorsCount - 1
      hPicBox = New PictureBox(ScrollViewMemoryColors) As "GroupColorBoxesA"
      If it < F_iiIconClockColorsA.Count Then  
        hPicBox.Background = F_iiIconClockColorsA[it]
        ' F_sColorChangeLineStandard &= F_iiIconClockColorsA[it] & "="
      Endif 
      hPicBox.Tooltip = Str(it + 1) & Space(1) & ("Gespeicherte Farbe übernehmen") 
      hPicBox.Tag = it '=Position
      hPicBox.Move(iW * it, 0, iW, iH)
      hPicBox.Cursor = New Cursor(PicBoxPickerColor.Picture, 0, 0) 
      hPicBox.Mouse = Mouse.Custom
      ' hPicBox.Mouse = Mouse.Pointing
      hPicBox.Visible = True 
      hPicBox.Border = Border.None
      
      F_ooPicBoxesColorsA.Add(hPicBox)
      
      hLabel = New Label(ScrollViewMemoryColors) As "GroupColorBoxesB"
      hLabel.Tooltip = Str(it + 1) & Space(1) & ("Farbe speichern") 
      hLabel.Tag = it '=Position
      hLabel.Move(iW * it, iH, iW, iH)
      hLabel.Cursor = New Cursor(PicTemplateColorPotCross.Picture, PicBoxColorMemoryBottom.Picture.W * 0.75, PicBoxColorMemoryBottom.Picture.H * 0.75) 
      hLabel.Mouse = Mouse.Custom
      hLabel.Alignment = Align.Center
      ' hLabel.Mouse = Mouse.Pointing
      hLabel.Visible = True 
      hLabel.Font.Bold = False
      hLabel.Text = Str(it + 1) '"+M" 
      hLabel.Border = Border.None
      
      ' If M01Functions.ColorInfoRGB(hLabel.Background, "L") < 150 Then hLabel.Foreground = Color.White Else hLabel.Foreground = Color.Black
      
      F_ooPicBoxesColorsB.Add(hLabel)
      
      ''Transparent-Grid in Background
      hPicBox = New PictureBox(ScrollViewMemoryColors) 
      hPicBox.Move(iW * it, iH, iW, iH)
      hPicBox.Tag = it '=Position
      hPicBox.Visible = True 
      
      F_ooPicBoxesColorsBgrid.Add(hPicBox) 
      
    Next
    
    ''Single, 1x:
    hPicBox = New PictureBox(ScrollViewMemoryColors) 
    hPicBox.Background = Color.Green 'find
    hPicBox.Tag = -1 'Position Nr.
    hPicBox.Move(-iW, 0, iW, iH)
    hPicBox.Mouse = Mouse.Default 
    hPicBox.Visible = False  
    hPicBox.Border = Border.None
    hPicBox.Name = "PicBoxSelect"
    F_oPicBoxColorFind = hPicBox
    
    ''Single, 1x:
    hPicBox = New PictureBox(ScrollViewMemoryColors) 
    hPicBox.Background = Color.Black 'last
    hPicBox.Tag = -1 'Position Nr.
    hPicBox.Move(-iW, 0, iW, iH)
    hPicBox.Mouse = Mouse.Default 
    hPicBox.Visible = False  
    hPicBox.Border = Border.None
    hPicBox.Name = "PicBoxSelect"
    F_oPicBoxColorLast = hPicBox
  Endif 
  ResizeColorBoxes()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorOpenSaveStandardG(Optional sOpenSaveStandard As String = "standard")
  
  Dim sPathLast, sDir, sFile, sDirFile, sLine, sLines, sSquare, sColors, sMessage As String 
  Dim ssColor As String[]
  Dim iColor, iDiff, it, iExist As Integer
  Dim iiColors As Integer[]
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
  iiColors = New Integer[]
  sPathLast = Settings[FMain.Name &/ "F_sPathPickerColorsMemory_txt", FMain.F_sPathPickerColorsMemory_txt]
  
  Select Case String.LCase(sOpenSaveStandard) 
      
    Case "open", "opencolors" '.....................................................
      iiColors = F_iiIconClockColorsA.Copy()
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      If sDirFile Then sFile = File.Name(sDirFile) 
      If Exist(sDir) = False Then sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = FileDialogPathReturn(sPathLast, "open", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Load:
      If Exist(sDirFile) = True Then 
        sLines = File.Load(sDirFile)
        If Not iiColors Then iiColors = New Integer[]
        If iiColors.Max <> F_ooPicBoxesColorsB.Max Then iiColors.Resize(F_ooPicBoxesColorsB.Count)
        it = -1
        For Each sLine In Split(sLines & gb.NewLine, gb.NewLine)
          If String.LCase(sLine) Like "*" & "color=" & "*" Then 
            ssColor = Split(sLine & "=", "=")
            If ssColor Then
              ssColor[1] = Trim(UnQuote(ssColor[1]))
              If IsInteger(ssColor[1]) = True Then 
                it = it + 1
                iColor = CInteger(ssColor[1]) 
                If it < iiColors.Count Then iiColors[it] = iColor Else Break
              Endif 
            Endif 
          Endif 
        Next 
        iExist = it
        If iiColors.Max > -1 Then 
          sColors = ""
          sMessage &= "<h3>" & "■ " & ("Aktuelle Farben") & "</h3>"
          For it = 0 To F_iiIconClockColorsB.Max
            If F_iiIconClockColorsB[it] = Color.Background Then 
              sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
            Else 
              sColors &= "<font color=#" & Hex(F_iiIconClockColorsB[it], 6) & ">" & "■" & "</font>"  
            Endif 
          Next   
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<br><br>"
          sMessage &= "<h3>" & "● " & ("Farben aus der Datei") & "</h3>"
          sColors = Null
          For it = 0 To iiColors.Max
            If iiColors[it] = F_iiIconClockColorsB[it] Then 
              sSquare = "■"
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
            Else 
              iDiff = iDiff + 1
              sSquare = "●" 'Changed
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
            Endif 
            sColors &= "<font color=#" & Hex(iiColors[it], 6) & ">" & sSquare & "</font>"
          Next  
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & iiColors.Count & Space(1) & ("Farben") & Space(1) & "</font></h3>"
          sMessage &= "<font color=gray>" & sDirFile & "</font>" & "<br>"
          If Exist(sDirFile) = True Then sMessage &= "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
          If Stat(sDirFile).Size = 0 Then sMessage &= "<font color=red size=5>" & ("Leer") & "</font>"
          If Stat(sDirFile).Size > 0 And iExist = -1 Then sMessage &= "<font color=red size=5>" & ("Keine Farben erkannt") & "</font>"
                    
          Select Case Message.Question(sMessage, "● " & ("Öffnen"), ("Ordner..."), ("Abbrechen"))
            Case 1  '"● "
              ''...Open
            Case 2 'Directory
              If Exist(sDirFile) = True Then M01Functions.FileManagerOpen(sDirFile) Else M01Functions.FileManagerOpen(sDir)
              Goto JumpEnd
            Case 3 'Cancel
              Goto JumpEnd
          End Select
          F_iiIconClockColorsB = iiColors.Copy()
          Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
          UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
        Else 
          sMessage = ""
          sColors = ""
          If F_iiIconClockColorsB Then
            sColors &= String(F_iiIconClockColorsB.Count, "□") & "<br>"
          Endif 
          If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
          sMessage &= sDirFile 
          sMessage &= "<h3><font color=red>" & ("Keine Farb-Palette?") & "</font></h3>"
          
          Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
            Case 1
              sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
              M01Functions.FileManagerOpen(sDir)
            Case 2
              ''...
          End Select
        Endif 
      Endif 
      
    Case "save", "savecolors" '.....................................................
      F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
      
      ' sMessage = "<h3><font color=gray>" & "■ " & ("Standard Farben") & "</font></h3>"
      sMessage = "<h3>" & "● " & ("Aktuelle Farben") & Space(1) & ("speichern") & "</h3>"
      sColors = ""
      For it = 0 To F_iiIconClockColorsB.Max 
        If F_iiIconClockColorsB[it] = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>" Else sSquare = "■"
        sColors &= "<font color=#" & Hex(F_iiIconClockColorsB[it], 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & F_iiIconClockColorsB.Count & Space(1) & ("Farben") & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Speichern") & "...", ("Ordner..."), ("Abbrechen"))
        Case 1  '"● "
          ''...Save
          
        Case 2 'Directory
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
          Goto JumpEnd
          
        Case 3 'Cancel
          Goto JumpEnd
      End Select
      
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      sFile = File.Name(sDirFile)
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = M01Functions.FileDialogPathReturn(sPathLast, "save", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Save:
      If sDirFile Then 
        If F_ooPicBoxesColorsB Then 
          sLines = "#" & Application.Name & Space(1) & Application.Version & ("Color-Palette") & gb.NewLine
          For it = 0 To F_ooPicBoxesColorsB.Max
            sLines &= "color=" & Quote(Str(F_ooPicBoxesColorsB[it].Background)) & gb.NewLine
          Next 
          '*****************************************************
          sDirFile = M01Functions.FileTextPlus(sDirFile, sLines, True) 'TRUE=overwrite (überschreiben)
          '*****************************************************
        Endif 
      Endif 
      
      ''Check:
      If sDirFile And Exist(sDirFile) = False Then
        sMessage = ""
        sColors = ""
        If F_iiIconClockColorsA Then
          sColors &= String(F_iiIconClockColorsA.Count, "□") & "<br>"
        Endif 
        If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
        sMessage &= sDirFile 
        sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            M01Functions.FileManagerOpen(sDir)
          Case 2
            ''...
        End Select
      Endif 
      
    Case "standard", "standardcolors", "reset" '.....................................................
      iiColors = Settings[FMain.Name &/ "F_iiIconClockColorsA", F_iiIconClockColorsA]
      F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
      If iiColors.Max <> F_ooPicBoxesColorsB.Max Then iiColors.Resize(F_ooPicBoxesColorsB.Count)
      
      sMessage = "<h3><font color=gray>" & "■ " & ("Standard Farben") & "</font></h3>"
      sColors = ""
      For it = 0 To iiColors.Max
        If iiColors[it] = Color.Background Then 
          sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
        Else 
          sColors &= "<font color=#" & Hex(iiColors[it], 6) & ">" & "■" & "</font>"  
        Endif 
      Next   
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<br><br>"
      sMessage &= "<h3>" & "● " & ("Aktuelle Farben") & "</h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsB.Max
        If iiColors[it] = F_ooPicBoxesColorsB[it].Background Then 
          sSquare = "■"
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
        Else 
          iDiff = iDiff + 1
          sSquare = "●" 'Changed
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
        Endif 
        sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & F_ooPicBoxesColorsB.Count & Space(1) & ("Farben") & Space(1) & "</font></h3>"
      
      Select Message.Question(sMessage, "■ " & ("Standard Farben (Reset)") & " Clear", ("Ordner..."), ("Abbrechen"))
        Case 1 'Reset Colors
          If iDiff > 0 Then 
            F_iiIconClockColorsB = iiColors.Copy()
            Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
            UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
            LabelInfo.Text = ("Farbe") & ": " & ("Standard (Reset)")
          Endif

        Case 2 
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
        Case 3 'Cancel
          '...
      End Select 
      
  End Select 
  
JumpEnd:
  
Catch 
  FMain.ErrorText()
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)

  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End



Public Sub UndoRedoColorsAdd(Optional iiColorsNew As Integer[] = Null)
  
  If iiColorsNew Then 
    If Not F_ooPicBoxesColorsB Then CreatePanelMemoryColors()
    
    If Not F_ooUndoRedoColors Then F_ooUndoRedoColors = New Object[]
    If iiColorsNew Then F_ooUndoRedoColors.Add(iiColorsNew) 
    
    Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColorsNew
    ListBackupCounter2.Text = F_ooUndoRedoColors.Max & Space(1) & "/" & Space(1) & F_ooUndoRedoColors.Max
    ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Farben-Reihe")
    F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
    ResizeColorBoxes()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoColorsPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim iiColors As Integer[]
  Dim sInfo As String
  
  If Not F_ooUndoRedoColors Then F_ooUndoRedoColors = New Object[]
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer - 1
      sInfo = ("Rückgängig")
      
    Case "r", "redo"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer + 1
      sInfo = ("Wiederherstellung")
      
    Case "m", "max"
      F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
      sInfo = ("max.")
      
    Case "s", "select"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer
      sInfo = ("Auswahl")
      
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoColorsPointer < 0 Then F_iUndoRedoColorsPointer = 0
  If F_iUndoRedoColorsPointer > F_ooUndoRedoColors.Max Then F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
  
  If F_iUndoRedoColorsPointer > -1 Then 
    iiColors = F_ooUndoRedoColors[F_iUndoRedoColorsPointer] 'Object Image
  Else 
    iiColors = Null
  Endif 
  ''Array [0,..., n-1]
  ''User 1,2,3,... n
  ListBackupCounter2.Text = Str(F_iUndoRedoColorsPointer + 1) & Space(1) & "/" & Space(1) & Str(F_ooUndoRedoColors.Max + 1)
  ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Farben-Reihe")

  If F_iUndoRedoColorsPointer > -1 Then 
    LabelInfo.Text = ("Farbe") & ": " & sInfo
    F_iiIconClockColorsB = iiColors 'without .Copy()
    Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
  Endif 
  
  SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  ResizeColorBoxes()
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxHTML_MouseDown()

  ButtonGroupSelect("textareatext")
  
Catch 
  FMain.ErrorText
End

Public Sub SettingsColorsUserReadSave(Optional sReadSave As String = "read")
  
  Dim it As Integer
  
  If F_ooPicBoxesColorsB Then '□ □ □
    Select Case String.LCase(String.Left(sReadSave, 1))
        
      Case "r" ''Read ■ ■ ■ ——▶ □ □ □
        If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
        If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
        
        ''Refresh:
        F_sColorChangeLineUser = "colorchange="
        For it = 0 To F_ooPicBoxesColorsB.Max
          F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
          F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
        Next  
        Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
        
      Case "s" ''Save □ □ □ ◀—— ■ ■ ■
        If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = New Integer[]
        If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
        
        F_sColorChangeLineUser = "colorchange="
        For it = 0 To F_ooPicBoxesColorsB.Max
          F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
          F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
        Next 
        Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
        
    End Select 
    ' M05.ColorClockGetSettings() 'read
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizeColorBoxes()
  
  Dim it, iH, iW As Integer
  Dim fW, fH As Float
  Dim Img As Image
  
  'Alternative: F_ooPicBoxesColorsA[it] = PanelColorBoxesA.Children[it]
  F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
  ' If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
  
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = M05.ColorPaletteStandardii() 'as Integer[]

  ' If Not F_ooPicBoxesColorsB Then CreateColorBoxes() 'Loop?
  F_iiIconClockColorsA = F_iiIconClockColorsB.Copy()
  
  If Not F_ooPicBoxesColorsA Or Not F_ooPicBoxesColorsBgrid Then CreatePanelMemoryColors()
  
  ''Colors A: Default □□□□□□□□□□
  If F_ooPicBoxesColorsA Then 
    iW = ScrollViewMemoryColors.W / F_ooPicBoxesColorsA.Count
    iH = ScrollViewMemoryColors.H / 2
    For it = 0 To F_ooPicBoxesColorsA.Max
      F_ooPicBoxesColorsA[it].Move(iW * it, 0, iW - 4, iH * 0.65)
      If it < F_iiIconClockColorsA.Count Then F_ooPicBoxesColorsA[it].Background = F_iiIconClockColorsA[it]
    Next
  Endif 
  
  ''Colors B: User □□□□□□□□□□
  If F_ooPicBoxesColorsB Then 'Boxes
    iW = ScrollViewMemoryColors.W / F_ooPicBoxesColorsB.Count
    iH = ScrollViewMemoryColors.H / 2
    fW = iW - 4
    fH = iH * 1.25
    
    For it = 0 To F_ooPicBoxesColorsB.Max
      If it < F_iiIconClockColorsB.Count Then F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
      F_ooPicBoxesColorsB[it].Font.Bold = False 
      F_ooPicBoxesColorsB[it].Font.Size = LabelInfo.Font.Size
      ' F_ooPicBoxesColorsB[it].Font.Size = ButtonColorPotNumber.Font.Size
      F_ooPicBoxesColorsB[it].Move(iW * it, iH * 0.75, fW, fH)
      F_ooPicBoxesColorsB[it].Raise()'▲
      If M01Functions.ColorInfoRGB(F_ooPicBoxesColorsB[it].Background, "L") < 150 And M01Functions.ColorInfoRGB(F_ooPicBoxesColorsB[it].Background, "A") < 150 Then F_ooPicBoxesColorsB[it].Foreground = Color.White Else F_ooPicBoxesColorsB[it].Foreground = Color.Black
    Next
    
    Img = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200), fW, fH) 'as Image
    For it = 0 To F_ooPicBoxesColorsBgrid.Max
      F_ooPicBoxesColorsBgrid[it].Move(iW * it, iH * 0.75, fW, fH)
      F_ooPicBoxesColorsBgrid[it].Lower()'▼
      F_ooPicBoxesColorsBgrid[it].Visible = True
      If Img Then F_ooPicBoxesColorsBgrid[it].Picture = Img.Picture
      ' F_ooPicBoxesColorsBgrid[it].Background = Color.Blue
    Next
    
    Img = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200), PicBoxColorSelectBGGrid.W, PicBoxColorSelectBGGrid.H) 'as Image
    If Img Then PicBoxColorSelectBGGrid.Picture = Img.Picture
    
    ''Selected:
    If F_iColorBoxesPointer > -1 And F_iColorBoxesPointer < F_ooPicBoxesColorsB.Count Then 
      F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Bold = True 
      F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = 22
      ' F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = ButtonColorPotNumber.Font.Size
    Endif 
  Endif
  ColorFindSelected()
  ' CheckFontColor() 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesA_Enter()
  
  F_iColorPicker = Last.Background
  ''ColorPicker 'Change ●
  Last.Cursor = New Cursor(PicBoxPickerColor.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 'as Picture, x, y
  Last.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesA_MouseDown()
  
  F_iColorPicker = Last.Background
  ColorChooser1.SelectedColor = F_iColorPicker
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesB_Enter()

  Dim iW, iH As Integer
  
  iW = 50
  iH = iW
  
  F_iColorPicker = Last.Background
  ''ColorPicker 'Change ●
  Last.Cursor = New Cursor(PicBoxColorMemoryBottom.Picture.Image.Stretch(iW, iH).Picture, iW, iH) 'as Picture, x, y
  Last.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesB_MouseDown()

  Dim sMessage As String 
  Dim it, iColor, iTrans, iColorRGB As Integer
  Dim iiColors As Integer[]
  
  iColor = ColorChooser1.SelectedColor
  iTrans = Color.GetAlpha(iColor) '0 = Color, 255 = full transparent
  iColorRGB = Color.SetAlpha(iColor, 0)
  sMessage = "<h1>" & "<font color=#" & Str(Hex(Last.Background, 6)) & ">" & "■ " & "</font>" & "#" & Str(Hex(Last.Background, 6)) & Space(1) & ("Alt") & "</h1>"
  sMessage &= "<h1>" & "<font color=#" & Str(Hex(iColorRGB, 6)) & ">" & "■ " & "</font>" & TextBoxHexaHTML.Text & Space(1) & ("Neu") & "</h1>"
  If iTrans > 0 Then sMessage &= "<font size=5 color=DarkGray><b>" & Str(iTrans) & "</b>" & Space(1) & ("von") & Space(1) & "255" & Space(1) & ("Alpha=Glas") & "</font><br>"
  sMessage &= "<h3><font color=DarkGray>" & TextBoxColorName.Text & "</font></h3>"
  
  sMessage &= "<h1>" & ("Neue Farbe merken?") & "</h1>"
  Select Case Message.Question(sMessage, ("Merken"), ("Abbrechen"))
      
    Case 1 
      Last.Background = iColor
      If M01Functions.ColorInfoRGB(iColor, "L") < 150 And M01Functions.ColorInfoRGB(iColor, "A") < 150 Then Last.Foreground = Color.White Else Last.Foreground = Color.Black
      it = CInteger(Last.Tag)
      F_iColorBoxesPointer = it
      Settings[F_sForm &/ "F_iColorBoxesPointer"] = F_iColorBoxesPointer
      iiColors = F_iiIconClockColorsB.Copy()
      If it < F_iiIconClockColorsA.Count Then F_iiIconClockColorsA[it] = iColor 
      If it < F_iiIconClockColorsB.Count Then iiColors[it] = iColor 
      Settings[F_sForm &/ "F_iiIconClockColorsA"] = F_iiIconClockColorsA
      Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
      UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
            
    Case 2 'Cancel
      '...
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoG(Optional hTextInfo As String = Null) '<HTML>
  
  If hTextInfo Then 
    LabelCopyExample.Text = hTextInfo
    ' LabelInfoSearch.Visible = True 
  Else 
    LabelCopyExample.Text = LabelCopyExample.Tooltip
    ' LabelInfoSearch.Visible = False 
  Endif 
  
Catch 
  FMain.ErrorText
  
End
Public Sub SearchText(Optional sUpDown As String = "+")
  
  Dim sFindText As String 
  
  TextAreaSearch.SelectAll()
  
  sFindText = TextAreaSearch.Selection.Text
  
  If PanelWebTextCode.Visible = True Then 
    ''Web:
    If WebView1.Visible = True Then 
      If sUpDown = "+" Then '> plus down ▼
        'WebView.FindText(...) needs component: gb.qt4.webkit   and see: gb.gui.webview
        'Function FindText ( [ Text As String, Backward As Boolean, CaseSensitive As Boolean, Wrap As Boolean ] ) As Boolean
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, False, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Else '"-" '< minus up ▲
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, True, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Endif 
      If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
        LabelInfoG(WebView1.SelectedText)
      Endif 
    Else If TextAreaCode.Visible = True Then 
      ''Code:
      F_iSearchPosCode = TextAreaTempPos(TextAreaCode, F_iSearchPosCode, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Position") & ": " & F_iSearchPosCode
    Else If TextAreaText.Visible = True Then 
      ''Text:
      F_iSearchPosText = TextAreaTempPos(TextAreaText, F_iSearchPosText, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Position") & ": " & F_iSearchPosText
    Else If ColumnView1.Visible = True Then 
      ''ColumnView:
      F_iSearchPosColumnView = ColumnViewFind(F_iSearchPosColumnView, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Zeile") & ": " & F_iSearchPosColumnView
    Endif 
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Function TextAreaTempPos(Optional hTextArea As TextArea, Optional iLastPos As Integer, Optional sUpDown As String = "+") As Integer
  
  Dim iPos As Integer
  Dim sFindText As String 
  
  sFindText = TextAreaSearch.Text
  
  If hTextArea Then 
    If iLastPos < 0 Then iLastPos = 0
    If sUpDown = "+" Then '> plus down ▼
      iPos = String.InStr(hTextArea.Text, sFindText, iLastPos) 'as Integer  0=not found in String.InStr()
      If iPos > 0 Then 
        ButtonSearch.Background = F_iColorSelectGreen150
      Else 
        ButtonSearch.Background = F_iColorSelectRed150
      Endif 
      ButtonSearchBack.Background = Color.Default
      iLastPos = iPos + 1
    Else '"-" '< minus up ▲
      If iLastPos < String.Len(sFindText) Then iLastPos = String.Len(hTextArea.Text) - 1
      If iLastPos < 1 Then iLastPos = 1
      iPos = String.RInStr(hTextArea.Text, sFindText, iLastPos) 
      If iPos > 0 Then 
        ButtonSearchBack.Background = F_iColorSelectGreen150
      Else 
        ButtonSearchBack.Background = F_iColorSelectRed150
      Endif 
      ButtonSearch.Background = Color.Default
      iLastPos = iPos - 1 
    Endif
    
    If iPos < 1 Then 'not found 
      If LabelBgSearch.Background = F_iColorSelectRed150 Then 
        LabelBgSearch.Background = Color.White
      Else 
        LabelBgSearch.Background = F_iColorSelectRed150
      Endif
      iLastPos = 0
      LabelBgSearch.Text = ("Ende Suche")
    Else 
      LabelBgSearch.Background = F_iColorSelectGreen150 
      If iPos - 1 < 1 Then iPos = 1
      hTextArea.Select(iPos - 1, String.Len(sFindText)) 'begin min. with 1
      LabelBgSearch.Text = ("Gefunden") 
    Endif
    hTextArea.EnsureVisible()
  Endif 
  
  Return iLastPos
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewFind(Optional iLastPos As Integer, Optional UpDown As String = "+") As Integer
  
  Dim M, it, iFound, iLine As Integer
  Dim sK1, sText, sFindText, sTopBottom As String 
  
  If ColumnView1.Visible = True Then 
    If ColumnView1.Count > 0 And ColumnView1.Columns.Count > F_iColumns13Undo Then 
      If iLastPos < 0 Then iLastPos = 0
      sFindText = TextAreaSearch.Text
      sFindText = String.LCase(Replace(sFindText, gb.NewLine, "", gb.String))
      M = ColumnView1.MoveCurrent()
      If ColumnView1.Mode <> Select.Single Then ColumnView1.Mode = Select.Single
      TextAreaSearch.Foreground = Color.DarkRed
      For it = 0 To ColumnView1.Count - 1 
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sTopBottom = "" 'Reset
        If UpDown = "+" Then 
          M = ColumnView1.MoveBelow() '▼
          If M = -1 Then 
            M = ColumnView1.MoveFirst() 'M=0=False>Exist. M=-1=True>Missing
            sTopBottom = "top"
          Endif 
        Else 
          M = ColumnView1.MoveAbove() '▲
          If M = -1 Then 
            M = ColumnView1.MoveLast()  
            sTopBottom = "bottom"
          Endif 
        Endif 
        If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
          sK1 = ColumnView1.Item.Key
          sText = String.LCase(ColumnView1[sK1][F_iColumns13Undo]) 
          iLastPos = String.InStr(sText, sFindText)  '0 not found
          If iLastPos > 0 Then 
            If IsInteger(ColumnView1[sK1][0]) = True Then iFound = CInteger(ColumnView1[sK1][0])
            Break
          Endif 
        Endif 
      Next
      If iLastPos > 0 Then
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1].EnsureVisible
        TextAreaSearch.Foreground = Color.DarkGreen
      Endif 

      If F_iSearchPosColumnView >= iFound Then 
        LabelBgSearch.Text = ("Ende Suche")
        LabelBgSearch.Background = F_iColorSelectRed150
        iFound = 0
      Else 
        LabelBgSearch.Text = ("Gefunden")
        LabelBgSearch.Background = F_iColorSelectGreen150
      Endif
    Endif 
  Endif 

  Return iFound
  
Catch
  FMain.ErrorText
  
End


Public Sub SearchPasteG()

  Dim sText As String
  
  If Clipboard.Type = Clipboard.Text Then sText = Clipboard.Paste("text") ' "text/plain"
  If Not sText Then 
    LabelCopyExample.Text = "[Zwischenablage]" & ": " & ("Leer")
    sText = TextBoxColorName.Text 
  Else 
    LabelCopyExample.Text = "[Zwischenablage]" & ": " & ("Eingefügt")
  Endif
  TextAreaSearch.SelectAll()
  TextAreaSearch.Insert(sText)
  LabelBgSearch.Background = Color.White
  LabelBgSearch.Text = ""
  
  Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_Select() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    LabelInfoG(WebView1.SelectedText)
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(WebView1.SelectedText)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub AplusG()
  
  If ColumnView1.Font.Size < 16 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
    WebView1.Zoom = 1 ' 1=100%
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
    WebView1.Zoom = 1.5 ' 1=100%
  Endif 
  
  ''Text-Height:
  
  LabelInfo.Font.Size = ColumnView1.Font.Size
  TextBoxHTML.Font.Size = ColumnView1.Font.Size
  TextAreaText.Font.Size = ColumnView1.Font.Size
  TextAreaCode.Font.Size = ColumnView1.Font.Size
  LabelCopyImageInfo.Font.Size = ColumnView1.Font.Size
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Click()

  Select Case Last.Tag
    Case "webback"
      WebView1.Back() ''◀—
      LabelCopyExample.Text = ("-1x Rückwärts")
    Case "webforward"
      WebView1.Forward() ''—▶
      LabelCopyExample.Text = ("+1x Vorwärts")
    Case "webcode"
      SideG(7) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      LabelCopyExample.Text = ("Quell-Text")
    Case "webcopyall"
      Clipboard.Clear
      Clipboard.Copy(WebView1.Document.HTML)
      If Clipboard.Type = Clipboard.Text Then 
        LabelCopyExample.Text = ("Kopie in der [Zwischenablage]") & ": " & String.Left(Clipboard.Paste("text/plain"), 300) 
      Else 
        LabelCopyExample.Text = ("Kopie in der [Zwischenablage]") & ": " & ("Fehlt") & Space(1) & ("(noch)")
      Endif 
    Case "webreload"
      WebView1.Reload()
      LabelCopyExample.Text = ("1x Neu geladen (Reload)")
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) <> "PictureBox" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Select Case Last.Tag
    Case ArrowR.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True 
      PanelColor.Background = F_iColorGreenAlpha220
    Case PicBoxMemoryColors.Tag
      Last.Background = F_iColorGreenAlpha150
      PanelMemoryColors.Background = F_iColorGreenAlpha220
    Case ButtonCancelMemoryColors.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True 
    Case PicBoxResetstart.Tag 
      Last.Background = F_iColorGreenAlpha150
      PanelColorBackground.Background = F_iColorGreenAlpha150
    Case PicBoxColorsUndo.Tag, PicBoxColorsRedo.Tag
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxOpenColors.Tag 
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxSaveColors.Tag 
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxPlus.Tag, PicBoxWebColorNamesSort.Tag, PicBoxColumnviewColorNamesFind.Tag, PicBoxColorChooser.Tag
      Last.Background = F_iColorGreenAlpha150
      PanelColor.Background = F_iColorGreenAlpha220
    Case ButtonSearch.Tag, ButtonSearchBack.Tag, ButtonCancelWebTextCode.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True
    Case WindowT5plus.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True
    Case Else 
      Last.Background = F_iColorGreenAlpha150
      If Object.Type(Last) = "Button" Then Last.Border = True 
  End Select

Catch 
  FMain.ErrorText
  
End 

Public Sub ButtonGroup_Leave()
  
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  PicBoxColorApplyTop.Background = PicBackground.Background
  
  Select Case Last.Tag
    Case ArrowR.Tag
      Last.Background = Color.Default 
      Last.Border = False 
      PanelColor.Background = Color.Default
    Case ButtonCancelMemoryColors.Tag
      Last.Background = Color.Default
      Last.Border = True 
    Case PicBoxResetstart.Tag 
      Last.Background = Color.Default 
      PanelColorBackground.Background = Color.Default
    Case PicBoxColorsRedo.Tag, PicBoxColorsRedo.Tag 
      Last.Background = Color.Default 
    Case PicBoxOpenColors.Tag 
      Last.Background = Color.Default 
    Case PicBoxOpenColors.Tag 
      Last.Background = Color.Default
    Case PicBoxSaveColors.Tag 
      Last.Background = Color.Default
    Case PicBoxPlus.Tag, PicBoxWebColorNamesSort.Tag, PicBoxColumnviewColorNamesFind.Tag, PicBoxColorChooser.Tag
      Last.Background = Color.Default
      PanelColor.Background = Color.Default
    Case ButtonSearch.Tag, ButtonSearchBack.Tag, ButtonCancelWebTextCode.Tag
      Last.Background = Color.Default
      Last.Border = True
    Case WindowT5plus.Tag
      If F_iLastSide = 6 Then Last.Background = Color.Green Else Last.Background = Color.Default
      Last.Border = True
    Case Else 
      Last.Background = Color.Default 
      If Object.Type(Last) = "Button" Then Last.Border = True 
  End Select
  
  If PicturePhoto.Visible = True Then   'PicBoxScreenshot
    PicBoxPickerColor.Background = Color.Green
  Else 
    PicBoxPickerColor.Background = Color.Default 
  Endif 
  If PanelMemoryColors.Visible = True Then 
    PicBoxMemoryColors.Background = Color.Green 
  Else 
    PicBoxMemoryColors.Background = Color.Default 
  Endif 
  PanelMemoryColors.Background = Color.Default 
  ScrollViewMemoryColors.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
End

Public Sub ButtonGroup_MouseUp()
  
  If Object.Type(Last) = "PictureBox" Or Object.Type(Last) = "Label" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseWheel()
  
  If Last.Tag = LabelZoom.Tag Or Last.Tag = PicBoxPickerColor.Tag Then 
    ZoomHasFocus(Mouse.Forward)   '.Forward as Boolean True/False
    ZoomLupeG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String, Optional sMouseLMR As String = "left")
  
  'Reset
  F_bESCpressedON = False
  IconError.Visible = False ''Reset
  sMouseLMR = String.Left(sMouseLMR, 1)
  sLastTag = String.LCase(sLastTag)
  TimerZoomLupe.Stop()
  
  Select Case sLastTag
    Case "aplus" 'A+, A-
      If ColumnView1.Font.Size < 16 Then 
        ColumnView1.Font.Size = 16 
      Else 
        ColumnView1.Font.Size = 12
      Endif 
      Settings[F_sForm &/ "ColumnView1.Font.Size"] = ColumnView1.Font.Size
      AplusG()
      
    Case "undophoto"
      If sMouseLMR = "r" Then F_iUndoRedoPhotosPointer = -1
      UndoRedoPhotosPointer("undo")
    Case "redophoto"
      If sMouseLMR = "r" And F_ooUndoRedoPhoto Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      UndoRedoPhotosPointer("redo")
    Case "undoredomax"
      UndoRedoPhotosPointer("max")
      
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "labelzoom"
      F_fZoomFactor = 10
      ' LabelZoomTextG()
      ZoomLupeG()
      TimerZoomLupe.Start()
    
    Case "photo"
      SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' F_fZoomFactor = 4
      PhotoG()
      
    Case "sidephoto"
      SidePhotoG()
      
    Case "colorchooser"
      If ColorChooser1.Visible = False Then 
        SideG(1)
      Else 
        SideG(F_iLastSideBefore) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Endif
      
    Case "colorpicker"
      F_imgScreen = Null
      PhotoColorPickerG()
      
    Case "copyimage"
      CopyButtonG() 
      
      ' Case "copyimagezoom"
      '   CopyButtonG("zoom") 
      
    Case PicBoxWebColorNamesSort.Tag 'HTML WebView1
      If PanelWebTextCode.Visible = False Then 
        SideG(4) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Else 
        SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Endif 
      
    Case PicBoxColumnviewColorNamesFind.Tag
      If ColumnView1.Visible = False Then 
        SideG(3) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
        'Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        'Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      Else 
        SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Endif
      
    Case ButtonCancelWebTextCode.Tag
        SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7  
      
    Case "cancelcopyimage"
      PanelCopyImage.Visible = False 
      
    Case PicBoxColorMemoryTop.Tag
      If ScrollViewMemoryColors.ScrollX = 0 Then ScrollViewMemoryColors.ScrollX = ScrollViewMemoryColors.ScrollW Else ScrollViewMemoryColors.ScrollX = 0
      PicBoxColorMemoryTop.Picture = PicBoxColorMemoryTop.Picture.Image.Mirror(True, False).Picture '(Horizontal, -Vertikal-)
      
    Case "dirfile" 
      M01Functions.FileManagerOpen(FilePathForm()) 'Path or "" Null
      
    Case "apps" 'Apps
      M01Functions.SystemStandardApplications() 'System Info
      
    Case "trashopen"
      M01Functions.ExternTrash()
      
    Case "photoform"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "menu"
      Menu1.Popup()
      
    Case "savepicture"
      SideG(2)
      SaveG()
      
    Case "clipboardimagepaste", mnuClipboardImagePaste.Tag 
      SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ClipboardImagePaste()
      
    Case "pastepictureopen", mnuPastePictureOpen.Tag
      PastePictureOpen()
      
    Case PicBoxPlus.Tag, "plus" '+
      Settings[F_sForm &/ "F_iLastColor"] = ColorChooser1.SelectedColor
      SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "wood"
      F_sBackgroundColorOrPath = sLastTag
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo.Text = PicBoxWoodTop.Tooltip
      
    Case "metal"
      F_sBackgroundColorOrPath = sLastTag
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo.Text = PicBoxMetalTop.Tooltip
      
    Case "colorapply" 'Apply + Return to Form
      F_sBackgroundColorOrPath = ColorChooser1.SelectedColor
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo.Text = PicBoxColorApplyTop.Tooltip
      
    Case "resetstart", PicBoxResetstart.Tag
      PhotoColorPickerLatest("reset")
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "apply"
      ApplyG()
      CheckFormBackgroundColor()
      
    Case "hidecolorchooser"
      If ColorChooser1.Visible = True Then 
        SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
        If Not PicturePhoto.Picture Then PicturePhoto.Picture = PicBoxPhoto.Picture
      Else 
        SideG(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Endif 
      
    Case PicBoxMemoryColors.Tag 'On-Off
      F_bMemoryColorsPanelON = Not F_bMemoryColorsPanelON
      Settings[F_sForm &/ "F_bMemoryColorsPanelON"] = F_bMemoryColorsPanelON
      Form_Resize()
      
    Case PicBoxResetMemoryColors.Tag 
      ColorOpenSaveStandardG("reset")
      
    Case PicBoxOpenColors.Tag 
      ColorOpenSaveStandardG("open")
      
    Case PicBoxSaveColors.Tag 
      ColorOpenSaveStandardG("save")
    
    Case PicBoxColorsUndo.Tag
      UndoRedoColorsPointer("undo")
    
    Case PicBoxColorsRedo.Tag
      UndoRedoColorsPointer("redo")
      
    Case "textareatext", "text5resize"
      If F_iLastSide <> 6 Then SideG(6) Else SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "textareacode"
      If F_iLastSide <> 7 Then SideG(7) Else SideG(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7

    Case PicBoxSearchPaste.Tag
      SearchPasteG()
      
    Case "searchdown"
      SearchText("+")
      
    Case "searchup"
      SearchText("-")
        
    Case "close", "cancelform", ButtonCancel.Tag  '×
      Me.Close
      
  End Select 
  
  If ColorChooser1.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '..............................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form7HTML.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form7HTML.class
65,8 KB
' Gambas class file

''Declarations: 
' F_ = Form
Public F_bCalendarAllReturnsON As Boolean
Public F_bCalendarHTMLautomaticRefreshON As Boolean
Public F_bCalendarQuarterWeekON As Boolean
Public F_bCalendarJumpDateON As Boolean
Public F_bChangeON As Boolean
Public F_bMoreButtons As Boolean = True
Public F_bMovingON As Boolean
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150) 
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iOnly1x As Integer
Public F_iSearchPosCode As Integer
Public F_iSearchPosText As Integer
Public F_iSearchPosWeb As Integer
Public F_iSecondCounter As Integer 'second
Public F_iSideWeb1Code2Text3 As Integer
Public F_iValueBoxHasFocus As Integer = 1
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_sForm As String = Me.Name 
Public F_statWebFileOld As Stat
Public F_sWebFileNew As String
Public F_sWebComponenteInfo As String 

'Note: Error> WebView1 'Actual not work with GTK3+. Work with QT5
' Gambas3 in 2022:
' gb.gtk GTK+2 Toolkit based on gb.qt4
' gb.gtk3 GTK+3 Toolkit based on gb.qt4
' This component Implements the Graphical User Interface classes.It Is Based On the QT 4 library.
' gb.gui
' This component will load one GUI component between gb.qt4, gb.qt5, gb.gtk Or gb.gtk3, according To the current desktop In use.
' gb.gui.webview
' This component will load one Of the webview components between gb.qt4.webview Or gb.gtk3.webview, according To the current desktop In use.
' gb.gui.webview 
' If you Use KDE 4, Then gb.qt4.webview will be loaded.
' If you Use KDE 5, Then gb.qt5.webview will be loaded.
' In all other cases, gb.gtk3.webview will be loaded.
'' gb.gtk3 has no support For webview at the moment.

Public Function FilePathForm() As String '.txt
  
  Return Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt] '—▶ + ".html"
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  WebView1.Stop()
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form7HTML.Window.Maximized = False Then
    Form7HTML.Window.Maximized = True
  Else
    Form7HTML.Window.Maximized = False
    Form7HTML.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim iYearBegin, iYearEnd, iYearCurrent, iDiff As Integer
  Dim sMessage As String 
  Dim bCurrentYear As Boolean
  
  ''Year 0000 begin—▶end:
  SettingsReadSave("save")  
  
  ''Check year:
  ' iYearBegin = ValueBoxYearBegin.Value
  ' iYearEnd = ValueBoxYearEnd.Value
  
  iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", Year(Date)]
  iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", Year(Date)] 
  iYearCurrent = Year(Date)
  If iYearCurrent >= iYearBegin And iYearCurrent <= iYearEnd Then bCurrentYear = True 
  iDiff = iYearBegin - iYearEnd
  If iDiff <> 0 Or bCurrentYear = False Then 
    sMessage = "<font size=7 color=red><b>" & iYearBegin & Space(1) & "</b></font><font size=5 color=blue><b>" & ("bis") & "</b></font><font size=7 color=red><b>" & Space(1) & iYearEnd & "</b></font>"
    If iDiff <> 0 Then 
      sMessage &= "<h2><font color=blue>" & "● " & ("Immer mehr als 1 Jahr berechnen? (=langsamer)") & "</font></h2>" 
    Else 
      sMessage &= "<h2><font color=blue>" & "● " & ("Immer berechnen?") & "</font></h2>"   
    Endif 
    If bCurrentYear = False Then 
      sMessage &= "<h2><font color=red>" & ("Achtung") & ": " & ("Ohne aktuelles Jahr!") & "</font></h2>"
    Endif 
    sMessage &= "<br>"
    sMessage &= "<h2><font color=green>" & "○ " & ("Nur") & Space(1) & Year(Date) & "</font></h2>" 
    
    Select Case Message.Question(sMessage, "● " & ("Ja"), "○ " & ("Nein, nur aktuelles Jahr") & Space(1) & Year(Date), ("Abbrechen"))
      Case 1 'years and check
        ValueBoxYearBegin.Value = iYearBegin ' > SettingsReadSave()
        ValueBoxYearEnd.Value = iYearEnd
        Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin
        Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
        RefreshG()
      Case 2
        iYearBegin = Year(Date)
        iYearEnd = Year(Date)
        ValueBoxYearBegin.Value = iYearBegin ' > SettingsReadSave()
        ValueBoxYearEnd.Value = iYearEnd
        Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin
        Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
        ' If iYearBegin <> Year(Date) Then 
        RefreshG()
      Case 3 'Cancel Form_Close(), back to program-page (zurück zur Programm-Seite)
        Stop Event 
        Return 
    End Select
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH, iYearCurrent, iYearBegin, iYearEnd As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form7HTML.Left]
      iY = Settings[F_sForm &/ "Top", Form7HTML.Top]
      iW = Settings[F_sForm &/ "Width", Form7HTML.W]
      iH = Settings[F_sForm &/ "Height", Form7HTML.H]
      Form7HTML.Move(iX, iY, iW, iH)
      ''Year 0000 begin—▶end:
      iYearCurrent = Year(Date)
      iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", iYearCurrent]
      iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", iYearCurrent] 
      ValueBoxYearBegin.Value = iYearBegin
      ValueBoxYearEnd.Value = iYearEnd
      If iYearBegin <> iYearCurrent And iYearEnd <> iYearCurrent Then 
        ValueBoxYearEnd.Value = iYearCurrent
        Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearCurrent
      Endif 
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form7HTML.Left
      Settings[F_sForm &/ "Top"] = Form7HTML.Top
      Settings[F_sForm &/ "Width"] = Form7HTML.Width
      Settings[F_sForm &/ "Height"] = Form7HTML.Height
      ''Year 0000 begin—▶end:
      If ValueBoxYearBegin.Value > 0 Then 
        iYearBegin = ValueBoxYearBegin.Value
        Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin
      Endif 
      If ValueBoxYearEnd.Value > 0 Then 
        iYearEnd = ValueBoxYearEnd.Value
        Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
      Endif 
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  
  Form7HTML.Window.Title = Application.Name & " - " & Format(Now, "yyyy-mm-dd hh:nn ddd") & ": " & ("Heute")
  If Not Form7HTML.Window.Icon Then Form7HTML.Window.Icon = FMain.Window.Icon
  SettingsReadSave("read")  'gb.settings muß zusätzlich aktiviert sein unter Komponenten. Oder Settings.Read(Form7HTML)
  FormBackgroundColor()
  ' Form7HTML.Window.Minimized = False 
  ' Form7HTML.Window.Raise
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    '...
  Else 
    F_sWebComponenteInfo = ("Volle Funktion nur unter Komponente QT4/QT5")
    If Component.IsLoaded("gb.gui") = True Then F_sWebComponenteInfo = "gb.gui" & Space(1) & F_sWebComponenteInfo'switch QT <> GTK
    ButtonSearch.Tooltip = F_sWebComponenteInfo
    ButtonSearchBack.Tooltip = F_sWebComponenteInfo
  Endif 
  
Catch 
  FMain.ErrorText
  ' If System.Error > 0 Then Form7HTML.Window.Close()
  
End

Public Function AdressFileTxt() As String 
  
  Dim sPath As String 
  
  sPath = TextBoxAdress.Text 
  ' sPath = WebView1.Url
  sPath = Replace(sPath, "file:", "")
  sPath = Replace(sPath, "///", "")
  sPath = Replace(sPath, "//", "")
  sPath = Replace(sPath, "/:", "")
  sPath = Replace(sPath, "#heute", "")
  sPath = Replace(sPath, gb.NewLine, "")
  If Exist(sPath) = False Then sPath = FilePathForm()  'Standard
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    FormStart()
    Form_Resize()
    Form7HTML.Window.Minimized = False 
    Form7HTML.Window.Raise
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim sPath As String 
  Dim picIcon As Picture
  
  LabelYearClear.Text = Year(Date)
  F_bCalendarHTMLautomaticRefreshON = Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON", False]
  F_bCalendarQuarterWeekON = Settings[FMain.Name &/ "F_bCalendarQuarterWeekON", False]
  F_bCalendarAllReturnsON = Settings[FMain.Name &/ "F_bCalendarAllReturnsON", False]
  F_bCalendarJumpDateON = Settings[FMain.Name &/ "F_bCalendarJumpDateON", False]
  
  CheckBoxesG()
  sPath = FilePathForm() 'as String 
  If String.LCase(File.Ext(sPath)) <> "html" Then F_sWebFileNew = sPath & ".html"
  TextAreaSearch.SelectAll()
  ' TextAreaSearch.Clear
  TextAreaSearch.Insert(Format(Date, "yyyy-mm-dd")) '"name=#heute" 
  
  picIcon = M01Functions.ExternStandardBrowserIcon() 'as Picture
  If picIcon Then ButtonBrowser.Picture = picIcon.Image.Stretch(22, 22).Picture
  picIcon = Picture.Load("images/info_32.png")
  If picIcon Then ButtonFileInfo.Picture = picIcon.Image.Stretch(22, 22).Picture
  
  PanelText.Background = F_iColorSelectGreen150
  PanelWeb.Background = F_iColorSelectGreen150
  
  ' TextAreaSearch.SetFocus 'Suche
  WindowStretchCursor()
  LabelBgSearch.Background = Color.Default
  LabelBgAutom.Background = Color.Default
  WebView1.Url = "about:blank" 'empty (leer)
  sPath = FilePathForm() '.txt
  IconCreate(False) 'prüfen, aktualisieren in Form7HTML
  TextBoxAdress.Text = sPath 
  MoreButtons(Settings[F_sForm &/ "F_bMoreButtons", True])
  
  SideG("web")
  ' CalendarRefresh(sPath) 
  ValueBoxYearBegin.Background = F_iColorSelectGreen150
  ValueBoxYearBegin.Border = True
  ' ValueBoxYearBegin.SetFocus
  ' TextAreaSearch.SetFocus
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconCreate(Optional IconNeu As Boolean = False)
  
  Dim sDir, sPath, IconPath As String
  Dim picIcon As Picture
  
  sPath = FilePathForm()
  sDir = File.Dir(sPath)
  If Exist(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  IconPath = sDir &/ Application.Name & "_" & "favicon.png" 'besser png statt ico
  If Exist(IconPath) = False Or IconNeu = True Then 'prüfen, fehlt oder neu überschreiben
    picIcon = M07Paint.CreateIconTerminweckerPNG(32).Picture
    If picIcon Then picIcon.Save(IconPath)
  Endif 
  If Exist(IconPath) = False Then 
    If Exist(sDir) = True Then 
      picIcon = Picture.Load("terminwecker.png") ' Programm-Icon laden
      picIcon = picIcon.Image.Stretch(32, 32).Picture
      picIcon.Save(IconPath) 'speichern wohin, Qualität (bei jpg)  im selben Ordner (html + icon), im erlaubten /home/...Verzeichnis
    Endif
  Endif 
  If Exist(IconPath) = True Then 
    PicBoxIcon.Picture = Picture.Load(IconPath) 
  Else 
    PicBoxIcon.Picture = PicTemplateQuestionRoundRed.Picture    
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconPathOpen()
  
  Dim sPath, sPathCache1, sDirFile, sMessage As String 
  Dim picIcon As Picture
  Dim iSize As Integer
  
  sPath = FilePathForm()
  sPath = File.Dir(sPath) &/ Application.Name & "_" & "favicon.png"
  
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png" 
  picIcon = M07Paint.CreateIconTerminweckerPNG(32).Picture
  If picIcon And IsDir(File.Dir(sPathCache1)) = True Then picIcon.Save(sPathCache1)
  If picIcon Then iSize = picIcon.W Else iSize = 32
  
  If Exist(sPathCache1) = True Then 
    sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & iSize & " height=" & iSize & ">" 
  Endif
  sMessage &= "<h3><font color=darkgreen>" & "● " & ("Icon, Favicon, Symbol") & Space(1) & iSize & "x" & iSize & Space(1) & ("Pixel") & "</font></h3>"
  If Exist(sPath) = True Then 
    sMessage &= "<h3><font color=red>" & ("Icon erstellen, überschreiben") & "</font></h3>"
  Endif
  sMessage &= "<font color=gray>" & sPath & "</font>" & "<br>"
  If Exist(sPath) = True Then sDirFile = sPath 
  If Exist(sPath) = False And Exist(sPathCache1) = True Then sDirFile = sPathCache1 
  If Exist(sDirFile) = True Then 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Endif 
  
  Select Case Message.Question(sMessage, "● " & ("Icon erstellen"), ("Ordner..."), ("Abbrechen"))
    Case 1 'Save
      If picIcon And IsDir(File.Dir(sPath)) = True Then picIcon.Save(sPath)
      M01Functions.FileManagerOpen(sPath)
      
    Case 2 'Directory
      M01Functions.FileManagerOpen(sPath)
      
    Case 3 'Cancel
      '...
      
  End Select
  
  If Exist(sPath) = False Then 
    LabelInfoG(("Fehlt") & ": " & sPath)
    PicBoxIcon.Picture = PicTemplateCalendar.Picture
  Else 
    LabelInfoG(("Gefunden") & ": " & sPath)
    PicBoxIcon.Picture = Picture.Load(sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CalendarRefresh(Optional sDirFile As String = "") 
  
  Dim sPath As String
  Dim iYearBegin, iYearEnd As Integer
  
  If Exist(sDirFile) = True Then '...terminwecker.txt
    sPath = sDirFile
  Else 
    sPath = FilePathForm()
  Endif 
  F_sWebFileNew = sPath
  If String.LCase(File.Ext(F_sWebFileNew)) <> "html" Then F_sWebFileNew = F_sWebFileNew & ".html" 
  If Exist(F_sWebFileNew) = True Then F_statWebFileOld = Stat(F_sWebFileNew)
  'FMain.F_bCalendarHTMLautomaticRefreshON = TRUE 'über Timerkalender starten
  
  ProgressBarONoff(True)
  
  ' ''Year 0000 begin—▶end:
  ' iYearBegin = Settings[FMain.Name  &/ "ValueBoxYearBegin.Value", ValueBoxYearBegin.Value] 
  ' iYearEnd = Settings[FMain.Name  &/ "ValueBoxYearEnd.Value", ValueBoxYearEnd.Value] 
  
  F_sWebFileNew = M04Kalender.CalendarReadCreateHTML(sPath, iYearBegin, iYearEnd) 'Text1=Einstellung Jahreszahl 0000
  
  If PanelWeb.Visible = False Then SideG("web")
  
  If String.LCase(File.Ext(F_sWebFileNew)) <> "html" Then F_sWebFileNew = F_sWebFileNew & ".html" 
  If Exist(F_sWebFileNew) = True Then 
    WebCheck()
  Else 
    WebCheck()
    F_iSecondCounter = 0
    Timer1.Enabled = True
  Endif
  Wait 0.5 'for user
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub RefreshG()
  
  Dim sDir, sPath, sDirFile As String 
  Dim iDiff As Integer
  Dim iYearBegin, iYearEnd As Integer
  
  ''Year 0000 begin—▶end:
  If ValueBoxYearBegin.Value Then 
    iYearBegin = ValueBoxYearBegin.Value
    Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin
  Endif 
  If ValueBoxYearEnd.Value Then 
    iYearEnd = ValueBoxYearEnd.Value
    Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
  Endif 
  ''Year 0000 begin—▶end:
  ' Settings[FMain.Name  &/ "ValueBoxYearBegin.Value"] = ValueBoxYearBegin.Value
  ' Settings[FMain.Name  &/ "ValueBoxYearEnd.Value"] = ValueBoxYearEnd.Value
  ' iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", Year(Date)] 
  ' iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", Year(Date)] 
  
  iDiff = iYearEnd - iYearBegin + 1 'Example: 2000 - 2000 = 0  =1x year  as Integer
  LabelInfoSearch.Text = iDiff & Space(1) & ("Kalender-Jahre erstellen") & ". " & ("Bitte warten") & "..."
  
  sPath = FilePathForm()
  sDir = File.Dir(sPath)
  TextBoxAdress.Text = sPath
  CalendarRefresh(sPath) '=>F_sWebFileNew
  If Timer1.Enabled = False Then 
    If Exist(F_sWebFileNew) = True Then 
      TextBoxAdress.Foreground = Color.Gray
    Else
      TextBoxAdress.Foreground = Color.Red
    Endif
    IconCreate(True) 'neu erstellen
    sDirFile = sDir &/ Application.Name & "_" & "favicon.png"
    If Exist(sDirFile) = True Then 
      PicBoxIcon.Picture = Picture.Load(sDirFile) ' Icon zeigen, Browserschalter
    Else 
      PicBoxIcon.Picture = PicTemplateQuestionRoundRed.Picture    
    Endif 
    SideG("web")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_Select() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    LabelInfoG(WebView1.SelectedText)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_MouseUp() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    If WebView1.SelectedText Then 
      LabelInfoG(WebView1.SelectedText)
      If WebView1.SelectedText Then 
        TextAreaSearch.SelectAll()
        TextAreaSearch.Insert(WebView1.SelectedText)
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub InfoG()
  
  If LabelInfoSearch.Text Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(LabelInfoSearch.Text)
  Endif 
  
Catch 
  FMain.ErrorText
  
End 

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = AdressFileTxt() 
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoG(Optional hTextInfo As String = Null) '<HTML>
  
  If hTextInfo Then 
    LabelInfoSearch.Text = hTextInfo
    LabelInfoSearch.Visible = True 
  Else 
    LabelInfoSearch.Text = Null
    LabelInfoSearch.Visible = False 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Dim sPath As String 
  
  sPath = AdressFileTxt() 'as String 
  If Exist(sPath) = False Then sPath = F_sWebFileNew
  Form19FileInfo.Tag = sPath
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True    'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub Timer1_Timer()
  'Timer1.Delay=1000 '=1Sek. Sekundentakt
  
  ProgressBarONoff(True)
  
  F_iSecondCounter = F_iSecondCounter + 1
  If F_iSecondCounter < 7 Then ' Wartezeit begrenzen.
    If PanelWeb.Visible = True And WebView1.Visible = True Then 
      If Exist(F_sWebFileNew) = True Then 'HTML-Kalender einlesen
        If F_statWebFileOld <> Stat(F_sWebFileNew) Then
          Timer1.Enabled = False
          F_iSecondCounter = 0
          WebView1.Url = "file://" & F_sWebFileNew & "#heute"
        Endif
      Endif
    Endif 
  Else 
    F_iSecondCounter = 0
    Timer1.Enabled = False
    ProgressBarONoff(False)
  Endif  
  WebCheck()
  If WebView1.Progress = 1 Then PicBoxWebStatus.Picture = PicTemplateLEDgreen.Picture Else PicBoxWebStatus.Picture = PicTemplateLEDred.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebCheck() 'gb.qt5...
  
  If WebView1.Visible = True Then 
    ''...loading...
    If WebView1.Progress > 0 And WebView1.Progress < 1 Then 'as Float    0, ....loading...., 1 finished
      ProgressBarONoff(True)
      PicBoxWebStatus.Picture = PicTemplateLEDred.Picture
      If M01Functions.CheckQT4QT5() = True Then 
        LabelInfoG(WebView1.Status) 'as String 
      Else 
        LabelInfoG(("Component") & Space(1) & ("qt4/qt5") & Space(1) & ("Fehlt"))
      Endif 
    Else 
      PicBoxWebStatus.Picture = PicTemplateLEDgreen.Picture 
      ProgressBarONoff(False)
      ' LabelInfoG(WebView1.Title)
    Endif
    If Exist(F_sWebFileNew) = False Then 'HTML-Kalender
      LabelInfoG("<b><font color=red>" & ("Datei fehlt") & ": " & "</b></font>" & Space(1) & F_sWebFileNew)
    Endif  
    PicBoxArrowLeft.Picture = PicTemplateWebBefore.Picture
    PicBoxArrowRight.Picture = PicTemplateWebBehind.Picture
    
  Else If TextAreaCode.Visible = True Then
    WebView1.Stop
    ProgressBarONoff(False)
    PicBoxArrowLeft.Picture = PicTemplateUndo.Picture
    PicBoxArrowRight.Picture = PicTemplateRedo.Picture
  Endif
  LabelYearClear.Text = Year(Date)
  ''________________________________________________________''
  ' File or directory does not exist at line #1:
  ' WebView1.Progress  
  ' gb.gui.webview / webview / progress
  ' WebView.Status needs component: (gb.qt4.webkit)
  ' gb.gui.qt.webkit: unable to load 'gb.qt5.webkit' component
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_MouseDown()
  
  LabelBgSearch.Background = Color.White
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_KeyPress()
  
  If Key.Code = Key.Return Then
    SearchText() 'ausführen
    Stop Event 'Vorgang hier abbrechen ohne Key.Return
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_Enter()
  
  LabelBgSearch.Border = Border.Plain 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_Leave()
  
  LabelBgSearch.Border = Border.None 
  
Catch 
  FMain.ErrorText
  
End

Public Sub NewG()
  
  Dim sPath, sEmptyFile, sNew As String
  Dim iDiff As Integer
  
  iDiff = ValueBoxYearEnd.Value - ValueBoxYearBegin.Value
  LabelInfoSearch.Text = iDiff & Space(1) & ("Kalender-Jahre erstellen") & ". " & ("Bitte warten") & "..."
  
  Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = ValueBoxYearBegin.Value
  Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = ValueBoxYearEnd.Value
  
  sPath = FilePathForm()
  
  sEmptyFile = File.Dir(sPath) &/ ("temp_leer.txt")
  sEmptyFile = M01Functions.FileTextPlus(sEmptyFile, "", True) ' TRUE=overwrite (überschreiben)
  If Exist(sEmptyFile) = True Then
    TextBoxAdress.Text = sEmptyFile
    CalendarRefresh(sEmptyFile)
    If File.Ext(sEmptyFile) <> "html" Then sEmptyFile = sEmptyFile & ".html"
    WebView1.Url = "file://" & sEmptyFile & "#heute"
    If PanelWeb.Visible = False Then SideG("web")
    sNew = M01Functions.FileLastModifiedTimeSize(sEmptyFile) 'as String 
    sNew = "<b><font color=green>" & ("Neu, ohne Termine") & ": " & "</b></font>" & Space(1) & sNew
  Else 
    sNew = "<b><font color=red>" & ("Datei fehlt") & ": " & "</b></font>" & Space(1) & sEmptyFile
  Endif 
  LabelInfoG(sNew)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchText(Optional sUpDown As String = "+")
  
  Dim sFindText As String 
  
  TextAreaSearch.SelectAll()
  
  sFindText = TextAreaSearch.Selection.Text
  
  If PanelWeb.Visible = True Then 
    ''Web:
    If WebView1.Visible = True Then 
      If sUpDown = "+" Then '> plus down ▼
        'WebView.FindText(...) needs component: gb.qt4.webkit   and see: gb.gui.webview
        'Function FindText ( [ Text As String, Backward As Boolean, CaseSensitive As Boolean, Wrap As Boolean ] ) As Boolean
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, False, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Else '"-" '< minus up ▲
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, True, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Endif 
      If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
        LabelInfoG(WebView1.SelectedText)
      Endif 
    Else 
      ''Code:
      F_iSearchPosCode = TextAreaTempPos(TextAreaCode, F_iSearchPosCode, sUpDown) 'as Integer
    Endif 
  Else If PanelText.Visible = True Then 
    ''Text:
    F_iSearchPosText = TextAreaTempPos(TextAreaText, F_iSearchPosText, sUpDown) 'as Integer
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Function TextAreaTempPos(Optional hTextArea As TextArea, Optional iLastPos As Integer, Optional sUpDown As String = "+") As Integer
  
  Dim iPos As Integer
  Dim sFindText As String 
  
  sFindText = TextAreaSearch.Text
  
  If hTextArea Then 
    If iLastPos < 0 Then iLastPos = 0
    If sUpDown = "+" Then '> plus down ▼
      iPos = String.InStr(hTextArea.Text, sFindText, iLastPos) 'as Integer  0=not found in String.InStr()
      If iPos > 0 Then 
        ButtonSearch.Background = F_iColorSelectGreen150
      Else 
        ButtonSearch.Background = F_iColorSelectRed150
      Endif 
      ButtonSearchBack.Background = Color.Default
      iLastPos = iPos + 1
    Else '"-" '< minus up ▲
      If iLastPos < String.Len(sFindText) Then iLastPos = String.Len(hTextArea.Text) - 1
      If iLastPos < 1 Then iLastPos = 1
      iPos = String.RInStr(hTextArea.Text, sFindText, iLastPos) 
      If iPos > 0 Then 
        ButtonSearchBack.Background = F_iColorSelectGreen150
      Else 
        ButtonSearchBack.Background = F_iColorSelectRed150
      Endif 
      ButtonSearch.Background = Color.Default
      iLastPos = iPos - 1 
    Endif
    
    If iPos < 1 Then 'not found 
      If LabelBgSearch.Background = F_iColorSelectRed150 Then 
        LabelBgSearch.Background = Color.White
      Else 
        LabelBgSearch.Background = F_iColorSelectRed150
      Endif
      iLastPos = 0
      LabelBgSearch.Text = ("Ende Suche")
    Else 
      LabelBgSearch.Background = F_iColorSelectGreen150 
      If iPos - 1 < 1 Then iPos = 1
      hTextArea.Select(iPos - 1, String.Len(sFindText)) 'begin min. with 1
      LabelBgSearch.Text = ("Position") & ": " & iPos
    Endif
    hTextArea.EnsureVisible()
  Endif 
  
  Return iLastPos
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'Beispielaufruf: 
  'ohne Value         ProgressBarONoff(TRUE)
  'oder direkt mit    ProgressBar1.Value = Zaehler / ColumnView1.Count
  'oder direkt mit    ProgressBar1.Value = 0.99 / ColumnView1.Count * it
  'ProgressBar1.Pulse = True  '◀▷'[......■■...]  False: [■■■□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'zurck zum Anfang
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 'Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckBoxesG()
  
  If F_bCalendarHTMLautomaticRefreshON = True Then ButtonCheckBoxAutom.Picture = PicTemplateConnectON.Picture Else ButtonCheckBoxAutom.Picture = PicTemplateConnectOff.Picture
  
  If F_bCalendarQuarterWeekON = True Then ButtonCheckBoxQKW.Picture = PicTemplateConnectON.Picture Else ButtonCheckBoxQKW.Picture = PicTemplateConnectOff.Picture
  
  If F_bCalendarAllReturnsON = True Then ButtonCheckBoxReturn.Picture = PicTemplateConnectON.Picture Else ButtonCheckBoxReturn.Picture = PicTemplateConnectOff.Picture
  
  If F_bCalendarJumpDateON = True Then ButtonCheckBoxScript.Picture = PicTemplateConnectON.Picture Else ButtonCheckBoxScript.Picture = PicTemplateConnectOff.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxAdress_Enter()
  
  PanelAdress.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxAdress_Leave()
  
  PanelAdress.Background = Color.Transparent
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxAdress_KeyPress()
  
  Dim sPath, sText As String
  
  sPath = Trim(TextBoxAdress.Text)
  
  If Key.Code = Key.Return Then
    If Exist(sPath) = True Then
      sText = File.Load(sPath)
      TextAreaCode.SelectAll()
      TextAreaCode.Insert(sText)
      WebView1.Url = sPath
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub InfoBookmarks_Enter()
  
  ButtonBrowser.Background = F_iColorSelectGreen150
  ButtonBrowser.Border = True 
  InfoBookmarks.Background = F_iColorSelectGreen150
  
Catch 
  FMain.ErrorText
  
End

Public Sub InfoBookmarks_Leave()
  
  ButtonBrowser.Background = Color.Default
  ButtonBrowser.Border = False
  InfoBookmarks.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub StatusG() 'xxx???
  
  If Timer1.Enabled = True Then 
    WebView1.Stop()
    WebView1.Visible = True 
    WebView1.Raise()
    ProgressBarONoff(False)
    PicBoxWebStatus.Picture = PicTemplateStartStop.Picture
  Else 
    Timer1.Start()
    WebView1.Refresh() 'Start ▶
    LabelInfoG(("Start/Reload") & ": " & WebView1.Url & Space(1) & Format(Now, "dddd hh:nn:ss"))
    Wait 0.3
    PicBoxWebStatus.Picture = PicTemplateLEDred.Picture
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_Progress() 'run without click
  
  WebView1.Visible = True 
  WebView1.Raise
  
  ''...loading...
  If WebView1.Progress < 1 Then 'as Float '0=start, 0...webpage loading...1, 1=finished, end
    PicBoxWebStatus.Picture = PicTemplateLEDred.Picture
  Else 'stop or finished
    PicBoxWebStatus.Picture = PicTemplateLEDgreen.Picture 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

' Public Sub WebView1_Status() 'run without click
'   WebView1.Visible = True 
'   WebView1.Raise()
'   LabelInfoG(WebView1.Status) 'as String  'here not .Status()
'   
'   Catch 
'   FMain.ErrorText
' End

Public Sub BrowserG()
  
  Dim sPath, sProgram As String
  
  sPath = AdressFileTxt()
  If Exist(sPath) = True Then
    ButtonBrowser.Background = Color.Green
    If String.LCase(File.Ext(sPath)) <> "html" Then sPath = sPath & ".html"
    If Exist(sPath) = False Then sPath = FMain.F_sPathTerminweckerActual_txt & ".html"
    sPath = "file://" & sPath & "#heute" 
    sProgram = Settings[FMain.Name &/ "F_sBrowserHTMLonlyName", "firefox"]
    If System.Exist(sProgram) = True Then 
      ButtonBrowser.Text = ">" & sProgram
      M01Functions.ExternStart(sProgram, sPath)
    Else 
      ButtonBrowser.Text = ">browser?"
      Desktop.Open(sPath)  
    Endif 
    PanelAdress.Background = Color.Default
  Else
    PanelAdress.Background = F_iColorSelectRed150
  Endif 
  If M01Functions.CheckQT4QT5() = True Then 
    LabelInfoG(WebView1.Status) 'as String  'WebView needs component: gb.qt4.webkit
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyAdressG()
  
  ButtonCopy.Background = Color.Green
  Clipboard.Clear()
  Clipboard.Copy(TextBoxAdress.Text) ' Copy in Clipboard (Zwischenablage)
  'sValue = Clipboard.Paste("text/plain") 'Not forget () (Klammer nicht vergessen!)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyG(Optional CopyAll As Boolean = False)
  
  Dim sText, sSide As String 
  
  ButtonCopy.Background = Color.Green
  
  ''Web:
  If PanelWeb.Visible = True And WebView1.Visible = True Then 
    If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
      If CopyAll = False Then 
        sText = WebView1.SelectedText
      Else 
        'sText = Conv(WebView1.Current.Text, "ASCII", Desktop.Charset) '"ASCII", System.Charset, "ISO-8859-1", Desktop.Charset = "UTF-8"
        sText = WebView1.Current.Text 'STRING.Code  'Returns the current frame.
      Endif 
    Else 
      sText = F_sWebComponenteInfo
    Endif 
  Endif
  
  ''Code:
  If PanelWeb.Visible = True And TextAreaCode.Visible = True Then 
    If CopyAll = False Then 
      sText = TextAreaCode.Selection.Text 
    Else 
      TextAreaCode.SelectAll()
      sText = TextAreaCode.Selection.Text
      ' sText = TextAreaCode.Text
    Endif 
  Endif
  
  ''Text:
  If PanelText.Visible = True And TextAreaText.Visible = True Then 
    If CopyAll = False Then 
      sText = TextAreaText.Selection.Text
    Else 
      TextAreaText.SelectAll()
      sText = TextAreaText.Selection.Text
      ' sText = TextAreaText.Text
    Endif 
  Endif
  
  If CopyAll = True Then sSide = Space(1) & ("Seite") Else sSide = ""
  
  ''Copy, Clipboard, [Zwischenablage]
  If sText Then 
    Clipboard.Clear()
    Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
    'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
    If String.InStr(sText, ">") = 0 Then  
      LabelInfoG("<b>" & ("Kopie") & sSide & ": </b>" & Replace(String.Left(sText, 500), gb.NewLine, gb.Tab))  
    Else
      LabelInfoG("<b>" & ("Kopie") & sSide & ": </b>" & ("in HTML"))   'Note: not show sText <HTML>  
    Endif 
    Wait 1
    If sText And Not Clipboard.Type = Clipboard.Text Then 
      LabelInfoG("<b>" & ("Kopie") & ": </b>" & "<font color=red>" & ("Nicht in der [Zwischenablage] gefunden") & "</font>")
    Endif
  Else 'not Text
    ButtonCopy.Background = F_iColorSelectRed150
    LabelInfoG(("Keine Markierung, keine Kopie."))
  Endif 
  
  ButtonCopy.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form7HTML.Window.Maximized = Not Form7HTML.Window.Maximized 
  If Form7HTML.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form7HTML.Window.FullScreen = True Or Form7HTML.Window.Maximized = True Then 
      F_bMovingON = False
      Form7HTML.Window.FullScreen = False
      Form7HTML.Window.Maximized = False
      If Form7HTML.Left + Form7HTML.W > Screen.AvailableWidth Then Form7HTML.Move(Form7HTML.Left, Form7HTML.Top, Screen.AvailableWidth - Form7HTML.Left, Screen.AvailableHeight - Form7HTML.Top)
    Else
      F_bMovingON = True
      Form7HTML.Window.FullScreen = False
      Form7HTML.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form7HTML.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form7HTML.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form7HTML.ClientW - WindowStretch.W, Form7HTML.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form7HTML.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form7HTML.W = Mouse.ScreenX - F_iX1
    Form7HTML.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form7HTML.ClientW - WindowStretch.W, Form7HTML.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form7HTML.ClientW - WindowStretch.W, Form7HTML.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form7HTML.Window.Maximized = Not Form7HTML.Window.Maximized 
    If Form7HTML.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form7HTML.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize() 
  
  Dim iBW, iBH, iH, iPH, iPH2 As Integer 'Border Width, Border Height, Panel Height
  Dim fRest As Float
  
  If Form7HTML.Width < 200 Then Form7HTML.Width = 200
  If Form7HTML.Height < 200 Then Form7HTML.Height = 200
  
  PicBackground.Move(0, 0, Form7HTML.ClientW, Form7HTML.ClientH)
  IconError.Move(Form7HTML.ClientW - 32, 0, 32, 32)
  
  If F_bMovingON = False Then  
    iBW = PicBackground.Width / 100 * 2.5 'Border, Randbreite
    iBH = PicBackground.Height / 100 * 2.5
    ''************************************
    ' iPH = ButtonAktu.Height 'Panel Hight
    iPH = 50 'ValueBoxYearBegin.Font.TextHeight("0000") + 10 'Panel Hight
    iPH2 = 30'iPH / 2
    ''************************************
    ValueBoxYearEnd.Font = ValueBoxYearBegin.Font
    
    ' InfoBookmarks.Padding = 3  'Border bigger ■ > ▪
    ' InfoBookmarks.Font.Size = iPH2 / 2
    ' ValueBoxYear.H = iPH
    ' ValueBoxYear.Font.Size = iPH2 'Zahl 0000 Jahr
    LabelInfoSearch.Font.Size = iPH2 / 2  'Distance
    
    ''Panels:
    PanelAdress.Move(iBW, iBH, Form7HTML.ClientW - (iBW * 2), iPH)
    PanelMenu.Move(iBW, PanelAdress.Top + PanelAdress.H, PanelAdress.W, iPH2)
    fRest = Form7HTML.ClientH - (iBH * 2) - (iPH * 4.175) 
    PanelWeb.Move(iBW, PanelMenu.Top + PanelMenu.H, PanelAdress.W, fRest)
    PanelText.Move(PanelWeb.Left, PanelWeb.Top, PanelWeb.W, PanelWeb.H)
    PanelLabelinfo.Move(iBW, PanelWeb.Top + PanelWeb.H, PanelAdress.W, iPH + iPH2)
    PanelSearch.Move(0, iPH2, PanelLabelinfo.W, iPH)
    PanelCancel.Move(iBW, PanelLabelinfo.Top + PanelLabelinfo.H, PanelAdress.W, iPH)
    
    ''PanelAdress:
    iH = PanelAdress.H
    ' PicBoxDir.Move(0, 0, iH, iH)
    ButtonMore.Move(0, 0, iH, iH)
    ButtonFileInfo.Move(ButtonMore.Left + ButtonMore.W, 0, iH, iH)
    TextBoxAdress.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelAdress.W - (ButtonFileInfo.Left + ButtonFileInfo.W) - (iH * 5), iH) 'Adresszeile
    PicBoxCopyAdress.Move(TextBoxAdress.Left + TextBoxAdress.W, 0, iH, iH) 'Adresszeile kopieren
    ButtonBrowser.Move(PicBoxCopyAdress.Left + PicBoxCopyAdress.W, 0, PanelAdress.W - (PicBoxCopyAdress.Left + PicBoxCopyAdress.W + iH), iH) 'Browser extern
    PicBoxIcon.Move(PanelAdress.W - iH, 0, iH, iH)
    ProgressBar1.Move(TextBoxAdress.Left, TextBoxAdress.Top, TextBoxAdress.Width, TextBoxAdress.Height)
    
    ''PanelWeb:
    WebView1.Move(0, 0, PanelWeb.W, PanelWeb.H)
    TextAreaCode.Move(0, 0, PanelWeb.W, PanelWeb.H - iPH2)
    PicBoxCodeWrap.Move(0, TextAreaCode.Top + TextAreaCode.H, iPH2, iPH2)
    ButtonCancelCode.Move(PicBoxCodeWrap.Left + PicBoxCodeWrap.W, TextAreaCode.Top + TextAreaCode.H, PanelWeb.W - (PicBoxCodeWrap.Left + PicBoxCodeWrap.W), iPH2)
    
    ''PanelText:
    PanelText.Move(PanelWeb.Left, PanelWeb.Top, PanelWeb.W, PanelWeb.H)
    TextAreaText.Move(0, 0, PanelText.W, PanelText.H - ButtonSaveTxt.H)
    PicBoxTextWrap.Move(0, TextAreaText.Top + TextAreaText.H, ButtonSaveTxt.H, ButtonSaveTxt.H)
    PicBoxTextChangedLED.Move(PicBoxTextWrap.Left + PicBoxTextWrap.W, TextAreaText.Top + TextAreaText.H, ButtonSaveTxt.H, ButtonSaveTxt.H)
    PicBoxTextRefresh.Move(PicBoxTextChangedLED.Left + PicBoxTextChangedLED.W, PicBoxTextChangedLED.Top, ButtonSaveTxt.H, ButtonSaveTxt.H)
    
    ButtonSaveTxt.Move(PicBoxTextRefresh.Left + PicBoxTextRefresh.W, PicBoxTextChangedLED.Top, PanelText.W / 2, ButtonSaveTxt.H)
    ButtonCancelText.Move(ButtonSaveTxt.Left + ButtonSaveTxt.W, PicBoxTextChangedLED.Top, PanelText.W - (ButtonSaveTxt.Left + ButtonSaveTxt.W), ButtonSaveTxt.H)
    
    ''PanelMenu:
    PicBoxWebStatus.Move(0, 0, iPH2, iPH2)
    PicBoxArrowLeft.Move(PicBoxWebStatus.Left + PicBoxWebStatus.W, 0, iPH2, iPH2)
    PicBoxArrowRight.Move(PicBoxArrowLeft.Left + PicBoxArrowLeft.W, 0, iPH2, iPH2)
    InfoBookmarks.Move(PicBoxArrowRight.Left + PicBoxArrowRight.W, 0, PanelMenu.W - (iPH2 * 7), iPH2)
    ' PicBoxSaveCode.Move(InfoBookmarks.Left + InfoBookmarks.W, 0, iPH2, iPH2)
    LabelInfo.Move(InfoBookmarks.Left, InfoBookmarks.Top, InfoBookmarks.W, InfoBookmarks.H)
    PicBoxWeb.Move(InfoBookmarks.Left + InfoBookmarks.W, 0, iPH2, iPH2)
    PicBoxCode.Move(PicBoxWeb.Left + PicBoxWeb.W, 0, iPH2, iPH2)
    PicBoxText.Move(PicBoxCode.Left + PicBoxCode.W, 0, iPH2, iPH2)
    
    ''PanelLabelinfo:
    LabelInfoSearch.Move(0, 0, PanelLabelinfo.W, iPH2) 
    TextAreaSearch.Move(0, 0, TextAreaSearch.Font.TextWidth("0000-00-00") + iPH, iPH)
    fRest = (PanelSearch.W - TextAreaSearch.W) / 9
    ButtonSearch.Move(TextAreaSearch.Left + TextAreaSearch.W, 0, fRest, iPH)
    ButtonSearchBack.Move(ButtonSearch.Left + ButtonSearch.W, 0, fRest, iPH)
    ButtonCopy.Move(ButtonSearchBack.Left + ButtonSearchBack.W, 0, fRest, iPH) 
    ButtonText.Move(ButtonCopy.Left + ButtonCopy.W, 0, iPH, iPH) 
    ButtonCalendarFileRefresh.Move(ButtonText.Left + ButtonText.W, 0, fRest, iPH)
    ButtonCheckBoxAutom.Move(ButtonCalendarFileRefresh.Left + ButtonCalendarFileRefresh.W, 0, fRest, iPH)
    ButtonCheckBoxQKW.Move(ButtonCheckBoxAutom.Left + ButtonCheckBoxAutom.W, 0, fRest, iPH)
    ButtonCheckBoxReturn.Move(ButtonCheckBoxQKW.Left + ButtonCheckBoxQKW.W, 0, fRest, iPH)
    ButtonCheckBoxScript.Move(ButtonCheckBoxReturn.Left + ButtonCheckBoxReturn.W, 0, PanelSearch.W - (ButtonCheckBoxReturn.Left + ButtonCheckBoxReturn.W), iPH)
    
    LabelBgSearch.Move(0, 0, TextAreaSearch.Left + TextAreaSearch.W, TextAreaSearch.H)
    LabelBgAutom.Move(ButtonCalendarFileRefresh.Left, 0, PanelLabelinfo.W - ButtonCalendarFileRefresh.Left, iPH)
    
    ''PanelCancel:
    ValueBoxYearBegin.Move(0, 0, ValueBoxYearBegin.Font.TextWidth("0000") + 20, PanelCancel.H)
    PicBoxArrowUp1.Move(ValueBoxYearBegin.Left + ValueBoxYearBegin.W, 0, ValueBoxYearBegin.H / 2, ValueBoxYearBegin.H / 2)
    PicBoxArrowDown1.Move(PicBoxArrowUp1.Left, PicBoxArrowUp1.Top + PicBoxArrowUp1.H, PicBoxArrowUp1.W, PicBoxArrowUp1.H)
    LabelYearToYear.Move(PicBoxArrowUp1.Left + PicBoxArrowUp1.W, 0, iPH, PanelCancel.H)
    ValueBoxYearEnd.Move(LabelYearToYear.Left + LabelYearToYear.W, 0, ValueBoxYearBegin.W, PanelCancel.H)
    PicBoxArrowUp2.Move(ValueBoxYearEnd.Left + ValueBoxYearEnd.W, 0, ValueBoxYearEnd.H / 2, ValueBoxYearEnd.H / 2)
    PicBoxArrowDown2.Move(PicBoxArrowUp2.Left, PicBoxArrowUp2.Top + PicBoxArrowUp2.H, PicBoxArrowUp2.W, PicBoxArrowUp2.H)
    LabelYearClear.Move(PicBoxArrowUp2.Left + PicBoxArrowUp2.W, 0, iPH, iPH)
    ButtonNew.Move(LabelYearClear.Left + LabelYearClear.W, 0, iPH, iPH)
    ButtonCalendarRefresh.Move(ButtonNew.Left + ButtonNew.W, 0, ButtonCalendarRefresh.Font.TextWidth(ButtonCalendarRefresh.Text) + iPH, iPH)
    ButtonCancel.Move(ButtonCalendarRefresh.Left + ButtonCalendarRefresh.W, 0, PanelCancel.W - (ButtonCalendarRefresh.Left + ButtonCalendarRefresh.W), iPH)
    WindowStretch.Move(Form7HTML.ClientW - iPH - iBW, Form7HTML.ClientH - iPH - iBH, iPH, iPH) 'Quadratisch WxH 1:1
  Endif 'F_bMovingON
  
  ResizeOrder()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizeOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  LabelBgAutom.Lower()
  LabelBgSearch.Lower()
  
  LabelInfo.Raise()
  PanelMenu.Raise() 'Level ▲Top▲ 
  ProgressBar1.Raise() 'Level ▲Top▲ 
  IconError.Raise()
  WebView1.Raise() 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBar1_Enter()
  
  ProgressBarONoff(False)
  
End

Public Sub ButtonGroup_KeyPress()
  
  Select Case String.LCase(Last.Tag) 
    Case "yearbegin"
      If Key.Code = Key.Return Then RefreshG() 
      
    Case "yearend"
      If Key.Code = Key.Return Then RefreshG()  
      
    Case "adress"
      If Key.Code = Key.Return Then SideG("web")
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadCodeG()
  
  SideG("code")
  TextAreaCode.SelectAll()
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    TextAreaCode.Insert(WebView1.Document.HTML)
  Else 
    TextAreaCode.Insert(F_sWebComponenteInfo)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveCodeG() 'unused
  
  Dim sPath, sText, sMessage As String 
  
  WebView1.Stop
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    sText = WebView1.Document.HTML 'WebView.Document needs component: gb.qt4.webkit
  Endif 
  
  If sText Then 
    sPath = WebView1.Url
    sMessage = "<h2><b>" & sPath & "</b></h2>" 
    If Exist(sPath) = True Then 
      sMessage &= "<font color=red><b>" & ("Überschreiben?") & "</b></font>"
    Else 
      sMessage &= "<font color=blue><b>" & ("Speichern?") & "</b></font>"
    Endif 
    
    Select Case Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
      Case 1
        ProgressBarONoff(True)
        Try File.Save(sPath, sText)
        If Error Then 
          ProgressBarONoff(False)
          Message.Warning("Fehler gemeldet" & Space(2) & Error.Text) 
        Else 
          ProgressBarONoff(True)
          Wait 0.5
          PanelWeb.Background = F_iColorSelectGreen150
        Endif 
        WebView1.Reload(False) 'Cache
        ProgressBarONoff(False)
      Case 2
        '...
    End Select
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function SavetxtG() As Boolean
  
  Dim sPath, sMessage As String 
  Dim bEdit As Boolean
  
  sPath = AdressFileTxt() 'as String 'Example: FMain.F_sPathTerminweckerActual_txt
  sMessage = "<h2><font color=silver><b>" & sPath & "</b></font></h2>"
  sMessage &= "<font size=2>" & String.Left(TextAreaText.Text, 100) & "<br>" & "..." & "<br>" & String.Right(TextAreaText.Text, 100) & "<br></font><br><br>"
  If Exist(sPath) = True Then 
    sMessage &= "<font color=blue size=5><b>" & ("Speichern?") & "</b></font>"
  Else 
    sMessage &= "<font color=red size=5><b>" & ("Überschreiben (Speichern)?") & "</b></font>"  
  Endif 
  
  Select Case Message.Question(sMessage, ("Bearbeiten"), ("Speichern"), ("Abbrechen"))
    Case 1
      bEdit = True 
    Case 2
      ProgressBarONoff(True)
      ' Try File.Save(sPath, TextAreaText.Text) 'without Backup
      Try sPath = M01Functions.FileTextPlus(sPath, TextAreaText.Text, True) ' TRUE=overwrite (überschreiben)
      If Error Then 
        ProgressBarONoff(False)
        Message.Warning("Fehler gemeldet" & Space(2) & Error.Text) 
      Else 
        Wait 0.5
        PanelText.Background = F_iColorSelectGreen150 'show effect
        PicBoxTextChangedLED.Picture = PicTemplateLEDgreen.Picture 
      Endif 
      ''Refresh webside:
      WebView1.Reload(False) 'Cache
      LabelInfoG(sPath & Space(3) & "<font color=darkgreen>" & M01Functions.FileLastModifiedText(sPath) & "</font>")
      ProgressBarONoff(False)
      bEdit = False 
    Case 3
      bEdit = False 
  End Select
  
  Return bEdit
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadTextG()
  
  Dim sPath As String 
  
  SideG("text")
  sPath = AdressFileTxt()
  If String.LCase(File.Ext(sPath)) <> "txt" Then sPath = File.SetExt(sPath, "txt")
  If Exist(sPath) = False Then sPath = FilePathForm() 'as String 
  
  ProgressBarONoff(True)
  If TextAreaText.Text = Null Then 
    F_bChangeON = False 
    If Exist(sPath) = True Then 
      TextAreaText.SelectAll()
      ProgressBarONoff(True)
      Try TextAreaText.Insert(File.Load(sPath)) 
      TextAreaText.Unselect()
      ProgressBarONoff(True)
      PanelText.Background = F_iColorSelectGreen150
    Endif 
    PicBoxTextChangedLED.Picture = PicTemplateLEDgreen.Picture 
    F_bChangeON = True 
  Endif 
  
  If Exist(sPath) = True Then 'Note: .FormatSize needs component: (gb.util)
    LabelInfoG(sPath & Space(3) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font>")
  Else 
    LabelInfoG(("ohne Datei") & Space(3) & ("Zeile") & ": " & (TextAreaText.Line + 1)) 
  Endif 
  ButtonSaveTxt.Tooltip = sPath
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TxtRefreshG()
  
  Dim sPath, sNew As String 
  
  ProgressBarONoff(True)
  Wait 0.5
  sPath = AdressFileTxt()
  If Exist(sPath) = False Then sPath = FilePathForm() 'as String
  If Exist(sPath) = True Then 
    TextAreaText.SelectAll()
    ProgressBarONoff(True)
    Try TextAreaText.Insert(File.Load(sPath)) 
    sNew = M01Functions.FileLastModifiedTimeSize(sPath) 'as String 
    sNew = "<b><font color=darkgreen>" & ("Ohne Veränderung") & ": " & "</b></font>" & Space(1) & sNew 
    PanelText.Background = F_iColorSelectGreen150
  Else 
    sNew = "<b><font color=red>" & ("Datei fehlt") & ": " & "</b></font>" & Space(1) & sPath
  Endif 
  LabelInfoG(sNew) 
  ButtonSaveTxt.Tooltip = sPath
  PicBoxTextChangedLED.Picture = PicTemplateLEDgreen.Picture 
  Wait 0.5
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CanceltxtG()
  
  Dim bEdit As Boolean
  
  ''Check:
  If PicBoxTextChangedLED.Picture = PicTemplateLEDred.Picture Then bEdit = SavetxtG()   'Cancel?
  
  If bEdit = False Then 
    SideG("web")
    TextAreaText.SelectAll()
    TextAreaText.Insert("")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LeftRightG(Optional BackOrForward As String = "<")
  
  If PanelText.Visible = True Then 
    Select Case BackOrForward
      Case "<" 
        TextAreaText.Undo() '◀—
      Case Else 
        TextAreaText.Redo() '—▶
    End Select
    PicBoxTextChangedLED.Picture = PicTemplateLEDred.Picture
  Else 'PanelWeb:
    If WebView1.Visible = True Then 
      Select Case BackOrForward
        Case "<" 
          WebView1.Back() '◀— Web-Page
        Case Else 
          WebView1.Forward() '—▶
      End Select
    Else If TextAreaCode.Visible = True Then 
      Select Case BackOrForward
        Case "<" 
          TextAreaCode.Undo() '◀—
        Case Else 
          TextAreaCode.Redo() '—▶
      End Select 
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaCode_MouseUp()
  
  Dim sText As String 
  
  F_iSearchPosCode = TextAreaCode.Pos  'click in Text with new Cursor-Position
  
  If TextAreaCode.Selected = True Then 
    sText = TextAreaCode.Selection.Text
    LabelInfoG(sText) 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(sText) 
  Endif  
  If PanelWeb.Background <> Color.Background Then PanelWeb.Background = Color.Background 'Quell-Code
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaText_MouseUp()
  
  Dim sText As String 
  
  F_iSearchPosText = TextAreaText.Pos  'click in Text with new Cursor-Position
  
  If TextAreaText.Selected = True Then 
    sText = TextAreaText.Selection.Text
    LabelInfoG(sText) 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(sText) 
  Endif  
  If PanelText.Background <> Color.White Then PanelText.Background = Color.White 'Quell-Text
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaText_Change()
  
  If F_bChangeON = True Then 
    PicBoxTextChangedLED.Picture = PicTemplateLEDred.Picture
    LabelInfoG(("Zeile") & ": " & (TextAreaText.Line + 1)) '.Line as Integer
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveTextAs(Optional sExt As String = "txt")
  
  Dim sPath, sText, sTitel, sNew As String 
  Dim ssFilter As New String[]
  
  ssFilter.Add("*.txt") 'Filter
  ssFilter.Add("Nur-Text") 'FilterText
  ssFilter.Add("*.csv") 'Filter
  ssFilter.Add("Tabelle, Trenner: TABulator") 'FilterText
  ' "*" 
  ' "All Files" ' Standard Anhang
  sTitel = Application.Name & " - " & ("Speichern unter...")
  
  sPath = AdressFileTxt()
  sPath = File.SetExt(sPath, sExt)
  
  If PanelText.Visible = True And TextAreaText.Visible = True Then
    sText = TextAreaText.Text  
    sPath = M01Functions.FileDialogSave(sPath, sText, ssFilter, sTitel) 'as String
    If Exist(sPath) = True Then 
      sNew = M01Functions.FileLastModifiedTimeSize(sPath) 'as String 
      sNew = "<b><font color=darkgreen>" & ("Gespeichert") & ": " & "</b></font>" & Space(1) & sNew
      PanelText.Background = F_iColorSelectGreen150
      PicBoxTextChangedLED.Picture = PicTemplateLEDgreen.Picture 
    Else 
      sNew = "<b><font color=red>" & ("Datei fehlt") & ": " & "</b></font>" & Space(1) & sPath
    Endif 
    LabelInfoG(sNew)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideG(Optional WebCodeText As String = "Web")
  
  Dim sPath, sDiff, sHTML, sSpace As String 
  
  sSpace = "&nbsp;" 'Leerzeichen 1x in html
  
  ''Reset:
  WebView1.Stop
  PanelText.Visible = False 
  PanelWeb.Visible = False 
  TextAreaCode.Visible = False 
  WebView1.Visible = False 
  PicBoxWeb.Background = Color.Default
  PicBoxCode.Background = Color.Default
  PicBoxText.Background = Color.Default
  
  sPath = AdressFileTxt()
  LabelInfoPathG(sPath)
  
  Select Case String.Left(String.LCase(WebCodeText), 1)
    Case "w", 1 ''web
      F_iSideWeb1Code2Text3 = 1
      ' WebView1.Url = "about:blank"
      If String.LCase(File.Ext(sPath)) = "html" Then 
        WebView1.Url = "file://" & sPath & "#heute"
      Else 
        WebView1.Url = "file://" & sPath & ".html#heute"
      Endif
      PanelWeb.Visible = True 
      WebView1.Visible = True 
      PicBoxArrowLeft.Picture = PicTemplateWebBefore.Picture
      PicBoxArrowRight.Picture = PicTemplateWebBehind.Picture
      PicBoxWeb.Background = Color.Green
      If Exist(sPath) = True Then sHTML = sPath & ".html"
      If Exist(sHTML) = True Then 
        sDiff = File.Name(sHTML) & String(5, sSpace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sHTML) & "</font>" 
      Else 
        sDiff = "?"
      Endif 
      LabelInfoG("<b>" & ("Web") & ":</b>" & Space(1) & sDiff)
      
    Case "c", 2 ''code
      F_iSideWeb1Code2Text3 = 2
      PanelWeb.Visible = True 
      TextAreaCode.Visible = True  
      PicBoxArrowLeft.Picture = PicTemplateUndo.Picture
      PicBoxArrowRight.Picture = PicTemplateRedo.Picture
      PicBoxCode.Background = Color.Green
      If Exist(sPath) = True Then sHTML = sPath & ".html"
      If Exist(sHTML) = True Then 
        sDiff = File.Name(sHTML) & String(5, sSpace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sHTML) & "</font>" 
      Else 
        sDiff = "?"
      Endif 
      LabelInfoG("<b>" & ("Code") & ":</b>" & Space(1) & sDiff)
      
    Case "t", 3 ''text
      F_iSideWeb1Code2Text3 = 3
      PanelText.Visible = True 
      PicBoxArrowLeft.Picture = PicTemplateUndo.Picture
      PicBoxArrowRight.Picture = PicTemplateRedo.Picture
      PicBoxText.Background = Color.Green
      If Exist(sPath) = True Then 
        sDiff = File.Name(sPath) & String(5, sSpace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font>" 
      Else 
        sDiff = "?"
      Endif 
      LabelInfoG("<b>" & ("Text") & ":</b>" & Space(1) & sDiff)
      
  End Select
  
  ButtonCancelCode.Visible = TextAreaCode.Visible
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtons(Optional bMore As Boolean = True)
  
  If bMore = True Then 
    ButtonMore.Picture = PicTemplateMoreButtonsON.Picture
  Else 
    ButtonMore.Picture = PicTemplateMoreButtonsOff.Picture
  Endif
  
  PicBoxCopyAdress.Visible = bMore
  PicBoxIcon.Visible = bMore
  PanelMenu.Visible = True ' bMore
  PicBoxWebStatus.Visible = bMore
  PicBoxArrowLeft.Visible = bMore
  PicBoxArrowRight.Visible = bMore
  PicBoxWeb.Visible = bMore
  PicBoxCode.Visible = bMore
  PicBoxText.Visible = bMore
  
  LabelYearClear.Visible = bMore 
  ButtonNew.Visible = bMore
  ButtonSearchBack.Visible = bMore
  ButtonCopy.Visible = bMore
  ButtonText.Visible = bMore
  ButtonCalendarFileRefresh.Visible = bMore
  ButtonCheckBoxAutom.Visible = True 'bMore
  ButtonCheckBoxQKW.Visible = bMore
  ButtonCheckBoxReturn.Visible = bMore
  ButtonCheckBoxScript.Visible = bMore
  
  PicBoxArrowUp2.Visible = bMore
  PicBoxArrowDown2.Visible = bMore
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Or Object.Type(Last) = "PictureBox" Then 'no Change=Click in TextBox
    If TextAreaText.Wrap = True Then PicBoxTextWrap.Background = Color.Green Else PicBoxTextWrap.Background = Color.Default
    If TextAreaCode.Wrap = True Then PicBoxCodeWrap.Background = Color.Green Else PicBoxCodeWrap.Background = Color.Default
    If Last.Background <> Color.Green Then Last.Background = F_iColorSelectGreen150
    If Object.Type(Last) = "Button" Then Last.Border = True Else Last.Border = Border.Plain
  Endif 
  If Object.Type(Last) = "Label" Then Last.Background = F_iColorSelectGreen150
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxAdress.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "up", "down", "clear"
      If F_iValueBoxHasFocus = 0 Then 
        ValueBoxYearBegin.Background = Last.Background
        ValueBoxYearEnd.Background = Color.Transparent
      Else 
        ValueBoxYearBegin.Background = Color.Transparent
        ValueBoxYearEnd.Background = Last.Background  
      Endif 
    Case "yearbegin"
      ValueBoxYearBegin.Border = True 
      ValueBoxYearEnd.Border = False
      ValueBoxYearBegin.Background = Last.Background  
      ValueBoxYearEnd.Background = Color.Transparent 
    Case "yearend"
      ValueBoxYearBegin.Border = False 
      ValueBoxYearEnd.Border = True 
      ValueBoxYearBegin.Background = Color.Transparent
      ValueBoxYearEnd.Background = Last.Background  
    Case "refresh", "new"
      ValueBoxYearBegin.Background = Last.Background
      ValueBoxYearEnd.Background = Last.Background
      LabelBgAutom.Background = F_iColorSelectGreen150
      ButtonCalendarFileRefresh.Foreground = Color.Blue
    Case "new"
      ButtonCalendarRefresh.Background = F_iColorSelectGreen150
    Case "copyadress", "panelpath"
      TextBoxAdress.Background = Color.White
    Case "search"
      LabelBgSearch.Background = F_iColorSelectGreen150
    Case "clear", LabelYearClear.Tag 
      LabelYearClear.Background = F_iColorSelectGreen150
    Case ButtonCheckBoxAutom.Tag, ButtonCheckBoxQKW.Tag, ButtonCheckBoxReturn.Tag, ButtonCheckBoxScript.Tag
      LabelBgAutom.Background = F_iColorSelectGreen150 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Or Object.Type(Last) = "PictureBox" Then 'no Change=Click in TextBox
    If Last.Background <> Color.Green Then Last.Background = Color.Default
    If Object.Type(Last) = "Button" Then Last.Border = False Else Last.Border = Border.None
  Endif 
  If Object.Type(Last) = "Label" Then Last.Background = Color.Default
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "up", "down", "clear"
      If F_iValueBoxHasFocus = 0 Then 
        ValueBoxYearBegin.Background = Color.Transparent
      Else 
        ValueBoxYearEnd.Background = Color.Transparent  
      Endif 
    Case "yearbegin"
      ValueBoxYearBegin.Border = False 
    Case "yearend"
      ValueBoxYearEnd.Border = False 
    Case "refresh", "new"
      ValueBoxYearBegin.Background = Color.Transparent
      ValueBoxYearEnd.Background = Color.Transparent
      LabelBgAutom.Background = Color.Default
      ButtonCalendarFileRefresh.Foreground = Color.Default
    Case "new"
      ButtonCalendarRefresh.Background = Color.Default
    Case "copyadress", "panelpath"
      TextBoxAdress.Background = Color.Transparent
    Case "search"
      LabelBgSearch.Background = Color.White
    Case "clear", LabelYearClear.Tag  
      LabelYearClear.Background = Color.Default
    Case ButtonCheckBoxAutom.Tag, ButtonCheckBoxQKW.Tag, ButtonCheckBoxReturn.Tag, ButtonCheckBoxScript.Tag
      LabelBgAutom.Background = Color.Transparent 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Change()
  
  Select Case String.LCase(Last.Tag) 
    Case TextBoxAdress.Tag 
      If Exist(TextBoxAdress.Text) = True Then TextBoxAdress.Foreground = Color.Gray Else TextBoxAdress.Foreground = Color.Red
  End Select
  
Catch 
  FMain.ErrorText
  
End 

Public Sub ButtonGroup_MouseUp()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")

  Dim iYearBegin, iYearEnd As Integer
  
  Select Case String.LCase(sLastTag) 
    Case "adress", TextBoxAdress.Tag 
      TextBoxAdress.Background = Color.White
    Case "browser"
      BrowserG()
    Case "web"
      SideG("web")
    Case "copyadress"
      CopyAdressG()
    Case "copy"
      If Mouse.Left Then 
        CopyG(False)
      Else If Mouse.Right Then 
        CopyG(True) 'all
      Endif 
    Case "icon"
      IconPathOpen() 
    Case "left"
      LeftRightG("<")
    Case "right"
      LeftRightG(">")
    Case "code"
      ReadCodeG()
    Case "status"
      StatusG()
    Case "clear"
      If F_iValueBoxHasFocus = 0 Then 
        ValueBoxYearBegin.Value = Year(Date)
      Else 
        ValueBoxYearEnd.Value = Year(Date)
      Endif 
    Case "yearbegin"
      F_iValueBoxHasFocus = 0
    Case "yearend"
      F_iValueBoxHasFocus = 1
    Case "up1"'▲
      ValueBoxYearBegin.Value = ValueBoxYearBegin.Value - 1 '.Value as Variant
      iYearBegin = ValueBoxYearBegin.Value
      Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin 'as Integer
    Case "down1"'▼
      ValueBoxYearBegin.Value = ValueBoxYearBegin.Value + 1
      iYearBegin = ValueBoxYearBegin.Value
      Settings[FMain.Name &/ "ValueBoxYearBegin.Value"] = iYearBegin
    Case "up2"'▲
      ValueBoxYearEnd.Value = ValueBoxYearEnd.Value - 1
      iYearEnd = ValueBoxYearEnd.Value
      Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
    Case "down2"'▼
      ValueBoxYearEnd.Value = ValueBoxYearEnd.Value + 1
      iYearEnd = ValueBoxYearEnd.Value
      Settings[FMain.Name &/ "ValueBoxYearEnd.Value"] = iYearEnd
    Case "info"
      InfoG()
    Case "fileinfo"
      FileInfoG()
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "morebuttons"
      F_bMoreButtons = Not F_bMoreButtons
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      MoreButtons(F_bMoreButtons)
      Form_Resize()
    Case "searchdown"
      SearchText("+")
    Case "searchup"
      SearchText("-")
    Case "refresh" 'aktualisieren
      RefreshG()
      ' Case "menu"
      '   Menu1.Popup()
      
    Case "checkboxautom", ButtonCheckBoxAutom.Tag 'Refresh automatic (Kalender autom. aktualisieren) 
      F_bCalendarHTMLautomaticRefreshON = Not F_bCalendarHTMLautomaticRefreshON
      Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON"] = F_bCalendarHTMLautomaticRefreshON
      CheckBoxesG()
      RefreshG()
    Case "checkboxqkw", ButtonCheckBoxQKW.Tag 'Quater, CalenderWeek (Quartal, KalenderWoche)
      F_bCalendarQuarterWeekON = Not F_bCalendarQuarterWeekON
      Settings[FMain.Name &/ "F_bCalendarQuarterWeekON"] = F_bCalendarQuarterWeekON
      CheckBoxesG()
      RefreshG()
    Case "checkboxreturn", ButtonCheckBoxReturn.Tag
      F_bCalendarAllReturnsON = Not F_bCalendarAllReturnsON
      Settings[FMain.Name &/ "F_bCalendarAllReturnsON"] = F_bCalendarAllReturnsON
      CheckBoxesG()
      RefreshG()
      TextAreaSearch.SelectAll()
      TextAreaSearch.Insert("¶") 'Return, Ersatz ¶
    Case "checkboxscript", ButtonCheckBoxScript.Tag
      F_bCalendarJumpDateON = Not F_bCalendarJumpDateON
      Settings[FMain.Name &/ "F_bCalendarJumpDateON"] = F_bCalendarJumpDateON
      CheckBoxesG()
      RefreshG()
      TextAreaSearch.SelectAll()
      TextAreaSearch.Insert("<script>") 
      
    Case "new"
      NewG()
    Case "textrefresh"
      TxtRefreshG()
    Case "textwrap"
      TextAreaText.Wrap = Not TextAreaText.Wrap
      ButtonGroup_Enter()
    Case "codewrap"
      TextAreaCode.Wrap = Not TextAreaCode.Wrap
      ButtonGroup_Enter()
    Case "savecode" 'unused
      SaveCodeG()
    Case "loadtxt"
      ReadTextG()
    Case "savetxt"
      ' SavetxtG()
      SaveTextAs()
    Case "canceltxt"
      CanceltxtG()
    Case "cancelcode"
      SideG("web")
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      Form7HTML.Window.Close
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "cancel"
      Form7HTML.Window.Close
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲ 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  
End '..........................................

Public Sub WebView1_MouseDown()

  

End



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form3Text.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form3Text.class
26,2 KB
' Gambas class file

Public F_bChangedON As Boolean
Public F_bESCpressedON As Boolean
Public F_bMovingON As Boolean
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iOnly1x As Integer
Public F_iSearchPosText As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sForm As String = Me.Name 
Public F_sTitleBasicText As String

 
Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Form3Text.Tag
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Form3Text.Window.Title = Application.Name & " - " & ("Lesefenster")
  If Not Form3Text.Window.Icon Then Form3Text.Window.Icon = FMain.Window.Icon
  F_sTitleBasicText = Form3Text.Title
  Menu1.Visible = False
  SettingsReadSave("read")
  FormBackgroundColor()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = F_iOnly1x + 1   '—▷ TextArea1_Change()
    FormStart()
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim sDirFile, sText, sMessage As String
  
  ' sDirFile = FilePathForm() 'as String
  If Exist(Form3Text.Tag) = True Then sDirFile = Form3Text.Tag
  If Exist(sDirFile) = True Then 'Path or Text?
    ProgressBarONoff(True)
    LabelInfoPathG(sDirFile) 
    TextBoxPath.Text = sDirFile
    ButtonSave.Enabled = True 
    TextArea1.SelectAll()
    TextArea1.Insert("wird eingelesen..." & gb.NewLine & gb.NewLine)
    If Stat(sDirFile).Size > 500000 Then 
      ProgressBarONoff(False)
      sMessage = sDirFile & "<br><br>"
      sMessage &= ("Große Datei") & ": " & Space(1) & File.FormatSize(Stat(sDirFile).Size, False)
      Select Message.Question(sMessage, ("weiter..."), ("Abbrechen")) 'File.FormatSize() needs component=gb.util
        Case 1 
          ''...Weiter
        Case 2 
          Form3Text.Window.Close()
          Goto FormEnd
      End Select
    Endif
    
    ''[ESC]?
    If F_bESCpressedON = True Then 
      Select Case Message.Question(sDirFile, ("weiter einlesen") & "...", ("Abbrechen"))
        Case 1 'no cancel
          F_bESCpressedON = False
        Case 2 'cancel
          Goto FormEnd
      End Select
    Endif 
    ProgressBarONoff(True)
    TextArea1.SelectAll()
    Try sText = File.Load(sDirFile)
    ProgressBarONoff(True)
    Try TextArea1.Insert(sText)
  Else
    LabelInfoPathG(("Ohne Datei"))  
    TextBoxPath.Text = ("Ohne Datei")
    ButtonSave.Enabled = False 
    TextArea1.SelectAll()
    If Form3Text.Tag = "" Then TextArea1.Insert(("leer")) Else Try TextArea1.Insert(Form3Text.Tag) 
  Endif
  ButtonSave.Tooltip = TextBoxPath.Text 
  
FormEnd:
  PanelTextArea.Background = Color.Default
  WindowStretchCursor()
  ProgressBarONoff(False)
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  F_bChangedON = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.Esc Then Me.Close
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then Form3Text.Title = ("Abbruch mit [ESC]") Else Form3Text.Window.Title = F_sTitleBasicText
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form3Text.Window.Maximized = False Then
    Form3Text.Window.Maximized = True
  Else
    Form3Text.Window.Maximized = False
    Form3Text.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPart, iPH As Integer
  
  If Form3Text.Width < 200 Then Form3Text.Width = 200
  If Form3Text.Height < 200 Then Form3Text.Height = 200
  
  iPart = Form3Text.ClientW / 17
  iPH = ButtonClose.H 
  
  PicBackground.Move(0, 0, Form3Text.ClientW, Form3Text.ClientH)
  iW = PicBackground.Width / 100 * 3 ' Randbreite
  iH = PicBackground.Height / 100 * 3
  PanelBorder.Move(iW, iH, Form3Text.ClientW - (iW * 2), Form3Text.ClientH - (iH * 2))
  
  ''File-Path:
  PanelBGPath.Move(0, 0, PanelBorder.W, iPH / 2)
  ProgressBar1.Move(0, 0, PanelBGPath.W, PanelBGPath.H)
  ButtonFileInfo.Move(0, 0, iPH, PanelBGPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelBGPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelBGPath.H)
  LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelBGPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), ButtonFileInfo.H)
  
  ''Text:
  PanelTextArea.Move(0, PanelBGPath.Top + PanelBGPath.H, PanelBorder.W, PanelBorder.H - (iPH * 1.5)) 'Background TextArea1
  TextArea1.Move(0, 0, PanelTextArea.W, PanelTextArea.H)
  
  ''Buttons:
  PanelClose.Move(0, PanelTextArea.Top + PanelTextArea.H, PanelTextArea.W, iPH)
  PicBoxPictureToText.Move(0, 0, iPH, iPH)
  ToggleButton1.Move(PicBoxPictureToText.Left + PicBoxPictureToText.W, 0, iPart, iPH)
  ButtonExtern.Move(ToggleButton1.Left + ToggleButton1.Width, 0, iPart, iPH)
  ButtonMinus.Move(ButtonExtern.Left + ButtonExtern.Width, 0, iPart, iPH)
  ButtonPlus.Move(ButtonMinus.Left + ButtonMinus.Width, 0, iPart, iPH)
  ButtonCopy.Move(ButtonPlus.Left + ButtonPlus.Width, 0, iPart, iPH)
  ButtonPanelSearch.Move(ButtonCopy.Left + ButtonCopy.Width, 0, iPart * 2, iPH)
  ButtonEdit.Move(ButtonPanelSearch.Left + ButtonPanelSearch.Width, 0, iPart * 2, iPH)
  ButtonSave.Move(ButtonEdit.Left + ButtonEdit.W, 0, iPart * 3, iPH)
  ButtonClose.Move(ButtonSave.Left + ButtonSave.Width, 0, PanelClose.Width - (ButtonSave.Left + ButtonSave.Width), iPH)
  
  If ButtonEdit.Font.TextWidth(("Bearbeiten") & "...") + iPH > ButtonEdit.W Then ButtonEdit.Text = "" Else ButtonEdit.Text = ("Bearbeiten") & "..."
  If ButtonSave.Font.TextWidth(("Speichern") & "...") + iPH > ButtonSave.W Then ButtonSave.Text = "" Else ButtonSave.Text = ("Speichern") & "..."
  If ButtonClose.Font.TextWidth(("Schliessen")) + iPH > ButtonClose.W Then ButtonClose.Text = "" Else ButtonClose.Text = ("Schliessen")
  ' If ButtonEdit.W < iPH * 2.5 Then ButtonEdit.Text = "" Else ButtonEdit.Text = ("Bearbeiten")
  ' If ButtonSave.W < iPH * 2.5 Then ButtonSave.Text = "" Else ButtonSave.Text = ("Speichern")
  ' If ButtonClose.W < iPH * 2.5 Then ButtonClose.Text = "" Else ButtonClose.Text = ("Schliessen")
  
  PanelSearch.Move(PanelClose.Left, PanelClose.Top, PanelClose.W, PanelClose.H)
  TextAreaSearch.Move(0, 0, PanelSearch.W - (ButtonSearch.W * 3), PanelSearch.H)
  LabelBgSearch.Move(0, 0, TextAreaSearch.W, TextAreaSearch.H)
  ButtonSearch.Move(TextAreaSearch.Left + TextAreaSearch.W, 0, ButtonSearch.W, PanelSearch.H)
  ButtonSearchBack.Move(ButtonSearch.Left + ButtonSearch.W, 0, ButtonSearch.W, PanelSearch.H)
  ButtonSearchCancel.Move(ButtonSearchBack.Left + ButtonSearchBack.W, 0, ButtonSearch.W, PanelSearch.H)
  
  WindowStretch.Height = iPH 
  WindowStretch.Raise() '▲Top Level▲
  If F_bMovingON = False Then WindowStretch.Move(Form3Text.ClientW - iPH - iW, Form3Text.ClientH - iPH - iH, iPH, iPH) 'quadratisch
  IconError.Move(Form3Text.ClientW - 22 - 22, PanelClose.Top, 22, 22)
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End 

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Else 
    LabelInfo.Text = "<font color=red><b>" & ("Ohne Datei") & "</b></font>"
  Endif 
  LabelInfo.Visible = True 
  LabelInfo.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveCheck()
  
  Dim sPath, sMessage As String 
  
  If F_bChangedON = True Then
    sPath = TextBoxPath.Text 'FilePathForm() 'as String 
    If Exist(sPath) = True Then 
      ButtonSaveG()
    Else 
      sMessage = "<h3>" & ("Ohne Datei") & "<br>" 
      sMessage &= "<font color=red>" & ("Text nicht gespeichert") & "</font></h3>" 
      sMessage &= "<h3><font color=blue>" & "○ " & ("Kopieren in die [Zwischenablage]?") & "</font></h3>"
      sMessage &= "<h3><font color=darkgreen>" & "● " & ("Extern im Textprogramm bearbeiten...") & "</font></h3>"
      
      Select Case Message.Question(sMessage, "○ " & ("Kopieren"), "● " & ("Extern im Textprogramm bearbeiten..."), ("Abbrechen")) 
        Case 1 ''Copy:
          TextArea1.SelectAll()
          Clipboard.Clear()
          Clipboard.Copy(TextArea1.Selection.Text)
          Wait 0.5
          TextArea1.Copy()
          
        Case 2
          TextArea1.SelectAll()
          sPath = M01Functions.ProgramDirCache("tempfile.txt")
          If IsDir(File.Dir(sPath)) = True Then File.Save(sPath, TextArea1.Selection.Text)
          LabelInfoPathG(sPath)
          M01Functions.ExternStart("libreoffice", sPath)
          If Exist(sPath) = False Then 
            TextArea1.SelectAll()
            Clipboard.Clear
            Clipboard.Copy(TextArea1.Selection.Text)
          Endif 
          ' Desktop.Open(sPath)
          
        Case 3 ''Cancel:
          ''...
      End Select
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower 'Level Bottom
  LabelBgSearch.Lower()
  PanelSearch.Raise
  IconError.Raise
  WindowStretch.Raise 'Level Top
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfo_Enter()
  
  LabelInfo.Visible = False
  
End

Public Sub ButtonSaveG()
  
  Dim sPath, sMessage As String
  
  ' sPath = FilePathForm() 'FMain.F_sPathTerminweckerActual_txt
  sPath = TextBoxPath.Text
  If Exist(sPath) = True Then 
    sMessage = "<h1><font color=red>" & ("Veränderter Text") & "</font></h1>" 
    sMessage &= "<font color=gray>" & sPath & "</font>"
    
    Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
        
      Case 1 'Speichern
        ButtonSave.Background = Color.Red
        ButtonSave.Border = True 
        ProgressBarONoff(True)
        sPath = M01Functions.FileTextPlus(sPath, TextArea1.Text, True) ' TRUE=overwrite (überschreiben)
        Wait 0.5
        If Exist(sPath) = True Then 
          LabelInfoPathG(sPath)  
          TextBoxPath.Background = Color.Transparent
          PanelTextArea.Background = F_iColorSelectGreen150
          ButtonSave.Background = Color.Default
          F_bChangedON = False
        Else 
          LabelInfoPathG(("Nicht gespeichert"))
          TextBoxPath.Background = F_iColorSelectRed150
        Endif 
        
      Case 2 'Abbrechen
        '...Leerlauf
    End Select
  Endif 
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextArea1_KeyPress()
  
  PanelTextArea.Background = Color.White
  ButtonSave.Background = Color.Red
  ButtonSave.Visible = True 
  F_bChangedON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextArea1_MouseDown()

  F_iSearchPosText = TextArea1.Pos
  
  PanelTextArea.Background = Color.White
  ButtonSave.Background = Color.Red
  ButtonSave.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextArea1_Change()
  
  PanelTextArea.Background = Color.White
  ButtonSave.Background = Color.Red
  ButtonSave.Visible = True 
  If F_iOnly1x > 1 Then F_bChangedON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCopyAll()
  
  TextArea1.SelectAll()
  TextArea1.Copy() 'copy selection Text in Clipboard
  'Clipboard.Clear() ' Zwischenablage löschen.
  Clipboard.Copy(TextArea1.Selection.Text) 'Text in Zwischenablage kopieren.
  'sValue = Clipboard.Paste("text/plain") 'Wieder heraus holen
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonZoomMinus()
  
  Dim bChanged As Boolean
  
  bChanged = F_bChangedON 
  If TextArea1.Font.Size <= 6 Then 'Minimum
    '...Leerlauf
  Else
    TextArea1.Font.Size = TextArea1.Font.Size - 2
  Endif
  F_bChangedON = bChanged 'Reset
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonZoomPlus()
  
  Dim bChanged As Boolean
  
  bChanged = F_bChangedON 
  If TextArea1.Font.Size >= 96 Then 'Maximum
    '...Leerlauf
  Else
    TextArea1.Font.Size = TextArea1.Font.Size + 2
  Endif
  F_bChangedON = bChanged 'Reset
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonOpenExtern(Optional MouseLMR As String = "L")
  
  Dim Ordner, sPath As String
  
  ProgressBarONoff(True)
  Ordner = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String   "/home/terminwecker/"
  sPath = Ordner &/ "temp_" & ("Lesefenster") & ".txt"
  sPath = M01Functions.ProgramDirCache(sPath) '/Ordner/~Datei.txt
  TextArea1.SelectAll()
  ProgressBarONoff(True)
  If IsDir(File.Dir(sPath)) = True Then Try File.Save(sPath, TextArea1.Selection.Text)
  ProgressBarONoff(False)
  ' If System.Find("gedit") = "" And System.Find("libreoffice") = "" Then 'check, gibt String zurück mit Pfad oder Null ""
  '   Desktop.Open(sPath)
  ' Else 
  MouseLMR = UCase(MouseLMR)
  If MouseLMR = "L" Then M01Functions.ExternStart("gedit", sPath)
  If MouseLMR = "R" Then M01Functions.ExternStart("libreoffice", sPath)
  ' Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form3Text.Window.Maximized = Not Form3Text.Window.Maximized 
  If Form3Text.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form3Text.Window.FullScreen = True Or Form3Text.Window.Maximized = True Then 
      F_bMovingON = False
      Form3Text.Window.FullScreen = False
      Form3Text.Window.Maximized = False
      If Form3Text.Left + Form3Text.W > Screen.AvailableWidth Then Form3Text.Move(Form3Text.Left, Form3Text.Top, Screen.AvailableWidth - Form3Text.Left, Screen.AvailableHeight - Form3Text.Top)
    Else
      F_bMovingON = True
      Form3Text.Window.FullScreen = False
      Form3Text.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form3Text.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form3Text.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form3Text.ClientW - WindowStretch.W, Form3Text.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form3Text.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form3Text.W = Mouse.ScreenX - F_iX1
    Form3Text.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form3Text.ClientW - WindowStretch.W, Form3Text.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form3Text.ClientW - WindowStretch.W, Form3Text.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form3Text.Window.Maximized = Not Form3Text.Window.Maximized 
    If Form3Text.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form3Text.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End
Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText

End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")

  Dim sPath As String 
  
  F_bESCpressedON = False
  
  Select Case String.LCase(sLastTag)
    Case "fileinfo"
      FileInfoG()
    Case "copyall"
      ButtonCopyAll()
    Case "zoomminus"
      If Mouse.Left Then 
        ButtonZoomMinus()
      Else If Mouse.Right Then 
        TextArea1.Font.Size = 14
      Endif 
      Settings[FMain.Name &/ "LesefensterLupe"] = TextArea1.Font.Size 
    Case "zoomplus"
      If Mouse.Left Then 
        ButtonZoomPlus()
      Else If Mouse.Right Then 
        TextArea1.Font.Size = 14
      Endif 
      Settings[FMain.Name &/ "LesefensterLupe"] = TextArea1.Font.Size 
    Case "wrap" 
      TextArea1.Wrap = Not TextArea1.Wrap
      Settings[FMain.Name &/ "TextArea1.Wrap"] = TextArea1.Wrap 
      ToggleButton1.Border = Not TextArea1.Wrap 'True/False
    Case "openextern"
      If Mouse.Left Then ButtonOpenExtern("L")
      If Mouse.Right Then ButtonOpenExtern("R")
    Case "edit"
      ButtonEditG()
    Case "save"
      SaveCheck()
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      Form3Text.Window.Close
    Case "dir"
      sPath = FilePathForm()
      If Exist(sPath) = False Then sPath = User.Home
      M01Functions.FileManagerOpen(sPath)
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "picturetotext"
      sPath = TextBoxPath.Text
      If Exist(sPath) = False Then sPath = User.Home
      M01Functions.FileManagerOpen(sPath)
      
    Case "searchpanel"
      PanelSearch.Visible = Not PanelSearch.Visible
      ' PanelClose.Visible = Not PanelSearch.Visible
      PanelTextArea.Background = Color.Default
      
    Case "searchdown"
      SearchText("+")
      
    Case "searchup"
      SearchText("-")
      
    Case "searchcancel"
      PanelSearch.Visible = False 
      PanelTextArea.Background = Color.Default
      
    Case "cancel" 'or [ESC]
      Form3Text.Window.Close
  End Select
  
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End 

Public Sub TextArea1_MouseUp()

  If TextArea1.Selection.Text Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(TextArea1.Selection.Text)
  Endif 

Catch
  FMain.ErrorText
End

Public Sub SearchText(Optional sUpDown As String = "+")
  
  Dim sFindText As String 
  
  TextAreaSearch.SelectAll()
  
  sFindText = TextAreaSearch.Selection.Text
  
  If TextArea1.Visible = True Then 
    ''Text:
    F_iSearchPosText = TextAreaTempPos(TextArea1, F_iSearchPosText, sUpDown) 'as Integer
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Function TextAreaTempPos(Optional hTextArea As TextArea, Optional iLastPos As Integer, Optional sUpDown As String = "+") As Integer
  
  Dim iPos As Integer
  Dim sFindText As String 
  
  sFindText = TextAreaSearch.Text
  
  If hTextArea Then 
    If iLastPos < 0 Then iLastPos = 0
    If sUpDown = "+" Then '> plus down ▼
      iPos = String.InStr(hTextArea.Text, sFindText, iLastPos) 'as Integer  0=not found in String.InStr()
      If iPos > 0 Then 
        ButtonSearch.Background = F_iColorSelectGreen150
      Else 
        ButtonSearch.Background = F_iColorSelectRed150
      Endif 
      ButtonSearchBack.Background = Color.Default
      iLastPos = iPos + 1
    Else '"-" '< minus up ▲
      If iLastPos < String.Len(sFindText) Then iLastPos = String.Len(hTextArea.Text) - 1
      If iLastPos < 1 Then iLastPos = 1
      iPos = String.RInStr(hTextArea.Text, sFindText, iLastPos) 
      If iPos > 0 Then 
        ButtonSearchBack.Background = F_iColorSelectGreen150
      Else 
        ButtonSearchBack.Background = F_iColorSelectRed150
      Endif 
      ButtonSearch.Background = Color.Default
      iLastPos = iPos - 1 
    Endif
    If iPos < 1 Then 'not found 
      If LabelBgSearch.Background = F_iColorSelectRed150 Then 
        LabelBgSearch.Background = Color.White
      Else 
        LabelBgSearch.Background = F_iColorSelectRed150
      Endif
      iLastPos = 0
      LabelBgSearch.Text = ("Ende Suche")
    Else 
      LabelBgSearch.Background = F_iColorSelectGreen150 
      If iPos - 1 < 1 Then iPos = 1
      hTextArea.Select(iPos - 1, String.Len(sFindText)) 'begin min. with 1
      LabelBgSearch.Text = ("Position") & ": " & iPos
    Endif
    hTextArea.EnsureVisible()
  Endif 
  
  Return iLastPos
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonEditG()
  
  Form2Bearb.Window.Show
  ' Form2Bearb.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer2KeyPress_Timer()
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  
  Form3Text.Tag = TextBoxPath.Text
  FormStart()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True 
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Default
    Case "save"
      PanelBGPath.Background = F_iColorSelectGreen150
      LabelInfoPathG(FilePathForm())
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False 
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Gray
    Case "save"
      PanelBGPath.Background = Color.Default
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form3Text.Left]
      iY = Settings[F_sForm &/ "Top", Form3Text.Top]
      iW = Settings[F_sForm &/ "Width", Form3Text.W]
      iH = Settings[F_sForm &/ "Height", Form3Text.H]
      Form3Text.Move(iX, iY, iW, iH)
      TextArea1.Font.Size = Settings[F_sForm &/ "TextArea1.Font.Size", TextArea1.Font.Size]
      TextArea1.Wrap = Settings[F_sForm &/ "TextArea1.Wrap", TextArea1.Wrap] '—▶Public TRUE?
      ToggleButton1.Value = TextArea1.Wrap 
      ToggleButton1.Border = Not TextArea1.Wrap 'True/False
        
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form3Text.Left
      Settings[F_sForm &/ "Top"] = Form3Text.Top
      Settings[F_sForm &/ "Width"] = Form3Text.Width
      Settings[F_sForm &/ "Height"] = Form3Text.Height
      Settings[F_sForm &/ "TextArea1.Font.Size"] = TextArea1.Font.Size 
      Settings[F_sForm &/ "TextArea1.Wrap"] = TextArea1.Wrap 
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SaveCheck()
  SettingsReadSave("save")
  Form3Text.Tag = "" 'Reset
  
Catch 
  FMain.ErrorText
  
End '..........................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form0NurUhr.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form0NurUhr.class
27,1 KB
' Gambas class file

Public F_bESCpressedON As Boolean
Public F_bMovingON As Boolean
Public F_bTopOnly As Boolean
Public F_iFormOpacity As Integer = 80
Public F_iOnly1x As Integer
Public F_iPH As Integer = 42 'Panel Height, Button
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_rectFormXYWH As Rect
Public F_sForm As String = Me.Name 
Public F_sTitleBasicText As String 

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt]
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  If Not Form0NurUhr.Window.Icon Then Form0NurUhr.Window.Icon = FMain.Window.Icon
  F_iOnly1x = 0
  PictureBoxUhr.W = PictureBoxUhr.H '1:1 Circle 
  F_rectFormXYWH = Rect(Me.Left, Me.Top, 300, 300 + F_iPH) 
  SettingsReadSave("read")
  Timer1.Start
  'Automatically next: >Form_Resize() >Form_Activate() >FormStart()
  
Catch 
  FMain.ErrorText 'Public Sub ErrorText()
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    Timer1.Stop
    ButtonBG.Background = Color.Default
    ButtonBG.Border = True
    FormBackgroundColor()
    PicBoxSizeAllCursor()
    WindowStretchCursor()
    CheckMenu()
    TimeLineBeforeG(PicBoxTimeLineBefore.W, PicBoxTimeLineBefore.H)
    Timer1.Start
    Form0NurUhr.Window.Minimized = False 
    Form0NurUhr.Window.Raise
    If Settings[F_sForm &/ "F_iTrayIconSystemON1", 0] = 1 Then 
      FMain.CheckTrayIconSystemOnOff() 'Public True?
    Endif 
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
  If Timer1.Enabled = False Then LabelWeekDay.Foreground = Color.Red Else LabelWeekDay.Foreground = Color.Default 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  ' FMain.F_bFMainSetFocus = True '—▶ FMain
  ' ShowFMain() 'Me Cancel —▶ FMain Show
 
Catch 
  FMain.ErrorText
  
End

Public Sub ShowFMainxxxx()

  FMain.F_bFMainSetFocus = True '—▶ FMain
  ' FMain.F_bFMainSetFocus = False '—▶ FMain
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End 

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then 
    Timer1.Stop()
    Form0NurUhr.Window.Title = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") 
    LabelWeekDay.Foreground = Color.Red
    IconTimerStart.Tooltip = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") 
    IconTimerStart.Visible = True
    IconTimerStart.Raise() 
    Me.Maximized = False
    Me.FullScreen = False
  Else 
    Timer1.Start()
    Form0NurUhr.Window.Title = F_sTitleBasicText
    LabelWeekDay.Foreground = Color.Default 
    IconTimerStart.Visible = False
  Endif 
  
  IconError.Visible = False
  
Catch
  FMain.ErrorText
  
End

Public Sub IconTimerStart_MouseDown()
  
  ESCkeypress()
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form0NurUhr.Window.Maximized = False Then
    Form0NurUhr.Window.Maximized = True
  Else
    Form0NurUhr.Window.Maximized = False
    Form0NurUhr.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPH, iPX As Integer
  Dim sInfo As String 
  
  sInfo = ("Uhr") & Space(1)
  If F_bMovingON = False Then
    If F_rectFormXYWH Then Form0NurUhr.Move(F_rectFormXYWH.X, F_rectFormXYWH.Y, F_rectFormXYWH.W, F_rectFormXYWH.H)
  Endif 
  iW = (Form0NurUhr.W / 100) * 3
  iH = (Form0NurUhr.H / 100) * 3
  
  iPH = F_iPH
  iPX = iPH
  
  ''Min.:
  If Form0NurUhr.W < iPH Then Form0NurUhr.W = iPH
  If Form0NurUhr.H < iPH Then Form0NurUhr.H = iPH 
  ' If Form0NurUhr.W < (iPH * 6) Then iPX = iPH / 2 
  
  IconError.Move(Form0NurUhr.W - iPH, 0, iPH, iPH)
  IconTimerStart.Move(0, 0, iPH, iPH)
  
  PicBackground.Move(0, 0, Form0NurUhr.ClientW, Form0NurUhr.ClientH) 'Hintergrund Aluminium, Holz oder Farbe
  PictureBoxUhr.Move(iW, iH, Form0NurUhr.ClientW - (iW * 2), Form0NurUhr.ClientH - (iH * 2) - iPH)
  PicBoxLEDPlusAlarm.Move(PictureBoxUhr.Left + PictureBoxUhr.W - 20, PictureBoxUhr.Top, 20, 20)
  TextAreaLEDPlusAlarm.move(PictureBoxUhr.Left, PictureBoxUhr.Top, PictureBoxUhr.W, PictureBoxUhr.H)
  
  PanelMenu.Move(iW, Form0NurUhr.ClientH - iH - iPH, Form0NurUhr.ClientW - (iW * 2), iPH)
  
  LabelWeekDay.Move(0, 0, iPH, iPH)
  PicBoxNote.Move(iPH, 0, iPH, iPH)
  PicBoxTopOnly.Move(PicBoxNote.Left + PicBoxNote.W, 0, iPH, iPH)
  If Desktop.Platform = "x11" Then 
    If PicBackground.W > 500 Then ButtonBG.Move(0, 0, iPH * 3, PanelMenu.H) Else ButtonBG.Move(0, 0, PictureBoxUhr.W, PanelMenu.H)
    PicBoxTopOnly.Visible = True 
    ButtonCancel.Move(PicBoxTopOnly.Left + PicBoxTopOnly.W, 0, PanelMenu.W - (PicBoxTopOnly.Left + PicBoxTopOnly.W), iPH)
  Else 
    If PicBackground.W > 500 Then 
      ButtonBG.Move(0, 0, PicBoxNote.Left + PicBoxNote.W, PanelMenu.H)
      ButtonCancel.Move(PicBoxNote.Left + PicBoxNote.W, 0, PanelMenu.W - (PicBoxNote.Left + PicBoxNote.W), iPH)
      ButtonCancel.Visible = True
    Else 
      ButtonBG.Move(0, 0, PictureBoxUhr.W, PanelMenu.H)
      ButtonCancel.Visible = False 
    Endif 
    PicBoxTopOnly.Visible = False 
  Endif
  PicBoxTimeLineBefore.Move(PanelMenu.Left, PanelMenu.Top + PanelMenu.H - 5, PanelMenu.W, iH / 2)
  
  ButtonBG.Text = ""
  If PicBackground.W < iPH * 4 Then 
    ButtonCancel.Text = ""
    ButtonCancel.Picture = Null
    WindowStretch.Picture = Null
  Else 
    ButtonCancel.Text = ("Abbrechen") '×
    ButtonCancel.Picture = Picture["images/closeform_32.png"] 'Picture[] or Picture.Load() '×
    WindowStretch.Picture = Picture["images/formstretch_32.png"]
  Endif 
  
  If F_bMovingON = False Then 
    WindowStretch.Move(Form0NurUhr.ClientW - iPX - iW, Form0NurUhr.ClientH - iPX - iH, iPX, iPX) 'quadratisch. Form_State()
  Endif 
  RaiseOrder()
  
  PictureBoxUhr.Tooltip = sInfo & " " & PictureBoxUhr.W & "x" & PictureBoxUhr.H & " Pixel" & " "
  MenuClockSpuare.Text = ("Uhr-Größe") & Space(1) & ("Breite=Höhe") 
  
  If F_iOnly1x > 0 Then SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  ButtonBG.Raise() 
  PicBoxLEDPlusAlarm.Raise()
  PicBoxTopOnly.Raise()
  PicBoxNote.Raise()
  LabelWeekDay.Raise()
  PicBoxTimeLineBefore.Raise()
  WindowStretch.Raise() 'Level ▲Top▲
  IconTimerStart.Raise()
  IconError.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()
  
  'Timer1.Delay = 1000  '1000=1Sekunde
  
  If String.Len(FMain.F_sErrorMessagesExtra) < 500 Then  'Fehler-Überlauf verhindern
    PictureBoxUhr.Picture = FMain.F_picClock 'aktuelle Uhrzeit holen  'Public True?
    If Not PictureBoxUhr.Picture Then PictureBoxUhr.Picture = M07Paint.ClockDigital(Now).Picture 'as Image
  Else
    ' PictureBoxUhr.Picture = Picture["images/earth_128.png"]
    PictureBoxUhr.Picture = M07Paint.ClockDigital(Now).Picture 'as Image
  Endif
  
  F_sTitleBasicText = Application.Name & "-" & Format(Now, "dddd dd.mmmm")
  LabelWeekDay.Text = Format(Now, "ddd")
  
  If LabelWeekDay.Background <> Color.Green Then 
    If WeekDay(Date) = gb.Sunday Then LabelWeekDay.Background = Color.Yellow Else LabelWeekDay.Background = Color.Default 
  Endif 
  
  PicBoxLEDPlusAlarm.Visible = FMain.PicBoxLEDPlusAlarm.Visible 'Public=True?
  
  If PicBoxLEDPlusAlarm.Visible = True Then 
    PicBoxLEDPlusAlarm.Picture = FMain.PicBoxLEDPlusAlarm.Picture
  ' Endif 
  ' 
  ' If Second(Time) = 1 Then 
    PicBoxLEDPlusAlarm.Tooltip = FMain.PicBoxLEDPlusAlarm.Tooltip ' FMain.F_sVorweckZeitText & gb.NewLine & ("Einstellungen") & "..."
    PicBoxTimeLineBefore.Tooltip = FMain.PicBoxLEDPlusAlarm.Tooltip
  Endif 
  
  TimeLineBeforeG(PicBoxTimeLineBefore.W, PicBoxTimeLineBefore.H)
  
  ' If FMain.F_bClockMessageON = True And FMain.F_bClockAlarmMusicON = True Then 
  '   ' If DateDiff(FMain.F_dateNow, FMain.F_dateVorweckzeit00, gb.Second) = 0 Or DateDiff(FMain.F_dateNow, FMain.F_dateVorweckzeit30, gb.Second) = 0 Or DateDiff(FMain.F_dateNow, FMain.F_dateVorweckzeit60, gb.Second) = 0 Then 
  '   If FMain.F_iNaechsterTermininMinuten - Abs(FMain.F_iVorNachweckzeit30) = 0 Or FMain.F_iNaechsterTermininMinuten - Abs(FMain.F_iVorNachweckzeit60) = 0 Or FMain.F_iNaechsterTermininMinuten = 0 Then 
  '     ShowFMain()
  '   Endif 
  ' Endif 

  If PicBoxTopOnly.Visible = True Then 
    If F_bTopOnly = True Then PicBoxTopOnly.Picture = PicTemplateTopOnlyPlus.Picture Else PicBoxTopOnly.Picture = PicTemplateTopOnlyMinus.Picture '.TopLevel only read
  Endif 
  MenuTopOnly.Enabled = PicBoxTopOnly.Visible
  
  If Timer1.Enabled = False Then LabelWeekDay.Foreground = Color.Red Else LabelWeekDay.Foreground = Color.Default
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub TimeLineBeforeG(Optional hPicBoxW As Integer = 0, Optional hPicBoxH As Integer = 0)
  
  Dim U As Float 
  Dim iMM As Integer
  Dim Img As Image
  
  If FMain.F_iNaechsterTermininMinuten = 0 And FMain.F_bClockAlarmMusicON = True Then
    PicBoxTimeLineBefore.Visible = True 
    PicBoxTimeLineBefore.Picture = Null
    PicBoxTimeLineBefore.Background = Color.SoftRed 'red
  Else If FMain.F_iNaechsterTermininMinuten < 0 Then
    PicBoxTimeLineBefore.Visible = True 
    PicBoxTimeLineBefore.Picture = Null
    PicBoxTimeLineBefore.Background = Color.SetAlpha(Color.SoftRed, 150)
  Else 
    If hPicBoxW > 0 And FMain.F_iNaechsterTermininMinuten > 0 And FMain.F_iNaechsterTermininMinuten < FMain.F_iVorNachweckzeit60 Then 
      PicBoxTimeLineBefore.Background = Color.White
      Img = New Image(hPicBoxW, hPicBoxH, Color.Transparent)
      iMM = FMain.F_iVorNachweckzeit60
      If iMM < 1 Then iMM = 60 
      U = hPicBoxW / iMM 'no zero 
      Paint.Begin(Img)
      Paint.FillRect(hPicBoxW - (U * FMain.F_iVorNachweckzeit30), 0, U * FMain.F_iVorNachweckzeit30, hPicBoxH, Color.Yellow) 
      Paint.FillRect(hPicBoxW - (U * FMain.F_iNaechsterTermininMinuten), 0, U * FMain.F_iNaechsterTermininMinuten, hPicBoxH, Color.SoftGreen) 
      Paint.End
      PicBoxTimeLineBefore.Picture = Img.Picture
      PicBoxTimeLineBefore.Visible = True 
      PicBoxTimeLineBefore.Stretch = True 
    Else 
      PicBoxTimeLineBefore.Background = Color.Transparent
      PicBoxTimeLineBefore.Visible = False 
    Endif  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form0NurUhr.Window.Maximized = Not Form0NurUhr.Window.Maximized 
  If Form0NurUhr.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form0NurUhr.Window.FullScreen = True Or Form0NurUhr.Window.Maximized = True Then 
      F_bMovingON = False
      Form0NurUhr.Window.FullScreen = False
      Form0NurUhr.Window.Maximized = False
      If Form0NurUhr.Left + Form0NurUhr.W > Screen.AvailableWidth Then Form0NurUhr.Move(Form0NurUhr.Left, Form0NurUhr.Top, Screen.AvailableWidth - Form0NurUhr.Left, Screen.AvailableHeight - Form0NurUhr.Top)
    Else
      F_bMovingON = True
      Form0NurUhr.Window.FullScreen = False
      Form0NurUhr.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form0NurUhr.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form0NurUhr.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form0NurUhr.ClientW - WindowStretch.W, Form0NurUhr.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form0NurUhr.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form0NurUhr.W = Mouse.ScreenX - F_iX1
    Form0NurUhr.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form0NurUhr.ClientW - WindowStretch.W, Form0NurUhr.ClientH - WindowStretch.H)
    WindowStretch.Raise()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form0NurUhr.ClientW - WindowStretch.W, Form0NurUhr.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form0NurUhr.Window.Maximized = Not Form0NurUhr.Window.Maximized 
    If Form0NurUhr.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  F_rectFormXYWH = Rect(Me.Left, Me.Top, Me.W, Me.H)
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form0NurUhr.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_Enter()
  
  TextAreaLEDPlusAlarm.Visible = False 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxLEDPlusAlarm_MouseDown()

  Form6Einst.Window.Show
  
  Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxLEDPlusAlarm_Enter()

  TextAreaLEDPlusAlarm.Visible = True 
  TextAreaLEDPlusAlarm.Raise() 'Top
  TextAreaLEDPlusAlarm.Text = PicBoxLEDPlusAlarm.Tooltip & gb.NewLine & FMain.F_sTerminaktuellMeldung 
  
  Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxSizeAllCursor()
  
  If Desktop.Platform = "x11" Then    
    PictureBoxUhr.Cursor = New Cursor(Picture["images/sizeall_64.png"], 32, 32)
    PictureBoxUhr.Mouse = Mouse.Custom
  Else 
    PictureBoxUhr.Mouse = Mouse.Pointing
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PictureBoxUhr_Enter()                                                          'Cursor inside
  
  'Form0NurUhr.Window.Opacity = 100 'no
  PictureBoxUhr.Background = Color.SoftGreen
  ButtonBG.Border = True
  
Catch 
  FMain.ErrorText
  
End 

Public Sub PictureBoxUhr_Leave()                                                          'Cursor inside
  
  'Form0NurUhr.Window.Opacity = F_iFormOpacity
  PictureBoxUhr.Background = Color.Default
  ButtonBG.Border = True 
  
Catch 
  FMain.ErrorText
  
End 

Public Sub PictureBoxUhr_DblClick()
  
  If Mouse.Left = True Then FMainWindow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FMainWindow()

  FMain.FormShowTop() ''Clock <> FMain
    
Catch 
  FMain.ErrorText
End

Public Sub PictureBoxUhr_MouseDown()
  
  If Mouse.Left Then 
    F_bMovingON = True
    PictureBoxUhr.Background = Color.Green
    F_iX1 = Mouse.X + PictureBoxUhr.Left 
    F_iY1 = Mouse.Y + PictureBoxUhr.Top + Desktop.Y
  Endif 
  If Mouse.Right Then 
    Menu1.Popup()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PictureBoxUhr_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form0NurUhr.Move(Mouse.ScreenX - F_iX1, Mouse.ScreenY - F_iY1)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PictureBoxUhr_MouseUp()
  
  F_bMovingON = False 
  ButtonBG.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCancel_Enter()
  
  ButtonCancel.Background = Color.SoftGreen
  
End

Public Sub ButtonCancel_Leave()
  
  ButtonCancel.Background = Color.Default
  
End

Public Sub ButtonCancel_Click()
  
  Form0NurUhr.Window.Close()
  
Catch 
  FMain.ErrorText

End

Public Sub Menu1_Show()
  
  CheckMenu()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckMenu()

  Dim sInfo As String 
  
  If Desktop.Platform = "x11" Then 
    sInfo = ("(Fenstergestalter: X11)")
    mnuUhrfoto.Enabled = True 
  Else If Desktop.Platform = "wayland" Then 
    sInfo = ("(Fenstergestalter: Wayland)")  
    mnuUhrfoto.Enabled = False 'error?
  Endif 
  MenuTopOnly.Checked = F_bTopOnly 'Form0NurUhr.TopOnly 'as Boolean TRUE or FALSE
  If F_bTopOnly = True Then PicBoxTopOnly.Picture = PicTemplateTopOnlyPlus.Picture Else PicBoxTopOnly.Picture = PicTemplateTopOnlyMinus.Picture
  ' If Desktop.Platform = "x11" Then PicBoxTopOnly.Visible = True Else PicBoxTopOnly.Visible = False 
  MenuTopOnly.Enabled = PicBoxTopOnly.Visible
  MenuTopOnly.Picture = PicBoxTopOnly.Picture
  MenuTopOnly.Text = Replace(MenuTopOnly.Text, sInfo, "") & Space(3) & sInfo 'only 1x
  PicBoxNote.Picture = FMain.ButtonNote.Picture 'Public True?
  PicBoxNote.Tooltip = FMain.ButtonNote.Tooltip
  If FMain.F_bClockAlarmMusicON = True Then 
    MenuNote.Picture = FMain.PicTemplateNoteGreen.Picture 'Public True?
  Else 
    MenuNote.Picture = FMain.PicTemplateNoteRed.Picture
  Endif 
  MenuNote.Checked = FMain.F_bClockAlarmMusicON
  PicBoxLEDPlusAlarm.Picture = FMain.PicBoxLEDPlusAlarm.Picture 'Public True?
  PicBoxLEDPlusAlarm.Tooltip = FMain.PicBoxLEDPlusAlarm.Tooltip
  PicBoxLEDPlusAlarm.Visible = FMain.PicBoxLEDPlusAlarm.Visible
  
  MenuPlusAlarm.Checked = FMain.F_bClockAlarmBeforeBehindON
  MenuPlusAlarm.Text = ("Plus-Alarm -vorher/+nachher") & Space(1) & FMain.F_iVorNachweckzeit60 & ", " & FMain.F_iVorNachweckzeit30 
  If MenuPlusAlarm.Checked = True Then 
    MenuPlusAlarm.Picture = FMain.PicBoxLEDPlusAlarm.Picture
  Else 
    MenuPlusAlarm.Picture = FMain.PicBoxLEDPlusAlarm.Picture.Image.Desaturate().Picture
  Endif 
  PicBoxLEDPlusAlarm.Visible = MenuPlusAlarm.Checked
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelWeekDay_Enter()
  Dim sText As String
  
  LabelWeekDay.Background = Color.Green
  If FMain.F_sNaechsterTermin Then
    sText = ("Wochentag") & gb.NewLine & ("Termine") & ": " & gb.NewLine & FMain.F_sNaechsterTermin 
  Else 
    sText = ("Wochentag") & gb.NewLine & ("Termine") & ": " & ("keine")
  Endif 
  LabelWeekDay.Tooltip = sText 
  
  If FMain.F_sErrorInfos Then 
    IconError.Visible = True 
    IconError.Raise() '▲Top▲
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelWeekDay_Leave()
  
  LabelWeekDay.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelWeekDay_MouseDown()
  
  If Mouse.Left = True Then ButtonBG_MouseUp()
  
Catch 
  FMain.ErrorText

End

Public Sub ButtonBG_Enter()
  
  ButtonBG.Border = True 
  ButtonBG.Background = Color.SoftGreen
  'Form0NurUhr.Window.Opacity = 100 'no
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonBG_Leave()
  
  ButtonBG.Border = True 
  ButtonBG.Background = Color.Default
  'Form0NurUhr.Window.Opacity = F_iFormOpacity
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonBG_MouseUp()

  ButtonBG.Border = True 
  Form0NurUhr.Window.Close()  'Me. = Form0NurUhr.Window.
    
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
      
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", FMain.PicBoxClock.ScreenX]
      iY = Settings[F_sForm &/ "Top", FMain.PicBoxClock.ScreenY]
      iW = Settings[F_sForm &/ "Width", FMain.PicBoxClock.W]
      iH = Settings[F_sForm &/ "Height", FMain.PicBoxClock.W] ' H=W, 1:1, FMain.PicBoxClock.H
      F_bTopOnly = Settings[F_sForm &/ "F_bTopOnly", F_bTopOnly] 
      F_rectFormXYWH = Rect(iX, iY, iW, iH)
      ' Form0NurUhr.Move(iX, iY, iW, iH)
      Form0NurUhr.Window.TopOnly = F_bTopOnly 'Gambas3: "Returns or sets if a window stays on top on all other windows."
      F_iFormOpacity = Settings[F_sForm &/ "F_iFormOpacity", F_iFormOpacity]
      ' Try 'Form0NurUhr.Window.Opacity = F_iFormOpacity '(gb.qt4) Note: .Opacity not in all linux-family possible  
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form0NurUhr.Left
      Settings[F_sForm &/ "Top"] = Form0NurUhr.Top
      Settings[F_sForm &/ "Width"] = Form0NurUhr.Width
      Settings[F_sForm &/ "Height"] = Form0NurUhr.Height
      Settings[F_sForm &/ "F_bTopOnly"] = F_bTopOnly
      Settings[F_sForm &/ "F_iFormOpacity"] = F_iFormOpacity
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuUhrfotoG()
  
  Dim sPath, sDir, sFile, sMessage, sMessagePic As String
  Dim picScreen As Picture
  Dim imgScreen, imgCut As Image
  Dim fRel As Float
  
  If Menu1.Visible = True And String.LCase(Desktop.Platform) = "x11" Then 
    Menu1.Close() 'Menü sicher ausblenden
    Wait 0.3
  Endif 
  
  sFile = "temp_" & ("foto") & "-" & Application.Name & ".png"
  sPath = M01Functions.ProgramDirCache(sFile) '/directory/file.png
  
  ''Foto:
  ' picScreen = Desktop.Screenshot() 'as Picture
  picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  ' imgScreen = Desktop.Screenshot().Image
  If Error Then picScreen = Null
  If picScreen Then imgScreen = picScreen.Image 'Convert Picture > Image
  
  If M01Functions.ScreenshotImageExist(imgScreen) = False Then  
    imgScreen = M01Functions.ScreenshotImageAlternative()
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  
  If imgScreen Then 
    imgCut = imgScreen.Copy(PictureBoxUhr.ScreenX, PictureBoxUhr.ScreenY, PictureBoxUhr.W, PictureBoxUhr.H) 'without Frame-Title ■■■■■×
  Endif 
  
  If imgCut Then
    fRel = imgCut.W / imgCut.H
    imgCut.Save(sPath)
    If Exist(sPath) = False Then 
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sPath = sDir &/ sFile 
      If IsDir(sDir) = True Then imgCut.Picture.Save(sPath)
    Endif 
  Endif 
  
  If Exist(sPath) = True Then 
    sMessagePic &= "<img src=" & Quote("file://" & sPath) & " width=" & Round(fRel * 100) & " height=100 >" 
  Endif  
  sMessage = "<h2><font color=darkgreen>" & ("Uhr-Foto") & "</font></h2>" 
  If imgCut And Exist(sPath) = True Then 
    sMessage &= "<br>" & sMessagePic & "<br>"
    sMessage &= "<font color=gray>" & ("Ausschnitt") & Space(1) & imgCut.W & " x " & imgCut.H & " px (Pixel)" 
    sMessage &= Space(1) & ("Größe") & ": " & M01Functions.FileSizeLongText(Stat(sPath).Size) & "</font>"
    sMessage &= "<h2><font color=darkgreen>" & ("Bild-Datei öffnen") & ":" & "</font></h2>" 
  Endif 
  
  sMessage &= "<h4><font color=gray>" & sPath & "</font></h4>" 
  If Exist(sPath) = False Then sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
  If Desktop.Platform = "wayland" Then 'bug top left?
    sMessage &= "<h4><font color=red>" & ("Fenster-System") & ": " & Desktop.Platform & "</font></h4>"
  Endif 
  
  ''Show:
  Select Case Message.Question(sMessage, ("Ordner..."), ("Bild-Programm..."), ("Abbrechen"))
    Case 1
      M01Functions.FileManagerOpen(sPath)
    Case 2
      ' M01Functions.ExternStart("gimp", sPath)
      Desktop.Open(sPath)
    Case 3 'Abbrechen
      '...Leerlauf
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.IconError()
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  'Form0NurUhr.Window.Opacity = 100 'no
  Last.Background = Color.SoftGreen
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  'Form0NurUhr.Window.Opacity = F_iFormOpacity
  Last.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  If Object.Type(Last) <> "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click() 'see Properties, PopupMenu = ...
  Dim sTag As String
  
  If Object.Type(Last) = "Menu" Then
    sTag = Last.Tag
    Menu1.Close()
    Wait 1
    ButtonGroupSelect(sTag)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  Dim iPH As Integer
  
  iPH = F_iPH 'Pixel —▶ Form_Resize()
  
  Select Case String.LCase(sLastTag)
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "toponly"
      If Desktop.Platform = "x11" Then 
        F_bTopOnly = Not F_bTopOnly
        Form0NurUhr.Window.TopOnly = F_bTopOnly
      Else 
        F_bTopOnly = False
      Endif
      CheckMenu()
    Case "note"
      FMain.CheckClockAlarmButtonNoteOnOff(True) 'Public True
      CheckMenu()
    Case "plusalarm"
      FMain.F_bClockAlarmBeforeBehindON = Not FMain.F_bClockAlarmBeforeBehindON
      Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = FMain.F_bClockAlarmBeforeBehindON
      CheckMenu()
    Case "photoside" 
      Form15Foto.Window.Show
    Case "clockdesign"
      Form14UhrDesign.Window.Show
      Form14UhrDesign.Refresh()
      Wait 0.5
      ' Form14UhrDesign.FormBackgroundColor()
    Case "photowindow"
      'Form0NurUhr.Window.Opacity = 100 'no
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      'Form0NurUhr.Window.Opacity = F_iFormOpacity
    Case "photoclock"
      'Form0NurUhr.Window.Opacity = 100 'no
      mnuUhrfotoG()

    Case "square"'■=● M1:1
      Form0NurUhr.Window.Maximized = False
      F_rectFormXYWH = Rect(Me.Left, Me.Top, Me.H, Me.H + iPH)
      Form_Resize()
    Case "100" '100x100 Pixel
      PictureBoxUhr.H = 100 
      Form0NurUhr.Window.Maximized = False
      F_rectFormXYWH = Rect(Me.Left, Me.Top, PictureBoxUhr.H, PictureBoxUhr.H + iPH)
      Form_Resize()
    Case "500"
      PictureBoxUhr.H = 500 
      Form0NurUhr.Window.Maximized = False
      F_rectFormXYWH = Rect(Me.Left, Me.Top, PictureBoxUhr.H, PictureBoxUhr.H + iPH)
      Form_Resize()
    Case "errormessages", "iconerror"
      M01Functions.IconError()
    Case "showfmain"
      FMainWindow()
    Case "cancelform"
      ButtonBG_MouseUp()
  End Select  
  
Catch 
  FMain.ErrorText
  
End '....................................................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form4Bis.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form4Bis.class
20,9 KB
' Gambas class file

'F_ = Form
Public F_bChangeON As Boolean '=False (Default)
Public F_bListChanged As Boolean
Public F_bMovingON As Boolean
Public F_dateDatum As Date
Public F_iDiffDatum As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sDatumText As String
Public F_sForm As String = Me.Name 
Public F_sText5Notiz As String

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt]
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form4Bis.Window.Maximized = False Then
    Form4Bis.Window.Maximized = True
  Else
    Form4Bis.Window.Maximized = False
    Form4Bis.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Dim sDirFile, sPath, sLine As String
  Dim ssSpli As String[]
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  Menu1.Visible = False
  Form4Bis.Window.Title = Application.Name & " - " & ("+Bis")
  If Not Form4Bis.Window.Icon Then Form4Bis.Window.Icon = FMain.Window.Icon
  sLine = FMain.F_sTerminUntilLine
  
  ''From Settings:
  If Not sLine Then sLine = Settings[FMain.Name &/ "F_sTerminUntilLine", sLine] 
  
  ''From File:
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt]
  If Not sLine And Exist(sDirFile) = True Then sLine = File.Load(sDirFile)
  
  LabelPath.Text = sDirFile & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>"
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt] 
  LabelPath.ToolTip = File.Dir(sPath) & "/" & "<font color=blue>" & File.Name(sPath) & "</font>" & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font>"
  
  ''Split, trennen:
  If sLine Then 
    sLine = Replace(sLine, "¶", hReturn)
    ssSpli = Split(sLine & String(6, hTab), hTab)
    If ssSpli.Count >= 5 Then 
      Text0.SelectAll()
      Text0.Insert(ssSpli[0])
      ssSpli[5] = Replace(ssSpli[5], hReturn & hReturn, hReturn) 
      Text5.SelectAll()
      Text5.Insert(ssSpli[5]) 'Text5.Text without Undo/Redo
    Endif
    F_sDatumText = Text0.Text
    F_sText5Notiz = Text5.Text
  Endif 
  If Not FMain.F_iSelectGreenAlpha150 Then FMain.F_iSelectGreenAlpha150 = Color.SetAlpha(Color.Green, 150)
  Text0.Background = FMain.F_iSelectGreenAlpha150
  Text5.Background = FMain.F_iSelectGreenAlpha150
  ButtonSave.Background = Color.ButtonBackground
  ButtonSave.ToolTip = ("Speichern in") & ": " & Space(1) & sDirFile
  
  SettingsReadSave("read")
  FormBackgroundColor()
  WindowStretchCursor()
  Text0.SetFocus
  
  F_bChangeON = False 
  F_bListChanged = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
    
Catch 
  FMain.ErrorText
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() '▼Level Bottom▼
  WindowStretch.Raise() '▲Level Top▲
  ButtonSave.Raise()
  IconError.Raise()
  PanelDateChooser.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sMessage As String 
  
  SettingsReadSave("save")
  
  If F_bListChanged = True Then
    sMessage = "<h1><font color=red>" "○ " & ("Veränderter Text") & "</font></h1>" 
    sMessage &= "<font color=gray>" & FilePathForm() & "</font> "
    
    Select Message.Question(sMessage, "○ " & ("Speichern"), ("Schliessen"), ("Abbrechen"))
      Case 1 'Save:
        SaveG()
      Case 2 'Close:
        '...Leerlauf
      Case 3 'Cancel:
        Stop Event  ' Vorgang abbrechen
    End Select
  Endif
  
  If FMain.Visible = True Then 'not in Test > Error
    FMain.F_iDaysMinusOrPlus = F_iDiffDatum
    FMain.RefreshAll(FMain.F_iDaysMinusOrPlus)
    ' FMain.TimerRefreshAll.Start() 'Public = True?
    ' FMain.F_bNeueinlesenStarten = True  'See FMain.RefreshAll()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPH As Integer
  
  '********************
  iPH = 40 'as Integer, Panel Height
  '********************
  
  If Form4Bis.Width < 400 Then Form4Bis.Width = 400
  If Form4Bis.Height < 400 Then Form4Bis.Height = 400
  
  PicBackground.Move(0, 0, Form4Bis.ClientW, Form4Bis.ClientH)
  iW = PicBackground.Width / 100 * 5 '3 ' Randbreite
  iH = PicBackground.Height / 100 * 5 '3
  
  IconError.Move(Form4Bis.ClientW - 32, 0, 32, 32)
  
  ''Panel:
  PanelBorder.Move(iW, iH, Form4Bis.ClientW - (iW * 2), Form4Bis.ClientH - (iH * 2))
  LabelTitle1.Move(0, 0, PanelBorder.W, LabelTitle1.Font.TextHeight(LabelTitle1.Text))
  LabelTitle1b.Move(LabelTitle1.Left - 2, LabelTitle1.Top + 2, LabelTitle1.Width, LabelTitle1.Height)
  LabelTitle1b.Font = LabelTitle1.Font
  LabelInputInfo.Move(0, LabelTitle1.Top + LabelTitle1.H, LabelTitle1.W, LabelInputInfo.H)
  Text0.Move(0, LabelInputInfo.Top + LabelInputInfo.H, LabelInputInfo.W, Text0.Font.TextHeight(Text0.Text) + 10)
  ButtonDateChooser.Move(Text0.Left + Text0.W - ButtonDateChooser.W, Text0.Top, ButtonDateChooser.W, Text0.H)
  LabelDatum.Move(0, Text0.Top + Text0.H, Text0.W, LabelDatum.Font.TextHeight(LabelDatum.Text))
  LabelNotiz.Move(0, LabelDatum.Top + (LabelDatum.H * 2), LabelDatum.W, LabelNotiz.Font.TextHeight(LabelNotiz.Text))
  ButtonSave.Move(0, PanelBorder.H - iPH, PanelBorder.W / 2, iPH)
  ButtonCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, ButtonSave.W, iPH)
  Text5.Move(0, LabelNotiz.Top + LabelNotiz.H, Text0.W, ButtonSave.Top - (LabelNotiz.Top + LabelNotiz.H) - iPH)
  LabelPath.Move(0, Text5.Top + Text5.H, Text5.W, iPH)
  
  ''Panel:
  PanelDateChooser.Move(Text0.Left, LabelDatum.Top + LabelDatum.H, Text0.W, PanelBorder.H - LabelNotiz.Top + iH)
  DateChooser1.Move(0, 0, PanelDateChooser.W, PanelDateChooser.H - iPH)
  DateCancel.Move(0, DateChooser1.Top + DateChooser1.H, DateChooser1.W, PanelDateChooser.H - DateChooser1.H)
  
  ''Stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form4Bis.ClientW - iPH - iW, Form4Bis.ClientH - iPH - iH, iPH, iPH) 'quadratisch
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG()
  
  Dim sLine, sMessage, sT5 As String
  Dim sDirFile, sPath, sDir, sFile As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt]
  
  ''Check:
  sT5 = Replace(Text5.Text, hReturn, "¶")
  sT5 = Replace(sT5, gb.NewLine, "¶")
  
  If Not F_dateDatum Then sMessage &= "<font color=red>" & ("Datum fehlt") & "</font><br>"
  If String.Len(Replace(sT5, gb.NewLine, "¶")) = 0 Then sMessage &= "<font color=red>" & ("Notiz-Text fehlt") & "</font><br>"
  
  If sMessage Then 
    Message.Info(sMessage, ("Abbrechen"))
  Else 
    
    sLine = M01Functions.CreateDateNotizLine(F_dateDatum, sT5) 'as String
    
    ''Save:
    If sLine Then 'in .config  [settings]
      FMain.F_sTerminUntilLine = sLine
      ''Save in Settings:
      Settings[FMain.Name &/ "F_sTerminUntilLine"] = sLine
      If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt] ''Alternative in File 
      ''Save in File:
      '********************************************************
      sDirFile = M01Functions.FileTextPlus(sDirFile, sLine, True) ' TRUE=overwrite (überschreiben)
      '********************************************************
      TerminweckerFilePlusLine()
      LabelPath.Text = sDirFile & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" 'Time or "?"
      sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt] 
      LabelPath.ToolTip = sPath & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font>"
    Endif
    
    ''Check:
    If Exist(sDirFile) = False Then
      sDir = File.Dir(sDirFile)
      sFile = File.Name(sDirFile)
      sMessage = sDir & "/<br>" 
      sMessage &= "<font color=red>" & sFile & "</font><br><br>"
      sMessage &= "<font color=red><b>" & ("Datei nicht gefunden") & "." & "</b></font>"
      Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
        Case 1 'Directory...
          If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
          M01Functions.FileManagerOpen(sDirFile)
        Case 2 'Cancel
          '...Leerlauf 
      End Select
    Else ''Reset:
      F_bListChanged = False
      ButtonSave.Background = Color.Default
      ButtonSave.Border = False 
      ButtonCancel.Border = True 
      ButtonCancel.Background = Color.Green
      If FMain.F_iSelectGreenAlpha150 Then 
        Text0.Background = FMain.F_iSelectGreenAlpha150
        Text5.Background = FMain.F_iSelectGreenAlpha150
      Endif 
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TerminweckerFilePlusLine()
  
  Dim sLine, sPath, sYYYYMMDD, sHHNN, sT5 As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If F_dateDatum Then 
    sYYYYMMDD = Format(F_dateDatum, "yyyy-mm-dd")
    sHHNN = Format(F_dateDatum, "hh:nn")
    sT5 = Replace(Text5.Text, gb.NewLine, "¶")
    sLine = M01Functions.TerminweckerLine(sYYYYMMDD, sHHNN, sT5)
    If sLine Then 
      If String.InStr(sLine, hReturn) = 0 Then sLine = sLine & hReturn
      If Not FMain.F_sPathTerminweckerActual_txt Then FMain.F_sPathTerminweckerActual_txt = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt] 
      sPath = M01Functions.FileTextPlus(FMain.F_sPathTerminweckerActual_txt, sLine, False) ' TRUE=overwrite (überschreiben)
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Change()
  
  F_dateDatum = DateChooser1.Value  'as Date
  Text0.SelectAll()
  Text0.Insert(Format(F_dateDatum, "yyyy-mm-dd"))
  Text0.Tag = F_dateDatum 'as Variant < as Date
  CheckText0Date()
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooserONoff()
  
  If PanelDateChooser.Visible = True Then
    PanelDateChooser.Visible = False
    ButtonDateChooser.Background = Color.Default
  Else
    PanelDateChooser.Visible = True
    ButtonDateChooser.Background = Color.Green
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()
  '2 Sekundentackt Timer1.delay
  
  If Text0.Text Then CheckText0Date()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub Text0_KeyPress()
  'IF String.InStr("0123456789-+", Key.Text) > 0 OR Key.Code = Key.BackSpace OR Key.Code = Key.Delete THEN
  
  If M01Functions.KeyPressCheck("0123456789-+", Key.Text, Key.Code) = True Then
    '... erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_Change()
  
  Text0.Background = Color.White
  ButtonSave.Background = Color.Red
  TextChanged()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5_Change()
  
  Text5.Background = Color.White
  ButtonSave.Background = Color.Red
  TextChanged()
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextChanged()
  
  If Text0.Text <> F_sDatumText Or Text5.Text <> F_sText5Notiz Then
    ButtonSave.Background = Color.Red
    ButtonSave.Default = True 
    ButtonSave.Border = True
    ButtonCancel.Background = Color.Default
    F_bChangeON = True 
    F_bListChanged = True 
  Else
    ButtonSave.Background = Color.Default
    ButtonSave.Default = False
    ButtonCancel.Background = Color.Default
    F_bChangeON = False  
    F_bListChanged = False 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckText0Date()   
  'abgesehen von Eingabe: Intern nur ein Datumformat weiter bearbeiten  GDatumMMDDYYYY
  
  Dim sTage, sT0, sTestDatum As String
  Dim ssSpli As String[] 
  Dim dateHeute As Date
  Dim dateDatum As Date     'yyyy-mm-dd 0-1-2 > mm/dd/yyyy 1-2-0
  
  dateHeute = Date
  sT0 = Text0.Text 
  If String.Left(sT0, 1) = "-" Or String.Left(sT0, 1) = "+" Or String.InStr(sT0, "-") = 0 Then 'auch ohne +
    sT0 = Replace(sT0, "+", "")
    If IsInteger(sT0) = True Then F_iDiffDatum = CInt(sT0) 'as Integer
  Else
    sT0 = Replace(sT0, ".", "-")
    sT0 = Replace(sT0, "/", "-")
    sT0 = Replace(sT0, Space(1), "-")
    ssSpli = Split(sT0 & "-" & "-", "-") '0-1-2
    If ssSpli Then 
      If ssSpli.Max = 2 Then dateDatum = Date(ssSpli[0], ssSpli[1], ssSpli[2])  'as Date  '(yyyy, mm, dd, hh, nn, ss, uu)      |0|1|2|...|n-1|   +1Tag 00>24h
    Endif
    If dateDatum Then sTestDatum = Format(dateDatum, "yyyy-mm-dd")
    If IsDate(sTestDatum) = False Then dateDatum = M01Functions.DateCheckyyyymmddhhnn(sT0, "00:00") 'as Date
    If dateDatum Then Try F_iDiffDatum = DateDiff(Date, dateDatum, gb.day)   '(höher, niedriger, Zwischenraum)  oder (dateHeute, gestern, gb.Day) 'as Integer
  Endif
  'Notiz: Date + 00:00:00 time, Now is Date + 12:34:56 time 
  If F_iDiffDatum <> 0 Then
    dateDatum = DateAdd(dateHeute, gb.day, F_iDiffDatum) 'as Date
  Else
    dateDatum = Date
  Endif
  If F_iDiffDatum > -1 Then 
    sTage = Space(3) & "+" & Str(F_iDiffDatum) & Space(1) & ("Tage") '+0, +1, +2, ...
  Else 
    sTage = Space(3) & Str(F_iDiffDatum) & Space(1) & ("Tage") '-1, -2, ...
  Endif 
  LabelDatum.Text = Format(dateDatum, "ddd yyyy-mm-dd") & sTage
  LabelDatum.Tooltip = LabelDatum.Text
  If LabelDatum.Text Like "*????-??-??*" Then 
    LabelDatum.Foreground = Color.DarkGreen
  Else
    If String.InStr(sT0, "-") > 1 Then ' 01-02-...
      LabelDatum.Foreground = Color.Red 'Datum noch nicht erkannt
    Else '-+Zahl
      LabelDatum.Foreground = Color.DarkBlue
    Endif
  Endif
  If Text0.Foreground <> LabelDatum.Foreground Then Text0.Foreground = LabelDatum.Foreground
  F_dateDatum = dateDatum
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form4Bis.Left]
      iY = Settings[F_sForm &/ "Top", Form4Bis.Top]
      iW = Settings[F_sForm &/ "Width", Form4Bis.W]
      iH = Settings[F_sForm &/ "Height", Form4Bis.H]
      Form4Bis.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form4Bis.Left
      Settings[F_sForm &/ "Top"] = Form4Bis.Top
      Settings[F_sForm &/ "Width"] = Form4Bis.Width
      Settings[F_sForm &/ "Height"] = Form4Bis.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub LabelPath_MouseDown()
  
  FileInfoG()
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt]  'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form4Bis.Window.Maximized = Not Form4Bis.Window.Maximized 
  If Form4Bis.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form4Bis.Window.FullScreen = True Or Form4Bis.Window.Maximized = True Then 
      F_bMovingON = False
      Form4Bis.Window.FullScreen = False
      Form4Bis.Window.Maximized = False
      If Form4Bis.Left + Form4Bis.W > Screen.AvailableWidth Then Form4Bis.Move(Form4Bis.Left, Form4Bis.Top, Screen.AvailableWidth - Form4Bis.Left, Screen.AvailableHeight - Form4Bis.Top)
    Else
      F_bMovingON = True
      Form4Bis.Window.FullScreen = False
      Form4Bis.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form4Bis.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form4Bis.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form4Bis.ClientW - WindowStretch.W, Form4Bis.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form4Bis.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form4Bis.W = Mouse.ScreenX - F_iX1
    Form4Bis.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form4Bis.ClientW - WindowStretch.W, Form4Bis.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form4Bis.ClientW - WindowStretch.W, Form4Bis.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form4Bis.Window.Maximized = Not Form4Bis.Window.Maximized 
    If Form4Bis.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form4Bis.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Select Case Last.Tag
    Case "save"
      Last.Border = True
    Case "cancel", "datechooser"
      Last.Border = True
      Last.Background = Color.Green
    Case "datecancel"
      Last.Border = True
      Last.Background = Color.Green
  End Select
  
Catch 
  FMain.ErrorText 
  
End

Public Sub ButtonGroup_Leave()
  
  Select Case Last.Tag
    Case "save"
      ' Last.Border = F_bChangeON 
    Case "cancel", "datechooser"
      Last.Border = False
      Last.Background = Color.Default
    Case "datecancel"
       Last.Border = True
  End Select
  
  If PanelDateChooser.Visible = True Then 
    ButtonDateChooser.Border = True 
    ButtonDateChooser.Background = Color.Green
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  Select Case sLastTag 
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      Form4Bis.Window.Close
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "datechooser", "datecancel"
      DateChooserONoff()
    Case "save"
      SaveG()
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "cancel"
      Form4Bis.Window.Close
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '............................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M04Kalender.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M04Kalender.module
24,6 KB
' Gambas module file

'Kalender KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
Public Function CalendarReadCreateHTML(Optional sDirFileTXT As String = "", Optional iYearBegin As Integer = 0, Optional iYearEnd As Integer = 0) As String 'Jahres-Kalender in HTML
  
  Dim sPath, sText, sLines, sTextFeiertage, sHolidaysPlus As String
  Dim sCalendarLines, sLine As String
  Dim T0, T1, T2, T3, T4, T5 As String
  Dim it As Integer
  Dim iDays As Integer ' > dateadd()
  Dim iDiffDays As Integer
  Dim hDate, dateBegin, dateEnd As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  FMain.F_ssCalendarList = New String[]
  
  ''Year 0000 begin—▶end:
  If iYearBegin = 0 Then iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", Year(Date)]
  If iYearEnd = 0 Then iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", Year(Date)]
  
  ''Sort:
  If iYearBegin > iYearEnd Then 
    it = iYearBegin
    iYearBegin = iYearEnd
    iYearEnd = it
  Else If iYearEnd < iYearBegin Then 
    it = iYearEnd
    iYearEnd = iYearBegin
    iYearBegin = it
  Endif 
  
  ' ''Min. current year?
  ' If iYearBegin = Year(Date) Or iYearEnd = Year(Date) Then 
  '   '...
  ' Else 
  '   iYearEnd = Year(Date) 
  ' Endif 
  
  ''Termine TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  If Exist(sDirFileTXT) = True Then 
    sPath = sDirFileTXT '.txt
  Else
    sPath = FMain.F_sPathTerminweckerActual_txt '.txt
    If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  Endif
  ' If Exist(sPath) = True Then Try sText = File.Load(sPath) '/Ordner/terminwecker.txt
  If Exist(sPath) = True Then Try sText = M01Functions.FileReadText(sPath, iYearBegin, iYearEnd) 'as String '>Faster
  ' If sText Then CalendarReadPlus(sText) 'Termine  '—▶ FMain.F_ssCalendarList.add()
  ''Termine TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  
  ''Feiertage FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  sLines = ""
  If iYearEnd - iYearBegin <> 0 Then sHolidaysPlus = "+" Else sHolidaysPlus = "-"
  For it = iYearBegin To iYearEnd
    hDate = Date(it, 1, 1)
    sLines &= M03Feiertage.HolidaysCalculate(Format(hDate, "yyyy-mm-dd"), sHolidaysPlus) 'as String
  Next
  ' Print iYearBegin, iYearEnd
  ' Print sLines
  sTextFeiertage = M01Functions.HolidaysLines(sLines)
  If sTextFeiertage Then sText = sText & sTextFeiertage
  ''Feiertage FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  
  ''Jahreskalender KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
  dateBegin = Date(iYearBegin, 1, 1)
  dateEnd = Date(iYearEnd, 12, 31)
  iDiffDays = DateDiff(dateBegin, dateEnd, gb.Day)
  'Kalendertage
  For iDays = 0 To iDiffDays
    hDate = DateAdd(dateBegin, gb.Day, iDays)
    'Datum = CDate(Datum)
    T0 = Format(hDate, "yyyy-mm-dd")
    T1 = "00:00"
    T2 = Format(hDate, "ddd")
    T3 = ""
    T4 = ""
    T5 = Space(1)
    sLine = T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hReturn
    sCalendarLines = sCalendarLines & sLine
  Next
  If sCalendarLines Then sText = sText & sCalendarLines
  If sText Then CalendarReadPlus(sText, iYearBegin, iYearEnd) 'Termine  '—▶ FMain.F_ssCalendarList.add()
  
  sPath = M04Kalender.CalendarNewHTML(sPath, iYearBegin, iYearEnd) ' .txt + .html    '◀— FMain.F_ssCalendarList
  'sPath = FMain.F_sDirAppName &/ "terminwecker.txt.html"
  FMain.F_ssCalendarList.Clear()
  ''Jahreskalender KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
  
  ' If Component.IsLoaded("gb.util") Then TimeSummerUTClocal(dateBegin) ' Date.ToUTC() 'needs component: gb.util
  
  Return sPath 'Rückgabewert
  
Catch
  FMain.ErrorText
  If Error Then Return
  
End

Public Sub TimeSummerUTClocal(Optional dateInput As Date = Now) 'unused
  
  Dim dateBegin, dateDay, dateDayNext As Date
  Dim dateTimeSummerBegin, dateTimeSummerEnd As Date 
  Dim it, iDiff, iDiffNext As Integer
  Dim iDiffWintertime, iDiffTimeSummer As Integer
  Dim sTimeSummerBegin, sTimeSummerEnd As String 
  Dim iDayChanged As Integer '=0
  
  If Component.IsLoaded("gb.util") Then
    dateBegin = Date(Year(dateInput), 1, 17, 0, 0, 0) '(date<comma>time)
    
    ' dateBeginUTC = Date.ToUTC(dateBegin) 'needs component: gb.util
    ' iDiffWintertime = DateDiff(Date.ToUTC(dateBegin), dateBegin, gb.Minute)
    dateDay = DateAdd(dateBegin, gb.Day, 170) 'middle Summer
    ' dateDay2 = Date.FromUTC(dateBegin)
    iDiffWintertime = DateDiff(Date.ToUTC(dateBegin), dateBegin, gb.Minute)
    iDiffTimeSummer = iDiffWintertime + DateDiff(Date.ToUTC(dateDay), dateDay, gb.Minute)
    ' iDiff = DateDiff(Date.FromUTC(dateBegin), dateBegin, gb.Minute)
    
    For it = 17 To 366 'days in year
      dateDay = DateAdd(dateBegin, gb.Day, it)
      dateDayNext = DateAdd(dateBegin, gb.Day, it + 1)
      iDiff = DateDiff(Date.ToUTC(dateDay), dateDay, gb.Minute)
      iDiffNext = DateDiff(Date.ToUTC(dateDayNext), dateDay, gb.Minute) '1Day=24h=1440m=86400s
      
      If iDayChanged = 0 Then 
        If iDiff = iDiffTimeSummer Then 
          dateTimeSummerBegin = DateAdd(dateDay, gb.Minute, iDiff) 'as Date
          iDiffTimeSummer = iDiff
          iDayChanged = iDayChanged + 1
          ' Print iDiff
        Endif 
      Else If iDayChanged = 1 Then 
        If iDiff = iDiffWintertime Then 
          dateTimeSummerEnd = DateAdd(dateDay, gb.Minute, iDiff) 'as Date
          iDiffWintertime = iDiff
          iDayChanged = iDayChanged + 1
          ' Print iDiff
          Break
        Endif 
      Endif 
    Next 
    If dateTimeSummerBegin And dateTimeSummerEnd Then 
      sTimeSummerBegin = Format(dateTimeSummerBegin, "yyyy-mm-dd hh:nn:ss")
      sTimeSummerEnd = Format(dateTimeSummerEnd, "yyyy-mm-dd hh:nn:ss")
      Settings[FMain.Name &/ "sTimeSummerCalculatedBegin"] = sTimeSummerBegin
      Settings[FMain.Name &/ "sTimeSummerCalculatedEnd"] = sTimeSummerEnd
      ' Print "sTimeSummerBegin:", sTimeSummerBegin
      ' Print "sTimeSummerEnd:", sTimeSummerEnd
    Endif 
  Endif 'component
  
Catch
  FMain.ErrorText
  
End

Public Function CalendarNewHTML(Optional sDirFileTxt As String = "", Optional iYearBegin As Integer = 0, Optional iYearEnd As Integer = 0) As String 'Datei-Pfad
  
  Dim T0, T1, T2, T3, T4, T5 As String
  Dim hDate As Date
  Dim sText, sPath, sJahreszahlen, sAktuelleZeile, sZeilenachher As String
  Dim sHTMLbegin, sHTMLend, sHTMLDoubleArrow, sHTMLqout, sHTMLbreak, sHTMLpara, sHTMLspace As String
  Dim it, iCounter, iHeuteeinmal As Integer
  Dim sLine, sLinkLine As String  
  Dim sListLine As String 
  Dim ssList As String[] ' muß String sein für Split()
  Dim sFarbeBGZelle, sFarbeBGZelle1, sNotizProzent As String
  Dim sHeuteDatum, sHeutezeiger, sVeraendertam, sSoftwareText, sHeuteRandNotiz, sIcon As String
  Dim bQuarterWeekON, bReturnON, bWithJumpDateON As Boolean 
  Dim sHTMLbold, sHTMLboldEnd As String
  Dim hTab, hReturn As String 
  Dim ssSpli As String[]
  Dim sJumpName As String
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sHTMLDoubleArrow = "&laquo;" 'Quote("&#171;") 
  sHTMLqout = "&quot;" '”Anfuehrungszeichen oben "&#34;"
  sHTMLbreak = "<br>" 'break, ¶
  sHTMLpara = "&para;" '"¶" Absatz-Zeichen "&#182;" 
  sHTMLspace = "&nbsp;" 'erzwungenes Leerzeichen "&#160;" (*1)
  '"&raquo;Space(1)»" angewinkelte Anfuehrungszeichen rechts ((*1) Quelle: selfhtml.org) "&#187;"
  '"&laquo;Space(1)«" angewinkelte Anfuehrungszeichen links "&#171;"
  
  ''Year 0000 begin—▶end:
  If iYearBegin = 0 Then iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", Year(Date)] 'Calendar in FMain!
  If iYearEnd = 0 Then iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", Year(Date)]
  
  ''Activate-Deactivate:
  bReturnON = Settings[FMain.Name &/ "F_bCalendarAllReturnsON", False]
  bQuarterWeekON = Settings[FMain.Name &/ "F_bCalendarQuarterWeekON", False] 'Quartal 1/4 Year (Q), Week (KW, Kalender-Woche)
  bWithJumpDateON = Settings[FMain.Name &/ "F_bCalendarJumpDateON", False] ''"Heute" (JavaScript)
  ' If iYearBegin <> iYearEnd Then bWithJumpDateON = True  '"Heute"
  
  ''File *.txt:
  If Exist(FMain.F_sDirAppName) = False Then 
    FMain.F_sDirAppName = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  Endif 
  If Exist(sDirFileTxt) = True Then
    sPath = sDirFileTxt
  Else
    sPath = FMain.F_sPathTerminweckerStandard_txt
    If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt]
  Endif
  
  ''Actual date line:
  sHeuteDatum = Format(Now, "yyyy-mm-dd")
  sAktuelleZeile = sHTMLDoubleArrow & Space(1) & ("Aktuelle Zeile")  'wg. Übersetzung  "»" = "&#187;"
  sVeraendertam = "<font color=darkblue>" & Space(1) & "(" & ("Aktualisiert") & ": " & Format(Now, "ddd dd.mm.yyyy hh:nn:ss") & ")" & "</font>"
  sSoftwareText &= String(3, sHTMLspace) & ("Jahr") & ": " & iYearBegin & Space(1) & ("bis") & Space(1) & iYearEnd & sHTMLspace
  sSoftwareText &= "<font color=silver>" & Space(1) & ("Software") & Space(1) & Application.Name & "</font>"
  
  ''Icon:
  If Exist(File.Dir(sPath) &/ Application.Name & "_" & "favicon.png") = True Then 
    sIcon = "<img src=" & Application.Name & "_" & "favicon.png" & " width=16 height=16 alt=programm_icon>" 'Icon im selben Ordner
    sSoftwareText = sSoftwareText & sIcon
    ''Favicon. Kleines Icon für Browser:
    If Exist("images/favicon.ico") = True And Exist(FMain.F_sDirAppName &/ "favicon.ico") = False Then
      If IsDir(FMain.F_sDirAppName) = True Then Copy "images/favicon.ico" To FMain.F_sDirAppName &/ "favicon.ico"
    Endif
  Endif 
    
  For it = iYearBegin To iYearEnd
    sJahreszahlen = sJahreszahlen & "," & Str(it)
  Next
  
  sFarbeBGZelle = "white"
  sLinkLine = ""
  sLinkLine &= "<table width=100% border=0 cellspacing=3 cellpadding=3 bordercolor=black >" & hReturn
  sLinkLine &= "<tr valign=top>" & hReturn
  sLinkLine &= "<td width=5% bgcolor=" & sFarbeBGZelle & "><font color=" & sFarbeBGZelle & " id=jump1 " & ">" & ("Datum") & "</font>" & "</td>" & hReturn
  sLinkLine &= "<td width=5% bgcolor=" & sFarbeBGZelle & "><font color=" & sFarbeBGZelle & ">" & ("Uhrzeit") & "</font></td>" & hReturn
  sLinkLine &= "<td width=5% bgcolor=" & sFarbeBGZelle & "><font color=" & sFarbeBGZelle & ">" & ("Tag") & "</font></td>" & hReturn
  sNotizProzent = "width=85%"
  If bQuarterWeekON = True Then
    sLinkLine &= "<td width=5% bgcolor=" & sFarbeBGZelle & "><font color=" & sFarbeBGZelle & ">" & "0Q" & "</font></td>" & hReturn
    sLinkLine &= "<td width=5% bgcolor=" & sFarbeBGZelle & "><font color=" & sFarbeBGZelle & ">" & ("00KW") & "</font></td>" & hReturn
    sNotizProzent = "width=75%"
  Endif
  sLinkLine &= "<td " & sNotizProzent & " bgcolor=" & sFarbeBGZelle & "><a href=#heute>" & sAktuelleZeile & "</a>" & sVeraendertam & sSoftwareText & "</td>" & hReturn
  sLinkLine &= "</tr>" & hReturn
  sLinkLine &= "</table>" & hReturn
  
  sHTMLbegin = "<!DOCTYPE html>" & hReturn 'html5 neu
  sHTMLbegin &= "<html lang=de>" & hReturn
  sHTMLbegin &= "<head>" & hReturn
  sHTMLbegin &= "<title>" & ("Kalender") & "-" & Application.Name & "</title>" & hReturn
  sHTMLbegin &= "<!-- Software " & Application.Name & Space(1) & sHeuteDatum & " www.design-cad.de -->" & hReturn
  sHTMLbegin &= "<!-- Zeichensatz -->" & hReturn
  sHTMLbegin &= "<meta charset=utf-8>" & hReturn 'html5 neu 'Old:"text/html;CHARSET=iso-8859-15"
  sHTMLbegin &= "<meta name=keywords content=" & Chr(34) & "Kalender, Calendar, Terminwecker" & Chr(34) & ">" & hReturn
  sHTMLbegin &= "<meta http-equiv=expires content=0>" & hReturn ' gueltig Zeitraum 0, immer sofort Originaldatei laden
  sHTMLbegin &= "<meta name=software content=" & Application.Name & ">" & hReturn 
  sHTMLbegin &= "<meta name=publisher content=design-cad.de>" & hReturn 'or name=author
  sHTMLbegin &= "<link rel=icon href=/" & Application.Name & "_" & "favicon.png" & " type=image/png>" & hReturn 'href=/favicon.ico 'wo ein kleines Symbolbild liegt
  sHTMLbegin &= "<link rel=" & Quote("shortcut icon") & " type=image/x-icon href=/favicon.ico>" & hReturn 'favicon.ico oder favicon.png werden  automatisch im selben Ordner gesucht, auch ohne LINK. 
  
  If bWithJumpDateON = True Then 
    ''JavaScript
    sHTMLbegin &= "<!-- Aktuelles Datum Heute d.m.yyyy -->" & hReturn
    sHTMLbegin &= "<script>" & hReturn '(*2)
    sHTMLbegin &= "\t'use strict';  " & hReturn 'Not forget, end with ";"
    sHTMLbegin &= "\t(function () {" & hReturn '"\t" = gb.Tab
    sHTMLbegin &= "\t  function init () {" & hReturn
    sHTMLbegin &= "\t  var datum = new Date();" & hReturn
    sHTMLbegin &= "\t  var GeheZu = datum.toLocaleDateString('de-DE');" & hReturn
    sHTMLbegin &= "\t  document.getElementById('jump1').innerHTML = " & Quote("<a href=#date") & " + " & "GeheZu" & " + " & Quote(">Heute</a>") & ";" & hReturn 
    sHTMLbegin &= "\t  document.getElementById('jump2').innerHTML = " & Quote("<a href=#date") & " + " & "GeheZu" & " + " & Quote(">Heute</a>") & ";" & hReturn 
    sHTMLbegin &= "\t}" & hReturn
    sHTMLbegin &= "\t\tdocument.addEventListener(" & hReturn
    sHTMLbegin &= "\t\t\t\"DOMContentLoaded\"," & hReturn
    sHTMLbegin &= "\t\t\tfunction () { init(); }" & hReturn
    sHTMLbegin &= "\t\t);" & hReturn
    sHTMLbegin &= "\t}()); " & hReturn
    sHTMLbegin &= "</script>" & hReturn
  Endif 
  
  sHTMLbegin &= "</head>" & hReturn
  
  sHTMLbegin &= "<body><font face=" & Chr(34) & "arial, sans-serif, ubuntu" & Chr(34) & "> " & hReturn
  sHTMLbegin &= sLinkLine & hReturn '"<!-- sprungnamen einheitlich IN kleinschrift -->"
  '&#187; = >>
  If bWithJumpDateON = True Then  
    sHTMLend = Replace(sLinkLine, "id=jump1", "id=jump2") & hReturn
  Else 
    sHTMLend = Replace(sLinkLine, Space(1) & "id=jump1" & Space(1), "") & hReturn
  Endif 

  sHTMLend &= "</font>" & hReturn
  sHTMLend &= "</body>" & hReturn 
  sHTMLend &= "</html>" & hReturn
  
  sText = ""
  'siehe Kopf ganz oben => Public FMain.F_ssCalendarList As New String[]
  FMain.F_ssCalendarList.Sort()      '()=Default bzw. .Sort(gb.Ascent) => A-Z
  iCounter = -1 ' FMain.F_ssCalendarList fängt mit 0 an.
  ' Print FMain.F_ssCalendarList
  
  For Each sListLine In FMain.F_ssCalendarList 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
    ' sLine = sListLine
    ' sListline = String.Left(sListLine, -1)  ' -1 All  ASCII intern > String.* UTF-8
    sListLine = Replace(sListLine, hReturn, sHTMLbreak) '"\n"
    sListLine = Replace(sListLine, String.Chr(182), sHTMLbreak) 'Returnzeichen "¶" = "<br>"  gb.Binary ist Voreinstellung
    sListLine = Replace(sListLine, Chr(34), sHTMLqout)  'Anfuehrungszeichen oben "&quot;"
    sListLine = Replace(sListLine, gb.NewLine, sHTMLbreak) '"\n"="<br>"=gb.Newline=Return   "\t"=TABulator
    If bReturnON = True Then sListline = Replace(sListLine, sHTMLbreak, sHTMLpara) 'Ersatzzeichen NewLine="¶"
    ' If String.IsValid(sListline) = True Then sListLine = Conv$(sListLine, "ASCII", "UTF-8")
    ' sListline = String.FromHTML(sListLine) 'Text ohne <html> 
    sJumpName = Null 'Reset
    If String.InStr(sListLine, hTab) > 0 Then
      ssList = Split(sListLine & hTab & hTab & hTab & hTab & hTab, hTab) 'Stringarray, mit & hTab auffüllen, um Fehler zu vermeiden wenn nicht in Zeile vorhanden
      T0 = ssList[0] 'Example: 2024-02-01 (yyyy-mm-dd)
      T1 = ssList[1]
      T2 = ssList[2]
      T3 = ssList[3]
      T4 = ssList[4]
      T5 = ssList[5]
      If bWithJumpDateON = True Then 
        ssSpli = Split(T0 & String(2, "-"), "-") 
        sJumpName = CInteger(ssSpli[2]) & "." & CInteger(ssSpli[1]) & "." & CInteger(ssSpli[0]) ' Example: 1.2.2024 (d.m.yyyy)
        ''Verweisanker, Sprungmarke, Gehe-zu
        sJumpName = "<a name=" & Quote("date" & sJumpName) & "></a>" 'Springe zur Zeile... 
      Endif 
    Endif
    'Leere doppelte Zeilen vor Einträgen vermeiden
    iCounter = iCounter + 1
    'leere Tag-Zeilen vor Tag-Einträgen vermeiden
    If iCounter + 1 <= FMain.F_ssCalendarList.Count - 1 Then
      sZeilenachher = FMain.F_ssCalendarList[iCounter + 1]
      If Replace(T5, Space(1), "") = "" And String.Left(sListLine, 10) = String.Left(sZeilenachher, 10) Then Goto springen
    Endif
    
    If String.InStr("so, su", String.LCase(T2)) > 0 Then    'Sonntage, Sundays
      sFarbeBGZelle = "bgcolor=Yellow"
    Else
      sFarbeBGZelle = Space(1) '"LightYellow"
    Endif
    If String.Left(T5, 1) = "#" And String.Left(T5, 2) <> "#(" Then sFarbeBGZelle = "bgcolor=#BBDDFA" 'Feiertage
    sFarbeBGZelle1 = sFarbeBGZelle
    
    ''Reset:
    sHeutezeiger = ""
    sHTMLbold = ""
    sHTMLboldEnd = ""
    sHeuteRandNotiz = ""
    
    ''today, now (heute):
    If String.InStr(T0, sHeuteDatum) > 0 Then
      sFarbeBGZelle = "bgcolor=#90EE90" 'hellgrün '#FF4500" 'Heute HHHHHHHHHHHHHHHH
      iHeuteeinmal = iHeuteeinmal + 1
      If iHeuteeinmal = 1 Then
        sHeutezeiger = "<a name=heute></a>" 
        sHTMLbold = "<b>"
        sHTMLboldEnd = "</b>"
        sHeuteRandNotiz = "<div align=right><font color=darkblue>" & sVeraendertam & "</font></div>"
      Endif
    Endif
    
    If String.InStr(sJahreszahlen, String.Left(T0, 4)) > 0 Then
      sLine = ""
      sLine &= "<table cellpadding=3>" ' tag-text möglichst vermeiden, sonst x365=große Datei
      sLine &= "<tr valign=top>"
      sLine &= "<td width=5% " & sFarbeBGZelle1 & ">" & T0 & sHeutezeiger & sJumpName & "</td>"
      sLine &= "<td width=5% " & sFarbeBGZelle & ">" & T1 & "</td>"
      sLine &= "<td width=5% " & sFarbeBGZelle & ">" & sHTMLbold & T2 & sHTMLboldEnd & "</td>"
      If bQuarterWeekON = True Then 'dauert länger
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0)
        T3 = "<font color=silver>" & Str(Format(M01Functions.DateQuarterG(hDate), "0") & "Q") & "</font>"
        T4 = "<font color=silver>" & Str(Format(M01Functions.DateCalenderWeek(hDate), "00") & ("KW")) & "</font>"
        sLine &= "<td width=5% " & sFarbeBGZelle & ">" & T3 & "</td>"
        sLine &= "<td width=5% " & sFarbeBGZelle & ">" & T4 & "</td>"
      Endif
      sLine &= "<td " & sNotizProzent & Space(1) & sFarbeBGZelle & ">" & T5 & sHeuteRandNotiz & "</td>"
      sLine &= "</tr>"
      sLine &= "</table>"
      sText = sText & sLine & hReturn
      'IF String.InStr(T0, sHeuteDatum) > 0 THEN sLine = Replace(sLine, "border=0", "border=1", gb.Text)
    Endif
  springen: 'Goto nur innerhalb einer Schleife For...Next
  Next 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
  
  sText = sHTMLbegin & sText & sHTMLend
  If String.LCase(File.Ext(sPath)) <> "html" Then sPath = sPath & ".html"  
  
  ''Create File (*.html):
  sPath = M01Functions.FileTextPlus(sPath, sText, True) ' TRUE=overwrite (überschreiben)
  
' Ende:
  FMain.F_ssCalendarList.Clear()
  Return sPath
  
  ''_________________________________________________________________________________________''
  '(*1) Quelle: selfhtml.org  HTML / Zeichenreferenz
  '(*2) Quelle: selfhtml.org  toLocaleDateString
  
Catch
  FMain.ErrorText
  If Error Then Return
  
End

Public Sub CalendarReadPlus(Optional sText As String = "", Optional iYearBegin As Integer = Year(Date), Optional iYearEnd As Integer = Year(Date)) '33333333333333333333333333333333333333333
  
  Dim it, iDay As Integer
  Dim sSeparator As String
  Dim sLine As String
  Dim ssList, ssLineParts, ssSpliDatum As String[] ' muß String[] sein für Split()
  Dim sYearYYYY, sValue As String
  Dim T0, T1, T2, T3, T4, T5, T5orig As String
  Dim hDate, dateWD As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If iYearBegin > iYearEnd Then 
    it = iYearBegin
    iYearBegin = iYearEnd
    iYearEnd = it
  Else If iYearEnd < iYearBegin Then 
    it = iYearEnd
    iYearEnd = iYearBegin
    iYearBegin = it
  Endif 
  
  'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
  
  sSeparator = hReturn
  If sText Then 
    If String.InStr(sText, sSeparator) > 0 Then
      ssList = Split(sText & sSeparator, sSeparator) ' Stringarray
      For Each sLine In ssList
        If String.InStr(sLine, hTab & "*") > 0 Then 'Geburtstagsjahr anpassen   "2020-12-25" > YYYY-12-25  
          ''Birthday, *Every Year (*Jedes Jahr, Geburtstage)
          ssLineParts = Split(sLine & String(6, hTab), hTab)
          T0 = ssLineParts[0] '0000-00-00
          T1 = ssLineParts[1] '00:00
          T2 = ssLineParts[2] 'Su (Weekday, Wochentag)
          T3 = ssLineParts[3] 'Q (Quater, Quartal) 
          T4 = ssLineParts[4] 'CW (CalenderWeek, KalenderWoche)
          T5 = ssLineParts[5] 'Notiz
          T5orig = T5
          
          ''*Birthday, *EveryYear (Geburtstag, *jedes Jahr)
          If T0 Like "*????-??-??" And String.InStr(String.Left(T5, 2), "*") > 0 Then 'Toleranz 1-2, wenn nicht bExact 1
            sValue = Replace(T0, Space(1), "") 'gb.Binary ist Voreinstellung)
            ssSpliDatum = Split(sValue & "-" & "-", "-")
            For it = iYearBegin To iYearEnd
              sYearYYYY = Format(it, "0000") 'as String
              T0 = sYearYYYY & "-" & ssSpliDatum[1] & "-" & ssSpliDatum[2]
              hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date

              ''Check Date in new Year:
              If IsDate(Str(hDate)) = True Then 'Schaltjahr bzw. Tag existiert nicht?
                If Format(hDate, "-mm-dd") <> String.Right(sValue, 6) Then
                  T0 = sYearYYYY & "-" & ssSpliDatum[1] & "-" & Format((CInteger(ssSpliDatum[2]) - 1), "00")
                  hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
                  If IsDate(Str(hDate)) = False Then 'noch einmal pruefen
                    T0 = sYearYYYY & "-" & ssSpliDatum[1] & "-" & Format((CInteger(ssSpliDatum[2]) - 2), "00")
                    hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
                  Endif 
                Endif 
              Endif 
              
              If hDate Then 
                T0 = Format(hDate, "yyyy-mm-dd")
                T2 = Format(hDate, "ddd") 'Wochentag anpassen
                T5 = T5orig & Space(1) & "(" & sValue & ")" '1x (Original-Datum zum Vergleich)
                ' Print T0, T5, "sValue"
              Endif 
              
              sLine = T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hTab
              If sLine And FMain.F_ssCalendarList.Find(sLine) = -1 Then FMain.F_ssCalendarList.Add(sLine) '1x, not double
            Next
          Endif
        Else If IsInteger(String.Left(sLine, 2)) = False Or String.InStr(sLine, "-Q" & hTab & "-" & ("KW")) > 0 Then 
          ''Timer SoMo...'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa) 0,1,2,3,4,5,6 = 7 Day (Week)
          ssLineParts = Split(sLine & String(6, hTab), hTab)
          T0 = ssLineParts[0] '0000-00-00
          T1 = ssLineParts[1] '00:00
          T2 = ssLineParts[2] 'Su (Weekday, Wochentag)
          T3 = ssLineParts[3] 'Q (Quater, Quartal) 
          T4 = ssLineParts[4] 'CW (CalenderWeek, KalenderWoche)
          T5 = ssLineParts[5] 'Notiz
          If T0 And T5 Then 
            hDate = Date 'M01Functions.DateLastWeekDay(Now, gb.Sunday) 'as Date   0=Sonntag, gb.Sunday
            For iDay = -7 To 14 '3 Weeks (Wochen)
              'Example: "Su0Mo1Tu2". WeekDay(d) = gb.Sunday = "0"
              dateWD = DateAdd(hDate, gb.Day, iDay)
              If String.InStr(T0, WeekDay(dateWD)) > 0 Or String.InStr(String.LCase(T0), String.LCase(String.Left(Format(dateWD, "dddd"), 2))) > 0 Then 
                'Example: "Su0" > "yyyy-mm-dd"
                sLine = Format(dateWD, "yyyy-mm-dd") & hTab & T1 & hTab & String.Left(Format(dateWD, "dddd"), 2) & hTab & T3 & hTab & T4 & hTab & "Timer:" & Space(1) & T5 & hTab
                If FMain.F_ssCalendarList.Find(sLine) = -1 Then FMain.F_ssCalendarList.Add(sLine) '1x, not double
              Endif 
            Next 
            sLine = "" 'Reset
          Endif 
        Else 'Timer und Rest entfernen
          '...Leerlauf
        Endif 
        If sLine And FMain.F_ssCalendarList.Find(sLine) = -1 Then FMain.F_ssCalendarList.Add(sLine) '1x, not double
        ' If IsAscii(sLine) = False Then sLine = M01Functions.WebZeichen(sLine) 'faster?
      Next 'sLine
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  ' If Error Then Return
  
End '333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
'KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M01Functions.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M01Functions.module
355 KB
' Gambas module file

Public Function CheckDirectoryCache() As String 
  
  Dim sDir, sDirCache As String
  
  ' sDirCache = File.Dir(M01Functions.CheckDirectoryCache()) '"/tmp/..." 'Delete automatically, if program ends
  sDir = User.Home &/ String.LCase(Application.Name) '' /home/USER/Application.Name
  If IsDir(sDir) = False Then Try Mkdir sDir
  sDirCache = sDir &/ String.LCase(Application.Name) & "-cache" '' sDir &/ Application.Name & "-cache"
  If IsDir(sDirCache) = False Then Try Mkdir sDirCache
  If IsDir(sDirCache) = False Then 
    sDirCache = Desktop.CacheDir &/ Application.Name  'Default "~/.cache/" + Application.Name           /home/>user</.cache/...
    If IsDir(Desktop.CacheDir) = True And IsDir(sDirCache) = False Then Try Mkdir sDirCache
  Endif 
  
  '*********************************************
  Return sDirCache
  '*********************************************
  ' If Exist(hCacheDir) = False Then Try Mkdir hCacheDir
  'Print "Temp$", Temp$                                                                   '/tmp/gambas.1000/<1234>/1.tmp
  'Print "Desktop.RuntimeDir", Desktop.RuntimeDir                                         '/run/<user>/1000
  'Print "Desktop.ConfigDir", Desktop.ConfigDir                                           '/home/<user>/.config
  'Print "Desktop.DataDir", Desktop.DataDir                                               '/home/<user>/.local/share
  'Print "Desktop.CacheDir", Desktop.CacheDir                                             '/home/<user>/.cache
  'Print "Desktop.Path", Desktop.Path                                                     '/home/<user>/Schreibtisch
  'Print "PICTURES", Desktop.GetDirectory("PICTURES")                                     '/home/<user>/Bilder   'or "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  
Catch 
  FMain.ErrorText
  
End

Public Function DirectorySystemDefaultPictures() As String 
  
  Dim sDir, sDirSub As String 
  
  sDir = Desktop.GetDirectory("PICTURES") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  sDirSub = sDir &/ Application.Name & "-pictures"
  
  If IsDir(sDir) = True And IsDir(sDirSub) = False Then Try Mkdir sDirSub
  'Alternative:
  If IsDir(sDirSub) = False Then sDir = Settings[FMain.Name &/ "F_sDirMyFiles", FMain.F_sDirMyFiles]
  If IsDir(sDirSub) = False Then 
    sDir = User.Home &/ Application.Name ''Example: /home/user/terminwecker/
    sDirSub = sDir &/ Application.Name & "-pictures" 
    If IsDir(sDir) = False Then Try Mkdir sDir
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
  Endif 
  Return sDir 
  
Catch 
  FMain.ErrorText
  
End

Public Function TempDirectory() As String '??? unused 
  'Alternative-Name —▶M01Functions.CheckDirectoryCache()
  
  'Print "Temp$", Temp$                                      '/tmp/gambas.1000/<1234>/1.tmp
  'Print "Desktop.RuntimeDir", Desktop.RuntimeDir            '/run/<user>/1000
  'Print "Desktop.ConfigDir", Desktop.ConfigDir              '/home/<user>/.config
  'Print "Desktop.DataDir", Desktop.DataDir                  '/home/<user>/.local/share
  'Print "Desktop.CacheDir", Desktop.CacheDir                '/home/<user>/.cache
  'Print "Desktop.Path", Desktop.Path                        '/home/<user>/Schreibtisch
  'Print "PICTURES", Desktop.GetDirectory("PICTURES")        '/home/<user>/Bilder   'or "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  'Print "Temp()", Temp() ' /tmp/gambas...Mit dem Programm-Ende werden alle Dateien automatisch im Ordner Temp gelöscht.  
  Return M01Functions.CheckDirectoryCache() 
  
Catch 
  FMain.ErrorText
  
End

Public Function ProgramCache(Optional CreateTRUE_DeleteFALSE As Boolean = True) As String
  
  Dim sDirFile, sDirCache, sDirSub, sDir, sFile As String
  
  sDirCache = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
  
  If CreateTRUE_DeleteFALSE = True Then
    If IsDir(sDirCache) = False Then Try Mkdir sDirCache
  Else
    If IsDir(sDirCache) = True Then
      ''1. Delete all Files
      For Each sFile In Dir(sDirCache, "*.*", gb.File)   '*.* 'Dir or RDir(Folder, Pattern*.*, gb.Directory and/or gb.File)
        sDirFile = sDirCache &/ sFile                        '* Files with and without .Extensions  file.txt, file,...
        Try Kill sDirFile                                    'KILL, Removes a file.
      Next
      
      For Each sDirSub In RDir(sDirCache, "*", gb.Directory)   '*.* 'Dir or RDir(Folder, Pattern*.*, gb.Directory and/or gb.File)
        ' Print sDirSub
        sDir = sDirCache &/ sDirSub
        ''1. Delete all Files
        If IsDir(sDir) = True Then
          For Each sFile In Dir(sDir, "*.*", gb.File)   '*.* 'Dir or RDir(Folder, Pattern*.*, gb.Directory and/or gb.File)
            sDirFile = sDir &/ sFile                        '* Files with and without .Extensions  file.txt, file,...
            Try Kill sDirFile                                    'KILL, Removes a file.
            ' Print sDirFile
          Next
        End If
        ''2. Delete empty Directory
        If IsDir(sDir) = True Then Try Rmdir sDir     'Rmdir Removes an empty directory.
        ' sDirSub = Settings[FMain.Name &/ "F_sDirPrintCache", FMain.F_sDirPrintCache]
      Next
    End If
  End If
  If IsDir(sDirCache) = False Then sDirCache = ""
  
  Return sDirCache
  
Catch
  FMain.ErrorText
  
End

Public Sub CloseProgramResetAll()
  
  Dim sPath, sDir, sCopy, sBackup, sMessage As String
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sMessage = "<h3><font color=red><b>" & "○ " & ("Beenden und") & Space(1) & "</b></font>" 
  sMessage &= "<font size=4 color=green><b>" & ("alle Einstellungen zurücksetzen?") & "</b></font></h3>" 
  sMessage &= Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf] & " = " & ("leeren") & "<br>"
  sMessage &= "<br>" 
  sMessage &= "<h3><font color=green>" & "● " & ("Eigene Dateien selber löschen im Ordner...") & "</font></h3>" 
  sMessage &= sDir &/ "..." 
  
  Select Case Message.Question(sMessage, "○ " & ("Beenden und") & Space(1) & ("Neu-Zustand (Reset)"), "● " & ("Ordner..."), ("Abbrechen")) '(0,1,2)?
      
    Case 1 'Reset
      ''Files:
      sPath = Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf]
      sCopy = FMain.F_sPathSettingsBackup_conf
      If Exist(sCopy) = False Then sCopy = sDir &/ File.Name(Settings.Path) 
      sBackup = M01Functions.FileBackupPathName(sPath) 'as String (*1)
      ''Copy:
      If Exist(sCopy) = True Then Try Copy sCopy To sBackup
      If Exist(sCopy) = True Then Try Kill sCopy 
      If Exist(sPath) = True Then Try Move sPath To sCopy
      If Exist(sBackup) = True Then 
        sMessage = ("Sicherungskopie") & ":" & "<br>" 
        sMessage &= "<font color=darkgreen><b>" & File.Name(sBackup) & "</b></font><br><br>" 
        sMessage &= ("Kopie im Ordner Sicherungskopien") & ":" & "<br>" 
        sMessage &= "● " & "<font color=blue>" & File.Dir(sBackup) & "</font><br>" 
        Select Case Message.Question(sMessage, ("Programm beenden"), "● " & ("Ordner..."), ("Abbrechen"))
          Case 1 'New-Condition (Neu-Zustand)
            ' Settings.Clear()
            FMain.Window.Close
            Settings.Clear() ''behind close! Delete/clears all settings, old and new
            'Settings.Clear("Titel") ' löscht die Settings unter dem [Titel]. Ohne Titel: alles. 
          Case 2 'Directory (Ordner...)
            M01Functions.FileManagerOpen(sBackup)  
          Case 3 'Cancel(Abbrechen)
            ''....
        End Select
      Endif 
      
    Case 2 'Directory (Ordner...)
      M01Functions.FileManagerOpen(sDir)
      
    Case 3 'Cancel (Abbrechen)
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  ''______________________________________________________________________________________________''
  '(*1) Beispiel: FMain.F_sDirBackup  &/ "temp_terminwecker_2020-08-12_16-38-21.txt"  oder ""
  
End

Public Function PrintFile(Optional sDirCache As String, Optional sTitle As String = Application.Name, Optional iIconSize As Integer = 32) As String
  
  Dim sLinesHTML, sInfoSelect, sText, sOldText, sNewText, sBytes, sMiBytes, sMessage As String
  Dim sFile, sDirFileCache, sCacheFileHTML, sDefaultProgramName As String
  Dim n As Integer 'Number
  Dim longSize As Long
  Dim sPixel, sWxH As String
  
  sWxH = Space(1) & "width=" & iIconSize & Space(1) & "height=" & iIconSize
  sPixel = iIconSize & "x" & iIconSize & "Pixel"
  
  If IsDir(sDirCache) = False Then Return 'no Files > no print
  
  For Each sFile In Dir(sDirCache, "*.{png,jpg,jpeg,gif,bmp,xpm,svg}", gb.File).Sort() 'as String[]
    ' Html(sFile) ''> html-Code "text a b c" 'only ASCII abc-z
    sDirFileCache = sDirCache &/ sFile
    If Exist(sDirFileCache) = True Then
      longSize = longSize + Stat(sDirFileCache).Size
      n = n + 1
      ''Text = Text & "..."
      sLinesHTML &= "<a target=_self href=" & sFile & " ><img src=" & sFile & " alt=" & sFile & " border=1 vspace=5 hspace=5 " & sWxH & " ></a>" & gb.NewLine
    Endif
  Next
  
  If longSize > 0 Then
    sText = M01Functions.SizeRestInfo(sDirCache, longSize) 'DFree()
    If sText Then sText &= gb.NewLine
    sBytes = M01Functions.SizePointComma(longSize)                    
    If Component.IsLoaded("gb.util") = True Then 
      sMiBytes = File.FormatSize(longSize, False)    'True 1.000 KiB, False default  '.FormatSize needs component —▶ gb.util
      ' sMiBytes = Format(longSize / 1000 / 1000, "0.#") ''1 MiB = 1.000.000 Bytes
      sText &= sBytes & Space(1) & ("Bytes") & Space(1) & "(" & Space(1) & sMiBytes & ")"  'round and 1.000-point
    Else 
      sMiBytes = M01Functions.SizePointComma(longSize / 1024 / 1024)
      sText &= sBytes & Space(1) & ("Bytes") & Space(1) & "(" & Space(1) & sMiBytes & Space(1) & ("MB") & ")"  'round and 1.000-point
    Endif 
  Else
    sText = ("Leer") 'F_sEmptyText
  Endif
  If n = 0 Then 
    sInfoSelect = "<font color=gray><b>" & ("Keine Auswahl") & "</b></font>"
  Else 
    sInfoSelect = "<font color=darkgreen><b>" & Str(n) & "</b></font>"
  Endif 
  
  ''Create File.html
  sCacheFileHTML = sDirCache &/ LCase(Application.Name & sPixel & ".html")
  sCacheFileHTML = M01Functions.CreatePrintFileHTML(sCacheFileHTML, sTitle) 'as String      'Body-Basic for "newtext"
  sDefaultProgramName = M01Functions.FindFileExtDefaultProgram("text/html")
  
  sMessage = "<h3>" & ("Druck-Vorlage") & "</h3>"
  sMessage &= sTitle & "<br>" 
  sMessage &= "<br>"
  sMessage &= "<h2>" & ("Dateien") & ": " & sInfoSelect & "</h2>"
  sMessage &= ("Größe") & ": " & sText & "<br>" & "<br>"
  sMessage &= sCacheFileHTML & "<br>"
  ' sMessage &= "<br>"
  ' sMessage &= "○" & Space(1) & ("Speichern + Öffnen") & Space(1) & "(" & ("im Standard-Programm") & Space(1) & sDefaultProgramName & ")" & "<br>"
  
  Select Case Message.Question(sMessage, "○" & Space(1) & ("Speichern + Öffnen") & "..." & sDefaultProgramName, ("Ordner..."), ("Abbrechen"))
    Case 1
      If sLinesHTML Then sOldText = File.Load(sCacheFileHTML)
      If sOldText Then sNewText = Replace(sOldText, "newtext", sLinesHTML)
      ' sNewText = Html(sNewText) 'Important: "<meta charset=" & Quote("utf-8") & " />"
      File.Save(sCacheFileHTML, sNewText)
      If Exist(sCacheFileHTML) = True Then Desktop.Open(sCacheFileHTML)
      ' If Exist(sCacheFileHTML) = True Then M01Functions.ExternStart(sDefaultProgramName, sCacheFileHTML)
    Case 2 ''Directory
      M01Functions.FileManagerOpen(sCacheFileHTML)
    Case 3
      ''...
  End Select
  
  Return sCacheFileHTML
  
Catch
  FMain.ErrorText
  
End

Public Function SizeRestInfo(Optional sMediaPath As String = User.Home, Optional longFilesSizeAdd As Long = 0) As String 
  
  Dim longMediaDfree As Long
  Dim sInfo, sMiBytes As String
  
  longMediaDfree = Dfree(sMediaPath) - longFilesSizeAdd
  If longMediaDfree < 500000 Then  'Bytes
    If Component.IsLoaded("gb.util") = True Then 
      sMiBytes = File.FormatSize(longMediaDfree, False)    'True 1.000 KiB, False 1.024 KB default '.FormatSize needs component —▶ gb.util
      sInfo = sMiBytes & Space(1) & "(" & longMediaDfree & Space(1) & ("Bytes") & ")" 
    Else 
      sMiBytes = M01Functions.SizePointComma(longMediaDfree / 1024 / 1024)
      sInfo = sMiBytes & Space(1) & ("MB") & Space(1) & "(" & longMediaDfree & Space(1) & ("Bytes") & ")"  'round and 1.000-point
    Endif 
    sInfo &= gb.NewLine
    sInfo &= ("Tipp: Unnötige Dateien löschen. Papierkorb leeren.")
  Endif
  
  Return sInfo
  
Catch
  FMain.ErrorText
  
End

Public Function CreatePrintFileHTML(Optional sPath As String = "", Optional sTitle As String = Application.Name) As String
  
  Dim sHTML, sKeywords As String
  
  sKeywords = Quote("free Icons, for Science and Programmer, software development, fuer Wissenschaft und Programmierer, Uhr-Baukasten, Uhrenteile, Clock-parts")
  
  sHTML &= "<!DOCTYPE html>" & gb.NewLine
  sHTML &= "<html lang=de>" & gb.NewLine
  sHTML &= "<head>" & gb.NewLine
  sHTML &= "<meta charset=utf-8>" & gb.NewLine  'Quote(""abc"")   in html= &quot;
  sHTML &= "<meta http-equiv=expires content=0>" & gb.NewLine ''Time duration in Cache 0 Sec.
  
  sHTML &= "<meta name=keywords content=" & sKeywords & " lang=de>" & gb.NewLine 
  sHTML &= "<meta name=software content=" & Application.Name & ">" & gb.NewLine 
  sHTML &= "<meta name=publisher content=design-cad.de>" & gb.NewLine 'or name=author
  
  sHTML &= "<style type =text/css>" & gb.NewLine 
  sHTML &= "<!--" & gb.NewLine 
  sHTML &= "A:Link {font-family: arial; color: limegreen; text-decoration: none;}" & gb.NewLine 
  sHTML &= "A:visited {font-family: arial; color: slategray; text-decoration: none;}" & gb.NewLine 
  sHTML &= "A:active {font-family: arial; color: red; text-ecoration: none;}" & gb.NewLine 
  sHTML &= "A:hover {font-family: arial; color: navy; text-decoration:underline;}" & gb.NewLine 
  sHTML &= "//-->" & gb.NewLine 
  sHTML &= "</style>" & gb.NewLine 
  
  sHTML &= "<title>" & Quote(sTitle) & "</title>" & gb.NewLine
  sHTML &= "</head>" & gb.NewLine
  
  sHTML &= "<body bgcolor=#" & Hex(Color.Background, 6) & "><font name=" & Quote("arial, ubuntu") & " size=1 color=silver>" & gb.NewLine
  sHTML &= "newtext" ''◀——     ◀——                '"<img src=" & Quote("file://" & sPath) & " alt=" & Quote(sPath) & " >" & gb.NewLine
  sHTML &= "</font></body>" & gb.NewLine
  sHTML &= "</html>" & gb.NewLine
  ' Text = Html(Text) 'Important: "<meta charset=" & Quote("utf-8") & " />"
  If File.Ext(sPath) <> "html" Then sPath = sPath & ".html"
  If Exist(sPath) = True Then Try Kill sPath
  File.Save(sPath, sHTML)
  If Exist(sPath) = False Then sPath = ""
  
  Return sPath
  
Catch
  FMain.ErrorText
  
End

Public Function FindFileExtDefaultProgram(Optional hFindDefaultProgram As String = "image/png") As String 
  
  Dim hPath, Text As String 
  Dim T1, T2, hProgram As String
  Dim hSpli As String[]
  
  hFindDefaultProgram = Trim(LCase(hFindDefaultProgram))
  
  If InStr(hFindDefaultProgram, "image") > 0 Then 
    hPath = "~/.config" &/ "mimeapps.list"  '"/home/<user>/.config" &/ "mimeapps.list" ''<user> read and write
  Else
    hPath = "/usr/share/applications" &/ "defaults.list" ''only read in root-path
  Endif
  
  If Exist(hPath) = True Then Text = File.Load(hPath)
  
  For Each T1 In Split(Text, gb.NewLine)
    If T1 Then 
      hSpli = Split(T1 & "=", "=")
      If hSpli Then 
        For Each T2 In hSpli
          If LCase(T2) = hFindDefaultProgram Then 
            hProgram = hSpli[1]
            If hProgram Then Break
          Endif 
        Next 'T2
      Endif 
    Endif
    If hProgram Then Break
  Next 'T1
  hProgram = Replace(LCase(hProgram), ".desktop", "")
  hProgram = Replace(LCase(hProgram), ";", "")
  
  Return hProgram ''=Program-Name, empty if not found   Examples: "firefox", "gimp", ...  
  ''__________________________________________________
  ' text/csv=libreoffice-calc.desktop
  ' text/html=firefox.desktop
  ' text/plain=gedit.desktop
  ' text/rtf=libreoffice-writer.desktop
  ' image/gif=eog.desktop                               ''eog: Eye of GNOME graphics viewer program  
  ' image/jpg=eog.desktop
  ' image/png=eog.desktop
  '' 
Catch
  FMain.ErrorText
  
End

Public Function isZahl(Optional sNumber As String = "") As Boolean
  
  If IsNumber(sNumber) = True Then 
    Return True
  Else 
    Return False 'Rückgabe,  True oder False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function DateCheckyyyymmddhhnn(Optional sDate As String = Format(Now, "yyyy-mm-dd-hh-nn-ss"), Optional sTime As String = "00:00") As Date
  'Rückgabe im Formular: Datum = M01Functions.DateCheckyyyymmddhhnn(Datum, Uhrzeit) ' Datum, prüfen
  
  Dim ssSpli As New String[]
  Dim dateDatum, dateXX As Date
  Dim iYYYY, iMM, iDD, iHH, iNN, iSS, iXX As Integer
  
  If Not dateDatum And sDate Like "*????-??-??-??-??-??*" Then 'yyyy-mm-dd-hh-nn-ss  [0,1,2,3,4,5]
    ssSpli = Split(sDate & String(6, "-"), "-")
    Try dateDatum = Date(CInt(ssSpli[0]), CInt(ssSpli[1]), CInt(ssSpli[2]), CInt(ssSpli[3]), CInt(ssSpli[4]), CInt(ssSpli[5]))
    If Error.Text Then dateDatum = Null 'Try...Error
  Endif 
  ' If Not dateDatum And IsDate(sDate) = True Then Try dateDatum = Val(sDate & Space(1) & "00:00:00") 'Format(sDate, "yyyy-mm-dd") 'as String
  
  If Not dateDatum Then  
    sDate = Trim(sDate) 'Wegschneiden von Leerzeichen am Beginn und am Ende eines Strings
    sDate = Replace(sDate, Space(1), "-") 'ohne Lehrzeichen
    sDate = Replace(sDate, ".", "-")
    sDate = Replace(sDate, "/", "-")
    sDate = Replace(sDate, ":", "-")
    sDate = Replace(sDate, gb.NewLine, "-") 
    
    If sDate Like "*????-??-??-??-??-??*" Then 'yyyy-mm-dd-hh-nn-ss  [0,1,2,3,4,5]
      ssSpli = Split(sDate & String(6, "-"), "-")
      Try dateDatum = Date(CInt(ssSpli[0]), CInt(ssSpli[1]), CInt(ssSpli[2]), CInt(ssSpli[3]), CInt(ssSpli[4]), CInt(ssSpli[5]))
      If Error.Text Then dateDatum = Null
    Endif 
  Endif 
  
  If Not dateDatum Then 
    ''Date Example: "2020-12-31" or "yyyy-mm-dd-hh-nn-ss" (date + time)
    If sDate <> "" And String.InStr(sDate, "y") = 0 Then
      ''dd-mm-yyyy
      If sDate Like "*?-*?-*????*" Then  'yyyy-mm-dd or yyyy-dd-mm
        ssSpli = Split(sDate & String(6, "-"), "-")
        If ssSpli Then           'Len() ASCII > oe, String.Len() UTF-8 > ö
          ssSpli[0] = String.Right(ssSpli[0], 4) ''"?0000" !!! 
          If IsInteger(ssSpli[0]) = True Then iDD = CInteger(ssSpli[0])
          If IsInteger(ssSpli[1]) = True Then iMM = CInteger(ssSpli[1])
          If IsInteger(ssSpli[2]) = True Then iYYYY = CInteger(ssSpli[2])
          If IsInteger(ssSpli[3]) = True Then iHH = CInteger(ssSpli[3]) 'Default 0
          If IsInteger(ssSpli[4]) = True Then iNN = CInteger(ssSpli[4]) 'Default 0
          If IsInteger(ssSpli[5]) = True Then iSS = CInteger(ssSpli[5]) 'Default 0
          If String.Len(iDD) = 4 Then 
            iXX = iYYYY
            iYYYY = iDD
            iDD = iXX
          Endif  
          If iMM > 12 And iDD < 32 Then
            iXX = iDD
            iDD = iMM
            iMM = iXX 
          Endif 
          If iHH > 23 Then iHH = 23
          If iNN > 59 Then iNN = 59 
          If iSS > 59 Then iSS = 59 
          dateXX = Date(iYYYY, iMM, iDD, iHH, iNN, iSS)
          If dateXX Then dateDatum = dateXX 
        Endif 
      Endif 
      
      ''yyyy-mm-dd
      If sDate Like "*????-??-??*" Then  'yyyy-mm-dd or yyyy-dd-mm
        ssSpli = Split(sDate & String(6, "-"), "-")
        If ssSpli Then           'Len() ASCII > oe, String.Len() UTF-8 > ö
          ssSpli[0] = String.Right(ssSpli[0], 4) ''"?0000" !!! 
          If IsInteger(ssSpli[0]) = True Then iYYYY = CInteger(ssSpli[0])
          If IsInteger(ssSpli[1]) = True Then iMM = CInteger(ssSpli[1])
          If IsInteger(ssSpli[2]) = True Then iDD = CInteger(ssSpli[2])
          If IsInteger(ssSpli[3]) = True Then iHH = CInteger(ssSpli[3]) 'Default 0
          If IsInteger(ssSpli[4]) = True Then iNN = CInteger(ssSpli[4]) 'Default 0
          If IsInteger(ssSpli[5]) = True Then iSS = CInteger(ssSpli[5]) 'Default 0
          If iYYYY = 0 Or iMM = 0 Or iDD = 0 Or iMM > 12 Or iDD > 31 Then 
            iYYYY = Year(Date)
            iMM = Month(Date)
            iDD = Day(Date)
          Endif  
          If iHH = 0 Or iNN = 0 Then  
            iHH = 0
            iNN = 0
            iSS = 0
          Endif 
          Try dateDatum = Date(iYYYY, iMM, iDD, iHH, iNN, iSS)  'as Date
          ''Month <> Day
          If iMM > 12 Then 
            Try dateDatum = Date(iYYYY, iDD, iMM, iHH, iNN, iSS)  'as Date
          Endif 
          ''Year <> Day
          If iYYYY < 32 And iDD > 31 Then 
            Try dateDatum = Date(iDD, iMM, iYYYY, iHH, iNN, iSS)  'as Date
          Endif 
        Endif
      Endif  
    Endif 
    
    ''Time Example: "00:00"
    If sTime <> "00:00" And sTime Like "*?:?*" Then 
      ssSpli = Split(sTime & String(2, ":"), ":")
      If ssSpli Then 
        iHH = 0 'Reset
        iNN = 0
        iSS = 0
        If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0])
        If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1])
        If IsInteger(ssSpli[2]) = True Then iSS = CInteger(ssSpli[2])
        If iHH < 0 Then iHH = 0
        If iHH > 23 Then iHH = 23
        If iNN < 0 Then iNN = 0
        If iNN > 59 Then iNN = 59
        If iSS < 0 Then iSS = 0
        If iSS > 59 Then iSS = 59
        dateDatum = Date(Year(dateDatum), Month(dateDatum), Day(dateDatum), iHH, iNN, iSS) 
      Endif
    Endif
  Endif 
  
  Return dateDatum 'as Date    Date+Time
  
Catch 
  FMain.ErrorText
  
End

Public Function DateToWeekday(Optional sDatumYYYYMMDD As String = "", Optional iWeekdayNumber As Integer = 4) As String
  'date2 = DateAdd(Now, gb.day, F_iDaysMinusOrPlus + 1) 'Vorgabe Datum yyyy-mm-dd und genauer Wochentag Mi (So,Mo,Di,Mi,Do,Fr,Sa)
  'Ungenutzt xxx???
  
  Dim date1, date2, date3 As Date 
  Dim sValue As String
  Dim it As Integer
  Dim hDate As Date
  
  hDate = M01Functions.DateCheckyyyymmddhhnn(sDatumYYYYMMDD, "00:00") 'as Date
  If hDate Then 
    date1 = DateAdd(hDate, gb.day, 0)
    'zum ersten eingestellten Wochentag
    For it = 0 To 7
      date2 = DateAdd(date1, gb.day, -it) '- zurück zum Wochenanfang So<< zählen
      If WeekDay(date2) = gb.Sunday Then
        date3 = DateAdd(date2, gb.day, iWeekdayNumber) 'So +Wochentag dazu zählen = Datum
        sValue = Format(date3, "yyyy-mm-dd")
        Break
      Endif
    Next
  Endif 'IsDate
  
  Return sValue 'Ergebnis als String zurückgeben im Format "yyyy-mm-dd", oder leer ""?
  
Catch 
  FMain.ErrorText
  
End

Public Function TimeCheckHHMM(Optional sHHMM As String = "") As String
  'Rückgabe im Formular: Zeit = M01Functions.TimeCheckHHMM(Zeit) = "12:00"
  
  Dim ssSpli As New String[]
  Dim hDate As Date
  Dim iHH, iNN As Integer
  
  If sHHMM Like "*:*" Then 
    ssSpli = Split(sHHMM & ":", ":")
    If ssSpli Then 
      ssSpli[0] = Replace(ssSpli[0], Space(1), "") 'no emtpy space
      ssSpli[1] = Replace(ssSpli[1], Space(1), "")
      If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0])
      If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1])
      If iHH < 0 Then iHH = 0
      If iHH > 23 And iNN = 0 Then '24:00 = 23:59 
        iHH = 23
        iNN = 59
      Endif 
      If iHH > 23 Then iHH = 23
      If iNN < 0 Then iNN = 0
      If iNN > 59 Then iNN = 59
      hDate = Date(Year(hDate), Month(hDate), Day(hDate), iHH, iNN)
      sHHMM = Format(hDate, "hh:nn")
    Endif
  Else
    ''...
  Endif
  
  Return sHHMM 
  
Catch 
  FMain.ErrorText
  
End

Public Function TextSplit(sText As String, Optional iPosition As Integer = 0, Optional sSeparator As String = "") As String
  'Rückgabe Spaltenwert
  
  Dim i As Integer
  Dim sLinePart, sReturnValue As String
  'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
  'Alles was zwischen zwei Nichttrennenzeichen steht ( zb in Anführungsstrichen ) wird nicht zerlegt.
  
  If sSeparator = "" Then sSeparator = FMain.F_sTab
  If Not sSeparator Then sSeparator = gb.Tab
  
  If String.InStr(sText, sSeparator) > 0 Then
    For Each sLinePart In Split(sText, sSeparator) ' Stringarray
      If i = iPosition Then
        sReturnValue = sLinePart
        Break
      Endif
      i = i + 1
    Next
  Endif
  Return sReturnValue 'as String
  
Catch 
  FMain.ErrorText
  
End

Public Function TextSplitSearch(sText As String, Optional sSearchText As String = "", Optional iStart As Integer = 0, Optional sSeparator As String = "") As Integer
  'Rückgabe Spaltennummer
  
  Dim i, iReturnValue As Integer
  Dim sFound As String
  'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
  'Alles was zwischen zwei Nichttrennenzeichen steht ( zb in Anführungsstrichen ) wird nicht zerlegt.
  If sSeparator = "" Then sSeparator = FMain.F_sTab
  If Not sSeparator Then sSeparator = gb.Tab 
  sSearchText = String.LCase(sSearchText)
  iReturnValue = -1 ' Rückgabe bei Fund 0-1-2-3...
  
  If String.InStr(sText, sSeparator) > 0 Then
    For Each sFound In Split(sText, sSeparator) ' Stringarray
      If String.InStr(sFound, "<body") > 0 Then i = 0 ' HTML-Kopf
      If i > iStart Then
        If String.InStr(String.LCase(sFound), sSearchText) > 0 Then
          If iReturnValue = -1 Then iReturnValue = i ' Zeilennummer
          Break
        Endif
      Endif
      i = i + 1
    Next
  Endif
  Return iReturnValue 'as Integer
  
Catch 
  FMain.ErrorText
  
End

Public Function TextFindCounter(sText As String, Optional sSearchText As String = "") As Integer
  'Rückgabe Anzahl Vorkommen
  'Example: sText = "level=begin" & gb.NewLine & "level=end", sSearchText= "level=", TextFindCounter=2
  
  Dim sText2 As String
  Dim iLenFind, iLen1, iLen2, iReturnValue As Integer

  'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
  'Alles was zwischen zwei Nichttrennenzeichen steht ( zb in Anführungsstrichen ) wird nicht zerlegt.

  sText = String.LCase(sText)
  sSearchText = String.LCase(sSearchText)
  iReturnValue = 0 ' Rückgabe bei Fund 0-1-2-3...
  
  sText2 = Replace(sText, sSearchText, "", gb.String) 'ASCII Abc123
  iLenFind = String.Len(sSearchText)
  iLen1 = String.Len(sText)
  iLen2 = String.Len(sText2)
  iReturnValue = (iLen1 - iLen2) / iLenFind

  Return iReturnValue 'as Integer
  
Catch 
  FMain.ErrorText
  
End

Public Function GridTransparentLinesCM(Optional iColorStroke As Integer = Color.Gray) As Image 
  
  Dim it, iW, iH As Integer
  Dim fCM As PointF 'x,y Float
  Dim Img As Image
  Dim sPath, sDir As String 
  Dim bNew As Boolean
  
  sPath = "images/grid_transparentlinescm.png"
  ' If Exist(sPath) = True Then Try Img = Image.Load(sPath)
  
  If Not Img Then 
    bNew = True 
  Else
    If Img.W <> Screen.W Or Img.H <> Screen.H Then bNew = True 'Refresh
  Endif
  If bNew = True Then 
    '********************************
    iW = Screen.W
    iH = Screen.H 
    'iW = Screen.AvailableWidth
    'iH = Screen.AvailableHeight                                                                             'Round
    '********************************
    fCM = M01Functions.Unit1cm() 'as PointF  Example: 40,40 'Pixel x,y
    
    Img = New Image(iW, iH, Color.Transparent)               'Pixel    WxH    Transparent=Default  
    
    Paint.Begin(Img)
    Paint.AntiAlias = True 'FMain.F_bAntiAliasON        '...———...
    Paint.LineCap = Paint.LineCapButt '■
    ' Paint.LineCap = Paint.LineCapRound '● as Integer=1'iLineEndType
    Paint.LineJoin = Paint.LineJoinRound 'as Integer=1'iLineEndType             
    For it = 0 To iH Step fCM.X                                                               '=>W
      Paint.MoveTo(0, it)
      Paint.LineTo(iW, it)
    Next 
    Paint.LineWidth = 1
    Paint.Brush = Paint.Color(iColorStroke)
    Paint.Stroke()
    For it = 0 To iW Step fCM.Y                                                               '=>H
      Paint.MoveTo(it, 0)
      Paint.LineTo(it, iH)
    Next 
    Paint.LineWidth = 1
    Paint.Brush = Paint.Color(iColorStroke)
    Paint.Stroke()
    Paint.End
    sDir = File.Dir(sPath)
    If IsDir(sDir) = True And String.InStr(Application.Path, User.Home) > 0 Then 'not in System-Root
      Img.Picture.Save(sPath) 
    Endif 
    
  Endif 'bNew
  
  Return Img                                'The Image is internally faster than a Picture
  
Catch 
  FMain.ErrorText
  
End

Public Function GridTransparentBackground(Optional iColorFill As Integer = Color.LightGray) As Image'□ □ □ □
  
  Dim Img As Image
  Dim iSize, iMax, iLineEndType, it As Integer
  Dim U As Float
  ''activate or deactivate with Comment-line '
  '***********************
  If Screen.W > Screen.H Then iSize = Screen.W Else iSize = Screen.H
  Img = New Image(iSize, iSize, Color.Transparent)
  U = Unit1cm() 'as Integer '10'Img.W / 10  'Unit 1x
  iMax = iSize / U
  
  iLineEndType = Paint.LineCapButt 'as Integer=0
  ' iLineEndType = FMain.F_iLineEndType 'Paint.LineCapRound 'as Integer=1
  ''Note: F_... level in Form, Dim level only in this procedure Public Sub or Function > End
  '***************************
  
  Paint.Begin(Img)
  Paint.AntiAlias = True 'FMain.F_bAntiAliasON        '...———...
  Paint.LineCap = Paint.LineCapButt '■
  ' Paint.LineCap = Paint.LineCapRound '● as Integer=1'iLineEndType
  Paint.LineJoin = 1  'F_iLineJoin 'as Integer=1'iLineEndType             
  Paint.LineWidth = 1
  For it = 0 To iMax
    Paint.MoveTo(U * it, U * 0)
    Paint.LineTo(U * it, U * iMax)'|
    Paint.MoveTo(U * 0, U * it)
    Paint.LineTo(U * iMax, U * it)'——
  Next
  Paint.Brush = Paint.Color(iColorFill)
  Paint.Stroke() '□
  Paint.End
  
  Return Img 
  
Catch
  FMain.ErrorText
  
End

Public Function GridTransparentBackgroundSquares(Optional iColorFill As Integer = Color.Gray, Optional iWidth As Integer = Screen.W, Optional iHeight As Integer = Screen.H) As Image 
  
  Dim it, it2, iCentimeter As Integer
  Dim iW, iH, R, iColor1, iColor2 As Integer
  Dim Img As Image
  Dim fRadius As Float
  Dim sPath, sDir As String 
  Dim bChangeON1, bChangeON2, bNew As Boolean
  
  sPath = "images/grid_transparentsquares.png"
  ' If Exist(sPath) = True Then Try Img = Image.Load(sPath)
  
  If Not Img Then 
    bNew = True 
  Else
    If Img.W <> Screen.W And Img.H <> Screen.H Then bNew = True 'Refresh
  Endif
  If bNew = True Then 
    '********************************
    iColor1 = iColorFill
    iColor2 = Color.Transparent
    iW = iWidth   ' Screen.W
    iH = iHeight  ' Screen.H 
    'W = Screen.AvailableWidth
    'H = Screen.AvailableHeight
    R = -2                                                                                  'Round
    '********************************
    iCentimeter = 8 'Pixel  'Unit1cm() 'as integer
    
    ' iCentimeter = Desktop.Resolution / 2.54 'ScaleUnit                                               'as Float 123,45
    ' E = Round(iCentimeter / 10, R)                                                                   '1 cm = 10 E |1 2 3 4 5 6 7 8 9 10| 
    ' If E * 10 > iCentimeter Then E = E - 1 
    ' If E * 10 < iCentimeter Then E = E + 1
    ' iCentimeter = E * 10
    fRadius = 0'iCentimeter / 4
    Img = New Image(iW, iH, Color.Transparent)                                                 'Pixel    WxH    Transparent=Default  
    bChangeON1 = True
    bChangeON2 = False 
    
    If Img.W > 0 And Img.H > 0 Then 
    Paint.Begin(Img)
    Paint.AntiAlias = True 'FMain.F_bAntiAliasON        '...———...
    Paint.LineCap = Paint.LineCapButt '■
    ' Paint.LineCap = Paint.LineCapRound '● as Integer=1'iLineEndType
    Paint.LineJoin = Paint.LineJoinRound 'as Integer=1'iLineEndType             
    Paint.LineWidth = 1
    Paint.Font.Size = iCentimeter / 5
    'Paint.Background = Color.Default
    Paint.Brush = Paint.Color(iColor1)
    For it = 0 To iW Step iCentimeter                                                               '=>W
      bChangeON1 = Not bChangeON1 '> ■ □ ■ □...
      For it2 = 0 To iH Step iCentimeter                                                            '=>H
        bChangeON2 = Not bChangeON2 '> ■ □ ■ □...
        Paint.Rectangle(it, it2, iCentimeter, iCentimeter, fRadius)
        If bChangeON2 = True Then 
          Paint.Brush = Paint.Color(iColor1)
          Paint.Fill()
          If it Mod 100 = 0 Then 
            Paint.Brush = Paint.Color(iColor2)
            Paint.Text("Transparent", it, it2, iCentimeter * 2, iCentimeter, Align.Center)
            Paint.Fill()
          Endif 
        Else
          Paint.Brush = Paint.Color(iColor2)
          Paint.Stroke()    
        Endif
      Next 'it2
      If bChangeON1 = bChangeON2 Then bChangeON2 = Not bChangeON2
    Next 'it
    
    Paint.End
    
    sDir = File.Dir(sPath)
    If IsDir(sDir) = True And String.InStr(Application.Path, User.Home) > 0 Then 'not in System-Root
      Img.Picture.Save(sPath) 
    Endif 
  Endif 'bNew
  Endif 
  
  Return Img                                      'The Image is internally faster than a Picture
  
Catch 
  FMain.ErrorText
  
End

Public Function Unit1cm() As PointF 'Example: PointF(40,40) Pixel = 1cm
  
  Dim fCentimeter As Float 
  Dim iMM As Integer ''mm
  Dim fPoint As PointF 'Float
  
  fCentimeter = Desktop.Resolution / 2.54           'Bildschirm-Auflösung in dpi (dots per inch, Punkte pro Zoll), 1 Zoll = 1 inch = 1'' = 2,54 cm
  
  ' iMM = fCentimeter / 10                          'Sub-ScaleUnit |''''!''''| cm
  iMM = Round(fCentimeter / 10)
  If iMM * 10 > fCentimeter Then iMM = iMM - 1 
  If iMM * 10 < fCentimeter Then iMM = iMM + 1
  iMM = iMM * 10  'Sub-ScaleUnit |''''!''''| cm
  fPoint = PointF(iMM, iMM)
  
  Return PointF(fPoint.X, fPoint.Y) 'Example: (40,40)  Pixel (Bildpunkte)
  
Catch 
  FMain.ErrorText
  
End

Public Function Unit1cmNew() As PointF 'Example: PointF(40,40) Pixel = 1cm
  
  Dim fCentimeter As New PointF  ''cm 'as PointF x,y Float
  
  'Sub-ScaleUnit |''''!''''| cm
  ' fCentimeter = Desktop.Resolution / 2.54           'Bildschirm-Auflösung in dpi (dots per inch, Punkte pro Zoll), 1 Zoll = 1 inch = 1'' = 2,54 cm
  fCentimeter = PointF(Round(Screen.ResolutionX / 2.54, 0), Round(Screen.ResolutionY / 2.54, 0))
  
  Settings[FMain.Name &/ "F_pointFUnitCentimeterXY"] = fCentimeter  'x,y
  
  Return fCentimeter 'Example: 40,40  Pixel (Bildpunkte)
  
Catch 
  FMain.ErrorText
  
End

Public Function HolidaysLines(Optional sText As String = "") As String
  
  Dim iCounter As Integer
  Dim sReturnText, sDatum, sLine, sLinePart As String
  Dim T0, T1, T2, T3, T4, T5 As String
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
  'Alles was zwischen zwei Nichttrennenzeichen steht ( zb in Anführungsstrichen ) wird nicht zerlegt.
  
  ' If sSeparator Then hTab = sSeparator  ' gb.Tab =hTab Example: TAB2018-12-31TAB#(Silvester)
  ' TAB2012-01-01TAB#NeujahrTAB...  TABDatumTABNotizTABDatumTABNotizTAB...
  
  If String.InStr(sText, hTab) > 0 Then
    For Each sLine In Split(sText & hReturn, hReturn)
      If sLine Then 
        For Each sLinePart In Split(sLine & String(6, hTab), hTab) ' Stringarray
          If iCounter = 1 And sLinePart <> "" Then
            T5 = sLinePart
            sReturnText = sReturnText & T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hReturn
            iCounter = 0
          Endif
          If sLinePart Like "*????-??-??*" Then
            iCounter = 1
            sDatum = sLinePart
            hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
            T0 = Format(hDate, "yyyy-mm-dd") 'sLinePart
            T1 = "00:00"
            T2 = Format(hDate, "ddd")
            T3 = M01Functions.DateQuarterG(hDate) & "Q" '1...4
            T4 = Format(M01Functions.DateCalenderWeek(hDate), "00") & ("KW") '00...52
          Endif
        Next
      Endif
    Next 
  Endif
  
  Return sReturnText 'as String
  
Catch 
  FMain.ErrorText
  
End

Public Function DateQuarterG(dateQuarter As Date) As Integer
  
  Dim iQ As Integer
  ' dateBegin = Date(Year(dateQuarter), 1, 1) 'Example: "1.1.2000 00:00:00"
  ' Return DateDiff(Date(Year(dateQuarter), 1, 1), dateQuarter, gb.Quarter) 'as Integer 
  ' Return DateDiff(dateQuarter, Date(Year(dateQuarter), 1, 1), gb.Quarter) + 1'as Integer 
  
  Select Case Format(dateQuarter, "mm")
    Case "01", "02", "03"
      iQ = 1
    Case "04", "05", "06"
      iQ = 2
    Case "07", "08", "09"
      iQ = 3
    Case "10", "11", "12"
      iQ = 4
  End Select
  
  Return iQ 'Quater 1,2,3,4
  
Catch 
  FMain.ErrorText
  
End

Public Function DateLastWeekDay(Optional dateInWeek As Date = Now, Optional iWeekDays0So6Sa As Integer = 0) As Date
  
  Dim hDate As Date
  'Return DateAdd(dateInWeek, gb.Day, iWeekDays0So6Sa - WeekDay(dateInWeek)) 'Kurzform
  Select Case iWeekDays0So6Sa
    Case 0 'gb.Sunday
      hDate = DateAdd(dateInWeek, gb.Day, 0 - WeekDay(dateInWeek)) 'So
    Case 1 'gb.Monday
      hDate = DateAdd(dateInWeek, gb.Day, 1 - WeekDay(dateInWeek)) 'Mo
    Case 2 'gb.Tuesday
      hDate = DateAdd(dateInWeek, gb.Day, 2 - WeekDay(dateInWeek)) 'Di
    Case 3 'gb.Wednesday
      hDate = DateAdd(dateInWeek, gb.Day, 3 - WeekDay(dateInWeek)) 'Mi
    Case 4 'gb.Thursday
      hDate = DateAdd(dateInWeek, gb.Day, 4 - WeekDay(dateInWeek)) 'Do
    Case 5 'gb.Friday
      hDate = DateAdd(dateInWeek, gb.Day, 5 - WeekDay(dateInWeek)) 'Fr
    Case 6 'gb.Saturday
      hDate = DateAdd(dateInWeek, gb.Day, 6 - WeekDay(dateInWeek)) 'Sa
  End Select
  
  Return hDate 
  
  ''________________________________________________________________''
  ' New in Gambas3: hDate = DateAdd(Now, gb.Day, 7 - WeekDay(Now)) 
  ' This example gives the date for the next coming sunday
  
Catch 
  FMain.ErrorText
  
End

Public Function DateCalenderWeek(dateWeek As Date) As Integer
  
  Return Week(dateWeek) '& ("KW") 'KalenderWoche, kann auch im vorigen Jahr vor dem 1.1.YYYY beginnen. 
  
Catch 
  FMain.ErrorText
  
End

Public Function TerminweckerLine(Optional sDatum As String, Optional sUhr As String, Optional sNotiz As String) As String
  
  Dim T0, T1, T2, T3, T4, T5, sLine As String
  Dim hDate As Date 
  Dim hTab As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  'hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
  sUhr = Trim(sUhr)
  If String.Left(sUhr, 5) Like "??:??" Then T1 = String.Left(sUhr, 5)
  If hDate Then 
    T0 = Format(hDate, "yyyy-mm-dd")
    T2 = Format(hDate, "ddd")
    T3 = Str(M01Functions.DateQuarterG(hDate)) & "Q" '1...4
    T4 = Format(M01Functions.DateCalenderWeek(hDate), "00") & ("KW") '00...52
  Endif
  T5 = sNotiz
  sLine = T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5
  Return sLine 'AS String
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectLine(Optional sDatum As String, Optional sUhr1 As String, Optional sProjectName As String, Optional sUhr2 As String) As String
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, sLine As String
  Dim dateTime1, dateTime2, dateSum As Date 
  Dim iDiff As Integer
  Dim hTab As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  'hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Not sProjectName Then 
    If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
    sProjectName = FMain.F_sProjectOnlyName
  Endif 
  
  dateTime1 = M01Functions.DateCheckyyyymmddhhnn(sDatum, sUhr1) 'as Date
  dateTime2 = M01Functions.DateCheckyyyymmddhhnn(sDatum, sUhr2) 'as Date
  
  ''Refresh Line:
  If dateTime1 And dateTime2 Then 
    dateSum = Date(Year(dateTime1), Month(dateTime1), Day(dateTime1), 0, 0, 0) 'only Date, Time = "00:00:00"
    
    iDiff = DateDiff(dateTime1, dateTime2, gb.Second)
    dateSum = DateAdd(dateSum, gb.Second, iDiff)
    
    T0 = Format(dateTime1, "yyyy-mm-dd")
    T1 = Format(dateTime1, "hh:nn")
    T2 = Format(dateTime1, "ddd")
    T3 = M01Functions.DateQuarterG(dateTime1) & "Q" '1...4
    T4 = Format(M01Functions.DateCalenderWeek(dateTime1), "00") & ("KW") '00...52
    T5 = sProjectName 'T5=Notiz --------------- ▲old▲  ▽new▽
    T6 = Format(dateTime2, "hh:nn")
    T7 = Format(dateTime2, "ddd")
    T8 = Str(iDiff) 'Example: "01234"
    T9 = Format(dateSum, "hh:nn:ss") '"00:00:00", max."23:59:59"
    
    sLine = T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hTab & T6
  Endif 
  
  Return sLine 'AS String
  
Catch 
  FMain.ErrorText
  
End

Public Function TempDirectoryOpen() As String 
  
  Dim sDir As String 
  
  sDir = M01Functions.CheckDirectoryCache()
  If Exist(sDir) = True Then Desktop.Open(sDir) ' M01Functions.FileManagerOpen(sDir)
  Return sDir
  
Catch 
  FMain.ErrorText
  
End

Public Function isText(Optional sDirFile As String = "") As Boolean 
  
  If Exist(sDirFile) = True And String.InStr("*.txt;*.conf;*.csv;", LCase("." & File.Ext(sDirFile) & ";")) > 0 Then 'text?
    Return True
  Else 
    Return False 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function isTerminweckerFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iFoundColumns, iSeparators As Integer
  Dim ssSpliLine As String[]
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 5 'Termine 5, Projects 8
  '******************************
  sSeparator = gb.Tab
  bFormat = False
  
  If Exist(sDirFile) = True Then
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine
      
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      ' gb.Unix For lines separated by Chr$(10).
      ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
      ' gb.Mac For lines separated by Chr$(13).
      
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If String.InStr(sLine, sSeparator) > 0 Then
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        If ssSpliLine.Count > iSeparators Then
          iFoundColumns = 0 'Reset
          If ssSpliLine[0] Like "*????-??-??*" Then iFoundColumns = iFoundColumns + 1
          If ssSpliLine[1] Like "*??:??*" Then iFoundColumns = iFoundColumns + 1
          If ssSpliLine[5] <> "" Then iFoundColumns = iFoundColumns + 1 'Notice, Name?
          If iFoundColumns > 2 Then iFoundLines = iFoundLines + 1
          If iFoundLines > 0 Then Break 'min. Check
        Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 0 Then bFormat = True 'Readable
    ' If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size)
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    sMessage = "<h2><font color=#" & Hex(Color.SelectedBackground, 6) & ">" & ("Auswahl") & "</font></h2>" 
    sMessage &= "<h3><font color=blue>" & File.Dir(sDirFile) & "/" & "</font><font color=red>" & File.Name(sDirFile) & "</font></h3>"
    If Exist(sDirFile) = False Then 
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font size=5>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt] & "<br>"
    sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & M01Functions.TerminweckerLine(Format(Date, "yyyy-mm-dd"), Format(Time, "hh:nn"), ("Notiz1")) & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= "● " & ("Abbrechen empfohlen") & "<br>"
    sMessage &= "</font>"
        
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), "● " & ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat 'AS Boolean
  
  ''________________________________________________________________________________''
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  'Example File-Muster:
  '2022-01-01 12:00 Mo  1 1KW Text  ...
  '...
  
Catch 
  FMain.ErrorText
  
End

Public Function isProjectFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iFoundColumns, iSeparators As Integer
  Dim ssSpliLine As String[]
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 8 'Termine 5, Projects 8
  '******************************
  sSeparator = gb.Tab
  bFormat = False
  
  If Exist(sDirFile) = True Then
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine
      
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      ' gb.Unix For lines separated by Chr$(10).
      ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
      ' gb.Mac For lines separated by Chr$(13).
      
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If String.InStr(sLine, sSeparator) > 0 Then
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        If ssSpliLine.Count > iSeparators Then
          iFoundColumns = 0 'Reset
          If ssSpliLine[0] Like "*????-??-??*" Then iFoundColumns = iFoundColumns + 1
          If ssSpliLine[1] Like "*??:??*" Then iFoundColumns = iFoundColumns + 1
          If ssSpliLine[5] <> "" Then iFoundColumns = iFoundColumns + 1 'Notice, Name?
          If ssSpliLine[6] Like "*??:??*" Then iFoundColumns = iFoundColumns + 1
          If iFoundColumns > 3 Then iFoundLines = iFoundLines + 1
          If iFoundLines > 0 Then Break 'min. Check
        Endif
        ' Endif
      Endif  
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 0 Then bFormat = True 'Readable
    ' If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"    
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] & "<br>"
    sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & M01Functions.ProjectLineRefresh() & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat 'AS Boolean
  
  ''________________________________________________________________________________''
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  'Example File-Muster:
  '2022-01-01 12:00 Mo  1 1KW Text  ...
  '...
  
Catch 
  FMain.ErrorText
  
End

Public Function isTerminweckerClockMusterFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iFoundColumns, iSeparators As Integer
  Dim ssSpliLine As String[]
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine
      
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      ' gb.Unix For lines separated by Chr$(10).
      ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
      ' gb.Mac For lines separated by Chr$(13).
      
      sLine = Replace(sLine, gb.Cr, "") '"\r" '(*1) '\r
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        If ssSpliLine.Count > iSeparators + 1 Then
          iFoundColumns = 0
          If iFoundLines = 0 Then 
            If sLine Like "*terminwecker*" Then iFoundColumns = iFoundColumns + 1
          Endif 
          If sLine Like "*level=*" Then iFoundColumns = iFoundColumns + 1
          If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
          If iFoundLines > 3 Then Break 'min. Check
        Endif
        ' Endif
        ' Print "isTerminweckerClockMusterFile", sDirFile, sLine, iLines
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("level=...") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat 'AS Boolean
  
  ' Example File-Muster:
  ' #terminwecker 3.0.353 Clock-Levels
  ' #level number left selected path '0 1 2 3 4
  ' 
  ' level=begin
  ' level=163=0=1==
  ' level=109=101=1==
  ' level=71=202=1==
  ' level=59=303=1==
  ' level=end
  '
  ' ...
  
Catch 
  FMain.ErrorText
  
End

Public Function isHolidaysPlusFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iSeparators As Integer
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ' ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        ' If ssSpliLine.Count > iSeparators + 1 Then
        ' iFoundColumns = 0
        If iFoundLines = 0 Then 
          If sLine Like "*terminwecker*" Then iFoundLines = iFoundLines + 1
        Endif 
        If sLine Like "holidaysplus*" & gb.Tab & "*" Then iFoundLines = iFoundLines + 1
        ' If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
        If iFoundLines > 3 Then Break 'min. Check
        ' Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt", FMain.F_sPathHolidaysPlus_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("HolidaysPlus00 ...") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' #terminwecker 3.0.369 Zusaetzliche Feiertage, Gedenktage
  ' HolidaysPlus00  0  2022-04-17  So  Ostersonntag
  ' ...
  
Catch
  FMain.ErrorText
  
End 

Public Function isPhotoSubtitleDateFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iSeparators As Integer
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ' ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        ' If ssSpliLine.Count > iSeparators + 1 Then
        ' iFoundColumns = 0
        If iFoundLines = 0 Then 
          If sLine Like "*terminwecker*" Then iFoundLines = iFoundLines + 1
        Endif 
        If sLine Like "quote=*" Then iFoundLines = iFoundLines + 1
        ' If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
        If iFoundLines > 3 Then Break 'min. Check
        ' Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("quote=...") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' #terminwecker 3.0.369 Zitate
  ' quote="..."
  ' ...
  
Catch
  FMain.ErrorText
  
End 

Public Function isBookmarkFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iSeparators As Integer
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ' ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        ' If ssSpliLine.Count > iSeparators + 1 Then
        ' iFoundColumns = 0
        If iFoundLines = 0 Then 
          If sLine Like "*terminwecker*" Then iFoundLines = iFoundLines + 1
        Endif 
        If sLine Like "*[bookmark*]*" Then iFoundLines = iFoundLines + 1
        ' If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
        If iFoundLines > 3 Then Break 'min. Check
        ' Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("[Bookmarks]") & "</b></font><br>"
    sMessage &= "<font color=gray><b>" & ("...") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' #terminwecker 3.0.369 Lesezeichen
  ' [Bookmarks]
  ' Count=0
  ' ...
  
Catch
  FMain.ErrorText
  
End 

Public Function isColorFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iSeparators As Integer
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ' ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        ' If ssSpliLine.Count > iSeparators + 1 Then
        ' iFoundColumns = 0
        If iFoundLines = 0 Then 
          If sLine Like "*terminwecker*" Then iFoundLines = iFoundLines + 1
        Endif 
        If sLine Like "*color=*" Then iFoundLines = iFoundLines + 1
        ' If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
        If iFoundLines > 3 Then Break 'min. Check
        ' Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("color=...") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' #terminwecker 3.0.364
  ' color="65280"
  ' color="16776960"
  ' color="16744576"
  ' color="12632256"
  ' color="4210752"
  ' color="16777215"
  ' color="16776960"
  ' color="16762880"
  ' color="-1774174144"
  ' color="0"
  ' color="15724527"
  
Catch
  FMain.ErrorText
  
End 

Public Function isTimerPlusFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iFoundColumns, iSeparators As Integer
  Dim ssSpliLine As String[]
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ssSpliLine = Split(sLine & sSeparator, sSeparator)  
        If ssSpliLine.Count > iSeparators + 1 Then
          iFoundColumns = 0
          If iFoundLines = 0 Then 
            If sLine Like "*terminwecker*" Then iFoundColumns = iFoundColumns + 1
          Endif 
          If sLine Like "*checkBox*=*" Then iFoundColumns = iFoundColumns + 1
          If sLine Like "*textarea*=*" Then iFoundColumns = iFoundColumns + 1
          If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
          If iFoundLines > 3 Then Break 'min. Check
        Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathTimerPlus_txt", FMain.F_sPathTimerPlus_txt] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & Space(1) & "1-10" & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("CheckBox=1=-1") & "</b></font><br>"
    sMessage &= "<font color=gray><b>" & ("TextArea=1=Notiz 1") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' #terminwecker 3.0.364
  ' CheckBox=1=-1
  ' CheckBox=2=0
  ' CheckBox=3=0
  ' CheckBox=4=0
  ' CheckBox=5=0
  ' CheckBox=6=0
  ' CheckBox=7=0
  ' CheckBox=8=0
  ' CheckBox=9=0
  ' CheckBox=10=0
  ' TextArea=1="Notiz 1"
  ' TextArea=2="Notiz 2"
  ' TextArea=3="Notiz 3"
  ' TextArea=4="Notiz 4"
  ' TextArea=5="Notiz 5"
  ' TextArea=6="Notiz 6"
  ' TextArea=7="Notiz 7"
  ' TextArea=8="Notiz 8"
  ' TextArea=9="Notiz 9"
  ' TextArea=10="Notiz 10"
  
Catch
  FMain.ErrorText
  
End 

Public Function isConfigurationFile(Optional sDirFile As String = "", Optional bMessageON As Boolean = False) As Boolean   
  
  Dim hFile As File
  Dim sLine, sSeparator, sFileSize, sEmpty, sMessage As String
  Dim iLines, iLinesMax, iFoundLines, iFoundColumns, iSeparators As Integer
  Dim ssSpliLine As String[]
  Dim bFormat As Boolean
  
  '******************************
  iLinesMax = 100
  iSeparators = 1
  '******************************
  sSeparator = "=" 
  bFormat = False
  
  If Exist(sDirFile) = True Then 
    ''Read ########################################
    hFile = Open sDirFile For Read
    While Not Eof(hFile)
      Line Input #hFile, sLine  'Aus der Datei wird zeilenweise gelesen
      hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
      'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
      
      If String.IsValid(sLine) = True Then 'gültige Zeichen UTF-8 
        ' If sLine Then 
        iLines = iLines + 1
        If iLines > iLinesMax Then Break
        sLine = String.LCase(sLine)
        If sLine Like "*<*html>*" Then Break '<!DOCTYPE html>
        ssSpliLine = Split(String.LCase(sLine) & sSeparator, sSeparator)  
        If ssSpliLine.Count > iSeparators + 1 Then
          iFoundColumns = 0
          If iFoundLines = 0 And sLine Like "*[*]*" Then iFoundColumns = iFoundColumns + 1
          If iFoundLines > 0 And sLine Like "*=*" Then iFoundColumns = iFoundColumns + 1
          If iFoundColumns > 0 Then iFoundLines = iFoundLines + 1 
          If iFoundLines > 3 Then Break 'min. Check
        Endif
        ' Endif
      Endif
    Wend
  Finally 'Line next by Error (Immer ausführen, auch bei einem Fehler)
    Close #hFile
    'RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
    If iFoundLines > 3 Then bFormat = True 'Readable
    If iLines > 0 And iLines < 3 And iFoundLines > 1 Then bFormat = True   'min. 2 found
    If Stat(sDirFile).Size = 0 Then bFormat = True 'empty, no Format
  Endif
  If bFormat = False And bMessageON = True Then
    If Exist(sDirFile) = True Then 
      sFileSize = M01Functions.FileSizeText(sDirFile) 'as String 
      If Stat(sDirFile).Size = 0 Then sEmpty = ("leer") Else sEmpty = ("Fehler-Zeilen")
    Else 
      sEmpty = ("Fehlt") 
    Endif 
    If Exist(sDirFile) = True Then 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>" 
    Else 
      sMessage = "<h3><font color=red>" & sDirFile & "</font></h3>"   
      sMessage &= "<h3><font color=red><b>" & ("Datei fehlt!") & "</b></font></h3>"   
    Endif 
    sMessage &= sFileSize & "<br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & sEmpty & "</b></font>" & "<br>" 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf] & "<br>"
    ' sMessage &= "<font color=gray><b>" & "0000-00-00 00:00 WD Q CW Notice" & "</b></font><br>"
    sMessage &= ("Beispiel-Zeile") & ": " & "<br>"
    sMessage &= "<font color=gray><b>" & ("[FMain]") & "</b></font><br>"
    sMessage &= "<font color=gray><b>" & ("Left=1440") & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= ("Abbrechen empfohlen") & "<br>"
    
    Select Case Message.Warning(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open (Öffnen)
        bFormat = True
      Case 2 'Directory (Ordner)
        bFormat = False
        If Exist(sDirFile) = False Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          Desktop.Open(File.Dir(sDirFile)) 
        Endif 
      Case 3 'Cancel (Abbrechen)
        bFormat = False
    End Select
  Endif
  
  Return bFormat
  
  ' Example File-Muster:
  ' [FMain]
  ' Left=1440
  ' ...
  
Catch
  FMain.ErrorText
  
End 

Public Function isPicForPictureBox(Optional sPath As String = "") As Boolean 
  'Example FileChooser1.Filter = ["*.png;*.jpg;*.jpeg;*.bmp", "Picture files", "*.svg;*.wmf", "Drawing files"]
  
  If Exist(sPath) = True And String.InStr("*.png;*.jpg;*.jpeg;*.bmp;*.xpm;*.svg;*.ppm;*.xpm;*.tiff;*.gif;", LCase("." & File.Ext(sPath) & ";")) > 0 Then 'picture?, 
    Return True
  Else 
    Return False 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function isMusic(Optional sPath As String = "") As Boolean 
  'Example FileChooser1.Filter = ["*.png;*.jpg;*.jpeg;*.bmp", "Picture files", "*.svg;*.wmf", "Drawing files"]
  
  If Exist(sPath) = True And String.InStr("*.mp3;*.mid;*.wav;*.ogg;", LCase("." & File.Ext(sPath) & ";")) > 0 Then 'picture?, 
    Return True
  Else 
    Return False 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function FileReadText(Optional sDirFile As String = "", Optional iYearBegin As Integer = 0, Optional iYearEnd As Integer = 0) As String
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File
  Dim sLine, sLines As String
  Dim date1, date2, date3 As Date
  Dim sT0, sT5 As String 
  Dim ssSearch, ssSpli As String[]
  Dim bFound As Boolean
  Dim it, iYears As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(sDirFile) = False Then 
    sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
    If Exist(sDirFile) = False Then sDirFile = FMain.F_sPathTerminweckerStandard_txt
  Endif 
  
  ''Year 0000 begin—▶end:
  If iYearBegin = 0 Then iYearBegin = Settings[FMain.Name &/ "ValueBoxYearBegin.Value", Year(Date)]
  If iYearEnd = 0 Then iYearEnd = Settings[FMain.Name &/ "ValueBoxYearEnd.Value", Year(Date)]
  
  If Exist(sDirFile) = True Then 
    
    date1 = Date(iYearBegin, 1, 1, 0, 0, 0) 'first day in the year
    date2 = Date(iYearEnd, 12, 31, 0, 0, 0) 'last day
    iYears = DateDiff(date1, date2, gb.Year) 'as Integer
    
    ssSearch = New String[]
    ssSearch.Sort() 
    For it = 0 To iYears
      date3 = DateAdd(date1, gb.Year, it)
      ssSearch.Add(Format(date3, "yyyy-")) 
    Next 
    
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFile & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      If String.Left(sLine, 1) <> "#" And String.InStr(sLine, hTab) > 0 Then 
        ssSpli = Split(sLine & String(5, hTab), hTab)
        sT0 = String.Left(ssSpli[0], 5) '"0000-" 
        sT5 = String.Left(ssSpli[5], 1) '*Every Year?
        bFound = False
        ' If sSearch Like "*" & sT0 & "*" Then
        If ssSearch.ExistSorted(sT0) = True Then 'Sorted faster
          bFound = True 
        Else If sT0 Not Like "*-*" Then 
          bFound = True
          ' Else If sT0 Like "*" & sTimer2 & "*" Then 
          '   bFound = True
          ' Else If sT0 Like "*" & sTimer3 & "*" Then 
          '   bFound = True
          ' Else If sT5 = "*" Then '*Every Year, Birthdays
        Else If sT5 Begins "*" Then 
          bFound = True
        Endif 
        If bFound = True Then sLines &= sLine & hReturn 
        'sLine = Conv$(sLine, Desktop.Charset, "ISO-8859-1")
        'sLine = Conv$(sLine, "utf-8", "ISO-8859-1")
      Endif 
    Next 
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  Return sLines
  
Catch
  FMain.ErrorText
  If Exist(sDirFile) = True Then hFile.Close()
  
End 

Public Function FileReadTextAlternative(Optional sDirFile As String = "") As String
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File
  Dim sLine, sLines As String
  
  If IsDir(sDirFile) = False And Exist(sDirFile) = True Then 
    
    ''Read ########################################
    hFile = Open sDirFile For Read
    ' hFile.ByteOrder = gb.LittleEndian
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    
    For Each sLine In hFile.Lines  ''all Lines in File
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFile & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      sLines &= sLine & gb.NewLine 
    Next 
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  Return sLines
  
Catch
  FMain.ErrorText
  If Exist(sDirFile) = True Then hFile.Close()
  
End 

Public Function CheckTextTerminwecker(Optional sText As String = Null) As String 'sInfoText
  
  Dim it, iColumns, iCounter, iTestLinesMax As Integer
  Dim iLines, iTerminLines, iProjectLines As Integer
  Dim sLinesSeparator, sLine, sSpalte, sInfoText, sMessage, sLinesFormatTermine, sLinesFormatProjects, hSep, sLineEnd As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  hSep = Space(1) & "|" & Space(1)
  sLineEnd = Space(3) & ("+Zeilenvorschub")
  iTestLinesMax = 4
  
  If sText Then 'wenn Text, dann Inhalt prüfen 
    sMessage = ("Zeilen nicht erkannt. Datei überprüfen.") & gb.NewLine 
    sMessage &= ("Tipp: Spalten umstellen in einem Tabellen-Programm.") & gb.NewLine 
    sMessage &= ("Siehe Menü>?>Info> Zeilenaufbau Format.") & gb.NewLine & gb.NewLine 
    sMessage &= ("Trenner: Tabulator-Taste") & "[⇄]" & Space(1) & ("+Zeilen-Ende" & "[↵]") & gb.NewLine 
    sLinesFormatTermine = ("Datum") & hSep & ("Uhrzeit") & hSep & ("Wochentag") & hSep & ("Quartal") & hSep & ("Kalenderwoche") & hSep & ("Notizen") 
    sLinesFormatProjects = ("Datum") & hSep & ("Uhrzeit") & hSep & ("Wochentag") & hSep & ("Quartal") & hSep & ("Kalenderwoche")
    sLinesFormatProjects &= hSep & ("Projekt-Name") & hSep & "00:00" & hSep & ("Wochentag") & hSep & ("Sek.-Zahl") & hSep & ("=Dauer") 
    'Zeilen trennen (Spalten-Trennung mit TAB bei Windows und Linux gleich)
    If String.InStr(sText, hReturn) > 0 Then 'Windows-Dateienden
      sLinesSeparator = hReturn
    Else  'Linux-Dateienden
      sLinesSeparator = gb.NewLine
    Endif
    
    For Each sLine In Split(sText, sLinesSeparator) ' Stringarray
      iColumns = 0
      iCounter = 0
      For Each sSpalte In Split(sLine & hTab, hTab) ' Stringarray
        ''Termine
        If iColumns = 0 And sSpalte Like "*????-??-??*" Then iCounter = iCounter + 1          'Datum 
        If iColumns = 1 And sSpalte Like "*??:??*" Then iCounter = iCounter + 1               'Uhr 
        If iColumns = 3 And sSpalte Like "-Q" Then iCounter = iCounter + 1                    'Timer SoMoDiMiDoFrSa
        If iColumns = 5 And IsNumber(String.Left(sSpalte, 5)) = False Then iCounter = iCounter + 1   'Notiz
        ''Projekte
        If iColumns = 6 And sSpalte Like "*??:??*" Then iCounter = iCounter + 1               'Uhr Projekt
        If iColumns = 9 And sSpalte Like "*??:??*" Then iCounter = iCounter + 1               'Dauer Projekt
        iColumns = iColumns + 1
      Next
      If iCounter < 3 Then iLines = iLines + 1
      If iCounter = 3 And iColumns <= 6 Then iTerminLines = iTerminLines + 1
      If iCounter > 3 And iColumns >= 10 Then iProjectLines = iProjectLines + 1
      it = it + 1
      If it > iTestLinesMax Then Break 
    Next
    If iLines >= 0 And iProjectLines = 0 Then 'zuerst größere Zahl testen
      sInfoText = Application.Name & "-" & ("Projekte") & " = " & sMessage & gb.NewLine & sLinesFormatProjects & sLineEnd & gb.NewLine
    Else If iLines >= 0 And iProjectLines = 0 And iTerminLines = 0 Then 
      sInfoText = Application.Name & "-" & ("Termine") & " = " & sMessage & gb.NewLine & sLinesFormatTermine & sLineEnd & gb.NewLine
    Endif 
  Endif 
  Return sInfoText 'As String 'hier kein html-Text, Null or Infotext
  
Catch 
  FMain.ErrorText
  
End 

Public Function WebZeichen(Optional sText As String = "") As String 'old, unused, new utf-8
  
  Dim hReturn As String 
  'hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sText = Replace(sText, "Ä", "&#196;")
  sText = Replace(sText, "ä", "&#228;")
  sText = Replace(sText, "Ö", "&#214;")
  sText = Replace(sText, "ö", "&#246;")
  sText = Replace(sText, "ü", "&#252;")
  sText = Replace(sText, "Ü", "&#220;")
  sText = Replace(sText, "ß", "&#223;")
  
  sText = Replace(sText, "€", "&euro;")
  sText = Replace(sText, "€", "&#8364;")                                                    'Euro
  sText = Replace(sText, "§", "&#167;")
  sText = Replace(sText, "¹", "&sup1;")                                                     'Hoch eins &#185;
  sText = Replace(sText, "²", "&sup2;")                                                     'Hoch zwei &#178;
  sText = Replace(sText, "³", "&sup3;")                                                     'Hoch drei &#179;
  
  'sText = Replace(sText, "¶", "&#182;")                                                    'Return, Zeilenvorschub
  sText = Replace(sText, "¶", "<br>")                                                       '¶ Absatz-Zeichen &para; oder &#182;
  sText = Replace(sText, hReturn, "<br>")
  
  Return sText 'AS String
  
  'see —▶WebZeichenUmkehren
Catch 
  FMain.ErrorText
  
End

Public Function WebZeichenUmkehren(Optional sText As String = "") As String 'old version, new UTF-8
  'unused
  
  Dim hReturn As String 
  'hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sText = Replace(sText, "&#196;", "Ä")
  sText = Replace(sText, "&#228;", "ä")
  sText = Replace(sText, "&#214;", "Ö")
  sText = Replace(sText, "&#246;", "ö")
  sText = Replace(sText, "&#252;", "ü")
  sText = Replace(sText, "&#220;", "Ü")
  sText = Replace(sText, "&#223;", "ß")
  
  sText = Replace(sText, "&euro;", "€")                                                     'Euro
  sText = Replace(sText, "&#8364;", "€")                                                    'Euro
  sText = Replace(sText, "&#167;", "§")
  sText = Replace(sText, "&sup1;", "¹")                                                     'Hoch eins &#185;
  sText = Replace(sText, "&sup2;", "²")                                                     'Hoch zwei &#178;
  sText = Replace(sText, "&sup3;", "³")                                                     'Hoch drei &#179;
  
  'sText = Replace(sText, "&#182;", "¶")                                                    'Return, Zeilenvorschub
  sText = Replace(sText, "<br>", "¶")                                                       '¶ Absatz-Zeichen &para; oder &#182;
  sText = Replace(sText, "¶", hReturn)
  
  Return sText 'as String
  
Catch 
  FMain.ErrorText
  
End

Public Function SecondsInfoText(Optional iSeconds As Integer = 0) As String 
  
  Dim iDays As Integer
  Dim sSep, sStopwatch As String ' Tage Stunden:Minuten:Sekunde
  Dim dateBegin, dateSum As Date 
  Dim sOneDay As String 
  
  sSep = "" 'Space(1) 'Separator, Trennzeichen 
  
  dateBegin = Date(Year(Date), 1, 1)
  dateSum = DateAdd(dateBegin, gb.Second, iSeconds) 'as Date
  iDays = DateDiff(dateBegin, dateSum, gb.Day) 'as Integer
  If iDays = 0 Then 
    sStopwatch = Format(dateSum, "hh:nn:ss")
  Else 
    If Abs(iDays) = 1 Then sOneDay = ("Tag") Else sOneDay = ("Tage")
    sStopwatch = Str(iDays) & sSep & sOneDay & " +" & Format(dateSum, "hh:nn:ss")
  Endif 
  'Anwendungsbeispiel:
  'Label4.Text = "Dauer: " & F_sProjectOnlyName & Space(1) & hhh_mm_ss  
  
  Return sStopwatch 'Rückgabewert Example: "0 Tage 23:30:59"
  
  ''_____________________________________________________________________________''
  ' Gambas3: The value of an Integer is between -2147483648 and +2147483647. (-2^31 and 2^31-1) For larger integers, use Long.
Catch 
  FMain.ErrorText
  
End

Public Function Seconds24hDate(Optional iSeconds As Integer = 0) As Date
  
  Dim date24h As Date 
  '1Day=24h=1440m=86400s  
  date24h = Date(Year(Date), Month(Date), Day(Date), 0, 0, 0, 0) ' or date24h = Date
  Return DateAdd(date24h, gb.Second, iSeconds) 'as Date  'Rückgabewert
  
Catch 
  FMain.ErrorText
  
End

Public Function SecondsHHHNNSS(Optional iSeconds As Integer = 0) As String 
  
  Dim dateA, dateB As Date 
  Dim iHHH As Integer
  Dim sText As String 
  
  dateA = Date  '0 seconds
  dateB = DateAdd(dateA, gb.Second, iSeconds) 'as Date
  iHHH = DateDiff(dateA, dateB, gb.Hour)
  sText = Str(iHHH) & ":" & Format(dateB, "nn:ss") 
  
  Return sText
  
Catch 
  FMain.ErrorText
  
End

Public Function SinceStartText(Optional dateStart As Date = Now) As String
  
  Dim iDiff As Integer
  Dim sText As String 
  
  If dateStart Then  
    iDiff = DateDiff(Now, dateStart, gb.Second)
    sText = Str(iDiff) & Space(1) & ("Sekunden")
    If Abs(iDiff) > 59 Then 
      iDiff = DateDiff(Now, dateStart, gb.Minute)
      sText = Str(iDiff) & Space(1) & ("Minuten")
      If Abs(iDiff) > 59 Then 
        iDiff = DateDiff(Now, dateStart, gb.Hour)
        sText = Str(iDiff) & Space(1) & ("Stunden")
        If Abs(iDiff) > 23 Then 
          iDiff = DateDiff(Now, dateStart, gb.Day)
          sText = Str(iDiff) & Space(1) & ("Tagen")
          If Abs(iDiff) > 31 Then 
            iDiff = DateDiff(Now, dateStart, gb.Month)
            sText = Str(iDiff) & Space(1) & ("Monaten")
            If Abs(iDiff) > 24 Then 
              iDiff = DateDiff(Now, dateStart, gb.Year)
              sText = Str(iDiff) & Space(1) & ("Jahren")
            Endif 
          Endif 
        Endif 
      Endif 
    Endif 
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Function InfoDirFileLastModifiedSizeMimeHTML(Optional sDirFile As String = "") As String '<HTML>
  
  Dim sInfoText, sEmpty, sExtType, sHTMLspace As String 
  
  If Exist(sDirFile) = True Then
    sExtType = M01Functions.FileCheckTypeExtension(sDirFile, True) 'True=MimeType
    sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html  (no break space)
    If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>"
    sInfoText = File.BaseName(sDirFile) & "." & "<b>" & File.Ext(sDirFile) & "</b>" & String(3, sHTMLspace) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & sEmpty & String(3, sHTMLspace)
    sInfoText &= sExtType
  Else 
    sInfoText = sDirFile
  Endif 
  
  Return sInfoText
  
Catch 
  FMain.ErrorText
  
End

Public Function InfoDirFileLastModifiedSizeText(Optional sDirFile As String = "") As String 
  
  Dim sInfoText, sEmpty As String 
  
  If Exist(sDirFile) = True Then
    If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & ("Leer") 
    sInfoText = File.Name(sDirFile) & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & sEmpty
  Else 
    sInfoText = sDirFile
  Endif 
  
  Return sInfoText
  
Catch 
  FMain.ErrorText
  
End

Public Function FileLastModifiedDate(Optional sDirFile As String = "") As Date
  
  Dim statInfo As Stat
  Dim dateVeraendertam As Date
  
  If Exist(sDirFile) = True Then
    statInfo = Stat(sDirFile)
    dateVeraendertam = statInfo.LastModified 'as Date (Datum + Uhrzeit)
  Endif
  
  Return dateVeraendertam
  
Catch 
  FMain.ErrorText
  
End

Public Function FileLastModifiedSeconds(Optional sDirFile As String = "") As Integer
  
  Dim statInfo As Stat
  Dim dateChanged As Date
  Dim iDiff As Integer
  
  If Exist(sDirFile) = True Then
    statInfo = Stat(sDirFile) 
    dateChanged = statInfo.LastModified 'as Date
    iDiff = DateDiff(dateChanged, Now, gb.Second) ' Rückgabe integer
  Endif
  Return iDiff
  
Catch 
  FMain.ErrorText
  
End

Public Function FileTypeProgram(Optional sDirFile As String = "", Optional sMimeProgramType As String = "text/html") As String
  
  Dim hTest As DesktopFile[]
  Dim iFound, iFound2, it As Integer
  Dim sProgramNames, sDir, sPathList, sDirFileDesktop, sText, sMimeSelect, sFoundProgram, sMimeExact As String
  Dim sProgram1, sProgram2, sMessage, sExtraInfo As String 
  Dim ssLine, ssLineDesktop, ssLinePart As String[]
  Dim ssExamples As String[] = ["text", "text/html", "text/plain", "text/rtf", "text/csv", "text/comma", "text/tab", "image", "image/png", "image/jpg", "image/bmp", "image/svg", "audio", "music", "audio/ogg", "audio/mp3", "audio/mpeg", "audio/midi"]
  ' hTest = DesktopFile.FromMime("text/plain") ''"text/html"  
  
  ''Desktop (Schreibtisch, Start-Bildschirm)
  hTest = DesktopFile.FromMime(sMimeProgramType) ''Desktop.FromMime() needs component: gb.desktop
  
  For it = 0 To hTest.Max 
    sProgramNames &= hTest[it].Name & gb.NewLine 'only Program-Names "firefox"..., only in Directory Desktop (Schreibtisch)
  Next
  
  ''Check Type:
  iFound = ssExamples.Find("*" & String.LCase(sMimeProgramType) & "*", gb.like) '-1 not found
  If iFound > -1 Then sMimeSelect = ssExamples[iFound]
  If sMimeSelect Then 
    sMimeSelect = String.LCase(sMimeSelect)
    Select Case sMimeSelect
      Case "text"
        sMimeExact = "text/plain"
      Case "image"
        sMimeExact = "image/png"
      Case "audio", "music"
        sMimeExact = "audio/mp3"
    End Select 
    If sMimeExact Then sMimeSelect = sMimeExact
    ' sPathList = "/usr/share/applications/defaults.list" 'only read!
    ' sDir = "/usr/share/applications/" 'File.Dir(sPathList) ' ssDesktop = RDir(sDir, "*.desktop", gb.File)
    ' If Exist(sPathList) = False Then sPathList = "/etc/gnome/defaults.list" 'IsDir()
    sPathList = User.Home &/ ".config" &/ "mimeapps.list" ' "/home/<user>/.config/mimeapps.list"     'Einfaches Textdokument (text/plain)  Zugriff im Bereich <user> erlaubt, ohne Root-Rechte."
    sDir = User.Home &/ ".config"
    '/etc/mime.types
    
    ''Load another:
    If Exist(sPathList) = True Then sText = File.Load(sPathList)
    If sText Then 
      ssLine = Split(sText & gb.NewLine, gb.NewLine)
      iFound = 0
      For it = 0 To ssLine.Max
        iFound = ssLine.Find("*" & sMimeSelect & "*", gb.Like, iFound)
        If iFound = -1 Then Break '-1 not found
        ssLinePart = Split(ssLine[iFound] & "=", "=")
        sFoundProgram = ssLinePart[1]
        sDirFileDesktop = sDir &/ sFoundProgram
        ''Check file*.desktop
        If Exist(sDirFileDesktop) = True Then '*.desktop
          sText = File.Load(sDirFileDesktop)
          ssLineDesktop = Split(sText & gb.NewLine, gb.NewLine)
          iFound2 = ssLineDesktop.Find("*" & "Exec" & "*", gb.Like)
          If iFound2 > -1 Then 
            ssLinePart = Split(ssLineDesktop[iFound2] & "=", "=")
            sFoundProgram = Null
            If ssLinePart Then sFoundProgram = ssLinePart[1] 'Example: "Exec=firefox"
            ssLinePart = Split(sFoundProgram & Space(1), Space(1))
            If ssLinePart Then sFoundProgram = ssLinePart[0]
            If sFoundProgram Then 
              If String.InStr(sProgramNames, sFoundProgram) = 0 Then sProgramNames &= sFoundProgram & gb.NewLine 'not double
            Endif 
          Endif 
        Endif 
      Next 
    Endif 
  Endif 
  sProgramNames = String.LCase(sProgramNames) 'ABC>abc
  ssLinePart = Split(sProgramNames & gb.NewLine, gb.NewLine)
  If ssLinePart[0] Then sProgram1 = System.Find(ssLinePart[0]) Else sProgram1 = Null 'no file
  If ssLinePart[1] Then sProgram2 = System.Find(ssLinePart[1]) Else sProgram2 = Null
  
  ''Start program:
  If sProgram1 And sProgram2 = Null Then 
    Shell sProgram1 & Space(1) & sDirFile
  Else If sProgram1 = Null And sProgram2 Then 
    Shell sProgram2 & Space(1) & sDirFile
  Else If sProgram1 And sProgram2 Then 
    If String.InStr(sProgram1 & "," & sProgram2, "eog") > 0 Then sExtraInfo = "<br><br>" & ("eog = Bilder/Dokumente")
    sMessage = "<h4>" & Str(File.Dir(sDirFile) &/ File.BaseName(sDirFile)) & "." & "<font color=blue>" & File.Ext(sDirFile) & "</font></h4>"
    sMessage &= ("Programm auswählen") & sExtraInfo
    Select Case Message.Question(sMessage, ssLinePart[0], ssLinePart[1], ("Abbrechen"))  '[0,1,2,3]
      Case 0
        '...Text
      Case 1 
        Shell sProgram1 & Space(1) & sDirFile
        
      Case 2
        Shell sProgram2 & Space(1) & sDirFile
      Case 3
        '... Cancel
    End Select 
  Else If Exist(sDirFile) = True Then 
    Desktop.Open(sDirFile) 'start File-Typ with Standard-Program
  Endif 
  
  Return sProgramNames 
  
  'Examples: "/usr/share/applications/defaults.list" , "/etc/gnome/defaults.list", "/usr/share/applications/mimeinfo.cache"
  ' [Default Applications]
  ' application/csv=libreoffice-calc.desktop
  ' text/html=firefox.desktop
  ' image/gif=eog.desktop                               ''eog: Eye of GNOME graphics viewer program  
  ' audio/mp4=org.gnome.Totem.desktop
  
  ' Example in Clipboard.Formats = [text/plain, text/html, image/png, image/tiff, image/jpeg, application/x-qt-image, ...] '=> MIME-Type
  
Catch
  FMain.ErrorText
  
End

Public Function FileTypeProgramListNameExec(Optional sDirFile As String = "") As String 
  'Old version
  
  Dim hDesktopMime As DesktopMime
  Dim hDesktopFile As DesktopFile
  Dim sPrograms As String 
  'Gambas3: "...defined by the freedesktop standard"
  If Exist(sDirFile) = True Then 
    hDesktopMime = DesktopMime.FromFile(sDirFile)
    
    If hDesktopMime.GetApplications().Count Then
      For Each hDesktopFile In hDesktopMime.GetApplications()
        sPrograms &= hDesktopFile.Name & gb.NewLine
        sPrograms &= hDesktopFile.Exec & gb.NewLine
        ' imgIcon = hDesktopFile.GetIcon(32) & gb.NewLine
      Next
    Endif
  Endif 
  Return sPrograms 
  
Catch
  FMain.ErrorText
  
End

Public Function FileDesktopEntryLineRead(Optional sProgramName As String = "firefox", Optional sDesktopEntryLineValue As String = "MimeType=") As String
  
  Dim hDesktopFile As DesktopFile
  Dim sPath, sText, sLine, sFound As String 
  
  hDesktopFile = DesktopFile[sProgramName]  'Expample: "firefox" or Application.Name
  sPath = hDesktopFile.Path
  If Exist(sPath) = True Then 
    sText = File.Load(sPath)
    For Each sLine In Split(sText & gb.NewLine, gb.NewLine)
      Print sLine 
      If sLine Like "*" & sDesktopEntryLineValue & "*" Then 
        sFound = sLine 
        Break
      Endif
    Next
  Endif 
  
  Return sFound 
  
  'Example: sInfo = M01Functions.FileDesktopEntryLineRead() 'as String. Example: "MimeType=text/html;image/png;", "GenericName=WebBrowser", "Name=firefox", "Exec=...", ...
  
Catch
  FMain.ErrorText
  
End

Public Function FileGetMimeType(Optional sDirFile As String = "") As String 
  
  Dim hMime As DesktopMime
  ' Examples:
  ' /dir/file.txt  > "text/plain"       ' GenericIcon: "text-x-generic"
  ' /dir/file.png  > "image/png"
  hMime = DesktopMime.FromFile(sDirFile)
  Return hMime.Type
  
Catch
  FMain.ErrorText
  
End

Public Function FileGetMimeTypeImageIcon(Optional sDirFile As String = "", Optional iGetIconSize As Integer = 32) As Image 
  
  Dim hMime As DesktopMime
  ' Examples:
  ' /dir/file.txt  > "text/plain"       ' GenericIcon: "text-x-generic"
  ' /dir/file.png  > "image/png"
  hMime = DesktopMime.FromFile(sDirFile)
  Return hMime.GetIcon(iGetIconSize) 'as Image, in Pixel
  
Catch
  FMain.ErrorText
  
End

Public Function FileSizeText(Optional sDirFile As String) As String
  
  Dim sFileSize As String 
  Dim longSize As Long 
  
  If Exist(sDirFile) = True Then 
    longSize = Stat(sDirFile).Size
    If Component.IsLoaded("gb.util") = True Then 
      sFileSize = ("Datei-Größe") & ": " & File.FormatSize(longSize, False) & Space(5) & "(" & Format(longSize, "0,0") & Space(1) & "Bytes)"
    Else  
      'Format() This function uses localization information.
      sFileSize = ("Datei-Größe") & ": " & Format(longSize / 1024 / 1024, "#,##0.0") & Space(1) & ("MB") & "(" & Format(longSize, "#,##0") & Space(1) & "Bytes)" 'as String 
    Endif 
  Endif 
  
  Return sFileSize
  
  ''______________________________________________________________________________''
  '' Static Function FormatSize ( Size As Long [ , Binary As Boolean ] ) As String
  '' Binary False old (1K = 1024) KB, True  (1K = 1000) KiB
  '' File.FormatSize()  needs component  —▶ gb.util
Catch
  FMain.ErrorText
  
End

Public Function FileSizeLongText(Optional longSize As Long = 0) As String 
  
  Dim sFileSize As String 
  ' Dim longSize As Long 'for File
  
  ' If Exist(sDirFile) = True Then longSize = Stat(sDirFile).Size 'as Long
  
  If Component.IsLoaded("gb.util") = True Then 
    sFileSize = File.FormatSize(longSize, False) 
  Else  
    'Format() This function uses localization information.
    If longSize > 1000000 Then '1MiB
      sFileSize = Format(longSize / 1024 / 1024, "#,##0.0") & Space(1) & ("MB") 
    Else  
      sFileSize = Format(longSize, "#,##0") & Space(1) & ("Bytes") 'as String 
    Endif 
    'Kilobyte (KB) 10^3 Byte = 1 000 Byte
    'Megabyte (MB) 10^6 Byte = 1 000 000 Byte
    'Gigabyte (GB) 10^9 Byte = 1 000 000 000 Byte
  Endif 
  
  Return sFileSize
  
  ''______________________________________________________________________________''
  '' Static Function FormatSize ( Size As Long [ , Binary As Boolean ] ) As String
  '' Binary False old (1K = 1024) KB, True  (1K = 1000) KiB
  '' File.FormatSize()  needs component  —▶ gb.util
Catch
  FMain.ErrorText
  
End

Public Function FileSizeLongToText(Optional longSize As Long = 0) As String 
  
  Dim sSize As String 
  
  If Component.IsLoaded("gb.util") = True Then 
    sSize = File.FormatSize(longSize, False) 
  Else  
    'Format() This function uses localization information.
    'Dfree(sDir) 'as Long
    If longSize > 1000000 Then '1MiB
      sSize = Format(longSize / 1024 / 1024, "#,##0.0") & Space(1) & ("MB") 
    Else  
      sSize = Format(longSize, "#,##0") & Space(1) & ("Bytes") 'as String 
    Endif 
    'Kilobyte (KB) 10^3 Byte = 1 000 Byte
    'Megabyte (MB) 10^6 Byte = 1 000 000 Byte
    'Gigabyte (GB) 10^9 Byte = 1 000 000 000 Byte
  Endif 
  
  Return sSize
  
  ''______________________________________________________________________________''
  '' Static Function FormatSize ( Size As Long [ , Binary As Boolean ] ) As String
  '' Binary False old (1K = 1024) KB, True  (1K = 1000) KiB
  '' File.FormatSize()  needs component  —▶ gb.util
Catch
  FMain.ErrorText
  
End

Public Function SizePointComma(vSize As Variant) As String
  
  'Format() This function uses localization information.
  Return Format(vSize, "#,##0.0") ''1 MiB = 1.000.000 Bytes rounded     
  
  ''___________________________________________________________________________________________________________________''
  ''* old version "1 MB" > "1024 KB"  (2^10=2×2×2×2×2×2×2×2×2×2=1024) 2¹⁰ = 1024 KiB (Norm IEC, see Wikipedia "Bytes")
  ''Point and Comma: 123.456.789,00  0,12 Attention: english left "," <> "."
Catch
  FMain.ErrorText
  
End

Public Function FileSizeLong(Optional sDirFile As String = "") As Long
  
  Dim statInfo As Stat
  Dim longSize As Long
  
  If Exist(sDirFile) = True Then
    statInfo = Stat(sDirFile)
    longSize = statInfo.Size 'as Long
  Endif
  Return longSize 'as Long
  
Catch 
  FMain.ErrorText
  
End

Public Function FileSizeMByteText(Optional sDirFile As String = "") As String 
  
  Dim statInfo As Stat
  Dim longSize As Long
  Dim sFileSize As String 
  
  If Exist(sDirFile) = True Then
    statInfo = Stat(sDirFile)
    longSize = statInfo.Size / 1024 / 1024 'as Long
    sFileSize = Format(longSize, "#,##0.0") 'rundet auf und setzt 1.000-Punkt, wenn darüber
  Endif
  Return sFileSize 'as String 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileLastModifiedTimeSize(Optional sDirFile As String = "") As String 
  
  Dim statInfo As Stat
  Dim sFileInfos, sSep As String
  
  sSep = Space(1) 'Separator, Trennzeichen 
  
  If Exist(sDirFile) = True Then
    statInfo = Stat(sDirFile)
    ''Note: .FormatSize needs component: (gb.util)
    sFileInfos = sDirFile & sSep & Format(statInfo.LastModified, "ddd dd.mm.yyyy hh:nn") & sSep & File.FormatSize(statInfo.Size, False) 'Format(statIinfo.Size, "#,###") & "" & "Bytes"
  Endif
  Return sFileInfos 'Rückgabe Dateiinfos oder ""
  
Catch 
  FMain.ErrorText
  
End

Public Function FileAuslagernVergangene(Optional sDirFile As String = "") As String
  
  Dim sTextA, sTextB, sDirFileA, sDirFileB As String
  Dim statInfo, statInfo2, statInfo2b As Stat
  Dim lGroesse, lGroesse2, lGroesse2b As Long
  Dim sDir, sFileBase, sExt As String 
  
  If Exist(sDirFile) = True Then 
    sDirFileA = sDirFile
    sDir = File.Dir(sDirFileA) '/Ordner
    sFileBase = File.BaseName(sDirFileA) 'Datei
    sExt = File.Ext(sDirFileA) ' "txt"
    
    sDirFileB = sDir &/ sFileBase & ("_oldyears.") & sExt '_oldyears
    
    statInfo = Stat(sDirFileA)
    lGroesse = statInfo.Size 'long
    If Exist(sDirFileB) = True Then
      statInfo2 = Stat(sDirFileB) 'prüfen, Fehler vermeiden
      lGroesse2 = statInfo2.Size
    Endif
    
    If lGroesse > 100000 Then '1MB 1.000.000
      sTextA = File.Load(sDirFileA)
      If sTextA <> "" Then
        If Exist(sDirFileB) = True Then Try sTextB = File.Load(sDirFileB)
        sDirFileB = M01Functions.FileTextPlus(sDirFileB, sTextA & sTextB, False) 'auslagern
        If Exist(sDirFileB) = True Then
          statInfo2b = Stat(sDirFileB) 'prüfen, Fehler vermeiden
          lGroesse2b = statInfo2b.Size
        Endif
      Endif
      If Exist(sDirFileB) = True And lGroesse2 < lGroesse2b Then 'ausgelagert?
        M01Functions.FileTextPlus(sDirFileA, "", True) 'Originaldatei leeren
      Endif
    Else
      sDirFileB = ""
    Endif
  Endif 
  
  Return sDirFileB 'Path or Null. Rückgabe wenn ausgelagert.
  
Catch 
  FMain.ErrorText
  
End

Public Function DirectoryFreeBytesLong(Optional sDirectory As String = "/") As Long
  
  'Dim longSize As Long
  'Größe = DFree ( Pfad )
  'Gibt den freien Speicherplatz(IN Bytes)des Geräts an, auf dem sich der Pfad befindet. 
  'PRINT Dfree("/")
  '5112569856
  'PRINT Dfree("/home")
  '454918144
  
  Return Dfree(sDirectory) ' Rückgabe as Long, Integer—▶longer 
  
Catch 
  FMain.ErrorText
  
End

Public Function ExternCalculator() As Boolean
  
  Dim bExist As Boolean
  Dim it As Integer
  Dim ssProgram As String[]
  
  ssProgram = New String[]
  ssProgram.Add("gnome-calculator")   'Ubunutu
  
  ssProgram.Add("gcalctool")  'Ubuntu12 old
  ssProgram.Add("kcalc") 'Kubuntu
  ssProgram.Add("galculator") 'Lubuntu
  ssProgram.Add("deepin-calculator")
  ssProgram.Add("mate-calc")
  ssProgram.Add("speedcrunch")
  ssProgram.Add("qalculate-gtk")
  ssProgram.Add("genius")
  
  For it = 0 To ssProgram.Max
    If System.Exist(ssProgram[it]) = True Then 
      bExist = True 
      ''Found and start program:
      Exec [ssProgram[it]] 'Wait   'Wait Terminwecker wartet und dunkelt ab
      'Shell (ssProgram[it]) 'alternative Startweise
      Break 
    Endif
  Next
  'If bExist = False Then Message.Info(("calculator") & gb.NewLine & ("Nicht installiert?"))
  
  Return bExist ' Rückgabe true oder false
  
Catch 
  FMain.ErrorText
  
End

Public Function ExternTrash() As Boolean
  
  Dim bExist As Boolean
  Dim sProgram1, sProgram2, sSep As String
  Dim sTrash As String
  
  sSep = Space(1) ' Separator, ein Leerzeichen als Trennung
  sProgram1 = "nautilus" 'Dateierwaltung Ubuntu
  sProgram2 = "pcmanfm" 'Dateierwaltung Lubuntu
  sTrash = "trash:/" 'Mülleimer   Leerzeichen beachten zwischen Programm und sValue: "nautilus trash:/"
  'Shell sTrash & " trash:/" 'Mülleimer
  'COPY Kopie TO "trash:/" & Kopie
  
  If System.Exist(sProgram1) = True Then 
    bExist = True 
    'Exec[Programm & Komma & Optionen] 'getrennt mit Kommata, anders bei Shell Programm & Leerzeichen & Optionen 
    ' Exec [sProgram1] 'Wait   'Wait Terminwecker wartet und dunkelt ab
    Shell sProgram1 & sSep & sTrash 'alternative Startweise
  Else If System.Exist(sProgram2) = True Then 
    bExist = True
    'Exec [sProgram2 & sTrash] 'Wait
    Shell sProgram2 & sSep & sTrash 'alternative Startweise
    'Else If System.Exist(Progr3) = True Then 
    'bExist = True
    'Exec [Progr3] 'Wait
    'Else If System.Exist(Progr4) = True Then 
    'bExist = True
    'Exec [Progr4] 'Wait
  Else 
    Try Desktop.Open(User.Home) 'Dateiverwaltung, Papierkorb im Menü
    If Not Error Then bExist = True
  Endif
  'If bExist = False Then Message.Info(("trash") & gb.NewLine & ("Nicht installiert?"))
  Return bExist ' Rückgabe true oder false
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExternStart(Optional sProgramName As String = "", Optional sDirFile_OrText As String = "")
  
  Dim sSep As String 
  
  sSep = Space(1) ' Separator, ein Leerzeichen als Trennung
  'Example:  M01Functions.ExternStart("gedit", "/dir/file.txt")
  sProgramName = Trim(sProgramName) 
  sProgramName = Replace(sProgramName, sSep, "") 'Leerstellen entfernen, sind Trenner/Separator
  sProgramName = String.LCase(sProgramName) 'Bei Pfad klein/GROSSschreibung beachten
  If sProgramName = "browser" Then sProgramName = "firefox"
  
  If sProgramName And System.Exist(sProgramName) = True Then 
    If Exist(sProgramName) = False Then sProgramName = System.Find(sProgramName)
    Shell sProgramName & sSep & Quote(sDirFile_OrText) Wait 'startet Programm mit Dateipfad oder Text einfügen
  Else If Exist(sDirFile_OrText) = True Then 
    Desktop.Open(sDirFile_OrText) 'Projekt>Eigenschaften>Komponenten. Die Komponente gb.Desktop muß hinzugfügt sein. 
    'Desktop.Open(Url As String, Wait As Boolean)   
    'Desktop.Open(OrdnerDatei)
  Else 
    ExternStartAlternative(sProgramName, sDirFile_OrText) ''Example: "gnome-control-center", "info"
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileManagerOpen(Optional sDirFile As String = "") As String 
  
  Dim sProgram As String
  Dim sSep As String 
  
  sSep = Space(1) ' Separator, ein Leerzeichen als Trennung
  
  ''Note: no space(1) in sDirFile. Space(1) is Separator in Shell "nautilus" & Space(1) & sDirFile
  
  sProgram = System.Find("nautilus") '(*1)
  
  If Exist(sProgram) = True And Exist(sDirFile) = True Then 
    Try Shell sProgram & sSep & Quote(sDirFile) 
  Else 
    Try Desktop.Open(File.Dir(sDirFile))
  Endif 
  
  If Error Then 'Error = True
    sDirFile = ""
  Else 
    If Exist(sDirFile) = False Then sDirFile = "" 'NULL
  Endif 
  
  Return sDirFile
  ''_________________________________________________________________''
  ' (*1) "nautilus -s", --select,  -w, --new-window
  ' https://manpages.ubuntu.com/manpages/focal/man1/nautilus.1.html
  ' Example: /Directo ry/Fil e.ext, Quote—▶ "/Directo ry/File e.ext"
  
Catch
  FMain.ErrorText
  
End

Public Sub ResetForm(Optional sFormName As String = "")
  
  Dim sMessage, sText, sDir, sFile, sDirFile, sKey As String 
  Dim iCount As Integer
  
  For Each sKey In Settings.Keys[sFormName]
    sText &= sFormName &/ sKey & "=" & Settings.ToString(Settings[sFormName &/ sKey]) & gb.NewLine
  Next
  
  iCount = Settings.Keys[sFormName].Count
  sMessage = "<h3><font color=blue>" & ("Nur für diese Seite") & ":" & "</font></h3>"
  sMessage &= "<h3><font color=red>" & "○ " & ("Einstellungen zurücksetzen (Reset)") & "</font></h3>"
  sMessage &= "<h3><font color=gray>" & ("Nach Neustart = Standard-Werte") & "</font></h3>"
  sMessage &= "<font color=gray>" & "● " & ("Öffnen") & ": " & "</font><br>"
  sMessage &= "<font color=gray>" & ("Anzahl") & ": " & iCount & "</font><br>"
  sMessage &= "<font color=gray>" & String.Left(sText, 200) & "..." & "</font><br>"
  
  Select Case Message.Question(sMessage, "○ " & ("Zurücksetzen (Reset)"), "● " & ("Öffnen..."), ("Abbrechen"))
    Case 1
      If sFormName Then Settings.Clear(sFormName)
    Case 2
      sText = ("Einstellungen Settings[...] = Null (Reset=Standard)") & gb.NewLine & gb.NewLine & sText 
      If Form3Text.Visible = True Then 
        sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] 
        sFile = sFormName & "-" & "settings.txt"
        sDirFile = sDir &/ sFile
        If IsDir(sDir) = True Then File.Save(sDirFile, sText)
        Desktop.Open(sDirFile)
      Else 
        Form3Text.Tag = sText
        Form3Text.Show
        Form3Text.Visible = True 
      Endif  
    Case 3
      '...
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Function FileRootToTemp(Optional sDirFile As String = "") As String 
  
  Dim sFile, sDirFileTemp As String 
  
  If Exist(sDirFile) = True Then 
    sFile = File.Name(sDirFile)
    ' sDirFileTemp = File.Dir(Temp()) &/ sFile ' /temp/gambas1000/.../     Programm-Close = delete File
    sDirFileTemp = M01Functions.CheckDirectoryCache() &/ sFile
    If Exist(sDirFileTemp) = True Then Try Kill sDirFileTemp
    Try Copy sDirFile To sDirFileTemp
    If Exist(sDirFileTemp) = True Then sDirFile = sDirFileTemp
  Endif 
  
  Return sDirFile
  
  ''_______________________________________________________________________''
  'In Root /usr/... no Access for other programs (Desktop.Open(File)), only about internally gambas3?   
  
Catch
  FMain.ErrorText
  
End

Public Function ExternStandardBrowserIcon(Optional iIconSize As Integer = 32) As Picture
  
  ' Dim hTest As DesktopFile[]
  ' Dim it As Integer
  ' Dim ssTypes As String[]
  Dim sPath As String 
  Dim sProgram As String
  Dim picIcon As Picture
  
  sProgram = Settings[FMain.Name &/ "F_sBrowserHTMLonlyName", "firefox"]
  sPath = System.Find(sProgram)
  If Exist(sPath) = True Then picIcon = M01Functions.ExternStandardProgramIconPicture(sProgram, iIconSize) '(sName, iIconSize)
  If Not picIcon Then picIcon = Picture.Load("images/internet_32.png") 'Standard 
  
  ' sProgram = M01Functions.ExternStandardProgramName("text/html")
  ' If Exist(sPath) = True Then ' "firefox" Standard-Browser in Ubuntu
  '   picIcon = M01Functions.ExternStandardProgramIconPicture(sProgram, 32) 'as Picture. (sName, iIconSize)
  ' Endif 
  
  ''Browser-Program:
  ' If sProgram = "firefox" Then 
  '   sPath = System.Find(sProgram) 'as String 
  '   If Exist(sPath) = True Then 
  '     ' picIcon = M01Functions.ExternStandardProgramIconPicture(sProgram, 32) 'as Picture
  '     If Not picIcon Then 
  '       sPath = "/usr/share/icons/hicolor/32x32/apps/firefox.png" '16x16/32x32/48x48/64x64/128x128 Pixel
  '       If Exist(sPath) = False Then sPath = "/lib/firefox/browser/chrome/icons/default/default32.png" '16/32/48/64/128 Pixel
  '       If Exist(sPath) = True Then picIcon = Picture.Load(sPath)
  '     Endif 
  '   Endif
  ' Endif 
  
  ''Alternative:
  ' If Not picIcon Then 
  '   hTest = DesktopFile.FromMime("text/html") ' FileName.Desktop Icons in Start-Screen, Desktop (Schreibtisch)
  '   For it = 0 To hTest.Max
  '     ssTypes = hTest[it].MimeTypes 'as String[]
  '     If ssTypes.Find("text/html") > -1 And String.LCase(hTest[it].Comment) Like "*web*" Then  
  '       picIcon = hTest[it].GetIcon(32).Picture ' (size in Pixel)
  '       If picIcon Then 
  '         sProgram = hTest[it].ProgramName
  '         Settings[FMain.Name &/ "F_sBrowserHTMLonlyName"] = sProgram
  '         Break
  '       Endif 
  '     Endif 
  '   Next
  ' Endif 
  
  ' If Not picIcon Then picIcon = Picture["images/internet_32.png"]
  
  Return picIcon
  ''________________________________________________________________''
  ' /usr/share/applications/defaults.list
  ' text/html=firefox.desktop
  ' text/plain=org.gnome.gedit.desktop
  
  ' Example:
  ' /usr/share/applications/libreoffice-startcenter.desktop
  ' /usr/share/applications/libreoffice-writer.desktop
  ' /usr/share/applications/bluefish.desktop
  ' /usr/share/applications/org.gnome.gedit.desktop
  
  ' Icons:
  ' /usr/share/icons/hicolor/32x32/apps/firefox.png '16x16/32x32/48x48/64x64/128x128 Pixel
  
  'others:
  '/home/user/.config/mimeapps.list
  '/home/user/.config/gtk-3.0/bookmarks
  '/home/user/.local/share/gnome-shell/application_state
  
Catch 
  FMain.ErrorText
  
End

Public Function ExternStandardProgramName(Optional sMimeTypeFileExt As String = "image/png") As String
  
  Dim sPath, sValue, sProgramName As String 
  Dim ssSpli As String[]
  
  sPath = System.Find("xdg-mime")
  If Exist(sPath) = True Then 
    ' Shell "xdg-mime query default image/png" To sValue 'Default (Voreinstellung, bevorzugte Programme), Type "image/" or "/" search
    Shell "xdg-mime query default " & sMimeTypeFileExt To sValue  
    If sValue Then 
      ssSpli = Split(sValue & gb.NewLine, gb.NewLine)
      sProgramName = ssSpli[0]
      sProgramName = Replace(String.LCase(sProgramName), ".desktop", "")
    Endif 
  Endif 
  
  Return sProgramName 'only name Example: "firefox"
  
  'Examples: 
  '     application/graphql
  '     application/javascript
  '     application/json
  '     application/ld+json
  '     application/msword (.doc)
  '     application/pdf
  '     application/sql
  '     application/vnd.api+json
  '     application/vnd.ms-excel (.xls)
  '     application/vnd.ms-powerpoint (.ppt)
  '     application/vnd.oasis.opendocument.text (.odt)
  '     application/vnd.openxmlformats-officedocument.presentationml.presentation (.pptx)
  '     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx)
  '     application/vnd.openxmlformats-officedocument.wordprocessingml.document (.docx)
  '     application/x-www-form-urlencoded
  '     application/xml
  '     application/zip
  '     application/zstd (.zst)
  '     audio/mpeg
  '     audio/ogg
  '     image/gif
  '     image/jpeg
  '     image/png
  '     multipart/form-data
  '     text/css
  '     text/csv
  '     text/html
  '     text/php
  '     text/plain
  '     text/xml
  '     ...
  ''________________________________________________________________''
  '*(1) Quelle: https://de.wikipedia.org/wiki/Internet_Media_Type
  
Catch
  FMain.ErrorText
  
End

Public Function ExternStandardProgramIconPicture(Optional sProgramName As String = "firefox", Optional iIconSize As Integer = 32) As Picture
  
  Dim sPath As String 
  Dim picIcon As Picture
  
  sPath = "/usr/share/icons/hicolor/" & Str(iIconSize & "x" & iIconSize) &/ "apps" &/ sProgramName & ".png" 
  If iIconSize <> 32 And Exist(sPath) = False Then 
    iIconSize = 32
    sPath = "/usr/share/icons/hicolor/" & Str(iIconSize & "x" & iIconSize) &/ "apps" &/ sProgramName & ".png" 
  Endif 
  If Exist(sPath) = True Then Try picIcon = Picture.Load(sPath)
  
  If Not picIcon Then 
    picIcon = Picture.Load("images/internet_32.png")
    If Not picIcon Then 
      sPath = System.Find(sProgramName)
      picIcon = Desktop.GetFileIcon(sPath, iIconSize) 'as Picture
    Endif 
  Endif 
  
  ''Check size:
  If picIcon Then 
    If picIcon.W <> iIconSize Then picIcon = picIcon.Image.Stretch(iIconSize, iIconSize).Picture
  Endif 
  
  Return picIcon 
  
Catch
  FMain.ErrorText
  
End

Public Sub ExternStartAlternative(Optional sProgramName As String = "", Optional sDirFile_OrText As String = "")
  
  Dim sFound, sFoundOption, sSep As String
  Dim ssProgramText, ssProgramFileManager, ssProgramPicture, ssProgramBrowser, ssProgramGnome As New String[] 'mit New
  Dim it, iProgramTyp As Integer
  Dim bExist As Boolean
  
  sDirFile_OrText = Quote(sDirFile_OrText) ' "a bc"
  sSep = Space(1) 'Separator, Trennzeichen
  '/usr/share/applications/bamf-2.index     'Liste der Programme und Kürzel
  '/usr/share/applications/defaults.list > Verknüpfungsziel: /etc/gnome/defaults.list
  'xxx.Add("abc", 0) 'Text, Position als Integer. Ohne Position wird autom. hinter letztem Feld angehängt.
  'xxx.Max '.count-1, also 2 Daten=|0|1|= count = 1
  'Beispiel Bildprogramm. Aufruf mit M01Functions.ExternStart("gimp", Datei)
  'SHELL "gedit" 'startet Ubuntu-Programm   Kleinschreibung beachten
  'SHELL "nautilus"
  '[Process = ] SHELL Command[ WAIT ][ FOR {  { READ | INPUT } | { WRITE | OUTPUT } } ] [ AS Name ]
  'SHELL Command TO Variable
  '[Process = ] EXEC Command[ WAIT ][ FOR {  { READ | INPUT } | { WRITE | OUTPUT } } ] [ AS Name ]
  'EXEC Command TO Variable
  'SHELL "gedit" 
  'DIM Variable_1, Variable_2 AS Variant
  'Variable_2 = sText
  'Variable_1 = " echo '" & Variable_2 & "' | gedit"
  'SHELL Variable_1 'startet Programm und fügt Text ein
  'M01Functions.ExternStart("gcalctool") 'gcalctool 'Taschenrechner
  'M01Functions.ExternStart("gucharmap") 'Sonderzeichen, Zeichentabelle
  'M01Functions.ExternStart("gnome-characters") 'Sonderzeichen, Zeichentabelle
  'M01Functions.ExternStart("gnome-search-tool") 'Suche im PC
  'M01Functions.ExternStart("baobab") 'Festplattenbelegung
  'M01Functions.ExternStart("gnome-control-center deja-dup") 'Datensicherung
  'M01Functions.ExternStart("gnome-control-center datetime") 'Zeit und Datum
  '/usr/share/applications
  '/etc/gnome/defaults.list
  'gcalctool 'Taschenrechner
  'gnome-session-properties 'Startprogramme
  'gnome-control-center --overview 'Systemeinstellungen
  'gnome-control-center indicator-datetime  'Zeit und Datum
  'gnome-control-center deja-dup 'Datensicherung
  'gnome-search-tool ' Suche im PC
  'gnome-calculator  'Taschenrechner im Betriebssystem
  'gucharmap   'Sonderzeichen in Dokumente einfügen
  'baobab 'Festplattenbelegung
  'deja-dup-preferences  'Datensicherung Einstellungen ändern
  'unity-control-center deja-dup 'Ihre Datensicherungseinstellungen ändern
  'nautilus --new-window   'Den persönlichen Ordner öffnen
  'unity-control-center --overview  'Einstellungen Betriebssystem
  'unity-control-center datetime ' Datum und Zeit, Einstellungen im Betriebssystem
  
  'Aufruf: exo-open [Adressen …]
  'exo - Open - - launch TYP[PARAMETER …]
  '- - launch TYP[PARAMETER …]         Die bevorzugte Anwendung für den TYP
  'mit den optionalen PARAMETERn starten,
  'wobei TYP einen der folgenden Werte
  'annehmen kann.
  '- - working - directory VERZEICHNIS Arbeitsverzeichnis f ür Anwendungen, die
  'mit - - launch gestartet werden.
  'Die folgenden TYPen für --launch werden derzeit unterstützt:
  'WebBrowser - Der bevorzugte Internetbrowser.
  'MailReader - Das bevorzugte E - Mail - Programm.
  'FileManager - Die bevorzugte Dateiverwaltung.
  'TerminalEmulator - Das bevorzugte Terminal.
  'Falls Sie die --launch - Option nicht angeben, wird exo-Open alle angegebenen
  'Adressen mit Ihrem bevorzugten Programm öffnen. Ansonsten können Sie auswählen,
  'welche bevorzugte Anwendung Sie starten wollen, und können dieser dann
  'zusätzliche Parameter übergeben (z.B. kann man bei TerminalEmulator den
  'Befehl angeben, der im Terminal ausgeführt werden soll).
  'Beispiel Aufruf: shell "exo-open --launch WebBrowser /home/USER/terminwecker/terminwecker.txt.html" 'Leerzeichen als Trenner!
  'Beispiel Aufruf: shell "exo-open /home/USER/terminwecker/terminwecker.txt" ' bevorzugtes Editor- oder Officeprogramm
  'Beispiel Aufruf: shell "exo-open /home/USER/terminwecker/terminwecker.html" ' bevorzugter Internet-Browser
  'Alternativen: gnome-open, kde-open, exo-open, xdg-open usw. 
  '"xdg-settings" - Auslesen und Setzen von Standard - Webbrowser und URI - Handlern
  sProgramName = String.LCase(sProgramName) 'kleinschreibung
  
  If String.InStr("edit,editor,office,libreoffice,txt,text,csv,rtf,odt,tab", sProgramName) > 0 Then 'Text-Editor
    iProgramTyp = 1
  Else If String.InStr("nautilus,filemanager,file,directory,dir,folder,path", sProgramName) > 0 Then 'File-Manager
    iProgramTyp = 2
  Else If String.InStr("gimp,paint,png,jpg,picture,image", sProgramName) > 0 Then 'Picture
    iProgramTyp = 3
  Else If String.InStr("firefox,browser,html,web", sProgramName) > 0 Then 'Browser
    iProgramTyp = 4
  Else If String.InStr("gnome,system,unity,settings,info,properties,program,app", sProgramName) > 0 Then 'Program-System
    iProgramTyp = 5
  Else 
    iProgramTyp = 6 'Standard-Progams
  Endif 
  
  bExist = False
  
  Select Case iProgramTyp 'integer
    Case 1 'gedit > Alternative 'Text: .........................................................
      ' If Exist(sDirFile_OrText) = True Then ssProgramText.Add("exo-open") 'bevorzugtes Standard-Programm
      ssProgramText.Add("gedit") 'Standardeditor in Ubuntu. GNOME Ubuntu
      ssProgramText.Add("leafpad") 'LXDE Xfce Lubuntu
      ssProgramText.Add("kate") 'Texteditor KDE  Kubuntu
      ssProgramText.Add("mousepad") 'Xfce Xubuntu
      ssProgramText.Add("pluma") 'MATE Ubuntu MATE
      ssProgramText.Add("libreoffice") 'verschiedene Endungen 
      ssProgramText.Add("libreoffice-calc") '"text/csc", "text/tab"
      ssProgramText.Add("soffice") 'soffice=libreoffice
      ssProgramText.Add("abiword") ' Textprogramm, Office
      
      For it = 0 To ssProgramText.Max
        sFound = ssProgramText[it]
        bExist = System.Exist(sFound)
        If bExist = True Then Break 'Break springt aus der Schleife heraus
      Next
      'Alternative: 
      'Shell "update-alternatives --list x-www-browser" To sFound 
      'Example: /usr/bin/firefox und andere Browser
      
    Case 2 'nautilus > Alternative 'Dateiverwaltung: .........................................................
      ' If Exist(sDirFile_OrText) = True Then ssProgramFileManager.Add("exo-open") 'bevorzugtes Standard-Programm
      ssProgramFileManager.Add("nautilus") 'Dateiverwaltung Ubuntu GNOME, Papierkorb "nautilus " & sValue="trash:/"
      ssProgramFileManager.Add("pcmanfm") 'Dateierwaltung Lubuntu, LXDE und LXQt
      ssProgramFileManager.Add("dolphin") 'Dateiverwaltung KDE Kubuntu
      ssProgramFileManager.Add("caja") 'Dateiverwaltung MATE
      ssProgramFileManager.Add("nemo") 'Dateiverwaltung Ubuntu Budgie, Unity, Cinnamon
      ssProgramFileManager.Add("thunar") 'Dateiverwaltung Ubuntu Xfce
      
      'sValue = "pcmanfm trash:/"   'Papierkorb Lubuntu
      For it = 0 To ssProgramFileManager.Max
        sFound = ssProgramFileManager[it]
        bExist = System.Exist(sFound)
        If bExist = True Then Break 'Break springt aus der Schleife heraus
      Next
      ' If sFound = "exo-open" Then sFoundOption = "--launch FileManager" 'bevorzugtes Programm Dateiverwaltung
      
    Case 3 'gimp > Alternative 'Bildbearbeitung: .........................................................
      ' If Exist(sDirFile_OrText) = True Then ssProgramPicture.Add("exo-open") 'bevorzugtes Standard-Programm
      ssProgramPicture.Add("gimp") 'Bildbearbeitungsprogramm
      ssProgramPicture.Add("pinta") 'Bildbearbeitungsprogramm
      ssProgramPicture.Add("kolourpaint4") 'einfaches Bildbearbeitungsprogramm, KDE
      ssProgramPicture.Add("krita") 'Bildbearbeitungsprogramm, Mal- bzw. Zeichenprogramm
      ssProgramPicture.Add("mtpaint") 'kleines Bildbearbeitungsprogramm, GTK+, Pixel, Icons, animierte GIF-Dateien extra
      ssProgramPicture.Add("tuxpaint") 'Bildbearbeitungsprogramm, Malprogramm für Kinder zwischen 3 und 12 Jahre
      ssProgramPicture.Add("eog") 'Bildbetrachter, Eye of GNOME, in Ubuntu und Ubuntu GNOME vorinstalliert.
      ssProgramPicture.Add("eom") 'Bildbetrachter, Eye of MATE, in Ubuntu MATE vorinstalliert.
      ssProgramPicture.Add("f-spot") 'Bild-Verwaltung. Nachfolger: shotwell
      ssProgramPicture.Add("shotwell") 'Ubuntu Standardprogramm Bild-Verwaltung, ersetzt F-Spot.
      For it = 0 To ssProgramPicture.Max
        sFound = ssProgramPicture[it]
        bExist = System.Exist(sFound)
        If bExist = True Then Break 'Break springt aus der Schleife heraus
      Next
      
    Case 4, 0 'firefox > Alternative 'Internet-Browser: .........................................................
      ' Webbrowser:
      '     Chromium - Open-Source-Browser aus dem Google-Umfeld
      '     Epiphany - der Browser von GNOME
      '     Firefox - alles über den Standardbrowser von Ubuntu
      '     Konqueror - den KDE-Browser Konqueror nutzen und konfigurieren
      '     Lariza - minimalistischer Browser auf GTK - und WebKit-Basis
      '     NetSurf - minimalistischer Browser mit JavaScript und PDF-Unterstützung
      '     Opera - vielseitiger Browser, der inzwischen auf Chromium basiert
      '     Pale Moon - Abspaltung von Firefox
      '     Basilisk-Browser - Abspaltung von Firefox
      '     QupZilla - schlanker Browser auf Qt- und WebKit-Basis
      '     SeaMonkey - die SeaMonkey-Suite installieren und einrichten
      '     Slimjet - auf Chromium basierender Browser mit fest eingebautem Werbeblocker
      '     Vivaldi - schlanker Browser auf Blink-Basis
      '     IceCat - Fork des Firefox ESR Browsers, der ausschließlich freie Komponenten verwendet
      ' 
      ' minimalistische und textbasierte Browser:
      '     Dillo - ein minimalistischer grafischer Webbrowser
      '     ELinks - Kommandozeilenbrowser mit umfangreicher HTML- und Protokollunterstützung sowie grafischer Oberfläche
      '     links2 - ein Browser für die Kommandozeile mit grafischer Oberfläche
      '     Lynx - ein Browser für die Kommandozeile
      '     w3m - ein weiterer Browser für die Kommandozeile
      '________________________________________________________________________________
      ' (*1) Quelle Year2020: https://wiki.ubuntuusers.de/Internetanwendungen/
      
      ' If Exist(sDirFile_OrText) = True Then ssProgramBrowser.Add("exo-open") 'bevorzugtes Standard-Programm
      ssProgramBrowser.Add("xdg-settings") ' debian: "Auslesen und Setzen von Standard - Webbrowser und URI - Handlern"
      ssProgramBrowser.Add("firefox") 'Browser in Ubuntu u.a., "firefox " & "www.design-cad.de"
      ssProgramBrowser.Add("firefox-portable") 'wie auf USB-Sticks. Mozilla, Netscape (ab 1994), Firefox...
      ssProgramBrowser.Add("epiphany") '"epiphany-browser" Gnome
      ssProgramBrowser.Add("opera") 'ab Opera12 auf Chromium wie Firefox
      ssProgramBrowser.Add("vivaldi") 'Variante von Opera
      ssProgramBrowser.Add("konqueror") 'Standard in Betriebssystem KDE, mit Werbefilter
      ssProgramBrowser.Add("midori") 'Browser
      ssProgramBrowser.Add("dillo") 'minimalistischer Browser
      ssProgramBrowser.Add("gupzilla") ' schlanker Browser, Qt
      ssProgramBrowser.Add("rekonq") 'KDE, Kubuntu, mit Werbefilter
      ssProgramBrowser.Add("arora") 'einfacher Browser, Qt, Entwicklung bis 2011
      ssProgramBrowser.Add("slimjet") ' auf Chromium basierender Browser mit fest eingebautem Werbeblocker (*1)
      ssProgramBrowser.Add("lariza") ' minimalistischer Browser auf GTK - und WebKit-Basis (*1)
      ssProgramBrowser.Add("chromium") '"chromium-browser" von firefox ersetzt. '"chromium" (also supported as "chromium-browser"), 
      ssProgramBrowser.Add("chrome") '"google-chrome"(also supported As "chrome")
      ssProgramBrowser.Add("icecat") ' Fork des Firefox ESR Browsers, der ausschließlich freie Komponenten verwendet (*1)
      ssProgramBrowser.Add("iceweasel") '"https://manpages.ubuntu.com/manpages/precise/en/man1/git-web--browse.1.html"
      ssProgramBrowser.Add("seamonkey") 'auch als "portable", Programm-Sammlung, Weiterentwicklung aus Mozilla mit Webbrowser, E-Mail-Programm, Chat-Client, HTML-Editor, Adressbuch und weiteren Hilfsprogrammen. Umbenennung in "Iceape", "ice"&ProgramName (wikipedia)
      ssProgramBrowser.Add("exo-open") 'bevorzugtes Programm " --launch webbrowser"
      ssProgramBrowser.Add("xdg-open") '"xdg-open" & Space(1) & FileOrURL
      ssProgramBrowser.Add("gnome-open") '"gnome-open" & Space(1) & FileOrURL
      ' ssProgramBrowser.Add("exo-open --launch WebBrowser") 'exo-open --launch WebBrowser 'Internetnavigator. Bevorzugtes Programm.
      ' ssProgramBrowser.Add("webbrowser-app") 'einfacher Browser in  Ubuntu, bereits vorinstalliert, Fehlerhaft?
      
      'Beispiel Aufruf: Shell "exo-open --launch WebBrowser /home/USER/terminwecker/terminwecker.txt.html" 'Leerzeichen als Trenner!
      'Beispiel Aufruf: shell "exo-open /home/USER/terminwecker/terminwecker.txt" ' bevorzugtes Editor- oder Officeprogramm
      'Beispiel Aufruf: shell "exo-open /home/USER/terminwecker/terminwecker.html" ' bevorzugter Internet-Browser
      For it = 0 To ssProgramBrowser.Max
        sFound = ssProgramBrowser[it]
        bExist = System.Exist(sFound)
        If bExist = True Then Break 'Break springt aus der Schleife heraus
      Next
      ' If sFound = "exo-open" Then sFoundOption = "--launch WebBrowser" 'bevorzugtes Programm
      'Desktop.Open(Url As String, Wait As Boolean)   
      'Desktop.Open(OrdnerDatei)
      
    Case 5 'Gnome apps
      ssProgramGnome.Add("gnome-control-center info") ' "info" Betriebssystem Info
      ssProgramGnome.Add("gnome-control-center info-overview") ' "info" Betriebssystem, View information about your system
      ssProgramGnome.Add("gnome-control-center datetime") ' "datetime" Zeit und Datum
      ssProgramGnome.Add("gnome-control-center deja-dup") ' "deja-dup" Datensicherung
      ssProgramGnome.Add("gnome-control-center default-apps") ' "default-apps" Standardprogramme, Configure Default Applications, Voreinstellungen, bevorzugte Programme
      ssProgramGnome.Add("gnome-search-tool") 'Suche im PC
      ssProgramGnome.Add("gnome-session-properties") 'Startprogramme, Startup Applications
      ssProgramGnome.Add("gnome-characters") 'Sonderzeichen, Smileys :-)...
      ssProgramGnome.Add("unity-control-center")  'Ubuntu unity system, new: gnome
      it = ssProgramGnome.Find(sProgramName)
      If it > -1 Then sFound = ssProgramGnome[it] 
      it = ssProgramGnome.Find(sDirFile_OrText)
      If it > -1 Then sFound = ssProgramGnome[it] 
      If sFound Then bExist = System.Exist(sFound)
      
    Case 6 'Standard, Default-Programs (bevorzugte Programme)
      If System.Exist("exo-open") = True Then 
        sProgramName = "exo-open"
        bExist = True
      Else If System.Exist("xdg-open") = True Then 
        sProgramName = "xdg-open"
        bExist = True
      Else If System.Exist("gnome-open") = True Then 
        sProgramName = "gnome-open"
        bExist = True
      Else If System.Exist("kde-open") = True Then 
        sProgramName = "kde-open"
        bExist = True
      Else 
        sProgramName = "" '—▶ Desktop.Open(Path)
        bExist = False
      Endif 
      
  End Select 'iProgramTyp.........................................................
  
  'Shell "firefox https://www.tagesschau.de/"  'startet Browser mit Seite
  'Shell "firefox file://" & System.User.Home &/ "terminwecker/terminwecker.txt.html#heute" ' Eingabe wie in Browser-Adresszeile
  'Shell "gedit " & System.User.Home &/ "terminwecker/terminwecker.txt.html" ' Datei mit Endung muß vorhanden sein
  sProgramName = sFound
  If bExist = True Then 'ExternStart(sFound, sDirFile_OrText) ' zurück mit alternativem Programm
    ' If String.Right(sProgramName, 1) <> sSep Then sProgramName = sProgramName & sSep ' ein Leerzeichen als Trennung
    sProgramName = Replace(sProgramName, sSep, "")
    If sFoundOption Then sFoundOption = sSep & sFound  ' Leerstellen als Trenner beachten
    If sDirFile_OrText Then sDirFile_OrText = sSep & sDirFile_OrText 
    sFound = String.LCase(sProgramName) & sFoundOption & sDirFile_OrText ' Bei Pfad klein/GROSSschreibung beachten
    '......................................
    Shell sFound 'startet Programm mit Dateipfad oder Text einfügen
    '......................................
  Else If Exist(sDirFile_OrText) = True Then 
    Desktop.Open(sDirFile_OrText) 'bevorzugtes Standard-Programm
  Endif
  
  'XDG (X Desktop Group)
  '    xdg-open - opens a file or URL in the user's preferred application
  ' Synopsis
  '    xdg-open { file | URL }
  '    xdg-open { --help | --manual | --version }
  ' Use 'man xdg-open' or 'xdg-open --manual' for additional info.
  ' Zuordnung von MIME-Typen und Standard-Anwendungen...entwickelt, um desktop-übergreifende Standards für Linux zu schaffen.
  ' Für Programmierer
  
  ' Funktionsweise: Alternativen werden über zweifache symbolische Links verwirklicht. Zum Beispiel ist /usr/bin/x-www-browser ein symbolischer Link auf /etc/alternatives/x-www-browser, was wiederum ein symbolischer Link auf den als Vorgabe eingestellten Webbrowser ist.
  ' Experten-Info: Diese scheinbar unsinnige "Umleitung" erklärt sich dadurch, dass der FHS empfiehlt, dass vom Systemadministrator durchgeführte Änderungen sich auf das Verzeichnis /etc beschränken sollten. 
  
  'File-Extension, Example Gambas3: Pattern "*.gambas"
  '/usr/share/mime/application/x-gambas3.xml   (XML-Dokument (application/xml))  'Root-Rechte erforderlich
  ' <?xml version="1.0" encoding="utf-8"?>
  ' <mime-type xmlns="https://www.freedesktop.org/standards/shared-mime-info" type="application/x-gambas3">
  '   <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  '   <sub-class-of type="application/x-executable"/>
  '   <comment>Gambas executable</comment>
  '   <glob pattern="*.gambas"/>
  ' </mime-type>
  
  ' /home/<user>/.config/mimeapps.list     'Einfaches Textdokument (text/plain)  Zugriff im Bereich <user> erlaubt, ohne Root-Rechte.
  
  'Shell "xdg-open" & Space(1) & Datei.html   öffnet bevorzugtes Standardprogramm, z.b. Browser "firefox" 
  ' Datei= "DirFile.html" oder URL= "https://www.design-cad.de"
  '' gnome-open, kde-open, exo-open, xdg-open usw. 
  ' Öffnet das jeweilige Standard-Programm, abhängig vom MIME-Typ (text/plain *.txt, image/png *.png usw.)
  '
  ''exo-open - Open URLs and launch preferred applications
  ' --launch category parameters...
  '            Launch the preferred application for the given category with the optional
  '            parameters..., where category is either WebBrowser, MailReader, TerminalEmulator or
  '            FileManager.
  ' 
  '        If you do not specify the --launch option, exo-open will open all specified URLs with
  '        their preferred URL handlers. Else, if you specify the --launch option, you can select
  '        which preferred application you want to run, and pass additional parameters to the
  '        application (i.e. for TerminalEmulator you can pass the command line that should be run in
  '        the terminal).
  '''____________________________________________________________________________''
  'Quelle:  "https://manpages.ubuntu.com/manpages/focal/en/man1/exo-open.1.html"
  
  ''xdg-open - opens a file or URL in the user's preferred application
  ' EXAMPLES
  '            xdg-open 'https://www.freedesktop.org/'
  '        Opens the freedesktop.org website in the user's default browser.
  '            xdg-open /tmp/foobar.png
  '        Opens the PNG image file /tmp/foobar.png in the user's default image viewing application.
  ' xdg-open supports: file, ftp, http and https URLs. Is not... to use xdg-open as root (Wurzelverzeichnis System).
  ' Notes: MIME applications associations specification >   "https://www.freedesktop.org/wiki/Specifications/mime-apps-spec/"
  '''____________________________________________________________________________''
  'Quelle:  "https://manpages.ubuntu.com/manpages/focal/en/man1/xdg-open.1.html"
  
  ' xdg-mime - command line tool for querying information about file type handling and adding descriptions for new file types
  ' EXAMPLES
  '            xdg-mime query filetype /tmp/foobar.png
  '        Prints the MIME type of the file /tmp/foobar.png, in this case image/png
  '            xdg-mime query default image/png
  '        Prints the .desktop filename of the application which is registered to open PNG files.
  '            xdg-mime install shinythings-shiny.xml
  '        Adds a file type description for "shiny"-files. "shinythings-" is used as the vendor
  '        prefix. The file type description could look as follows.
  '            shinythings-shiny.xml:
  ' 
  '            <?xml version="1.0"?>
  '            <mime-info xmlns='https://www.freedesktop.org/standards/shared-mime-info'>
  '              <mime-type type="text/x-shiny">
  '                <comment>Shiny new file type</comment>
  '                <glob pattern="*.shiny"/>
  '                <glob pattern="*.shi"/>
  '              </mime-type>
  '            </mime-info>
  ' 
  '        An icon for this new file type must also be installed, for example with:
  '            xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
  
  'Example with Program Gambas3:
  'File-Extension, Example Gambas3: Pattern "*.gambas"
  '/usr/share/mime/application/x-gambas3.xml   (XML-Dokument (application/xml))  'Root-Rechte erforderlich
  '
  ' <?xml version="1.0" encoding="utf-8"?>
  ' <mime-type xmlns="https://www.freedesktop.org/standards/shared-mime-info" type="application/x-gambas3">
  '   <!--Created automatically by update-mime-database. DO NOT EDIT!-->
  '   <sub-class-of type="application/x-executable"/>
  '   <comment>Gambas executable</comment>
  '   <glob pattern="*.gambas"/>
  ' </mime-type>
  '''____________________________________________________________________________''
  'Quelle:  "https://manpages.ubuntu.com/manpages/focal/en/man1/xdg-mime.1.html"
  ' 
  
Catch 
  FMain.ErrorText
  'Example (Beispiel): 
  'sValue = File.Load(Dateipfad)
  'M01Functions.ExternStart("gedit", sValue)
  
  'Note 2020: Old: "https://" , New: "https://" s—▶Sicherer
End

Public Function FileCheckTypeExtension(Optional sDirFile As String = "", Optional bMimeType As Boolean = False) As String
  
  Dim sTool As String = "file"
  Dim sPathProgram, sPathInfo, sExt As String 
  Dim ssSpli As String[]
  
  If Exist(sDirFile) = True Then 
    sPathProgram = "/usr/bin/" & sTool
    If Exist("/snap/bin" &/ sTool) = True Then sPathProgram = "/snap/bin" &/ sTool
    If Exist(sPathProgram) = False Then sPathProgram = System.Find("file") 
    If Exist(sPathProgram) = True Then 
      If bMimeType = False Then 'Example: "/dir/file.ext: PNG ..." (*1)     Quote("...") because Space(1) in Path ist Separator (Trenner)!
        Shell sTool & Space(1) & "--extension" & Space(1) & Quote(sDirFile) To sPathInfo
      Else 'bMimeType = True   'Example: "/dir/file.ext: text/plain..."  image/png (*2)
        Shell sTool & Space(1) & "--mime-type" & Space(1) & Quote(sDirFile) To sPathInfo
      Endif 
      If sPathInfo Then
        ssSpli = Split(sPathInfo & ":", ":")
        sExt = ssSpli[1]
        ssSpli = Split(ssSpli[1] & Space(1), Space(1))
        sExt = ssSpli[1]
        sExt = String.LCase(sExt)
        sExt = Trim(sExt)
        sExt = Replace(sExt, gb.NewLine, "")
      Endif 
    Endif 
  Endif 
  ' Print "sPathInfo Mime", sPathInfo, sExt
  If sExt = "???" Then sExt = ""
  Return sExt
  
  ''__________________________________________________________''
  '' (*) "file" as Tool!
  'Example: file --extension sDirFile > ": png"
  'Example: file -k sDirFile > ": PNG image data, 300 x 300, 8-bit/color RGBA, non-interlaced\012- data"
  'Example: file -i sDirFile > ": image/png; charset=binary"
  'Example: file --mime-type sDirFile > ": image/png"
  
  'https://manpages.ubuntu.com/manpages/jammy/man1/file.1.html
  
Catch
  FMain.ErrorText
  
End 

Public Function FileExtStandardProgramName(Optional sDirFileExt As String = "") As String 
  
  Dim sProgramDesktop, sMimeType, sProgramName As String
  Dim ssSpli As String[]
  
  ''not forget empty-space Space(1) or Space(1) as Separator
  
  ''xdg:
  If System.Exist("xdg-open") = True Then '"xdg-open FileOrURL" '(*1)
    Shell "xdg-mime query filetype " & sDirFileExt To sMimeType  'Example file.pdf: "application/pdf; charset=binary"
    Shell "xdg-mime query default " & sMimeType To sProgramDesktop 'Standard-Program "<name>.desktop"
    ssSpli = Split(sProgramDesktop & gb.NewLine, gb.NewLine)
    If ssSpli Then sProgramName = ssSpli[0] Else sProgramName = Null '<name>.desktop, link to program
    If sProgramName Then 
      sProgramName = File.SetExt(sProgramName, "") 'Example: org.gnome.gedit.desktop > org.gnome.gedit
      sProgramName = Replace(sProgramName, ".", "/")  'Example: org.gnome.gedit > org/gnome/gedit
      sProgramName = File.Name(sProgramName) 'Example: "gedit"
    Endif 
  Endif 
  
  If Not sProgramName Then 'search next
    ''exo:
    If System.Exist("exo-open") = True Then '"exo-open FileOrURL" '(*2) Xfce Preferred Applications
      sProgramName = "exo-open"  'xdg-open - opens a file or URL in the user's preferred application
      'exo-open [[url]...] 
      'exo-open --launch [category] [[parameter]...]
      ' --launch category parameters...     'category: WebBrowser, MailReader, TerminalEmulator Or FileManager.
      'Example: Shell "exo-open --launch FileManager" & Space(1) & sDirFileExt
      
      ''gnome:
    Else If System.Exist("gnome-open") = True Then '"gnome-open FileOrURL"  (*3)
      sProgramName = "gnome-open"
      
      ''kde:
    Else If System.Exist("kde-open") = True Then 
      sProgramName = "kde-open"
      
      ''gambas3:
    Else 
      sProgramName = "" 'Desktop.Open(sDirFileExt)  
    Endif 
  Endif 
  
  If sProgramName Then 
    Shell sProgramName & Space(1) & sDirFileExt 
  Else 
    Desktop.Open(sDirFileExt)
  Endif 
  
  Return sProgramName
  ''_________________________________________________________________________''
  '(*1) "https://manpages.ubuntu.com/manpages/focal/en/man1/xdg-open.1.html", in all ubuntu-Version?
  '(*2) "https://manpages.ubuntu.com/manpages/hirsute/en/man1/exo-open.1.html", in all ubuntu-Version?
  '(*3) "https://manpages.ubuntu.com/manpages/bionic/en/man1/gnome-open.1.html", Version ends in ubuntu18LTS?
  'opens a file or URL in the user's preferred application
  
Catch 
  FMain.ErrorText
  
End

Public Function AccessDirFileReadWrite(Optional sDirFile As String = "", Optional Erlaubt_Read0_Write1_Exec2_Alle3 As Integer = 0) As Boolean
  
  Dim bZugang As Boolean '=False
  'Im Projektverzeichnis gesperrt, freie Zugriffe über Tempfiles oder /home/<user>/... 
  
  If Exist(sDirFile) = True Then 
    Select Case Erlaubt_Read0_Write1_Exec2_Alle3
      Case 0 'lesen möglich
        bZugang = Access(sDirFile, gb.Read) 
      Case 1 'schreiben möglich
        bZugang = Access(sDirFile, gb.Write)
      Case 2 'ausführen möglich    Datei als Programm oder Verzeichnis zugänglich
        bZugang = Access(sDirFile, gb.Exec)
      Case 3 'Alle
        bZugang = Access(sDirFile, gb.Read Or gb.Write Or gb.Exec) 'kombiniert
    End Select
  Endif 
  Return bZugang 'Rückgabe as Boolean  True/False   erlaubt/nicht erlaubt
  
  ''____________________________________________________________________________''
  'Gambas3:
  ' PRINT Access("/root", gb.Write)
  ' False
  ' 
  ' Alle Dateien inner- und unterhalb des Projektverzeichnisses (und auch alle Unterverzeichnisse darin) werden als read-only behandelt, egal wie die tatsächlichen Moduseinstellungen lauten, auch bei Dateien mit dem Modus 777 (voller Lese- und Schreibzugriff für Besitzer, Gruppe und Andere). Das heißt, Access("img/myImage.png") gibt niemals gb.Write zurück. Stattdessen sollten Tempfiles oder ein extra Verzeichnis (ggf. versteckt) im Homeverzeichnis des aktiven Benutzers (also von dem Benutzer des Gambas-Programms) verwendet werden.
  '
  ' Examples
  ' Print Access("data/img/myImage.png", gb.Write)
  ' False
  
  'write and read TRUE:
  '—▶ /home/<user>/terminwecker/file.txt
  
Catch 
  FMain.ErrorText
  
End

Public Function FileBackupPathName(Optional sDirFile As String = "") As String 'gibt Name zurück. () Klammern nicht vergessen
  
  Dim sDir As String
  
  sDir = FMain.F_sDirBackup 'change, bis 2020 sTilde = "~"
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirAppName &/ Application.Name & "-backup"] 
  If IsDir(File.Dir(sDir)) = True And IsDir(sDir) = False Then Try Mkdir sDir 'auch ohne Strich "/" am Ende
  ' If String.InStr(File.BaseName(sDirFile), "_lastnotice") > 0 Then 
  '   If IsDir(sDir) = True Then sDirFile = sDir &/ File.Name(sDirFile) & "_backup" & Format(Now, "hh-nn") & "." & File.Ext(sDirFile) 'not too many
  ' Else 
  If IsDir(sDir) = True Then sDirFile = sDir &/ File.Name(sDirFile) & "_backup" & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss-uu") & "." & File.Ext(sDirFile)
  ' Endif 
  
  Return sDirFile 'Backup-Path-Name oder Original-Path-Name 
  'Example: /dir/file.txt_backup2022-09-02-Fr-38-21-00-000.txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function OpenBackupDirFile(Optional sDirFileOriginal As String = "") As String 
  
  Dim sPath, sDir, sSearchPattern, sFile, sDirFile As String 
  Dim ssFiles As String[]
  
  sPath = sDirFileOriginal & "_lastbackup." & File.Ext(sDirFileOriginal)
  If Exist(sPath) = True Then 
    sDirFile = sPath
  Else 
    sPath = sDirFileOriginal
    sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
    sSearchPattern = File.BaseName(sPath) & "*." & File.Ext(sPath)
    sSearchPattern = Replace(sSearchPattern, "_", "*")
    sSearchPattern = "*" & sSearchPattern & "*"
    
    ssFiles = Dir(sDir, sSearchPattern, gb.File) 'as String[]
    If ssFiles.Max > -1 Then 
      ssFiles.Sort(gb.Descent)
      If ssFiles.Max > -1 Then sFile = ssFiles.First
      sDirFile = sDir &/ sFile
    Endif 
  Endif 
  
  Return sDirFile '/Dir/File.ext*_backup*.ext
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 'only Text
  '(Last-Path, open/save, Standard-Path)
  
  Dim ssFilter As String[] 
  Dim sFilePattern, sFilePatternDate, sDate, sDir, sDirBackup, sFile, sName As String 
  Dim it As Integer
  
  sDirBackup = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  sFilePattern = sFile & "*" 
  
  it = Dir(sDir, sFilePattern, gb.File).Max '-1 not found
  If it = -1 Then sFilePattern = "*" & sFilePattern
  sFilePatternDate = sFilePattern & "_date_" & "*" & "." & File.Ext(sStandardPath)  'File.ext_backup_date_*
  
  ssFilter = New String[]
  
  ssFilter.Add(sFilePattern) ''Example: *terminwecker*.txt, "*terminwecker*project*.txt"
  ssFilter.Add(("Nur-Text") & Space(1) & Str(it + 1) & "x")
  
  ssFilter.Add("*.txt")
  ssFilter.Add(("Nur-Text"))
  
  sDate = Format(DateAdd(Now, gb.Hour, -1), "yyyy-mm-dd-hh")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("vor 1 Stunde"))
  
  sDate = Format(Date, "yyyy-mm-dd")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Heute"))
  
  sDate = Format(DateAdd(Date, gb.Day, -1), "yyyy-mm-dd")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Gestern") & Space(1) & sDate)
  
  sDate = Format(Date, "yyyy-mm-")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Monat") & Space(1) & Format(Date, "yyyy mmmm"))
  
  sDate = Format(DateAdd(Date, gb.Month, -1), "yyyy-mm-")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Monat") & Space(1) & Format(DateAdd(Date, gb.Month, -1), "yyyy mmmm"))
  
  sDate = Format(Date, "yyyy")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Jahr") & Space(1) & sDate)
  
  sDate = Format(DateAdd(Date, gb.Year, -1), "yyyy")
  ssFilter.Add(Replace(sFilePatternDate, "_date_", sDate))
  ssFilter.Add(("Backup") & Space(1) & ("Jahr") & Space(1) & sDate)
  
  sDate = Format(Date, "yyyy-mm-dd")
  ssFilter.Add("*" & File.BaseName(sDirFile) & "*")
  ssFilter.Add(("Backup") & Space(1) & ("Heute"))
  
  sName = "*" & Application.Name
  
  ''Extra:
  If sFile Like "*terminwecker.txt*" Or sFile Like "*oldyears*.txt*" Or sFile Like "*project*.txt*" Then 
    sFilePattern = sName & "_oldyears" & "." & File.Ext(sFile) & "*" & ";" & sName & "_vergangene" & "." & File.Ext(sFile) & "*" & ";"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Ausgelagert, vergangene Jahre"))
  Endif
  If sDirFile Like "*geburtstag*" Or sDirFile Like "*birthday*" Or sDirFile Like "*everyyear*" Then 
    sFilePattern = sName & "_everyyear" & "." & File.Ext(sDirFile) & "*" & ";" & sName & "_geburtstage" & "." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Geburtstage *Jedes Jahr"))
  Endif
  If sDirFile Like "*.conf" Or sDirFile Like "*settings*" Then 
    sFilePattern = sName & "." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Configuration, Einstellungen, Settings"))
  Endif
  If sDirFile Like "*.txt" Or sDirFile Like "*lastnotice*" Then 
    sFilePattern = sName & "*lastnotice." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Letzter Zeilen-Eintrag"))
  Endif
  
  'autom. Append (Anhang) ["*.*", "All Files"] = FilterIndex=-1
  If File.BaseName(sDirFile) = "" Then sDirFile = sDirFile &/ ("datei") & "." & File.Ext(sDirFile)
  If File.BaseName(sDirFile) <> "" And File.Ext(sDirFile) = "" Then sDirFile = sDirFile & "." & "txt"
  Dialog.Filter = ssFilter '[Filter1, Filtertext1, ...]
  Dialog.Path = sDirFile
  
  If sOpenSave = "open" Then 
    Dialog.Title = ("Datei öffnen...") & Space(5) & ("Typ") & ": " & Space(1) & File.Name(sDirFile) & Space(1) & Str(it + 1) & "x"
    If Dialog.OpenFile() Then Return 'Canceled (abgebrochen)
  Else 
    Dialog.Title = ("Datei speichern...") & Space(5) & ("Typ") & ": " & Space(1) & File.Name(sDirFile)
    Dialog.AutoExt = True ''needs component: gb.form.dialog
    If Dialog.SaveFile() Then Return 'Canceled (abgebrochen) 
  Endif 
  
  Return Dialog.Path 'No canceled (nicht abgebrochen)
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub FileNamesSettingsReload()
  
  ' alles klein geschrieben?
  ' "&/"  fügt zusammen und prüft, damit nur 1 Schrägstrich dazwischen ist
  ''Note: File-Names not translate (Datei-Namen nicht übersetzen)
  
  FMain.F_sPathAutoStartDatei_desktop = User.Home &/ ".config/autostart/" & Application.Name & ".desktop"
  
  ''Program-Directory:
  FMain.F_sDirProgramOnlyRead = Application.Path 'Example: /home/user/Gambas3/terminwecker/ or /usr/bin/ 'Root-Directory
  
  ''User-Directory Standard:
  FMain.F_sDirAppName = User.Home &/ Application.Name 'Example: /home/user/terminwecker/
  If IsDir(FMain.F_sDirAppName) = False Then Try Mkdir FMain.F_sDirAppName
  ' FMain.F_sDirAppName = Application.Path 'alle Pfade relativ zum Programm-Pfad
  ' FMain.F_sDirAppName = ".../" 'relative, Program-Path
  ' Unter Unix-Systemen sind alle Geräte wie Dateien. 
  
  ''Directory Termine:
  If Exist(FMain.F_sDirAppName) = False Then  '.../terminwecker/<files>
    FMain.F_sDirAppName = M01Functions.CheckDirAppName() 'as String
  Endif
  
  ''Sub-Directory Cache:
  FMain.F_sDirCache = FMain.F_sDirAppName &/ Application.Name & "-cache"
  If IsDir(FMain.F_sDirCache) = False Then Try Mkdir FMain.F_sDirCache
  
  ''Sub-Directory MyFiles:
  FMain.F_sDirMyFiles = FMain.F_sDirAppName &/ String.LCase(Application.Name) & "-myfiles"
  If IsDir(FMain.F_sDirMyFiles) = False Then Try Mkdir FMain.F_sDirMyFiles
  
  ''Sub-Directory Projects:
  FMain.F_sDirProject = FMain.F_sDirAppName &/ Application.Name & "-projects" 'Ordner
  If Exist(FMain.F_sDirProject) = False Then
    Try Mkdir FMain.F_sDirProject
    If Exist(FMain.F_sDirProject) = False Then FMain.F_sDirProject = FMain.F_sDirAppName
  Endif
  
  ''Sub-Directory Backups:
  FMain.F_sDirBackup = FMain.F_sDirAppName &/ Application.Name & "-backup" 'Ordner
  If Exist(FMain.F_sDirBackup) = False Then
    Try Mkdir FMain.F_sDirBackup
    If Exist(FMain.F_sDirBackup) = False Then FMain.F_sDirBackup = FMain.F_sDirAppName
  Endif
  
  ''Sub-Directory Clock:
  FMain.F_sDirClock = FMain.F_sDirAppName &/ Application.Name & "-clock" 'Ordner
  If Exist(FMain.F_sDirClock) = False Then
    Try Mkdir FMain.F_sDirClock
    If Exist(FMain.F_sDirClock) = False Then FMain.F_sDirClock = FMain.F_sDirAppName
  Endif
  
  ''Sub-Directory Colors:
  FMain.F_sDirColors = FMain.F_sDirAppName &/ String.LCase(Application.Name) & "-colors"
  If IsDir(FMain.F_sDirColors) = False Then 
    Try Mkdir FMain.F_sDirColors
    If Exist(FMain.F_sDirColors) = False Then FMain.F_sDirColors = FMain.F_sDirAppName
  Endif 
  
  ''Sub-Directory Music:
  FMain.F_sDirMusic = FMain.F_sDirAppName &/ String.LCase(Application.Name) & "-music"
  If IsDir(FMain.F_sDirMusic) = False Then 
    Try Mkdir FMain.F_sDirMusic
    If Exist(FMain.F_sDirMusic) = False Then FMain.F_sDirMusic = FMain.F_sDirAppName
  Endif 
  
  ''Sub-Directory Pictures, Icons:
  FMain.F_sDirPictures = FMain.F_sDirAppName &/ String.LCase(Application.Name) & "-pictures"
  If IsDir(FMain.F_sDirPictures) = False Then 
    Try Mkdir FMain.F_sDirPictures
    If Exist(FMain.F_sDirPictures) = False Then FMain.F_sDirPictures = FMain.F_sDirAppName
  Endif 
  
  ''Defaults:                   'Example: /home/user/terminwecker/terminwecker.txt
  FMain.F_sPathTerminweckerStandard_txt = FMain.F_sDirAppName &/ Application.Name & ".txt"
  FMain.F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  FMain.F_sPathProject_txt = FMain.F_sDirProject &/ ("project_") & String.LCase(FMain.F_sProjectOnlyName) & ".txt"
  
  ''Current Directory:
  FMain.F_sPathTerminweckerActual_txt = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt] 
  ' If Exist(FMain.F_sPathTerminweckerActual_txt) = False Then FMain.F_sPathTerminweckerActual_txt = FMain.F_sPathTerminweckerStandard_txt
  FMain.F_sDirTerminweckerCurrent = File.Dir(FMain.F_sPathTerminweckerActual_txt)
  
  ''Path:
  FMain.F_sPathEveryYear = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_everyyear.txt" '*EveryYear Birthsdays (*jedesJahr Geburtstage) 
  FMain.F_sPathSettingsBackup_conf = FMain.F_sDirTerminweckerCurrent &/ File.Name(Settings.Path) & "_backup.conf"
  FMain.F_sPathText5Temp_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_lastnotice.txt"
  
  FMain.F_sPathTerminweckerUntil_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_until.txt" 'Datei, Inhalt 1 sLine
  FMain.F_sPathMediaTerminwecker_txt = Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt", Null]
  FMain.F_sPathProjectsNames_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_projectsnames.txt"
  FMain.F_sPathProjectsAllTimes_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_projectsalltimes.txt"
  FMain.F_sPathHolidaysPlus_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_holidaysplus.txt" 'fixed and moveable holidays (feiertageplus.txt)
  FMain.F_sPathTimerPlus_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_timerplus.txt"
  FMain.F_sPathClockMuster_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_clockmuster.txt"
  FMain.F_sPathClockColors_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_colors.txt"
  FMain.F_sPathPickerColorsMemory_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_colors.txt"
  FMain.F_sPathTerminweckerLastBackup_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_lastbackup.txt"
  FMain.F_sPathSettingsDefaultExtern_conf = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_extern.conf"
  
  FMain.F_sPathScreenphotoPNG = FMain.F_sDirCache &/ "Screenshot.png"
  
  ''Other:
  FMain.F_sPathStartzeit_txt = FMain.F_sDirAppName &/ "temp_" & Application.Name & "_programstart.txt"
  FMain.F_sDirPrintCache = FMain.F_sDirCache &/ Application.Name & "-printcache"
  FMain.F_sBrowserHTMLonlyName = Settings[FMain.Name &/ "F_sBrowserHTMLonlyName", "firefox"]
  FMain.F_sPathSettings_conf = Settings.Path 'User.Home &/ ".config/gambas" &/ Application.Name & ".conf"  ' Gambas3
  FMain.F_sPathMusicStandard_mp3 = "music/clockalarmmusic.mp3" 'Relative to Program. Ordner mit Punkt davor sind unsichtbar wie ".hidden" (verborgene Ordner oder Dateien)
  FMain.F_sPathMusicPlusAlarm_wav = "music/clockplusalarm.wav"
  ' FMain.F_sPathMusicSelect_mp3 = Desktop.GetDirectory("MUSIC") &/ "clockalarmmusic.mp3" ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  FMain.F_sPathClockBackground_png = FMain.F_sDirClock &/ "clockbackground.png" 
  FMain.F_iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128]
  FMain.F_sPathBookmarks_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_bookmarks.txt"
  FMain.F_sPathPhotoSubtitleDate_txt = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "-photo_subtitledate.txt"
  
  Settings[FMain.Name &/ "F_sPathStartzeit_txt"] = FMain.F_sPathStartzeit_txt
  Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt"] = FMain.F_sPathTerminweckerStandard_txt
  Settings[FMain.Name &/ "F_sPathAutoStartDatei_desktop"] = FMain.F_sPathAutoStartDatei_desktop
  Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt"] = FMain.F_sPathTerminweckerActual_txt
  Settings[FMain.Name &/ "F_sPathTerminweckerLastBackup_txt"] = FMain.F_sPathTerminweckerLastBackup_txt
  Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt"] = FMain.F_sPathTerminweckerUntil_txt
  Settings[FMain.Name &/ "F_sPathClockMuster_txt"] = FMain.F_sPathClockMuster_txt
  Settings[FMain.Name &/ "F_sPathClockColors_txt"] = FMain.F_sPathClockColors_txt
  Settings[FMain.Name &/ "F_sPathPickerColorsMemory_txt"] = FMain.F_sPathPickerColorsMemory_txt
  Settings[FMain.Name &/ "F_sPathEveryYear"] = FMain.F_sPathEveryYear '*EveryYear (*jedes Jahr, Geburtstage)
  Settings[FMain.Name &/ "F_sPathProjectsNames_txt"] = FMain.F_sPathProjectsNames_txt 
  Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt"] = FMain.F_sPathProjectsAllTimes_txt 
  Settings[FMain.Name &/ "F_sPathText5Temp_txt"] = FMain.F_sPathText5Temp_txt
  Settings[FMain.Name &/ "F_sPathClockBackground_png"] = FMain.F_sPathClockBackground_png
  Settings[FMain.Name &/ "F_sPathSettings_conf"] = FMain.F_sPathSettings_conf
  Settings[FMain.Name &/ "F_sPathTimerPlus_txt"] = FMain.F_sPathTimerPlus_txt
  Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt"] = FMain.F_sPathHolidaysPlus_txt 'fixed and moveable holidays (feste und bewegliche Feiertage)
  Settings[FMain.Name &/ "F_sPathProject_txt"] = FMain.F_sPathProject_txt
  Settings[FMain.Name &/ "F_sPathMusicStandard_mp3"] = FMain.F_sPathMusicStandard_mp3 'little file: 25 KB
  Settings[FMain.Name &/ "F_sPathMusicPlusAlarm_wav"] = FMain.F_sPathMusicPlusAlarm_wav
  ' Settings[FMain.Name &/ "F_sPathMusicSelect_mp3"] = FMain.F_sPathMusicSelect_mp3 
  Settings[FMain.Name &/ "F_sPathSettingsDefaultExtern_conf"] = FMain.F_sPathSettingsDefaultExtern_conf
  Settings[FMain.Name &/ "F_sPathBookmarks_txt"] = FMain.F_sPathBookmarks_txt
  Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt"] = FMain.F_sPathPhotoSubtitleDate_txt
  Settings[FMain.Name &/ "F_sDirProgramOnlyRead"] = FMain.F_sDirProgramOnlyRead '=Application.Path
  Settings[FMain.Name &/ "F_sDirAppName"] = FMain.F_sDirAppName
  Settings[FMain.Name &/ "F_sDirProject"] = FMain.F_sDirProject
  Settings[FMain.Name &/ "F_sDirBackup"] = FMain.F_sDirBackup
  Settings[FMain.Name &/ "F_sDirMyFiles"] = FMain.F_sDirMyFiles
  Settings[FMain.Name &/ "F_sDirClock"] = FMain.F_sDirClock
  Settings[FMain.Name &/ "F_sDirCache"] = FMain.F_sDirCache
  Settings[FMain.Name &/ "F_sDirPrintCache"] = FMain.F_sDirPrintCache
  Settings[FMain.Name &/ "F_sDirColors"] = FMain.F_sDirColors
  Settings[FMain.Name &/ "F_sDirMusic"] = FMain.F_sDirMusic
  Settings[FMain.Name &/ "F_sDirPictures"] = FMain.F_sDirPictures    
  Settings[FMain.Name &/ "F_sPathScreenphotoPNG"] = FMain.F_sPathScreenphotoPNG 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ErrorMessages()
  
  Dim sError, sText, sInfo, sNote As String
  Dim hDate As Date
  Dim sDirFile As String
  
  sDirFile = FMain.F_sDirAppName &/ "error-info.txt"
  
  ' sError = FMain.F_sErrorMessagesExtra
  sError &= FMain.F_sErrorInfos 
  
  sText = ("Fehler-Meldungen") & ":" & gb.NewLine
  sText &= gb.NewLine
  
  If Not sError Then 
    sText &= ("Keine") & gb.NewLine & gb.NewLine
  Else
    sText &= String.Left(sError, 10000) & gb.NewLine
    sText &= Format(Dfree("/") / 1024 / 1024 / 1024, "0,0") & Space(1) & "GB free" & Space(2) & "(" & Format(Dfree("/"), "0,0") & Space(1) & "Bytes" & ")" & gb.NewLine
    sText &= sError & gb.NewLine
    ' sText &= M01Functions.CheckComponents() 'with html > Message.Info()
  Endif 
  sText &= FMain.F_sErrorMessagesExtra & gb.NewLine
  hDate = FMain.F_dateFileReadingTime
  If Not hDate Then hDate = Settings[FMain.Name &/ "F_dateFileReadingTime", FMain.F_dateFileReadingTime]
  If hDate Then sInfo = String(5, gb.NewLine) & File.Name(FMain.F_sPathTerminweckerActual_txt) & "= " & Format(hDate, "hh:nn:ss.uu") & Space(1) & ("Dauer Einlesezeit") & gb.NewLine 
  sInfo &= ("Tipp") & ":" & ("Bearbeiten") & ">" & ("Datei") & ">" & ("Auslagern") & gb.NewLine & gb.NewLine
  
  sNote = ("Die Fehler-Meldungen sind eine Hilfe für den Programmierer und für Benutzer ein Hinweis auf technisch bedingte Fehlerquellen.") & gb.NewLine & gb.NewLine
  sNote &= ("Technischer Hinweis: Der Fenster-Macher und -Verwalter ''X11'' verhält sich anders als der Nachfolger ''Wayland''. Aktiv") & ": " & Desktop.Platform & gb.NewLine & gb.NewLine  ''(*1)  
  
  If Exist(sDirFile) = True Then 
    sNote &= sDirFile & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & gb.NewLine
  Endif
  sText = sText & sInfo & sNote '& FMain.F_sInfoMessagesExtra
  ' sText = Replace(sText, ("Fehler-Meldungen") & ":", ("Fehler-Meldungen") & ":") 'only 1x 
  
  ''Übergabe an extra Formular, Fenster:
  Form3Text.Tooltip = "" 'Path
  Form3Text.Tag = sText 
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
  'Error.Raise("Test") 'künstlich Test-Fehler erzeugen und hervorheben
  
  ''_________________________________________________________________''
  'Desktop(gb.desktop) 'Gambas3: "This class allows you To Use desktop - agnostic routines based On the freedesktop standards And xdg-utils project."
  '(*1) "X11" and "Wayland" are Window-Manager (Fenster-Macher). Wayland is the next generation and replace X11. 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckComponents() As String
  
  Dim sDir, sFile, sPath, sDirFile, sComponent, sDirComponents, sComponentInSystem, sText, sMessage As String 
  Dim sHTMLbreak, sHTMLfont, sHTMLfontEnd As String 
  Dim iMissing, iComponentlines As Integer
  Dim ssSplitComponent, ssExist, ssComponents As String[]
  Dim sSplitPart, sCheckList, sGUItoolkit As String 
  Dim bTest As Boolean
  ' Dim hComponent As Component
  bTest = True 'Default TRUE! xxx???
  
  sHTMLbreak = "<br>" 'HTML break line like gb.NewLine
  sHTMLfont = "<font color=black><b>" 'HTML-Code
  sHTMLfontEnd = "</b></font>" 'b=Bold
  
  If Component.IsLoaded("gb.gui") = True Then sGUItoolkit = "gb.gui" & Space(1) 'switch QT <> GTK
  If Component.IsLoaded("gb.qt4") = True Then sGUItoolkit &= "gb.qt4" & Space(1)
  If Component.IsLoaded("gb.qt5") = True Then sGUItoolkit &= "gb.qt5" & Space(1)
  If Component.IsLoaded("gb.qt6") = True Then sGUItoolkit &= "gb.qt6" & Space(1)  '?
  If Component.IsLoaded("gb.gtk3") = True Then sGUItoolkit &= "gb.gtk3" & Space(1)
  If Component.IsLoaded("gb.gtk4") = True Then sGUItoolkit &= "gb.gtk4" & Space(1)
  If Component.IsLoaded("gb.gtk5") = True Then sGUItoolkit &= "gb.gtk5" & Space(1)  '?
  If Component.IsLoaded("gb.gtk6") = True Then sGUItoolkit &= "gb.gtk6" & Space(1)  '?
  sGUItoolkit = Replace(sGUItoolkit, "gb.", Space(1))
  sGUItoolkit = UCase(sGUItoolkit) 'Example: "QT5" or "GTK3"...
  ''Installed in Root?  Root-Example: "/usr/..."   User-Example: "/home/user/..."
  ' sDirFile = System.Path '"/usr/"   Components "/usr/lib/gambas3/..."  MyApp: '"/usr/share/MyApp/..."
  sDirFile = System.Find(Application.Name) 'Find Program, Software, App
  If sDirFile = "" Then sDirFile = Application.Path &/ Application.Name & ".gambas"
  ' Example Components:
  ' Components-Names in File ".startup":       (Note: see in filemanager, Program-Directory, hidden File)
  ' FMain
  ' terminwecker
  ' 0
  ' 0
  ' 3.0.186
  ' 
  ' gb.args
  ' gb.image
  ' gb.qt5
  ' gb.form
  ' gb.debug
  ' gb.desktop
  ' gb.desktop.x11
  ' gb.eval
  ' gb.eval.highlight
  ' gb.form.dialog
  ' gb.util
  ' gb.settings
  ' gb.form.stock
  ' gb.inotify
  ' gb.net
  ' gb.net.curl
  ' gb.markdown
  ' gb.qt5.ext
  ' gb.qt5.webkit
  ' gb.sdl2.audio
  
  'All used?
  
  ''Basis QT5. Check-List:
  'gb eingebaute Basis-Klassen (minimal)
  'Other Componenten:
  'Dim hHTTPClient As HttpClient 'needs component: "gb.net.curl" 
  'Desktop.FromMime() needs component: gb.desktop
  'WebView.Document needs component: gb.qt4.webkit, gb.qt5.webkit
  'WebView.FindText(...) needs component: gb.qt4.webkit, gb.qt5.webkit
  'Music.Play(1,0) > (Loop 1x, default 0) needs component: (gb.sdl2.audio)
  'needs component: gb.settings (*1)
  'Dialog.AutoExt = True ''needs component: gb.form.dialog
  '.FormatSize() needs component gb.util
  'gb.dbus 'D-Bus Interface. Wenn geladen, dann in Gambas3 autom. verbunden.
  'gb.desktop.x11 'Fensterunterstützung. Noch nicht für Qt5! Nachfolger siehe .wayland?
  'gb.args 'Zus. Programm-Argumente Version, Hilfe...
  'gb.form.stock 'Standard-Icons
  'gb.inotify'This component enables you To Catch filesystem events using Linux ' inotify API.
  'gb.image 'Bildverwaltung, ergänzend: gb.image.effects
  'gb.markdown 'Auszeichnungssyntax
  'gb.qt5
  'gb.qt5.ext
  'gb.qt5.webkit
  'gb.eval.highlight '> Editor html, gambas3, c++,...
  'gb.form 'weitere Steuerelemente, z.b. DateChooser, Bookmarks, ...
  'gb.util 'utility methods or classes. z.b. .FormatSize(), CsvFile.Open(), ...
  'gb.eval  'evaluating, analyzing and highlighting a line of Gambas code, Eval() as Variant, Print Application.Font.ToString()
  'gb.debug 'This class allows To Debug a running Gambas project.
  'gb.test 'Test-Component 'Message: Modul fehlt
  
  sChecklist = ""
  ssExist = New String[]
  
  sDirComponents = Component.Path '(gb) Example: "/usr/lib/gambas3/" Gambas3: "Returns the system path where all the components are stored."
  If Exist(sDirComponents) = True Then ssComponents = Dir(sDirComponents, "gb.*component", gb.File) ' as String[]
  
  sDir = "" 'Application.Path
  sFile = ".startup" ' "*.txt" simple Text-File
  sPath = sFile 'sDir &/ sFile
  
  If Exist(sPath) = True Then sText = File.Load(sPath) 'as String
  If sText Then 
    sText = sText & gb.NewLine & sCheckList
    ssSplitComponent = Split(sText & gb.NewLine, gb.NewLine)
    For Each sSplitPart In ssSplitComponent
      If String.InStr(String.LCase(sSplitPart), "gb.") > 0 Then 
        If ssExist.Find(sSplitPart) = -1 Then 'not double
          ssExist.Add(sSplitPart)
          iComponentlines = iComponentlines + 1
          If ssComponents Then '[...]
            If ssComponents.Exist(sSplitPart & ".component") = bTest Then 
              sComponentInSystem = "" '"<font color=gray><b>" & " •" & "</b></font>" ' see "selfhtml vga color Name" [*1]
            Else 
              sComponentInSystem = "<font color=red><b>" & " •" & "</b></font>"
            Endif 
          Endif 
          If Component.IsLoaded(String.LCase(sSplitPart)) = bTest Then 
            sComponent = sComponent & String.LCase(sSplitPart) & Space(1) & "<font color=darkgreen><b>" & ("●") & "</b></font>" & sComponentInSystem & sHTMLbreak
          Else
            iMissing = iMissing + 1
            sComponent = sComponent & String.LCase(sSplitPart) & Space(1) & "<font color=red><b>" & "● " & ("Fehlt") & "</b></font>" & sComponentInSystem & sHTMLbreak
          Endif
        Endif  
      Endif
      
    Next
  Endif
  
  ' Component = gb.settings        '/home/<user>/.config/programname/programname.conf"
  ' Example: If Not Component.IsLoaded("gb.image") Then Component.Load("gb.image")
  
  If iMissing = 0 Then  
    sComponentInSystem = ""
  Else 
    If Exist(sDirComponents) = True Then '"/usr/lib/gambas3/"
      sComponentInSystem = "<font color=gray><b>" & "• = " & ("Component im System gefunden") & "</b></font>"
    Else 
      sComponentInSystem = "<font color=red><b>" & "• = " & Component.Path &/ Space(1) & ("Fehlt") & "</b></font>"
    Endif 
  Endif 
  
  If sComponent Then 
    sMessage = ("Liste der Komponenten (Software-Teile) in Gambas") & System.Version & Space(1) & "(" & System.FullVersion & ")" & Space(1) & ("gefunden oder nicht gefunden") & ": " & sHTMLbreak 
    sMessage &= ("GUI-Toolkit") & Space(1) & ("(Graphical User Interface)") & Space(1) & "QT, GTK" & ": " & "<font color=blue><b>" & sGUItoolkit & "</b></font>" & Space(1) & ("Programm-Bibliothek") & sHTMLbreak
    sMessage &= ("Fenster-Macher-System (X11, Wayland)") & ": " & "<font color=blue><b>" & String.UCase(Desktop.Platform) & "</b></font>" & sHTMLbreak
    ' sMessage &= sHTMLfont & sComponent & sHTMLfontEnd ''HTML-Code
    sMessage &= "<font size=1>" & sComponent & "</font>" 
    sMessage &= ("Installiert") & "=" & sHTMLfont & Str(iComponentlines - iMissing) & Space(1) & ("von") & Space(1) & Str(iComponentlines) & Space(1) & ("Komponenten") & sHTMLfontEnd & sHTMLbreak
    
    sMessage &= ("Ordner Komponenten") & ": " & sHTMLfont & sDirComponents & sHTMLfontEnd & sHTMLbreak
    sMessage &= sComponentInSystem & sHTMLbreak
    ' sMessage &= ("Ordner Applikationen (Apps)") & ": " & sHTMLfont & System.Path & sHTMLfontEnd & sHTMLbreak  'Example: "/usr"  "/usr/share/applications"
    'sMessage &= ...  or sMessage = sMessage & ...
    sMessage &= ("Programm") & ": " & sHTMLfont & sDirFile & sHTMLfontEnd & sHTMLbreak 
    sMessage &= ("gambas3 runtime. Interpreter-Version") & ": " & "Gambas" & "<b>" & System.Version & "</b>" & ". " & ("Thanks (Merci, Danke)") & "." & sHTMLbreak  'System.Version Example: "3"
    sMessage &= ("Bildschirmfoto") & Space(1) & ("(Tool)") & ": " & sHTMLfont & FMain.F_sScreenshotToolPath & sHTMLfontEnd & sHTMLbreak 
    sMessage &= ("System.Architecture") & ": " & sHTMLfont & System.Architecture & sHTMLfontEnd & sHTMLbreak 
    sMessage &= ("Betriebssystem (OS Operating System)") & ": " & sHTMLfont & System.Family & sHTMLfontEnd & sHTMLbreak  ''Example: "Linux"
    sMessage &= "XDG_CURRENT_DESKTOP" & ": " & Application.Env["XDG_CURRENT_DESKTOP"] & sHTMLbreak 'Example: "ubuntu:gnome"
    sMessage &= ("Anzahl Umgebungsvariable (Environment)") & ": " & Application.Env.Count & sHTMLbreak
    sMessage &= ("Anzahl Argumente") & ": " & Application.Args.Count & sHTMLbreak
    sMessage &= ("PID (Process identifier, Programm-Identifizierung, eindeutiger Schlüssel mit Zahlen während der Laufzeit)") & ": " & Application.Id & sHTMLbreak
    sMessage &= ("Sprache Schrift") & ": " & sHTMLfont & System.Charset & sHTMLfontEnd & sHTMLbreak  ''Example: UTF-8, ISO-8859-15, ...
    sMessage &= ("Sprache") & ": " & sHTMLfont & System.Language & sHTMLfontEnd & sHTMLbreak  ''Example: "fr_FR", "de_DE"
    sMessage &= sHTMLbreak
    
    sMessage &= "<font color=darkgreen>" & ("Tipp") & ": " & ("Siehe Programm-Typ") & Space(1) & "<b>" & ("Paketverwaltung") & "</b>" & Space(1) & ("(PackageManager) für Software-Pakete, Suche") & ": " & "<b>" & Application.Name & "</b>" & sHTMLbreak
    sMessage &= ("(Installieren, Nachinstallieren, Entfernen)") & "</font>"
  Endif 
  
  Return sMessage
  
  ''______________________________________________________________________''
  '[*1] Color Info: "https://wiki.selfhtml.org/wiki/Grafik/Farbe/Farbpaletten"
  ' "Sie stammen zumeist aus dem X Windows System (X11), wo sie in den 1980ern definiert wurden. Falls ein Namenskonflikt mit den VGA-Farben (siehe oben) auftrat, gab die W3C den VGA-Farben Vorrang. Deshalb ist darkgray (aus X11) heller als gray (aus den VGA-Farben)." 
  
Catch
  FMain.ErrorText
  
End

Public Function CheckQT4QT5() As Boolean
  
  Dim bIsLoaded As Boolean
  
  If Component.IsLoaded("gb.qt4.webkit") = True Or Component.IsLoaded("gb.qt5.webkit") = True Then bIsLoaded = True
  
  Return bIsLoaded
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLineOpenRefreshClose(Optional dateBegin As Date = Now, Optional dateRefreshEnd As Date = Now, Optional bOpen As Boolean = True)
  
  Dim sLine, sPath As String
  Dim sPathTimeStampStart, sPathTimeStampLatest As String 
  Dim sTime1, sTime2, sFileStampFormat As String 
  
  sFileStampFormat = "yyyy-mm-dd-hh-nn-ss"
  'Example: Date|Time|Weekday|Quarter|Calendarweek|Projectname|Time End|Weekday|Seconds Number|Seconds Clock 
  'Example: [0,1,2,3,4,5,6,7,8,9]
  'Example: 2020-05-04|14:53|Mo|1Q|19KW|terminwecker|14:53|Mo|20|00:00:20    '"|" > Separator hTab
  'String.LCase(sProjectName) 'einheitliche Kleinschreibung (bei Linux(Unix) sind file.txt oder File.txt verschiedene Dateien)
  
  ''Project:
  If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]
  
  ' FMain.F_sProjectOnlyName = String.LCase(Application.Name)
  If Exist(FMain.F_sDirProject) = False Then FMain.F_sDirProject = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  FMain.F_sPathProject_txt = FMain.F_sDirProject &/ ("project_") & String.LCase(FMain.F_sProjectOnlyName) & ".txt"
  
  ''Directory:
  If Exist(FMain.F_sDirAppName) = False Then 
    FMain.F_sDirAppName = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
    If Exist(FMain.F_sDirAppName) = False And Exist(File.Dir(FMain.F_sDirAppName)) = True Then Try Mkdir FMain.F_sDirAppName
  Endif 
  
  ''Stamp-Files:
  sPathTimeStampStart = FMain.F_sDirAppName &/ String.LCase("time_" & FMain.F_sProjectOnlyName & "_start.txt")
  sPathTimeStampLatest = FMain.F_sDirAppName &/ String.LCase("time_" & FMain.F_sProjectOnlyName & "_latest.txt")
  
  ''Begin:
  If Exist(sPathTimeStampStart) = True Then 
    sTime1 = File.Load(sPathTimeStampStart) 
    dateBegin = M01Functions.DateCheckyyyymmddhhnn(sTime1)
  Else 'Create File:
    sTime1 = Format(dateBegin, sFileStampFormat)
    File.Save(sPathTimeStampStart, sTime1)
  Endif 
  
  ''Begin/Refresh
  FMain.F_dateProjectStart = dateBegin
  FMain.F_dateProjectEnd = dateRefreshEnd 'Date Change End old, max. 23:59:59
  
  sTime2 = Format(FMain.F_dateProjectEnd, sFileStampFormat)
  If IsDir(File.Dir(sPathTimeStampLatest)) = True Then 
    File.Save(sPathTimeStampLatest, sTime2) 'Refresh
  Else If IsDir(FMain.F_sDirAppName) = True Then 'Alternative
    File.Save(FMain.F_sDirAppName &/ File.Name(sPathTimeStampLatest))
  Endif 
  
  ''Refresh Line:
  FMain.F_sProjectLineActual = M01Functions.ProjectLineRefresh(FMain.F_dateProjectStart, FMain.F_dateProjectEnd, FMain.F_sProjectOnlyName) 'as String
  
  Settings[FMain.Name &/ "F_dateProjectStart"] = FMain.F_dateProjectStart
  
  ''Save, if Date-Changed or Old or Project-Ends:
  If bOpen = False Then 
    sLine = FMain.F_sProjectLineActual
    ' If String.InStr(sLine, gb.NewLine) = 0 Then sLine = gb.NewLine & sLine
    
    ''Single:
    If Not FMain.F_sPathProject_txt Then FMain.F_sPathProject_txt = Settings[FMain.Name &/ "F_sPathProject_txt", FMain.F_sPathProject_txt]
    sPath = M01Functions.FileTextPlus(FMain.F_sPathProject_txt, sLine, False) 'Line add (+) in sDirFileActual 
    ''All:
    If Not FMain.F_sPathProjectsAllTimes_txt Then FMain.F_sPathProjectsAllTimes_txt = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] 
    sPath = M01Functions.FileTextPlus(FMain.F_sPathProjectsAllTimes_txt, sLine, False) 'Line add (+) in sDirFileActual 
    
    ''Reset. Project finished, delete file:
    FMain.F_iProjectSeconds = 0
    FMain.F_sProjectLineActual = Null 'Variable
    ' Settings[FMain.Name &/ "ProjectLine_Backup"] = Null 'Delete
    If Exist(sPathTimeStampStart) = True Then Try Kill sPathTimeStampStart  'Null
    If Exist(sPathTimeStampLatest) = True Then Try Kill sPathTimeStampLatest  'Null
    Settings[FMain.Name &/ "F_dateProjectStart"] = Null
    FMain.F_dateProjectStart = Null
    FMain.F_dateProjectEnd = Null 
  Endif 
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectOldFindAndCompleted() As String 
  
  Dim sLine, sLines As String
  Dim date1, date2 As Date
  Dim sPathTimeStampStart, sPathTimeStampLatest As String 
  Dim sTime1, sTime2 As String 
  Dim sDir, sFile, sPath, sProjectName, sPathProject As String 
  
  ''Check Dir + File:
  If Exist(FMain.F_sDirProject) = False Then FMain.F_sDirProject = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  If Exist(FMain.F_sDirAppName) = False Then FMain.F_sDirAppName = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If Not FMain.F_sPathProjectsAllTimes_txt Then FMain.F_sPathProjectsAllTimes_txt = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] 
  sDir = FMain.F_sDirAppName
  
  ''Program crashed? Ended abruptly? Program was closed, but not from user (Program plötzlich abgebrochen, aber nicht vom Benutzer über Funktion "Beenden"?)
  If Exist(sDir) = True Then 
    For Each sFile In Dir(sDir, "*time_*_start.txt", gb.File) 'find unfinished projects (Suche, finde nicht abgeschlossene Projekte.)
      sPathTimeStampStart = sDir &/ sFile 
      sPathTimeStampLatest = sDir &/ File.Name(Replace(sFile, "_start.txt", "_latest.txt"))
      sProjectName = Replace(File.Name(sPathTimeStampStart), "_start.txt", "")
      sProjectName = Replace(sProjectName, "time_", "")
      sPathProject = FMain.F_sDirProject &/ ("project_") & String.LCase(sProjectName) & ".txt"
      
      ''Read Times:
      If Exist(sPathTimeStampStart) = True Then 
        sTime1 = File.Load(sPathTimeStampStart) 'yyyy-mm-dd-hh-nn-ss
        date1 = M01Functions.DateCheckyyyymmddhhnn(sTime1)
      Endif 
      
      If Exist(sPathTimeStampLatest) = True Then 
        sTime2 = File.Load(sPathTimeStampLatest) 
        date2 = M01Functions.DateCheckyyyymmddhhnn(sTime2)
      Endif 
      
      If date1 And date2 Then 
        If date1 <= date2 Then 
          ''Refresh:
          sLine = M01Functions.ProjectLineRefresh(date1, date2, sProjectName) 'as String
          
          If sLine Then 
            ' If String.InStr(sLine, gb.NewLine) = 0 Then sLine = gb.NewLine & sLine
            sLines = sLines & sLine
            
            ''Single:
            sPath = M01Functions.FileTextPlus(sPathProject, sLine, False) 'Line add (+) in sDirFileActual 
            
            If Exist(sPath) = True Then 
              ''project finished, delete file:
              If Exist(sPathTimeStampStart) = True Then Try Kill sPathTimeStampStart  'Null
              If Exist(sPathTimeStampLatest) = True Then Try Kill sPathTimeStampLatest  'Null
            Endif 
          Endif 
        Endif 
      Endif 
    Next  
  Endif 
  
  If sLines Then 
    ''All:
    sPath = M01Functions.FileTextPlus(FMain.F_sPathProjectsAllTimes_txt, sLines, False) 'Line add (+) in sDirFileActual 
    If Exist(sPath) = False Then sLines = Null
  Endif 
  
  Return sLines
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectLineRefresh(Optional dateTimeBegin As Date = Now, Optional dateTimeEnd As Date = Now, sProjectName As String = "Test") As String
  
  Dim sLine As String
  Dim ssSpli As String[]
  Dim dateTime1, dateTime2, dateSum As Date
  Dim iDiff, it As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''Check:
  If Not sProjectName Then 
    If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
    sProjectName = FMain.F_sProjectOnlyName
  Endif 
  
  dateTime1 = dateTimeBegin
  dateTime2 = dateTimeEnd 
  ' If dateTime1 > dateTime2 Then 'Reihenfolge, evtl. Fehler beheben?
  '   dateTime3 = dateTime1
  '   dateTime1 = dateTime2
  '   dateTime2 = dateTime3
  ' Endif
  
  ''Refresh Line:
  If dateTime1 And dateTime2 Then 
    dateSum = Date(Year(dateTime1), Month(dateTime1), Day(dateTime1), 0, 0, 0) 'only Date, Time = "00:00:00"
    ' If Day(dateTime1) = 0 Then dateTime1 = Date(Year(Date), Month(Date), Day(Date), Hour(dateTime1), Minute(dateTime1), Second(datetime1))
    ' If Day(dateTime2) = 0 Then dateTime2 = Date(Year(datetime1), Month(datetime1), Day(datetime1), Hour(dateTime2), Minute(dateTime2), Second(datetime2))  
    iDiff = DateDiff(dateTime1, dateTime2, gb.Second)
    dateSum = DateAdd(dateSum, gb.Second, iDiff)
    ssSpli = New String[10] '0,1,2,...,9=10x
    ssSpli[0] = Format(dateTime1, "yyyy-mm-dd")
    ssSpli[1] = Format(dateTime1, "hh:nn")
    ssSpli[2] = Format(dateTime1, "ddd")
    ssSpli[3] = M01Functions.DateQuarterG(dateTime1) & "Q" '1...4
    ssSpli[4] = Format(M01Functions.DateCalenderWeek(dateTime1), "00") & ("KW") '00...52
    ssSpli[5] = sProjectName 'T5=Notiz --------------- ▲old▲  ▽new▽
    ssSpli[6] = Format(dateTime2, "hh:nn")
    ssSpli[7] = Format(dateTime2, "ddd")
    ssSpli[8] = Str(iDiff) 'Example: "01234"
    ssSpli[9] = Format(dateSum, "hh:nn:ss") '"00:00:00", max."23:59:59"
    
    'Muster Projects: 
    '0          1     2  3 4  5       6     7     8         9        10   11       12   13
    '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
    
    ''Read Line:
    If ssSpli.Count > 10 Then ssSpli.Resize(10) '[0,1,2,3,4,5,6,7,8,9] =10x
    sLine = Null
    For it = 0 To ssSpli.Max
      If it < ssSpli.Max Then 
        sLine &= ssSpli[it] & hTab
      Else 
        sLine &= ssSpli[it] & hReturn  
      Endif 
    Next 
  Endif 
  ' Print sLine 
  
  Return sLine 'Project-Line or Null ""
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckDirAppName(Optional sDirSub As String = FMain.F_sDirCache, Optional bDirSubAll As Boolean = True) As String 
  
  Dim sDir As String
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  ' If IsDir(sDir) = False Then Try Mkdir sDir
  If IsDir(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  
  If IsDir(sDir) = True And bDirSubAll = True Then 
    sDirSub = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirMyFiles", FMain.F_sDirMyFiles] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
    sDirSub = Settings[FMain.Name &/ "F_sDirPictures", FMain.F_sDirPictures] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
  Else If IsDir(sDir) = True Then 
    If IsDir(sDirSub) = False Then sDirSub = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] 'Ordner  
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
  Else 
    sDir = ""
  Endif 
  
  Return sDir
  
Catch 
  FMain.ErrorText
  
End

Public Function FileTextPlus(Optional sDirFile As String = "", Optional sText As String = "", Optional bOverwrite As Boolean = False) As String
  
  Dim sDir, sDirFileCopy, sDirFileCheck, sDirFileBackup, sInfo, sT1 As String
  Dim statBefore, statBehind As Stat
  
  ''Nur-Text Dateien wie *.txt
  If sDirFile Then 'Ein Datei-Name muß vorhanden sein.
    
    If String.Left(sDirFile, 1) <> "/" Then sDirFile = Application.Path &/ sDirFile ' "text/file.txt ''Only Read in Root, save in "/home/user/terminwecker/" & sDirFile
    sDirFileCheck = sDirFile
    
    ''Backup in Directory:
    sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
    
    If Exist(sDir) = False Then sDir = M01Functions.CheckDirAppName() 'as String, Check Standard-Ordner/erstellen
    If Exist(sDir) = False Then Try Mkdir sDir
    If Exist(sDir) = True Then 
      ' sDirFileCopy = sDir &/ File.Name(sDirFile) & "_backup" & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss-uu") & "." & File.Ext(sDirFile)
      sDirFileCopy = M01Functions.FileBackupPathName(sDir &/ File.Name(sDirFile))
      Try Copy sDirFile To sDirFileCopy
      If Exist(sDirFileCopy) = True Then FMain.F_sLastCopyBackup = sDirFileCopy Else FMain.F_sLastCopyBackup = Null
      If sDirFile = FMain.F_sPathTerminweckerActual_txt Then 
        Settings[FMain.Name &/ "F_sPathTerminweckerLastBackup_txt"] = sDirFileCopy
      Endif 
    Endif
    
    'Auslagern ab einer bestimmten Größe?
    'Kilobyte (KB) 10^3 Byte = 1 000 Byte
    'Megabyte (MB) 10^6 Byte = 1 000 000 Byte
    'Gigabyte (GB) 10^9 Byte = 1 000 000 000 Byte
    
    ''Save:
    '**********************************************************
    If Exist(sDirFile) = True Then statBefore = Stat(sDirFile)
    If bOverwrite = True Then
      Try File.Save(sDirFile, sText)
    Else
      ' Try sFileText = File.Load(sDirFile) 'read (einlesen)
      ' If sFileText Then sText = sFileText & sText 'append (anhängen)
      ' If sText Then Try File.Save(sDirFile, sText) 'save all
      sDirFile = M01Functions.FileAppendText(sDirFile, sText)
    Endif
    If Exist(sDirFile) = True Then statBehind = Stat(sDirFile)
    '**********************************************************
    
    ''Check:
    If Not Error And Exist(sDirFile) = True Then ' List —▶ FMain.mnuInfoG()
      'File-Changed List (veränderte Dateien Liste)
      If String.InStr(FMain.F_sFilesChangedList, sDirFile) = 0 Then FMain.F_sFilesChangedList = FMain.F_sFilesChangedList & sDirFile & gb.NewLine
    Else
      sDirFile = "" 'Fehler?
    Endif 
    
    If Exist(sDirFileCheck) = True Then 
      If statBefore = statBehind Or AccessDirFileReadWrite(sDirFileCheck, 1) = False Then 
        sT1 = ("Keine Änderung möglich?") & "<br>"
        sT1 &= ("Nicht beschreibbar?") & "<br>" '1=write 'nicht verändert, gespeichert?
        sInfo = FMain.F_sErrorMessagesExtra & "<br><font color=red>" & sDirFileCheck & "</font><br>" & sT1 & ("Pfad oder Zugriffsrechte überprüfen (siehe Ordner/Datei Eigenschaften)") & "<br>"
        FMain.F_sErrorMessagesExtra = FMain.F_sErrorMessagesExtra & gb.NewLine & sDirFileCheck & Space(1) & ("Achtung, kann nicht speichern? Zugriffrechte?")
        Select Case Message.Question(sInfo, ("Ordner..."), ("Abbrechen"))
          Case 1 'Directory
            If Exist(sDirFileCheck) = True Then 
              M01Functions.FileManagerOpen(sDirFileCheck)
            Else 
              M01Functions.FileManagerOpen(Application.Path)  
            Endif 
          Case 2
            '...
        End Select
      Endif 
    Endif
    
    If Exist(sDirFile) = True Then 
      Print "FileTextPlus: ", File.Name(sDirFile), Format(Time, "hh:nn:ss.uu")
      Print "FileTextPlus-Backup:", sDirFileCopy
      sDirFileBackup = sDirFile & "_lastbackup." & File.Ext(sDirFile)
      If Exist(sDirFileBackup) = True Then Kill sDirFileBackup
      Copy sDirFile To sDirFileBackup
      If Not Error And Exist(sDirFileBackup) = True And Settings[FMain.Name &/ "F_bCheckBoxLastBackup", True] = True Then ' List —▶ FMain.mnuInfoG()
        'File-Changed List (veränderte Dateien Liste)
        If String.InStr(FMain.F_sFilesChangedList, sDirFileBackup) = 0 Then FMain.F_sFilesChangedList = FMain.F_sFilesChangedList & sDirFileBackup & gb.NewLine
      Endif 
    Else 'Error?
      Print "FileTextPlus: ", ("Fehler") & Space(1) & File.Name(sDirFileCheck), Format(Time, "hh:nn:ss.uu")
      sInfo = M01Functions.SizeRestInfo(sDirFileCheck) 'DFree()
      FMain.F_sErrorMessagesExtra = FMain.F_sErrorMessagesExtra & gb.NewLine & sDirFileCheck & Space(1) & sInfo
    Endif 
  Endif 
  
  Return sDirFile 'Rückgabe
  
Catch 
  FMain.ErrorText
  
End

Public Sub SystemDirFileToTrash(Optional sDirFile As String = "") 

  Dim sDir, sFile, sTool, sInfo, sT As String 
  
  sTool = "gio" 'Gnome Input Output
  
  ''Installed in Root?
  'sPathTool = System.Find(sTool) 'Find Program, Software, App
  
  If System.Exist(sTool) = True Then 
    ''Test:
    If sDirFile = "test" Then 'only for programmer
      sDir = User.Home &/ "testtrash" 
      sFile = "testtrash.txt"
      sDirFile = sDir &/ sFile
      If IsDir(sDir) = False Then Mkdir sDir 
      If IsDir(sDir) = True Then File.Save(sDirFile, "test trash gio")
    Endif 
    
    ''Move to trash:
    If String.InStr(sDirFile, User.Home) > 0 And Exist(sDirFile) = True Then 'only in User.Home
      ' Exec [sTool, "trash", sDirFile] Wait
      Shell sTool & Space(1) & "trash" & Space(1) & sDirFile Wait ' /dir or /dir/file.ext
      
      ''Check. Not moved in trash?
      If Exist(sDirFile) = True Then 
        If IsDir(sDirFile) = True Then sT = ("Der Ordner") Else sT = ("Die Datei")
        sInfo = sDirFile & gb.NewLine & sT & Space(1) & ("konnte nicht in den System-Papierkorb verschoben, gelöscht werden") & gb.NewLine
        If String.InStr(FMain.F_sErrorMessagesExtra, sInfo) = 0 Then FMain.F_sErrorMessagesExtra &= sInfo
      Endif 
    Endif 
  Else 
    sInfo = ("Löschen in den Papierkorb (trash). Ein Tool (Programm-Werkzeug) fehlt") & ": " & sTool & ". " & Quote(("Gnome Input Output")) & Space(1) & ("kann nachinstalliert werden mit einer Paketverwaltung wie z.B. Synaptic") & gb.NewLine
    sInfo &= "libfm4" & Space(3) & "file management support (core library)" & gb.NewLine
    If String.InStr(FMain.F_sErrorMessagesExtra, sInfo) = 0 Then FMain.F_sErrorMessagesExtra &= sInfo
  Endif
  
  ''____________________________________________________________________''
  ' "https://manpages.ubuntu.com/manpages/noble/man1/gio.1.html"
  
Catch
  FMain.ErrorText

End

Public Function CheckLatestTerminweckerTXT(Optional bInfo As Boolean = False) As String 
  
  Dim sInfo, sInfo1, sInfo2, sEmpty, sDirFile, sDirFileCurrent, sDirFileStandard As String 
  Dim iDiff As Integer
  
  ''Standard:
  sDirFileStandard = FMain.F_sPathTerminweckerStandard_txt
  If Exist(sDirFileStandard) = False Then sDirFileStandard = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", Null] 
  
  ''Current:
  sDirFileCurrent = FMain.F_sPathTerminweckerActual_txt
  If Exist(sDirFileCurrent) = False Then sDirFileCurrent = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", Null] 
  
  ''Check LastModified: File A <> File B
  If sDirFileStandard <> sDirFileCurrent And Exist(sDirFileStandard) = True And Exist(sDirFileCurrent) = True Then 
    ' If Exist(sDirFileStandard) = True Then sInfo1 = M01Functions.InfoDirFileLastModifiedSizeMimeHTML(sDirFileStandard)
    ' If Exist(sDirFileCurrent) = True Then sInfo2 = M01Functions.InfoDirFileLastModifiedSizeMimeHTML(sDirFileCurrent)
    
    sDirFile = sDirFileStandard
    If Exist(sDirFile) = True Then
      If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>" Else sEmpty = ""
      sInfo1 = File.Name(sDirFile) & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & sEmpty & "<br>"
    Endif 
    
    sDirFile = sDirFileCurrent
    If Exist(sDirFile) = True Then
      If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>" Else sEmpty = ""
      sInfo2 = File.Name(sDirFile) & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & sEmpty & "<br>"
    Endif 
    
    'A Latest and bigger > B
    iDiff = DateDiff(Stat(sDirFileCurrent).LastModified, Stat(sDirFileStandard).LastModified, gb.Second)
    ''Time Difference:
    If bInfo = True Or iDiff > 0 Then 
      ''Text, here no html
      ' sInfo = ("Info. Aktuelle Einstellung") & ": " & gb.NewLine
      ' sInfo &= gb.NewLine
      sInfo = "● " & ("Alternative Datei") & gb.NewLine
      sInfo &= File.Dir(sDirFileCurrent) & "/" & gb.NewLine & "<font color=blue>" & sInfo2 & "</font>" & gb.NewLine
      sInfo &= gb.NewLine
      sInfo &= "○ " & ("Standard Datei") & gb.NewLine
      sInfo &= File.Dir(sDirFileStandard) & "/" & gb.NewLine & "<font color=blue>" & sInfo1 & "</font>" & gb.NewLine
      ' sInfo &= gb.NewLine
      ' Form1FileOpen.ButtonDirAlternativeCopy.Text 'not forget, Button > Public=True?
      ' sInfo &= ("Menü > Datei > Öffnen... ") & ("Kopieren") & "..." & gb.NewLine 
      If String.InStr(FMain.F_sInfoMessagesExtra, sInfo) = 0 Then FMain.F_sInfoMessagesExtra &= sInfo 
    Endif
  Endif 
  
  Return sInfo
  
Catch 
  FMain.ErrorText
  
End

Public Function FileAppendText(Optional sDirFile As String = "", Optional sText As String = "") As String 
  
  Dim hFile As File
  Dim hReturn As String 
  
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(sDirFile) = False Then File.Save(sDirFile, "") 'Create File
  If Exist(sDirFile) = True And sText Then 
    Try hFile = Open sDirFile For Append
    Print #hFile, hReturn & sText
    
  Finally
    If Exist(sDirFile) Then Close #hFile
  Endif 
  
  Return sDirFile 'Rückgabe
  
Catch 
  FMain.ErrorText
  If Exist(sDirFile) Then Close #hFile
  
End

Public Function FileRefreshWithoutDoubleLines(Optional sDirFileStandard As String = "", Optional sDirFileAlternative As String = "") As String 
  
  'FileReadCompareSaveDoubleLines
  Dim ssExist As String[]
  Dim sLine, sText, sText1, sText2 As String 
  Dim hReturn As String 
  
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''File  A+B
  ssExist = New String[]
  ssExist.Sort() '> .FindSorted()
  FMain.Timer1.Stop 
  
  If Exist(sDirFileStandard) = True Then 
    ''File A:
    ''Read ########################################
    sText1 = File.Load(sDirFileStandard)
    Print sline 
    
    For Each sLine In Split(sText1 & gb.NewLine, gb.NewLine).Sort()  ''all Lines in File
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFileStandard & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      sLine = Replace(sLine, gb.Cr, "") '(*1) '\r
      If ssExist.FindSorted(sLine) < 0 Then ssExist.Add(sLine)  '< 0 not found
    Next 
    ' ########################################
  Endif 
  
  If FMain.F_bESCpressedON = False And Exist(sDirFileAlternative) = True Then 
    ''File B:
    ''Read ########################################
    sText2 = File.Load(sDirFileAlternative)
    Print sText2 
    
    For Each sLine In Split(sText2 & gb.NewLine, gb.NewLine).Sort()  ''all Lines in File
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFileStandard & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      sLine = Replace(sLine, gb.Cr, "") '(*1) '\r
      If ssExist.FindSorted(sLine) < 0 Then ssExist.Add(sLine)  '< 0 not found
    Next 
    ' ########################################
    'if /media/... then current-File > standard-File  A+B
    sText = ssExist.Join(hReturn)
  Endif
  
  If sText Then 
    sDirFileStandard = M01Functions.FileTextPlus(sDirFileStandard, sText, True) ' TRUE=overwrite (überschreiben)
    sDirFileAlternative = M01Functions.FileTextPlus(sDirFileAlternative, sText, True) ' TRUE=overwrite (überschreiben)
    ' If Exist(sDirFileStandard) = True Then Try Copy sDirFileStandard To sDirFileAlternative
    ' M01Functions.FileAppendText(sDirFileAlternative)
    ' File.Save(sDirFileStandard, ssExist.Join(hReturn))  '>CheckLatestTerminweckerTXT()
  Endif 
  
  FMain.Timer1.Start
  
  Return sDirFileStandard 'Rückgabe
  
  ''____________________________________________________''
  '(*1) Gambas3: "For example: Split(MyString, "\r\n") will split MyString by using "\r" or "\n" as separator, but not the full string "\r\n"."
  ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' = gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
  
Catch 
  FMain.ErrorText
  FMain.Timer1.Start
  
End

Public Function DemoFileTermineOrProjects(Optional sFilePathForm As String = "") As String
  
  Dim it, iQuater4 As Integer
  Dim sLine, sText, sDirFile, sDirCache, sFile As String 
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sFile = File.Name(sFilePathForm)
  sFile = String.LCase(sFile)
  If Not sFile Or File.Ext(sFile) <> "txt" Then sFile = ("demo.txt")
  
  ''Terminwecker:
  If String.InStr(sFile, String.LCase(Application.Name) & ".") > 0 Then 
    For it = 0 To 7
      hDate = DateAdd(Date, gb.Day, it)
      iQuater4 = DateDiff(Date(Year(hDate), 1, 1), hDate, gb.Quarter) 'DateDiff()as Integer 
      sLine = Format(hDate, "yyyy-mm-dd") & hTab & "00:00" & hTab & Format(hDate, "ddd") & hTab & iQuater4 & "Q" & hTab & Week(hDate) & ("KW") & hTab & ("Notiz Test ") & Str(it + 1) & hReturn
      sText = sText & sLine
    Next
    sText = sText & sLine 'Double Test
    ' sDirFile = M01Functions.ProgramDirCache(("demofile-terminwecker.txt")) 'only Path-Name
    
  Else If String.InStr(sFile, "proje") > 0 Then  
    ''Projects:
    For it = 0 To 7
      hDate = DateAdd(Date, gb.Day, it)
      iQuater4 = DateDiff(Date(Year(hDate), 1, 1), hDate, gb.Quarter) 'DateDiff()as Integer 
      sLine = Format(hDate, "yyyy-mm-dd") & hTab & "00:00" & hTab & Format(hDate, "ddd") & hTab & iQuater4 & "Q" & hTab & Week(hDate) & ("KW") & hTab & ("Notiz Test ") & Str(it + 1) 
      sLine = sLine & hTab & "00:01" & hTab & Format(hDate, "ddd") & hTab & "60" & hTab & "00:01:00" & hReturn
      sText = sText & sLine
    Next
    sText = sText & sLine 'Double Test
    
  Endif 
  
  If sText Then 
    sDirCache = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] 'Ordner  
    If IsDir(sDirCache) = False Then M01Functions.CheckDirAppName() 'as String
    If IsDir(sDirCache) = False Then sDirCache = M01Functions.TempDirectory()
    If IsDir(sDirCache) = True Then 
      sDirFile = sDirCache &/ sFile
      File.Save(sDirFile, sText)
    Endif 
  Endif
  If Exist(sDirFile) = False Then sDirFile = ""
  
  Return sDirFile
  
Catch 
  FMain.ErrorText
  
End

Public Sub MessageQuestionON(Optional sMessage As String = "", Optional sDirFile As String = "")
  
  If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If Not sMessage Then sMessage = sDirFile
  
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
    Case 1 'Directory...
      M01Functions.FileManagerOpen(sDirFile)
    Case 2 'Cancel
      '...Leerlauf 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub SystemStandardApplications()
  
  Dim sDirFile As String 
  'open picture... (external in Standard-Program, see default applications at operating system) 
  ''Program-Path:
  sDirFile = System.Find("unity-control-center")                                          'Ubuntu unity
  If Exist(sDirFile) = True Then 
    Try Shell sDirFile & Space(1) & "info"                                                'Example: png > gimp, html > firefox, ...
  Else 
    sDirFile = System.Find("gnome-control-center")                                        'Ubuntu gnome
    If Exist(sDirFile) = True Then Try Shell sDirFile & Space(1) & "default-apps"
  Endif
  
  ''______________________________________________________________________________''
  'https://manpages.ubuntu.com/manpages/artful/en/man1/gnome-control-center.1.html
  '"...path...", "datetime", "info", "search", "background", "default-apps"
  
Catch 
  FMain.ErrorText
  
End

Public Function DemoLineTerminwecker() As String
  
  Dim sDemoLine As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''Empty, Demo-Line
  sDemoLine = Format(Now, "yyyy-mm-dd") & hTab & "00:00" & hTab & Format(Now, "ddd") & hTab & "Q" & hTab & ("KW") & hTab & ("Notiz") & Space(1) & ("leer") & hReturn
  
  Return sDemoLine
  
Catch
  
  FMain.ErrorText
  
End

Public Function DemoLineProjects() As String
  
  Dim sDemoLine As String
  Dim hDate As Date 
  Dim iQuater4 As Integer
  Dim sLine, sText As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''Empty, Demo-Line
  hDate = Now
  iQuater4 = DateDiff(Date(Year(hDate), 1, 1), hDate, gb.Quarter) 'DateDiff()as Integer 
  sLine = Format(hDate, "yyyy-mm-dd") & hTab & "00:00" & hTab & Format(hDate, "ddd") & hTab & iQuater4 & "Q" & hTab & Week(hDate) & ("KW") & hTab & ("Projekt") & Space(1) & ("leer") & Str(1) 
  sLine = sLine & hTab & "00:01" & hTab & Format(hDate, "ddd") & hTab & "60" & hTab & "00:01:00" & hReturn
  sDemoLine = sText & sLine
  
  Return sDemoLine
  
Catch
  
  FMain.ErrorText
  
End

Public Function CheckFormBackgroundColorValue(Optional sLastTag As String = "") As String
  
  Dim sValue, sCorrect As String 
  
  If sLastTag Then sValue = sLastTag Else sValue = Settings[FMain.Name &/ "FormBackgroundColor", "images/bg_aluminium1.png"] 'Path or Color
  Select Case sValue
    Case "wood", "holz"
      sCorrect = "images/bg_holz2.png" 'Path or Color
      
    Case Like "*holz*.png"
      sCorrect = "images/bg_holz2.png"
      
    Case "metal", "alu"
      sCorrect = "images/bg_aluminium1.png"
      
    Case Like "*alu*.png"
      sCorrect = "images/bg_aluminium1.png"
      
      ''Color:
    Case "white" 
      sCorrect = Color.White 
      
    Case "light" ''light □
      sCorrect = Color.White 
      
    Case "dark" ''dark ■
      sCorrect = Color.DarkGray 
      
    Case "classic" ''Classic Menu-Gray
      sCorrect = Color.Background 
      
    Case "mycolorbackground" ''User
      sCorrect = Settings[FMain.Name &/ "ColorButton1.Value", Color.Background] 
      
    Case Else 'CInteger(sValue)
      If IsInteger(sValue) = True Then sCorrect = CInteger(sValue) Else sCorrect = sValue
      
  End Select
  Settings[FMain.Name &/ "FormBackgroundColor"] = sCorrect 'Path or Color
  
  Return sCorrect 'Path or Color
  
Catch 
  FMain.ErrorText
  
End

Public Function ColorCreateButton(Optional iWidth As Integer = 16, Optional iHeight As Integer = 16, Optional iColor As Integer = Color.Transparent) As Image
  
  Dim Img As Image
  Dim U, R As Float
  
  Img = New Image(iWidth, iHeight, iColor) 
  U = Img.W / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  Paint.Begin(Img)
  Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R)
  ' If bWhiteBorderON = True Then
  Paint.LineWidth = U * 1
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  ' Endif
  Paint.LineWidth = U * 0.5
  Paint.Brush = Paint.Color(Color.DarkGray)
  Paint.Stroke()
  Paint.End
  
  Return Img 
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectSumCSV(Optional sDirFile As String = "") As String
  'Rückgabe Spaltenwert
  
  Dim it2, iCounter, iSum, iNumber As Integer
  Dim ssLines, ssLineParts As String[] ' muß String sein für Split()
  Dim sText, sSeparator, sTitle, sLine As String 
  Dim sDirFileCSV, sHHMMSS As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(sDirFile) = True Then
    If isProjectFile(sDirFile, True) = True Then sText = File.Load(sDirFile)
    Print sText
  Endif
  
  If sText Then 
    'Array = Split ( Text [ , Trennzeichen , Nichttrennen ] ) 
    'Alles was zwischen zwei Nichttrennenzeichen steht ( zb in Anführungsstrichen ) wird nicht zerlegt.
    iCounter = 0
    sSeparator = hReturn
    
    If String.InStr(sText, sSeparator) > 0 Then
      ssLines = Split(sText, sSeparator) ' Stringarray
      For Each sLine In ssLines
        ssLineParts = Split(sLine & String(16, hTab), hTab) 'Auffüllen mit Trennzeichen, Mindestanzahl, Fehler vermeiden
        iNumber = 0
        If IsInteger(ssLineParts[8]) = True Then 
          iNumber = CInteger(ssLineParts[8])
          ' If TypeOf(Val(iNumber)) <= (gb.Float = False) Then
          For it2 = 2 To 16
            If ssLineParts[it2] Like "*:??:*" Then
              If IsInteger(ssLineParts[it2 - 1]) = True Then 
                iNumber = CInteger(ssLineParts[it2 - 1]) 'before...|1234|00:00:00|
                Break
              Endif
            Endif 
          Next
        Endif
        ' If TypeOf(Val(iNumber)) <= (gb.Float = True) Then 
        iSum = iSum + iNumber
        iCounter = iCounter + 1
      Next
      
      sHHMMSS = M01Functions.SecondsInfoText(iSum)
      sTitle = String(10, hTab) & hReturn ' Leere Titelzeile, Summe ab Zeile 1
      sText = sTitle & sText
      sText = sText & String(3, hReturn) & String(10, hTab) & iSum & hTab & ("Projekt-Summe in Sekunden") & hTab & hReturn
      sText = sText & String(1, hReturn) & String(10, hTab) & sHHMMSS & hTab & ("Summe im Uhrformat") & hTab & hReturn
      
    Endif
    
    sDirFileCSV = File.SetExt(sDirFile, "csv")
    sDirFileCSV = M01Functions.ProgramDirCache(sDirFileCSV) '/Ordner/~Datei.txt
    
    If IsDir(File.Dir(sDirFileCSV)) = True Then 
      If Exist(sDirFileCSV) = True Then Try Kill sDirFileCSV
      Try File.Save(sDirFileCSV, sText)
      Print sDirFileCSV
    Endif 
    
  Endif 'sText
  
  ' M01Functions.ExternStart("libreoffice", sDirFileCSV)
  M01Functions.ExternStart("", sDirFileCSV)
  
  Return sDirFileCSV
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckTimerTextWeekdays0to6(Optional sTimerText As String = "") As String
  
  Dim sDay As String
  Dim dateSunday As Date
  'sDay = System.Language ' example: "de_DE.UTF-8" deutsch
  
  ''German:
  If String.InStr(String.LCase("Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag"), String.LCase(Format(Now, "dddd"))) > 0 Then 
    If String.InStr(sTimerText, "so") > 0 Then sDay &= "So"
    If String.InStr(sTimerText, "mo") > 0 Then sDay &= "Mo"
    If String.InStr(sTimerText, "di") > 0 Then sDay &= "Di"
    If String.InStr(sTimerText, "mi") > 0 Then sDay &= "Mi"
    If String.InStr(sTimerText, "do") > 0 Then sDay &= "Do"
    If String.InStr(sTimerText, "fr") > 0 Then sDay &= "Fr"
    If String.InStr(sTimerText, "sa") > 0 Then sDay &= "Sa"
    ''English:
  Else If String.InStr(String.LCase("Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday"), String.LCase(Format(Now, "dddd"))) > 0 Then 
    If String.InStr(sTimerText, "su") > 0 Then sDay &= "Su"
    If String.InStr(sTimerText, "mo") > 0 Then sDay &= "Mo"
    If String.InStr(sTimerText, "tu") > 0 Then sDay &= "Tu"
    If String.InStr(sTimerText, "we") > 0 Then sDay &= "We"
    If String.InStr(sTimerText, "th") > 0 Then sDay &= "Th"
    If String.InStr(sTimerText, "fr") > 0 Then sDay &= "Fr"
    If String.InStr(sTimerText, "sa") > 0 Then sDay &= "Sa"
  Else 
    dateSunday = DateAdd(Now, gb.Day, 7 - WeekDay(Now)) 'as Date 'Gambas3: "This example gives the date for the next coming sunday"
    sDay &= Format(DateAdd(dateSunday, gb.day, 0), "ddd") 'So 0  gb.Sunday
    sDay &= Format(DateAdd(dateSunday, gb.day, 1), "ddd") 'Mo 1
    sDay &= Format(DateAdd(dateSunday, gb.day, 2), "ddd") 'Di 2
    sDay &= Format(DateAdd(dateSunday, gb.day, 3), "ddd") 'Mi 3
    sDay &= Format(DateAdd(dateSunday, gb.day, 4), "ddd") 'Do 4
    sDay &= Format(DateAdd(dateSunday, gb.day, 5), "ddd") 'Fr 5
    sDay &= Format(DateAdd(dateSunday, gb.day, 6), "ddd") 'Sa 6
  Endif
  Return sDay 'Rückgabewert
  
Catch 
  FMain.ErrorText
  
End

Public Sub LinkAutoStartCheck()
  
  Dim bAutostart As Boolean
  Dim sDirFile, sFound, sMessage, sHTMLspace As String
  
  sHTMLspace = "&nbsp;" 'String(5, "&nbsp;") ' Anzahl Leerzeichen
  
  M01Functions.ExternStart("gnome-session-properties") 'Startprogramme
  Wait 0.5
  
  sDirFile = Settings[FMain.Name &/ "F_sPathAutoStartDatei_desktop", FMain.F_sPathAutoStartDatei_desktop]
  
  sMessage = "<font size=5>"
  sMessage &= "<font color=blue>" & ("[Hinzufügen]") & "</font><br><br>"
  sMessage &= "<font color=blue>" & ("Name") & ": " & gb.Tab & "</font><font color=darkgreen>" & Application.Name & "</font><br>" 
  sMessage &= "<font color=blue>" & ("Befehl") & ": " & "</font><font color=darkgreen>" & Application.Name & "</font><br>" 
  sMessage &= "<font color=blue>" & ("Kommentar") & ": " & "</font><font color=darkgreen>" & Application.Name & "</font><br><br><br>" 
  sMessage &= "</font>"
  sMessage &= Application.Name & "<font color=darkgreen>" & sHTMLspace & ("''Einfügen''") & sHTMLspace & "</font>" & ("aus der [Zwischenablage], Mausklick rechts") & "<br>"
  
  If Exist(sDirFile) = True Then
    sFound = "<font color=darkgreen>" & "● " & ("gefunden") & "</font>"
  Else 
    sFound = "<font color=red>" & "○ " & ("nicht gefunden") & "</font>"
  Endif
  
  sMessage &= "<h3><b>" & ("Programmstart-Verknüpfung") & "</b><br>" & sFound & "</h3>"
  sMessage &= "<font color=gray>" & sDirFile & "</font>" & "<br>"
  If Exist(sDirFile) = True Then 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
  Endif 
  sMessage &= ("(Terminwecker automatisch mit dem Computer starten)") & "<br>"
  
  Select Case Message.Question(sMessage, "● " & ("Erstellen"), "○ " & ("Entfernen"), ("Abbrechen"))
      
    Case 1
      bAutostart = True 'erstellen
      ' Settings[FMain.Name &/ "Autostart"] = bAutostart
      M01Functions.LinkAutoStartChreate(bAutostart)
      
    Case 2
      bAutostart = False 'entfernen/löschen
      ' Settings[FMain.Name &/ "Autostart"] = bAutostart
      M01Functions.LinkAutoStartChreate(bAutostart)
      
    Case 3
      '...Leerlauf
      
  End Select
  ' Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub LinkAutoStartChreate(Optional bON As Boolean = True) 'mit Computerstart
  
  Dim sDir, sPathLink, sPathAutostart As String
  Dim sLinkText, sMessage As String
  
  'F_sPathAutoStartDatei_desktop = "/home/USER/.config/autostart/terminwecker.gambas.desktop"
  'Pfad oder Beispiel Befehl: "firefox %u" bzw. "terminwecker %u"
  ' Clipboard.Clear()
  ' Clipboard.Copy(sProgramPath) ' Copy in Clipboard (Zwischenablage)
  ' 'sMessage = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
  ' M01Functions.ExternStart("gnome-session-properties") 'Startprogramme
  ' 'gnome-session-properties 'Startprogramme
  ' sProgramPath = Application.Path &/ Application.Name & ".gambas"
  ' bOpen = M01Functions.AccessDirFileReadWrite(sPathAutostart, 1) 'as Boolean, 0=lesen, 1=schreiben
  FMain.F_sPathAutoStartDatei_desktop = Settings[FMain.Name &/ "F_sPathAutoStartDatei_desktop", FMain.F_sPathAutoStartDatei_desktop]
  sPathAutostart = FMain.F_sPathAutoStartDatei_desktop
  If Exist(sPathAutostart) = False Then 
    sPathAutostart = User.Home &/ ".config/autostart" &/ Application.Name & ".desktop"
    sDir = File.Dir(sPathAutostart)
    If IsDir(sDir) = False Then Try Mkdir sDir
    ' If M01Functions.AccessDirFileReadWrite(File.Dir(sDir), 1) = True Then Try Mkdir sDir
  Endif 
  
  If bON = False Then
    If Exist(sPathAutostart) = True Then Try Kill sPathAutostart 'Entfernen
    Wait 0.3
    sMessage = sPathAutostart & "<br>"
    If Exist(sPathAutostart) = False Then
      sMessage &= "<font color=red>" & ("Autostart-Datei nicht gefunden/entfernt.") & "</font>"
    Else 
      sMessage &= "<font color=red>" & ("Autostart-Datei konnte nicht entfernt werden.") & "</font>"
    Endif 
  Else
    ''Exist Example-File? terminwecker.desktop
    sDir = "text"
    sPathLink = sDir &/ Application.Name & ".desktop"
    
    If Exist(sPathLink) = True Then
      ' sLinkText = File.Load(sPathLink)
    Endif 
    
    If String.InStr(sLinkText, "[Desktop Entry]") = 0 Then 
      sLinkText = LinkTextDesktopEntry() 'as String
    Endif 
    
    ''Save:
    If M01Functions.AccessDirFileReadWrite(File.Dir(sPathAutostart), 1) = True Then 
      File.Save(sPathAutostart, sLinkText)
      If Exist(sPathAutostart) = True Then Settings[FMain.Name &/ "F_sPathAutoStartDatei_desktop"] = sPathAutostart
    Endif 
    Clipboard.Clear()
    Clipboard.Copy(Application.Name) ' Name "terminwecker" Copy in Clipboard (Zwischenablage)
    
    ''Check:
    If Exist(sPathAutostart) = False Then
      sMessage = "<font color=red>" & ("Autostart-Datei nicht gefunden, nicht möglich.") & "</font><br>"
      sMessage &= ("Rechte Maustaste auf Ordner. Siehe Einstellungen, Zugriffsrechte") & ": " & "<br>"
      sMessage &= "<font color=gray>" & sPathAutostart & "</font><br><br>"
      sMessage &= "<font color=blue>" & ("[Hinzufügen]") & "<br>" 
      sMessage &= ("Name") & ":<br>" 
      sMessage &= ("Befehl") & ":<br>" 
      sMessage &= ("Kommentar") & ":<br>" & "</font><br>"
      sMessage &= "<font color=darkgreen>" & ("Einfügen oder Programm-Name eintippen") & ": " & "</font>"
      sMessage &= "<font size=7 color=#" & Hex(FMain.F_iColorClockBlue, 6) & "><b>" & Application.Name & "</b></font>" 
    Endif
  Endif
  
  sMessage = sPathAutostart
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen")) 'Case 0,1,2
    Case 1 'Directory
      If Exist(sPathAutostart) = True Then 
        M01Functions.FileManagerOpen(sPathAutostart)
      Else 
        M01Functions.FileManagerOpen(File.Dir(sPathAutostart)) 
      Endif 
    Case 2 'Cancel
      '...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function LinkTextDesktopEntry() As String 
  
  Dim sLinkText, sExecutable, sPathIcon As String 
  
  sExecutable = System.Find(Application.Name) 'as String  vollständigen Pfad zurück geben Ordner/Datei
  If M01Functions.AccessDirFileReadWrite(sExecutable, 1) = True Then 'user.home/...
    sExecutable = Application.Path &/ Application.Name & ".gambas" 'Menu >Projekt>Erstellen>Ausführbare Datei gespeichert in Ordner...
    sPathIcon = Application.Path &/ Application.Name & ".png"
  Else 'Installed in System-Root
    sExecutable = Application.Name
    sPathIcon = Application.Name '& "icon.png" 'autom.
  Endif 
  
  ''Name.desktop
  sLinkText = "[Desktop Entry]" & gb.NewLine
  sLinkText &= "#Author: https://www.design-cad.de" & gb.NewLine '#Comment lines are not read
  sLinkText &= "Name=" & Application.Name & gb.NewLine
  sLinkText &= "Exec=" & sExecutable & " %F" & gb.NewLine 'FileManager "Open with..." (%f=File, %F=File-List, %u=URL)
  sLinkText &= "Comment=" & Application.Name & gb.NewLine 
  sLinkText &= "Icon=" & sPathIcon & gb.NewLine 'in Program-Directory, 256x256 Pixel?
  sLinkText &= "Type=" & "Application" & gb.NewLine
  sLinkText &= "MimeType=" & "text/plain;text/html;image/png;image/jpg;" & gb.NewLine
  sLinkText &= "Categories=" & "Calendar;Graphics;TextEditor;TextTools;Utility;" & gb.NewLine
  sLinkText &= "Keywords=" & "termin;dates;text;notes;notice;event;alarm;holidays;timerplus;txt;png;utils;clock;date;timer;graphics;pictures;images;icons;productive;creative;science;design;screenshot;" & gb.NewLine
  
  sLinkText &= "Actions=" & "QT4;QT5;QT6;GTK3;GTK4;GTK5;GTK6;" & gb.NewLine
  
  ''QT4
  sLinkText &= "[Desktop Action QT4]" & gb.NewLine
  sLinkText &= "Name=Run With QT 4" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec QT 4" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.qt4 " & Application.Name & gb.NewLine
  
  ''QT5
  sLinkText &= "[Desktop Action QT5]" & gb.NewLine
  sLinkText &= "Name=Run With QT 5" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec QT 5" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.qt5 " & Application.Name & gb.NewLine
  
  ''QT6
  sLinkText &= "[Desktop Action QT6]" & gb.NewLine
  sLinkText &= "Name=Run With QT 6" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec QT 6" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.qt6 " & Application.Name & gb.NewLine
  
  ''...................................................
  
  ''GTK3
  sLinkText &= "[Desktop Action GTK3]" & gb.NewLine
  sLinkText &= "Name=Run With GTK+ 3" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec GTK+ 3" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.gtk3 " & Application.Name & gb.NewLine
  
  ''GTK4
  sLinkText &= "[Desktop Action GTK4]" & gb.NewLine
  sLinkText &= "Name=Run With GTK+ 4" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec GTK+ 4" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.gtk4 " & Application.Name & gb.NewLine
  
  ''GTK5
  sLinkText &= "[Desktop Action GTK5]" & gb.NewLine
  sLinkText &= "Name=Run With GTK+ 5" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec GTK+ 5" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.gtk5 " & Application.Name & gb.NewLine
  
  ''GTK6
  sLinkText &= "[Desktop Action GTK6]" & gb.NewLine
  sLinkText &= "Name=Run With GTK+ 6" & gb.NewLine
  sLinkText &= "Name[fr]=Ex écuter avec GTK+ 6" & gb.NewLine
  sLinkText &= "Exec=env GB_GUI=gb.gtk6 " & Application.Name & gb.NewLine
  
  Return sLinkText
  
  'Example Gambas3: /usr/share/applications/gambas3.desktop
  
  'Example Menu>Debug (Debuggen, Ausführen, Konfiguration)
  'GB_JIT_DEBUG=1  'Debugging-Meldungen des JIT-Compilers sehen
  'GB_GUI = gb.qt5 'bevorzugte GUI (Graphical User Interface), grafische Benutzeroberflächen 
  'oder alles entfernen = ohne Angaben automatische Auswahl, was im System installiert ist.
  ' Info: IDE, Integrated Development Environment (integrierte Entwicklungs-Umgebung), Beispiel Gambas3 IDE
  
  'Example File "/usr/share/applications/terminwecker.desktop":
  ' [Desktop Entry]
  ' Version=1.0
  ' Name=terminwecker
  ' Comment=Terminwecker_3L, Date Event alarm Clock, Termine (*.txt), www.design-cad.de, Open Source (Quelltext lesbar), Freeware (Kostenlos).
  ' Exec=terminwecker
  ' Icon=terminwecker
  ' Terminal=false
  ' Type=Application
  ' StartupNotify=true
  ' Categories=Calendar;TextEditor;TextTools;Utility;
  ' MimeType=text/plain;image/png
  ' Name[en]=terminwecker
  ' Comment[en]=Terminwecker_3L, Date Event alarm Clock, Termine (*.txt), www.design-cad.de, Open Source (Quelltext lesbar), Freeware (Kostenlos).
  
  ''_________________________________________________________________________________''
  'Check in Terminal: desktop-file-validate /dir/file.desktop
  ' key "Encoding=" & "UTF-8" is deprecated
  ' key "TerminalOptions" is deprecated
  ' value "'/home/...file.gambas'" reserved character ''' outside of a quote, without ' and "
  ' https://wiki.ubuntuusers.de/.desktop-Dateien/
Catch 
  FMain.ErrorText
  
End

Public Sub LinkDesktopCreate()
  
  Dim sDir, sPathProgram, sExecutable, sPathLink, sPathDesktop, sDesktopFileText, sPathCache1 As String 
  Dim sLinkText, sPathIcon, sMessage, sMessage1, sMessage2, sMessageIcon, sSep, sPathInfo As String
  Dim picIcon As Picture
  Dim iIconSize As Integer
  
  sSep = Space(1) 'Separator, Trennzeichen 
  iIconSize = 50
  
  ''/dir/file.desktop
  sDir = Application.Path &/ "text"
  sPathLink = sDir &/ Application.Name & ".desktop"
  picIcon = M07Paint.CreateIconTerminweckerPNG(iIconSize).Picture
  
  sDir = Desktop.GetDirectory("DESKTOP")       '/home/user/DESKTOP       ("Schreibtisch")
  sPathDesktop = sDir &/ Application.Name & ".desktop"
  
  sPathProgram = System.Find(Application.Name) 'as String  vollständigen Pfad zurück geben Ordner/Datei
  If Exist(sPathProgram) = False Then sPathProgram = Application.Path &/ Application.Name & ".gambas"
  If Exist(sPathProgram) = False Then sPathProgram = User.Home &/ Application.Name &/ Application.Name & ".gambas"
  
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then 'user.home/...
    sExecutable = User.Home &/ Application.Name &/ Application.Name & ".gambas"
    sPathIcon = Application.Path &/ Application.Name & ".png"
  Else 
    sExecutable = Application.Name
    sPathIcon = Application.Name 
  Endif 
  
  If String.InStr(sLinkText, "[Desktop Entry]") = 0 Then 
    sLinkText = LinkTextDesktopEntry() 'as String
    
    ''Save:
    If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then 'user.home/...
      File.Save(sPathLink, sLinkText) 'intern: "text" &/ Application.Name & ".desktop"
    Endif 
  Endif 
  
  ''Icon □ Image:
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png" 
  If picIcon And IsDir(File.Dir(sPathCache1)) = True Then picIcon.Save(sPathCache1)
  If Exist(sPathCache1) = True Then 
    sMessageIcon = "<br>" 
    sMessageIcon &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & iIconSize & Space(1) & "height=" & iIconSize & " >" & "<br>" 
  Endif
  ''/dir/file.desktop
  If Exist(sPathDesktop) = True Then 
    sPathInfo = "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathDesktop) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPathDesktop).Size)
    sDesktopFileText = File.Load(sPathDesktop)
    sMessageIcon &= "<font color=gray>" & String.Left(sDesktopFileText, 150) & "..." & "</font>" & "<br>" 
    sMessageIcon &= "<br>" 
    sMessageIcon &= "<font color=black>" & ("Desktop-Datei (Link)") & ":" & "</font>" & "<br>"
    sMessageIcon &= "<font color=darkgreen>" & sPathDesktop & "</font>" & Space(1)
    sMessageIcon &= "<font color=gray>" & sPathInfo & "</font>" & "<br>"
  Endif 
  ''/dir/file.gambas, Exec, Application, program, software:
  If Exist(sPathProgram) = True Then 
    sPathInfo = "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathProgram) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPathProgram).Size)
    sMessageIcon &= ("Ausführbare Programm-Datei") & ":" & "<br>" 
    sMessageIcon &= "<font color=darkgreen>" & sExecutable & "</font>" & Space(1) 
    sMessageIcon &= sPathInfo & "<br>"
  Else
    sMessageIcon &= ("Eine ausführbare Programm-Datei fehlt") & ":" & "<br>" 
    sMessageIcon &= "<font color=red>" & Application.Name & ".gambas" & "</font>" & "<br>" 
  Endif 
  ''/dir/file.png, Icon Image path:
  If Exist(sPathIcon) = True Then 
    sPathInfo = "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathIcon) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPathIcon).Size)
    sMessageIcon &= ("Programm-Icon") & ":" & "<br>" 
    sMessageIcon &= "<font color=darkgreen>" & sPathIcon & "</font>" & Space(1) 
    sMessageIcon &= sPathInfo & "<br>"
  Else
    sMessageIcon &= ("Programm-Icon nicht gefunden") & ":" & "<br>" 
    sMessageIcon &= "<font color=red>" & sPathIcon & "</font>" & "<br>" 
  Endif 
  
  sMessage1 = "<h3><font color=gray>" & ("Verknüpfung (Link) auf dem Start-Bildschirm (Desktop)") & "</font></h3>" 
  sMessage1 &= "<font color=gray>"
  sMessage1 &= ("Info") & ": " 
  sMessage1 &= ("Eine Verknüpfung ist eine kleine Datei auf dem Start-Bildschirm, hinter einem Symbol-Bild/Icon.") & sSep & ("Wird das kleine Symbol-Bild angeklickt, startet das Programm.") 
  sMessage1 &= "</font>" & "<br>" 
  
  sMessage2 = "<font color=gray>" & ("Symbol-Bild/Icon markieren, Rechtsklick > Maus-Menü") & ": " & "</font>"
  sMessage2 &= "<h3>" 
  sMessage2 &= ("Siehe Datei-Eigenschaften") & ": " & sSep & "<b><i><font color=darkgreen>" & ("Datei als Programm ausführen") & "</font></i></b><br>" 
  sMessage2 &= ("Oder") & ": " & sSep & "<b><i><font color=darkgreen>" & ("Start erlauben") & "</font></i></b>"
  sMessage2 &= "</h3>"
  
  sMessage = sMessage1 & sMessageIcon & sMessage2
  ' "xdg-desktop-icon" ' Debian: "Installieren von Symbolen auf der Arbeitsfläche des Anwenders"
  
  ''Create?
  If Exist(sPathDesktop) = False Then
    Select Case Message.Question(sMessage, "● " & ("Symbol erstellen"), ("Abbrechen"))
      Case 1 'Create Link (Symbol erstellen):
        File.Save(sPathDesktop, sLinkText)
        If Exist(sPathDesktop) = False Then Try Link sPathProgram To sPathDesktop '(*1)
        
      Case 2 'Cancel (Abbrechen):
        sMessage = "JumpEnd"
    End Select
    If sMessage = "JumpEnd" Then Goto JumpEnd 'Goto not in Loop
  Else
    ''Delete?
    sMessage = sMessage1 
    sMessage &= sMessageIcon & "<br>" 
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Die Datei existiert schon") & ": " & "</font></h3>" 
    sMessage &= "<font color=darkgreen>" & sPathDesktop & "</font><br>" 
    sMessage &= sMessage2
    
    Select Case Message.Question(sMessage, "● " & ("Überschreiben (erneuern)"), "○ " & ("Verknüpfung entfernen"), ("Abbrechen"))
        
      Case 1 ''Create Link (Überschreiben (erneuern)):
        sMessage = Null 'Reset
        If Exist(sPathDesktop) = True Then Try Kill sPathDesktop
        File.Save(sPathDesktop, sLinkText)
        If Exist(sPathDesktop) = False Then Try Link sPathProgram To sPathDesktop
        
      Case 2 ''Delete Link (Verknüpfung entfernen):
        sMessage = Null 'Reset
        If Exist(sPathDesktop) = True Then Try Kill sPathDesktop
        If Exist(sPathDesktop) = True Then 'Error?
          sMessage = sPathDesktop & "<br>"
          sMessage &= ("Entfernt") & ": " & "<font color=red><b>" & ("Nein") & "</b></font><br><br>" 
          sMessage &= ("Die kleine Verknüpfungs-Datei auf dem Start-Bildschirm (Desktop) konnte nicht entfernt werden.") 
          Message.Info(sMessage, ("Abbrechen"))
        Endif  
        
      Case 3 'Cancel (Abbrechen):
        sMessage = "JumpEnd"
        
    End Select
  Endif 
  If sMessage = "JumpEnd" Then Goto JumpEnd
  
  ''Check:
  sMessage = Null 'Reset
  If Exist(sPathDesktop) = True Then
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Symbol gefunden") & "</font></h3>"
  Else 
    sMessage &= "<h3><font color=red>" & "● " & ("Symbol nicht gefunden") & "</font></h3>"
  Endif 
  sMessage &= "<font color=darkgreen>" & sPathDesktop & "</font><br>"
  
  Select Case Message.Question(sMessage, "● " & ("Ordner..."), ("Abbrechen"))
    Case 1 'Ordner...
      If Exist(sPathDesktop) = True Then 
        M01Functions.FileManagerOpen(sPathDesktop)
      Else 
        M01Functions.FileManagerOpen(File.Dir(sPathDesktop))  
      Endif 
      
    Case 2 'Cancel (Abbrechen):
      '...
      
  End Select
  
JumpEnd:
  
Catch
  FMain.ErrorText
  ''_______________________________________________________________________________________________''
  ''(*1) Info Quelle: gambas3 hilfe > https://manpages.debian.org/buster/manpages-de/ln.1.de.html
  ''Shell "ln --help" 'gibt unten in der Konsole wie Print den Text aus zum Nachlesen. 
  
  ''Example Gambas3: /usr/share/applications/gambas3.desktop
  
  ' DesktopFile
  ' Gambas3: "For a good example take a look at the gambas.desktop file that installs when you install Gambas..."
  ' 
  ' [Desktop Entry]
  ' Name=Gambas 3
  ' Exec=gambas3
  ' GenericName=Gambas 3 IDE
  ' GenericName[fr]=EDI Gambas 3
  ' GenericName[ru]=Gambas 3 IDE(ИСР)
  ' Comment=Gambas3 Integrated Development Environment
  ' Comment[fr]=Environnement de développement intégré Gambas 3
  ' Comment[ru]=Gambas 3 IDE(ИСР) - альтернатива для Visual Basic
  ' Icon=gambas3
  ' Terminal=false
  ' Type=Application
  ' Categories=Development;IDE;
  ' StartupNotify=true
  ' Actions=QT4;QT5;GTK3
  ' 
  ' [Desktop Action QT4]
  ' Name=Run with QT 4
  ' Name[fr]=Exécuter avec QT 4
  ' Exec=env GB_GUI=gb.qt4 gambas3
  ' 
  ' [Desktop Action QT5]
  ' Name=Run with QT 5
  ' Name[fr]=Exécuter avec QT 5
  ' Exec=env GB_GUI=gb.qt5 gambas3
  ' 
  ' [Desktop Action GTK3]
  ' Name=Run with GTK+ 3
  ' Name[fr]=Exécuter avec GTK+ 3
  ' Exec=env GB_GUI=gb.gtk3 gambas3
  
End

Public Function LinkDesktopExist() As String 
  
  Dim sDir, sPath As String
  
  sDir = Desktop.GetDirectory("DESKTOP") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  sPath = sDir &/ Application.Name & ".desktop"
  ' sPath = sDir &/ Application.Name & ".gambas"
  If Exist(sPath) = False Then sPath = ""
  
  Return sPath  'Example: /home/user/desktop/terminwecker.desktop
  
Catch 
  FMain.ErrorText
  
End

Public Function SoftwareCheckUpdateTXT() As String 
  
  Dim hHTTPClient As HttpClient 'needs component: "gb.net.curl" 
  Dim sURL, sDir, sFile, sDirFile, sText As String 
  
  sDir = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache()
  sFile = "terminwecker3linux_info-version-nr.txt"
  ' sDirFile = M01Functions.ProgramDirCache(sFile)
  
  '**********************************************************
  ''From HOMEPAGE in Internet-Online:
  sURL = "https://www.design-cad.de/cad-design/software/" & sFile
  ''DOWNLOAD To User-Computer in Directory:
  sDirFile = sDir &/ sFile
  '**********************************************************
  ' If Exist(sDirFile) = True Then 
  '   sDirFileOld = File.Dir(sDirFile) &/ File.BaseName(sDirFile) & Format(Stat(sDirFile).LastModified, "yyyy-mm-dd-hh-nn-ss") & "." & File.Ext(sDirFile)
  '   Copy sDirFile To sDirFileOld
  '   If Exist(sDirFile) = True Then Kill sDirFile
  ' Endif 
    
  hHTTPClient = New HttpClient As "hHTTPClient" 'needs component: (gb.net.curl)
  hHttpClient.URL = sURL 
  hHTTPClient.Async = False
  hHTTPClient.Timeout = 3 'Seconds. Gambas3: "Do not forget to set this property if you are doing a synchronous request, otherwise the client may wait for the server forever!"
  Try hHTTPClient.Get([], sDirFile)
  
  ''Check:
  If Exist(sDirFile) = True Then ' hHTTPClient.Status > -1 Then  'Gambas3: "Const Inactive As Integer = 0"
    sText = File.Load(sDirFile)
    If sText Like "*" & Application.Version & "*" Then sDirFile = Null
    sText = Replace(sText, Space(1), "")
    If IsInteger(String.Left(sText, 1)) = False Then sDirFile = Null 'first sign is no number. html-Errortext or other?
  Else 
    sDirFile = Null
  Endif 
  
  If Exist(sDirFile) = False Then sText = Null
  
  Return sText
  
  'Example Internet:
  ' If Not Component.IsLoaded("gb.net.curl") Then Component.Load("gb.net.curl")
  ' File.save("/tmp/test.png", Object.New("HttpClient").Download("https://gambas.one/files/test.png"))
  
Catch 
  FMain.ErrorText
  
End

Public Function SoftwareDownloadInternetVersionNumberTXT() As String 
  
  Dim hHTTPClient As HttpClient 'needs component: "gb.net.curl" 
  Dim sURL, sDir, sFile, sDirFile As String 
  
  sDir = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache()
  sFile = "terminwecker3linux_info-version-nr.txt"
  
  '**********************************************************
  ''From HOMEPAGE in Internet-Online:
  sURL = "https://www.design-cad.de/cad-design/software" &/ sFile
  ''DOWNLOAD To User-Computer in Directory:
  sDirFile = sDir &/ sFile
  '**********************************************************
  
  hHTTPClient = New HttpClient As "hHTTPClient" 'needs component: (gb.net.curl)
  hHttpClient.URL = sURL
  hHTTPClient.Async = False
  hHTTPClient.Timeout = 10
  Try hHTTPClient.Get([], sDirFile)
  
  ''Check:
  If Exist(sDirFile) = True Then 
    If Stat(sDirFile).Size = 0 Then sDirFile = Null
  Else 
    sDirFile = Null
  Endif 
  
  Return sDirFile
  
  'Example Internet:
  ' If Not Component.IsLoaded("gb.net.curl") Then Component.Load("gb.net.curl")
  ' File.save("/tmp/test.png", Object.New("HttpClient").Download("https://gambas.one/files/test.png"))
  
Catch 
  FMain.ErrorText
  
End

Public Function SoftwareDownloadInternetPackageDEB() As String 
  
  Dim hHTTPClient As HttpClient 'needs component: "gb.net.curl" 
  Dim sURL, sDir, sFile, sDirFile As String 
  
  sDir = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache()
  sFile = "terminwecker3linux_entpacken_.deb" 'ca. 3MB
  sDirFile = sDir &/ sFile
  
  '**********************************************************
  ''From HOMEPAGE in Internet-Online:
  sURL = "https://www.design-cad.de/cad-design/software/" & sFile
  ''DOWNLOAD To User-Computer in Directory:
  sDirFile = sDir &/ sFile
  '**********************************************************
  
  hHTTPClient = New HttpClient As "hHTTPClient"
  hHttpClient.URL = sURL
  hHTTPClient.Async = False
  hHTTPClient.Timeout = 10
  Try hHTTPClient.Get([], sDirFile)
  
  ''Check:
  If Exist(sDirFile) = True Then 
    If Stat(sDirFile).Size = 0 Then sDirFile = Null
  Else 
    sDirFile = Null
  Endif 
  
  Return sDirFile
  
  'Example Internet:
  ' If Not Component.IsLoaded("gb.net.curl") Then Component.Load("gb.net.curl")
  ' File.save("/tmp/test.png", Object.New("HttpClient").Download("https://gambas.one/files/test.png"))
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoftwareDeInstall()
  
  Dim sDir, sDirFile, sDirFileLatest, sSoftwareCenter, sPackage, sDirUser As String
  Dim sMessage, sValue, sRemoveText, sList As String 
  Dim dateDeInstall As Date 
  Dim iDiff, it As Integer
  Dim ssSpli As String[]
  
  sDir = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  ' For Each sFile In Dir(sDir, "*" & Application.Name & "*.deb")
  '   sList &= sFile & gb.NewLine
  ' Next 
  If Not sList Then 
    'Search in Sub-Directories (Recursively, Rekursiv):
    sDir = User.Home
    ssSpli = RDir(sDir, "*" & Application.Name & "*.deb", gb.Directory + gb.File).Sort()
    For it = 0 To ssSpli.Max ' Alternative: gb.File + gb.Directory
      sDirFile = sDir &/ ssSpli[it]
      If Not sDirFileLatest Then 
        sDirFileLatest = sDirFile
      Else If Exist(sDirFile) = True And Exist(sDirFileLatest) = True Then 
        If Stat(sDirFile).LastModified > Stat(sDirFileLatest).LastModified Then sDirFileLatest = sDirFile 
      Endif
      sList &= sDirFile & gb.NewLine
    Next 
    If Not sList Then sList = ("Keine")
    If String.Len(sList) > 300 Then sList = String.Left(sList, 500) & "..."
  Endif 
  ' sFile = "terminwecker3linux_entpacken_.deb" 'ca. 3MB
  'Software: Stable Version installed? Stable Version de-install. 
  ' sDirFile = sDir &/ sFile
  
  If Exist(sDirFileLatest) = True Then sPackage = sDirFileLatest
  
  sDirUser = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If Exist(sDirUser) = False Then sDirUser = ("Fehlt") & Space(3) & sDirUser
  
  sMessage = "<h2><font color=darkgray><b>" & Application.Name & "</b></font></h2>" 
  sMessage &= "<h3><font color=gray>" & ("Die installierte Software wieder entfernen im") & Space(1) & "</font><font color=orangered><b>" & ("Software-Center") & "</b></font>" & "</h3>"
  
  sMessage &= "<font color=darkgray>" & ("Gefundene Pakete im Ordner (Download?)") & ": " & "</font>" & "<br>"
  sMessage &= "<font color=gray>" & sList & "</font>" & "<br>" & "<br>"
  If Exist(sPackage) = True Then 
    sMessage &= ("Neuestes Paket") & ": " & "<br>" 
    sMessage &= "<font color=blue>" & sPackage & "</font>" & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPackage) & "</b></font>" & "<br>" & "<br>" 
  Endif 
  
  sMessage &= "○" & Space(1) & ("Ordner...") & Space(1) & ("mit eigenen Dateien selber löschen") & "<br>"
  sMessage &= sDirUser & "<br>"
  sMessage &= "<br>"
  sMessage &= "<font color=blue><b>" & "●" & Space(1) & Application.Name & "</b></font>" & "<br>"
  sMessage &= "1. " & ("Beenden") & "<br>"
  sMessage &= "2. " & ("Entfernen im") & Space(1) & "<b>" & ("Software-Center") & "</b>" & "<br>"
  
  If Exist(FMain.F_sPathAutoStartDatei_desktop) = True Then 
    sMessage &= "<font color=gray>"
    sMessage &= "<h3>" & ("Programmstart-Verknüpfung") & Space(1) & ("gefunden") & "</h3>"
    sMessage &= "<b>" & ("Vorher löschen!") & "</b>" & Space(1) & ("Siehe...Menu...Autostart...") & "<br>"
    sMessage &= ("(Terminwecker automatisch mit dem Computer starten)") & "<br>"
    sMessage &= FMain.F_sPathAutoStartDatei_desktop 
    sMessage &= "</font><br>"
  Endif 
  
  dateDeInstall = Settings[FMain.Name &/ "SoftwareDeInstallAlternativeDate", Now] 
  If dateDeInstall Then iDiff = DateDiff(dateDeInstall, Now, gb.Hour)
  
  ''Alternative 1+2:
  If iDiff < 1 Then 
    Settings[FMain.Name &/ "SoftwareDeInstallAlternativeDate"] = Now
    sValue = System.Find("apt")
    If Exist(sValue) = True Then sRemoveText = "sudo apt remove terminwecker"
    sValue = System.Find("dpkg")
    If Exist(sValue) = True Then sRemoveText = "sudo dpkg --remove terminwecker"
    Clipboard.Copy(sRemoveText)
    
    ''Alternative 1:
    sMessage &= "<h3><font color=darkgreen><b>" & ("Alternative 1") & ": " & "</b></font></h3>" 
    sMessage &= "<font color=gray>" 
    sMessage &= ("Eine Software vom Typ") & Space(1) & "<b>" & ("Paketverwaltung") & "</b>" & Space(1) & ("für andere Software installieren im") & Space(1) & "<b>" & ("Software-Center") & "</b>" & "<br>"
    sMessage &= ("Wort in Suche") & ": " & "<font color=blue><b>" & Application.Name & "</b></font>" & "<br>"
    
    sValue = System.Find("synaptic")
    If Exist(sValue) = True Then 
      sMessage &= ("Gefunden") & ": " & "<font color=orangered><b>" & "Synaptic" & "</b></font>" & "-" & ("Paketverwaltung") & "<br>"
    Endif 
    
    ''Alternative 2:
    ' Try Shell "apt list terminwecker" To sValue 'short Info-Line
    sMessage &= "<h3><font color=darkgreen><b>" & ("Alternative 2") & ": " & "</b></font></h3>"
    sMessage &= ("Vorinstallierte Hilfsprogramme. Terminal aus 'Anwendungen' starten") & " <font color=black><b>" & ">_" & "</b></font><br>"
    sMessage &= "<b>" & ">_" & " </b>" & ("Eingabe in die Befehlszeile") & ": " & "<br>"
    sMessage &= "<font color=red><b>" & Quote(sRemoveText) & "</b></font><br>" 'Terminal Hilfsprogram ">_"
    sMessage &= ("[Kopie aus Zwischenablage einfügen, rechte Maustaste]") & "<br>"
    sMessage &= ("Danach folgt die Bestätigung durch die Passwort-Anfrage") & "." & "<br>"
    sMessage &= "</font>" 
  Endif 
  
  Select Case Message.Question(sMessage, "○" & Space(1) & ("Ordner..."), "●" & Space(1) & ("Löschen + Beenden..."), ("Abbrechen"))
      
    Case 1 'Directory (Ordner)
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      M01Functions.FileManagerOpen(sDir)
      
    Case 2 'Delete, De-Install
      FMain.F_sPathAutoStartDatei_desktop = Settings[FMain.Name &/ "F_sPathAutoStartDatei_desktop", FMain.F_sPathAutoStartDatei_desktop]
      If Exist(FMain.F_sPathAutoStartDatei_desktop) = True Then Try Kill FMain.F_sPathAutoStartDatei_desktop
      
      ''Software-Center  *.deb > Install > De-Install
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("snap-store")
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("gnome-software")
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("ubuntu-software")
      If sSoftwareCenter = "" Then 
        sSoftwareCenter = System.Find("gnome-control-center")
        If sSoftwareCenter <> "" Then sSoftwareCenter = sSoftwareCenter & Space(1) & "applications"
      Endif 
      
      If sSoftwareCenter <> "" Then 
        Shell sSoftwareCenter  ' "gnome-control-center applications" 
      Else 
        Desktop.Open(sPackage) 'start Software-Center with File /dir/file.deb
      Endif 
      Wait 2
      
      If Desktop.Platform = "x11" Then FMain.Window.Stacking = Window.Above '▲
      ''********************************
      FMain.Window.Close() 'Quit this program
      ''********************************
      
    Case 3 'Cancel (Abbrechen)
      ''...
  End Select
  
  ''__________________________________________________________________________________''
  ''Install and De-Install. About "rpm" or "apt" / "dpkg", not parallel? "/var/lib/rpm"
  
Catch
  FMain.ErrorText
  
End

Public Function StretchPicture(hPicture As Picture, Optional iWidth As Integer = 160, Optional iHeight As Integer = 120) As Picture
  'Beispiel Aufruf: PictureBox1.Picture = M01Functions.StretchPicture(PictureBox1.Picture, 160, 120)
  
  If Not hPicture Then 
    hPicture = New Picture(iWidth, iHeight, True) 'True = Transparent
  Else
    hPicture = hPicture.Image.Stretch(iWidth, iHeight).Picture 'umwandeln > Image > Picture, anpassen
  Endif 
  'bei .png keine Qualitätsangabe, sonst Fehler   
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .save(JPG-Datei, Qualität1bis100)
  Return hPicture 'as Picture 'Rückgabe
  
Catch 
  FMain.ErrorText
  
End

Public Function StretchImage(hImage As Image, Optional iWidth As Integer = 160, Optional iHeight As Integer = 120) As Image
  'Beispiel Aufruf: hImage = M01Functions.StretchImage(PictureBox1.Picture.Image, 160, 120)
  
  If Not hImage Then 
    hImage = New Image(iWidth, iHeight, Color.Transparent) 
  Else
    hImage = hImage.Stretch(iWidth, iHeight)
  Endif 
  'bei .png keine Qualitätsangabe, sonst Fehler   
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .save(JPG-Datei, Qualität1bis100)
  Return hImage 'as Image 'Rückgabe
  
Catch 
  FMain.ErrorText
  
End

Public Function FilesDeleteWithPlaceholder(Optional sDir As String = "", Optional sPattern As String = "*temp_*.*") As String
  
  Dim sFile, sDirFileDelete, sText As String
  
  If IsDir(sDir) = True And sPattern Then 
    'alle Dateien löschen
    'RDir (Ordner, Pattern*.*, gb.Directory und/oder gb.File)
    ' Pattern "*.*" nur Dateien mit Endung werden gelöscht
    ' Pattern "*" auch Dateien ohne Endung werden gelöscht
    For Each sFile In RDir(sDir, sPattern, gb.File)   
      sDirFileDelete = sDir &/ sFile                  
      If String.InStr(FMain.F_sTempDateien, sDirFileDelete) > 0 Then 'nur vom Programm erstellte Dateien, Liste F_sTempDateien
        Try Kill sDirFileDelete
        If Exist(sDirFileDelete) = False Then sText = sText & gb.NewLine & sDirFileDelete
      Endif
    Next
  Endif
  
  Return sText 'Rückgabe gelöschter Dateien für Info
  
Catch 
  FMain.ErrorText
  
End

Public Function FileExistQuestionText(Optional sDirFile As String = "") As String
  
  Dim sFilesExist As String
  
  If Exist(sDirFile) = False Then
    sFilesExist = ""
  Else
    sFilesExist = ("Die Datei ist schon vorhanden. Überschreiben?") 
  Endif
  Return sFilesExist 'Rückgabetext
  
Catch 
  FMain.ErrorText
  
End

Public Function TimeDiffsecondClock1Clock2(Optional sTime1hhnn As String = "", Optional sTime2hhnn As String = "") As Integer 'ungenutzt?
  
  Dim iSecond As Integer
  
  If sTime1hhnn Like "??:??" And sTime2hhnn Like "??:??" Then
    Try iSecond = DateDiff(CDate(sTime1hhnn), CDate(sTime2hhnn), gb.Second)
  Else
    iSecond = 0
  Endif
  Return iSecond 'Rückgabe als Zahl
  
  ''__________________________________________________________________________________''
  'Gambas3, CDate(): "Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Zeit ist unabhängig von lokalen Einstellungen. Eingabe wird geprüft 00:00
Catch 
  FMain.ErrorText
  
End

Public Function TimeSystemBootStart() As Date 
  
  Dim sTool, sYYYYMMDDHHMMSS As String 
  Dim dateBoot As Date 
  
  sTool = "uptime"  
  If System.Exist(sTool) = False Then sTool = System.Find(sTool)
  If sTool Then 
    Shell sTool & Space(1) & "-s" To sYYYYMMDDHHMMSS 
    '-s, --since     'System ist hochgefahren seit, im Format »yyyy-mm-dd HH:MM:SS«
    If sYYYYMMDDHHMMSS Then 
      sYYYYMMDDHHMMSS = Replace(sYYYYMMDDHHMMSS, gb.NewLine, "")
      dateBoot = M01Functions.DateCheckyyyymmddhhnn(sYYYYMMDDHHMMSS)
    Endif 
  Endif
  
  Return dateBoot
  'uptime ist in procps enthalten, in allen ubuntus
  'uptime - feststellen, wie lange das System schon läuft
  'https://manpages.ubuntu.com/manpages/impish/de/man1/uptime.1.html
Catch 
  FMain.ErrorText
  
End

Public Sub FileToForm3Text(Optional sDirFile As String = "")
  
  If Exist(sDirFile) = False Then
    Message.Info(sDirFile & "<br>" & "<br>" & "<font color=red>" & ("Datei nicht gefunden") & "." & "</font>")
  Else
    Form3Text.Tag = sDirFile ' Path or Text
    Form3Text.Window.Show
    ' Form3Text.Window.Visible = True  'Wayland error?
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function FileNameCheckWithoutLastbackup(Optional sDirFile As String = "") As String
  
  Dim sFile, sMessage As String 
  
  ''Check File-Name:
  
  If Exist(sDirFile) = True Then 
    sFile = File.Name(sDirFile)
    If sFile Like "*" & "_lastbackup" & "*" Or sFile Like "*" & "_oldyears" & "*" Then 
      sMessage = "<h3><font color=red><b>" & sDirFile & "</b></font></h3>"
      sMessage &= "<h3><font color=darkgreen>" & ("Einen Datei-Namen wählen ohne") & ":" "</b></font></h3>" 
      sMessage &= "<font color=red><b>" & "_lastbackup" & "</b></font></h3>"
      sMessage &= "<font color=red><b>" & "_oldyears" & "</b></font></h3>"
      sMessage &= "<h3><font color=black><b>" & "○ " & ("Abbrechen") & "</b></font></h3>"
      sMessage &= "<h3><font color=gray>" & "..." & ("und speichern unter einem anderen Datei-Namen") & "</font></h3>"
      
      Select Message.Question(sMessage, ("Ordner..."), "○ " & ("Abbrechen"))
        Case 1
          M01Functions.FileManagerOpen(sDirFile)
          sDirFile = ""
        Case 2 'Cancel:
          sDirFile = ""
      End Select
    Endif
  Endif 
  
  Return sDirFile ' /Dir/File.ext or Empty
  
Catch 
  FMain.ErrorText
  
End

Public Function FileTempDirFileTxt(Optional sFileName As String = "") As String
  
  Dim sDir, sDirFileNew As String 
  'Temp() = "/tmp/gambas.[User id]/[Process id]/[Name].tmp"
  'Nach dem Beenden des Programms werden die Dateien im Ordner M01Functions.CheckDirectoryCache() automatisch entfernt
  sDir = M01Functions.CheckDirectoryCache() 'Dir/File & "tmp"
  ' If String.InStr(sFileName, "/") > 0 Then 
  sDirFileNew = sDir &/ File.Name(sFileName)
  sDirFileNew = File.SetExt(sDirFileNew, "txt") '"tmp" > "txt"
  'Example:/tmp/gambas.501/14593/sFile.tmp   Ohne Name 1.tmp, 2.tmp...  File.SetExt(sDirFileExt, sExt)
  
  Return sDirFileNew  'Expample sPath = M01Functions.FileTempDirFileTxt()  "/Dir/File.txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function TempDirFile(Optional sDirFile As String = "") As String 'unused
  
  Dim sTempPath, sDir, sFile, sDirTempFile As String
  
  sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  sFile = ("temp_") & Replace(sFile, "temp_", "") 'not double
  If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache()
  If IsDir(sDir) = False Or M01Functions.AccessDirFileReadWrite(sDirFile, 1) = False Then 
    sTempPath = Temp() 'Example: /dir/.../1.tmp
    sDir = File.Dir(sTempPath) 
    sFile = File.BaseName(sFile) & "." & File.Ext(sFile)
    File.Save(sDir &/ sFile, Null) 
  Endif 
  sDirTempFile = sDir &/ sFile
  If String.InStr(FMain.F_sTempDateien, sDirTempFile) = 0 Then FMain.F_sTempDateien = FMain.F_sTempDateien & gb.NewLine & sDirTempFile
  Return sDirTempFile ' Example: /Directory/temp_filename.txt
  
Catch 
  FMain.ErrorText
  
End

Public Function ProgramDirCache(Optional sFile As String = "") As String '/DirCache/file.ext
  
  Dim sDir, sDirTempFile As String
  
  sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
  
  If IsDir(sDir) = False Then 
    If IsDir(FMain.F_sDirAppName) = False Then M01Functions.CheckDirAppName() 'as String
    If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache() 'as String
    If IsDir(sDir) = False Then sDir = Desktop.GetDirectory("PICTURES") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS
    If IsDir(sDir) = False Then sDir = M01Functions.TempDirectory()
  Endif 
  
  If File.Ext(sFile) <> "" And IsDir(sFile) = False Then sDirTempFile = File.SetDir(sFile, sDir)
  
  If String.InStr(FMain.F_sTempDateien, sDirTempFile) = 0 Then FMain.F_sTempDateien = FMain.F_sTempDateien & gb.NewLine & sDirTempFile
  
  Return sDirTempFile ' Example: /Directory/temp_filename.txt
  
Catch 
  FMain.ErrorText
  
End

Public Function FileBasisHTML(Optional sInputText As String = "") As String 
  
  Dim sHTML As String 
  
  sHTML = "<!DOCTYPE html>" & gb.NewLine 'html5 neu
  sHTML &= "<html lang=de>" & gb.NewLine
  sHTML &= "<head>" & gb.NewLine
  sHTML &= "<meta http-equiv=Language content=de>" & gb.NewLine
  sHTML &= "<meta http-equiv=Content-Type content=" & Chr(34) & "text/html;CHARSET=utf-8" & Chr(34) & ">" & gb.NewLine
  sHTML &= "<meta name=software content=" & Application.Name & ">" & gb.NewLine 
  sHTML &= "<meta name=publisher content=design-cad.de>" & gb.NewLine 'or name=author
  sHTML &= "<title>" & Application.Name & "</title>" & gb.NewLine
  sHTML &= "</head>" & gb.NewLine
  
  sHTML &= "<body><font face=" & Chr(34) & "arial, sans-serif, freesans, ubuntu" & Chr(34) & "> " & gb.NewLine
  sHTML &= sInputText & gb.NewLine
  sHTML &= "</font></body></html>" & gb.NewLine
  
  Return sHTML
  
Catch 
  FMain.ErrorText
  
End

Public Function MusicStartStop(Optional sDirFile As String = "", bONoff As Boolean = True) As String 
  'Siehe Projekt, Eigenschaften, Komponenten. gb.sdl.sound muß aktiviert sein
  
  Dim sDir, sFile, sDirSub As String 
  Dim ssSpli As String[]
  
  If Component.IsLoaded("gb.sdl2.audio") Then 'neue Komponente
    
    If bONoff = True Then
      If Exist(sDirFile) = False Then 
        M01Functions.CheckDirMusic()
        sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent] ''USB-Stick?
        sDirSub = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic]
        If String.InStr(sDir, sDirSub) > 0 Then sDir = sDirSub
        If IsDir(sDir) = False Then sDir = "music" 'Program-Directory
        
        ''Plusalarm
        If sDirFile = "Plus" Then 
          sDirFile = Settings[FMain.Name &/ "F_sPathMusicPlusAlarm_wav", "Standard"]
          If Exist(sDirFile) = False Then 
            sFile = "clockplusalarm.wav"
            sDirFile = sDir &/ sFile
          Endif 
          If Exist(sDirFile) = False Then 
            ''Search alternative
            ssSpli = Dir(sDir, "*clockplusalarm*.{mp3,mid,wav,ogg}", gb.File)
            If ssSpli.Empty = False Then sFile = ssSpli.First
            If Exist(sDir &/ sFile) = True Then sDirFile = sDir &/ sFile
          Endif
        Endif 
        
        ''Clockalarm
        If sDirFile = "" Or sDirFile = "Standard" Then 
          sDirFile = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"]
          If Exist(sDirFile) = False Then 
            sFile = "clockalarm.mp3"
            sDirFile = sDir &/ sFile
          Endif
          If Exist(sDirFile) = False Then
            ''Search alternative
            ssSpli = Dir(sDir, "*clockalarm*.{mp3,mid,wav,ogg}", gb.File)
            If ssSpli.Empty = False Then sFile = ssSpli.First
            If Exist(sDir &/ sFile) = True Then sDirFile = sDir &/ sFile
          Endif
        Endif 
        
        If Exist(sDirFile) = False Then 
          sDir = "music" 
          sDirFile = sDir &/ sFile 
        Endif 
      Endif 
      
      ''Play Music
      If Exist(sDirFile) = True Then 
        Music.Load(sDirFile) 'Music.Play > needs component: (gb.sdl2.audio) (*1)
        Music.Play(1, 0) 'Play ( [ Loops As Integer, FadeIn As Float ] ) (1x, Default 0)
      Endif 
    Else
      sDirFile = ""
      If Music.State > 0 Then Music.Stop()
    Endif
  Endif 
  
  Return sDirFile 
  
Catch 
  FMain.ErrorText
  ''___________________________________________________________________________''
  '(*1) Music.Play(1,0) > (Loop 1x, default 0) needs component: (gb.sdl2.audio)
  'Quelle Gambas3: The music file format can be: WAV, OGG or MP3.
  'Music.Stop()
  'Read Status: iInfo = Music.State 'as Integer  '< Music.Stopped, Music.Playing, Music.Paused 'as Integer Constanten
  
End

Public Sub CheckDirMusic()
  
  Dim sDirFile, sDirFileCopy, sFile, sDirCurrent, sDirMusic As String 
  
  ''Directory Terminwecker?
  sDirMusic = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic]
  If IsDir(sDirMusic) = True Then 
    sDirFile = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"]
    If sDirFile = "Standard" Then sDirFile = "music/clockalarmmusic.mp3"
    sFile = File.Name(sDirFile)
    sDirFileCopy = sDirMusic &/ sFile 
    If Exist(sDirFile) = True And Exist(sDirFileCopy) = False Then Copy sDirFile To sDirFileCopy
    
    sDirFile = Settings[FMain.Name &/ "F_sPathMusicPlusAlarm_wav", FMain.F_sPathMusicPlusAlarm_wav]
    sFile = File.Name(sDirFile)
    sDirFileCopy = sDirMusic &/ sFile 
    If Exist(sDirFile) = True And Exist(sDirFileCopy) = False Then Copy sDirFile To sDirFileCopy
  Endif 
  
  ''Directory USB?
  If Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = True Then 
    sDirCurrent = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
    If IsDir(sDirCurrent) = True Then 
      sDirFileCopy = sDirCurrent &/ sFile 
      If Exist(sDirFile) = True And Exist(sDirFileCopy) = False Then Copy sDirFile To sDirFileCopy
      
      sDirFile = "music/clockplusalarm.wav"
      sFile = File.Name(sDirFile)
      sDirFileCopy = sDirCurrent &/ sFile 
      If Exist(sDirFile) = True And Exist(sDirFileCopy) = False Then Copy sDirFile To sDirFileCopy
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusicSelectionDialog()
  
  Dim sDir, sDirFile, sStandardPath, sMessage, sTool, sStandardONoff, sSelectONoff, sInfo1, sInfo2 As String
  Dim ssFilter As New String[]
  
  ssFilter.Add("*.ogg;*.mp3;*.mid;*.wav;") 'ssFilter
  ssFilter.Add(("Musik-Formate")) 'ssFilterText
  ssFilter.Add("*.ogg") 'ssFilter
  ssFilter.Add(("Musik")) 'ssFilterText
  ssFilter.Add("*.mp3") 'ssFilter
  ssFilter.Add(("Musik")) 'ssFilterText
  ' "*" 
  ' "All Files" ' Standard Anhang
  If Not Component.IsLoaded("gb.sdl2.audio") Then sTool = ("Musik-Programm-Teil fehlt.") & "<br>" & ("Component: gb.sdl2.audio") & "<br>" 'needs component: gb.sdl2.audio
  
  sStandardPath = FMain.F_sPathMusicStandard_mp3 '"music" &/ "clockalarmmusic.mp3"
  sDirFile = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", ("Standard")]
  If Exist(sStandardPath) = False Then sStandardPath = "music/clockalarmmusic.mp3"
  If Exist(sDirFile) = False Then sDirFile = sStandardPath
  
  If Exist(sStandardPath) = True Then sInfo1 = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sStandardPath) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sStandardPath).Size) 
  
  If Exist(sDirFile) = True Then sInfo2 = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size)  
  
  ''Music-File Standard?
  If sDirFile = sStandardPath Or Exist(sDirFile) = False Then 
    sStandardONoff = "●" & Space(1)
    sSelectONoff = "○" & Space(1)
  Else 
    sStandardONoff = "○" & Space(1)
    sSelectONoff = "●" & Space(1)
  Endif 
  
  sMessage = sTool & "<font color=darkgreen><h3>" & sStandardONoff & ("Standard") & ": " & "</h3>" 
  sMessage &= sStandardPath & "</font>" & "<br>"
  sMessage &= sInfo1 & "<br>"
  
  sMessage &= "<font color=blue><h3>" & sSelectONoff & ("Auswahl") & ": " & "</h3>" 
  sMessage &= sDirFile & "</font>" & "<br>"
  sMessage &= sInfo2 & "<br>"
  
  Select Case Message.Question(sMessage, sStandardONoff & ("Standard"), sSelectONoff & ("Auswahl..."), ("Abbrechen"))
    Case 1 'Standard:
      Settings[FMain.Name &/ "F_sPathMusicSelect_mp3"] = sStandardPath
      FMain.F_sPathMusicSelect_mp3 = sStandardPath
      ' M01Functions.MusicStartStop("", True)'Standard
      Goto hEnde
    Case 2 ''Selection...
      '...
    Case 3 'Cancel:
      M01Functions.MusicStartStop("", False)
      ' Music.Stop()
      Goto hEnde
  End Select
  
  ''Selection...
  sDirFile = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", FMain.F_sPathMusicStandard_mp3]
  ' sDirFile = M01Functions.FileDialogOpen(sDir &/ "music.mp3", ssFilter, ("Musik-Datei öffnen..."))
  ' sDir = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic]
  ' If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  
  ' If String.Left(sDirFile, 1) <> "" Then 
  If Exist(sDirFile) = False Then 
    sDir = Desktop.GetDirectory("MUSIC") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
    sDirFile = sDir &/ "clockalarmmusic.mp3"
  Endif 
  sDirFile = Form6Einst.FileDialogPathReturn(sDirFile, "open", "music/clockalarmmusic.mp3") 'Last-Path, open/save, Standard-Path
  'ME.Raise 'zurück zum aktuellen obersten Fenster, Dialogfenster kann Fokus/Ebene ändern
  If Exist(sDirFile) = True Then 
    M01Functions.MusicStartStop(sDirFile, True)
    sMessage = sDirFile & "<br>"
    sMessage &= "<h3><font color=blue>" & File.Name(sDirFile) & "</font></h3>"
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</b></font>" & "<br>"
    
    Select Case Message.Question(sMessage, ("Musik-Datei merken"), ("Abbrechen"))
      Case 1
        Settings[FMain.Name &/ "F_sPathMusicSelect_mp3"] = sDirFile 'speichern
        FMain.F_sPathMusicSelect_mp3 = sDirFile
        M01Functions.MusicStartStop(sDirFile, True)
        ' Music.Load(sDirFile) '(*1)
        ' Music.Play(1, 0)
      Case 2 'Abbrechen
        M01Functions.MusicStartStop("", False)
        ' Music.Stop()
    End Select
  Endif
  
hEnde:
  
  ''___________________________________________________________________________''
  '(*1) Music.Play(1,0) > (Loop 1x, default 0) needs component: (gb.sdl2.audio)
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogOpen(Optional sDirFile As String = "", Optional ssFilter As String[] = ["*.txt", "Text"], Optional sTitle As String = Application.Name & " - " & ("Öffnen...")) As String
  'Beispiel--------------------------
  'Dim Filter2 As Variant 'New String[]
  'Filter2 = "*.txt, Nur-Text" 'Filter
  'Filter2.Add("Nur-Text", 2) 'FilterText
  'Filter.Add("*.csv")'Filter
  'Filter.Add("Tabelle")'FilterText
  ' "*" 
  ' "All Files" ' Standard Anhang
  'Beispiel--------------------------
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  'Dialog.Filter = ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
  
  'If ssFilter = "" Then ssFilter = Filter2
  Dialog.Filter = ssFilter 
  Dialog.Path = sDirFile
  'If Exist(Dialog.Path) = False Then Dialog.Path = User.Home
  ' If Not Exist(Dialog.Path) Then
  '   Dialog.Path = User.Home
  ' Endif
  Dialog.Title = sTitle
  'if Dialog.OpenFile() then Return 'Kurzform
  If Dialog.OpenFile() = True Then
    Return ' User pressed Cancel -
  Else
    'nicht abgebrochen
  Endif
  
  Return Dialog.Path
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogSave(Optional sDirFile As String = "", Optional sText As String = "", Optional ssFilter As String[] = ["*.txt", "Text"], Optional sTitle As String = Application.Name & " - " & ("Speichern unter...")) As String
  
  Dim sFileBefore, sFileBehind, sFilesExist, sMessage, sExt As String
  'Beispiel--------------------------
  'DIM Filter AS NEW String[]
  'Filter.Add("*.txt") 'Filter
  'Filter.Add("Nur-Text") 'FilterText
  'Filter.Add("*.csv")'Filter
  'Filter.Add("Tabelle")'FilterText
  ' "*" 
  ' "All Files" ' Standard Anhang
  'Beispiel--------------------------
  
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  Dialog.Path = sDirFile
  If Not Exist(File.Dir(Dialog.Path)) Then Dialog.Path = FMain.F_sDirAppName
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  Dialog.Filter = ssFilter
  Dialog.Title = sTitle
  Dialog.AutoExt = True ' Extension ".txt"
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  'nicht abgebrochen
  sDirFile = Dialog.Path
  sExt = File.Ext(sDirFile)
  If sExt = "" Then sDirFile = sDirFile & ".txt"
  
  If Exist(sDirFile) = True Then
    sFileBefore = sDirFile & Space(1) & Format(Stat(sDirFile).LastModified, "ddd dd.mm.yyyy hh:nn") & Space(1) & M01Functions.FileSizeLong(sDirFile)
  Endif
  
  If Exist(sDirFile) = False Then
    sFilesExist = ""
  Else
    sFilesExist = ("Die Datei ist schon vorhanden.") & "<br>"
    sFilesExist &= ("Sicherungskopien") & Space(1) & ("in") & ":" & "<br>" 
    sFilesExist &= Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] & "<br><br>"
    sFilesExist &= "<h3><font color=red>" & ("Überschreiben?") & "</font></h3>"
  Endif
  sMessage = File.Dir(sDirFile) &/ "<font color=blue><b>" & File.Name(sDirFile) & "</b></font><br><br>"
  sMessage &= sFilesExist
  
  Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
    Case 1 'Speichern
      'File.Save(Datei, Text)
      M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
      If Exist(sDirFile) = True Then
        sFileBehind = sDirFile & Space(1) & Format(Stat(sDirFile).LastModified, "ddd dd.mm.yyyy hh:nn") & Space(1) & M01Functions.FileSizeLong(sDirFile)
      Endif
      If sFileBefore = sFileBehind Then
        sMessage = sFileBehind & "<br>" & "<br>" 
        sMessage &= "<h3><font color=red>" & ("Nicht erfolgreich gespeichert?") & "</font></h3>"
        
        Select Case Message.Question(sMessage, ("Nachsehen im Ordner..."), ("Abbrechen"))
          Case 1
            M01Functions.FileManagerOpen(sDirFile)
          Case 2 'Abbrechen
            'Leerlauf
        End Select
        sDirFile = "" 'Fehler
      Endif
    Case 2 'Abbrechen
      'Leerlauf
      sDirFile = "" 'Abbruch
  End Select
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  
  Return sDirFile  'Rückgabe Pfad oder leer, ausgeführt oder Abbruch/Fehler
  
Catch 
  FMain.ErrorText
  
End

Public Function KeyPressCheck(Optional sErlaubteZeichen As String = "", Optional sKeyText As String = "", Optional iKeyCode As Integer = "") As Boolean
  
  Dim bCheck As Boolean
  
  If String.InStr(sErlaubteZeichen, sKeyText) > 0 Or iKeyCode = Key.BackSpace Or iKeyCode = Key.Delete Or iKeyCode = Key.Left Or iKeyCode = Key.Right Then
    bCheck = True
  Else
    bCheck = False
  Endif
  Return bCheck 'Rückgabe      Ja oder Nein
  
Catch 
  FMain.ErrorText
  
End

Public Function Weekdays0to6LocalLanguage() As String[]
  
  'Auf Variablenformat achten
  Dim dateSunday As Date
  Dim ssWeekDay As New String[7] 'Weekdays (Wochentage)
  
  dateSunday = DateAdd(Now, gb.Day, 7 - WeekDay(Now)) 'as Date 'Gambas3: "This example gives the date for the next coming sunday"
  
  ssWeekDay[0] = Format(DateAdd(dateSunday, gb.day, 0), "ddd") 'So 0  gb.Sunday
  ssWeekDay[1] = Format(DateAdd(dateSunday, gb.day, 1), "ddd") 'Mo 1
  ssWeekDay[2] = Format(DateAdd(dateSunday, gb.day, 2), "ddd") 'Di 2
  ssWeekDay[3] = Format(DateAdd(dateSunday, gb.day, 3), "ddd") 'Mi 3
  ssWeekDay[4] = Format(DateAdd(dateSunday, gb.day, 4), "ddd") 'Do 4
  ssWeekDay[5] = Format(DateAdd(dateSunday, gb.day, 5), "ddd") 'Fr 5
  ssWeekDay[6] = Format(DateAdd(dateSunday, gb.day, 6), "ddd") 'Sa 6
  'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  'ssWeekDay["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] '0-6
  
  Return ssWeekDay 'WTage
  
Catch 
  FMain.ErrorText
  
End

Public Function DateSundayBefore(Optional dateDatum As Date = Date) As Date
  
  If dateDatum Then dateDatum = DateAdd(dateDatum, gb.Day, 7 - WeekDay(dateDatum)) ' This example gives the date for the next coming sunday
  
  Return dateDatum '(Sunday)
  
Catch 
  FMain.ErrorText
  
End

Public Function RandomIntegerNumbers(Optional iUntergrenze As Integer = 0, Optional iObergrenze As Integer = 1, Optional iAnzahl As Integer = 1) As Integer[]
  
  Dim fZufallszahl As Float
  Dim it, iNumber As Integer
  Dim iiNumbers As New Integer[]
  
  Randomize
  For it = 0 To iAnzahl - 1
    fZufallszahl = Rnd(iUntergrenze, iObergrenze + 1) 
    iNumber = Round(fZufallszahl) 'Int(1.234) = 1 (ganze Zahlen) 
    iiNumbers.Add(iNumber)
    ' Print iNumber
  Next
  
  Return iiNumbers 'Example: -2 bis 4, Anzahl 5  [1, 4, -2, 0, 3]
  
Catch 
  FMain.ErrorText
  
End

Public Function RandomFloatNumbers(Optional fUntergrenze As Float = 0, Optional fObergrenze As Float = 1, Optional iAnzahl As Integer = 1) As Float[]
  
  Dim fZufallszahl As Float
  Dim it As Integer
  Dim ffNumbers As New Float[]
  
  Randomize
  For it = 0 To iAnzahl - 1
    fZufallszahl = Rnd(fUntergrenze, fObergrenze + 1) 
    ffNumbers.Add(fZufallszahl)' 0.123456789
  Next
  
  Return ffNumbers 'Example: -0.123 bis 5.123, Anzahl 5  [1.123, 4.123, -2.123, 0.123, -0.123]
  
Catch 
  FMain.ErrorText
  
End

Public Function RandomColors(Optional iUntergrenze As Integer = 0, Optional iObergrenze As Integer = 255, Optional iAnzahl As Integer = 10) As Integer[]
  
  Dim it, iColor As Integer
  Dim iiNumbers As New Integer[]
  
  Randomize
  For it = 0 To iAnzahl - 1
    iColor = Color.RGB(Rnd(iUntergrenze, iObergrenze), Rnd(iUntergrenze, iObergrenze), Rnd(iUntergrenze, iObergrenze))
    iiNumbers.Add(iColor)
  Next
  
  Return iiNumbers  ' Example: [5630268, 4150393, 4337120. 10376583, 12872741, 6604528, 8320383, 16018494, 8941775, 1130268]
  
Catch 
  FMain.ErrorText
  
End

Public Function FileBackupChecken(Optional sDirFile As String = "") As String '?
  
  Dim statInfo1, statInfo2 As Stat
  Dim sDir, sFile, sPathBackup, sWert1, sWert2, sExt As String
  
  If Exist(sDirFile) = True Then
    statInfo1 = Stat(sDirFile)
    sExt = File.Ext(sDirFile)
    If Exist(FMain.F_sDirBackup) = True Then sDir = FMain.F_sDirBackup Else sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirAppName]
    sFile = File.Name(sDirFile)
    sFile = Replace(String.LCase(sFile), "backup_", "") 'not double
    sPathBackup = sDir &/ "backup_" & sFile
    
    If Exist(sPathBackup) = True Then
      statInfo2 = Stat(sPathBackup)
      sWert1 = statInfo1.LastModified & statInfo1.Size
      sWert2 = statInfo2.LastModified & statInfo2.Size
    Endif
    If sWert2 = "" Or sWert1 <> sWert2 Then
      If Exist(sPathBackup) = True Then Try Kill sPathBackup
      Try Copy sDirFile To sPathBackup
      If Exist(sPathBackup) = False Then sDirFile = "" 'Fehler
    Endif
  Endif 'Exist
  
  Return sDirFile ' Rückgabe Pfad oder leer bei Fehler
  
Catch 
  FMain.ErrorText
  
End

' Public Function WindowsDesktopList(Optional sSearchPattern As String = "*") As String

' Dim hWindow As DesktopWindow 'Returns Top-Level Windows (gb.desktop)
' Dim sTextlist As String
' 
' sSearchPattern = "*"
' 
' For Each hWindow In Desktop.Windows
'   If String.LCase(hWindow.Name) Like String.LCase(sSearchPattern) Then
'     sTextlist = hWindow.Name
'     Break
'     'sTextlist = sTextlist & hWindow.id & gb.NewLine
'     'sTextlist = sTextlist & hWindow.Name & gb.NewLine
'     'sTextlist = sTextlist & hWindow.Desktop & gb.NewLine 'virtual Desktop Nr.?
'   Endif
' Next
' Return sTextlist 

' Dim winForm As Window
' Dim sForm As String
' 
' Me.Visible = False 
' sForm = Me.Tag 
' 
' For Each winForm In Windows '(gb.qt4)
'   If winForm.Name = sForm Then 
'     winForm.Show()
'     Break 
'   Endif
' Next

' Catch 
'   FMain.ErrorText

' End

Public Function CreateDateNotizLine(Optional dateCreate As Date = Now, Optional sNotice As String = "") As String 
  
  Dim T0, T1, T2, T3, T4, T5, sLine As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  Select Case Format(dateCreate, "mm") 
    Case "01", "02", "03"
      T3 = 1
    Case "04", "05", "06"
      T3 = 2
    Case "07", "08", "09"
      T3 = 3
    Case "10", "11", "12"
      T3 = 4
  End Select 
  T3 = Str(T3)
  ' T4 = Week(dateCreate) 'as Integer 0-52    'Result = Week ( Date AS Date [ , FirstDayOfWeek AS Integer , FullWeek AS Boolean ] )
  T4 = Str(Format(Week(dateCreate), "00"))
  
  T0 = Format(dateCreate, "yyyy-mm-dd")
  T1 = "00:00"
  T2 = Format(dateCreate, "ddd")
  T3 = T3 & "Q"
  T4 = T4 & ("KW")
  T5 = Replace(sNotice, hReturn, String.Chr(182)) ' Returnzeichen ¶ ersetzen
  sLine = T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hReturn
  Return sLine
  
Catch 
  FMain.ErrorText
  
End

Public Function ColorInfoRGB(Optional iColor As Integer = Color.Green, Optional RedGreenBlueAlphaLuminanceSaturationHue As String = "G") As Integer
  
  Dim hColorInfo As ColorInfo
  Dim iCol As Integer
  
  hColorInfo = Color[iColor] ''RGB-Colors
  Select Case String.Left(String.LCase(RedGreenBlueAlphaLuminanceSaturationHue), 1)
    Case "r"
      iCol = hColorInfo.Red
    Case "g"
      iCol = hColorInfo.Green
    Case "b"
      iCol = hColorInfo.Blue
    Case "a"
      iCol = hColorInfo.Alpha
    Case "l"
      iCol = hColorInfo.Luminance
    Case "s"
      iCol = hColorInfo.Saturation
    Case "h"
      iCol = hColorInfo.Hue
  End Select
  ''Example: it = M01Functions.ColorInfoRGB(Color.Green, "g") 'as Integer
  
  Return iCol
  
Catch
  FMain.ErrorText
  
End

Public Sub CreateMenuButtonRulerColors()  'only 1x for programer, software developer
  
  Dim sDir, sFile, sDirFile As String
  Dim Img, ImgRule As Image 
  Dim it As Integer
  Dim iiColors As Integer[] = [Color.Yellow, Color.SetAlpha(16762880, 100), Color.SetAlpha(Color.SoftBlue, 100), Color.SetAlpha(Color.LightGray, 100)]
  
  ' sDir = M01Functions.CheckDirectoryCache() 'as String
  sDir = "images" 'not in root, system
  If String.InStr(Application.Path, User.Home) > 0 Then  
    sDirFile = sDir &/ "scale_32.png"
    If Exist(sDirFile) = True Then 
      ImgRule = Image.Load(sDirFile)
    Else 
      ImgRule = New Image(32, 32, Color.Transparent)
    Endif 
    
    For it = 0 To iiColors.Max
      Img = New Image(ImgRule.W, ImgRule.H, iiColors[it])
      Paint.Begin(Img)
      Paint.AntiAlias = True    
      ' Paint.FillRect(0, 0, ImgBG.W, ImgBG.H, iiColors[it])
      Paint.DrawImage(ImgRule, 0, 0)
      Paint.Fill()
      Paint.End
      sFile = "rulercolor" & Str(it + 1) & ".png"
      sDirFile = sDir &/ sFile
      ' If Exist(sDirFile) = True Then Kill sDirFile
      Img.Save(sDirFile)
    Next
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormsBackgroundColorAll()
  
  FMain.FormBackgroundColor()
  Form0NurUhr.FormBackgroundColor()
  Form1FileOpen.FormBackgroundColor()
  Form2Bearb.FormBackgroundColor()
  Form3Text.FormBackgroundColor()
  Form4Bis.FormBackgroundColor()
  Form5Projekte.FormBackgroundColor()
  Form6Einst.FormBackgroundColor()
  Form7HTML.FormBackgroundColor()
  Form8ZusFeiertage.FormBackgroundColor()
  ''9
  ''10
  Form11Breitengrade.FormBackgroundColor()
  Form12Timerplus.FormBackgroundColor()
  Form13Export.FormBackgroundColor()
  Form14UhrDesign.FormBackgroundColor()
  Form15Foto.FormBackgroundColor()
  Form16Diagramm.FormBackgroundColor()
  ''17
  Form18Projektbearbeiten.FormBackgroundColor()
  Form19FileInfo.FormBackgroundColor()
  Form20OpenSource.FormBackgroundColor()
  Form21Colors.FormBackgroundColor()
  Form22DialogOpenSave.FormBackgroundColor()
  
Catch
  FMain.ErrorText
  
End

Public Function ProgramIsAlreadyON() As Boolean
  
  Dim sTool, sToolPath, sDirFileApp, sDir, sText1, sLine As String 
  Dim bON As Boolean 
  Dim iCount, iFirst, iNext As Integer
  Dim ssSpli As String[]
  
  If Component.IsLoaded("gb.dbus") = True Then 'Der Daten-Bus arbeitet automatisch, wenn geladen
    'DBus.Unique = False —▶ "org.gambas.terminwecker-1234" plus PID
    'DBus.Name = "org.gambas." & Application.Name '& "-" & PID
    'Another Example: org.gnome.Shell.Screenshot
    ssSpli = DBus.Session.Applications.Sort(gb.Natural) '.Natural as Integer = 8. Also 1,2,3,10,... not 1,10,2,3...
    iFirst = ssSpli.Find("org.gambas." & Application.Name & "*", gb.like) 
    iNext = ssSpli.Find(DBus.Name & "*", gb.Like, iFirst + 1)
    If iNext > -1 Then 
      bON = True 'double
      Goto JumpEnd
    Endif 
  Endif
  
  ''Application
  sDir = Application.Path 'in Root "/usr/..." or Home "/home/..."    'Root (Wurzelverzeichnis, Betriebssystem)
  sDirFileApp = sDir &/ Application.Name
  If String.InStr(sDir, "/home/") > 0 Then '/home/...?
    sDir = "/usr/bin" 'Binär Exec
    sDirFileApp = sDir &/ Application.Name
    If Exist("/snap/bin" &/ Application.Name) = True Then sDirFileApp = "/snap/bin" &/ Application.Name
    If Exist(sDirFileApp) = False Then sDirFileApp = System.Find(Application.Name)
    If Exist(sDirFileApp) = True Then sDir = File.Dir(sDirFileApp) 
  Endif 
  
  ''Info App active
  sTool = "pgrep"
  sToolPath = sDir &/ sTool  'wie im grafischen Tool 'Systemüberwachung', vorinstalliert in allen Ubuntus
  If Exist(sToolPath) = False Then sToolPath = System.Find("pgrep") ''(*1)
  
  If Exist(sToolPath) = True Then 
    
    'test***************************************
    ' sPath = User.Home &/ "test" &/ "test-pidof.txt"
    ' Shell sTool & " -l terminwecker > " & sPath
    ' Shell sTool & " -a " & sDirFileApp To sText1
    ' Shell sTool & " -c " & Application.Name To sText1 'Example: "-c > 1\n"
    ' Shell sTool & " -c " & sDirFileApp To sText1 'Example: "-fc > 1\n"
    ' Shell sTool & " -f " & sDirFileApp To sText 'Example: "-f > 2525\n"
    Shell sTool & " -flo --list-full " & Application.Name To sText1 'Example: "-fl > 2525 programname\n" 'or process shell
    ' Shell sTool & " -fln " & Application.Name To sText1
    ' Shell "ps aux | grep " & Application.Name To sText1
    ' If Exist(sPath) = True Then sText2 = File.Load(sPath)
    ' Print "sText1: " & sText1
    ' Print "sText2: " & sText2
    ' Print "Application.Id: " & Application.Id '(PID, Handle)
    ' If sText1 And sText2 And sText1 = sText2 Then bON = False Else bON = True 'double?
    
    If IsInteger(sText1) = True Then 
      sText1 = Replace(sText1, gb.NewLine, "")
      iCount = CInteger(sText1)
    Else 
      ssSpli = Split(sText1 & gb.NewLine, gb.NewLine) ' gb.NewLine="\n"
      For Each sLine In ssSpli 
        If sLine Then 
          If String.InStr(sLine, "gambas") = 0 And String.InStr(sLine, Str(Application.Id)) = 0 Then
            If String.InStr(sLine, Application.Name) > 0 Then iCount = iCount + 1
          Endif 
        Endif 
      Next 
    Endif
    
    If iCount > 0 Then bON = True Else bON = False 'double?
    
    ' Print "Max: " & iCount '0=Off, 1=On, 2=Double, 3=...
    
    'test***************************************
    ' Shell "ps aux | grep " & Application.Name To sText2
    ' Shell "top -c terminwecker" To sText2
    ' Shell "ps -FC " & Application.Name To sText2
    ' Shell "pgrep -f terminwecker" To sText2
    ' Print "sText2: " & sText2
    ' If Not sText2 Then bON = False Else bON = True 'double?
    ' Print "Print ID: " & FMain.Id & Space(1) & Desktop.Platform '(x11 or wayland)
  Endif 
  '-i, --ignore-case   '"sucht nach Prozessen, ohne Groß- oder Kleinschreibung zu berücksichtigen."
  '-l, --list-name  '"listet sowohl den Prozessnamen als auch die Prozesskennung auf(nur f ür pgrep)." 
  '-l, 'Example: "2525 terminwecker\n"
  '-f, --full 'sucht nach vollständiger Befehlszeile  sDirFileApp  statt "nur" AppName 
  '-o, --oldest   '"wählt nur den ältesten (zuerst gestarteten) aus den passenden Prozessen aus."
  '-n, --newest   '"wählt nur den neuesten (zuletzt gestarteten) aus den passenden Prozessen aus."
  '-c, --count    '0 wie FALSE
  
  ''sText Example:
  ' 2525 gbr3 /usr/bin/terminwecker
  ' 15638 /usr/bin/gbx3 -g -f /tmp/gambas.1000/gambas3-ide-debug-7772. /home/<user>/Gambas3/terminwecker
  ' 15661 /bin/sh -c /usr/bin/pgrep -fl --list-full --ignore-case terminwecker
JumpEnd:
  
  Return bON 
  ''_______________________________________________________________________________''
  '(*1) "https://manpages.ubuntu.com/manpages/focal/de/man1/pgrep.1.html"
  ' "https://wiki.ubuntuusers.de/ps/"
  
Catch 
  FMain.ErrorText
  
End

Public Function UbuntuVersionG() As String
  
  Dim sShort, sTool As String
  
  sTool = "lsb_release"
  If System.Exist(sTool) Then 
    Try Shell sTool & Space(1) & "-sdc" To sShort
    If sShort Then sShort = Replace(sShort, gb.NewLine, Space(1))
    '-s, --short
    '-d, --description
    '-r, --release
    '-c, --codename
    '-a, --all
  Endif 
  
  Return sShort 'Example: "Ubuntu 23.10 mantic"
  
  ''__________________________________________________________________________''
  ' "https://wiki.ubuntuusers.de/Systeminformationen_ermitteln/"
  ' "https://manpages.ubuntu.com/manpages/xenial/en/man1/lsb_release.1.html"
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckProgramON() As Boolean
  
  Dim bON As Boolean
  
  If Not FMain.F_sPathStartzeit_txt Then FMain.F_sPathStartzeit_txt = Settings[FMain.Name &/ "F_sPathStartzeit_txt", FMain.F_sPathStartzeit_txt]
  If Not FMain.F_sPathStartzeit_txt Then FMain.F_sPathStartzeit_txt = User.Home &/ Application.Name &/ "temp_" & Application.Name & "_programstart.txt"
  
  If Exist(FMain.F_sPathStartzeit_txt) = True Then  'Example: /home/user/terminwecker/...
    If FMain.F_iProgramStartCounter < 3 Then 
      Try Kill FMain.F_sPathStartzeit_txt
      ' Else 
      '   If File.Load(FMain.F_sPathStartzeit_txt) <> Str(FMain.F_dateProgramStart) Then 
      '     Try File.Save(FMain.F_sPathStartzeit_txt, Str(FMain.F_dateProgramStart))
      'Application.Id '(PID, Handle)
      '   Endif
      FMain.F_iProgramStartCounter = FMain.F_iProgramStartCounter + 1 'secound
    Endif 
  Endif 
  
  ' Try File.Save(FMain.F_sPathStartzeit_txt, Format(F_dateNow, "yyyy-mm-dd-hh-nn-ss-ddd"))
  If FMain.F_iProgramStartCounter > 1 Then bON = True Else bON = False 'double?
  
  Return bON
  
Catch 
  FMain.ErrorText
  
End

Public Function FileTerminWeckerCreateReturnDirectory() As String 
  
  Dim sDir As String 
  
  ' Try sDir = FMain.F_sDirAppName
  ''1.Test
  If Exist(sDir) = False Then Try sDir = File.Dir(Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt])
  
  ''2.Test
  If Exist(sDir) = False Then sDir = User.Home &/ Application.Name
  If Exist(sDir) = False Then Try Mkdir sDir
  
  ''3.Test
  If Exist(sDir) = False Then sDir = Desktop.GetDirectory("DOCUMENTS") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  
  Return sDir 
  
Catch 
  FMain.ErrorText
  
End

Public Function ClipboardImageExist() As Boolean
  
  Dim sMimeTyp As String
  Dim bYesNo As Boolean
  
  bYesNo = False
  ''Example Clipboard.Formats = [text/plain, text/html, image/png, image/tiff, image/jpeg, application/x-qt-image, ...] '=> MIME-Type
  For Each sMimeTyp In Clipboard.Formats                                                   'as String[]
    If String.InStr(sMimeTyp, "image") > 0 Then 
      bYesNo = True
      Break 
    Endif
  Next 
  Return bYesNo
  
Catch 
  FMain.ErrorText
  
End

Public Function ClipboardImage() As Image 'Mimetype only in Text-Formats, not Image/Picture-Formats
  
  '=>ClipBoard: MIME-Type
  Dim imgTemp As Image 
  
  If Clipboard.Type = Clipboard.Image Then 
    imgTemp = Clipboard.Paste() '◀—
  Endif 
  
  ''Formats in Text not Image
  
  ' If Not imgTemp Then 
  '   For Each sMimeTyp In Clipboard.Formats
  '     If String.InStr(sMimeTyp, "image/png") > 0 Then  'full image without loss   'or String.InStr(sMimeTyp, "image/bmp") > 0 
  '       imgTemp = Clipboard.Paste()                                                   'as Image
  '       If imgTemp Then Break
  '     Endif 'png, bmp
  '   Next 
  ' If imgTemp = Null Then                                                                   'other formats
  '   sImageFormat = "image"                                                                 'all image-type, or specially => MIME-Type
  '   For Each sMimeTyp In Clipboard.Formats
  '     If String.InStr(String.LCase(sMimeTyp), sImageFormat) > 0 Then                        'Example: application/x-qt-image
  '       ' imgTemp = Clipboard.Paste()                           'as Image 1x
  '       ' If imgTemp Then Break
  '       sText &= sMimeTyp & gb.NewLine ' "ClipBoard MIME-Type: " & Clipboard.Formats[0]
  '     Endif
  '   Next 
  '   Print "ClipBoard MIME-Type: " & gb.NewLine & sText
  ' Endif 'Null
  ' Endif 
  ''Clipboard [Zwischenablage] Alternative:
  ''Clipman  'xfce
  ''Parcellite 'auch in LXDE
  ''ClipIt 'auch in LXDE 'in den offiziellen Paketquellen enthalten. GTK+
  ''Diodon ''in den offiziellen Paketquellen enthalten. "Diodon ist ein Ersatz für ClipIt, der nicht mehr unterstützt wird."
  ''GPaste 'Gnome3
  ''Glipper
  ''Klipper 'KDE
  ''clipper
  ''qlipper
  ''CopyQ
  
  Return imgTemp
  
  ''___________________________________________________________________________''
  ''Mime-Type:
  ''Example Type=0 None: NULL
  ''Example Type=1 Text: text/plain, text/html, ...
  ''Example Type=2 Image: image/png, image/x-icon, image/x-ico, image/x-win-bitmap, image/bmp, image/x-bmp, image/x-MS-bmp, 
  ''image/tiff, image/jpeg, application/x-qt-image, ...   '(application/x-qt-image =>Linux ubuntu  Clipboard.Type=Clipboard.Image)
  
Catch 
  FMain.ErrorText
  
End 

Public Function ClipboardText() As String 
  
  Dim sMimeTyp As String                                                                   '=>ClipBoard: MIME-Type
  Dim sTextFormat As String
  Dim sText As String  
  
  If Clipboard.Type = Clipboard.Text Then 
    sText = Clipboard.Paste() '◀—
  Endif 
  
  If Not sText Then 
    For Each sMimeTyp In Clipboard.Formats
      If String.InStr(sMimeTyp, "text/plain") > 0 Then  'full image without loss   'or String.InStr(sMimeTyp, "text/html") > 0 
        sText = Clipboard.Paste(sMimeTyp)                                                   'as Image
        If sText Then Break
      Endif 'png, bmp
    Next 
    If sText = Null Then                                                                   'other formats
      sTextFormat = "text"                                                                 'all image-type, or specially => MIME-Type
      For Each sMimeTyp In Clipboard.Formats
        If String.InStr(String.LCase(sMimeTyp), sTextFormat) > 0 Then                        'Example: application/x-qt-image
          sText = Clipboard.Paste(sMimeTyp)                           'as Image 1x
          If sText Then Break
        Endif
      Next 
    Endif 'Null
  Endif 
  ' If sText Then 
  Return sText
  
  ''___________________________________________________________________________''
  ''Mime-Type:
  ''Example Type=0 None: NULL
  ''Example Type=1 Text: text/plain, text/html, ...
  ''Example Type=2 Image: image/png, image/x-icon, image/x-ico, image/x-win-bitmap, image/bmp, image/x-bmp, image/x-MS-bmp, 
  ''image/tiff, image/jpeg, application/x-qt-image, ...   '(application/x-qt-image =>Linux ubuntu  Clipboard.Type=Clipboard.Image)
  
Catch 
  FMain.ErrorText
  
End 

Public Function ScreenshotGambasCentral() As Picture
  
  Dim sDir, sFile, sDirFile As String
  Dim picScreen As Picture
  Dim Img As Image
  
  ''Check exist:
  Try sDir = Desktop.GetDirectory("PICTURES")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If Error Then sDir = M01Functions.ProgramCache()
  sFile = "Screenshot.png"
  sDirFile = sDir &/ sFile
  If Exist(sDirFile) = True Then Kill sDirFile 'not double like Screenshot.png, Screenshot1.png, Screenshot2.png, ... 
  If Exist(sDirFile) = True Then Wait 0.5
  'Note: PictureBox.Picture = Desktop.Screenshot() 'Return as Picture AND automatically save Picture as file Screenshot.png, Screenshot1.png, Screenshot2.png, ... 
  
  ''Picture and File:
  Try picScreen = Desktop.Screenshot() 'as Picture Error=Try=Next line
  If Error Then picScreen = Null
  If picScreen Then Img = picScreen.Image
  
  If M01Functions.ScreenshotImageExist(Img) = False Then 
    ''Alternative:
    Img = M01Functions.ScreenshotImageAlternative() 'as Image
    If Img Then picScreen = Img.Picture
  Endif 
  
  Return picScreen
  
Catch
  FMain.ErrorText
  
End

Public Function ScreenshotImageAreaForm(Optional iFormX As Integer, Optional iFormY As Integer, Optional iFormW As Integer, Optional iFormH As Integer) As Image
  
  Dim sPath, sDir, sFile, sSize, sMessage As String
  Dim imgScreen, imgCut As Image
  Dim picScreen As Picture
  Dim iW, iH As Integer
  Dim fRel As Float
  
  ' sFile = ("bildschirmfoto-form.png")
  sFile = "Screenshot.png"
  sPath = M01Functions.ProgramDirCache(sFile) '/directory/file.png
  sDir = File.Dir(sPath)
  
  ''Foto:
  ' If Desktop.Platform = "wayland" Then 
    imgScreen = M01Functions.ScreenshotImageAreaFormWayland() 'as Image
    If imgScreen Then 
      imgCut = imgScreen
      Goto jumpWayland
    Endif 
  ' Endif 
  
  ' picScreen = Desktop.Screenshot() 'as Picture
  picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  If picScreen Then imgScreen = picScreen.Image
  ' imgScreen = Desktop.Screenshot(iFormX, iFormY, iFormW, iFormH).Image 'as Picture 'Note: Convert null picture to image > Error
  
  ''Missing? Alternative:
  If M01Functions.ScreenshotImageExist(imgScreen) = False Then 'Image, but all black?
    ' If Not imgScreen Then 
    imgScreen = M01Functions.ScreenshotImageAlternative()
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  
  If Not imgScreen Then imgScreen = M01Functions.ScreenshotImageDemo(iFormX, iFormY, iFormW, iFormH)
  
  ''Screen:
  If imgScreen Then 
    If IsDir(sDir) = True Then imgScreen.Save(sPath)
    If Exist(sPath) = False Then 
      sDir = FMain.F_sDirAppName
      If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sPath = sDir &/ sFile 
      imgScreen.Picture.Save(sPath)
    Endif 
    
    ''Cut area:
    If Exist(sPath) = True Then 
      imgScreen = Image.Load(sPath)
      If imgScreen.W = Screen.W And imgScreen.H = Screen.H Then 
        If imgScreen Then imgCut = imgScreen.Copy(iFormX, iFormY, iFormW, iFormH) 'without Frame-Title ■■■■■×
      Else 
        imgCut = imgScreen.Copy()
      Endif 
    Endif 
  Endif 
  
jumpWayland:
  If imgCut And IsDir(sDir) = True Then imgCut.Save(sPath)
  If imgCut And Exist(sPath) = True Then 
    fRel = imgCut.W / imgCut.H
    ' sMessage &= "<img src=" & Quote("file://" & sPath) & " width=100 height=100 >" & "<br>" 
    sMessage &= "<img src=" & Quote("file://" & sPath) & " width=" & Round(fRel * 100) & " height=100 >" 
  Else
    sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
  Endif 
  If imgCut Then 
    iW = imgCut.W
    iH = imgCut.H
  Endif 
  If Exist(sPath) = True Then sSize = M01Functions.FileSizeLongText(Stat(sPath).Size) 
  
  sMessage &= "<h2><font color=darkgreen>" & ("Fenster-Foto") & "</font></h2>" 
  sMessage &= "<h4>" & File.Dir(sPath) &/ "<font color=darkgreen>" & File.Name(sPath) & "</font></h4>"
  sMessage &= "<h4><font color=gray>" & iW & " x " & iH & Space(1) & ("Pixel") & ", " & sSize & "</font></h4>"
  If Exist(sPath) = False Then sMessage &= "<h4><font color=red>" & ("Fehlt") & "</font></h4>" 
  If Desktop.Platform = "wayland" Then 'bug top left?
    sMessage &= "<h4><font color=red>" & ("Fenster-System") & ": " & Desktop.Platform & "</font></h4>"
  Endif 
  
  ''Show:
  Select Case Message.Question(sMessage, ("Bildprogramm..."), ("Ordner..."), ("Abbrechen"))
    Case 1 ''Picture-Program
      If Exist(sPath) = True Then Desktop.Open(sPath) 'Standard-Program
      ' M01Functions.ExternStart("gimp", sPath)
    Case 2 ''Directory:
      If Exist(sPath) = True Then M01Functions.FileManagerOpen(sPath) Else Desktop.Open(sDir)
    Case 3 ''Cancel
      '...Leerlauf
  End Select
  
  Return imgScreen  '(cut area From screen)
  
Catch
  FMain.ErrorText
  
End

Public Function ScreenshotImageDesktopx11Window() As Image 
  
  Dim Img As Image 

  'DesktopWindow.GetScreenshot. Needs Component: gb.desktop.x11 'unused, ready May 2021?
  'GetScreenshot([WithoutFrame As Boolean]) As Picture
  'Example: If Not Component.IsLoaded("gb.settings") Then Component.Load("gb.settings")
  If Component.IsLoaded("gb.desktop.x11") = True Then 
    Try Img = DesktopWindow.GetScreenshot(False).Image 'as Picture to Image 'without Frame = True or False
  Endif 
  
  Return Img 
  
  ''_________________________________________________________________''
  'X11 Fensterverwalter (Windowmanager, Fenster-Macher): gb.desktop.x11, gb.qt5.x11 
  'X11 Nachfolger (next Generation): Wayland (gb.qt5.wayland, gb.gtk+3.wayland)
  
Catch 
  FMain.ErrorText
  
End

Public Function ScreenshotImageExist(Optional Img As Image = Null) As Boolean
  
  Dim bCheck As Boolean
  
  If Img Then 'check
    If Img.W > 0 And Img.H > 0 Then 
      If Img.Pixels.First = Img.Pixels.Last And Img.Pixels.First = Img.Pixels[Img.Pixels.Max / 2] Then Img = Null 'only one Color? 
    Else 
      Img = Null
    Endif 
    If Img Then bCheck = True
  Endif 
  
  Return bCheck
  
Catch 
  FMain.ErrorText
  
End

Public Function ScreenshotImageAreaFormWayland() As Image ''(*1)
  
  Dim sTool, sDir, sDirFile, sPathProgram As String 
  Dim imgScreen As Image
  
  sDir = FMain.F_sDirCache
  If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  ' sDirFile = M01Functions.ProgramDirCache(("bildschirmfoto-form.png")) '/cache/file.png
  sDirFile = M01Functions.ProgramDirCache("Screenshot.png") '/cache/file.png
  sDir = File.Dir(sDirFile)
  
  sTool = "gnome-screenshot"  ''(*2) gtk+
  sPathProgram = "/usr/bin" &/ sTool
  If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sPathProgram = FMain.F_sScreenshotToolPath '/dir/file.ext
  If Exist(sPathProgram) = False Then sPathProgram = System.Find(sTool) 
  If Exist("/snap/bin" &/ sTool) = True Then sPathProgram = "/snap/bin" &/ sTool
  If Exist(sPathProgram) = True Then   'Example: "/usr/bin/gnome-screenshot"
    If IsDir(sDir) = True Then 
      ' If sPathProgram Then Shell sPathProgram & Space(1) & "-a --file=" & sDirFile Wait '-a, +area+
      If sPathProgram Then Shell sPathProgram & Space(1) & "-w --file=" & sDirFile Wait '-f= '"-c"  "-w" (Window-Form) 
      '-w, --window   (Grab the current active window instead of the entire screen.)
      '-c, --clipboard  (Send the grab directly to the clipboard.)   
      '-f, --file=FILENAME  (Save screenshot directly To this file.)
      '-a, --area  (*2)(Grab an area of the screen instead of the entire screen.)
      If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)
      If imgScreen And Exist(sDirFile) = True Then Try Kill sDirFile
    Endif 
  Endif 
  If Not sPathProgram Then 
    If String.InStr(FMain.F_sErrorMessagesExtra, sTool) = 0 Then 
      FMain.F_sErrorMessagesExtra &= ("Fehlt") & ": " & Quote(sTool) & ". " & ("Siehe in Software (installieren)") & gb.NewLine
    Endif 
  Endif 
  
  Return imgScreen 'as Image —▶ Screenshot (Bildschirmfoto)
  ''__________________________________________________________''
  '(*1) X11 Window-Manager (Fenster-Macher). See next Generation "Wayland"
  '(*2) https://manpages.ubuntu.com/manpages/jammy/man1/gnome-screenshot.1.html
  
Catch 
  FMain.ErrorText
  
End

Public Function ScreenshotImageAlternative() As Image
  
  Dim imgScreen As Image 'Image faster than Picture
  Dim sDirFile, sDir, sTool, sMessage, sInfo As String
  Dim bScreenphotoExist As Boolean
  
  sDir = FMain.F_sDirCache
  If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  ' sDirFile = M01Functions.ProgramDirCache(("bildschirmfoto.png")) '/cache/file.png
  sDirFile = M01Functions.ProgramDirCache("Screenshot.png") '/cache/file.png
  sDir = File.Dir(sDirFile)
  
  If Not FMain.F_sScreenshotToolPath Then FMain.F_sScreenshotToolPath = Settings[FMain.Name &/ "F_sScreenshotToolPath", FMain.F_sScreenshotToolPath]  'no search, faster
  
  sInfo = "ScreenshotImageAlternative" & ": " & Time & gb.NewLine
  ' Goto JumpMessage
  ' Dim ssTools As String[]
  
  ' sTool = System.Find("xdg-desktop-portal-gtk") 'GTK+/GNOME
  ' sTool = System.Find("xdg-desktop-portal-kde") 'QT
  ' sTool = System.Find("xfce4-screenshooter") '"xfce4-goodies" extra
  
  ' ssTools = ["gnome-screenshot", "ksnip", "mate-screenshot", "shutter", "xwd", "xdg-desktop-portal-gtk", "xdg-desktop-portal-kde", "xfce4-screenshooter"]
  ' For Each sTool In ssTools
  '   If System.Find(sTool) Then Print sTool
  ' Next 
  
  ''Alternative 0: Gnome
  If Not imgScreen Then 
    sTool = "gnome-screenshot"  ''(*2) gtk+
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
      If IsDir(sDir) = True Then 
        If sTool Then Shell sTool & Space(1) & "--file=" & sDirFile Wait '-f=
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)
      Endif 
      
      ''Clipboard ([Zwischenablage])
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool & Space(1) & "--clipboard" Wait    '"-c"  "-w" (Window-Form)      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif 
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    ' x11, qt4, but not supportes on wayland?
    ' Desktop.SendKeys("{[Control_L]}{[Print]}") ' Bildschirmkopie Tastatur [Druck]
    ' Desktop.SendKeys("{[Control_L]}{[Alt_L]}{[Print]}") ' Bildschirmkopie Tastatur [Druck]
    ' Desktop.SendKeys("{[Alt_L]}{[Print]}")  ' Bildschirmkopie des aktiven Fensters
    '(*2) https://manpages.ubuntu.com/manpages/jammy/man1/gnome-screenshot.1.html
    ' Desktop.SendKeys("{[Ctrl]} & {[Shift]} & {[Alt]} + {[Shift_L]r}")      'ctrl + Shift + Alt + r
    
    ' Desktop.SendKeys("{[" & Key.ShiftKey & "][" & Key.Print & "]}") ' Bildschirmkopie Tastatur [Druck]
    ' If Error Then 
    '   Message.Info(Error.Text)
    ' Endif
    ' Desktop.SendKeys(Str(Key.Print)) ' Bildschirmkopie Tastatur [Druck]
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 1: grim - grab images from a Wayland compositor
  If Not imgScreen Then
    sTool = "grim" 'Synaptic: "grim is a command-line utility to take screenshots of Wayland desktops".  -t "image/png" is Default (t=type)
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    
    If Exist(sTool) = True Then 
      ''in File:
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & sDirFile Wait
        '- o < output >
        ' If sTool Then Shell sTool & " -g " & Quote("0,0 " & Screen.W & "x" & Screen.H) & " -o -t png > " & sDirFile 'Wait 'saved in File, not in clipboard"
        'Konsole: "compositor doesn't support wlr-screencopy-unstable-v1"
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
        If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
      Endif 
    Endif
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    'https://manpages.ubuntu.com/manpages/lunar/en/man1/grim.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative: screengrab 'QT
  If Not imgScreen Then
    ''ScreenGrab in QT5. "ScreenGrab is the default screenshot tool for Lubuntu". https://manual.lubuntu.me/stable/2/2.3/2.3.2/screengrab.html
    sTool = "screengrab" 'PNG, JPG or BMP, Screen or window
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    
    If Exist(sTool) = True Then 
      ''in File:
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        '- o < output >
        If sTool Then Shell sTool & " > " & sDirFile Wait 'saved in File, not in clipboard
        ''Umleitung in Datei bei Shell: " > " & "/dir/file.ext" oder " >> " & "/dir/file.ext" 'Append, anhängen  
        'Konsole: "compositor doesn't support wlr-screencopy-unstable-v1"
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
        If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
      Endif 
    Endif
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 2: X11
  If Not imgScreen Then
    sTool = "Gambas3 gb.desktop.x11" 'Gambas3 Component: gb.desktop.x11  Here only info
    If Desktop.Platform = "x11" Then 
      Try imgScreen = M01Functions.ScreenshotImageDesktopx11Window() ''as Image '(*1)
      '(*1) X11 Window-Manager (Fenster-Macher)
      If imgScreen And IsDir(sDir) = True Then imgScreen.Save(sDirFile)
      If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    Endif 
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif 
  
  ''Alternative 3: Ksnip 
  If Not imgScreen Then 
    sTool = "ksnip"  ''QT, Wayland, Gnome (Ubuntu Software)
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
      If IsDir(sDir) = True Then 
        If sTool Then Shell sTool & Space(1) & "--file=" & sDirFile Wait '-f=
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)
      Endif 
      
      ''Clipboard ([Zwischenablage])
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool & Space(1) & "--clipboard" Wait    '"-c"                  
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif 
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 3: xwd (x11) Format. xwd stands for "X Window Dump". Like Picture.BMP
  If Not imgScreen Then 
    sTool = "x11-apps" '"xwd"
    '- xwd, a utility for taking window dumps ("screenshots") of the X session;
    'Only Text:  - xclipboard, a tool to manage cut-and-pasted text selections;
    
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    '' -silent (Operate silently, i.e. don't ring any bells before and after dumping the window)
    If System.Exist(sTool) = False Then sTool = System.Find(sTool) 'Else sTool = ""   'X11  "xwd -screen -out FILE"
    If Exist(sTool) = True Then 
      FMain.F_sScreenshotToolPath = sTool 'no search, faster
      sDirFile = M01Functions.ProgramDirCache("xwd-screenshot.png")
      If sTool Then Shell sTool & Space(1) & "-root -out " & sDirFile Wait  '-root = Fullscreen
      If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)
    Endif 
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    'MIT, Smithsonian Astrophysical Observatory
    'https://manpages.ubuntu.com/manpages/jammy/en/man1/xwd.1.html
    'https://manpages.ubuntu.com/manpages/lunar/en/man1/xclip-copyfile.1.html
  Endif
  
  ''Alternative 4: ImageMagick
  If Not imgScreen Then
    sTool = "import"
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & sDirFile Wait                      'saved in File, not in clipboard
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
        If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
      Endif 
    Endif
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    'ImageMagick: Program/Tool in Linux/Ubuntu: "import" 
    'https://manpages.ubuntu.com/manpages/trusty/man1/ImageMagick.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 5: xfce4 (GTK+) '"xfce4-goodies" extra
  If Not imgScreen Then
    sTool = "xfce4" 'xfce4-screenshooter
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & "-screenshooter -f -s " & sDirFile Wait  
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
      Endif 
      
      ''Check Clipboard
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool & Space(1) & "-screenshooter -c" Wait                      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    '' -f, --fullscreen (Take a screenshot of the entire screen)
    '' -c, --clipboard (Copy the screenshot To the clipboard)
    '' -s, --save (Directory or File-Path where the screenshot will be saved (*.png, *.jpg, *.bmp))
    'https://manpages.ubuntu.com/manpages/jammy/man1/xfce4-screenshooter.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 6: shutter
  If Not imgScreen Then
    sTool = "shutter" 
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & "-screenshot -f -n -o=" & sDirFile Wait 
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)  
      Endif 
      
      ''Check Clipboard
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool & Space(1) & "-f -n" Wait                      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    '' -f, --full  
    '' -o, --output=FILENAME  (*.png, *.jpg, *.gif, *.bmp,..., *.pdf, *.ps, *.svg)
    '' -n, --no_session 
    '"Do not add the screenshot to the session. This is useful when using Shutter in scripts." (*1)
    '' -e, --exit_after_capture
    '"Exit after the first capture has been made.This Is Useful when using Shutter in scripts."
    '' -web=[URL]    (Capture a webpage.Providing an URL ist optional)
    '"Capture a webpage.Providing an URL ist optional."
    '' -a, --active
    '"Capture the current active window."
    '' -w, --window=[NAME_PATTERN]
    '"Select a window to capture. Providing a NAME_PATTERN (Perl-style regex) ist optional."
    
    '        Example 2:               shutter -s=100,100,300,300 -e
    ' 
    '        Example 3                shutter --window=.*firefox.*
    ' 
    '        Example 4                shutter --web=https://shutter-project.org/ -e
    
    'Shutter - Feature-rich Screenshot Tool
    '(*1) https://manpages.ubuntu.com/manpages/jammy/en/man1/shutter.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 7: mate (Debian)
  If Not imgScreen Then
    sTool = "mate-utils" '"mate-screenshot - capture the screen, a window, or an user-defined area and save the snapshot image to a file".
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & "-screenshot" & sDirFile Wait                       'saved in File, not in clipboard
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
      Endif 
      
      ''Check Clipboard
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool Wait                      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    'GDM, https://manpages.ubuntu.com/manpages/impish/man1/gdmflexiserver.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 8: copyq (QT)
  If Not imgScreen Then
    sTool = "copyq" 
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool) 
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & " write " & sDirFile                      'saved in File, not in clipboard
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile)  
      Endif 
      
      ''Check Clipboard
      If Not imgScreen Then
        Clipboard.Clear()
        '"x11"
        'copyq read image/png 0 > image.png
        'Example Notation:
        ' !file:///home/user/dir/file.ext!
        ' !https://www.host.com/image.gif!
        ' or
        ' !attached-image.gif!
        ' Inserts an image into the page.
        'xml, html
        ' <test>
        '     <another tag="attribute"/>
        ' </test>
        '
        If sTool Then Shell sTool Wait                      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    'GDM, https://manpages.ubuntu.com/manpages/impish/man1/gdmflexiserver.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative 9: GDM (GTK+, for Debian, Part of Gnome)
  If Not imgScreen Then
    sTool = "gdm" 
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If Exist(sTool) = False Then sTool = System.Find(sTool)  
    If Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        If sTool Then Shell sTool & Space(1) & "-screenshot " & sDirFile Wait                      'saved in File, not in clipboard
        If Exist(sDirFile) = True Then Try imgScreen = Image.Load(sDirFile) 
      Endif 
      
      ''Check Clipboard
      If Not imgScreen Then
        Clipboard.Clear()
        If sTool Then Shell sTool & Space(1) & "-screenshot" Wait                      
        imgScreen = M01Functions.ClipboardImage() 'as Image
      Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    '" -d, --debug" (Debugging Output)
    'GDM, https://manpages.ubuntu.com/manpages/impish/man1/gdmflexiserver.1.html
  Endif 
  If imgScreen Then 
    bScreenphotoExist = True 
    Goto JumpEnd
  Endif
  
  ''Alternative: 
  If Not imgScreen Then
    sTool = "Gambas3 Desktop.Screenshot" 'Gambas3 (gb.qt4), here only info
    ' picScreen = Desktop.Screenshot() 'as Picture! Screenshot standard
    ' picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot() 'Loop Error?
    ' If picScreen Then imgScreen = picScreen.Image
    
    If IsDir(sDir) = True Then 
      If M01Functions.ScreenshotImageExist(imgScreen) = False Then imgScreen = M01Functions.ScreenshotImageDemo()
      If imgScreen Then 
        imgScreen.Save(sDirFile)
        bScreenphotoExist = False 
      Endif 
    Endif 
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
  Endif 
  
  ''More alternatives:
  ''screencapture (BSD)
  ''QScreenCapture QT6.5
  ''Scrot (SCReenshOT)
  ''ScreenGrab — Cross-platform application designed to quickly take screenshots (Qt).
  ''gscreenshot — Simple GTK screenshot utility with delays, selection, and copy-to-clipboard functionality.
  ''LXQt Screenshot — Screenshot tool for LXQt. Run with lximage-qt --screenshot.
  ''imlib2 provides a Binary imlib2_grab To take screenshots.To take a screenshot Of the full screen, type: $ imlib2_grab screenshot.png
  ''xclip  Kommandozeilenschnittstelle für "X selections" (Zwischenablage)
  ''xclip-copyfile, xclip-cutfile, xclip-pastefile - copy and move files via the X clipboard
  ''"GPaste - A lightweight clipboard manager for the Gnome desktop"
  
JumpMessage:
  
  If Not imgScreen Or bScreenphotoExist = False Then 
    sMessage = M01Functions.ScreenshotErrorMessageExtra() 'as String 
    
    ' sMessage = "<font color=gray>" & ("Fehlt: Ein Program-Werkzeug (Tool) für ein Bildschirm-Abbild") & "</font><br><br>" 
    ' sMessage &= "<font color=blue>" & ("Im Software-Center installieren:") & "</font>" 
    ' sMessage &= "<h2><font color=red><b>" & "gnome-screenshot" & "</b></font>" & Space(1) & "<font color=darkgreen>" & ("Bildschirmfoto") & "</font></h2>" 
    
    ' sMessage = ("Fehlt: Ein Program-Werkzeug (Tool) für ein Bildschirm-Abbild") & gb.NewLine 
    ' sMessage &= gb.NewLine
    ' sMessage &= ("Im Software-Center installieren. Eingabe in") & Space(1) & Quote("Suche") & ":" & gb.NewLine
    ' sMessage &= Quote("gnome-screenshot") & gb.Tab & ("(Bildschirmfoto)") & gb.NewLine
    Form15Foto.LabelPictureSavedPath.Text = ("<font color=red>" & ("Ein Werkzeug (Tool, Paket) fehlt") & ": " & "</font>" & "<font color=blue>" & ("Installieren im Software-Center:") & "</font>" & Space(1) & "<font color=darkgreen><b>" & "gnome-screenshot" & "</b></font>" & Space(1) & "<font  color=blue>" & ("Bildschirmfoto")) 'Label Public=True?
  Endif 
  
JumpEnd:
  Print sInfo 
  If Exist(sDirFile) = True Then File.Save(File.SetExt(sDirFile, "txt"), sInfo)
  
  Return imgScreen 'as Image —▶ Screenshot (Bildschirmfoto)
  ''__________________________________________________________''
  '(*1) X11 Window-Manager (Fenster-Macher). See next Generation "Wayland"
  '(*2) https://manpages.ubuntu.com/manpages/jammy/man1/gnome-screenshot.1.html
  'Liste  https://wiki.archlinux.org/title/Screen_capture
Catch 
  FMain.ErrorText
  
End

Public Sub CheckTools()  
  
  Dim sTool, sText, sExist, sSoftwareCenter, sMessage As String 
  Dim ssTools As String[]
  
  sText = ("Beispiel: Fehlende Tools (Werkzeuge) können auf Wunsch zusätzlich nach-installiert werden unter Betriebssystem 'Software'. Suche: Tool-Name") & gb.NewLine 
  sText &= gb.NewLine
  sText &= ("Tool-Name = Bereits installiert?") & ":" & gb.NewLine
  ssTools = ["Bildschirm-Foto:", "imagemagick", "import", "gnome-screenshot", "grim", "screengrab", "x11-apps", "xfce4", "mate-utils", "Software Verwaltung:", "synaptic", "snap-store", "gnome-software", "ubuntu-software", "gnome-control-center", "appstream", "ffmpeg"]
  '"appstream" 'Metadata, freedesktop.org, Application-Center (Anwendungszenter), Software
  
  For Each sTool In ssTools
    If String.InStr(sTool, ":") > 0 Then 
      sExist = "<hr>" & sTool '---------------
    Else  
      If System.Exist(sTool) = True Then 
        sExist = sTool & "=" & "<font color=darkgreen><b>" & ("Ja") & " ●" & "</b></font>" 
      Else 
        sExist = "<font color=gray>" & sTool & "=" & ("Nein") & " ○" & "</font>"
      Endif 
    Endif 
    sText &= sExist & "<br>"
  Next 
  
  sMessage = "<h3><font color=darkgreen>" & ("Check Tools") & ":" & "</font></h3>"
  sMessage &= sText 
  
  Select Case Message.Question(sMessage, ("Software-Verwaltung") & "...", ("Abbrechen"))
    Case 1
      ''Software-Center  *.deb > Install > De-Install
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("snap-store")
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("gnome-software")
      If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("ubuntu-software")
      If sSoftwareCenter <> "" Then Shell sSoftwareCenter  ' "gnome-control-center applications" 
    Case 2
      ''...
  End Select  
  
  ''__________________________________________________________''
  ' https://manpages.ubuntu.com/manpages/   (Search: ?)
  
Catch 
  FMain.ErrorText

End

Public Sub CheckLastSettings()
  
  Dim sDirConfigFile1, sDirConfigFile2, sDirFileLastbackup, sDirFile, sDir, sFile As String 
  
  Settings.Save() 'Gambas3: "Saves the configuration file to the disk."
  
  sDirConfigFile1 = Settings.Path 'User.Home & ".config" &/ "gambas3" 
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirConfigFile1)
  sDirConfigFile2 = sDir &/ sFile
  
  If Exist(sDirConfigFile1) = True And IsDir(sDir) = True Then
    If Exist(sDirConfigFile2) = False Then 
      Copy sDirConfigFile1 To sDirConfigFile2 'USB-Stick?
    Else If Stat(sDirConfigFile1).LastModified > Stat(sDirConfigFile2).LastModified Then 
      Kill sDirConfigFile2 
      Copy sDirConfigFile1 To sDirConfigFile2 'USB-Stick?
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] 'Harddisk: User.Home &/ Application.Name
      If IsDir(sDir) = True Then 
        sDirFile = sDir &/ sFile 
        If Exist(sDirFile) = True Then Kill sDirFile 
        Copy sDirConfigFile1 To sDirFile 'Harddisk?
      Endif 
    Endif 
  Endif 
  
  sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  If Exist(sDirConfigFile1) = True And IsDir(sDir) = True Then 
    sDirFileLastbackup = sDir &/ File.BaseName(sFile) & "_lastbackup." & File.Ext(sFile)
    If Exist(sDirFileLastbackup) = False Then 
      Copy sDirConfigFile1 To sDirFileLastbackup
    Else 
      If Stat(sDirConfigFile1).Size <> Stat(sDirFileLastbackup).Size And Abs(DateDiff(Stat(sDirConfigFile1).LastModified, Stat(sDirFileLastbackup).LastModified, gb.Day)) > 2 Then 
        Kill sDirFileLastbackup
        Copy sDirConfigFile1 To sDirFileLastbackup
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText

End

Public Function FindFileSettings() As String
  
  Dim sDir, sDirSub, sFile, sMedia, sDirFileFound, sDirFile1, sDirFile2, sAppName, sMessage As String
  Dim ssDirs, ssDirSub As String[]
  Dim ssFiles As String[]
  Dim iFound As Integer
  Dim bMessageON As Boolean
  
  If Exist(Settings.Path) = True Then 
    sFile = File.Name(Settings.Path)
    bMessageON = False
  Else 
    sFile = Application.Name & ".conf"
    bMessageON = True 
  Endif 
  
  ''USB, Media
  sMedia = "/media" &/ User.Name 
  ssDirs = Dir(sMedia, "*", gb.Directory)
  
  If ssDirs Then 
    For Each sDir In ssDirs
      ssDirSub = Dir(sMedia &/ sDir, "*", gb.Directory)
      If ssDirSub Then 
        iFound = ssDirSub.Find(Application.Name) '-1 not found 
        If iFound > -1 Then 
          sDirSub = sMedia &/ sDir &/ ssDirSub[iFound]
          If IsDir(sDirSub) = True Then 
            sDirFile1 = sDirSub &/ sFile 
            If Exist(sDirFile1) = True Then Break 
          Endif
        Endif 
      Endif 
    Next
  Endif
  
  ''Harddisk
  sDirFile2 = User.Home &/ Application.Name &/ sFile 
  
  If Exist(sDirFile2) = False Then
    sDir = User.Home &/ Application.Name &/ Application.Name & "-backup" 
    If IsDir(sDir) = True Then 
      ssFiles = Dir(sDir, sFile & "*", gb.File).Sort()
      If ssFiles Then sDirFile2 = sDir &/ ssFiles.Last 'Last backup
    Endif 
  Endif
  
  If Exist(sDirFile1) = True Or Exist(sDirFile2) = True Then 
    sDir = User.Home &/ ".config"
    If IsDir(sDir) = False Then Try Mkdir sDir
    sDir = User.Home &/ ".config" &/ "gambas3"
    If IsDir(sDir) = False Then Try Mkdir sDir
    
    If Exist(sDirFile1) = True And Exist(sDirFile2) = True Then 
      If Stat(sDirFile1).LastModified > Stat(sDirFile2).LastModified Then
        sDirFileFound = sDirFile1
      Else 
        sDirFileFound = sDirFile2
      Endif 
    Else 
      If Exist(sDirFile1) = True Then 
        sDirFileFound = sDirFile1
      Else 
        If Exist(sDirFile2) = True Then sDirFileFound = sDirFile2
      Endif 
    Endif
    Print Stat(sDirFileFound).size 
    
    If bMessageON = True And Exist(sDirFileFound) = True Then 
      sAppName = "<font size=7 color=#" & Hex(FMain.F_iColorClockBlue, 6) & "><b>" & Application.Name & "</b></font>" 
      sMessage = sAppName & "<br>"
      sMessage &= "<h2><font color=darkgreen>" & "● " & ("Mit Einstellungen") & "</font></h2>" 
      sMessage &= sDirFileFound & "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileFound) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileFound).Size)
      sMessage &= "<br>"
      sMessage &= "<h2><font color=blue>" & "○ " & ("Im Neuzustand") & "</font></h2>" 
      
      Select Case Message.Question(sMessage, "● " & ("Mit Einstellungen"), "○ " & ("Im Neuzustand"), ("Abbrechen"))
        Case 1
          If IsDir(sDir) = True Then Try Copy sDirFileFound To Settings.Path '/.config/gambas3/" & Application.Name & ".conf"
          If Exist(Settings.Path) = True Then Settings.Reload()
          Print Stat(Settings.Path).size  
          
        Case 2
          ''...
        Case 3
          ''...
      End Select
    Endif
  Endif
  
  Return sDirFileFound
  
Catch 
  FMain.ErrorText

End

Public Function ScreenshotErrorMessageExtra() As String 

  Dim sMessage As String 
  Dim sText, sToolName As String
  
  FMain.F_iScreenshotMissingCounter = FMain.F_iScreenshotMissingCounter + 1
  
  If FMain.F_iScreenshotMissingCounter = 1 Then 'only 1x
    sToolName = "gnome-screenshot"
    sMessage = ("Fehlt: Ein Program-Werkzeug (Tool) für ein Bildschirm-Abbild") & gb.NewLine 
    sMessage &= gb.NewLine
    sMessage &= ("Im Software-Center installieren. Eingabe in") & Space(1) & Quote("Suche") & ":" & gb.NewLine
    sMessage &= Quote(sToolName) & gb.Tab & ("(Bildschirmfoto)") & gb.NewLine
    sMessage &= gb.NewLine
    sMessage &= ("Alternativ") & ":" & gb.NewLine
    sMessage &= ("Über ein Programmtyp") & Space(1) & Quote("Paketverwaltung") & Space(1) & ("(z.B. Synaptic, Muon, ...) das fehlende Paket nachinstallieren.") & gb.NewLine
    sMessage &= gb.NewLine
    sMessage &= ("Alternativ") & ":" & gb.NewLine
    sMessage &= ("Folgende Zeile kopieren und einfügen im Terminal") & " '>_'" & ":" & gb.NewLine
    sMessage &= ("sudo apt-get install gnome-screenshot") & gb.NewLine
    sMessage &= gb.NewLine
    '.....................................................................................
    sMessage &= ("Paket") & ": " & Quote(sToolName) & Space(1) & "(*.deb Debian 0,2 MB)" & gb.NewLine '(*1)
    sMessage &= ("GNOME-Programm für die Erzeugung von Bildschirmfotos") & gb.NewLine
    sMessage &= ("Dieses Werkzeug »fotografiert« die Arbeitsfläche im Computer oder ein Programm-Fenster und speichert das Foto in eine Datei.") & Space(1) & ("(Quelle: GNOME Paket-Info)") & gb.NewLine
    '.....................................................................................
    
    FMain.F_sErrorMessagesExtra &= sMessage
    
    sText = ("<font size=7 color=red><b>" & ("Fehlt") & ": " & "</b></font>" & "<br><font size=7 color=darkgreen><b>" & sToolName & "</b></font>" & Space(1) & "<font color=blue>" & ("Bildschirmfoto") & "</font><br><font size=5 color=blue>" & ("Das Werkzeug (Tool, Paket) fehlt") & ". " & ("Es kann nach-installiert werden im") & Space(1) & "<font color=orange><b>" & ("Software-Center") & "*</b></font>" & Space(1) & ("des Betriebssytems im Computer") & Space(1) & ("(*oder ähnliche Bezeichnung A, App, Anwendungen)") & "</font>") 'Label Public=True?
    
    Select Case Message.Warning("<h2><font color=red>" & ("Fehler. Bild fehlt.") & "</font></h2>" & sMessage & "<br>" & sText, ("Fehlermeldungen") & "...", ("Kopiere Name") & Space(1) & Quote(sToolName), ("Abbrechen"))
      Case 1 'Fehlermeldungen, Error messages
        M01Functions.ErrorMessages()
      Case 2
        Clipboard.Clear()
        Clipboard.Copy(sToolName) ' Name  Copy in Clipboard (Zwischenablage)
      Case 3 'Abbrechen, Cancel
        ''...
    End Select
    
  Endif 
  
  Return sMessage
  
  ''_______________________________________________________________________________________''
  '(*1) Quelle: GNOME Paket-Info
  
Catch 
  FMain.ErrorText

End

Public Function ScreenshotImageDemo(Optional iLeft As Integer = 0, Optional iTop As Integer = 0, Optional iW As Integer = Screen.W, Optional iH As Integer = Screen.H) As Image
  
  Dim U As Float
  Dim imgTemp As Image
  
  imgTemp = New Image(Screen.W, Screen.H, Color.SetAlpha(Color.Green, 150))
  U = iH / 10
  
  Paint.Begin(imgTemp)
  '---------------------- □
  Paint.Dash = [1, 2]
  Paint.Rectangle(0, 0, imgTemp.W, imgTemp.H, 0) '□
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke()
  '---------------------- □
  
  Paint.Font.Name = "Ubuntu"
  Paint.Font.Bold = False
  Paint.Font.Size = U * 0.75
  Paint.Text(("Ersatz-Bild") & gb.NewLine & ("Fehlt: Bildschirm-Foto"), 0, 0, imgTemp.W, imgTemp.H, Align.Center)
  Paint.LineWidth = 2
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.Fill()
  
  '---------------------- □
  Paint.Dash = [1, 2]
  Paint.Rectangle(iLeft, iTop, iW, iH, 0) '□
  Paint.LineWidth = U * 0.05
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke()
  Paint.Dash = Null
  '---------------------- □
  Paint.End 
  
  Return imgTemp
  
Catch 
  FMain.ErrorText
  
End

Public Function DemoDiagramFile() As String 
  
  Dim it, iDays As Integer
  Dim sLine, sClock, sText, sProjectOnlyName As String
  Dim sPath, sFile As String 
  Dim date1, date2, dateWeekBegin As Date
  Dim iiNumbers1, iiNumbers2 As Integer[] 
  Dim iHH, iMM As Integer
  Dim hReturn As String 
  
  ' hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  '****************************
  iDays = 7  'Anzahl Tage
  sClock = "06:00" 'Anfangszeit
  sProjectOnlyName = ("Test")
  sFile = "project_test.txt"
  dateWeekBegin = M01Functions.DateLastWeekDay(Now, gb.Sunday) 'as Date   0=Sonntag, gb.Sunday
  '****************************
  
  ''iiNumbers1 as Integer[]  Random (zufällige Zahlen erstellen)
  iiNumbers1 = M01Functions.RandomIntegerNumbers(6, 20, iDays) '(von, bis, Anzahl) 'as Integer[]  '06-20 Uhr
  iiNumbers2 = M01Functions.RandomIntegerNumbers(0, 60, iDays) '(von, bis, Anzahl) 'as Integer[]  '00-60 Minuten
  
  If iiNumbers1.Count < iDays Then iiNumbers1.Resize(iDays)
  If iiNumbers2.Count < iDays Then iiNumbers2.Resize(iDays)
  
  If iiNumbers1 And iiNumbers2 Then 
    For it = 0 To iiNumbers1.Max
      date1 = DateAdd(dateWeekBegin, gb.day, it - iDays)
      ''Sa + Su:
      If WeekDay(date1) = gb.Saturday Or WeekDay(date1) = gb.Sunday Then 'Werktage ohne Wochenende
        date1 = Date(Year(date1), Month(date1), Day(date1), 0, 0, 0)
        date2 = Date(Year(date1), Month(date1), Day(date1), 0, 0, 0)
      Else 'Work Days:
        iHH = iiNumbers1[it]
        iMM = iiNumbers2[it]
        date1 = Date(Year(date1), Month(date1), Day(date1), 7, 0, 0)
        date2 = Date(Year(date1), Month(date1), Day(date1), iHH, iMM, 0)
      Endif 
      sLine = M01Functions.ProjectLineRefresh(date1, date2, sProjectOnlyName) 'as String
      If String.InStr(sLine, hReturn) = 0 Then sLine = sLine & hReturn
      sText = sText & sLine
    Next
    ' sPath = M01Functions.FileTempDirFileTxt(sFile) 
    sPath = M01Functions.CheckDirectoryCache() &/ sFile
    If IsDir(File.Dir(sPath)) = True Then 
      File.Save(sPath, sText)
      Settings[FMain.Name &/ "ProjectTest"] = sPath
    Endif 
  Endif 
  
  Return sPath 
  
Catch 
  FMain.ErrorText
  
End

Public Function PictureBGplusFG(Optional picBackground As Picture, Optional picForeground As Picture) As Picture 
  
  If picBackground And picForeground Then 
    Paint.Begin(picBackground)
    Paint.DrawPicture(picForeground, (picBackground.W / 2) - (picForeground.W / 2), (picBackground.H / 2) - (picForeground.H / 2)) '—▶center◀—
    Paint.End  
  Endif 
  Return picBackground ''1+2
  
Catch 
  FMain.ErrorText
  
End

Public Function ImageSaveSVG(Optional Img As Image, Optional sDirFileSVG As String) As String 'unused Test xxxx
  
  Dim imgSVG As SvgImage '(Scalable Vector Graphics)
  
  'imgSVG = SvgImage.Load("~/gambas.svg") 'see PictureBox.Picture
  
  imgSVG = New SvgImage(Img.W, Img.H)
  
  Paint.Begin(imgSVG) '(Device) Flaeche, auf die gemalt wird.
  Paint.DrawImage(Img, 0, 0) 'left-top
  ' Paint.DrawImage(Img, (imgSVG.W / 2) - (Img.W / 2), (imgSVG.H / 2) - (Img.H / 2)) '—▶center◀—
  ' Paint.Fill()
  Paint.End  
  
  If Exist(sDirFileSVG) = True Then Try Kill sDirFileSVG
  If IsDir(File.Dir(sDirFileSVG)) = True Then imgSVG.Save(sDirFileSVG) 
  If Exist(sDirFileSVG) = False Then sDirFileSVG = ""
  
  Return sDirFileSVG
  
Catch 
  FMain.ErrorText
  
End

Public Function ESCmessage(Optional sMessage As String = ("Vorgang abbrechen?")) As Boolean
  
  Dim bCancel As Boolean
  
  sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
  
  Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
    Case 1
      bCancel = False
    Case 2
      bCancel = True
  End Select
  
  Return bCancel
  
Catch
  FMain.ErrorText
  'Beispiel Aufruf in For...Next, Example:
  ' If FMain.F_bESCpressedON = True Then
  '   If M01Functions.ESCmessage() = True Then Break
  ' Endif
  
End

Public Sub BookmarksGlobalStandardLoad() 
  
  Dim cBookmark As Collection
  
  ''Note: Here "Bookmarks", not "FileChooser.Bookmarks"
  
  'Check:
  If Not FMain.F_ccBookmarksStandards Then 
    FMain.F_ccBookmarksStandards = New Collection[]
    FMain.F_ccBookmarksStandards = M01Functions.BookmarksDefaultG() 'as Collection[]
    
    'To Bookmarks:
    If FMain.F_ccBookmarksStandards Then 
      Bookmarks.Clear() 'Global, Edit with .Add, .Remove, .Clear, .Count   Needs Component: gb.Form
      For Each cBookmark In FMain.F_ccBookmarksStandards
        Bookmarks.Add(cBookmark["Path"], cBookmark["Name"], cBookmark["Icon"]) 'in FileChooser and DirBox
        'Bookmarks(gb.form) Gambas3: "This class allows To globally manage a list Of file bookmarks."
      Next 
    Endif 
  Endif 
  
  ' If Exist(F_sPathBookmarks) = True Then Desktop.Open(F_sPathBookmarks)
  '-------------------------------------
  'see global extra —▶ +Bookmark, edit in FileChooser1.Bookmarks   sDirFile= File.Dir(Settings.Path) &/ "gb.form.conf"? (Einfache Textdatei)  'needs Component: gb.form
  '-------------------------------------
  
Catch 
  FMain.ErrorText
  
End

Public Function BookmarksDefaultG() As Collection[]    'Needs Components: gb.form, gb.desktop, gb.settings
  
  Dim ccDefaultBookmarks As Collection[]
  Dim cBookmark As Collection
  Dim sDir, sIcon, sDir1x As String
  ' Dim hSettings As Settings
  
  'Example: If Not Component.IsLoaded("gb.settings") Then Component.Load("gb.settings")
  
  sDir = FMain.F_sDirAppName
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir 
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon 
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                                       'Alternative:  
    'ccDefaultBookmarks.Add(["Path": F_sDirDefault, "Name": Application.Name, "Icon": "icon:/22/add"])
  Endif 
  
  sDir = FMain.F_sDirBackup
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir 
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                         
  Endif 
  
  sDir = FMain.F_sDirProject
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                            
  Endif 
  
  sDir = FMain.F_sDirClock
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                            
  Endif 
  
  sDir = Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt", Null]
  If IsDir(sDir) = False Then sDir = File.Dir(sDir)
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(File.Dir(sDir)) 'Name last directory
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                           
  Endif 
  
  sDir = FMain.F_sDirAppName
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDir = "/media" &/ User.Name &/ sDir
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/clock"
    ' sIcon = "images/clock_22.png"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(File.Dir(sDir)) 'Name last directory
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                           
  Endif 
  
  sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/system"
    ' sIcon = "images/screen_22.png"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                          
  Endif 
  sDir1x = sDir
  
  sDir = Desktop.GetDirectory("PICTURES")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If sDir1x <> sDir And IsDir(sDir) = True Then 
    sIcon = "icon:/22/system"
    ' sIcon = "images/screen_22.png"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = ("Bilder")
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                          
  Endif 
  sDir1x = sDir
  
  sDir = File.Dir(Settings[FMain.Name &/ "sPathFoto", Null])
  If sDir1x <> sDir And IsDir(sDir) = True Then 
    sIcon = "icon:/22/system"
    ' sIcon = "images/screen_22.png"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = File.Name(sDir)
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                            
  Endif 
  
  sDir = "/media" &/ User.Name
  If IsDir(sDir) = True Then 
    sIcon = "icon:/22/system"
    ' sIcon = "images/screen_22.png"
    If Not ccDefaultBookmarks Then ccDefaultBookmarks = New Collection[]
    cBookmark = New Collection
    cBookmark["Path"] = sDir
    cBookmark["Name"] = ("Andere Orte... media USB-Stick")
    cBookmark["Icon"] = sIcon
    If ccDefaultBookmarks.Find(cBookmark) = -1 Then ccDefaultBookmarks.Add(cBookmark)                          
  Endif 
  
  ' ccFileChooserBookmarks = Form1FileOpen.FileChooser1.Bookmarks  'Public = True?
  ' If Not ccFileChooserBookmarks Then ccFileChooserBookmarks = New Collection[]
  
  ' ''Add Defaults
  ' If ccDefaultBookmarks Then 
  '   For Each cBookmark In ccDefaultBookmarks
  '     If ccFileChooserBookmarks.Find(cBookmark) = -1 Then ccFileChooserBookmarks.Add(cBookmark) 'not double
  '   Next  
  ' Endif 
  'Bookmarks.Clear() '.Add, .Remove, .Clear, Global in Gambas-Apps
  '-------------------------------------
  'see other extra —▶ FileChooser1.Bookmarks
  '-------------------------------------
  '   For Each cCollection In ccDefaultBookmarks
  '     Bookmarks.Add(cCollection["Path"], cCollection["Name"], cCollection["Icon"]) 'in FileChooser and DirBox
  '     'Bookmarks(gb.form) Gambas3: "This class allows To globally manage a list Of file bookmarks."
  '     ' FileChooser1.Bookmarks.Add(cCollection)
  ' '     sText &= "Bookmark" & Str(it) & "=" & "[" & Quote(cCollection["Path"]) & "," & Quote(cCollection["Name"]) & "]" & gb.NewLine
  '     ' Break
  '   Next 
  ''**************************************************************
  ' Form1FileOpen.FileChooser1.Bookmarks = ccFileChooserBookmarks 'Public = True?
  ''**************************************************************
  ' sText = hSettings.ToString(ccFileChooserBookmarks)
  
  ''Default automatically: See in FileChooser or DirBox (Edit, Rename, Remove)
  'Manuel—▶ M01Functions.BookmarkDefaultSaveG(ccDefaultBookmarks) '/home/user/.config/gb.form.conf
  
  Return ccDefaultBookmarks 'as Collection[]
  
  ''_________________________________________________________________________''
  ' /home/user/.config/gb.form.conf  (einfache Textdatei)  sPath = File.Dir(Settings.Path) &/ "gb.form.conf"
  ' Example:
  
  ' [Bookmarks]
  ' Count = 2
  ' Bookmark1 = ["/media/user/USB", "USB-Stick-1"]
  ' Bookmark2 = ["/media/user/partition2/home/user/Gambas3", "Gambas3"] '["Path", "Name"]
  
Catch 
  FMain.ErrorText
  
End

Public Sub BookmarkDefaultSaveG(Optional ccDefaultBookmarks As Collection[])
  
  Dim hSettings As Settings 
  Dim iCount As Integer  
  Dim cBookmark As Collection
  
  If Not ccDefaultBookmarks Or Not Component.IsLoaded("gb.settings") Then Return
  
  hSettings = New Settings("gb.form")
  
  hSettings.Clear("/Bookmarks")
  
  For Each cBookmark In ccDefaultBookmarks
    iCount = iCount + 1
    hSettings["/Bookmarks/Bookmark" & Str(iCount)] = [cBookmark["Path"], cBookmark["Name"], cBookmark["Icon"]]
  Next
  
  hSettings["/Bookmarks/Count"] = iCount
  
  hSettings.Save    '/home/user/.config/gb.form.conf
  
Catch 
  FMain.ErrorText
  
End

Public Function FileLastModifiedText(Optional sDirFile As String) As String 
  
  Dim iDiff As Integer
  Dim sText As String 
  
  If Exist(sDirFile) = True Then 
    iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Second)
    sText = Str(iDiff) & Space(1) & ("Sekunden")
    If Abs(iDiff) > 59 Then 
      iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Minute)
      sText = Str(iDiff) & Space(1) & ("Minuten")
      If Abs(iDiff) > 59 Then 
        iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Hour)
        sText = Str(iDiff) & Space(1) & ("Stunden")
        If Abs(iDiff) > 23 Then 
          iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Day)
          sText = Str(iDiff) & Space(1) & ("Tagen")
          If Abs(iDiff) > 31 Then 
            iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Month)
            sText = Str(iDiff) & Space(1) & ("Monaten")
            If Abs(iDiff) > 24 Then 
              iDiff = DateDiff(Now, Stat(sDirFile).LastModified, gb.Year)
              sText = Str(iDiff) & Space(1) & ("Jahren")
            Endif 
          Endif 
        Endif 
      Endif 
    Endif 
  Else 
    sText = ("?")
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Function FontSizeCheck(Optional sText As String, Optional fPaintFont As Font = Font["Ubuntu,12"], Optional iTextWidthMax As Integer = FMain.F_iIconSize, Optional bWrap As Boolean = False) As Float 
  
  Dim hTextLabel As Label 'or TextLabel with Wrap
  Dim itF As Float
  
  hTextLabel = New Label(FMain) 'Note: PanelHiden.Public = True ?
  hTextLabel.Font = fPaintFont
  ' hTextLabel.Wrap = bWrap 'Label.Wrap' is not a property
  bWrap = bWrap
  hTextLabel.Text = sText
  If Not iTextWidthMax Then iTextWidthMax = hTextLabel.FontTextWidth(sText)
  ''big to little:
  If hTextLabel.Font.TextWidth(sText) > iTextWidthMax Then 
    For itF = hTextLabel.Font.Size To 1 Step -1
      hTextLabel.Font.Size = itF
      If hTextLabel.Font.TextWidth(sText) < iTextWidthMax Then Break 
    Next
  Else ''little to big:
    For itF = hTextLabel.Font.Size To hTextLabel.Font.Size + 100 Step 1
      hTextLabel.Font.Size = itF
      If hTextLabel.Font.TextWidth(sText) > iTextWidthMax Then Break
    Next
  Endif 
  hTextLabel.Delete() 'wieder entfernen
  
  Return itF 
  
Catch
  FMain.ErrorText
  
End

Public Sub SettingsBackupConfig(Optional sDirFileBackup As String = Null)
  
  Dim sDirFileSettings, sDir, sText, sInfo1, sInfo2, sAppName, sMessageInfo, sMessage As String 
  Dim ssSpli As String[]
  
  ''Message, Infos?
  If Not sDirFileBackup Then 
    sDirFileSettings = Settings[FMain.Name &/ "F_sPathSettings_conf", Settings.Path] 'Original
    sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
    sDirFileBackup = sDir &/ Application.Name & "_lastbackup." & File.Ext(sDirFileSettings)
    'FMain.F_sPathSettingsBackup_conf
    sDirFileBackup = M01Functions.FileDialogPathReturn(sDirFileBackup, "open", Settings.Path)
    '(Last-Path, open/save, Standard-Path)
    
    If Exist(sDirFileBackup) = False Then sDirFileBackup = FMain.F_sPathSettingsBackup_conf
    If Exist(sDirFileBackup) = False Then 
      sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
      ssSpli = Dir(sDir, "*terminwecker*.conf*", gb.file).Sort(gb.Descent) '▲
      If ssSpli Then sDirFileBackup = sDir &/ ssSpli.First
    Endif
    
    'Backup to Original:
    If Exist(sDirFileBackup) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFileBackup) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileBackup).Size) Else sInfo1 = "<font color=red>" & ("Nicht gefunden") & "</font>"
    
    If Exist(sDirFileSettings) = True Then sInfo2 = M01Functions.FileLastModifiedText(sDirFileSettings) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileSettings).Size) Else sInfo2 = "<font color=red>" & ("Nicht gefunden") & "</font>"
    
    sMessageInfo = "<h2><font color=darkgreen><b>" & ("Backup Einstellungen [settings]") & "</b></font>" & "<br>"
    sMessageInfo &= "<font size=2 color=gray>" & ("(Mehr Details in Seite > Einstellungen)") & "</font>" & "</h2>"
    
    sMessageInfo &= "<h2><font color=gray>" & ("Von:") & "</font>" & "</h2>"
    sMessageInfo &= "<h3><font color=darkgreen><b>" & "○ " & sDirFileBackup & "</b></font>" & "<br>"
    sMessageInfo &= "<font color=gray>" & ("vor") & Space(1) & sInfo1 & "</font>" & "</h3>"
    
    sMessageInfo &= "<font size=2 color=gray>" & ("Inhalt") & ":" & "</font>" & "<br>"
    If Exist(sDirFileBackup) = True Then sText = File.Load(sDirFileBackup)
    If sText Then 
      sMessageInfo &= "<font color=gray>" & String.Left(sText, 70) & "..." & "</font>" & "<br>"
    Else 
      sMessageInfo &= "<font color=red><b>" & ("Leer") & "</b></font>" & "<br>"
    Endif 
    sMessageInfo &= "<hr>" '———
    sMessageInfo &= "<h2><font color=gray>" & ("Nach:") & "</font>" & "</h2>"
    sMessageInfo &= "<h3><font color=blue><b>" & "● " & sDirFileSettings & "</b></font>" & "<br>"
    sMessageInfo &= "<font color=gray>" & ("vor") & Space(1) & sInfo2 & "</font>" & "</h3>"
    
    sMessageInfo &= "<h2>" & ("Speichern und") & Space(1) & "<font color=blue>" & ("Original") & Space(1) & "</font>" & "<font color=red>" & ("überschreiben?") & "</font>" & "</h2>"
    sMessageInfo &= "<font color=gray>"
    ' sMessageInfo &= ("Vorsicht: Einstellungen nur mit Fachwissen ändern.") & "<br>"
    sMessageInfo &= ("Im Notfall alle Einstellungen löschen. Das Programm startet dann wie im Neu-Zustand.") & Space(1) & ("(Reset)")
    sMessageInfo &= "</font>"
    
    sMessage = "<h2><font color=darkgreen><b>" & ("Vormerken") & "</b></font></h2>"
    sMessage &= sDirFileBackup & "<h3>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileBackup) & "</b></font>" & Space(3) & M01Functions.FileSizeLongText(Stat(sDirFileBackup).Size) & "</h3>"
    sMessage &= "<br>"
    sAppName = "<font size=7 color=#" & Hex(FMain.F_iColorClockBlue, 6) & "><b>" & Application.Name & "</b></font>" 
    sMessage &= sAppName & "<br>" & "<br>"
    sMessage &= "<h2><font color=blue><b>" & ("Bitte dieses Programm beenden und neu starten") & Space(1) & "<font color=darkgreen>" & ("(mit den neuen Einstellungen)") & "</b></font></h2>" 
    
    Select Case Message.Question(sMessage, ("Beenden"), ("Mehr Infos") & "...", ("Abbrechen")) 'Case[0,1,2,3]
      Case 1 ''Load backup...
        Settings[FMain.Name &/ "sDirFileBackup"] = sDirFileBackup
        FMain.mnuBeendenG()
        
      Case 2 ''More Infos...
        Select Case Message.Question(sMessageInfo, "● " & ("Beenden"), ("Ordner..."), ("Abbrechen")) 'Case[0,1,2,3]
          Case 1
            Settings[FMain.Name &/ "sDirFileBackup"] = sDirFileBackup
            FMain.mnuBeendenG()
          Case 2 'Directory...
            sDirFileBackup = Null
            If Exist(sDirFileSettings) = False Then sDirFileSettings = File.Dir(sDirFileSettings)
            M01Functions.FileManagerOpen(sDirFileSettings)
          Case 3 'Cancel
            sDirFileBackup = Null
        End Select
        
      Case 3 'Cancel
        sDirFileBackup = Null
    End Select
  Endif 
  
  ''Save?
  If Exist(sDirFileBackup) = True Then 
    sText = File.Load(sDirFileBackup)
    If sText Then sDirFileSettings = M01Functions.FileTextPlus(Settings.Path, sText, True) ' TRUE=overwrite (überschreiben)
    Settings.Reload()
    Settings.Save()
  Else 
    Settings[FMain.Name &/ "sDirFileBackup"] = Null
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub SystemControl(Optional sLastTag As String = "")
  
  Dim sProgram, sOption, sPath, sFind, sSnap, sMessage As String 
  
  Select Case LCase(sLastTag)
    Case "systemprograms"
      sProgram = "gnome-control-center"
      sOption = "applications"
      
    Case "defaultapplications"
      sProgram = "gnome-control-center"
      sOption = "default-apps"
      
    Case "displays"
      sProgram = "gnome-control-center"
      sOption = "display"
      
    Case "dock"
      sProgram = "gnome-control-center"
      sOption = "ubuntu"
      
    Case "eog"
      sProgram = "eog" 'eyes of gnome, picture viewer
      sPath = FMain.F_sDirDefault
      
    Case "databackup"
      sProgram = "deja-dup"
      
    Case "libreoffice"
      sProgram = "libreoffice.writer"
      ' sProgram = "gnome-text-editor"
      
    Case "characters"
      sProgram = "gnome-characters"
      
    Case "systeminfo"
      sProgram = "gnome-control-center"
      sOption = "info-overview"
      
  End Select
  
  ''Check:
  sFind = System.Find(sProgram) 'as String 
  sSnap = "/snap/bin" &/ sProgram
  If Exist(sSnap) = True Then sFind = sSnap
  If sFind Then 
    ''Muster: Shell sProgram sPath  (not forget Separator space(1) or " ")
    If sOption Then sOption = Space(1) & sOption 
    If sPath Then sPath = Space(1) & Quote(sPath)  
    Shell sFind & sOption & sPath
  Else 
    sMessage = "<h3><font color=blue>" & sProgram & "</font></h3>"
    sMessage = "<h3><font color=red>" & ("Programm nicht gefunden") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif 
  
Catch
  FMain.ErrorText
  Message.Info(FMain.ErrorText)
  
  ''_______________________________________________________________________________''
  ''sProgram: Programs, Apps, Tools, Software... in Ubuntu (OS, Operating-System) 
  
End

Public Sub IconError()
  
  Dim sMessage As String
  
  sMessage = ("Fehler-Meldungen") & ":" & gb.NewLine 
  sMessage &= gb.NewLine
  
  If FMain.F_sErrorInfos <> "" Then 
    sMessage &= FMain.F_sErrorInfos & gb.NewLine              'Dfree as Long
    sMessage &= Format(Dfree("/") / 1024 / 1024 / 1024, "0,0") & Space(1) & "GB free" & Space(2) & "(" & Format(Dfree("/"), "0,0") & Space(1) & "Bytes" & ")" & gb.NewLine
  Else 
    sMessage &= "<font color=darkgreen><b>" & ("Keine") & "</b></font>" & gb.NewLine
  Endif
  
  'Kein Error, aber Einlesefehler?
  If FMain.F_sErrorMessagesExtra Then sMessage = sMessage & gb.NewLine & gb.NewLine & FMain.F_sErrorMessagesExtra & gb.NewLine
  
  Select Case Message.Question(sMessage, "?", ("Andere Meldungen..."), ("Abbrechen")) '(0,1,2,3)?
    Case 1
      M06InfoText.CharsetABCInfo()
    Case 2 
      M01Functions.ErrorMessages()
    Case 3 'Cancel
      '...
  End Select 
  
Catch 
  FMain.ErrorText
  
End '...............................



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M07Paint.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M07Paint.module
74,8 KB
' Gambas module file

Public Function CreateIconTerminweckerPNG(Optional iIconSize As Integer = 256) As Image
  
  Dim Img, ImgGray As Image
  Dim iLineEndType As Integer
  Dim U, R As Float
  Dim fRadius, fLeft, fDayH, fDayTop, fDis As Float
  Dim MX1, MY1 As Float
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  Dim sDir, sDirFile As String 
  
  bWhiteBorderON = True
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  
  U = Img.W / 10    '1 Unit
  R = U * 0.25 
  
  ''Clock
  Paint.Begin(Img)
  Paint.AntiAlias = bAntiAliasON       '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType       'Paint.LineJoinRound 'as Integer=1
  
  ''Body
  Paint.Rectangle(U * 2, U * 0.25, U * 6, U * 9.5, R)
    
  Paint.LineWidth = U * 0.5
  Paint.Brush = Paint.Color(Color.Gray)
  Paint.Stroke(True)
  Paint.Brush = Paint.Color(Color.White)
  Paint.Fill()
  
  ''Text ...
  Paint.Arc(U * 2.75, U * 3.5, U * 0.15)
  Paint.Arc(U * 3.25, U * 3.5, U * 0.15)
  Paint.Arc(U * 3.75, U * 3.5, U * 0.15)
      
  Paint.LineWidth = U * 0.1
  Paint.Brush = Paint.Color(Color.SoftBlue)
  Paint.Fill()
  
  ''Clock
  MX1 = U * 5.95
  MY1 = U * 2.5
  fRadius = U * 1.6
  fLeft = U * 2.6
  fDayTop = U * 5
  fDayH = U * 1.3
  fDis = U * 0.25
  
  ''Hour, Clock-Hand: ■■○▶
  Paint.MoveTo(MX1, MY1)
  Paint.LineTo(MX1, MY1 - fRadius + (U * 0.75))

  Paint.LineWidth = U * 0.5
  Paint.Brush = Paint.Color(Color.Green)
  Paint.Stroke()

  ''Minute, Clock-Hand: ▪▪▪▪▪▪ - | -
  Paint.MoveTo(MX1, MY1)
  Paint.LineTo(MX1 + fRadius - (U * 0.35), MY1)

  Paint.LineWidth = U * 0.2
  Paint.Brush = Paint.Color(Color.SoftBlue)
  Paint.Stroke()

  ''Center-Point: ●
  Paint.Arc(MX1, MY1, U * 0.25)
  
  Paint.LineWidth = U * 0.75
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.2
  Paint.Brush = Paint.Color(Color.SoftRed)
  Paint.Stroke(True)
  Paint.Fill()

  ''Clock-Radius ○
  Paint.Arc(MX1, MY1, fRadius)

  Paint.LineWidth = U * 0.5
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.275
  Paint.Brush = Paint.Color(Color.SoftBlue)
  Paint.Stroke()

  ''Day +0
  Paint.Rectangle((U * 5) - fLeft, fDayTop + (fDayH * 0) + (fDis * 0), fLeft * 2, fDayH, R)
  
  Paint.LineWidth = U * 0.4
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.SoftRed)
  Paint.Fill()
  
  ''Day +1
  Paint.Rectangle((U * 5) - fLeft, fDayTop + (fDayH * 1) + (fDis * 1), fLeft * 2, fDayH, R)
  
  Paint.LineWidth = U * 0.4
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.Yellow)
  Paint.Fill()
  
  ''Day +2
  Paint.Rectangle((U * 5) - fLeft, fDayTop + (fDayH * 2) + (fDis * 2), fLeft * 2, fDayH, R)
    
  Paint.LineWidth = U * 0.4
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.Green)
  Paint.Fill()
  
  Paint.End
  
  ''Save:
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  If String.InStr(Application.Path, "/home/") > 0 Then sDir = "images"
  
  If IsDir(sDir) = True Then 
    ImgGray = Img.Copy() 'don't forget "()"
    
    sDirFile = sDir &/ Application.Name & "_" & iIconSize & ".png"
    Img.Picture.Save(sDirFile) 
    
    ImgGray = ImgGray.Desaturate()
    sDirFile = sDir &/ Application.Name & "_gray_" & iIconSize & ".png"
    ImgGray.Picture.Save(sDirFile) 
  Endif 
  
  Return Img 'Icon
  
Catch 
  FMain.ErrorText
  
End
Public Sub ClockLoadDefaultHourMinuteSecondCenter()
  
  Dim Img As Image
  Dim iIconSize, iLineEndType, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorYellow, iColorTransWater, it3 As Integer
  Dim U, R As Float
  Dim Text, T As String = ""
  
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  ''activate or deactivate with Comment-line '
  '***********************
  bWhiteBorderON = Settings[FMain.Name &/ "F_bWhiteBorderON", True]
  ' bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNature = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorChange = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  Text = "C" 'Clock
  U = iIconSize / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  
  ' F_iColor = Color.Green 
  ' F_iColorBlue = Color.Lighter(Color.Blue) '&H6472B0F4& 'Spezial-Blue 
  ' F_iColorCut = Color.Background 'or Color.DarkYellow ?
  ' F_iColorDarkGray = Color.DarkGray
  ' F_iColorGray = Color.Lighter(Color.Gray)
  ' F_iColorGreen = Color.Lighter(Color.Green) 
  ' F_iColorMagenta = Color.Magenta
  ' F_iColorNature = Color.RGB(255, 200, 0) 'or yellow foot = &H00FFC800& (Post-Package)
  ' F_iColorOrange = Color.Orange
  ' F_iColorPackage = Color.Lighter(&HFFC800&) 'Post-Package
  ' F_iColorPink = Color.Pink
  ' F_iColorRed = Color.Lighter(Color.Red) 'primary colors > RGB (Red, Green, Blue)
  ' F_iColorViolet = Color.Violet
  ' F_iColorWaterTrans = Color.SetAlpha(Color.DarkGray, 150)
  ' F_iColorYellow = Color.Yellow
  ' F_iColorWhite = Color.White
  ' F_iColorGrayMiddle = Color.Gray
  ' F_iColorDarkBlue = Color.DarkBlue
  ' F_iColorBlack = Color.Black
  '***************************
  ''hhhhhhhhhhhhhhhhmmmmmmmmmmmmmmmmsssssssssssssssssssssss
  For it3 = 0 To 4
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Select Case it3
      Case 0
        T = "-hour"
      Case 1
        T = "-minute"
      Case 2
        T = "-second-centerpoint"  
      Case 3
        T = "-centerpoint"  
      Case 4
        T = "-datepoint"  
    End Select
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    
    If String.InStr(T, "-hour") > 0 Then 
      ''Hour, Line, Pointer --
      Paint.MoveTo(U * 5, U * 5)
      Paint.LineTo(U * 5, U * 2.5)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1.4
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke(True)
      'Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif 
    
    If String.InStr(T, "-minute") > 0 Then 
      ''Minute, Line, Pointer ----
      Paint.MoveTo(U * 5, U * 5)
      Paint.LineTo(U * 5, U * 1.5)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.7
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke(True)
      'Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif 
    
    If String.InStr(T, "-second") > 0 Then 
      ''Second, Line, Pointer ------
      Paint.MoveTo(U * 5, U * 5)
      Paint.LineTo(U * 5, U * 1)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.4
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.2
      Paint.Brush = Paint.Color(iColorRed)
      Paint.Stroke(True)
      'Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif 
    
    If String.InStr(T, "-centerpoint") > 0 Then 
      ''Center, Circle
      Paint.Arc(U * 5, U * 5, U * 0.5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.8
      Paint.Brush = Paint.Color(iColorRed)
      Paint.Stroke(True)
      'Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-datepoint") > 0 Then 
      ''Second, Line, Pointer ------
      Paint.MoveTo(U * 5, U * 5)
      Paint.LineTo(U * 5, U * 1)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorRed)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(iColorWhite)
      Paint.Fill()
    Endif 
    Paint.End
    
    Select Case it3
      Case 0
        If Form14UhrDesign.Window.Visible = True Then Form14UhrDesign.F_imgMinute = Img.Copy() Else FMain.F_imgMinute = Img.Copy()
        
      Case 1
        If Form14UhrDesign.Window.Visible = True Then Form14UhrDesign.F_imgHour = Img.Copy() Else FMain.F_imgHour = Img.Copy()
        
      Case 2
        If Form14UhrDesign.Window.Visible = True Then Form14UhrDesign.F_imgSecond = Img.Copy() Else FMain.F_imgSecond = Img.Copy()
        
      Case 3
        If Form14UhrDesign.Window.Visible = True Then Form14UhrDesign.F_imgCenterPoint = Img.Copy() Else FMain.F_imgCenterPoint = Img.Copy()
        
      Case 4
        If Form14UhrDesign.Window.Visible = True Then Form14UhrDesign.F_imgDatePoint = Img.Copy() Else FMain.F_imgDatePoint = Img.Copy()
        
    End Select
  Next 'it3
  ''hhhhhhhhhhhhhhhhmmmmmmmmmmmmmmmmsssssssssssssssssssssss
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockDigital(Optional dateTime As Date = Now, Optional sTag As String = "Sawasdee") As Image
  ' Example: PictureBoxUhr2.Picture = M07Paint.ClockDigital(...).Picture
  
  Dim Img As Image
  Dim iLineEndType, iIconSize, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow, iColorChange2, iColorChange3 As Integer
  Dim sFontName As String
  Dim U, fHour, fMinute As Float 
  Dim fRectText As RectF
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  Dim iAlign, iBottom As Integer
  
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Color select:
  If String.InStr(sTag, "-green") > 0 Then 
    iColorChange2 = iColorGreen
  Else If String.InStr(sTag, "-blue") > 0 Then 
    iColorChange2 = iColorBlue 
  Else If String.InStr(sTag, "-skyblue") > 0 Then 
    iColorChange2 = Color.Lighter(iColorBlue)
  Else If String.InStr(sTag, "-red") > 0 Then 
    iColorChange2 = iColorRed
  Else If String.InStr(sTag, "-gray") > 0 Then 
    iColorChange2 = iColorGray  
  Else If String.InStr(sTag, "-darkgray") > 0 Then 
    iColorChange2 = iColorDarkGray
  Else If String.InStr(sTag, "-yellow") > 0 Then 
    iColorChange2 = iColorYellow
  Else If String.InStr(sTag, "-watertrans") > 0 Then 
    iColorChange2 = iColorTransWater
  Else If String.InStr(sTag, "-white") > 0 Then 
    iColorChange2 = iColorWhite
  Else 'Default
    iColorChange2 = iColorRed
  Endif 
  
  ''Light
  If String.InStr(sTag, "-onlylight") > 0 Then 
    iColorChange3 = Color.Transparent 
  Else 'Default
    iColorChange3 = Color.SetAlpha(iColorGray, 245)
  Endif 
  
  ''Icon-Size:
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  U = Img.W / 10
  fHour = Img.W / 24
  fMinute = fHour / 60
  
  Paint.Begin(Img)
  ''Text
  Paint.AntiAlias = bAntiAliasON                                                               '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integ
  Paint.LineWidth = 1
  ' Paint.Font.Name = "Ubuntu" 'Default
  ' Paint.Font.Name = "Ubuntu Condensed"' —▶0◀—
  ' Paint.Font.Name = "Ubuntu Thin" 'new, very small stroke
  ' Paint.Font.Name = "FreeSans"
  ' Paint.Font.Name = "Sawasdee" '0 12 3 6 9   simple modern
  ' Paint.Font.Name = "Waree"
  ' Paint.Font.Name = "FreeSerif"
  ' Paint.Font.Name = "FreeMono"
  ' Paint.Font.Name = "Monospace"
  
  ''Font-Name:
  If sTag Like "*ubuntu*condensed*" Then 
    sFontName = "Ubuntu Condensed"
  Else If sTag Like "*ubuntu*thin*" Then 
    sFontName = "Ubuntu Thin"
  Else If sTag Like "*freesans*" Then 
    sFontName = "FreeSans"
  Else If sTag Like "*sawasdee*" Then 
    sFontName = "Sawasdee"
  Endif 
  
  ''Font-Name:
  If Fonts.Exist(sFontName) = True Then 
    Paint.Font.Name = sFontName
  Else 'Default
    Paint.Font.Name = "Ubuntu Condensed" 'alternative
  Endif 
  
  ''Time: 00:00
  If String.InStr(sTag, "-bold") > 0 Then 
    ' Paint.Font.Bold = True
    Paint.LineWidth = U * 0.15
  Else 'Default
    ' Paint.Font.Bold = False
    Paint.LineWidth = U * 0.05
  Endif
  
  If String.InStr(sTag, "-middle") > 0 Then 
    Paint.Font.Size = iIconSize / 6.5
    iAlign = Align.Center
    iBottom = iIconSize
  Else If String.InStr(sTag, "-bottom") > 0 Then 
    Try Paint.Font.Size = U * 1.25
    iAlign = Align.Bottom
    iBottom = U * 8
  Else 
    Paint.Font.Size = iIconSize / 4 'Paint.Font.RichTextWidth("00:00"), Paint.TextExtents("00:00").Width
    fRectText = Paint.TextSize("00:00") 'as RectF
    ' fRectText = Paint.RichTextSize("00:00") 'as RectF
    Paint.Font.Size = Paint.Font.Size * (iIconSize / fRectText.W) '|◀—max—▶|
    iAlign = Align.Center
    iBottom = iIconSize
  Endif
  Paint.Font.Size = FMain.F_fFontSizePlus + Paint.Font.Size
  If Second(Now) Mod 2 = 0 Then ': blinken im Sekundentakt
    Paint.Text(Format(datetime, "hh nn"), 0, 0, iIconSize, iBottom, iAlign)
  Else 
    Paint.Text(Format(datetime, "hh:nn"), 0, 0, iIconSize, iBottom, iAlign) 'without ":"
  Endif 
  
  ' If bWhiteBorderON = True Then
  '   Paint.LineWidth = U * 0.5
  '   Paint.Brush = Paint.Color(Color.White)
  '   Paint.Stroke(True)
  ' Endif
  ' Paint.LineWidth = U * 0.5
  Paint.Brush = Paint.Color(iColorChange2) 'Color.SelectedBackground
  Paint.Stroke(True)
  Paint.Fill()
  
  Paint.End
  
  Return Img 'Rückgabebild
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockGearWheel(Optional dateTime As Date = Now, Optional sTag As String = "") As Image
  ' Beispiel: PictureBoxUhr2.Picture = M07Paint.ClockLCD(...).Picture
  
  Dim Img As Image
  Dim iIconSize, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorYellow As Integer
  Dim U, R, a, b, c, alpha, itF, Radius As Float
  Dim iStep, MX1, MY1, iLineEndType As Integer
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    ' iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    ' iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  U = iIconSize / 10
  R = U * 0.5
  
  If String.InStr(sTag, "-sun") > 0 Then 
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integ
    
    Paint.LineWidth = U * 0.5
    
    a = U * 5 'X▶, Middle, Center, start-point
    b = U * 5 'Y▼
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    
    ''background fill
    Paint.Arc(a, b, U * 3)
    Paint.Brush = Paint.Color(iColorBlue)
    ' Paint.Stroke()
    Paint.Fill()
    
    ''gearwheel ●
    iStep = 15
    For itF = -(iStep / 2) To 360 Step iStep
      alpha = Rad(itF)
      Radius = c * 0.425 '>Line length
      MX1 = a + (Radius * Cos(alpha))
      MY1 = b + (Radius * Sin(alpha))
      Paint.Arc(MX1, MY1, U * 0.25)
      ' Paint.Brush = Paint.Color(Color.Transparent)
      Paint.Operator = Paint.OperatorClear
      Paint.Fill()
    Next 'it
    
    ''inside circles
    Paint.Arc(U * 5, U * 5, U * 2.25)
    ' Paint.Operator = Paint.OperatorClear
    Paint.Operator = Paint.OperatorATop
    Paint.LineWidth = U * 0.5
    Paint.Brush = Paint.Color(iColorYellow)
    ' Paint.Stroke()
    Paint.Fill()
    Paint.End
  Endif
  
  If String.InStr(sTag, "-sun") = 0 Then 
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType        
    Paint.LineWidth = U * 0.5
    
    a = U * 5 'X▶, Middle, Center, start-point
    b = U * 5 'Y▼
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    
    ''background fill
    Paint.Arc(a, b, U * 3)
    Paint.Brush = Paint.Color(iColorGray)
    ' Paint.Stroke()
    Paint.Fill()
    
    ''gearwheel ●
    iStep = 15
    For itF = -(iStep / 2) To 360 Step iStep
      alpha = Rad(itF)
      Radius = c * 0.425 '>Line length
      MX1 = a + (Radius * Cos(alpha))
      MY1 = b + (Radius * Sin(alpha))
      Paint.Arc(MX1, MY1, U * 0.25)
      ' Paint.Brush = Paint.Color(Color.Transparent)
      Paint.Operator = Paint.OperatorClear
      Paint.Fill()
    Next 'it
    
    ''inside circles
    iStep = 90
    For itF = 0 To 360 Step iStep
      alpha = Rad(itF)
      Radius = c * 0.15 '>Line length
      MX1 = a + (Radius * Cos(alpha))
      MY1 = b + (Radius * Sin(alpha))
      '   Radius = c * 0.3 '>Line length
      '   MX2 = a + (Radius * Cos(alpha))
      '   MY2 = b + (Radius * Sin(alpha))
      Paint.Arc(MX1, MY1, U * 0.75, Rad(itF - 45), Rad(90), True)
      
      Paint.Brush = Paint.Color(iColorGray)
      Paint.Operator = Paint.OperatorClear
      ' Paint.Operator = Paint.OperatorATop
      Paint.LineWidth = U * 0.75
      Paint.Stroke(True)
      Paint.Fill()
    Next 'it
    Paint.End
  Endif 
  If Img Then Img = Img.Rotate(Rad(-Second(dateTime) * 6)) '360°Degree / 60 = 6° = 1 Part Minute=Second  |....!....|....!... 12:01, 12:02, ...
  Return Img 'Rückgabebild
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockLCD(Optional dateTime As Date = Now, Optional sTag As String = "") As Image
  ' Beispiel: PictureBoxUhr2.Picture = M07Paint.ClockLCD(...).Picture
  
  Dim Img As Image
  Dim it, iLineEndType, iIconSize, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow, iColorChange1, iColorChange2, iColorChange3 As Integer
  Dim U, R, L As Float
  Dim sNumbers, sNumberN, sText As String
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Color select:
  If String.InStr(sTag, "-green") > 0 Then 
    iColorChange2 = iColorGreen
  Else If String.InStr(sTag, "-blue") > 0 Then 
    iColorChange2 = iColorBlue 
  Else If String.InStr(sTag, "-skyblue") > 0 Then 
    iColorChange2 = Color.Lighter(iColorBlue)
  Else If String.InStr(sTag, "-red") > 0 Then 
    iColorChange2 = iColorRed
  Else If String.InStr(sTag, "-gray") > 0 Then 
    iColorChange2 = iColorGray  
  Else If String.InStr(sTag, "-darkgray") > 0 Then 
    iColorChange2 = iColorDarkGray
  Else If String.InStr(sTag, "-yellow") > 0 Then 
    iColorChange2 = iColorYellow
  Else If String.InStr(sTag, "-watertrans") > 0 Then 
    iColorChange2 = iColorTransWater
  Else If String.InStr(sTag, "-white") > 0 Then 
    iColorChange2 = iColorWhite
  Else 'Default
    iColorChange2 = iColorRed
  Endif 
  
  ''Light
  If String.InStr(sTag, "-onlylight") > 0 Then 
    iColorChange3 = Color.Transparent 
  Else 'Default
    iColorChange3 = Color.SetAlpha(iColorGray, 245)
  Endif 
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  U = Img.W / 10
  R = U * 0.5
  
  Paint.Begin(Img)
  Paint.AntiAlias = bAntiAliasON                                                               '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integ
  ''LCD 00:00
  sTag = String.LCase(sTag)
  If String.InStr(sTag, "-square") > 0 Then 
    Paint.LineCap = Paint.LineCapSquare
  Else 'Default
    Paint.LineCap = Paint.LineCapRound
  Endif
  ' Paint.LineJoin = Paint.LineJoinRound
  Paint.AntiAlias = True 
  Paint.LineWidth = 1
  
  ''Size + Center 
  If String.InStr(sTag, "-sizemax") > 0 Then 
    Paint.Scale(0.75, 0.75)
    Paint.Translate(U * 2.275, U * 1.75)
  Else If String.InStr(sTag, "-middle") > 0 Then 
    ' Paint.Scale(0.7, 0.7)
    ' Paint.Translate(U * 2.75, U * 2.25)
    Paint.Scale(0.4, 0.4)
    Paint.Translate(U * 8, U * 9)
  Else 'Default
    Paint.Scale(0.5, 0.5)
    Paint.Translate(U * 5.75, U * 5)
  Endif
  
  ''LineWidth
  If String.InStr(sTag, "-big") > 0 Then 
    Paint.LineWidth = U * 0.75 
  Else 'Default
    Paint.LineWidth = U * 0.5
  Endif 
  
  '' points ":"       00:00
  Paint.Rectangle(U * 4.25, U * 3.5, U * 0.25, U * 0.75, R / 2)
  Paint.Rectangle(U * 4.25, U * 6, U * 0.25, U * 0.75, R / 2)
  If Second(datetime) Mod 2 = 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
  Paint.Brush = Paint.Color(iColorChange1) 
  Paint.Stroke(True)
  Paint.Fill()
  
  For it = 0 To 3  'Numbers 01:23 =4x
    Select Case it
      Case 0 ''Hour Hh:mm
        sNumbers = Format(Str(Hour(datetime)), "00")
        ' sNumbers = Format(Str(23), "00")
        L = U * 6
        sNumberN = String.Left(sNumbers, 1)
        sText = sNumberN
      Case 1 ''Hour hH:mm
        L = U * 3
        sNumberN = String.Right(sNumbers, 1)
        sText = sText & sNumberN
      Case 2 ''Minute hh:Mm
        sNumbers = Format(Str(Minute(datetime)), "00")
        ' sNumbers = Format(Str(59), "00")
        L = -U * 1.75
        sNumberN = String.Left(sNumbers, 1)
        sText = sText & ":" & sNumberN
      Case 3 ''Minute hh:mM
        L = -U * 4.75
        sNumberN = String.Right(sNumbers, 1) 
        sText = sText & sNumberN
    End Select
    
    ''Lines: |—|
    Paint.MoveTo(U * 4.5 - L, U * 2) '——▶ top
    Paint.LineTo(U * 5.5 - L, U * 2)
    If String.InStr("0235789", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 4.5 - L, U * 5) '——▶ middle
    Paint.LineTo(U * 5.5 - L, U * 5)
    If String.InStr("2345689", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 4.5 - L, U * 8) '——▶ bottom
    Paint.LineTo(U * 5.5 - L, U * 8)
    If String.InStr("023568", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 4 - L, U * 2.5) '▼ left
    Paint.LineTo(U * 4 - L, U * 4.5)
    If String.InStr("045689", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 4 - L, U * 5.5) '▼
    Paint.LineTo(U * 4 - L, U * 7.5)
    If String.InStr("0268", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 6 - L, U * 2.5) '▼ right
    Paint.LineTo(U * 6 - L, U * 4.5)
    If String.InStr("01234789", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
    Paint.MoveTo(U * 6 - L, U * 5.5) '▼
    Paint.LineTo(U * 6 - L, U * 7.5)
    If String.InStr("013456789", sNumberN) > 0 Then iColorChange1 = iColorChange2 Else iColorChange1 = iColorChange3
    Paint.Brush = Paint.Color(iColorChange1) 
    Paint.Stroke()
    
  Next 'it
  Paint.End
  
  Return Img 'Rückgabebild
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockPhythagoras(Optional dateTime As Date = Now, Optional sTag As String = "-hour-minute-second-centerpoint") As Image
  
  Dim Img, imgTemp As Image
  Dim iIconSize, iLineEndType, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow As Integer
  Dim U, R As Float
  Dim fAngle, fOnePart, fAngle1500 As Float
  Dim a, b, c, Radius, alpha As Float
  Dim MX1, MY1, MX2, MY2 As Float
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Icon-Size:
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else  'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  imgTemp = New Image(iIconSize, iIconSize, Color.Transparent)
  
  ''activate or deactivate with Comment-line '
  '***********************
  ' sText = "C" 'Clock
  U = Img.W / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  
  ' F_iColor = Color.Green
  ' F_iColorBlue = Color.Lighter(Color.Blue) '&H6472B0F4& 'Spezial-Blue 
  ' F_iColorCut = Color.Background 'or Color.DarkYellow ?
  ' F_iColorDarkGray = Color.DarkGray
  ' F_iColorGray = Color.Lighter(Color.Gray)
  ' F_iColorGreen = Color.Lighter(Color.Green)
  ' F_iColorMagenta = Color.Magenta
  ' F_iColorNature = Color.RGB(255, 200, 0) 'or yellow foot = &H00FFC800& (Post-Package)
  ' F_iColorOrange = Color.Orange
  ' F_iColorPackage = Color.Lighter(&HFFC800&) 'Post-Package
  ' F_iColorPink = Color.Pink
  ' F_iColorRed = Color.Lighter(Color.Red) 'primary colors > RGB (Red, Green, Blue)
  ' F_iColorViolet = Color.Violet
  ' F_iColorWaterTrans = Color.SetAlpha(Color.DarkGray, 150)
  ' F_iColorYellow = Color.Yellow
  ' F_iColorWhite = Color.White
  ' F_iColorGrayMiddle = Color.Gray
  ' F_iColorDarkBlue = Color.DarkBlue
  ' F_iColorBlack = Color.Black
  '***************************
  
  ''Clock Phythagoras
  Paint.Begin(Img)
  Paint.AntiAlias = bAntiAliasON                                                               '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
  
  sTag = String.LCase(sTag)
  
  ''Hour, Clock-Hand: ■■○▶
  If String.InStr(sTag, "-hour") > 0 Then 
    a = U * 5 'Middle, Center, start-point
    b = U * 5
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    ' L = 30 'one hour
    ''Rad(0) = 03:00                  Clock-Scala
    ''1 Hour 360/12 = 30              Hour = 30°
    ''1 Minute 360/12/5 = 6           Minute = 6°
    ''1 Second 360/12/5 = 6           Second = 6° 'scala '|....|
    'datetime = Time(3, 35, 0) 'Test
    fOnePart = 30
    fAngle1500 = 90 ''-90°|__Position—▶0=360=15:00
    fAngle = (fOnePart * Hour(dateTime)) - fAngle1500 + (fOnePart / 6 * (Minute(dateTime)) * 0.1)
    ' For it = L To 360 Step L  '4xHours 03:00, 06:00, 09:00, 12:00
    alpha = Rad(fAngle)
    Radius = c * 0.2 '>Line length
    MX1 = a '+ (Radius * Cos(alpha))
    MY1 = b '+ (Radius * Sin(alpha))
    Radius = c * 0.3 '>Line length
    MX2 = a + (Radius * Cos(alpha))
    MY2 = b + (Radius * Sin(alpha))
    'Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
    
    Paint.MoveTo(MX1, MY1)
    Paint.LineTo(MX2, MY2)
    
    If bWhiteBorderON = True Then
      Paint.LineWidth = U * 2
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
    Endif
    Paint.LineWidth = U * 1.4
    Paint.Brush = Paint.Color(iColorBlue)
    Paint.Stroke(True)
    'Paint.Brush = Paint.Color(Color.White)
    Paint.Fill()
  Endif 
  
  ''Minute, Clock-Hand: ▪▪▪▪▪▪
  If String.InStr(sTag, "-minute") > 0 Then 
    ''Lines, Pointer, Parts - | -
    a = U * 5 'Middle, Center, start-point
    b = U * 5
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    ''Rad(0) = 03:00                  Clock-Scala
    ''1 Hour 360/12 = 30              Hour = 30°
    ''1 Minute 360/12/5 = 6           Minute = 6°
    ''1 Second 360/12/5 = 6           Second = 6° 'scala '|....|
    fOnePart = 6
    fAngle1500 = 90 ''-90°|__Position—▶0=360=15:00
    fAngle = (fOnePart * Minute(dateTime)) - fAngle1500
    alpha = Rad(fAngle)
    Radius = c * 0.2 '>Line length
    MX1 = a '+ (Radius * Cos(alpha))
    MY1 = b '+ (Radius * Sin(alpha))
    Radius = c * 0.5 '>Line length
    MX2 = a + (Radius * Cos(alpha))
    MY2 = b + (Radius * Sin(alpha))
    
    Paint.MoveTo(MX1, MY1)
    Paint.LineTo(MX2, MY2)
    
    If bWhiteBorderON = True Then
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
    Endif
    Paint.LineWidth = U * 0.7
    Paint.Brush = Paint.Color(iColorGreen)
    Paint.Stroke(True)
    'Paint.Brush = Paint.Color(Color.White)
    Paint.Fill()
  Endif 
  
  ''Second, Clock-Hand: ———————
  If String.InStr(sTag, "-second") > 0 Then 
    a = U * 5 'Middle, Center, start-point
    b = U * 5
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    ''Rad(0) = 03:00                  Clock-Scala
    ''1 Hour 360/12 = 30              Hour = 30°
    ''1 Minute 360/12/5 = 6           Minute = 6°
    ''1 Second 360/12/5 = 6           Second = 6° 'scala '|....|
    fOnePart = 6
    fAngle1500 = 90 ''-90°|__Position—▶0=360=15:00
    fAngle = (fOnePart * Second(dateTime)) - fAngle1500
    
    alpha = Rad(fAngle)
    Radius = c * 0.2 '>Line length
    MX1 = a '+ (Radius * Cos(alpha))
    MY1 = b '+ (Radius * Sin(alpha))
    Radius = c * 0.6 '>Line length
    MX2 = a + (Radius * Cos(alpha))
    MY2 = b + (Radius * Sin(alpha))
    ''Alternative:
    ' Paint.Arc(a, b, U * 4.5, fAngle, fOnePart / 4, True)                                                      'Punkt, Point(X2,Y2)
    
    Paint.MoveTo(MX1, MY1)
    Paint.LineTo(MX2, MY2) 
    
    If bWhiteBorderON = True Then
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
    Endif
    Paint.LineWidth = U * 0.2
    Paint.Brush = Paint.Color(iColorRed)
    Paint.Stroke(True)
    'Paint.Brush = Paint.Color(Color.White)
    Paint.Fill()
  Endif 
  
  ''Center-Point: ●
  If String.InStr(sTag, "-centerpoint") > 0 Then 
    ''Center, Circle
    Paint.Arc(U * 5, U * 5, U * 0.25)
    
    If bWhiteBorderON = True Then
      Paint.LineWidth = U * 1.5
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
    Endif
    Paint.LineWidth = U * 0.8
    Paint.Brush = Paint.Color(iColorRed)
    Paint.Stroke(True)
    'Paint.Brush = Paint.Color(Color.White)
    Paint.Fill()
  Endif
  Paint.End
  
  Return Img  'Phythagoras
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockNumbers(Optional dateTime As Date = Now, Optional sTag As String = "") As Image 
  
  Dim Img As Image
  Dim it, iIconSize, iLineEndType, iStep, iNumber, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow, iColorChange1 As Integer
  Dim U, R, W, H, fClockCounterRadius As Float
  Dim sFontName As String = ""
  Dim iNumbers4x As Integer
  Dim a, b, c, Radius, alpha, fSizeMin, fFontSize As Float
  Dim MX1, MY1 As Float
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  ''activate or deactivate with Comment-line '
  '***********************
  ''Example: hPicture = M07Paint.ClockNumbers(dateTime, "-freesans-small-blue-radius6").Picture
  ''sTag: Font-Name: ubuntu*condensed, ubuntu*thin, freesans, sawasdee, Font-Size: big, middle, small, Font-Color: blue, gray, darkgray, green, Font-Bold: bold, Font-Circle: radius3, radius4, radius5, radius6, radius7, radius8, numbers4x, nowhite
  
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  ' 
  ''Color select:
  If String.InStr(sTag, "-green") > 0 Then 
    iColorChange1 = iColorGreen
  Else If String.InStr(sTag, "-blue") > 0 Then 
    iColorChange1 = iColorBlue
  Else If String.InStr(sTag, "-red") > 0 Then 
    iColorChange1 = iColorRed
  Else If String.InStr(sTag, "-gray") > 0 Then 
    iColorChange1 = iColorGray
  Else If String.InStr(sTag, "-darkgray") > 0 Then 
    iColorChange1 = iColorDarkGray
  Else If String.InStr(sTag, "-watertrans") > 0 Then 
    iColorChange1 = iColorTransWater
  Else If String.InStr(sTag, "-white") > 0 Then 
    iColorChange1 = iColorWhite
  Else If String.InStr(sTag, "-yellow") > 0 Then 
    iColorChange1 = iColorYellow
  Else 'Default
    iColorChange1 = Color.Black
  Endif 
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  
  ' sText = "C" 'Clock
  U = Img.W / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  
  ''Clock-Numbers: 0-3-6-9 or 15-18-21-24 or all
  Paint.Begin(Img)
  Paint.AntiAlias = bAntiAliasON                                                               '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType      
  
  ''Font-Name:
  If sTag Like "*ubuntu*condensed*" Then 
    sFontName = "Ubuntu Condensed"
  Else If sTag Like "*ubuntu*thin*" Then 
    sFontName = "Ubuntu Thin"
  Else If sTag Like "*freesans*" Then 
    sFontName = "FreeSans"
  Else If sTag Like "*sawasdee*" Then 
    sFontName = "Sawasdee"
  Endif 
  
  If Fonts.Exist(sFontName) = True Then 
    Paint.Font.Name = sFontName
  Else 'Default
    Paint.Font.Name = "Ubuntu Condensed" 'alternative
  Endif 
  
  ''Font-Size:
  If String.InStr(sTag, "-big") > 0 Then 
    fFontSize = FMain.F_fFontSizePlus + U * 1.5 
  Else If String.InStr(sTag, "-middle") > 0 Then 
    fFontSize = FMain.F_fFontSizePlus + U * 0.85
  Else If String.InStr(sTag, "-small") > 0 Then 
    fFontSize = FMain.F_fFontSizePlus + U * 0.65
  Else 'Default
    fFontSize = FMain.F_fFontSizePlus + U * 0.5
  Endif 
  
  If fFontSize < 2 Then fFontSize = 2
  Paint.Font.Size = fFontSize
  
  ''Font-Area:
  W = Paint.Font.TextWidth("00") / 2
  H = Paint.Font.TextHeight("00") / 2
  
  ''Font-Circle-Radius: ○
  If String.InStr(sTag, "-radius3") > 0 Then 
    fClockCounterRadius = 0.35
  Else If String.InStr(sTag, "-radius4") > 0 Then 
    fClockCounterRadius = 0.4
  Else If String.InStr(sTag, "-radius5") > 0 Then 
    fClockCounterRadius = 0.45
  Else If String.InStr(sTag, "-radius6") > 0 Then 
    fClockCounterRadius = 0.5
  Else If String.InStr(sTag, "-radius7") > 0 Then 
    fClockCounterRadius = 0.55
  Else If String.InStr(sTag, "-radius8") > 0 Then 
    fClockCounterRadius = 0.6
  Else 'Default
    fClockCounterRadius = 0.4
  Endif
  
  ''Clock Numbers 12x, 4x ?
  If String.InStr(sTag, "-numbers4x") > 0 Then 
    iNumbers4x = 3 '0,1,2,3,=4x   3-6-9-12 or 15-18-21-24
  Else 'Default
    iNumbers4x = 1 '=12x  1-2-3-4-5-6-7-8-9-10-11-12 or 13-14-15-16-17-18-19-20-21-22-23-24
  Endif 
  
  ''Circle-Points xy, Clock-Number 1-12:
  a = U * 5 'X▶, Middle, Center, start-point
  b = U * 5 'Y▼
  c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
  iStep = 30 '=30°=1h, 12x
  ' iNumber = 12
  If Hour(datetime) < 6 Then iNumber = 0
  If Hour(datetime) > 12 Then iNumber = 12
  fSizeMin = Paint.Font.Size
  
  ''Clock-Numbers:
  For it = -60 To 360 - 90 Step iStep '0=360°=15:00h  0h (=12h=24h) = -90°, begin with 1 =-60° 
    iNumber = iNumber + 1
    If iNumber Mod iNumbers4x = 0 Then ' 12x or 4x ?
      alpha = Rad(it)   '00:00=-90°
      Radius = c * fClockCounterRadius '>Line length
      MX1 = a + (Radius * Cos(alpha))
      MY1 = b + (Radius * Sin(alpha))
      ' Radius = c * 0.4 '>Line length
      ' MX2 = a + (Radius * Cos(alpha))
      ' MY2 = b + (Radius * Sin(alpha))
      ' Paint.Arc(MX2, MY2, U * 0.5)
      If iNumber > 9 Then 
        fSizeMin = fSizeMin - (U * 0.01)
        If fSizeMin < 2 Then fSizeMin = 2
      Endif 
      Paint.Font.Size = fSizeMin
      Paint.Text(Str(iNumber), MX1 - (W / 2), MY1 - (H / 2), W, H, Align.Center) ' |
      ' Paint.RichText(Str(iNumber), MX1 - (W / 2), MY1 - (H / 2), W, H, Align.Center) ' |
      If String.InStr(sTag, "-nowhite") > 0 Then 
        ''...
      Else 'Default
        If bWhiteBorderON = True Then
          Paint.LineWidth = Paint.Font.Size / 2
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
      Endif 
      If String.InStr(sTag, "-bold") > 0 Then 
        Paint.LineWidth = U * 0.1 
      Else  'Default
        Paint.LineWidth = U * 0.01 
      Endif 
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
  Next 
  Paint.End
  
  Return Img 'Rückgabebild
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockSunUpDown(Optional dateTime As Date = Now, Optional sTag As String = "") As Image
  
  Dim Img As Image
  Dim iLineEndType, iColorGreen, iColorBlue, iColorRed, iColorGray, ColN, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow As Integer
  Dim U, R, itF, L, fLineBig, fSA, fSU, fTwilight As Float ' fTwilight (Dämmerung)
  Dim dateSunUp, dateSunDown As Date
  Dim it As Integer
  
  Dim a, b, c, Radius, alpha, fHour, fMinute As Float
  Dim MX2, MY2 As Float
  Dim iIconSize As Integer
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  
  ''activate or deactivate with Comment-line '
  '***********************
  sTag = String.LCase(sTag)
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0 |--|
  iLineEndType = Paint.LineCapRound 'as Integer=1 (--)
  '***********************
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ColN = iColorBlue 'Night
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif
  
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  
  ' sText = "C" 'Clock
  U = Img.W / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  
  ''Check up ○ ● down
  If Not FMain.F_dateSunUp Or DateDiff(FMain.F_dateSunUp, dateTime, gb.Day) <> 0 Then 
    dateSunUp = M02Astro.AstroSunUpDown(datetime) 'as Date
  Endif 
  
  dateSunUp = FMain.F_dateSunUp
  dateSunDown = FMain.F_dateSunDown
  
  ''Night-Day-Night, Horizontal: ■■■□□□□□■■■
  If String.InStr(sTag, "-horizontal") > 0 Then 
    
    fHour = Img.W / 24
    fMinute = fHour / 60
    fTwilight = fMinute * 90  ' =90 Minute (Dämmerung)
    fSA = (fHour * Hour(dateSunUp)) + (fMinute * Minute(dateSunUp)) 
    fSU = (fHour * Hour(dateSunDown)) + (fMinute * Minute(dateSunDown))
    
    Paint.Begin(Img)
    ''Text
    Paint.LineCap = Paint.LineCapRound
    Paint.LineJoin = Paint.LineJoinRound
    Paint.AntiAlias = bAntiAliasON 
    Paint.LineWidth = 1
    
    ''Scale, Rule 24h:     |||...|
    For it = 0 To 24
      If it Mod 6 = 0 Then 
        Paint.MoveTo(fHour * it, U * 8.75)
        Paint.LineTo(fHour * it, U * 9.5)
        Paint.Brush = Paint.Color(iColorDarkGray) 
        Paint.LineWidth = 3
      Else 
        Paint.MoveTo(fHour * it, U * 8.5)
        Paint.LineTo(fHour * it, U * 9.5)
        Paint.Brush = Paint.Color(ColN)
        Paint.LineWidth = U * 0.2
      Endif 
      Paint.Stroke()
    Next
    
    'Quarter 3h
    If String.InStr(sTag, "-quarter") > 0 Then 
      For it = 0 To 24
        If it Mod 6 = 0 Then 
          Paint.Rectangle(fHour * it, U * 8.75, fHour * 6, U * 1, 0)
          ' Paint.MoveTo(fHour * it, U * 7.75)
          ' Paint.LineTo(fHour * it, U * 9.5)
        Endif 
      Next
      Paint.Brush = Paint.Color(iColorDarkGray) 
      Paint.LineWidth = 1
      Paint.Stroke()
    Endif 
    
    ''Line day 24h ■■■■■■■■
    ' Paint.MoveTo(U * 0, U * 9.75)
    ' Paint.LineTo(U * 10, U * 9.75)
    ' 
    ' If bWhiteBorderON = True Then
    '   Paint.LineWidth = U * 1
    '   Paint.Brush = Paint.Color(Color.White)
    '   Paint.Stroke(True)
    ' Endif
    ' Paint.LineWidth = U * 0.5
    ' Paint.Brush = Paint.Color(iColorBlue)
    ' Paint.Stroke()
    'Paint.Brush = Paint.Color(Color.White)
    ' Paint.Fill()
    
    ''Rule, SunUpDown:
    Paint.LineCap = Paint.LineCapButt '■
    
    ''Night-Day-Night:  ▪▪▪□□□□□▪▪▪
    ''Night
    Paint.MoveTo(0, U * 9.75)
    Paint.LineTo(fSA, U * 9.75)
    Paint.LineWidth = U * 0.25
    Paint.Brush = Paint.Color(ColN) '■
    Paint.Stroke()
    
    ''Night —▶ Day (Dämmerung)
    Paint.MoveTo(fSA, U * 9.75)
    Paint.LineTo(fSA + fTwilight, U * 9.75)
    Paint.LineWidth = U * 0.25
    Paint.Brush = Paint.Color(iColorGray) '■□
    Paint.Stroke()
    
    ''Day
    Paint.MoveTo(fSA + fTwilight, U * 9.75)
    Paint.LineTo(fSU, U * 9.75)
    Paint.LineWidth = U * 0.5
    Paint.Brush = Paint.Color(iColorYellow) '□
    Paint.Stroke()
    
    ''Night ◀— Day (Dämmerung)
    Paint.MoveTo(fSU, U * 9.75)
    Paint.LineTo(fSU + fTwilight, U * 9.75)
    Paint.LineWidth = U * 0.25
    Paint.Brush = Paint.Color(iColorGray) '□■
    Paint.Stroke()
    
    ''Night
    Paint.MoveTo(fSU + fTwilight, U * 9.75)
    Paint.LineTo(U * 10, U * 9.75)
    Paint.LineWidth = U * 0.25
    Paint.Brush = Paint.Color(ColN) '■
    Paint.Stroke()
    
    Paint.LineCap = Paint.LineCapRound '●
    
    ''Time-Pin | Position:   ■■■□□□|□□□■■■
    L = (fHour * Hour(datetime)) + (fMinute * Minute(datetime))
    
    ' Paint.MoveTo(L, U * 8.75)
    ' Paint.LineTo(L, U * 9.5)      '|
    ' 
    ' Paint.LineWidth = U * 0.25
    ' Paint.Brush = Paint.Color(iColorBlue)
    ' Paint.Stroke()
    
    ''Sun:
    Paint.Arc(L, U * 7.5, U * 0.5)  '○
    
    If bWhiteBorderON = True Then
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
    Endif
    Paint.LineWidth = U * 0.25
    Paint.Brush = Paint.Color(iColorYellow)
    Paint.Stroke(True)
    'Paint.Brush = Paint.Color(Color.White)
    Paint.Fill() 
    Paint.End
  Else If String.InStr(sTag, "-doublering") > 0 Then 
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType      
    '1h=30°, 30/5m=6
    'half-light, dusk  up ●—▷○,  down ○–▷●, night|||:::...day, "general" round 1 1/2 hour = "90 Minutes"
    
    ' datetime = Date(Year(Date), Month(Date), Day(Date), 1, 0, 0) 'test individual time
    
    ' If String.InStr(sTag, "-little") > 0 Then 
    '   itF = 1.5 
    ' Else If String.InStr(sTag, "-small") > 0 Then 
    '   itF = 2.5
    ' Else If String.InStr(sTag, "-middle") > 0 Then  
    '   itF = 3.5
    ' Else If String.InStr(sTag, "-big") > 0 Then  
    '   itF = 4.5
    ' Else 'Default
    itF = 3
    ' Endif  
    
    ' If String.InStr(sTag, "-linebig") > 0 Then 
    '   fLineBig = 3 'x3
    ' Else 'Default
    fLineBig = 1.5 'x1
    ' Endif
    
    Paint.LineCap = Paint.LineCapButt '■
    
    ''00:00-12:00h Night —▶ Day, ○ Sun up ▲ ....................................
    dateSunUp = FMain.F_dateSunUp
    dateSunDown = FMain.F_dateSunDown
    fHour = 360 / 12
    fMinute = fHour / 60
    fTwilight = fMinute * 90  ' =90 Minute (Dämmerung)
    fSA = (fHour * Hour(dateSunUp)) + (fMinute * Minute(dateSunUp)) 
    L = fSA
    
    ''00:00-12:00h. Night ● 
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), False) 'Start -90 = 00:00h, Length = L
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(ColN) '●
    Paint.Stroke()
    
    ''Night —▶ Day (Dämmerung) ●○
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), False) 'length=1h+30m=90Minute
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(iColorGray) '●○
    Paint.Stroke()
    
    ''00:00-12:00h. Day ○
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), False)
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(iColorYellow) '○
    Paint.Stroke()
    
    '>12:00-24:00h''○ Round Clock, day —▶ night, ● Sun down ▼ ....................................
    
    dateSunUp = FMain.F_dateSunUp
    dateSunDown = DateAdd(FMain.F_dateSunDown, gb.Hour, -12) 'as Date
    fHour = 360 / 12
    fMinute = fHour / 60
    fTwilight = fMinute * 90  ' =90 Minute (Dämmerung)
    fSU = (fHour * Hour(dateSunDown)) + (fMinute * Minute(dateSunDown)) 
    L = fSU
    
    itF = 3.5
    
    Paint.LineCap = Paint.LineCapButt '■
    ''12:00-24:00h. Day ○
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), False) 'Start -90 = 00:00h, Length = L
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(iColorYellow) '○
    Paint.Stroke()
    
    ''Day —▶ Night (Dämmerung) ○●
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), False) 'length=1h+30m=90Minute
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(iColorGray) '○●
    Paint.Stroke()
    
    ''12:00-24:00h. Night ●
    Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), False)
    Paint.LineWidth = U * 0.25 * fLineBig
    Paint.Brush = Paint.Color(ColN) '●
    Paint.Stroke()
    Paint.End 'Double-Ring..............................................................
    
  Else ''Single-Ring, Night-Day-Night, Circle: ○ Sun-Up Sun-Down
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType      
    a = U * 5 'X▶, Middle, Center, start-point
    b = U * 5 'Y▼
    c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
    '1h=30°, 30/5m=6
    'half-light, dusk  up ●—▷○,  down ○–▷●, night|||:::...day, "general" round 1 1/2 hour = "90 Minutes"
    
    ' datetime = Date(Year(Date), Month(Date), Day(Date), 1, 0, 0) 'test individual time
    
    If String.InStr(sTag, "-little") > 0 Then 
      itF = 1.5 
    Else If String.InStr(sTag, "-small") > 0 Then 
      itF = 2.5
    Else If String.InStr(sTag, "-middle") > 0 Then  
      itF = 3.5
    Else If String.InStr(sTag, "-big") > 0 Then  
      itF = 4.5
    Else 'Default
      itF = 3
    Endif  
    
    If String.InStr(sTag, "-linebig") > 0 Then 
      fLineBig = 3 'x3
    Else 'Default
      fLineBig = 1 'x1
    Endif
    
    Paint.LineCap = Paint.LineCapButt '■
    ''half circle (Halbkreis, Nachthimmel oder Taghimmel)
    If String.InStr(sTag, "-nightday") > 0 Then 
      Paint.Arc(U * 5, U * 5, U * itF, Rad(-180), Rad(180), False) 'length=1h+30m=90Minute
      If datetime < dateSunUp Or datetime > dateSunDown Then
        Paint.Brush = Paint.Color(ColN)
      Else 
        Paint.Brush = Paint.Color(iColorYellow)  
      Endif 
      Paint.LineWidth = U * 0.25 * fLineBig
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If Hour(datetime) < 12 Then ''00:00-12:00h Night —▶ Day, ○ Sun up ▲ ....................................
      dateSunUp = FMain.F_dateSunUp
      dateSunDown = FMain.F_dateSunDown
      fHour = 360 / 12
      fMinute = fHour / 60
      fTwilight = fMinute * 90  ' =90 Minute (Dämmerung)
      fSA = (fHour * Hour(dateSunUp)) + (fMinute * Minute(dateSunUp)) 
      L = fSA
      
      ''00:00-12:00h. Night ● 
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), False) 'Start -90 = 00:00h, Length = L
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(ColN) '●
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), True)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(ColN, 200)) '●
        Paint.Fill()
      Endif 
      
      ''Night —▶ Day (Dämmerung) ●○
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), False) 'length=1h+30m=90Minute
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(iColorGray) '●○
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), True) 'length=1h+30m=90Minute
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGray, 200)) '●○
        Paint.Fill()
      Endif 
      
      ''00:00-12:00h. Day ○
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), False)
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(iColorYellow) '○
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), True)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorYellow, 200)) '○
        Paint.Fill()
      Endif 
      
      ''point ○
      If String.InStr(sTag, "-sunpoint") > 0 Then '"SU", Sun up △
        alpha = Rad(-90 + L)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.35)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25 
        Paint.Brush = Paint.Color(iColorYellow)
        Paint.Fill()
      Endif 
      
    Else ''>12:00-24:00h''○ Round Clock, day —▶ night, ● Sun down ▼ ....................................
      
      dateSunUp = FMain.F_dateSunUp
      dateSunDown = DateAdd(FMain.F_dateSunDown, gb.Hour, -12) 'as Date
      fHour = 360 / 12
      fMinute = fHour / 60
      fTwilight = fMinute * 90  ' =90 Minute (Dämmerung)
      fSU = (fHour * Hour(dateSunDown)) + (fMinute * Minute(dateSunDown)) 
      L = fSU
      
      Paint.LineCap = Paint.LineCapButt '■
      ''12:00-24:00h. Day ○
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), False) 'Start -90 = 00:00h, Length = L
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(iColorYellow) '○
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90), Rad(L), True)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorYellow, 200)) '○
        Paint.Fill()
      Endif 
      
      ''Day —▶ Night (Dämmerung) ○●
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), False) 'length=1h+30m=90Minute
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(iColorGray) '○●
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L), Rad(fTwilight), True) 'length=1h+30m=90Minute
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGray, 200)) '○●
        Paint.Fill()
      Endif 
      
      ''12:00-24:00h. Night ●
      If String.InStr(sTag, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), False)
        Paint.LineWidth = U * 0.25 * fLineBig
        Paint.Brush = Paint.Color(ColN) '●
        Paint.Stroke()
      Else If String.InStr(sTag, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * itF, Rad(-90 + L + fTwilight), Rad(360 - (L + fTwilight)), True)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(ColN, 200)) '●
        Paint.Fill()
      Endif 
      
      ''point ●
      If String.InStr(sTag, "-sunpoint") > 0 Then '"SU" Sun down ▼
        alpha = Rad(-90 + L)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.35)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25 
        Paint.Brush = Paint.Color(ColN)
        Paint.Fill()
      Endif 
    Endif '..............................................................
    Paint.End
  Endif 'Circle ○
  
  Return Img 'Rückgabebild
  
Catch 
  FMain.ErrorText
  
End

Public Function ClockCreatePartFiles() As Picture
  
  Dim Img As Image
  Dim iIconSize, iLineEndType, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorTransWater, iColorWhite, iColorYellow, iColorChange1 As Integer
  Dim it3, it4, it5 As Integer
  Dim U, R As Float
  ' Dim fAngle, fOnePart, fAngle1500 As Float
  ' Dim a, b, c, Radius, alpha As Float
  ' Dim MX1, MY1, MX2, MY2 As Float
  Dim bIconThemeAllAddON As Boolean = False
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  Dim T As String 
  
  ' bWhiteBorderON = Settings[FMain.Name &/ "F_bWhiteBorderON", True]
  bWhiteBorderON = FMain.F_bWhiteBorderON
  bAntiAliasON = True
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Check Color-Palette:
  If Not FMain.F_iiIconClockColorsB Then M05.ColorClockGetSettings()
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
  Endif 
  
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    ' iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    ' iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    ' iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    ' iColorCut = iColorMenuGray
  Endif
  
  ''Check Icon-Size:
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else  'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  
  ''activate or deactivate with Comment-line '
  '***********************
  ' sText = "C" 'Clock
  U = iIconSize / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  '***************************
  
  For it4 = 0 To 3 'Figure
    For it3 = 0 To 3 'Colors
      Select Case it4 
        Case 0
          T = "-timecenterpoint-little"'●
        Case 1
          T = "-timecenterpoint-middle-whiteborderoff"'●
        Case 2
          T = "-timecenterpoint-big"'●
        Case 3
          T = "-timecenterpoint-big-fillred"'●
      End Select 
      
      Select Case it3 'Colors ○●○○
        Case 0 'RGB(Red,Green,Blue)
          T = T & "-red"
          iColorChange1 = iColorRed
        Case 1
          T = T & "-green"
          iColorChange1 = iColorGreen
        Case 2
          T = T & "-blue"
          iColorChange1 = iColorBlue
        Case 3
          T = T & "-gray"
          iColorChange1 = iColorGray
          
      End Select 
      
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      
      Paint.Begin(Img)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
      
      If String.InStr(T, "-timecenterpoint") > 0 Then '●
        If String.InStr(T, "-little") > 0 Then Paint.Arc(U * 5, U * 5, U * 0.15)
        If String.InStr(T, "-middle") > 0 Then Paint.Arc(U * 5, U * 5, U * 0.25)
        If String.InStr(T, "-big") > 0 Then Paint.Arc(U * 5, U * 5, U * 0.5)
        
        If String.InStr(T, "-whiteborderoff") > 0 Then
          '...
        Else  
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
        Endif 
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke(True)
        If String.InStr(T, "-fillred") > 0 Then Paint.Brush = Paint.Color(iColorRed)
        Paint.Fill()
      Endif 
      
      Paint.End
      ' it5 = it5 + 1
      ' sFile = "extra" & T & "-" & Str(it5) & ".png" 
      ' sPath = sDir &/ sFile
      ' Img.Save(sPath)
      ' If Exist(sPath) = True Then 
      '   If ssSplitPaths.Find(sPath) = -1 Then ssSplitPaths.Add(sPath) 'not double
      ' Endif 
      
      it5 = it5 + 1
      Form14UhrDesign.F_sLastIconName = "clock" & String.LCase(T) & "-" & Str(it5)
      Form14UhrDesign.F_imgLastIconImage = Img
      If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
      If Form14UhrDesign.F_bESCpressedON = True Then Break
    Next 'it3
  Next 'it4
  ' If ssSplitPaths Then Settings[FMain.Name &/ "sExtraPartsPaths"] = ssSplitPaths.Join(gb.NewLine) 
  
Catch 
  FMain.ErrorText
  
End



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M02Astro.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M02Astro.module
15,2 KB
' Gambas module file

Public Function SommerzeitAnfangEnde(Optional dateDatum As Date = Now) As Integer 
  ' Liegt das Datum innerhalb der Sommerzeit? 
  
  Dim sTimeSummerBegin, sTimeSummerEnd As String
  Dim it, iDiffMinutes As Integer
  Dim dateSummerBegin, dateSummerEnd As Date
  
  sTimeSummerBegin = Format(dateDatum, "yyyy") & Settings[FMain.Name &/ "Astro/TimeSummerBegin", "-03-31"]
  sTimeSummerEnd = Format(dateDatum, "yyyy") & Settings[FMain.Name &/ "Astro/TimeSummerEnd", "-10-31"] ' 31.10.
  
  dateSummerBegin = M01Functions.DateCheckyyyymmddhhnn(sTimeSummerBegin, "00:00") 'as Date
  dateSummerEnd = M01Functions.DateCheckyyyymmddhhnn(sTimeSummerEnd, "00:00") 'as Date
  
  ''Begin:
  If WeekDay(dateSummerBegin) = gb.Sunday Then
    '... 
  Else
    For it = 31 To 1 Step -1
      dateSummerBegin = DateAdd(dateSummerBegin, gb.day, -1)
      If WeekDay(dateSummerBegin) = gb.Sunday Then Break 
    Next
  Endif
  FMain.F_dateTimeSummerBegin = dateSummerBegin
  Settings[FMain.Name &/ "F_dateTimeSummerBegin"] = dateSummerBegin
  
  ''End:
  If WeekDay(dateSummerEnd) = gb.Sunday Then
    '... 
  Else
    For it = 31 To 1 Step -1
      dateSummerEnd = DateAdd(dateSummerEnd, gb.day, -1)
      If WeekDay(dateSummerEnd) = gb.Sunday Then Break 
    Next
  Endif
  FMain.F_dateTimeSummerEnd = dateSummerEnd
  Settings[FMain.Name &/ "F_dateTimeSummerEnd"] = dateSummerEnd
  
  ' dateYearBegin = Date(Year(dateDatum), 1, 1)
  
  ' iDiff = DateDiff(dateDatum, dateYearBegin, gb.day)
  ' iBegin = DateDiff(dateSummerBegin, dateYearBegin, gb.day)
  ' iEnd = DateDiff(dateSummerEnd, dateYearBegin, gb.day)
  ' iDiffHours = DateDiff(Date.ToUTC(dateDatum), dateDatum, gb.Hour) ' neu in Gambas3, Date.ToUTC needs component: gb.util
  iDiffMinutes = DateDiff(Date.ToUTC(dateDatum), dateDatum, gb.Minute)
  'System.TimeZone 'Component (gb) = Basis   Example: "-7200" 'as Integer, Seconds
  ' If iDiffHours = 2 Then 
  ' ' If iDiff <= iBegin And iDiff >= iEnd Then
  '   ' sValue = Settings[FMain.Name &/ "Astro/MESZ", "2"] 'Datum innerhalb der Sommerzeit
  '   Print "MESZ = +2h"
  ' Else
  '   ' sValue = Settings[FMain.Name &/ "Astro/MEZ", "1"] 'Datum außerhalb der Sommerzeit
  '   Print "MEZ = +1h"
  ' Endif
  ' iDiffHours = ? 'innerhalb der Sommerzeit MESZ=+2 oder Winterzeit MEZ=+1?
  ' If iDiffHours > -1 Then sValue = "+" Else sValue = ""
  
  ' Print "UTC" & sValue & Str(iDiffHours) & "h"
  FMain.F_iTimeSummerMinutesDiff = iDiffMinutes
  
  Return iDiffMinutes 'as Integer Rückgabewert
  
  ''__________________________________________________________''
  'März und Oktober haben nach DIN immer 31 Tage 
  'MEZ=Mittel-Europäische-Zeit
  'MESZ=Mittel-Europäische-Sommer-Zeit
  'SommerzeitAnfang ist der letzte Sonntag im März +1h 
  
Catch 
  FMain.ErrorText
  
End 

Public Function AstroSunUpDown(Optional dateDatum As Date = Now) As Date
  'Sun up▲ down▼
  
  Dim fLaengengrad, fBreitengrad As Float
  Dim sRegion As String 
  Dim dateAstro As Date
  
  If dateDatum Then
    'fLaengengrad = 10 'Deutschland 6-15, -West, +Ost 
    'fBreitengrad = 50 'Deutschland 47-55, -Süd, +Nord 
    sRegion = Settings[FMain.Name &/ "Astro/Laengengrad_Breitengrad", "10+50+Region M"] ' 10+50= gerundet ca. Fulda. "M" Mitte zwischen Hamburg und München.
    
    If sRegion <> "" Then
      sRegion = Replace(sRegion, ",", ".") ' Komma durch Punkt ersetzen
      sRegion = Replace(sRegion, Space(1), "") ' Leerzeichen entfernen
      fLaengengrad = Val(M01Functions.TextSplit(sRegion, 0, "+"))
      fBreitengrad = Val(M01Functions.TextSplit(sRegion, 1, "+"))
    Endif
    If fLaengengrad = 0 Then fLaengengrad = 10
    If fBreitengrad = 0 Then fBreitengrad = 50
    
    dateAstro = Sonnenaufgang(dateDatum, fLaengengrad, fBreitengrad) 'as Date
    FMain.F_dateSunUp = dateAstro
    Settings[FMain.Name &/ "F_dateSunUp"] = Str(FMain.F_dateSunUp) 'date not change, take string
    
    dateAstro = Sonnenuntergang(dateDatum, fLaengengrad, fBreitengrad) 'as Date
    FMain.F_dateSunDown = dateAstro
    Settings[FMain.Name &/ "F_dateSunDown"] = Str(FMain.F_dateSunDown)
    
    ' Print "FMain.F_dateSunUp", FMain.F_dateSunUp
    ' Print "FMain.F_dateSunDown", FMain.F_dateSunDown
  Endif
  
  Return dateAstro 'Rückgabewert leer oder Date 
  
Catch 
  FMain.ErrorText
  
End

Public Function Sonnenaufgang(Optional dateDatum As Date = Now, Optional fLaengengrad As Float, Optional fBreitengrad As Float) As Date
  '○Sun up▲
  
  Dim fDeklination, fDiffWozMoz As Float
  Dim iYearDay, fHorizontSunUp As Float
  Dim fDiffMittag, fDummy As Float
  Dim fSunUp As Float
  Dim dateYearBegin, dateTime As Date
  
  'CONST Pi = 3.141592653       'Pi ist in Gambas3 bereits ein Name mit Zahlenwert
  
  'Sonnenaufgang bei -50 Bogenminuten, fBreitengrad=50
  fHorizontSunUp = (-fBreitengrad / 60) * Pi / 180
  
  'Tag des Jahres
  dateYearBegin = Date(Year(dateDatum), 1, 1)
  iYearDay = DateDiff(dateYearBegin, dateDatum, gb.day)
  fBreitengrad = fBreitengrad * Pi / 180
  fLaengengrad = fLaengengrad * Pi / 180
  
  'Breitengrad, über dem die Sonne Mittags senkrecht steht
  fDeklination = 0.40954 * Sin(0.0172 * (iYearDay - 79.35))
  
  'Differenz zum Mittag in Stunden berechnen
  fDummy = (Sin(fHorizontSunUp) - Sin(fBreitengrad) * Sin(fDeklination)) / (Cos(fBreitengrad) * Cos(fDeklination))
  fDiffMittag = 12 * (Atn((fDummy * -1) / Sqr(fDummy * -1 * fDummy + 1)) + 2 * Atn(1)) / Pi
  fDiffWozMoz = -0.1752 * Sin(0.03343 * iYearDay + 0.5474) - 0.134 * Sin(0.018234 * iYearDay - 0.1939)
  fSunUp = (12 - fDiffMittag - fDiffWozMoz + (15 - fLaengengrad * 180 / Pi) * 4 / 60) / 24
  'fSunUp = Format(CDate(fSunUp), "hh:nn:ss")  'Float 0,123456789 > String "12:34:56"
  dateTime = CDate(fSunUp) 'as Date  hier Tag 0, Time 00:00:00     CDate(Day vor Komma, Time nach Komma)
  dateTime = Date(Year(dateDatum), Month(dateDatum), Day(dateDatum), Hour(dateTime), Minute(dateTime), Second(dateTime))
  
  Return dateTime 'as Date 
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  ' Fußnote: 
  ' in VB Double > in Gambas Float  Kommazahlen
  ' Kurzes Grundgeruest. Berechnung hier nur als grobe Kurzform.
  
Catch 
  FMain.ErrorText
  
End

Public Function Sonnenuntergang(Optional dateDatum As Date = Now, Optional fLaengengrad As Float, Optional fBreitengrad As Float) As Date
  '○Sun down▼
  
  Dim fDeklination, fDiffWozMoz As Float
  Dim iYearDay, fHorizontSunUp As Float
  Dim fDiffMittag, fDummy As Float
  Dim fSunDown As Float
  Dim dateYearBegin, dateTime As Date
  
  'CONST Pi = 3.141592653       'Pi ist in Gambas3 bereits ein Name mit Zahlenwert
  
  'Sonnenuntergang bei -50 Bogenminuten
  fHorizontSunUp = (-fBreitengrad / 60) * Pi / 180
  
  'Tag des Jahres
  dateYearBegin = Date(Year(dateDatum), 1, 1)
  iYearDay = DateDiff(dateYearBegin, dateDatum, gb.day)
  fBreitengrad = fBreitengrad * Pi / 180
  fLaengengrad = fLaengengrad * Pi / 180
  
  'Breitengrad, über dem die Sonne Mittags senkrecht steht
  fDeklination = 0.40954 * Sin(0.0172 * (iYearDay - 79.35))
  
  'Differenz zum Mittag in Stunden berechnen
  fDummy = (Sin(fHorizontSunUp) - Sin(fBreitengrad) * Sin(fDeklination)) / (Cos(fBreitengrad) * Cos(fDeklination))
  fDiffMittag = 12 * (Atn((fDummy * -1) / Sqr(fDummy * -1 * fDummy + 1)) + 2 * Atn(1)) / Pi
  fDiffWozMoz = -0.1752 * Sin(0.03343 * iYearDay + 0.5474) - 0.134 * Sin(0.018234 * iYearDay - 0.1939)
  fSunDown = (12 + fDiffMittag - fDiffWozMoz + (15 - fLaengengrad * 180 / Pi) * 4 / 60) / 24
  dateTime = CDate(fSunDown)
  dateTime = Date(Year(dateDatum), Month(dateDatum), Day(dateDatum), Hour(dateTime), Minute(dateTime), Second(dateTime))
  
  Return dateTime 'As Date 
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  ' (Hier: Nutzung ohne Datum, nur als Uhrzeit)
  
Catch 
  FMain.ErrorText
  
End 

Public Function JahreszeitenSeasons(Optional iSpring1_Summer2_Autum3_Winter4 As Integer = 0, Optional iYear As Integer = Year(Date)) As Integer '20  Maerz
  Dim ssSpli, ssBegin As String[]
  Dim iDay, iFound As Integer
  'Spring, Summer, Autumn, Winter. (Frühling, Sommer, Herbst, Winter.)
  
  If iYear < 1980 Or iYear > 2100 Then 
    iDay = 0
  Else 
    Select Case iSpring1_Summer2_Autum3_Winter4
      Case 1  'Spring (Frühling)
      ''1980-2100. yyyy=dd  '19, 20 or 21. Always in the month of March (immer im Monat März)
      ssBegin = ["1980=20", "1981=20", "1982=20", "1983=21", "1984=20", "1985=20", "1986=20", "1987=21", "1988=20", "1989=20", "1990=20", "1991=21", "1992=20", "1993=20", "1994=20", "1995=21", "1996=20", "1997=20", "1998=20", "1999=21", "2000=20", "2001=20", "2002=20", "2003=21", "2004=20", "2005=20", "2006=20", "2007=21", "2008=20", "2009=20", "2010=20", "2011=21", "2012=20", "2013=20", "2014=20", "2015=20", "2016=20", "2017=20", "2018=20", "2019=20", "2020=20", "2021=20", "2022=20", "2023=20", "2024=20", "2025=20", "2026=20", "2027=20", "2028=20", "2029=20", "2030=20", "2031=20", "2032=20", "2033=20", "2034=20", "2035=20", "2036=20", "2037=20", "2038=20", "2039=20", "2040=20", "2041=20", "2042=20", "2043=20", "2044=20", "2045=20", "2046=20", "2047=20", "2048=19", "2049=20", "2050=20", "2051=20", "2052=19", "2053=20", "2054=20", "2055=20", "2056=19", "2057=20", "2058=20", "2059=20", "2060=19", "2061=20", "2062=20", "2063=20", "2064=19", "2065=20", "2066=20", "2067=20", "2068=19", "2069=20", "2070=20", "2071=20", "2072=19", "2073=20", "2074=20", "2075=20", "2076=19", "2077=20", "2078=20", "2079=20", "2080=19", "2081=19", "2082=20", "2083=20", "2084=19", "2085=19", "2086=20", "2087=20", "2088=19", "2089=19", "2090=20", "2091=20", "2092=19", "2093=19", "2094=20", "2095=20", "2096=19", "2097=19", "2098=20", "2099=20", "2100=20"]
    
      Case 2  'Summer (Sommer)
      ''1980-2100. yyyy=dd  '20 or 21. Always in the month of June (immer im Monat Juni)
      ssBegin = ["1980=21", "1981=21", "1982=21", "1983=22", "1984=21", "1985=21", "1986=21", "1987=22", "1988=21", "1989=21", "1990=21", "1991=21", "1992=21", "1993=21", "1994=21", "1995=21", "1996=21", "1997=21", "1998=21", "1999=21", "2000=21", "2001=21", "2002=21", "2003=21", "2004=21", "2005=21", "2006=21", "2007=21", "2008=21", "2009=21", "2010=21", "2011=21", "2012=21", "2013=21", "2014=21", "2015=21", "2016=21", "2017=21", "2018=21", "2019=21", "2020=20", "2021=21", "2022=21", "2023=21", "2024=20", "2025=21", "2026=21", "2027=21", "2028=20", "2029=21", "2030=21", "2031=21", "2032=20", "2033=21", "2034=21", "2035=21", "2036=20", "2037=21", "2038=21", "2039=21", "2040=20", "2041=21", "2042=21", "2043=21", "2044=20", "2045=21", "2046=21", "2047=21", "2048=20", "2049=20", "2050=21", "2051=21", "2052=20", "2053=20", "2054=21", "2055=21", "2056=20", "2057=20", "2058=21", "2059=21", "2060=20", "2061=20", "2062=21", "2063=21", "2064=20", "2065=20", "2066=21", "2067=21", "2068=20", "2069=20", "2070=21", "2071=21", "2072=20", "2073=20", "2074=21", "2075=21", "2076=20", "2077=20", "2078=20", "2079=21", "2080=20", "2081=20", "2082=20", "2083=21", "2084=20", "2085=20", "2086=20", "2087=21", "2088=20", "2089=20", "2090=20", "2091=21", "2092=20", "2093=20", "2094=20", "2095=21", "2096=20", "2097=20", "2098=20", "2099=21", "2100=21"]
    
      Case 3  'Autum (Herbst)
      ''1980-2100. yyyy=dd  '22 or 23. Always in the month of September (immer im Monat September)
      ssBegin = ["1980=22", "1981=23", "1982=23", "1983=23", "1984=22", "1985=23", "1986=23", "1987=23", "1988=22", "1989=23", "1990=23", "1991=23", "1992=22", "1993=23", "1994=23", "1995=23", "1996=22", "1997=23", "1998=23", "1999=23", "2000=22", "2001=23", "2002=23", "2003=23", "2004=22", "2005=23", "2006=23", "2007=23", "2008=22", "2009=22", "2010=23", "2011=23", "2012=22", "2013=22", "2014=23", "2015=23", "2016=22", "2017=22", "2018=23", "2019=23", "2020=22", "2021=22", "2022=23", "2023=23", "2024=22", "2025=22", "2026=23", "2027=23", "2028=22", "2029=22", "2030=23", "2031=23", "2032=22", "2033=22", "2034=23", "2035=23", "2036=22", "2037=22", "2038=23", "2039=23", "2040=22", "2041=22", "2042=22", "2043=23", "2044=22", "2045=22", "2046=22", "2047=23", "2048=22", "2049=22", "2050=22", "2051=23", "2052=22", "2053=22", "2054=22", "2055=23", "2056=22", "2057=22", "2058=22", "2059=23", "2060=22", "2061=22", "2062=22", "2063=23", "2064=22", "2065=22", "2066=22", "2067=23", "2068=22", "2069=22", "2070=22", "2071=22", "2072=22", "2073=22", "2074=22", "2075=22", "2076=22", "2077=22", "2078=22", "2079=22", "2080=22", "2081=22", "2082=22", "2083=22", "2084=22", "2085=22", "2086=22", "2087=22", "2088=22", "2089=22", "2090=22", "2091=22", "2092=22", "2093=22", "2094=22", "2095=22", "2096=22", "2097=22", "2098=22", "2099=22", "2100=23"]
    
      Case 4  'Winter (Winter)
      ''1980-2100. yyyy=dd  '20, 21 or 22. Always in the month of December (immer im Monat Dezember)
      ssBegin = ["1980=21", "1981=21", "1982=22", "1983=22", "1984=21", "1985=21", "1986=22", "1987=22", "1988=21", "1989=21", "1990=22", "1991=22", "1992=21", "1993=21", "1994=22", "1995=22", "1996=21", "1997=21", "1998=22", "1999=22", "2000=21", "2001=21", "2002=22", "2003=22", "2004=21", "2005=21", "2006=22", "2007=22", "2008=21", "2009=21", "2010=22", "2011=22", "2012=21", "2013=21", "2014=22", "2015=22", "2016=21", "2017=21", "2018=21", "2019=22", "2020=21", "2021=21", "2022=21", "2023=22", "2024=21", "2025=21", "2026=21", "2027=22", "2028=21", "2029=21", "2030=21", "2031=22", "2032=21", "2033=21", "2034=21", "2035=22", "2036=21", "2037=21", "2038=21", "2039=22", "2040=21", "2041=21", "2042=21", "2043=21", "2044=21", "2045=21", "2046=21", "2047=22", "2048=21", "2049=21", "2050=21", "2051=21", "2052=21", "2053=21", "2054=21", "2055=21", "2056=21", "2057=21", "2058=21", "2059=21", "2060=21", "2061=21", "2062=21", "2063=21", "2064=21", "2065=21", "2066=21", "2067=21", "2068=21", "2069=21", "2070=21", "2071=21", "2072=21", "2073=21", "2074=21", "2075=21", "2076=21", "2077=21", "2078=21", "2079=21", "2080=21", "2081=21", "2082=21", "2083=21", "2084=20", "2085=21", "2086=21", "2087=21", "2088=20", "2089=21", "2090=21", "2091=21", "2092=20", "2093=21", "2094=21", "2095=21", "2096=20", "2097=21", "2098=21", "2099=21", "2100=21"]
    End Select
        
    iFound = ssBegin.Find(iYear & "*", gb.Like) '-1 not found
    If iFound > -1 Then 
     ssSpli = Split(ssBegin[iFound], "=")
     iDay = CInteger(ssSpli[1])
    Endif
  Endif 
  
  Return iDay 'Example: 20
    
  ''_____________________________________________________________________''
  ' Ergänzende Funktion ab 2024. Bearbeitet: 2024
  ' Quelle: Wikipedia, Frühlingsanfang, Ausnahmen, Regeln
  ' 19., 20. oder 21. March (März)
  ' 21.März.2011 letztmalig im Jahrhundert 2000-2100. Nächster 21.März 2102
  ' 19.März.2048 erstmalig im Jahrhundert 2000-2100. Danach mindestens alle 4 Jahre.
  ' "Wegen des im Jahr 2100 ausfallenden Schalttages wird der Frühlingsanfang zu Beginn des 22. Jahrhunderts dann wieder zwischen dem 20. und 21. März pendeln" ("https://de.wikipedia.org/wiki/Jahreszeit#Beginn_der_Jahreszeiten")
  
  Catch 
  FMain.ErrorText
  
End '..................................



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/FMain.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/FMain.class
261 KB
' Gambas class file

'/usr/bin/gbx3 'Program

''Declarations:
'F_ = Form  'Öffentlich (Public) über Form hinaus mit Form-Name davor: FMain.F_... Adresse: Wie Ort (Form) und Straßenname (Funktion, Sub, Variable)
Public F_bCalendarHTMLautomaticRefreshON As Boolean
Public F_bCheckUpdateInternetDaily As Boolean
Public F_bCheckUSBFileMissing As Boolean
Public F_bClockAlarmBeforeBehindON As Boolean
Public F_bClockAlarmMusicON As Boolean
Public F_bClockHorizontalON As Boolean
Public F_bClockMessageON As Boolean
Public F_bClockPlusAlarmMusicON As Boolean
Public F_bESCpressedON As Boolean
Public F_bFilePathHideONoff As Boolean
Public F_bFMainSetFocus As Boolean
Public F_bMovingON As Boolean
Public F_bNeueinlesenStarten As Boolean
Public F_bProgramON As Boolean = True 'Default
Public F_bStopForWindowPhoto As Boolean
Public F_bStopwatchON As Boolean
Public F_bTerminMeldungenAusImmer As Boolean
Public F_bWhiteBorderON As Boolean 
Public F_bZeilenumbruchON As Boolean
Public F_ccBookmarksStandards As Collection[]
Public F_dateAuswahl As Date
Public F_dateChange As Date
Public F_dateFileReadingTime As Date 
Public F_dateNaechsterTermin As Date
Public F_dateNow As Date = Now
Public F_dateNow00second As Date 
Public F_dateProgramStart As Date = Now
Public F_dateProjectEnd As Date
Public F_dateProjectStart As Date 
Public F_dateSunDown As Date
Public F_dateSunUp As Date 
Public F_dateTimeSummerBegin As Date
Public F_dateTimeSummerEnd As Date
Public F_fFontSizePlus As Float 
Public F_iClockMap0Stop1Count2Digital3Design4 As Integer
Public F_iClockPictureBoxHeight As Integer 'WxH
Public F_iClockSwitchBefore As Integer
Public F_iColorAmpel1 As Integer
Public F_iColorAmpel2 As Integer
Public F_iColorAmpel3 As Integer
Public F_iColorBGNextTermin As Integer = Color.White
Public F_iColorClockBlue As Integer = &H678DB2
Public F_iColorFormBlack As Integer = Color.Black
Public F_iColorFormRed As Integer = Color.Red
Public F_iColorFormWhite As Integer = Color.White
Public F_iColorFormYellowLight As Integer
Public F_iColumnNr As Integer
Public F_iColumnsCount As Integer 'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iCounterComponentWarning As Integer
Public F_iCounterStopwatch As Integer
Public F_iCounterWithKeyPress As Integer
Public F_iDaysMinusOrPlus As Integer 
Public F_iFMainIconStatus As Integer
Public F_iHeight As Integer
Public F_iIconSize As Integer
Public F_iiPicBoxesVisibleLevelNr As Integer[]
Public F_imgCenterPoint As Image
Public F_imgClock As Image
Public F_imgClockBG As Image 'BackGround
Public F_imgClockNumbers As Image
Public F_imgDatePoint As Image
Public F_imgDigital As Image
Public F_imgGearWheel As Image
Public F_imgHour As Image
Public F_imgLastIconImage As Image 
Public F_imgLCD As Image
Public F_imgMinute As Image
Public F_imgNightSky As Image
Public F_imgPhythagoras As Image 'calculated with formular
Public F_imgSecond As Image
Public F_imgStopWatchBG As Image
Public F_imgSunUpDown As Image
Public F_imgTerminPunkt As Image
Public F_imgTimeSummer As Image
Public F_imgZiffer As Image
Public F_iMoveLineMaxH As Integer
Public F_iMoveLineMinH As Integer
Public F_iNaechsterTermininMinuten As Integer 'Next Date
Public F_iOnly1x As Integer
Public F_iProgramStartCounter As Integer 'double start?
Public F_iProjectSeconds As Integer
Public F_iScreenshotMissingCounter As Integer
Public F_iSecondCounter As Integer
Public F_iSelectGreenAlpha150 As Integer
Public F_iTimerSecond As Integer
Public F_iTimeSummerMinutesDiff As Integer
Public F_iTrayIconSystemON1 As Integer 'Icon in system bar, usually top right.⬈
Public F_iVorNachweckzeit30 As Integer
Public F_iVorNachweckzeit60 As Integer
Public F_iWidth As Integer
Public F_iX1 As Integer 
Public F_iX2 As Integer 
Public F_iY1 As Integer
Public F_iY2 As Integer 
Public F_ooNrBox As Object[] 
Public F_picClock As Picture '—▶ Clock and FMain.Window.Icon or FMain.Window.Icon
Public F_sBrowserHTMLonlyName As String
Public F_sClockPartsFileNames As String ' Example: "clockbackground.png" & gb.NewLine & "..."
Public F_sDirAppName As String 
Public F_sDirBackup As String
Public F_sDirCache As String
Public F_sDirClock As String
Public F_sDirColors As String
Public F_sDirMusic As String 
Public F_sDirMyFiles As String 
Public F_sDirPictures As String 
Public F_sDirPrintCache As String
Public F_sDirProgramOnlyRead As String 
Public F_sDirProject As String
Public F_sDirTerminweckerCurrent As String
Public F_sEinleseZeit As String 
Public F_sErrorMessagesExtra As String
Public F_sFeiertage As String
Public F_sFilesChangedList As String 
Public F_sForm As String = Me.Name 
Public F_sHeuteyyyymmdd As String
Public F_sHTMLTEXT As String
Public F_sInfoMessagesExtra As String
Public F_sLastCopyBackup As String 
Public F_sMenuLastName As String
Public F_sNaechsterTermin As String
Public F_sPathAutoStartDatei_desktop As String
Public F_sPathBookmarks_txt As String 
Public F_sPathClockBackground_png As String
Public F_sPathClockColors_txt As String 
Public F_sPathClockMuster_txt As String 
Public F_sPathEveryYear As String
Public F_sPathHolidaysPlus_txt As String 
Public F_sPathMediaTerminwecker_txt As String
Public F_sPathMusicPlusAlarm_wav As String
Public F_sPathMusicSelect_mp3 As String ' ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
Public F_sPathMusicStandard_mp3 As String
Public F_sPathPhotoSubtitleDate_txt As String 
Public F_sPathPickerColorsMemory_txt As String
Public F_sPathProject_txt As String
Public F_sPathProjectsAllTimes_txt As String 
Public F_sPathProjectsNames_txt As String 
Public F_sPathScreenphotoPNG As String
Public F_sPathSettings_conf As String
Public F_sPathSettingsBackup_conf As String
Public F_sPathSettingsDefaultExtern_conf As String 
Public F_sPathStartzeit_txt As String
Public F_sPathTerminweckerActual_txt As String
Public F_sPathTerminweckerLastBackup_txt As String 
Public F_sPathTerminweckerStandard_txt As String
Public F_sPathTerminweckerUntil_txt As String
Public F_sPathText5Temp_txt As String 
Public F_sPathTimerPlus_txt As String 
Public F_sPathWithPatternOpen As String
Public F_sProgramVersionNrInternet As String 
Public F_sProjectLineActual As String 
Public F_sProjectOnlyName As String
Public F_sReturnCrLF As String 
Public F_ssCalendarList As String[]
Public F_sScreenshotToolPath As String 
Public F_ssEditLevels As String[]
Public F_sTab As String
Public F_sTagsClockDatePoints As String 
Public F_sTagsClockDigital As String 'Example: "FreeSans"
Public F_sTagsClockGearWheel As String 'Example: "-sun"
Public F_sTagsClockLCD As String 'Example: "timelcd-square-big-blue"
Public F_sTagsClockNumbers As String 
Public F_sTagsClockPhythagoras As String 
Public F_sTagsClockSunUpDown As String 'Example: "-stroke"
Public F_sTempDateien As String
Public F_sTerminaktuellMeldung As String
Public F_sTerminUntilLine As String
Public F_sVorweckZeitText As String 
Public F_sWebFileNew As String  

''Clock Colors:
Public F_iColor As Integer '0
Public F_iColorBlue As Integer '1
Public F_iColorRed As Integer '2
Public F_iColorGray As Integer '3
Public F_iColorDarkGray As Integer '4
Public F_iColorWhite As Integer '5
Public F_iColorTransBlack As Integer '6
Public F_iColorYellow As Integer '7
Public F_iColorNature As Integer '8
Public F_iColorWaterTrans As Integer '9
Public F_iColorCut As Integer '10
Public F_iiIconClockColorsB As Integer[]

Public F_sErrorInfos As String       '=>Error messages.  Public in Form, Adresse global in anderer Form nur mit Name davor z.B. FMain.F_sErrorInfos

''"(c) 2012-2013, 2021-2024, 2025, www.design-cad.de" Freeware, OpenSource
'Attention: Installation-Package min. Version active? 3.8, 3.19,...
'Gambas3 in Konsole: "Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway."
'------------------------------------------------------------------------------------------------------
'Projekt>Eigenschaften>Umgebung Siehe Add▼ Variable: GB_GUI_PLATFORM Wert: wayland       'deaktiviert?
'------------------------------------------------------------------------------------------------------

'To-Do-List: Structure consistently afterwards (Im Nachhinein konsequent strukturieren)

'Note: Sub or Function with "G" in Name is a extra differentiator. Example: "Read" > ReadG()

'Install in Root. Suse-Linux in Directory "/home/user/RPM" ?

'Ubuntu-Software, Gnome-Software: Installed in system-root or in "/home/" with "snap" or "flatpak" ?

' Menü > Projekt > Eigenschaften > Beschreibung:
' Terminwecker_3L, \nDate Event alarm Clock, Termine  (*.txt), \nwww.design-cad.de, Open Source (Quelltext lesbar), Freeware (Kostenlos). \nHerstellerseite \"https://www.design-cad.de\".  GUI: QT5
' This program is written in Gambas.                  '(Diese Zeile wird zuletzt automatisch ergänzt im Installationspaket)

Public Function FilePathForm() As String 
  
  Return Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt") '"_vergangene.txt"
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  ' F_sForm = Me.Name & "/"
  ' F_sForm = FMain.Name & "/"
  
  Select Case String.LCase(String.Left(sReadSave, 1))
      
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", FMain.Left]
      iY = Settings[F_sForm &/ "Top", FMain.Top]
      iW = Settings[F_sForm &/ "Width", FMain.W]
      iH = Settings[F_sForm &/ "Height", FMain.H]
      FMain.Move(iX, iY, iW, iH)
      FMain.F_fFontSizePlus = Settings[F_sForm &/ "F_fFontSizePlus", FMain.F_fFontSizePlus]
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = FMain.Left
      Settings[F_sForm &/ "Top"] = FMain.Top
      Settings[F_sForm &/ "Width"] = FMain.Width
      Settings[F_sForm &/ "Height"] = FMain.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart() 'OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
  
  Timer1.Enabled = False 'Wichtig, sonst läuft es parallel weiter
  Timer2Calendar.Enabled = False
  Timer3CounterClock.Enabled = False
  ' FMain.Persistent = True 
  ' F_iColumnNr = 6
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  F_iColumnNr = 6                                  'Termine 6, in Projects 13
  F_iColumnUndo = 7                                'Termine 7, in Projects 10
  F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
  F_iColumnSort = 9                                'Termine 9, in Projects 12
  
  ''Column-Count 1,2,3...n
  F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
  F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
  
  'Gambas character
  'BEL Audible Signal(Bell OR Beep) '\a' 
  'BS Backspace                     '\b' 
  'HT Horizontal Tab                '\t'
  'LF LINE Feed                     '\n'
  'VT Vertical Tab                  '\v' 
  'FF Form Feed                     '\f' 
  'CR Carriage RETURN               '\r'
  
  'PRINT System.Charset 'zeigt aktuellen Zeichensatz unten im Print-Fenster an utf... oder iso...
  'PRINT System.Language
  'FMain.F_sReturnCrLF = gb.NewLine '= Chr(13) & Chr(10) ' Zeilenumbruch + Wagenrücklauf  'Linux,  Equivalent to Chr$(10)
  'F_sReturnCrLF funktioniert wie gb.newline, aber nicht umgekehrt!
  
  ' Gambas3:
  ' String constants
  ' gb.NewLine  Newline character. Equivalent to Chr$(10). = gb.Lf = "\n" 
  ' gb.Cr  Carriage return character. Equivalent to Chr$(13). The line terminator on old Macintoshs. = "\r"
  ' gb.Lf  Linefeed character. Equivalent to Chr$(10). The line terminator on Linux and co. = "\n"
  ' gb.CrLf  Carriage return followed by linefeed. The line terminator on Windows and network protocols such as HTTP. = "\r\n"
  ' gb.Tab  Tab character. Equivalent to Chr$(9). = "\t"
  
  '>hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
  'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
  ' gb.Unix For lines separated by Chr$(10).
  ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' = gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
  ' gb.Mac For lines separated by Chr$(13).
  
  FMain.F_sReturnCrLF = gb.CrLf '= Chr(13) & Chr(10) = "\r\n"' Zeilenumbruch + Wagenrücklauf  '>Windows
  ''gb.NewLine = Chr(10)
  FMain.F_sTab = gb.Tab 'Chr(9)  
  Settings[FMain.Name &/ "hReturn"] = FMain.F_sReturnCrLF '= gb.CrLf = "\r\n"
  Settings[FMain.Name &/ "hTab"] = FMain.F_sTab '= Chr(9) = "\t" 
  FMain.F_iiPicBoxesVisibleLevelNr = Settings[FMain.Name &/ "F_iiPicBoxesVisibleLevelNr", FMain.F_iiPicBoxesVisibleLevelNr]
  
  FMain.F_iColorFormRed = Color.Red '&HFF0000& = RGB(255,0,0)
  FMain.F_iColorFormBlack = Color.Black '&H000000& = "0"
  ''Black = 0, Default = -1 or -16777216 = Transparent
  ''White = 16777215 ' &HFFFFFF
  FMain.F_iColorFormWhite = Color.White '&HFFFFFF&
  FMain.F_iColorAmpel1 = ColumnView1.Background 'Color.Red
  FMain.F_iColorAmpel2 = ColumnView2.Background 'Color.Yellow
  FMain.F_iColorAmpel3 = ColumnView3.Background 'Color.Green
  FMain.F_iSelectGreenAlpha150 = Color.SetAlpha(Color.Green, 150) '&HCFFF9F& 'Grün
  FMain.F_iColorFormYellowLight = &HFFFFBF& 'Gelb
  FMain.F_iColorClockBlue = LabelTime.Foreground 'Uhr  '&H00678DB2&  'mattblau  
  F_bESCpressedON = False
  
  M01Functions.FileNamesSettingsReload()
  
  FMain.F_bClockAlarmBeforeBehindON = Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON", True]
  FMain.F_iVorNachweckzeit60 = Settings[FMain.Name &/ "F_iVorNachweckzeit60", -60]
  FMain.F_iVorNachweckzeit30 = Settings[FMain.Name &/ "F_iVorNachweckzeit30", -30]
  FMain.F_bClockAlarmMusicON = Settings[FMain.Name &/ "F_bClockAlarmMusicON", True]
  FMain.F_bClockPlusAlarmMusicON = Settings[FMain.Name &/ "F_bClockPlusAlarmMusicON", False]
  FMain.F_bWhiteBorderON = Settings[FMain.Name &/ "F_bWhiteBorderON", True]
  FMain.F_bCheckUpdateInternetDaily = Settings[FMain.Name &/ "F_bCheckUpdateInternetDaily", False]
  FMain.F_bClockMessageON = Settings[FMain.Name &/ "F_bClockMessageON", True]
  
  If Exist(FMain.F_sPathAutoStartDatei_desktop) = False Then
    PicBoxAutostart.Picture = PicTemplateConnectOff.Picture
    PicBoxAutostart.Visible = True
    PicBoxAutostart.Raise
  Endif
  CheckClockAlarmButtonNoteOnOff(False)
  
  TerminMeldungenEinAus()
  
  ''Horizontal Clock __|__ 
  FMain.F_bClockHorizontalON = Settings[FMain.Name &/ "F_bClockHorizontalON", True]
  
  ''Refresh Calendar HTML:
  FMain.F_bCalendarHTMLautomaticRefreshON = Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON", False]
  
  ' ' Über Timer ReadG() 'EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  ' F_bNeueinlesenStarten = True
  WindowStretchCursor()
  
  ''Clock-Picture:
  FMain.F_iClockMap0Stop1Count2Digital3Design4 = Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4", FMain.F_iClockMap0Stop1Count2Digital3Design4]
  
  LabelTime.Text = "00:00:00" 'Format(Time, "hh:nn:ss")
  LabelDateQuarterCWeekG()
  LabelProjectTime.Text = String.Left(F_sProjectOnlyName, 12) & Space(1) & "00:00:00" & Space(2) 'M01Functions.SecondsInfoText(F_iProjectSeconds) 'as String
  
  CheckTerminweckerTXTBackup()  '/Dir/terminwecker.txt_backup.txt
  ''Media, USB-Stick?
  If FMain.F_sPathTerminweckerActual_txt <> FMain.F_sPathTerminweckerStandard_txt And FMain.F_sPathTerminweckerActual_txt Begins "/media" Then  
    If M01Functions.CheckLatestTerminweckerTXT() Then PicBoxMedia.Visible = True Else PicBoxMedia.Visible = False 
    PicBoxMedia.Background = Color.Red
  Endif 
  
  ''Read File:
  FMain.F_bNeueinlesenStarten = True ''Timer ReadG()
  
  ''Start and Refresh:
  Timer1.Start()
  
  Settings[FMain.Name &/ "ProgramStart"] = F_dateNow 'in Form_Close() = Null 'Reset
  
  If IsDir(File.Dir(FMain.F_sPathStartzeit_txt)) = False Then M01Functions.CheckDirAppName()
  Try File.Save(FMain.F_sPathStartzeit_txt, Format(F_dateNow, "yyyy-mm-dd-hh-nn-ss-ddd"))
  
  TrayIconFile("read")
  CheckTrayIconSystemOnOff()
  
  ' M07Paint.CreateIconTerminweckerPNG(32) 'as Image (Iconsize in Pixel). Deactivate, only 1x for programmer
  ' TestTerminNotiz() see ReadG()
Catch
  
  FMain.ErrorText
  If Error Then Error.Clear()
  ' Return
  
End 'OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

Public Sub SettingsDefaultForExtern()
  
  Dim sDir, sDirFile, sDirMusic, sPathStandard, sPath1, sPath2, sLine, sText, sReadSave, sMessage As String 
  Dim ssSpli, ssSpliPart As String[]
  
  sPathStandard = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "_extern.conf"
  
  sDirMusic = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic]
  If IsDir(sDirMusic) = True Then 
    ' ssSpli = Dir(sDirMusic, "clock*.{mp3,mid,wav,ogg}", gb.File) 'as String[]
    sPath1 = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"]
    sPath2 = Settings[FMain.Name &/ "F_sPathMusicPlusAlarm_wav", FMain.F_sPathMusicPlusAlarm_wav]
  Endif
  sDirFile = Settings[FMain.Name &/ "F_sPathSettingsDefaultExtern_conf", sPathStandard]
  sDir = File.Dir(sDirfile)
  
  If Exist(sDirfile) = False Then
    sDirFile = FindDirFile(User.Home, "*/" & File.Name(sPathStandard) & "*", 3) 'as String, with /media/
    If Exist(sDirFile) = True Then 
      Settings[FMain.Name &/ "F_sPathSettingsDefaultExtern_conf"] = sDirFile 
    Else 
      sDirFile = sPathStandard
    Endif 
  Endif
  
  sMessage = "<h3>" & ("Einige Einstellungen für andere Orte") & "<br>" 
  sMessage &= "<font color=gray>" & ("(z.B. USB-Stick)") & "</font></h3>"
  If sPath1 Then 
    sMessage &= "<font color=darkgray>" & sPath1 & "</font><br>"
    sMessage &= "<font color=darkgray>" & sPath2 & "</font><br>"
  Endif 
  
  If Exist(sDirfile) = True Then 
    sMessage &= "<font color=darkgreen>" & "○ " & sDirFile & "</font><br>"
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</b></font>" & "<br>"
    sMessage &= "<h3><font color=blue>" & "● " & ("Speichern (aktualisieren, überschreiben)") & "</font></h3>"
  Else 
    sMessage &= "<h3><font color=gray>" & "○ " & ("Noch nicht gefunden") & "</font></h3>" 
    sMessage &= "<font color=gray>" & sDirFile & "</font><br>"
    sMessage &= "<br>"
    sMessage &= "<h3><font color=blue>" & "● " & ("Jetzt speichern in") & ":" & "</font></h3>"
    sMessage &= "<font color=blue>" & sDirFile & "</font><br>"
  Endif 
  
  Select Case Message.Question(sMessage, "○ " & ("Einlesen"), "● " & ("Speichern"), ("Abbrechen"))
    Case 1
      sReadSave = "read"
      If String.InStr(FMain.F_sFilesChangedList, sDirFile) = 0 Then FMain.F_sFilesChangedList &= sDirFile & gb.NewLine
    Case 2
      sReadSave = "save"
      If String.InStr(FMain.F_sFilesChangedList, sDirFile) = 0 Then FMain.F_sFilesChangedList &= sDirFile & gb.NewLine
    Case 3
      ''...
  End Select
  
  Select Case sReadSave 
    Case "read"
      If Exist(sDirFile) = True Then
        sText = File.Load(sDirFile)
        sText &= sPath1 & gb.NewLine & sPath2 & gb.NewLine
        If sText Then 
          ssSpli = Split(sText & gb.NewLine, gb.NewLine)
          For Each sLine In ssSpli
            If sLine Then 
              ssSpliPart = Split(sLine & "=", "=")
              '...terminwecker.txt
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathTerminweckerActual_txt") And Exist(UnQuote(ssSpliPart[1])) = True Then FMain.F_sPathTerminweckerActual_txt = UnQuote(ssSpliPart[1])
              'Extern, USB-Stick? ...terminwecker.txt
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathMediaTerminwecker_txt") And Exist(UnQuote(ssSpliPart[1])) = True Then FMain.F_sPathMediaTerminwecker_txt = UnQuote(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathBookmarks_txt") And Exist(ssSpliPart[1]) = True Then FMain.F_sPathBookmarks_txt = ssSpliPart[1]
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathPhotoSubtitleDate_txt") And Exist(ssSpliPart[1]) = True Then FMain.F_sPathPhotoSubtitleDate_txt = ssSpliPart[1]              
              
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bClockMessageON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bClockMessageON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bCalendarHTMLautomaticRefreshON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bCalendarHTMLautomaticRefreshON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bClockHorizontalON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bClockHorizontalON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bClockAlarmBeforeBehindON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bClockAlarmBeforeBehindON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bClockPlusAlarmMusicON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bClockPlusAlarmMusicON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bClockAlarmMusicON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bClockAlarmMusicON = CBoolean(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bWhiteBorderON") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bWhiteBorderON = CBoolean(ssSpliPart[1])   
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_bCheckUpdateInternetDaily") And IsBoolean(ssSpliPart[1]) = True Then FMain.F_bCheckUpdateInternetDaily = CBoolean(ssSpliPart[1])
              
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_iClockMap0Stop1Count2Digital3Design4") And IsInteger(ssSpliPart[1]) = True Then FMain.F_iClockMap0Stop1Count2Digital3Design4 = CInteger(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("ValueBoxVorweckzeit60.Value") And IsInteger(ssSpliPart[1]) = True Then FMain.F_iVorNachweckzeit60 = CInteger(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("ValueBoxVorweckzeit30.Value") And IsInteger(ssSpliPart[1]) = True Then FMain.F_iVorNachweckzeit30 = CInteger(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_iiIconClockColorsB") And IsInteger(ssSpliPart[1]) = True Then FMain.F_iiIconClockColorsB = CInteger(ssSpliPart[1])
              
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathMusicSelect_mp3") And Exist(UnQuote(ssSpliPart[1])) = True Then FMain.F_sPathMusicSelect_mp3 = UnQuote(ssSpliPart[1])
              If String.LCase(Trim(ssSpliPart[0])) = String.LCase("F_sPathMusicPlusAlarm_wav") And Exist(UnQuote(ssSpliPart[1])) = True Then FMain.F_sPathMusicPlusAlarm_wav = UnQuote(ssSpliPart[1])
            Endif
          Next
        Endif 
        Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt"] = FMain.F_sPathTerminweckerActual_txt
        Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt"] = FMain.F_sPathMediaTerminwecker_txt
        Settings[FMain.Name &/ "F_sPathBookmarks_txt"] = FMain.F_sPathBookmarks_txt
        Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt"] = FMain.F_sPathPhotoSubtitleDate_txt
        Settings[FMain.Name &/ "F_bClockMessageON"] = FMain.F_bClockMessageON
        Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON"] = FMain.F_bCalendarHTMLautomaticRefreshON
        Settings[FMain.Name &/ "F_bClockHorizontalON"] = FMain.F_bClockHorizontalON
        Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = FMain.F_bClockAlarmBeforeBehindON
        Settings[FMain.Name &/ "F_bWhiteBorderON"] = FMain.F_bWhiteBorderON
        Settings[FMain.Name &/ "F_bCheckUpdateInternetDaily"] = FMain.F_bCheckUpdateInternetDaily
        Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = FMain.F_bClockAlarmMusicON
        Settings[FMain.Name &/ "F_bClockPlusAlarmMusicON"] = FMain.F_bClockPlusAlarmMusicON
        Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4"] = FMain.F_iClockMap0Stop1Count2Digital3Design4
        Settings[FMain.Name &/ "F_iVorNachweckzeit60"] = FMain.F_iVorNachweckzeit60
        Settings[FMain.Name &/ "F_iVorNachweckzeit30"] = FMain.F_iVorNachweckzeit30
        Settings[FMain.Name &/ "F_iiIconClockColorsB"] = FMain.F_iiIconClockColorsB
        M01Functions.CheckDirMusic()
        FormStart()
        
        sMessage = "<h3><font color=darkgreen>" & ("Eingelesen") & "</font></h3>"
        sMessage &= "<font color=gray>" & String.Left(sText, 500) & "</font>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            M01Functions.FileManagerOpen(sDirFile)
          Case 2
            ''...
        End Select  
      Endif
      
    Case "save"
      If IsDir(sDir) = True Then 
        sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Externe Einstellungen") & Space(1) & ("(USB-stick, ...)") & gb.NewLine
        sText &= "F_sPathTerminweckerActual_txt" & "=" & Quote(FMain.F_sPathTerminweckerActual_txt) & gb.NewLine
        sText &= "F_sPathMediaTerminwecker_txt" & "=" & Quote(FMain.F_sPathMediaTerminwecker_txt) & gb.NewLine 
        sText &= "F_bClockMessageON" & "=" & Str(FMain.F_bClockMessageON) & gb.NewLine
        sText &= "F_bCalendarHTMLautomaticRefreshON" & "=" & Str(FMain.F_bCalendarHTMLautomaticRefreshON) & gb.NewLine
        sText &= "F_bClockHorizontalON" & "=" & Str(FMain.F_bClockHorizontalON) & gb.NewLine  
        sText &= "F_bClockAlarmBeforeBehindON" & "=" & Str(FMain.F_bClockAlarmBeforeBehindON) & gb.NewLine  
        sText &= "F_bClockPlusAlarmMusicON" & "=" & Str(FMain.F_bClockPlusAlarmMusicON) & gb.NewLine  
        sText &= "F_bClockAlarmMusicON" & "=" & Str(FMain.F_bClockAlarmMusicON) & gb.NewLine  
        sText &= "F_bWhiteBorderON" & "=" & Str(FMain.F_bWhiteBorderON) & gb.NewLine
        sText &= "F_bCheckUpdateInternetDaily" & "=" & Str(FMain.F_bCheckUpdateInternetDaily) & gb.NewLine
        sText &= "F_iClockMap0Stop1Count2Digital3Design4" & "=" & Str(FMain.F_iClockMap0Stop1Count2Digital3Design4) & gb.NewLine  
        sText &= "F_iVorNachweckzeit60" & "=" & Str(FMain.F_iVorNachweckzeit60) & gb.NewLine  
        sText &= "F_iVorNachweckzeit30" & "=" & Str(FMain.F_iVorNachweckzeit30) & gb.NewLine  
        sText &= "F_sPathMusicSelect_mp3" & "=" & Quote(FMain.F_sPathMusicSelect_mp3) & gb.NewLine
        sText &= "F_sPathMusicPlusAlarm_wav" & "=" & Quote(FMain.F_sPathMusicPlusAlarm_wav) & gb.NewLine
        Try File.Save(sDirFile, sText)
        sMessage = "<h3><font color=darkgreen>" & ("Gespeichert") & "</font></h3>"
        sMessage &= "<font color=blue>" & sDirFile & "</font>" & "<br>"
        sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</b></font>" & "<br>" & "<br>"
        sMessage &= "<font color=gray>" & String.Left(sText, 500) & "</font>"
        M01Functions.CheckDirMusic()
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            M01Functions.FileManagerOpen(sDirFile)
          Case 2
            ''...
        End Select  
      Endif 
  End Select 
  
Catch
  
  FMain.ErrorText
  
End

Public Sub CheckClockAlarmButtonNoteOnOff(Optional bChangeON As Boolean = False)
  
  If bChangeON = True Then 
    F_bClockAlarmMusicON = Not F_bClockAlarmMusicON
    Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = F_bClockAlarmMusicON
  Else 
    F_bClockAlarmMusicON = Settings[FMain.Name &/ "F_bClockAlarmMusicON", F_bClockAlarmMusicON]
  Endif 
  
  If F_bClockAlarmMusicON = True Then 
    ButtonNote.Picture = PicTemplateNoteGreen.Picture
    ButtonNote.Tooltip = ("Uhr-Alarm eingeschaltet") 'On
  Else 
    ButtonNote.Picture = PicTemplateNoteRed.Picture
    ButtonNote.Tooltip = ("Uhr-Alarm ausgeschaltet") 'Off
  Endif 
  
Catch
  
  FMain.ErrorText
  
End

Public Sub PlusAlarmON()
  
  F_bClockAlarmBeforeBehindON = Not F_bClockAlarmBeforeBehindON
  Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = F_bClockAlarmBeforeBehindON
  
Catch
  
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Dim iCheckQTandGTK As Integer
  Dim iMe As Integer
  Dim bMe As Boolean
  Dim sMessage, sMessageSystem, sPathCache1, sUbuntuVersion As String
  Dim dateBoot As Date 
  
  ''Timer:
  Timer1.Enabled = False 'Wichtig, sonst läuft es parallel weiter
  Timer2Calendar.Enabled = False
  Timer3CounterClock.Enabled = False
  MenuTrayIconSystem.Visible = False 
  FMain.Tag = ("ON") 'Default
  
  If Component.IsLoaded("gb.qt4") = False And Component.IsLoaded("gb.qt5") = False Then 
    sMessage &= "<h2>" & ("GUI-Toolkit fehlt") & ": " & "<font color=red>" & "QT5" & "</font></h2>" 
    ' sMessage &= ("Tipp: Nachinstallieren im") & Space(1) & "<font color=orange><b>" & ("Software-Center") & "</b></font>" & "<br>"
    ' sMessage &= "<h2><font color=orange><b>" & ("Suche") & ": " & "</b></font>" & "<font color=darkgreen><b>" & Quote("QT5-core20") & "</b></font></h2>"
    ' sMessage &= "Qt5 runtime for core20" & Space(1) & "(Ubuntu 20 LTS)" & "<br>" & "<br>" 
    sMessage &= ("In einer Paket-Verwaltung (Package-Manager)") & ": " 
    sMessage &= "<h2><font color=red>" & Quote("gambas3 gb-qt5") & "</font></h2>" 
    iCheckQTandGTK = iCheckQTandGTK + 1
  Endif 
  
  If Component.IsLoaded("gb.gtk3") = False And Component.IsLoaded("gb.gtk4") = False Then 
    sMessage &= "<h2>" & ("GUI-Toolkit fehlt") & ": " & "<font color=red>" & "GTK3" & "</font></h2>" 
    sMessage &= ("In einer Paket-Verwaltung (Package-Manager)") & ": " 
    sMessage &= "<h2><font color=red>" & Quote("gambas3 gb-gtk3") & "</font></h2>" 
    iCheckQTandGTK = iCheckQTandGTK + 1
  Endif 
  
  If iCheckQTandGTK > 1 Then 
    sMessage &= Quote("gambas3 gb-runtime") & Space(1) & ("ist die Laufzeit-Datei (Runtime) und das notwendige Basis-Paket für diese Software, damit das Programm läuft.") & Space(1) & ("(This package includes the Gambas interpreter needed to run Gambas applications.)")
    
    Select Message.Warning(sMessage, ("Weiter..."), ("Beenden"))
      Case 1
        '...
      Case 2  
        FormCloseNowDirectlyTotalWithQuit() 'Note: Attention. Beware, be careful! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    End Select 
  Endif
  
  ''Check Program, start only 1x
  FMain.F_sPathStartzeit_txt = User.Home &/ Application.Name &/ "temp_" & Application.Name & "_programstart.txt"
  If M01Functions.ProgramIsAlreadyON() = True Then  'not forget "()" Or Exist(User.Home &/ Application.Name &/ "temp_programstart.txt") = True
    dateBoot = M01Functions.TimeSystemBootStart()
    If dateBoot Then 
      sMessageSystem = ("System-Start") & ": " & Format(dateBoot, "ddd hh:nn:ss")
    Endif
    sUbuntuVersion = M01Functions.UbuntuVersionG() 'as String 
    If sUbuntuVersion Then sMessageSystem &= Space(1) & sUbuntuVersion 
    If sMessageSystem Then sMessageSystem = "<font color=gray>" & sMessageSystem & "</font>" & "<br>"
    
    System.Language = Settings[FMain.Name &/ "System.Language", "de_DE.utf8"] ' "en_GB.utf8" <> "de_DE.utf8"
    If Desktop.Platform = "x11" Then 
      iMe = FMain.Window.Stacking  'as Integer. Window.Above = 1, Window.Below = 2, Window.Normal = 0
      bMe = FMain.Window.TopOnly
    Endif 
    ' FMain.Stacking = Window.Above'▲ Gambas3: "...property for windows that must stay above other windows." in "x11", not "wayland"
    ' FMain.Window.TopOnly = True' "...window stays on top on all other windows."
    ' FMain.Sticky = True '"...window is visible in all virtual desktops."
    
    sMessage = ""
    
    sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
    If IsDir(File.Dir(sPathCache1)) = True Then 
      FMain.Window.Icon.Save(sPathCache1)
      sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=100 height=100 >" & "<br>" 
    Endif 
    sMessage &= "<h1><font color=orangered><b>" & Application.Name & "</b></font></h1>"
    sMessage &= "<h3>" & ("Programm (noch) offen?") & "</h3>"
    If Exist(FMain.F_sPathStartzeit_txt) = True Then 
      sMessage &= sMessageSystem 
      sMessage &= "<font color=gray>" & FMain.F_sPathStartzeit_txt & "</font>" & "<br>"
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(FMain.F_sPathStartzeit_txt) & "</b></font>" & "<br>"
      sMessage &= "<font color=gray>" & ("Neustart abbrechen") & "?" & "</font>" & "<br>"
    Endif 
    
    FMain.Window.Minimized = True  
    Select Case Message.Question(sMessage, ("Starten"), ("Neustart abbrechen"))
        
      Case 1 ''start
        If Desktop.Platform = "x11" Then FMain.Window.Stacking = iMe 'Reset
        FMain.Window.TopOnly = bMe
        FMain.Window.Minimized = False 
        
      Case 2 ''cancel
        FormCloseNowDirectlyTotalWithQuit() 'Note: Attention. Beware, be careful! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    End Select
  Endif  
  
  If FMain.Tag Then 'Start
    ' If Exist(Settings.Path) = False Then M01Functions.CheckLastSettings()
    If Exist(Settings.Path) = False Then M01Functions.FindFileSettings()
    SettingsReadSave("read")
    FormBackgroundColor()
  Endif 
  
  ''___________________________________________________________________________''
  ''Die Quellenangaben sind helfende Hinweise für weitere Informationen. Aber die Inhalte der Internetseiten können sich ändern und sind kein "Zitat".  
  ' "https://wiki.ubuntuusers.de/System/"
  ' Mehr Informationen, Quelle: "https://de.wikipedia.org/wiki/Gambas_%28Programmiersprache%29"  Stand: "Diese Seite wurde zuletzt am 19. Dezember 2023 um 09:49 Uhr bearbeitet."
  'Gambas-Books (Bücher): "https://gambaswiki.org/wiki/doc/book?nh&l=en"
  
Catch 
  FMain.ErrorText
  
End

Public Sub ErrorText()                                                                    '=>Error handling
  
  Dim sLine, sText, sDirFile As String
  Dim it As Integer
  ' Dim sMessage As String 
  
  sDirFile = FMain.F_sDirAppName &/ "error-info.txt"
  
  sLine = Error.Text & gb.NewLine & Error.Where & Space(2) & Format(Now, "ddd hh:nn:ss.uu") 
  FMain.F_sErrorInfos = sLine & gb.NewLine & FMain.F_sErrorInfos 'new in first line
  
  ''Show for User:
  IconError.Visible = True
  IconError.Raise()
  TimerIconError.Start()
  
  FMain.F_sErrorInfos = String.Left(FMain.F_sErrorInfos, 400)                             'not too many messages
  FMain.F_sErrorInfos &= gb.NewLine
  FMain.F_sErrorInfos &= sDirFile & gb.NewLine
  
  Print sLine 'siehe unten in "Konsole" 
  
  sText = ("gambas3 runtime. Interpreter-Version") & ": " & "Gambas" & System.Version & " Version: " & System.FullVersion & gb.NewLine
  sText &= Application.Name & Space(1) & Application.Version & gb.NewLine
  sText &= gb.NewLine
  sText &= ("Fehler-Meldungen") & ":" & gb.NewLine
  sText &= FMain.F_sErrorInfos & gb.NewLine
  
  For it = 0 To Error.Backtrace.Max
    sText &= "Error.Backtrace[" & it & "]: " & Error.Backtrace[it] & gb.NewLine
  Next  
  
  If System.Error Then
    sText &= "System.Error: " & System.Error & gb.NewLine 
    sText &= "(Unix-System). Gambas3: " & Quote("Return the Unix error code of the last error raised by a system call.") & gb.NewLine
    sText &= "https://gambaswiki.org/wiki/doc/crash" & gb.NewLine
    If IsDir(File.Dir(sDirFile)) = True Then File.Save(sDirFile, sText)
  Endif 
  
  If Exist(sDirFile) = True Then sText &= Replace(sDirFile, User.Home, "") & gb.NewLine
  
  Print sText 
  
  ''System-Error? '(*11)
  If System.Error Then 'Gambas3: "Return the Unix error code of the last error raised by a system call."
    ' sMessage = "<h2><font color=red>" & ("Fehler") & ": " & "</font></h2>" 
    ' sMessage &= sLine
    ' 
    ' Select Case Message.Error(sMessage, ("Fehler-Info") & "...", ("Abbrechen"))
    '   Case 1
    '     Desktop.Open(sDirFile)
    '   Case 2
    '     ''... The program ended abruptly? (Das Programm wurde abrupt beendet?)
    ' End Select
    Me.Visible = True 
    Me.Minimized = False 
    If Me.Visible = False Then Me.Close
  Endif 
  ' If FMain.F_iScreenshotMissingCounter = 1 Then 
  '   FMain.F_sErrorMessagesExtra = FMain.F_sErrorMessagesExtra & gb.NewLine & ("Bildschirm-Foto nicht möglich?") & gb.newline & ("Suche in Software-Center oder Paketmanager") & ": " & Quote("gnome-screenshot") & Space(1) & ("(Bildschirmfoto)") & ("installieren") & "?" 
  ' Endif 
  
  F_iCounterComponentWarning = F_iCounterComponentWarning + 1
  ' If System.Error > 0 And F_iCounterComponentWarning < 2 Then Message.Warning(M01Functions.CheckComponents(), ("Abbrechen"))
  'Public Sub Application_Signal(Signal As Integer) 
  'Example: System.Error = 11 'as Integer   ' "Schutzverletzung" SIGSEGV (SIG=Signal) 'Crash (beendet meist Programm=Absturz) Datei oder Variable verletzt, gleichzeitiger Zugriff? (*11)
  'https://de.wikipedia.org/wiki/Signal_(Unix) 'Year 2021
  'Double? Overwrite? File or Variable read and write > crash
  '(...) "&" (...) missing? 
  'File *.class to big? (> 220 KB) 
  'Gambas Version old <> new. Error? Refresh —▶ Menu>File>Compile
  If Error Then Error.Clear() 
  'Keyboard: Ctrl + "\"  Quit the aktiv Window-Form 
  '"Ctrl-\ sends a QUIT signal (SIGQUIT);" 'https://en.wikipedia.org/wiki/Signal_(IPC)
  'Quit with Keyboard: Alt + F4
  'Error.Backtrace.Max
  
  ''________________________________________________________________________________________''
  'Info: Variable und SUB-Prozeduren global PUBLIC öffentlich,
  ' oder PRIVATE privat nur auf Formular-Ebene solange die betreffende Form geladen ist.
  ' Konsole: "Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway."
  'Help? Pakete (Gnome, PackageManager): "QT_QPA_PLATFORM", "This package contains the GTK+ 2 style and platform theme. Export QT_QPA_PLATFORMTHEME=gtk2 to enable it for all Qt applications."
  ' dh_installdeb: warning: Compatibility levels before 10 are deprecated (level 9 in use)    '.dep helper
  ' https://manpages.ubuntu.com/manpages/jammy/de/man1/dh_installdeb.1.html
  
  '(*11) Gambas3: "The Program has stopped unexpectedly by raising signal #11
  ' This message is displayed by the Development Environment when the running project crashes.
  ' This is not a bug in your project, but a bug in the interpreter. This message should never occur, but nothing is perfect is this world!" (terminwecker: We are human developers.)
  'https://gambaswiki.org/wiki/doc/crash
  'https://gambaswiki.org/wiki/error
  
  ''QT 6.5:
  'Hinweis: Qt 6 ist hochkompatibel mit Qt 5. Entwickler von Qt 5-Anwendungen können nahtlos zu Qt 6 wechseln und dabei die Funktionalität der Anwendungen beibehalten. https://doc.qt.io/qt-6/qt-intro.html   Sep. 2023
  
  'here not Catch!
End

Public Sub Application_Error() 'Test, unsed
  
  Dim it As Integer
  
  ' Print "xxx Test"
  ' Print "Application.Env: ", Application.Env["Path"]'as Env, process environment variables, Collection of Strings, Example: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  ' Print "Application.Dir: ", Application.Dir 'as String, Example: "/home/user/myapplication/"
  ' Print "Application.Path: ", Application.Path 'as String, Example: "/home/user/Gambas3/program-name" or in Root "/usr/..." 
  ' Print "Application.ID: ", Application.Id 'as Integer, Identification= .Handle, Example: 7610
  ' Print "System.Path: ", System.Path 'as String,  Gambas3: "Returns the installation path of Gambas.", Example: "/usr"
  ' Print "System.TimeZone: ", System.TimeZone 'gb() as Integer, <UTC+2>, Example: -7200
  ' Print "System.Language: ", System.Language '= "de_DE.utf8" 'as String, Example: "en_GB.utf8"
  ' Print "System.Find(Application.Name): ", System.Find(Application.Name) 'as String, Example: "/user/.../program-name"
  ' Print "System.Charset: ", System.Charset 'as String, "utf-8", "ISO-8859-15", ...
  ' Print "System.Cores: ", System.Cores 'as Integer, Number of CPU, Example: 2 (oh, so much?:-)
  ' Print "System.Family: ", System.Family 'as String, "Linux", .... 
  ' Print "System.User: ", System.User 'as User
  ' Print "System.Profile: ", System.Profile 'as Boolean, TRUE or FALSE
  ' Print "System.Version: ", System.Version 'gambas3 runtime. Interpreter-Version Example: 3
  ' Print "System.FullVersion: ", System.FullVersion 'Gambas Version Example: 3.17.0
  ' Print "System.Architecture: ", System.Architecture 'Beispiel: x86 (32-bit), x86_64 (64-bit Architecture)
  
  ' Print "System.Error: ", System.Error 'as Integer, Unix Error Example: 11 
  ' Print "System.Backtrace: ", System.Backtrace 'as String[], Error-Lines, Gambas3: "If no debugging information is available, then this property returns NULL."
  ' Print System.Domain 
  ' Print System.Host 'Example: xxx-Laptop-xx-xxxxxx   'Computer-Name
  ' Print Windows[FMain.id].Grab() '> Mouse Menu
  ' Print Windows[FMain.id].Window 'Return Top-Level
  ' Print Windows[FMain.id].Transparent 'as Boolean 'Area Form.Picture
  
  If Error Then 
    Print "Error.Backtrace.Count: ", Error.Backtrace.Count 'as Integer 'Number of Errors
    For it = 0 To Error.Backtrace.Max
      Print "Error.Backtrace[" & it & "]:", Error.Backtrace[it]
    Next  
  Endif 
  ''"Fehler ohne Fehlerbehandlung. Das Programm wird beendet."
  ''______________________________________________________________________''
  'Falsche Zuordnung, z.B. bei Varible as Variant
  'Double? Overwrite? File or Variable read and write > crash
  
  'Gambas3. Application_Error() "SEIT 3.5: This handler Is Called when an Error Is Raised And Is Not handled by any Catch , TRY Or Finally instruction."
Catch 
  FMain.ErrorText
  
End

Public Sub LoadClockG() 'about picture file
  
  Dim sDir, sFile, sPath As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  F_sClockPartsFileNames = Settings[FMain.Name &/ "F_sClockPartsFileNames", F_sClockPartsFileNames]
  ' Print F_sClockPartsFileNames
  If Not FMain.F_iiPicBoxesVisibleLevelNr Then FMain.F_iiPicBoxesVisibleLevelNr = Settings[FMain.Name &/ "F_iiPicBoxesVisibleLevelNr", FMain.F_iiPicBoxesVisibleLevelNr]
  
  ''Colors:
  ' iiColors = Settings[FMain.Name &/ "F_iiIconClockColorsB", Null] 
  M05.ColorClockGetSettings(True) '>FMain
  
  ''Clock Parts:
  If Exist(sDir) = True Then 
    
    sFile = "clockbackground.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgClockBG = Image.Load(sPath) Else F_imgClockBG = Null
    ' If F_imgClockBG Then Add1xClockLevel(F_imgClockBG.Picture, sPath)
    
    sFile = "clocksunupdown.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgSunUpDown = Image.Load(sPath) Else F_imgSunUpDown = Null
    ' If F_imgSunUpDown Then Add1xClockLevel(F_imgSunUpDown.Picture, sPath)
    ' If F_imgSunUpDown Then F_sTagsClockSunUpDown = Settings[FMain.Name &/ "F_sTagsClockSunUpDown", F_sTagsClockSunUpDown]
    
    sFile = "clockgearwheel.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgGearWheel = Image.Load(sPath) Else F_imgGearWheel = Null
    ' If F_imgGearWheel Then Add1xClockLevel(F_imgGearWheel.Picture, sPath)
    
    sFile = "clocknumbers.png" '0-3-6-9-12 or 15-18-21-24
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgClockNumbers = Image.Load(sPath) Else F_imgClockNumbers = Null
    ' If F_imgClockNumbers Then Add1xClockLevel(F_imgClockNumbers.Picture, sPath)
    
    sFile = "clockhour.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgHour = Image.Load(sPath) Else F_imgHour = Null
    ' If F_imgHour Then Add1xClockLevel(F_imgHour.Picture, sPath)
    
    sFile = "clockminute.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgMinute = Image.Load(sPath) Else F_imgMinute = Null
    ' If F_imgMinute Then Add1xClockLevel(F_imgMinute.Picture, sPath)
    
    sFile = "clocksecond.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgSecond = Image.Load(sPath) Else F_imgSecond = Null
    ' If F_imgSecond Then Add1xClockLevel(F_imgSecond.Picture, sPath)
    
    sFile = "clockcenterpoint.png" '●
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgCenterPoint = Image.Load(sPath) Else F_imgCenterPoint = Null
    ' If F_imgCenterPoint Then Add1xClockLevel(F_imgCenterPoint.Picture, sPath)
    
    sFile = "clockdatepoint.png" '● terminwecker
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgDatePoint = Image.Load(sPath) Else F_imgDatePoint = Null
    ' If F_imgDatePoint Then Add1xClockLevel(F_imgDatePoint.Picture, sPath)
    
    sFile = "clockphythagoras.png" 
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgPhythagoras = Image.Load(sPath) Else F_imgPhythagoras = Null
    If F_imgPhythagoras Then 
      F_sTagsClockPhythagoras = Settings[FMain.Name &/ "F_sTagsClockPhythagoras", F_sTagsClockPhythagoras]
      '   Add1xClockLevel(F_imgPhythagoras.Picture, sPath)
    Endif 
    
    sFile = "clockdigital.png" '00:00 Text
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgDigital = Image.Load(sPath) Else F_imgDigital = Null
    If F_imgDigital Then 
      F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      '   Add1xClockLevel(F_imgDigital.Picture, F_sTagsClockDigital)
    Endif 
    
    sFile = "clocklcd.png" '00:00 Text
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgLCD = Image.Load(sPath) Else F_imgLCD = Null
    If F_imgLCD Then 
      F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      '   Add1xClockLevel(F_imgLCD.Picture, F_sTagsClockLCD)
    Endif 
    
    sFile = "clocktimesummer.png" '02:00<>03:00 Begin +h <> End -h
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    ' Print sFile
    ' Print F_sClockPartsFileNames
    If Exist(sPath) = True Then 
      F_imgTimeSummer = Image.Load(sPath)
      ' FMain.F_dateTimeSummerBegin = Settings[FMain.Name &/ "F_dateTimeSummerBegin", Null]
      If FMain.F_dateTimeSummerBegin = Null Then M02Astro.SommerzeitAnfangEnde(F_dateNow) 'calculate
      ' If F_imgTimeSummer Then 
      '   Add1xClockLevel(F_imgTimeSummer.Picture, sPath)
      ' Endif 
    Else 
      F_imgTimeSummer = Null
      FMain.F_dateTimeSummerBegin = Null
      FMain.F_dateTimeSummerEnd = Null
    Endif 
    
    sFile = "clocknightsky.png" '02:00<>03:00 Begin +h <> End -h
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgNightSky = Image.Load(sPath) Else F_imgNightSky = Null
    
  Endif 
  '' —▶ load levels
  
Catch 
  FMain.ErrorText
  
End

Public Sub DrawTime(Optional dateTime As Date = F_dateNow) 'paint all in one clock-picture
  
  Dim imgTemp As Image
  Dim sTag As String
  Dim dateNext As Date
  Dim Img As Image'(F_iIconSize, F_iIconSize, Color.Transparent) 'Transparent True
  Dim iIconSizeHalf As Integer
  
  If Not dateTime Then dateTime = F_dateNow
  PicBoxClock.Visible = True
  PicBoxClock.Background = Color.Default
  
  If Not FMain.F_iiIconClockColorsB Then 
    ' FMain.F_bWhiteBorderON = Settings[FMain.Name &/ "F_bWhiteBorderON", True]
    FMain.F_iiIconClockColorsB = Settings[FMain.Name &/ "F_iiIconClockColorsB", Null] 
    If Not FMain.F_iiIconClockColorsB Then M05.ColorClockGetSettings(True) 'M05.ColorPaletteStandardii()'as Integer[]
  Endif 
  ' Print "DrawTime", Second(Time)
  
  ''1 Second:
  ''Digital 00:00
  ' If FMain.F_bClockDigitalON = True Then ''00:00
  If F_iClockMap0Stop1Count2Digital3Design4 = 3 Then 
    ' F_picClock = M07Paint.ClockDigital().Picture ' Rückgabe Picture  Klammern nicht vergessen()
    If Not F_sTagsClockDigital Then F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", "-timelcd-big-red-sizemax-bold"]
    Img = M07Paint.ClockDigital(F_dateNow, F_sTagsClockDigital) 'as Image
    If InStr(F_sTagsClockDigital, "white") > 0 Then PicBoxClock.Background = F_iColorDarkGray
  Else 
    ''Clocks ○
    ''...Level+Level=Sum Clock:  
    If F_iIconSize = 0 Then F_iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128]
    iIconSizeHalf = F_iIconSize / 2
    If Not Img Then Img = New Image(F_iIconSize, F_iIconSize, Color.Transparent)
    
    Paint.Begin(Img) 'rotate and add Clock-Parts
    Paint.AntiAlias = True                                                                     '...----...
    
    If F_imgClockBG Then 'Basis, Background, Clock-Design
      Paint.DrawImage(F_imgClockBG, iIconSizeHalf - (F_imgClockBG.Width / 2), iIconSizeHalf - (F_imgClockBG.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgGearWheel Then 
      If Not F_sTagsClockGearWheel Then F_sTagsClockGearWheel = Settings[FMain.Name &/ "F_sTagsClockGearWheel", Null]
      If F_sTagsClockGearWheel Then F_imgGearWheel = AddImagesTags("F_imgGearWheel", F_sTagsClockGearWheel) 'as Image
      ' imgTemp = imgTemp.Rotate(-Second(F_dateNow) * Pi(2 / 60)) 'Example in Gambas3
      ' imgTemp = imgTemp.Rotate(Rad(-Second(dateTime) * 6)) 'my Short-Version '360°Degree / 60 = 6° = 1 Part Minute=Second  |....!....|....!... 12:01, 12:02, ...
      If F_imgGearWheel Then Paint.DrawImage(F_imgGearWheel, iIconSizeHalf - (F_imgGearWheel.Width / 2), iIconSizeHalf - (F_imgGearWheel.Height / 2)) 'center, middle —▶○◀—
    Endif 
    
    If F_imgNightSky Then 
      If Not FMain.F_dateSunUp Then M02Astro.AstroSunUpDown(F_dateNow) 'as Date
      If F_dateNow < FMain.F_dateSunUp Or F_dateNow > FMain.F_dateSunDown Then 
        Paint.DrawImage(F_imgNightSky, iIconSizeHalf - (F_imgNightSky.Width / 2), iIconSizeHalf - (F_imgNightSky.Height / 2)) 'center, middle —▶○◀—
      Endif 
    Endif
    
    If F_imgTimeSummer Then '02:00<>03:00 Begin +h <> End -h
      If Not FMain.F_dateTimeSummerBegin Then FMain.F_iTimeSummerMinutesDiff = M02Astro.SommerzeitAnfangEnde(F_dateNow) 'calculate
      If Abs(DateDiff(FMain.F_dateTimeSummerBegin, F_dateNow, gb.Day)) < 3 Or Abs(DateDiff(FMain.F_dateTimeSummerEnd, F_dateNow, gb.Day)) < 3 Then 
        'Days before or after the time change (Tage vor oder nach der Zeitumstellung)
        Paint.DrawImage(F_imgTimeSummer, iIconSizeHalf - (F_imgTimeSummer.Width / 2), iIconSizeHalf - (F_imgTimeSummer.Height / 2)) 'center, middle —▶○◀—
      Endif 
    Endif
    
    If F_imgSunUpDown Then 
      If Second(dateTime) = 0 Then 'only 1x in one Minute  0,1,2,3,..,58,59,0
        If Not F_sTagsClockSunUpDown Then F_sTagsClockSunUpDown = Settings[FMain.Name &/ "F_sTagsClockSunUpDown", Null]
        F_imgSunUpDown = AddImagesTags("F_imgSunUpDown", F_sTagsClockSunUpDown)
        ' Print "F_imgSunUpDown"
      Endif 
      If F_imgSunUpDown Then Paint.DrawImage(F_imgSunUpDown, iIconSizeHalf - (F_imgSunUpDown.Width / 2), iIconSizeHalf - (F_imgSunUpDown.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgClockNumbers And F_sTagsClockNumbers Then  
      If Second(dateTime) = 0 Then 'only 1x in one Minute
        If Not F_sTagsClockNumbers Then F_sTagsClockNumbers = Settings[FMain.Name &/ "F_sTagsClockNumbers", Null]
        F_imgClockNumbers = AddImagesTags("F_imgClockNumbers", F_sTagsClockNumbers) 'as Image
      Endif 
      If F_imgClockNumbers Then Paint.DrawImage(F_imgClockNumbers, iIconSizeHalf - (F_imgClockNumbers.Width / 2), iIconSizeHalf - (F_imgClockNumbers.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgHour Then 'short ●———
      ' imgTemp = imgTemp.Rotate(-((Hour(dateTime) * 60) + Minute(dateTime)) * Pi(1 / 360)) '360°Degree / 12 = 30° = 1 Part Hour  12:00, 13:00,...  |....!....|....!...
      imgTemp = F_imgHour.Rotate(Rad(-Hour(dateTime) * 30 + (-Minute(dateTime) * 0.5))) '1h=30°, 30/5m=6
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - (imgTemp.Width / 2), iIconSizeHalf - (imgTemp.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgMinute Then 'long ●———————
      ' imgTemp = imgTemp.Rotate(-Minute(F_dateNow) * Pi(2 / 60))
      imgTemp = F_imgMinute.Rotate(Rad(-Minute(dateTime) * 6))
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - (imgTemp.Width / 2), iIconSizeHalf - (imgTemp.Height / 2)) 'center, middle —▶○◀—
    Endif 
    
    If F_imgSecond Then 'longest ●——————————
      ' imgTemp = imgTemp.Rotate(-Second(F_dateNow) * Pi(2 / 60))
      imgTemp = F_imgSecond.Rotate(Rad(-Second(dateTime) * 6)) '360°Degree / 60 = 6° = 1 Part Minute=Second  |....!....|....!... 12:01, 12:02, ...
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - (imgTemp.Width / 2), iIconSizeHalf - (imgTemp.Height / 2)) 'center, middle —▶○◀—
    Endif 
    
    If F_imgDatePoint Then '—▶ user terminwecker
      If Not F_sTagsClockDatePoints Then F_sTagsClockDatePoints = Settings[FMain.Name &/ "F_sTagsClockDatePoints", F_sTagsClockDatePoints]
      For Each sTag In Split(F_sTagsClockDatePoints & gb.NewLine, gb.NewLine)
        If IsDate(sTag) = True Then 
          dateNext = Val(sTag)
          imgTemp = F_imgDatePoint.Copy()
          If imgTemp Then 
            If dateNext Then 
              If dateNext < F_dateNow Then 'old
                imgTemp = imgTemp.Desaturate()'.Opacity(0.4) 'Grayscale, Transparent
              Else 
                If DateDiff(F_dateNow, dateNext, gb.Hour) > 12 Then imgTemp = imgTemp.Hue(0.7)
              Endif 
            Endif
            imgTemp = imgTemp.Rotate(Rad(-Hour(Val(sTag)) * 30 + (-Minute(Val(sTag)) * 0.5)))
            Paint.DrawImage(imgTemp, iIconSizeHalf - (imgTemp.Width / 2), iIconSizeHalf - (imgTemp.Height / 2)) 'center, middle —▶○◀—
          Endif 
        Endif
      Next
    Endif
    
    If F_imgCenterPoint Then '●
      Paint.DrawImage(F_imgCenterPoint, iIconSizeHalf - (F_imgCenterPoint.Width / 2), iIconSizeHalf - (F_imgCenterPoint.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgPhythagoras Then 'hour-minute-second-centerpoint = 1 Picture
      If Not F_sTagsClockPhythagoras Then F_sTagsClockPhythagoras = Settings[FMain.Name &/ "F_sTagsClockPhythagoras", "-hour-minute-second-centerpoint"]
      If F_sTagsClockPhythagoras Then imgTemp = AddImagesTags("F_imgPhythagoras", F_sTagsClockPhythagoras) 'as Image
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - (imgTemp.Width / 2), iIconSizeHalf - (imgTemp.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgDigital Then '00:00 Text
      If Not F_sTagsClockDigital Then F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", Null]
      If F_sTagsClockDigital Then F_imgDigital = AddImagesTags("F_imgDigital", F_sTagsClockDigital) 'as Image
      If F_imgDigital Then Paint.DrawImage(F_imgDigital, iIconSizeHalf - (F_imgDigital.Width / 2), iIconSizeHalf - (F_imgDigital.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    If F_imgLCD Then '00:00 LCD
      If Not F_sTagsClockLCD Then F_sTagsClockLCD = Settings[FMain.Name &/ "F_sTagsClockLCD", Null]
      If F_sTagsClockLCD Then F_imgLCD = AddImagesTags("F_imgLCD", F_sTagsClockLCD) 'as Image
      If F_imgLCD Then Paint.DrawImage(F_imgLCD, iIconSizeHalf - (F_imgLCD.Width / 2), iIconSizeHalf - (F_imgLCD.Height / 2)) 'center, middle —▶○◀—
    Endif
    
    Paint.End
  Endif 
  
  If Img Then 'Paint.Begin(Img)
    PicBoxClock.Picture = Img.Picture 'without .Copy() not accurate
    F_picClock = Img.Picture  'Note: Image internally is faster than Picture   convert Image to Picture
    FMain.SkipTaskbar = False '(Default ■) '=Icon in Startpanel .SkipTaskbar = False (Default) = is on, visible
    ' If FMain.SkipTaskbar = False Then FMain.Window.Icon = F_picClock 'False > Show (Default), True Icon in Taskbar verhindern □
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End 'DrawTime

Public Function DateMaker(Optional sDate As String = "") As Date
  
  Dim ssDate As String[]
  Dim sNumber As String 
  
  Dim iiNumbers As New Integer[]
  Dim dateNew As Date
  
  If sDate Then
    sDate = Replace(sDate, ":", "-")
    sDate = Trim(sDate) 'delete empty space left+right
    sDate = Replace(sDate, Space(1), "-")
    
    ssDate = Split(sDate & String(5, "-"), "-")
    If ssDate Then   '0000-00-00-00-00-00
      For Each sNumber In ssDate
        If IsInteger(sNumber) = True Then iiNumbers.Add(CInteger(sNumber)) 
      Next
      If iiNumbers.Max < 6 Then iiNumbers.Resize(6)
      dateNew = Date(iiNumbers[0], iiNumbers[1], iiNumbers[2], iiNumbers[3], iiNumbers[4], iiNumbers[5])
    Endif 
  Endif
  
  Return dateNew
  
Catch 
  FMain.ErrorText
  
End

Public Function AddImagesTags(Optional sClockPart As String = "F_imgSunUpDown", Optional sTags As String = Null) As Image
  
  Dim imgTemp As Image
  Dim sTag As String 
  Dim it As Integer
  
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date 
  
  If sClockPart Then 
    ' If sTags Then 
    imgTemp = Null
    Select Case sClockPart 'moving parts (bewegliche Teile)
      Case "F_imgGearWheel"
        imgTemp = M07Paint.ClockGearWheel(F_dateNow, sTags) 'as Image
      Case "F_imgSunUpDown"
        imgTemp = M07Paint.ClockSunUpDown(F_dateNow, sTags) 'as Image
      Case "F_imgClockNumbers"
        imgTemp = M07Paint.ClockNumbers(F_dateNow, sTags) 'as Image
      Case "F_imgDigital"
        imgTemp = M07Paint.ClockDigital(F_dateNow, sTags) 'as Image
      Case "F_imgLCD"
        imgTemp = M07Paint.ClockLCD(F_dateNow, sTags) 'as Image
      Case "F_imgPhythagoras"
        imgTemp = M07Paint.ClockPhythagoras(F_dateNow, sTags) 'as Image
    End Select
    ' Endif 
    
    If imgTemp Then 
      ''Image edit:
      If Not F_ssEditLevels Then F_ssEditLevels = Settings[FMain.Name &/ "F_ssEditLevels", Null]
      ' it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject) '-1 not found 
      If Not FMain.F_iiPicBoxesVisibleLevelNr Then FMain.F_iiPicBoxesVisibleLevelNr = Settings[FMain.Name &/ "F_iiPicBoxesVisibleLevelNr", FMain.F_iiPicBoxesVisibleLevelNr]
      If FMain.F_iiPicBoxesVisibleLevelNr Then
        For Each it In FMain.F_iiPicBoxesVisibleLevelNr
          If it > -1 And F_ssEditLevels Then 
            For Each sTag In Split(F_ssEditLevels[it] & "=", "=")
              If sTag Then imgTemp = ImageEditReturn(imgTemp, sTag)
            Next
          Endif  
        Next 
      Endif 
    Endif 
  Endif 
  
  Return imgTemp
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Function ImageEditReturn(Optional Img As Image, Optional sLastTag As String = "") As Image 
  
  Dim U, U75 As Float 
  Dim tmpImg As Image 
  
  If Img Then 
    ' ssSpli = Split(sLastTag & "=", "=")
    ' For Each sTag In ssSpli
    '   If sTag Then 
    Select Case sLastTag
      Case "mirrorleftright" 'vertical ◁|▶
        Img = Img.Mirror(True, False) '(Horizontal As Boolean, Vertical As Boolean) 
        
      Case "mirrortopbottom" 'horizontal △——▼
        Img = Img.Mirror(False, True)
        
      Case "rotateleft" '◀○
        Img = Img.RotateLeft()
        
      Case "rotateright" '○▶
        Img = Img.RotateRight()
        
      Case "grayscale" '□■
        Img = Img.Desaturate()
        
      Case "scaleminus" ''■ –▶ ▪ ("Inhalt ->verkleinern<-") & Space(1) & "(Scale Minus)"
        tmpImg = New Image(Img.W, Img.H, Color.Transparent)
        Paint.Begin(tmpImg)
        Paint.AntiAlias = True
        Img = Img.Stretch(ImageHalfCheck(Img.W * 0.9), ImageHalfCheck(Img.H * 0.9))
        Paint.DrawImage(Img, (tmpImg.W / 2) - (Img.W / 2), (tmpImg.H / 2) - (Img.H / 2)) '' > center <
        Paint.End
        Img = tmpImg.Copy()
        
      Case "scaleplus" ''▪ –▶ ■ ("Inhalt <-vergrößern->") & Space(1) & "(Scale Plus)"
        tmpImg = New Image(Img.W, Img.H, Color.Transparent)
        Paint.Begin(tmpImg)
        Paint.AntiAlias = True
        Img = Img.Stretch(ImageHalfCheck(Img.W * 1.1), ImageHalfCheck(Img.H * 1.1))
        Paint.DrawImage(Img, (tmpImg.W / 2) - (Img.W / 2), (tmpImg.H / 2) - (Img.H / 2)) '' > center <
        Paint.End
        Img = tmpImg.Copy()
        
      Case "moveleft", "moveright", "moveup", "movedown" '◀ ▶ ▲ ▼
        U = Img.W / 10
        U75 = ImageHalfCheck(U * 0.75)
        tmpImg = New Image(Img.W, Img.H, Color.Transparent)
        Select Case sLastTag
          Case "moveleft"
            Paint.Begin(tmpImg)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, -U75, 0)
            ' Paint.Fill()
            Paint.End
          Case "moveright"
            Paint.Begin(tmpImg)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, U75, 0)
            ' Paint.Fill()
            Paint.End
          Case "moveup"
            Paint.Begin(tmpImg)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, 0, -U75)
            ' Paint.Fill()
            Paint.End    
          Case "movedown"
            Paint.Begin(tmpImg)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, 0, U75)
            ' Paint.Fill()
            Paint.End
        End Select
        Img = tmpImg.Copy()
        
    End Select
    '   Endif 
    ' Next 
  Endif
  
  Return Img 'Background Picture
  
Catch 
  FMain.ErrorText
  
End

Public Function ImageHalfCheck(Optional iSize As Integer = 0) As Integer
  
  iSize = (iSize / 2) * 2 
  If iSize Mod 2 <> 0 Then iSize = iSize + 1 
  
  Return iSize 
  
Catch 
  FMain.ErrorText
  
End

Public Sub HorizontalUhrCheck()
  
  If F_bClockHorizontalON = True Then
    Horizontaluhr()
    HorizontaluhrNurZeiger()
    RaiseOrder()
  Endif
  PanelClockHorizontal.Visible = F_bClockHorizontalON
  
Catch 
  FMain.ErrorText
  
End

Public Sub Horizontaluhr() 'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
  
  Dim it As Integer
  Dim fStdBreite As Float ' mit Kommazahlen, höhere Genauigkeit
  Dim $hLabel As Label
  Dim bCreate As Boolean
  Dim fHour, fMinute, fTwilight, fSA, fSU As Float ' mit Kommazahlen, höhere Genauigkeit
  Dim dateNow As Date
  Dim dateSunUp, dateSunDown As Date
  
  If F_bClockHorizontalON = True Then 
    PanelClockHorizontal.Visible = False 'wegen Aufbau
    dateNow = F_dateAuswahl
    If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date  
    If Not dateNow Then dateNow = F_dateNow
    
    fStdBreite = (PanelClockHorizontal.W / 25)  'Einheit Stunde
    
    If Not F_ooNrBox Then ' —▶see in ▲Declarations▲ in FMain Object[] Public F_
      F_ooNrBox = New Object[]  'New [...]
      bCreate = True
    Else
      bCreate = False
    Endif
    
    If F_ooNrBox Then 
      For it = 0 To 24 ' 0-1-2-3-...24 = 25
        If bCreate = True Then 'wenn noch nicht vorhanden, sonst unten nur Vorhandene bewegen
          $hLabel = New Label(PanelClockHorizontal) As "HUhrLabel"
          $hLabel.Background = Color.Default 'ist transparent
          $hLabel.Foreground = Color.Default
          ' $hLabel.Font.Name = "Ubuntu Condensed" 'smaller
          $hLabel.Font.Size = fStdBreite * 0.45
          $hLabel.Border = Border.None
          $hLabel.Alignment = Align.center
          $hLabel.Text = it
          F_ooNrBox.Add($hLabel)
        Endif 'bCreate
        F_ooNrBox[it].Move((fStdBreite * it), 0, fStdBreite, PanelClockHorizontal.H) ' Breite als 'AS Float' (Komma-Genauigkeit), sonst addieren sich gerundete Fehlpositionen
        F_ooNrBox[it].Visible = True
      Next
    Endif 'F_ooNrBox
    
    dateSunUp = FMain.F_dateSunUp
    dateSunDown = FMain.F_dateSunDown
    
    ''Check times
    If DateDiff(dateSunUp, dateNow, gb.Day) = 0 Or DateDiff(dateSunDown, dateNow, gb.Day) = 0 Then 
      ''current day
    Else 
      M02Astro.AstroSunUpDown(dateNow) 'as Date
      dateSunUp = FMain.F_dateSunUp
      dateSunDown = FMain.F_dateSunDown
      'Check again
      If DateDiff(dateSunUp, dateNow, gb.Day) = 0 Or DateDiff(dateSunDown, dateNow, gb.Day) = 0 Then 
        '...
      Else 
        dateSunUp = Val(Settings[FMain.Name &/ "F_dateSunUp", FMain.F_dateSunUp]) ' String fix > date format
        dateSunDown = Val(Settings[FMain.Name &/ "F_dateSunDown", FMain.F_dateSunDown])
      Endif 
    Endif 
    
    fHour = PanelClockHorizontal.W / 24
    fMinute = fHour / 60
    fTwilight = fMinute * 90  ' =90 Minute (Dmmerung)
    fSA = (fHour * Hour(dateSunUp)) + (fMinute * Minute(dateSunUp)) 
    fSU = (fHour * Hour(dateSunDown)) + (fMinute * Minute(dateSunDown)) 
    
    'Nacht Anfang  nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
    LabelNight1.Text = ""
    LabelNight1.Move(0, PanelClockHorizontal.H / 3 * 2, fSA, PanelClockHorizontal.H)
    LabelNight1.Lower()
    'Nacht Anfang  nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
    
    'Sonnenaufgang SA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    LabelSunUp.Text = ""
    LabelSunUp.Move(LabelNight1.Left + LabelNight1.W, LabelNight1.Top, fTwilight, LabelNight1.H)
    LabelSunUp.Raise()
    'Sonnenaufgang SA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    
    'heller Tagesbereich TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
    LabelDay.Text = ""
    LabelDay.Move(LabelSunUp.Left + LabelSunUp.W, LabelNight1.Top, fSU - fSA - fTwilight, LabelNight1.H)
    LabelDay.Lower()
    'heller Tagesbereich TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
    
    'Sonnenuntergang SU AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    LabelSunDown.Text = ""
    LabelSunDown.Move(LabelDay.Left + LabelDay.W, LabelNight1.Top, fTwilight, LabelNight1.H)
    LabelSunDown.Raise()
    'Sonnenuntergang SU AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    
    'Nacht Ende NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
    LabelNight2.Text = ""
    LabelNight2.Move(LabelSunDown.Left + LabelSunDown.W, LabelNight1.Top, PanelClockHorizontal.W - (LabelSunDown.Left + LabelSunDown.W), LabelNight1.H)
    LabelNight2.Raise() 
    'Nacht Ende NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
    
    PanelClockHorizontal.Visible = True ' wieder sichtbar machen
  Endif 'F_bClockHorizontalON
  
  ''Hours Font Size
  If F_ooNrBox Then 
    For it = 0 To F_ooNrBox.Max
      If F_ooNrBox[it].H / 1.25 < F_ooNrBox[it].W Then 
        ''large ■  0 1 2 3 ... 24
        F_ooNrBox[it].Font.Size = F_ooNrBox[it].H * 0.45
        F_ooNrBox[it].Foreground = Color.Gray
        F_ooNrBox[it].Font.Name = "Ubuntu"
        F_ooNrBox[it].Alignment = Align.Top
      Else 
        ''small ▪  0  2  4 ... 24
        If it Mod 2 = 0 Then 
          F_ooNrBox[it].Font.Size = F_ooNrBox[it].W * 0.65
          F_ooNrBox[it].Foreground = Color.Black
        Else 
          F_ooNrBox[it].Foreground = Color.Transparent  
        Endif
        F_ooNrBox[it].Font.Name = "Ubuntu Condensed" 'or Standard "Ubuntu"
        F_ooNrBox[it].Alignment = Align.Center
      Endif 
      F_ooNrBox[it].Lower() 'Level ▼
    Next
    PicBoxSun.Lower() 'Level ▼
  Endif
  
Catch
  'Message.Error(Error.Text)
  PanelClockHorizontal.Visible = False
  
  FMain.ErrorText
  If Error Then Error.Clear()
  
End

Public Sub HorizontaluhrNurZeiger() 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ only: |
  
  Dim iHH, iMM As Integer
  Dim fStdBreite, fPos1, fZeigerbreite, fSunH As Float
  Dim dateUhrZeiger As Date
  
  If PanelClockHorizontal.Visible = True Then 'Eingeschaltet
    If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date 
    dateUhrZeiger = F_dateNow '"23:50"
    iHH = Hour(dateUhrZeiger)
    iMM = Minute(dateUhrZeiger)
    fStdBreite = (PanelClockHorizontal.Width / 25)  'Einheit Stunde
    
    'Uhrzeiger UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU   ___|____
    fPos1 = 0
    If iHH = 0 Then fPos1 = 0 '0-Fehler vermeiden
    fPos1 = iHH * fStdBreite 'Stundenteil
    If iMM = 0 Then iMM = 1
    fPos1 = fPos1 + ((fStdBreite / 60) * iMM) ' Minuten
    fZeigerbreite = fStdBreite / 2 'mittig Zahl (fStdBreite / 2) und mittig Zeiger (fZeigerbreite / 2) beachten
    LabelSun.Move(fPos1 + (fStdBreite / 2) - (fZeigerbreite / 2), 0, fZeigerbreite, PanelClockHorizontal.Height / 3 * 2)
    LabelSun.Visible = False
    LabelSun.Lower()
    fSunH = PanelClockHorizontal.H / 3 * 2
    PicBoxSun.Move(LabelSun.Left + (LabelSun.W / 2) - (fSunH / 2), 0, fSunH, fSunH)
    PicBoxSun.Visible = True
    PicBoxSun.Lower() 
    'Uhrzeiger UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
  Endif 
  
Catch
  
  FMain.ErrorText
  
End 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Public Sub FilePathHideONoff()
  
  F_bFilePathHideONoff = Settings[FMain.Name &/ "F_bFilePathHideONoff", True]
  If F_bFilePathHideONoff = False Then
    LabelPath.Foreground = Color.Transparent
    LabelPath.Text = ""
  Else
    LabelPath.Text = FMain.F_sPathTerminweckerActual_txt
    If Exist(FMain.F_sPathTerminweckerActual_txt) = False Then
      LabelPath.Foreground = F_iColorFormRed
    Else
      LabelPath.Foreground = LabelTime.Foreground
    Endif
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim fPart As Float
  Dim iW, iH, iPH As Integer
  Dim iPanelMinimizedH As Integer
  
  If FMain.Width < 200 Then FMain.Width = 200 'W
  If FMain.Height < 200 Then FMain.Height = 200 'H
  PicBackground.Move(0, 0, FMain.ClientW, FMain.ClientH)
  
  If F_iOnly1x > 0 And F_bMovingON = False Then 
    iW = PicBackground.Width / 100 * 3 ' Randbreite
    iH = PicBackground.Height / 100 * 3
    iPanelMinimizedH = PanelMinimized.H
    
    ''Panels:
    PanelClock.Move(iW, iH, PicBackground.Width - (2 * iW), PanelClock.H)
    PanelClockHorizontal.Move(iW, PanelClock.Top + PanelClock.H, PanelClock.W, PanelClockHorizontal.H)
    PanelMenu.Move(iW, PanelClockHorizontal.Top + PanelClockHorizontal.H, PanelClock.W, PanelMenu.H)
    PanelColumnV123.Move(iW, PanelMenu.Top + PanelMenu.H, PanelClock.W, FMain.ClientH - (PanelClock.H + PanelClockHorizontal.H + PanelMenu.H + iPanelMinimizedH) - (iH * 2))
    PanelMinimized.Move(iW, FMain.ClientH - iPanelMinimizedH - iH, FMain.ClientW - (iW * 2), iPanelMinimizedH)
    
    ''PanelClock:
    iPH = PanelClock.Height
    F_iClockPictureBoxHeight = iPH 
    PicBoxClock.Move(PanelClock.Width - iPH, 0, iPH, iPH)
    
    iPH = iPH / 3
    PicBoxSchloss.Move(0, (PanelClock.H / 2) - iPH, iPH, iPH)
    PicBoxZaehler.Move(0, PicBoxSchloss.Top + PicBoxSchloss.H, iPH, iPH)
    ' PicBoxKalender.Move(0, PicBoxZaehler.Top + PicBoxZaehler.H, iPH, iPH / 2)
    LabelTime.Move(iPH, 0, PanelClock.W - PicBoxClock.W - iPH, PanelClock.H / 2) ''00:00:00
    LabelProjectTime.Move(LabelTime.Left, LabelTime.Top + LabelTime.Height, LabelTime.W, iPH) 'Dauer
    LabelPressCounter.Move(LabelTime.Left, LabelProjectTime.Top, LabelTime.W + PicBoxClock.W, iPH) '+1 1,2,3...
    LabelDateQKW.Move(LabelTime.Left, LabelPressCounter.Top + LabelPressCounter.H, LabelTime.W, PanelClock.H - (LabelPressCounter.Top + LabelPressCounter.H))
    PicBoxLEDPlusAlarm.Move(0, LabelDateQKW.Top, LabelDateQKW.H, LabelDateQKW.H) '1:1
    
    fPart = PanelMenu.W / 9 
    ButtonEdit.Move(0, 0, fPart * 3, PanelMenu.H) '+Bearbeiten
    ButtonBrowser.Move(ButtonEdit.Left + ButtonEdit.Width, 0, fPart, ButtonEdit.H) 'Browser extern
    ButtonKal.Move(ButtonBrowser.Left + ButtonBrowser.Width, 0, fPart, ButtonEdit.H) 'Calendar HTML
    PicBoxKalender.Move(ButtonKal.Left, ButtonKal.Top, ButtonKal.W, ButtonKal.H)
    ButtonNote.Move(ButtonKal.Left + ButtonKal.Width, ButtonKal.Top, fPart, ButtonEdit.H)
    ButtonRefresh.Move(ButtonNote.Left + ButtonNote.Width, 0, fPart, ButtonEdit.H) 'Aktualisieren
    ButtonMinus.Move(ButtonRefresh.Left + ButtonRefresh.Width, 0, fPart, ButtonEdit.H) '▼ —
    ButtonPlus.Move(ButtonMinus.Left + ButtonMinus.Width, 0, PanelMenu.W - (ButtonMinus.Left + ButtonMinus.W), ButtonEdit.H) '▲ +
    
    ''List:
    ColumnView1.Move(0, 0, PanelColumnV123.Width, PanelColumnV123.H / 3) 'red
    ColumnView2.Move(0, ColumnView1.Top + ColumnView1.H, PanelClock.W, ColumnView1.H) 'yellow
    ColumnView3.Move(0, ColumnView2.Top + ColumnView2.H, PanelClock.W, PanelColumnV123.H - (ColumnView2.Top + ColumnView2.H)) 'green
    
    ''PanelMinimized: _minimieren_
    iPH = LabelPath.H
    PicBoxFileInfo.Move(0, 0, iPH, iPH) '"i"
    PicBoxMedia.Move(PicBoxFileInfo.Left + PicBoxFileInfo.W, 0, iPH, iPH)
    LabelPath.Move(0, 0, PanelClock.W, iPH) 'Pfad
    ProgressBar1.Move(LabelPath.Left, LabelPath.Top, LabelPath.Width, LabelPath.Height)
    LabelMinimi.Move(0, LabelPath.Top + LabelPath.H, PanelClock.W, PanelMinimized.H - iPH) '_minimieren_
    PicBoxPhoto.Move(0, LabelPath.Top + LabelPath.H, LabelMinimi.H, LabelMinimi.H) '—▶AutoResize=False? Padding=4?
    PicBoxAutostart.Move(PicBoxPhoto.Left + PicBoxPhoto.W, PicBoxPhoto.Top, PicBoxPhoto.W, PicBoxPhoto.H)
    IconError.Move(PanelMinimized.W - iPH, 0, iPH, iPH)
    
    ''TextArea:
    iPH = ButtonEdit.H
    PanelTextArea.Move(iW, PanelClock.Top + PanelClock.H, PanelClock.W, PanelMinimized.Top + PanelMinimized.H - PanelClockHorizontal.Top) 
    TextArea2.Move(0, 0, PanelTextArea.W, PanelTextArea.H - iPH)
    ButtonCopy.Move(0, TextArea2.Top + TextArea2.H, iPH, iPH)
    ButtonCancel.Move(ButtonCopy.Left + ButtonCopy.W, TextArea2.Top + TextArea2.H, PanelTextArea.W - iPH, iPH)
    
    ''Panel Program close, end (Quit):
    PanelProgramClose.Move(PanelTextArea.Left, PanelTextArea.Top, PanelTextArea.W, PanelTextArea.H)
    LabelWindowFormClose.Move(0, 0, PanelProgramClose.W, iPH)
    PicBoxFormClose.Move(0, LabelWindowFormClose.Top + LabelWindowFormClose.H, PanelProgramClose.W, PanelProgramClose.H - (iPH * 4))
    ButtonProgramClose.Move(0, PicBoxFormClose.Top + PicBoxFormClose.H, PicBoxFormClose.W, iPH * 2)
    ButtonCloseCancel.Move(0, ButtonProgramClose.Top + ButtonProgramClose.H, LabelWindowFormClose.W, iPH)
    
    ''Jahr, Schieber: ↕
    MoveLine.Move(FMain.ClientW - iW, PanelColumnV123.Top, iW, PanelMenu.H / 2)
    LabelSchiebbereich.Move(FMain.ClientW - iW, PanelColumnV123.Top, iW, PanelColumnV123.H)
    F_iMoveLineMinH = PanelColumnV123.Top
    F_iMoveLineMaxH = PanelColumnV123.Top + PanelColumnV123.H - MoveLine.H
    
    LabelFoto.Move(0, PanelClock.Top + PanelClock.H - LabelTime.Height, iW * 2, LabelTime.Height)
    
    PicBoxFormOpenCount.Move(0, 0, iPH * 0.8, iPH * 0.8)
    
    If FMain.Window.Minimized = False And F_bMovingON = False Then 
      HorizontalUhrCheck()
      
      RaiseOrder()
      
      ColumnView123Resize()
      
      CheckFontSize() 'slowly
      ' ResizeFontSize() 'Fine
      
      ''Form stretch:
      WindowStretch.Move(FMain.ClientW - LabelMinimi.H - iW, FMain.ClientH - LabelMinimi.H - iH, LabelMinimi.H, LabelMinimi.H) 'quadratisch
    Endif 
  Endif  
  
Catch
  
  FMain.ErrorText
  
End

Public Sub CheckFontSize()
  
  Dim iDis As Integer
  Dim fSize As Float
  
  iDis = 4 'Pixel
  LabelTime.Font.Size = LabelTime.H * 0.65
  LabelPressCounter.Font.Size = LabelPressCounter.H * 0.65
  LabelProjectTime.Font.Size = (LabelProjectTime.H - (LabelProjectTime.H / 2)) * 0.65 
  LabelDateQKW.Font.Size = LabelDateQKW.H * 0.65
  If Desktop.Platform = "x11" Then fSize = 0.4 Else fSize = 0.45
  
  ''Check TextWidth:
  If LabelTime.Font.TextWidth(LabelTime.Text) + iDis > LabelTime.W Then LabelTime.Font.Size = LabelTime.H * fSize
  If LabelPressCounter.Font.TextWidth(LabelPressCounter.Text) + iDis > LabelPressCounter.W Then LabelPressCounter.Font.Size = LabelPressCounter.H * fSize
  If LabelProjectTime.Font.TextWidth(LabelProjectTime.Text) + iDis > LabelProjectTime.W Then LabelProjectTime.Font.Size = LabelProjectTime.H * (fSize - 0.2)
  If LabelDateQKW.Font.TextWidth(LabelDateQKW.Text) + iDis > LabelDateQKW.W Then LabelDateQKW.Font.Size = LabelDateQKW.H * fSize
  
Catch
  
  FMain.ErrorText
  
End

Public Sub ResizeFontSize() 'unused, slowly > M01Functions.FontSizeCheck
  
  ''Check Font.Size:
  LabelTime.Font.Size = M01Functions.FontSizeCheck(LabelTime.Text, LabelTime.Font, LabelTime.W, False) 'Wrap=False
  LabelProjectTime.Font.Size = M01Functions.FontSizeCheck(LabelProjectTime.Text, LabelProjectTime.Font, LabelProjectTime.W, False)
  LabelPressCounter.Font.Size = M01Functions.FontSizeCheck(LabelPressCounter.Text, LabelPressCounter.Font, LabelPressCounter.W, False)
  LabelDateQKW.Font.Size = M01Functions.FontSizeCheck(LabelDateQKW.Text, LabelDateQKW.Font, LabelDateQKW.W, False) 'as Float
  
Catch
  
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() '▼Level Bottom▼
  
  WindowStretch.Raise() '▲Level Top▲
  PicBoxFormOpenCount.Raise()
  MoveLine.Raise()
  PanelTextArea.Raise()
  ' TextArea2.Raise()
  PicBoxKalender.Raise()
  LabelFoto.Raise()
  PicBoxFileInfo.Raise() '"i"
  PicBoxPhoto.Raise()
  PicBoxMedia.Raise()
  IconError.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    ' Me.Persistent = True 'FMain
    FormStart()
    F_iOnly1x = F_iOnly1x + 1 
    Form_Resize()
    CheckFileWrite()
    ClockSwitchCheck()
    CheckSoftwareUpdateTXT()
    If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then Form_Resize()
    ' If LabelTime.Font.TextWidth(LabelTime.Text) > LabelTime.W Then Form_Resize()
  Endif 
  
  ' CheckStartFromExternPath()
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckStartFromExternPath()
  
  Dim sLine, sPath As String 
  Dim ssSpli As String[]
  'Menu > Project > Properties > components...
  'Args = Argument > needs component: gb.args > Debuggen/Configuration/Arguments...
  
  If Component.IsLoaded("gb.args") = True Then
    Args.Begin()
    Args.End() 'Gambas3: "Use the Begin method to start the option analysis and the End method to terminate it."
    ' Application.Args.All 'as String[]  The Application.Name is always first: "Name" & space(1) & "Path" & space(1) & ... Path = Args[1], Path = Args[2], ...
    If Args.Abort = False Then Return 'Cancel (Abbrechen)
    For Each sLine In Args.All '.End()  'Separator is Space(1)= " " 'empty bar 1x
      ssSpli = Split(sLine & Space(1), Space(1)) 'application.name & Space(1) & "/dir/file.txt"
      'sProgramName = ssSpli[0]
      sPath = Trim(ssSpli[1])
      If Exist(sPath) = True Then
        If String.LCase(File.Ext(SPath)) = "txt" Then 
          Form3Text.Tag = sPath
          Form3Text.Show
          Break 
        Endif
        ' If String.LCase(File.Ext(SPath)) = "png" Then 
        '   '...
        ' Endif
      Endif
    Next
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckSoftwareUpdateTXT() 
  
  Dim sText, sInfo, sChecked As String 
  
  sInfo = ("Neue Version verfügbar")
  
  If F_bCheckUpdateInternetDaily = True Then sText = M01Functions.SoftwareCheckUpdateTXT() 
  
  If F_bCheckUpdateInternetDaily = True Then  
    sChecked = "," & Space(1) & ("Check") & ":" & Space(1) & String.Left(sText, 10) & Space(1) & Format(Now, "yyyy-mm-dd hh:nn:ss")
  Else 
    sChecked = "," & Space(1) & ("Check") & ":" & Space(1) & ("deaktiviert")
  Endif 
  
  If sText Then 
    MenuCheckUpdateDaily.Text = sInfo & ": " & ("Ja") & sChecked
    mnuHilfe.Text = "?" & String.Left(sText, 10)
  Else  
    MenuCheckUpdateDaily.Text = sInfo & ": " & ("Nein") & sChecked
    mnuHilfe.Text = "?" 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckFileWrite()
  
  Dim sPath, sLines, sText As String 
  
  If Exist(FMain.F_sPathStartzeit_txt) = False Then 
    ' Message.Warning(("Info: Programm gewaltsam beendet (abgestürzt)?"))
    FMain.F_sErrorMessagesExtra = FMain.F_sErrorMessagesExtra & gb.NewLine & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & ": " & ("Achtung, kann nicht speichern? Zugriffrechte?")
  Else 
    If Exist(FMain.F_sPathEveryYear) = False Then 
      If Exist(FMain.F_sDirAppName &/ "geburtstage.txt") = True Then 
        sText = File.Load(FMain.F_sDirAppName &/ "geburtstage.txt")
        sPath = M01Functions.FileAppendText(FMain.F_sPathEveryYear, sText)
        If Exist(sPath) = True Then 
          Try Kill FMain.F_sDirAppName &/ "geburtstage.txt"
          Message.Info("<h3>" & ("Neu") & ":" & "<br><br><font color=darkgreen>" & "geburtstage.txt" & "</font><br><br>" & ("Kopie in") & ":" & "<br><br><font color=blue>" & File.Name(sPath) & "</font></h3>")
        Endif
      Endif  
    Endif 
  Endif 
  
  ''Chrashed, old Files?
  sLines = M01Functions.ProjectOldFindAndCompleted() 'as String 
  If sLines Then 
    sLines = ("Info") & ": " & ("Abgebrochenes Projekt gefunden und abschließend verarbeitet") & ": " & gb.NewLine & sLines & gb.NewLine
    ' Form3Text.Tag = sLines 
    ' Form3Text.Window.Show
    ' Form3Text.Window.Visible = True
    FMain.F_sErrorMessagesExtra = FMain.F_sErrorMessagesExtra & gb.NewLine & sLines
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sMessage, sPath As String
  
  If FMain.Tag = Null Then ''0 noStart
    '...nothing
  Else 
    F_bProgramON = False
    If F_bProgramON = False Then
      F_bProgramON = False
      Timer1.Enabled = False
      ' FMain.Window.Raise()
      ' FMain.Window.SetFocus()
      FMain.Window.TopOnly = True 'Show Message in top ▲level▲ ' "...window stays on top on all other windows."
      ' Windows[FMain.Id].TopOnly = True   
      PanelProgramClose.Visible = True 
      ButtonProgramClose.Raise()
      FMain.Window.TakeFocus = False 'Top —▶ Message.Question()
      ' FMain.Window.Sticky = False 'window is visible in all virtual desktops. False is Default
      sMessage = "<p align=left>" & String(14, "&nbsp;") & IconLogoMessagePic() & "<br>" 
      sMessage &= "<font size=6 color=#" & Hex(FMain.F_iColorClockBlue, 6) & "><b>" & Application.Name & "</b></font>" & "</p>" 
      
      Select Case Message.Question(sMessage, ("Beenden"), ("Abbrechen") & Space(1) & ("[ESC]"))
        Case 1 'Close
          F_bProgramON = False
        Case 2 'Cancel
          F_bProgramON = True
          Timer1.Enabled = True
          Stop Event
      End Select 
    Endif 
    
    ''Program close, end (Quit)
    If F_bProgramON = False Then
      Timer1.Enabled = False
      Timer2Calendar.Enabled = False
      Timer3CounterClock.Enabled = False
      ' M01Functions.MusicStartStop("", False) 'without faster
      ' FMain.Window.Visible = True 'Wayland error?
      If F_bTerminMeldungenAusImmer = False Then ' Nein, nur im laufenden Programm
        mnuTerminMeldungenONG() 'nach Neustart wieder mit Meldungen
      Endif
      'Projektzeiten aktualisieren und abschließen. Bei Abstürzen vor Beenden wird später nachgetragen beim nächsten Neustart. 
      
      ''Project Close:
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, Now, False) 'TRUE (open/refresh), FALSE (close)
      
      SettingsBackupCheck()
      'FMain.F_sTempDateien, 'nur gemerkte löschen
      ' If IsDir(FMain.F_sDirAppName) = True Then sValue = M01Functions.FilesDeleteWithPlaceholder(FMain.F_sDirAppName) 'as String *temp_*.*
      ' M01Functions.FilesDeleteWithPlaceholder(FMain.F_sDirCache) 'as String *temp_*.*
      
      SettingsReadSave("save") 
      Settings[FMain.Name &/ "ProgramStart"] = Null
      CheckTerminweckerTXTBackup()
      M01Functions.ProgramCache(False) 'Delete Cache
      M01Functions.CheckLastSettings()'With Settings.Save() 'Gambas3: "Saves the configuration file to the disk."
      sPath = Settings[FMain.Name &/ "sDirFileBackup", Null]
      If sPath Then M01Functions.SettingsBackupConfig(sPath) 'New, Reload
      Settings[FMain.Name &/ "sDirFileBackup"] = Null
      FormClose() 'vorbereiten
      
      ' FMain.Window.Persistent = False ' Gambas: "The program should stop when all windows are closed, not destroyed. So the "persistent" flag has no effect in that test."
      
      If Exist(FMain.F_sPathStartzeit_txt) = True Then Try Kill FMain.F_sPathStartzeit_txt
      
      'Makes end be sure:
      FormCloseNowDirectlyTotalWithQuit() 'Note: Attention. Beware, be careful! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Endif
  Endif 
  ' Application_Error() 'Print ... in >_ ▼Konsole▼
  
  'Gambas3: "Closing the main window implies closing all other opened windows and quitting the application."
  
Catch
  FMain.ErrorText
  
  Quit ' Beendet das Programm sofort.
  ' Alle Fenster werden geschlossen, dann gelöscht und alles so sauber wie möglich freigegeben.
  
End

Public Function IconLogoMessagePic() As String 
  Dim fRel As Float
  Dim sPathCache1, sMessagePic As String
  Dim Img As Image
  
    'Cache:
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
  Img = FMain.Icon.Image
  If Img And IsDir(File.Dir(sPathCache1)) = True Then 
    Img.Save(sPathCache1)
    fRel = Img.W / Img.H
  Endif 
  If Exist(sPathCache1) = True Then 
    sMessagePic &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & Round(fRel * 100) & " height=100 hspace=0>" 
  Endif 
  
  Return sMessagePic
  
  Catch
  FMain.ErrorText
End

Public Sub FormCloseNowDirectlyTotalWithQuit() 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  ' Dim sPath As String 
  ' 
  ' sPath = User.Home &/ Application.Name &/ "quit.txt"
  ' If IsDir(File.Dir(sPath)) = True Then File.Save(sPath, Me.Title & gb.NewLine & "quit " & Time)
  
  FMain.Tag = Null
  FMain.Persistent = False 
  FMain.TrayIcon1.Delete()
  
  Print "Form_Open(), Form_Close(): " & "Quit, end the program here total"
  Quit 'Gambas3: "End the program immediately. All windows are closed, then deleted, And everything Is Freed As Cleanly As Possible."
  
  ''The Program Ends here totally! (Das Programm endet hier vollständig!)
End

Public Sub CheckTerminweckerTXTBackup()
  
  Dim sPath1, sPath2 As String 
  
  sPath1 = FMain.F_sPathTerminweckerLastBackup_txt '/Dir/Backup/terminwecker.txt_backup.txt
  sPath2 = File.SetDir(sPath1, FMain.F_sDirAppName) '/Dir/terminwecker.txt_backup.txt
  
  If Exist(sPath1) = True And Exist(sPath2) = True Then 
    If Stat(sPath1).LastModified > Stat(sPath2).LastModified Then Try Copy sPath1 To sPath2
  Else If Exist(sPath1) = True 
    If IsDir(File.Dir(sPath2)) = True Then Try Copy sPath1 To sPath2
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub SettingsBackupCheck()
  
  Dim iDiff As Integer
  Dim hDate As Date 
  
  ''Check:
  If Exist(FMain.F_sPathSettingsBackup_conf) = True Then
    hDate = M01Functions.FileLastModifiedDate(FMain.F_sPathSettingsBackup_conf) 'as Date
    iDiff = DateDiff(Now, hDate, gb.day) 'Rückgabe Integer
    'Example: 1 = DateDiff("02.01.2000", "01.01.2000", Tage), (höheres Datum, niedriges Datum)
  Else
    iDiff = 1
  Endif
  
  ''Refresh:
  If Abs(iDiff) > 7 Then 'Tage
    If Exist(FMain.F_sPathSettingsBackup_conf) = True Then
      Try Kill FMain.F_sPathSettingsBackup_conf
    Endif
    If Exist(FMain.F_sPathSettings_conf) = True Then Try Copy FMain.F_sPathSettings_conf To FMain.F_sPathSettingsBackup_conf
  Endif
  
Catch
  
  FMain.ErrorText
  
End

Public Sub FormHide()
  
  TextArea2.Font.Size = 30
  TextArea2.Font.Bold = True
  TextArea2.Foreground = Color.White
  'TextArea2.Text = "Beenden in 3 Sek."
  TextArea2.Background = Color.Green
  PanelTextArea.Background = TextArea2.Background
  
  ButtonCancel.Visible = False 'Abbrechen
  ButtonCopy.Visible = ButtonCancel.Visible
  PanelTextArea.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  PanelTextArea.Visible = True
  TextArea2.Text = ("nur_minimieren_")
  Wait 1.5
  PanelTextArea.Visible = False ' letzte und erste Darstellung beim Einblenden
  TextArea2.Text = ""
  TextArea2.Font.Size = ColumnView1.Font.Size
  TextArea2.Foreground = Color.SelectedBackground
  'INC FMain.Window.TopOnly ' ZOrder, höchste Ebene, INC > sValue = sValue +1 (1 addieren)
  'INC FMain.SkipTaskbar
  'PictureBoxUhr_MouseDown
  
  ButtonCancel.Visible = True 'Abbrechen
  ButtonCopy.Visible = ButtonCancel.Visible
  PanelTextArea.Background = Color.White
  'FMain.Window.Visible = FALSE
  'FMain.Hide´
  FMain.F_picClock = PicBoxClock.Picture
  ' FMain.Window.Icon = PicBoxClock.Picture
  FMain.Window.Minimized = True
  PanelTextArea.Visible = False
  
Catch
  
  FMain.ErrorText
  
End

Public Sub FormClose()
  
  FMain.Window.Title = Application.Name & Space(2) & ("Beenden") & "..."
  TextArea2.Font.Size = 30
  TextArea2.Font.Bold = True
  TextArea2.Foreground = Color.White
  'TextArea2.Text = "Beenden in 3 Sek."
  TextArea2.Background = Color.Red
  PanelTextArea.Background = TextArea2.Background
  ButtonCancel.Visible = False 'Abbrechen
  ButtonCopy.Visible = ButtonCancel.Visible
  PanelTextArea.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  PanelTextArea.Visible = True
  TextArea2.Text = ("Beenden...")
  ' CloseAll()  'alle Fenster im Programm, Hauptfenster zuletzt
  FMain.TopOnly = True 
  ' Wait 0.5
  
  'F_bProgramON = True
  ' FMain.Persistent = False
  'FMain.Window.Close() 'FMain in Form_Close
  
Catch
  FMain.ErrorText
  
End

Public Sub CloseAll() 'all (Program-Forms, Windows)
  
  Dim oObj As Object
  
  ''Application-Windows
  For Each oObj In Windows 'Form   (gb.qt4) Gambas3: "Returns a collection of all windows created by your application."
    If Object.Type(oObj) Like "Form*" Then 
      ' If Class.IsLoaded(oObj.Name) = True Then
      ' If oObj.Name <> FMain.Name Then 
      ' Print oObj.Name
      ' oObj.Window.Persistent = False
      oObj.Window.Close 'Close FMain last
      ' Endif 
    Endif 
  Next 
  
  ' ''System, Desktop-Windows '—▶ M01Functions.ProgramIsAlreadyON()  ' For Each hWindow In Desktop.Windows
  
  ' Dim sFile, sForm As String 
  ' Dim ssSpli As String[]
  ' 
  ' For Each sFile In Dir(".src", "*.form")
  '   ssSpli = Split(sFile & ".", ".")
  '   sForm = ssSpli[0]
  '   Print sForm
  ' Next 
  
  ' If Windows.Count > 1 Then 'FMain last
  '   Form0NurUhr.Close 
  '   Form1FileOpen.Close 
  '   Form2Bearb.Close 
  '   Form3Text.Close 
  '   Form4Bis.Close 
  '   Form5Projekte.Close 
  '   Form7HTML.Close 
  '   Form8ZusFeiertage.Close 
  '   9
  '   10
  '   Form11Breitengrade.Close 
  '   Form12Timerplus.Close 
  '   Form13Export.Close 
  '   Form14UhrDesign.Close 
  '   Form15Foto.Close 
  '   Form16Diagramm.Close 
  '   Form18Projektbearbeiten.Close 
  '   Form19FileInfo.Close 
  '   Form20OpenSource.Close 
  '   Form21Colors.Close 
  '   Form22DialogOpenSave.Close 
  ' Endif 
  'Last FMain.Window.Close —▶ this Form_Close()
  
  ''____________________________________________________________________''
  'Gambas3: "If the window is not persistent (which is by default), then the window is destroyed after the Close() method is called. This means that any control contained in the Window is also destroyed, and the window object itself becomes invalid."
  
Catch
  
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  FilePathHideONoff()
  
Catch
  
  FMain.ErrorText
  
End

Public Sub TerminBisZeileLesen() '+until (+bis)
  
  Dim sLine As String
  Dim T0, T5, sDiff As String
  Dim iDiff As Integer
  Dim hDate As Date
  
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date  
  
  If Exist(FMain.F_sPathTerminweckerUntil_txt) = True Then 
    sLine = File.Load(FMain.F_sPathTerminweckerUntil_txt)
  Endif 
  If Not sLine Then 
    'Alternative safely:
    sLine = Settings[FMain.Name &/ "F_sTerminUntilLine", sLine]
  Endif 
  
  If String.InStr(sLine, FMain.F_sTab) > 0 Then
    FMain.F_sTerminUntilLine = sLine
    T0 = M01Functions.TextSplit(sLine, 0, FMain.F_sTab)
    T5 = M01Functions.TextSplit(sLine, 5, FMain.F_sTab)
    hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
    iDiff = DateDiff(F_dateNow, hDate, gb.day) 'as Integer
    'Example: 1 = DateDiff("02.01.2000", "01.01.2000", Tage), (höheres Datum, niedriges Datum)
    If iDiff > -1 Then
      sDiff = "+" & Str(iDiff + 1)
    Else
      sDiff = Str(iDiff + 1)
    Endif
    T0 = Format(hDate, "ddd dd.mm.yyyy")
    mnuBis.Text = Space(3) & sDiff & Space(3) 'mehr Anklickfläche
    mnuHilfe.Text = "?" & Space(5)
    mnuBisEingabe.Text = ("Anzahl Tage bis") & ": " & sDiff & " = " & T0 & Space(1) & String.Left(T5, 15)
    If iDiff > -1 Then mnuBisAmpel.Visible = False Else mnuBisAmpel.Visible = True   'Picture["icon:/22/important"] 
  Endif
  
Catch
  
  FMain.ErrorText
  
End

Public Sub LabelDateQuarterCWeekG()
  
  Dim sT3, sT4, sTitle As String
  Dim dateNow As Date  
  'Select Case Format(Date, "mm")
  'Case "01", "02", "03"
  'sT3 = 1
  'Case "04", "05", "06"
  'sT3 = 2
  'Case "07", "08", "09"
  'sT3 = 3
  'Case "10", "11", "12"
  'sT3 = 4
  'End Select
  'sT3 = sT3 & "Q"
  'sT4 = Week(Date) & ("KW")
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date 
  dateNow = F_dateNow
  sT3 = Str(M01Functions.DateQuarterG(dateNow)) & "Q" '1...4
  sT4 = Format(M01Functions.DateCalenderWeek(dateNow), "00") & ("KW") '00...52   Week(dateNow)
  
  LabelDateQKW.Text = Format(dateNow, "ddd dd.mm.yyyy ") & Space(1) & sT3 & Space(1) & sT4 & Space(1) & Format(dateNow, "mmm")
  sTitle = Application.Name & " - " & Format(dateNow, "mmmm")
  If FMain.Window.Title <> sTitle Then FMain.Window.Title = Application.Name & " - " & Format(dateNow, "mmmm")
  
Catch
  FMain.ErrorText
  
End

Public Sub FMainSetFocus() 'as Public
  
  ''FMain. or FMain.
  FMain.F_bFMainSetFocus = False
  FMain.Activate()
  FMain.Window.Minimized = False
  ' FMain.Window.Maximized = False 
  
  ' FMain.Window.TopOnly = True'▲ Gambas3: "...window stays on top on all other windows."
  ' FMain.Stacking = Window.Above '▲ 'Fenster unter, über, normal. integer 2=Below. Gambas3: "This constants is used by the Stacking property for windows that must stay below other windows."
  ' FMain.Window.Sticky = False 'window is visible in all virtual desktops. False is Default
  FMain.Window.Visible = True 'Wayland error?
  FMain.Window.Raise() '▲top level▲ (erheben, oberste Ebene)
  ' FMain.Window.SetFocus()
  
  TrayIconColorize(0) 'iStop0_Plus1_Alarm2
  
  ''__________________________________________________''
  'Wayland (Fensterverwalter): Form.Move(x,y) and all functions with Position are not available, no support. Actual no alternative without X11 (old). 
  'https://gambaswiki.org/wiki/comp/gb.qt4/form
  
Catch
  FMain.ErrorText
  
End

Public Function DateTimeActual() As Date 
  
  If Not F_dateNow Then F_dateNow = Now
  
  Return F_dateNow
  
Catch
  FMain.ErrorText
  
End

' Public Sub TimerCheckStart_Timer()
'   '.Delay = 1010 ?
'   M01Functions.CheckProgramON() 'only 1x, not double
'   If F_iProgramStartCounter > 3 Then TimerCheckStart.Enabled = False 
'   
' Catch 
'   FMain.ErrorText
' End

Public Sub Timer1_Timer()
  
  'Timer1.Delay = 1000 ' 1000=1Sekunde, also im Sekundentakt (second intervals)
  
  If F_bStopForWindowPhoto = False Then 'False is Default '—▶Menuphotowindowfixtime
    If FMain.F_bFMainSetFocus = True Then FMainSetFocus()
    If Exist(FMain.F_sPathTerminweckerActual_txt) = False Then 
      LabelPath.Text = ("Datei fehlt")
      PicBoxFileInfo.Visible = True 
      PicBoxFileInfo.Background = Color.Red
      LabelPath.Foreground = Color.Red
      F_bCheckUSBFileMissing = True 
    Else 
      PicBoxFileInfo.Visible = False 
      PicBoxFileInfo.Background = Color.Default
      LabelPath.Foreground = LabelTime.Foreground
      If F_bFilePathHideONoff = True Then LabelPath.Text = FMain.F_sPathTerminweckerActual_txt Else LabelPath.Text = ""
      
      If F_bCheckUSBFileMissing = True Then 
        F_bCheckUSBFileMissing = False 
        F_bNeueinlesenStarten = True
      Endif 
    Endif 
    
    F_dateNow = Now 'New  ********************************
    F_dateNow00second = Date(Year(F_dateNow), Month(F_dateNow), Day(F_dateNow), Hour(F_dateNow), Minute(F_dateNow), 0)
    
    If Not F_dateChange Then F_dateChange = F_dateNow
    
    If Day(F_dateNow) > Day(F_dateChange) Then F_bNeueinlesenStarten = True
    
    ''Refresh Projects:
    Timer1IntervalSecond() '—▶ F_dateChange = F_dateNow 'Refresh 'ProjectLineOpenRefreshClose 'Refresh, F_sVorweckzeit60 Alarm
    ' F_dateChange  Old ************************
    
    ''Refresh all:
    If F_bNeueinlesenStarten = True Then 
      TimerRefreshAll.Start() 
    Else 
      ''Clock-Alarm:
      If Second(F_dateNow) = 1 Then Timer1IntervalMinute()  ' If Format(F_dateNow, "ss") = "00" Then 
    Endif 
    
  Endif 'F_bStopForWindowPhoto
  
  ''Paint Clock:
  If F_iClockMap0Stop1Count2Digital3Design4 > 2 Then DrawTime()
  
  WindowFormOpenCount()
  
  If F_bProgramON = False Then
    Timer1.Enabled = False
    FMain.Window.Close
  Endif
  
Catch
  
  FMain.ErrorText
  
End

Public Sub WindowFormOpenCount()
  
  Dim iCount As Integer
  Dim oObj As Object
  
  ''Application-Windows
  For Each oObj In Windows 'Form   (gb.qt4) Gambas3: "Returns a collection of all windows created by your application."
    If Object.Type(oObj) Like "Form*" Then 
      If Object.IsValid(oObj) = True Then 
        If oObj.Visible = True Then iCount = iCount + 1
      Endif  
    Endif 
  Next 
  
  ''More Program-Windows open?
  If iCount > 0 Then PicBoxFormOpenCount.Visible = True Else PicBoxFormOpenCount.Visible = False
  ' PicBoxFormOpenCount.Tooltip = ("Aktiv: " & iCount & Space(1) & ("Programm-Fenster"))
  
Catch
  
  FMain.ErrorText
  
End

Public Sub Timer1IntervalSecond()
  
  F_iProjectSeconds = F_iProjectSeconds + 1
  ' Settings["F_iProjectSeconds"] = F_iProjectSeconds
  
  If F_bStopForWindowPhoto = False Then 
    If Not FMain.F_dateProjectStart Then FMain.F_dateProjectStart = F_dateNow
    
    ''Day Changed? 00:00:00
    If Day(F_dateNow) > Day(F_dateChange) Then  'Example: Day(24) > Day(23) = True
      'Current process
      ''Project Old: 23:59:59 
      FMain.F_dateProjectEnd = Date(Year(F_dateChange), Month(F_dateChange), Day(F_dateChange), 23, 59, 59) 'Yesterday End 23:59:59
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, FMain.F_dateProjectEnd, False) 'TRUE (open/refresh), FALSE (close)
      
      ''Poject New: 00:00:01 
      FMain.F_dateProjectStart = Date(Year(F_dateNow), Month(F_dateNow), Day(F_dateNow), 0, 0, 1) 'Today Begin 00:00:01
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, F_dateNow, True) 'TRUE (open/refresh), FALSE (close)
      
      ''Calendar Refresh:
      ' If F_bCalendarHTMLautomaticRefreshON = True Then
      '   Timer2Calendar.Enabled = True ' übergeben und warten bis Einlesen als Vorlage fertig ist
      ' Endif
      
    Else If Second(F_dateNow) = 30 Then 'give Time, not parallel processing >0<
      ''Refresh Line: Now
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, F_dateNow, True) 'TRUE (open/refresh), FALSE (close)
    Endif 
  Endif 
  
  ''Project Counter:
  If F_iClockMap0Stop1Count2Digital3Design4 < 1 Or F_iClockMap0Stop1Count2Digital3Design4 > 2 Then 
    LabelPressCounter.Visible = False
    LabelProjectTime.Visible = True
    If F_sProjectOnlyName Then
      LabelProjectTime.Text = String.Left(F_sProjectOnlyName, 16) & "=" & M01Functions.SecondsInfoText(F_iProjectSeconds) & Space(2) 'as String
      LabelProjectTime.ToolTip = ("Projekt: Name + Dauer") & gb.NewLine & F_sProjectOnlyName
      ' LabelProjectTime.Tooltip = ("Dauer") & ": " & LabelProjectTime.Text
    Endif
    If FMain.Window.Title <> Application.Name & " - " & Format(F_dateNow, "mmmm") Then FMain.Title = Application.Name & " - " & Format(F_dateNow, "mmmm")
  Endif
  
  ''Label Counter Timer:
  LabelTime.Text = Format(F_dateNow, "hh:nn:ss")
  
  If F_bClockHorizontalON = True And PanelClockHorizontal.Visible = False Then HorizontalUhrCheck()
  
  F_dateChange = F_dateNow 'Refresh
  
  'See, show:          (Main.F_sErrorInfos)
  ' If F_sErrorMessagesExtra Then IconError.Visible = True ' auch aus anderen Formularen und Modulen
  
  ''______________________________________________________________________''
  'Info:   
  '0 = Error, not divisible by zero 0
  '60s x 60m x 24h = 86400s = 1 Day
  'Gambas3: "The current localization is used for converting numbers and dates. So beware that date, time, decimal and thousands separators change with the language!"
Catch
  
  FMain.ErrorText
  
End

Public Sub Timer1IntervalMinute()
  
  ' If Exist(FMain.F_sPathStartzeit_txt) = False Then  'Example: /home/user/terminwecker/...
  '   M01Functions.CheckProgramON()
  ' Else If File.Load(FMain.F_sPathStartzeit_txt) <> Str(FMain.F_dateProgramStart) Then 
  '   Try File.Save(FMain.F_sPathStartzeit_txt, Str(FMain.F_dateProgramStart)) 'Reset, Refresh
  ' Endif
  
  ''Weekday changed or Null:
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date 
  F_dateNow00second = Date(Year(F_dateNow), Month(F_dateNow), Day(F_dateNow), Hour(F_dateNow), Minute(F_dateNow), 0)
  If String.InStr(LabelDateQKW.Text, Format(F_dateNow, "dd.mm.yyyy")) = 0 Then LabelDateQuarterCWeekG()
  
  If F_bClockHorizontalON = True Then HorizontaluhrNurZeiger() '__|__
  
  ''Clock-Alarm
  TermineaktuellTextArea2()'aktualisieren, Clock-Alarm 
  
  ''Media, USB-Stick?
  If FMain.F_sPathTerminweckerActual_txt <> FMain.F_sPathTerminweckerStandard_txt And FMain.F_sPathTerminweckerActual_txt Begins "/media" Then   
    If M01Functions.CheckLatestTerminweckerTXT() Then PicBoxMedia.Visible = True Else PicBoxMedia.Visible = False 
    PicBoxMedia.Background = Color.Red
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub TestTerminNotiz()
  
  Dim sKey As String 
  Dim dateTest As Date 
  
  ''in Arbeit
  ''Test: 
  F_iVorNachweckzeit60 = -2
  F_iVorNachweckzeit30 = -1
  dateTest = Date(Year(F_dateNow), Month(F_dateNow), Day(F_dateNow), Hour(F_dateNow), Minute(F_dateNow), 0)
  
  dateTest = DateAdd(dateTest, gb.Minute, Abs(F_iVorNachweckzeit60) + 1)
  sKey = ColumnView1.Count + 1
  ColumnView1.Add(sKey, "")
  ColumnView1[sKey][0] = Format(dateTest, "yyyy-mm-dd")
  ColumnView1[sKey][1] = Format(dateTest, "hh:nn")
  ColumnView1[sKey][5] = "xNotiz Test1"
  
  dateTest = DateAdd(dateTest, gb.Minute, Abs(F_iVorNachweckzeit60) + 2)
  sKey = ColumnView1.Count + 1
  ColumnView1.Add(sKey, "")
  ColumnView1[sKey][0] = Format(dateTest, "yyyy-mm-dd")
  ColumnView1[sKey][1] = Format(dateTest, "hh:nn")
  ColumnView1[sKey][5] = "xNotiz Test2"
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckOldLines()
  
  Dim iOnly1x, it As Integer
  Dim dateLine As Date
  Dim sKey, sColumnViewX As String 
  Dim ssLines, ssPart As New String[]
  
  ColumnView123Resize()
  ColumnView1.UnSelectAll()
  ColumnView2.UnSelectAll()
  ColumnView3.UnSelectAll()
  
  For Each sKey In ColumnView1.Keys
    ColumnView1[sKey].BackGround = Color.Default
    ssLines.Add(ColumnView1[sKey][0] & gb.NewLine & ColumnView1[sKey][1] & gb.NewLine & "1" & gb.NewLine & sKey)
  Next 
  For Each sKey In ColumnView2.Keys
    ColumnView2[sKey].BackGround = Color.Default
    ssLines.Add(ColumnView2[sKey][0] & gb.NewLine & ColumnView2[sKey][1] & gb.NewLine & "2" & gb.NewLine & sKey)
  Next 
  For Each sKey In ColumnView3.Keys
    ColumnView3[sKey].BackGround = Color.Default
    ssLines.Add(ColumnView3[sKey][0] & gb.NewLine & ColumnView3[sKey][1] & gb.NewLine & "3" & gb.NewLine & sKey)
  Next 
  ssLines.Sort()
  F_sNaechsterTermin = Null 'Reset
  
  ''0 Date | 1 Clock | 2 ColumnViewX | 3 Key
  For it = 0 To ssLines.Max
    ssPart = Split(ssLines[it] & String(3, gb.NewLine), gb.NewLine)
    dateLine = M01Functions.DateCheckyyyymmddhhnn(ssPart[0], ssPart[1]) 'as Date
    dateLine = Date(Year(dateLine), Month(dateLine), Day(dateLine), Hour(dateLine), Minute(dateLine), 0) 'Today Begin 00:00:00    yyyy-mm-dd hh:nn:00
    
    sColumnViewX = ssPart[2] 'Day: Red, Yellow, Green
    sKey = ssPart[3]
    
    ''—▶Select Line
    Select Case sColumnViewX 
        
      Case 1', "1"
        If iOnly1x = 0 And ColumnView1.Exist(sKey) = True Then  
          If dateLine >= F_dateNow00second Then 
            F_sNaechsterTermin = ColumnView1[sKey][0] & FMain.F_sTab & ColumnView1[sKey][1] & FMain.F_sTab & ColumnView1[sKey][2] & FMain.F_sTab & ColumnView1[sKey][5] & FMain.F_sReturnCrLF
            F_dateNaechsterTermin = dateLine
            'Gleiche Vorzeichen, Example: F_iNaechsterTermininMinuten, F_iVorNachweckzeit60, -60, -60
            F_iNaechsterTermininMinuten = DateDiff(dateLine, F_dateNow00second, gb.Minute)
            'Example: 1 = DateDiff("02.01.2000", "01.01.2000", Tage), (höheres Datum, niedriges Datum)
            ColumnView1[sKey].Selected = True
            ColumnView1[sKey].BackGround = LabelTime.Foreground
            ColumnView1[sKey].EnsureVisible 'show next termin
            iOnly1x = iOnly1x + 1 'alternative: INC iOnly1x
          Endif
        Endif 
        
      Case 2', "2"
        If iOnly1x = 0 And ColumnView2.Exist(sKey) = True Then  
          If dateLine >= F_dateNow00second Then 
            F_sNaechsterTermin = ColumnView2[sKey][0] & FMain.F_sTab & ColumnView2[sKey][1] & FMain.F_sTab & ColumnView2[sKey][2] & FMain.F_sTab & ColumnView2[sKey][5] & FMain.F_sReturnCrLF
            F_dateNaechsterTermin = dateLine
            F_iNaechsterTermininMinuten = DateDiff(dateLine, F_dateNow00second, gb.Minute)
            ColumnView2[sKey].Selected = True
            ColumnView2[sKey].BackGround = LabelTime.Foreground
            ColumnView2[sKey].EnsureVisible 'show next termin
            iOnly1x = iOnly1x + 1
            ColumnView1.ScrollY = ColumnView1.ScrollH 'Last line
          Endif
        Endif  
        
      Case 3', "3"
        If iOnly1x = 0 And ColumnView3.Exist(sKey) = True Then  
          If dateLine >= F_dateNow00second Then 
            F_sNaechsterTermin = ColumnView3[sKey][0] & FMain.F_sTab & ColumnView3[sKey][1] & FMain.F_sTab & ColumnView3[sKey][2] & FMain.F_sTab & ColumnView3[sKey][5] & FMain.F_sReturnCrLF
            F_dateNaechsterTermin = dateLine
            F_iNaechsterTermininMinuten = DateDiff(dateLine, F_dateNow00second, gb.Minute)
            ColumnView3[sKey].Selected = True
            ColumnView3[sKey].BackGround = LabelTime.Foreground
            ColumnView3[sKey].EnsureVisible 'show next termin
            iOnly1x = iOnly1x + 1
            ColumnView2.ScrollY = ColumnView2.ScrollH 'Last line
          Endif
        Endif  
        
    End Select 
    
    If iOnly1x > 0 Then Break 
  Next 
  
  If iOnly1x = 0 Then F_iNaechsterTermininMinuten = 1
  
Catch
  
  FMain.ErrorText
  
End

Public Sub TermineaktuellTextArea2() 'Check Clock Alarm
  
  Dim sText, sText1, sText2, sPlusMinutes, sMinutes As String
  Dim iDays, iMinutes As Integer
  Dim sDay As String
  Dim dateNext As Date
  Dim iStop0_Plus1_Alarm2 As Integer = -1
  Dim iColorForeground As Integer = Color.Default
  
  CheckOldLines() 'Nächsten Termin einlesen, Clock-Alarm
  
  F_sVorweckZeitText = ("Plus-Alarm -vorher/+nachher") & ": " & F_iVorNachweckzeit60 & " / " & F_iVorNachweckzeit30
  
  If F_iNaechsterTermininMinuten <= 0 Then 
    sText2 = Format(F_dateNaechsterTermin, "ddd") & FMain.F_sTab & F_sNaechsterTermin
    
    iMinutes = F_iNaechsterTermininMinuten
    'calendar days, not clock distance:
    iDays = DateDiff(Date(Year(F_dateNow), Month(F_dateNow), Day(F_dateNow)), Date(Year(F_dateNaechsterTermin), Month(F_dateNaechsterTermin), Day(F_dateNaechsterTermin)), gb.Day) 'only calendar days, yyyy-mm-dd - yyyy-mm-dd
    'iDays = DateDiff(F_dateNow, F_dateNaechsterTermin, gb.Day)
    'Example: 1 = DateDiff("02.01.2000", "01.01.2000", Tage), (höheres Datum, niedriges Datum)
    
    Select Case iDays
      Case 0
        sDay = ("HEUTE")
      Case 1
        sDay = ("MORGEN")
      Case 2
        sDay = ("ÜBERMORGEN")
      Case Else 
        sDay = "..."  '("TAGEN")
    End Select 
    
    If iMinutes >= 0 Then sMinutes = iMinutes Else sMinutes = "+" & Abs(iMinutes)
    If Abs(iMinutes) = 1 Then sPlusMinutes = ("Minute") Else sPlusMinutes = ("Minuten")
    
    sText1 = ("Nächster Termin") & Space(1) & sDay & Space(1) & Format(dateNext, "ddd") & FMain.F_sReturnCrLF 
    sText1 &= ("in") & Space(1) & sMinutes & Space(1) & sPlusMinutes & FMain.F_sReturnCrLF 
    sText1 &= FMain.F_sReturnCrLF
    PicBoxLEDPlusAlarm.Tooltip = sText1 & FMain.F_sReturnCrLF & F_sVorweckZeitText
    
    sText = sText1 & FMain.F_sReturnCrLF 
    sText &= sText2 & FMain.F_sReturnCrLF 
    sText = Replace(sText, FMain.F_sTab, Space(2))
    
    TextArea2.Clear()
    
    Select Case F_iNaechsterTermininMinuten
      Case F_iVorNachweckzeit60
        PicBoxLEDPlusAlarm.Picture = PicTemplateLEDyellow.Picture
        F_iColorBGNextTermin = Color.Lighter(F_iColorAmpel2) 'lighter yellow
        TextArea2.Background = F_iColorBGNextTermin
        TextArea2.Foreground = Color.Default
        iStop0_Plus1_Alarm2 = 1 
        
      Case F_iVorNachweckzeit30
        PicBoxLEDPlusAlarm.Picture = PicTemplateLEDyellow.Picture
        F_iColorBGNextTermin = F_iColorAmpel2  'yellow
        iColorForeground = Color.Default
        iStop0_Plus1_Alarm2 = 1
        
      Case F_iVorNachweckzeit60 To F_iVorNachweckzeit30 
        PicBoxLEDPlusAlarm.Picture = PicTemplateLEDyellow.Picture
        F_iColorBGNextTermin = Color.Darker(F_iColorAmpel2) 'darker yellow
        iColorForeground = Color.Default
        
      Case 0
        PicBoxLEDPlusAlarm.Picture = PicTemplateLEDred.Picture
        F_iColorBGNextTermin = F_iColorAmpel1 'red
        iColorForeground = Color.White
        iStop0_Plus1_Alarm2 = 2
        
      Case Else 
        PicBoxLEDPlusAlarm.Picture = PicTemplateLEDgreen.Picture
        F_iColorBGNextTermin = Color.Lighter(F_iColorAmpel3) 'lighter green
        iColorForeground = Color.Default 
        
    End Select 
    
    PicBoxLEDPlusAlarm.Visible = F_bClockAlarmBeforeBehindON
    PicBoxLEDPlusAlarm.Raise()
    TextArea2.Background = F_iColorBGNextTermin
    TextArea2.Foreground = iColorForeground
    TextArea2.SelectAll()
    TextArea2.Insert(sText)
    TextArea2.Pos = 0
    
  Else
    TextArea2.Clear()
    sText = ("Kein aktueller Termin") & FMain.F_sReturnCrLF 
    sText &= F_sVorweckZeitText & FMain.F_sReturnCrLF
    PicBoxLEDPlusAlarm.Picture = PicTemplateLEDgreen.Picture
    F_iColorBGNextTermin = Color.Default 'white
    TextArea2.Background = F_iColorBGNextTermin
    TextArea2.Foreground = Color.Default 'black
    PicBoxLEDPlusAlarm.Visible = F_bClockAlarmBeforeBehindON
    PicBoxLEDPlusAlarm.Raise()
    TextArea2.SelectAll()
    TextArea2.Insert(sText)
    TextArea2.Pos = 0
  Endif 
  
  If F_dateNaechsterTermin = Null Or Day(F_dateNaechsterTermin) > Day(F_dateNow00second) Then 
    ' If ColumnView1.Current Then ColumnView1[ColumnView1.Keys.Last].EnsureVisible()
    ColumnView1.ScrollY = ColumnView1.ScrollH
  Endif
  FMain.F_sTerminaktuellMeldung = String.Left(sText, 300) '>Form0NurUhr
  
  ClockAlarmMusicStopPlay(iStop0_Plus1_Alarm2)
  
Catch
  FMain.ErrorText
  
End

Public Sub ClockAlarmMusicStopPlay(Optional iStop0_Plus1_Alarm2 As Integer = 0)
  
  Dim sPath, sDirFile, sDir, sFile As String 
  
  ''Clock-Alarm:
  If F_bClockMessageON = True Then 
    
    Select Case iStop0_Plus1_Alarm2
        
      Case 0 ''Stop
        M01Functions.MusicStartStop("", False) 'Stopp
        
      Case 1 ''Plus-Alarm
        If F_bClockAlarmBeforeBehindON = True Then 
          FMainSetFocus()
          M01Functions.MusicStartStop("", False) 'Stopp
          sDirFile = M01Functions.MusicStartStop("Plus", True) 'very short (sehr kurzer Weckerton)
          sDirFile = M01Functions.MusicStartStop("Plus", True) 
        Endif 
        
      Case 2 ''Clock-Alarm:
        If F_bClockAlarmMusicON = True Then 
          sPath = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", FMain.F_sPathMusicStandard_mp3]
          sDir = File.Dir(sPath)
          If IsDir(sDir) = False And IsDir("music") = True Then sDir = "music"
          sFile = File.Name(sPath)
          sDirFile = sDir &/ sFile
          
          FMainSetFocus()
          M01Functions.MusicStartStop("", False) 'Stopp
          sDirFile = M01Functions.MusicStartStop(sDirFile, True) 'Weckerton
        Endif 
        
    End Select 
    If sDirFile Then TextArea2.Text = TextArea2.Text & gb.NewLine & F_sVorweckZeitText & gb.NewLine & sDirFile
    TrayIconColorize(iStop0_Plus1_Alarm2)
  Endif 
  
  'Check next termin in 1 Minute —▶Timer
  
Catch
  FMain.ErrorText
  
End

Public Sub TrayIconColorize(Optional iStop0_Plus1_Alarm2 As Integer = 0)
  
  If F_iTrayIconSystemON1 = 1 Then
    If Component.IsLoaded("gb.gui.trayicon") = True Then 'needs component "gb.dbus"  (D-Bus-Interface)
      Select Case iStop0_Plus1_Alarm2
        Case 0 'Original 32x32
          TrayIcon1.Icon = PicTemplateFMainIcon32.Picture
          
        Case 1  'Yellow
          TrayIcon1.Icon = PicTemplateFMainIcon32.Picture.Image.Colorize(Color.RGB(255, 240, 0)).Picture 'Color.Yellow
          
        Case 2  'Red
          TrayIcon1.Icon = PicTemplateFMainIcon32.Picture.Image.Colorize(Color.SoftRed).Picture
          
      End Select
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub RefreshAll(Optional iDaysMinusOrPlus As Integer = 0) 
  
  F_iDaysMinusOrPlus = iDaysMinusOrPlus
  LabelDateQuarterCWeekG()
  ReadG()
  ' TermineaktuellTextArea2()
  TerminBisZeileLesen() 
  FormBackgroundColor()
  LoadClockG()
  CheckStandardFile()
  If F_bClockHorizontalON = True Then HorizontalUhrCheck()
  F_bCalendarHTMLautomaticRefreshON = Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON", False] 
  
  ''Timer2 or this?
  If F_bCalendarHTMLautomaticRefreshON = True Then 
    Timer2Calendar.Start()
    ' If Exist(FMain.F_sPathTerminweckerActual_txt) = True Then 
    '   F_sWebFileNew = M04Kalender.CalendarReadCreateHTML(FMain.F_sPathTerminweckerActual_txt) 
    ' Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonRefreshG()
  'Werte zurücksetzen und neu einlesen
  
  F_iDaysMinusOrPlus = 0
  LabelDateQuarterCWeekG()
  CheckFontSize()
  FMain.F_sFeiertage = ""
  Settings[FMain.Name &/ "F_sFeiertage"] = ""
  LabelSchiebbereich.Visible = False
  MoveLine.Top = F_iMoveLineMinH
  F_iVorNachweckzeit60 = Settings[FMain.Name &/ "F_iVorNachweckzeit60", -60]
  F_iVorNachweckzeit30 = Settings[FMain.Name &/ "F_iVorNachweckzeit30", -30]
  ReadG()
  
  ' TermineaktuellTextArea2()
  ' M01Functions.FileBackupChecken(FMain.F_sPathTerminweckerActual_txt)
  TerminBisZeileLesen() 
  FormBackgroundColor()
  LoadClockG()
  ' If F_bClockHorizontalON = True Then HorizontalUhrCheck()
  F_bCalendarHTMLautomaticRefreshON = Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON", False] 
  If F_bCalendarHTMLautomaticRefreshON = True And Timer2Calendar.Enabled = False Then Timer2Calendar.Start()
  TrayIconColorize(0) 'iStop0_Plus1_Alarm2
  
Catch
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG() 'EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  
  Dim it, it2, iLinesCount, iColumnsCount, iDiff As Integer
  Dim ssLinesAll, ssLine As String[]
  Dim date1, date2, date3, dateA, dateB, dateC As Date
  Dim sDateA, sDateB, sDateC As String 
  Dim sKey, sText, sYYYYNow, sMMDD, sYYYYOld, sPlusMinusCounter As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  'Info: 'Gambas3: "For example: Split(MyString, "\r\n") will split MyString by using "\r" or "\n" as separator, but not the full string "\r\n"."
  
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date 
  FMain.F_sErrorMessagesExtra = "" 'Reset, Fehlerliste zurücksetzen
  F_dateFileReadingTime = Now
  
  FilePathHideONoff()
  IconError.Visible = False
  
  F_bESCpressedON = False
  F_sTagsClockDatePoints = Null
  
  ' If F_iDaysMinusOrPlus = 0 Then F_sTermineActual = ""
  
  F_sHeuteyyyymmdd = Format(F_dateNow, "yyyy-mm-dd")
  date1 = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus)
  date2 = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus + 1)
  date3 = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus + 2)
  dateA = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus)
  sDateA = Format(dateA, "yyyy-mm-dd")
  dateB = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus + 1)
  sDateB = Format(dateB, "yyyy-mm-dd")
  dateC = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus + 2)
  sDateC = Format(dateC, "yyyy-mm-dd")
  
  F_dateAuswahl = date1
  
  ColumnView1.Clear()
  ColumnView1.Header = True ' Sichtbar
  ColumnView2.Clear()
  ColumnView2.Header = True ' Sichtbar
  ColumnView3.Clear
  ColumnView3.Header = True ' Sichtbar
  
  'Spalten (Columns) erzeugen
  ColumnView1.Columns.Count = F_iColumnsCount ' 0=Datum, 1=Uhr, 2, 3, 4, 5=Notiz, '6=Datum
  ColumnView2.Columns.Count = F_iColumnsCount
  ColumnView3.Columns.Count = F_iColumnsCount
  'ColumnView1.Expand = True 
  
  ''Termine einlesen: 
  If Exist(FMain.F_sPathTerminweckerActual_txt) = True Then
    ' If Stat(FMain.F_sPathTerminweckerActual_txt).Size < 500000 Then 
    '   sText = File.Load(FMain.F_sPathTerminweckerActual_txt) 'All Lines
    ' Else
    sText = ReadActualLinesFromFileG() 'only acutal Lines
    ' Endif 
  Else 
    ''Empty, Demo-Line
    sText = M01Functions.DemoLineTerminwecker()
  Endif 
  
  ''Check Text-Format: 
  If sText And Split(sText & hTab, hTab).Count < 5 Then 
    LabelPath.Foreground = Color.Red
    FMain.F_sErrorMessagesExtra &= FMain.F_sPathTerminweckerActual_txt & gb.NewLine
    FMain.F_sErrorMessagesExtra &= ("TABulatoren als Spalten-Trennzeichen fehlen") & "." & gb.NewLine
    If String.Len(sText) < 20 Then FMain.F_sErrorMessagesExtra &= ("Leere Datei" & "?") & gb.NewLine
  Endif
  
  ''Type End of Line:
  If String.InStr(sText, gb.CrLf) > 0 Then 'Windows-Dateienden
    hReturn = gb.CrLf
  Else  'Linux-Dateienden
    hReturn = gb.NewLine
  Endif
  
  ''Lines:
  ssLinesAll = Split(sText & hReturn, hReturn)
  iLinesCount = ssLinesAll.Count
  
  ''ColumnView1 (red): 111111111111111111111111111111111111111111111111111111111111
  If F_iDaysMinusOrPlus > -1 Then
    sPlusMinusCounter = Space(5) & "+" & Str(F_iDaysMinusOrPlus) & Space(1) & ("Tage")
  Else
    sPlusMinusCounter = Space(5) & Str(F_iDaysMinusOrPlus) & Space(1) & ("Tage")
  Endif
  ColumnView1.Columns[1].Text = Format(date1, "ddd")
  ColumnView1.Columns[5].Text = Format(date1, "dd.mm.yyyy ") & sPlusMinusCounter
  
  ''ColumnView2 (yellow): 2222222222222222222222222222222222222222222222222222222222
  If F_iDaysMinusOrPlus + 1 > -1 Then
    sPlusMinusCounter = Space(5) & "+" & Str(F_iDaysMinusOrPlus + 1) & Space(1) & ("Tage")
  Else
    sPlusMinusCounter = Space(5) & Str(F_iDaysMinusOrPlus + 1) & Space(1) & ("Tage")
  Endif
  ColumnView2.Columns[1].Text = Format(date2, "ddd")
  ColumnView2.Columns[5].Text = Format(date2, "dd.mm.yyyy ") & sPlusMinusCounter
  
  ''ColumnView3 (green): 3333333333333333333333333333333333333333333333333333333333
  If F_iDaysMinusOrPlus + 1 > -1 Then
    sPlusMinusCounter = Space(5) & "+" & Str(F_iDaysMinusOrPlus + 2) & Space(1) & ("Tage")
  Else
    sPlusMinusCounter = Space(5) & Str(F_iDaysMinusOrPlus + 2) & Space(1) & ("Tage")
  Endif
  ColumnView3.Columns[1].Title = Format(date3, "ddd")
  ColumnView3.Columns[5].Title = Format(date3, "dd.mm.yyyy ") & sPlusMinusCounter
  
  ''ColumnView1:
  ColumnView1.Background = F_iColorFormWhite
  If F_iDaysMinusOrPlus = 0 Then ColumnView1.Background = F_iColorAmpel1
  If F_iDaysMinusOrPlus = 1 Then ColumnView1.Background = F_iColorAmpel2
  If F_iDaysMinusOrPlus = 2 Then ColumnView1.Background = F_iColorAmpel3
  If ColumnView1.Background = F_iColorFormWhite And Format(date1, "ddd") = gb.Sunday Then ColumnView1.Background = F_iColorFormYellowLight
  If ColumnView1.Background = F_iColorAmpel1 Then
    ColumnView1.Foreground = F_iColorFormWhite
    ColumnView1.Font.Bold = True
  Else
    ColumnView1.Foreground = Color.Default
    ColumnView1.Font.Bold = False
  Endif
  
  ''ColumnView2:
  ColumnView2.Background = F_iColorFormWhite
  If F_iDaysMinusOrPlus + 1 = 0 Then ColumnView2.Background = F_iColorAmpel1
  If F_iDaysMinusOrPlus + 1 = 1 Then ColumnView2.Background = F_iColorAmpel2
  If F_iDaysMinusOrPlus + 1 = 2 Then ColumnView2.Background = F_iColorAmpel3
  If ColumnView2.Background = F_iColorFormWhite And Format(date2, "ddd") = gb.Sunday Then ColumnView2.Background = F_iColorFormYellowLight
  
  ''ColumnView3:
  ColumnView3.Background = F_iColorFormWhite
  If F_iDaysMinusOrPlus + 2 = 0 Then ColumnView3.Background = F_iColorAmpel1
  If F_iDaysMinusOrPlus + 2 = 1 Then ColumnView3.Background = F_iColorAmpel2
  If F_iDaysMinusOrPlus + 2 = 2 Then ColumnView3.Background = F_iColorAmpel3
  If ColumnView3.Background = F_iColorFormWhite And Format(date3, "ddd") = gb.Sunday Then ColumnView3.Background = F_iColorFormYellowLight
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  For it = 0 To iLinesCount - 1 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLines
    If FMain.F_bESCpressedON = True Then 
      Select Case Message.Question(("Termine") & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
        Case 1
          FMain.F_bESCpressedON = False
        Case 2
          Break
      End Select
    Endif 
    ssLine = Null
    ssLine = Split(ssLinesAll[it] & String(5, hTab), hTab)
    If ssLine Then iColumnsCount = ssLine.Count Else iColumnsCount = 0
    If iColumnsCount > 4 Then ' DDDDDDDDDD
      ssLine[0] = Replace(ssLine[0], Space(1), "") ' evtl. Leerzeichen entfernen
      ''Day: 0000-00-00
      If String.Len(ssLine[0]) > 10 Then 'raus filtern
        If ssLine[0] Like "????-??-??*" Then 
          ssLine[0] = String.Left(ssLine[0], 10) 
        Else If ssLine[0] Like "*????-??-??" Then 
          ssLine[0] = String.Right(ssLine[0], 10) ' von rechts, links kann Dateiinfo an Dateianfang sein.
        Endif 
      Endif
      ''Birthday: *
      If String.Left(ssLine[5], 1) = "*" Then 'EveryYear, birthsday (Geburtstag) **********************************
        sYYYYNow = Format(F_dateNow, "yyyy") 'yyyy
        sMMDD = String.Right(ssLine[0], 6) '-mm-dd
        sYYYYOld = String.Left(String.Right(ssLine[0], 10), 4)
        If M01Functions.isZahl(sYYYYOld) = True Then
          iDiff = Val(sYYYYNow) - Val(sYYYYOld)
          ssLine[5] = ssLine[5] & " (" & Str(ssLine[0]) & "=" & Str(iDiff) & "J.)"
        Endif
        ssLine[0] = sYYYYNow & sMMDD 'yyyy-mm-dd
      Endif
      If ssLine[1] Not Like "??:??" Then ssLine[1] = "00:00" 'Empty>Error
      ssLine[1] = M01Functions.TimeCheckHHMM(ssLine[1]) 
      ' If String.Left(ssLine[1], 2) = "24" Then ssLine[1] = "23" & ":" & String.Right(ssLine[1], 2) ' 24h=00h
      
      Select Case String.LCase(ssLine[0]) '0000-00-00 or SoSa (Timer)
          
        Case sDateA ''0000-00-00
          sKey = ColumnView1.Count + 1
          ColumnView1.Add(sKey, "")
          For it2 = 0 To ColumnView1.Columns.Max '=Count-1
            ColumnView1[sKey][it2] = ssLine[it2]
            ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
          Next
          ' If F_iDaysMinusOrPlus = 0 And Val(ssLine[1]) >= Val(Format(F_dateNow, "hh:nn")) Then 
          '   F_sTermineActual &= ColumnView1[sKey][0] & F_sTab & ColumnView1[sKey][1] & F_sTab & String.Left(ColumnView1[sKey][5], 300) & hReturn 'Tooltip—▶ Form0NurUhr
          ' Endif 
          If ssLine[0] Then F_sTagsClockDatePoints = F_sTagsClockDatePoints & Str(DateMaker(ssLine[0] & Space(1) & ssLine[1])) & gb.NewLine 
          
        Case sDateB ''0000-00-00
          sKey = ColumnView2.Count + 1
          ColumnView2.Add(sKey, "")
          For it2 = 0 To ColumnView2.Columns.Max '=Count-1
            ColumnView2[sKey][it2] = ssLine[it2]
            ColumnView2[sKey][F_iColumnSort] = ColumnView2[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
          Next
          ' If F_sTermineActual = "" Then F_sTermineActual = F_sTermineActual & ColumnView2[sKey][0] & F_sTab & ColumnView2[sKey][1] & F_sTab & String.Left(ColumnView2[sKey][5], 300) & hReturn
          
        Case sDateC ''0000-00-00
          sKey = ColumnView3.Count + 1
          ColumnView3.Add(sKey, "")
          For it2 = 0 To ColumnView3.Columns.Max '=Count-1
            ColumnView3[sKey][it2] = ssLine[it2]
            ColumnView3[sKey][F_iColumnSort] = ColumnView3[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
          Next
          
        Case Else ''Timer SoMo...'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
          If ssLine[0] <> "" And ssLine[0] Not Like "*????-??-??*" Then 'Timerzeile 
            
            ''ColumnView1:
            If String.LCase(ssLine[0]) Like "*" & String.LCase(Format(date1, "ddd")) & "*" Or ssLine[0] Like "*" & Str(WeekDay(date1)) & "*" Then 'Timer Line (Timer-Zeile) Example: "Su0Mo1". WeekDay(date1) = gb.Sunday = "0"
              sKey = ColumnView1.Count + 1
              ColumnView1.Add(sKey, sDateA) '[0]
              For it2 = 1 To ColumnView1.Columns.Max '[1], [2], ...
                ColumnView1[sKey][it2] = ssLine[it2]
                ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
              Next
              If String.LCase(String.Left(ColumnView1[sKey][5], 2)) <> String.LCase("Timer:") Then ColumnView1[sKey][5] = "Timer:" & Space(1) & ColumnView1[sKey][5]
            Endif 
            
            ''ColumnView2:
            If String.LCase(ssLine[0]) Like "*" & String.LCase(Format(date2, "ddd")) & "*" Or ssLine[0] Like "*" & Str(WeekDay(date2)) & "*" Then 'Timer Line
              sKey = ColumnView2.Count + 1
              ColumnView2.Add(sKey, sDateB) '[0]
              For it2 = 1 To ColumnView2.Columns.Max
                ColumnView2[sKey][it2] = ssLine[it2]
                ColumnView2[sKey][F_iColumnSort] = ColumnView2[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
              Next
              If String.LCase(String.Left(ColumnView2[sKey][5], 2)) <> String.LCase("Timer:") Then ColumnView2[sKey][5] = "Timer:" & Space(1) & ColumnView2[sKey][5]
            Endif 
            
            ''ColumnView3:
            If String.LCase(ssLine[0]) Like "*" & String.LCase(Format(date3, "ddd")) & "*" Or ssLine[0] Like "*" & Str(WeekDay(date3)) & "*" Then 'Timer Line
              sKey = ColumnView3.Count + 1
              ColumnView3.Add(sKey, sDateC) '[0]
              For it2 = 1 To ColumnView3.Columns.Max
                ColumnView3[sKey][it2] = ssLine[it2]
                ColumnView3[sKey][F_iColumnSort] = ColumnView3[sKey][F_iColumnSort] & String.Left(ssLine[it2], 10)
              Next
              If String.LCase(String.Left(ColumnView3[sKey][5], 2)) <> String.LCase("Timer:") Then ColumnView3[sKey][5] = "Timer:" & Space(1) & ColumnView3[sKey][5]
            Endif
          Endif 
          
      End Select
    Endif ' DDDDDDDDDDDDDDDDDD
    
  Next 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLines
  
  'Holidays (Feiertage) HHHHHHHHHHHHHHHHHHHHHHHHHolidays
  FMain.F_sFeiertage = Settings[FMain.Name &/ "F_sFeiertage"] 
  If String.InStr(FMain.F_sFeiertage, Format(date1, "yyyy")) = 0 Then M03Feiertage.HolidaysCalculate(date1)
  If String.InStr(FMain.F_sFeiertage, Format(date3, "yyyy")) = 0 Then M03Feiertage.HolidaysCalculate(date3, "+")
  ssLine = Split(FMain.F_sFeiertage & hReturn, hReturn)
  If ssLine Then iLinesCount = ssLine.Count Else iLinesCount = 0
  
  If iLinesCount > 0 Then ' NNNNNNNNNNN
    For it = 0 To ssLine.Max
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(("Feiertage") & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      ssLinesAll = Split(ssLine[it] & String(2, hTab), hTab) ' gb.Tab =hTab Example: TAB2018-12-31TAB#(Silvester)
      Select Case ssLinesAll[1] 'Example: 2018-12-31
        Case sDateA
          sKey = ColumnView1.Count + 1
          ColumnView1.Add(sKey, "") '[0]
          ColumnView1[sKey][0] = sDateA
          ColumnView1[sKey][1] = "00:00"
          ColumnView1[sKey][5] = ssLinesAll[2] & Space(1) & ("[autom. berechnet]")
          
        Case sDateB
          sKey = ColumnView2.Count + 1
          ColumnView2.Add(sKey, "") '[0]
          ColumnView2[sKey][0] = sDateB
          ColumnView2[sKey][1] = "00:00"
          ColumnView2[sKey][5] = ssLinesAll[2] & Space(1) & ("[autom. berechnet]")
          
        Case sDateC
          sKey = ColumnView3.Count + 1
          ColumnView3.Add(sKey, "") '[0]
          ColumnView3[sKey][0] = sDateC
          ColumnView3[sKey][1] = "00:00"
          ColumnView3[sKey][5] = ssLinesAll[2] & Space(1) & ("[autom. berechnet]")
      End Select
    Next
  Endif 'HHHHHHHHHHHHHHHHHHHHHHHHHolidays
  ColumnView123Resize()
  ' TestTerminNotiz() 'xxxxxxx
  TermineaktuellTextArea2() 'CheckOldLines() 'Zeit einlesen
  
  ' ColumnView1.SetFocus '???
  ' ColumnView1_GotFocus() ' Fokus und Spaltenbreiten an 2 und 3 weitergeben
  If DateDiff(F_dateNow, F_dateFileReadingTime, gb.Second) > 1 Then PicBoxFileInfo.Visible = True Else PicBoxFileInfo.Visible = False
  F_dateFileReadingTime = Now - F_dateFileReadingTime 'F_dateNow 1sec. Timer, Now with uuu (MilliSecond)
  Settings[FMain.Name &/ "F_dateFileReadingTime"] = F_dateFileReadingTime
  
Ende:
  
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch  '(Mögliche Fehler abfangen)
  LabelPath.Visible = True
  IconError.Visible = True
  FMain.ErrorText
  ' If Error Then Return
  
End  ''ReadG() 'EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Public Function ReadActualLinesFromFileG() As String ''TTTTTTTTTTTTTTTTTT
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File
  Dim sLine, sLines, sText, sSearch, sDirFile As String
  Dim date1, date2, date3 As Date
  Dim sT0, sT5, sDateA, sDateB, sDateC As String 
  Dim sTimer1, sTimer2, sTimer3 As String 
  Dim ssSpli As String[]
  Dim dateNow As Date 
  Dim bFound As Boolean
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFile = F_sPathTerminweckerActual_txt
  If Exist(sDirFile) = False Then sDirFile = F_sPathTerminweckerStandard_txt
  
  If Exist(sDirFile) = True Then 
    If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date  
    dateNow = DateAdd(F_dateNow, gb.day, F_iDaysMinusOrPlus)
    
    date1 = Date(Year(dateNow), Month(dateNow), Day(dateNow), 0, 0, 0)
    date2 = DateAdd(date1, gb.day, 1)
    date3 = DateAdd(date1, gb.day, 2)
    
    ''Dates:
    sDateA = Format(date1, "yyyy-mm-dd")
    sDateB = Format(date2, "yyyy-mm-dd")
    sDateC = Format(date3, "yyyy-mm-dd")
    
    ''Timer:
    sTimer1 = String.LCase(Format(date1, "ddd")) 'Weekday: "Su", "Mo", ...
    sTimer2 = String.LCase(Format(date2, "ddd"))
    sTimer3 = String.LCase(Format(date3, "ddd"))
    
    ''Days: 3
    sSearch = sDateA & hTab & sDateB & hTab & sDateC & hTab & sTimer1 & hTab & sTimer2 & hTab & sTimer3 'Actual Lines
    
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFile & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            FMain.F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      If String.Left(sLine, 1) <> "#" And String.InStr(sLine, hTab) > 0 Then 
        ssSpli = Split(sLine & String(5, hTab), hTab)
        sT0 = String.LCase(ssSpli[0]) 
        sT5 = String.Left(ssSpli[5], 1) '*Every Year?
        bFound = False
        If sSearch Like "*" & sT0 & "*" Then
          bFound = True 
        Else If sT0 Like "*" & sTimer1 & "*" Then 
          bFound = True
        Else If sT0 Like "*" & sTimer2 & "*" Then 
          bFound = True
        Else If sT0 Like "*" & sTimer3 & "*" Then 
          bFound = True
        Else If sT5 = "*" Then '*Every Year, Birthdays
          bFound = True
        Endif 
        If bFound = True Then sLines &= sLine & hReturn 
        'sLine = Conv$(sLine, Desktop.Charset, "ISO-8859-1")
        'sLine = Conv$(sLine, "utf-8", "ISO-8859-1")
      Endif 
    Next 
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  'Check "\r" Return,  Typ Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
  If Exist(sDirFile) = True And String.InStr(sLine, gb.Cr) > 0 Then 
    sText = File.Load(sDirFile)
    If sText Then 
      ssSpli = New String[]
      sText = Replace(sText, gb.Cr, gb.NewLine)
      ssSpli = Split(sText & gb.NewLine, gb.NewLine) 
      sLines = ssSpli.Join(hReturn)
    Endif 
  Endif 
  Return sLines
  
Catch
  FMain.ErrorText
  
End 'TTTTTTTTTTTTTTTTTT

Public Sub mnuDatei_Show()
  
  Dim sDirFileOldYears, sFile As String
  
  sDirFileOldYears = FilePathFormOldYears() '"_vergangene.txt"
  sFile = File.Name(sDirFileOldYears)
  mnuTermineAuslagern.Text = ("Auslagern...") & Space(1) & (" >> ") & Space(1) & sFile & Space(1) & ("=schneller")
  mnuTermineEinlagern.Text = ("Einlagern...") & Space(1) & (" << ") & Space(1) & sFile 
  
  CheckStandardFile()
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDateiOpenG() 'Öffnen...
  
  Form1FileOpen.Tag = FMain.F_sPathTerminweckerActual_txt
  Form1FileOpen.Window.Show
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuBeendenG()
  
  F_bProgramON = False 'about Timer1
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuHilfe_Show()
  
  Dim sDirFile, sDir, sFile As String
  
  ' sDirFile = "text/CHANGELOG" 'Relative Path  GROSS/klein beachten
  ' If File.IsRelative(sDirFile) = False Then 
  sDir = "text/"
  sFile = "CHANGELOG" 'Text-File
  sDirFile = ".hidden/CHANGELOG" 'only in "/home/..."
  ''Access forbidden? 
  If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then  'Read=0 
    sDirFile = sDir &/ sFile 'Relative-Path
  Endif 
  mnuVersionsaenderungen.Enabled = Exist(sDirFile)  'True or False
  MenuCheckUpdateDaily.Checked = F_bCheckUpdateInternetDaily
  MenuSoftwareInfo.Text = ("Software-Info") & Space(1) & ("Version") & Space(1) & Application.Version
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuFestplattenbelegung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("baobab")
  If bExist = True Then
    Shell "baobab" 'startet Programm
    ' M01Functions.ExternStart("baobab") 'Festplattenbelegung
  Else
    bExist = System.Exist("nautilus")
    M01Functions.ExternStart("nautilus", "")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuFestplattenbelegung.Text, "Fehlt") = 0 Then mnuFestplattenbelegung.Text &= Space(2) & ("Fehlt!")
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup")
  If bExist = True Then
    Shell "deja-dup" 'startet Programm
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuInfoG()
  
  Dim statInfo As Stat
  Dim dateBoot, dateProgramStart As Date
  Dim sSystemBootStart, sProgramStart, sDauer, sLastChange, sDirTerminwecker, sProgramFile, sDirFile, sDir, sPathDesktop, sDesktop, sFile As String 
  Dim sComponentsText, sToolScreenshot As String 
  Dim iSeconds As Integer
  Dim sFreierSpeicher, sDirSize, sValue, sUbuntuVersion, sMessage As String 
  Dim longFree, longSize As Long
  
  sToolScreenshot = FMain.F_sScreenshotToolPath 
  If Not sToolScreenshot Then sToolScreenshot = ("leer")
  sUbuntuVersion = M01Functions.UbuntuVersionG() 'as String 
  
  ''Programm:
  sProgramFile = Application.Path &/ Application.Name & ".gambas"
  If Exist(sProgramFile) = False Then sProgramFile = System.Find(Application.Name)
  If Exist(sProgramFile) = False Then sProgramFile = Application.Path &/ Application.Name & ".png"
  If Exist(sProgramFile) = False Then sProgramFile = Application.Path &/ ".startup"
  statInfo = Stat(sProgramFile)
  sDirTerminwecker = FMain.F_sDirAppName 'Extra private User-Dir, Work-Dir
  
  ''Free:
  longFree = M01Functions.DirectoryFreeBytesLong("/") ' as Long  "/"=Alles auf Gerät
  If Component.IsLoaded("gb.util") = True Then '.FormatSize() needs component gb.util   False="KB" (1024), True="KiB" (1000)
    sFreierSpeicher = ("Freier Speicher") & ": " & File.FormatSize(longFree, False) & Space(5) & "(" & Format(longFree, "0,0") & Space(1) & "Bytes)"
    'Exist File-Size:
    For Each sFile In RDir(sDirTerminwecker, "*.*")
      longSize = longSize + Stat(sDirTerminwecker &/ sFile).Size
    Next 
    sDirSize = ("Dateien") & ": " & RDir(sDirTerminwecker, "*.*").Count & " = " & File.FormatSize(longSize, False)
  Else  
    sFreierSpeicher = ("Freier Speicher") & ": " & Format(longFree / 1024 / 1024 / 1024, "0,0") & Space(1) & "GB" & Space(5) & "(" & Format(longFree, "0,0") & Space(1) & "Bytes)"
  Endif 
  
  'Test:
  ' sValue = sValue & statInfo.LastAccess & "<br>"
  ' sValue = sValue & statInfo.LastChange & "<br>"
  ' sValue = sValue & statInfo.LastModified & "<br>"
  ' sValue = sValue & statInfo.Link & "<br>"
  ' sValue = sValue & statInfo.Mode & "<br>"
  ' sValue = sValue & statInfo.Size & "<br>"
  ' sValue = sValue & statInfo.Time & "<br>"
  ' sValue = sValue & statInfo.User & "<br>" ' /Benutzername/
  ' sValue = ""
  
  ''Info:
  ' sLastChange = sValue 
  sLastChange = ("Geändert") & ": " & Format(statInfo.LastChange, "ddd dd.mm.yyyy hh:nn") & "<br>"
  sLastChange &= ("Größe") & ": " & Format(statInfo.Size, "0,0") & Space(1) & "Bytes" & " (" & M01Functions.FileSizeLongText(statInfo.Size) & ")" & "<br>"
  sLastChange &= ("gambas3 runtime. Interpreter-Version") & ": " & "Gambas" & System.Version & ". " & ("Thanks (Merci, Danke)") & "." & "<br>"  'Example: 3
  sLastChange &= "<br>"
  sLastChange &= ("Letzte Bildschirmfotos mit") & ": " & sToolScreenshot & "<br>"
  sLastChange &= ("Eigene Dateien") & ": " & File.Dir(sDirTerminwecker) &/ "<font color=blue>" & File.Name(sDirTerminwecker) & "</font>" &/ "..." & "<br>"
  sLastChange &= sDirSize & "<br>"
  sLastChange &= sFreierSpeicher & "<br>"
  
  dateBoot = M01Functions.TimeSystemBootStart()
  sSystemBootStart = ("System-Boot-Start") & ": " & Format(dateBoot, "ddd dd.mm.yyyy hh:nn")
  
  dateProgramStart = Settings[FMain.Name &/ "ProgramStart", Now]
  
  iSeconds = DateDiff(dateProgramStart, Now, gb.Second) ' as Integer ' Test: CDate("01/03/2013 18:22:00")
  
  sDauer = M01Functions.SinceStartText(dateProgramStart) 'as String "-1234 Sekunden"
  sDauer = ("vor") & Space(1) & sDauer
  
  sProgramStart = ("ProgramStart") & ": " & Format(dateProgramStart, "ddd dd.mm.yyyy hh:nn")
  
  ''Components:
  sComponentsText = M01Functions.CheckComponents() 'as String  'leer oder Text
  
  sMessage = "<h2>" & ("Programm") & ": " & Application.Name & "</h2>" 
  sMessage &= "(Linux-Version)" 
  sMessage &= "<h4>" & "Version" & ": " & Application.Version & Space(1) & ("Freeware") & "<font color=darkgreen>" & Space(1) & ("(kostenlos)") & "</h4>" 
  
  sMessage &= ("System.Architecture") & ": " & ("Alle") & ", " & "32-bit & 64-bit" & ", " & ("hier") & Space(1) & System.Architecture & Space(1) & "<font color=gray>" & "(x86, x86_64, arm, aarch64, powerpc, e2k)" & "</font>" & "<br>" 
  sMessage &= ("Programm-Verzeichnis") & ": " & Application.Path &/ Application.Name & "<br>" 'Example: /usr/bin/gambas3/ or /home/user/gambas3/
  sMessage &= sLastChange & "<br>" 
  If Exist(FMain.F_sPathAutoStartDatei_desktop) = True Then 
    sMessage &= ("Auto-Start") & ": ● " & ("Ja") & "<br>"
  Else 
    sMessage &= ("Auto-Start") & ": ○ " & ("Nein") & "<br>" 
  Endif 
  sMessage &= ("Betriebssystem") & ": " & sUbuntuVersion & "<br>" 
  
  sMessage &= sSystemBootStart & "<br>"
  sMessage &= sProgramStart & "<br>"
  sMessage &= ("Dauer") & ": " & "<b><font color=darkgreen>" & sDauer & "</font></b>" & Space(1) & "(" & Str(iSeconds) & Space(1) & ("Sekunden") & ")" & "<br>"
  sMessage &= "<br>" 
  
  ''Link in Desktop:
  sDir = Desktop.GetDirectory("DESKTOP")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If Exist(sDir) = True Then
    sPathDesktop &= sDir &/ Application.Name & ".desktop" 
    If Exist(sPathDesktop) = False Then 
      For Each sFile In Dir(sDir, "*" & Application.Name & "*").Sort()
        sDesktop &= sFile & "<br>"
      Next 
    Endif 
    If Exist(sPathDesktop) = True Then 
      sMessage &= ("Verknüpfung (Link) im Schreibtisch (Desktop, Startbildschirm)") & ": " & "<font color=gray>" & "● " & ("Ja") & "</font>" & "<br>"
    Else 
      sMessage &= ("Verknüpfung (Link) im Schreibtisch (Desktop, Startbildschirm)") & ": " & "<font color=gray>" & "○ " & ("Nein") & "</font>" & "<br>"
      sMessage &= "<font color=gray>" & sDesktop & "</font>" & "<br>"
    Endif 
  Endif 
  sMessage &= "<br>" 
  
  sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then 
    sValue = M01Functions.FileSizeText(sDirFile)
    sMessage &= ("Aktuelle Terminwecker-Datei") & ":" & "<br>" 
    sMessage &= "<font color=blue>" & sDirFile & "</font>" & "<br>" 
    sMessage &= sValue & "<br>"
    sValue = M01Functions.FileLastModifiedText(sDirFile)
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & sValue & "</b></font>" & "<br>"
  Else 
    sMessage &= sDirFile & Space(3) & "<font color=red><b>" & ("Fehlt") & "</b></font>" & "<br>"
  Endif 
  sMessage &= "<br>" 
  
  ''"(c) 2012-2013, 2021-2022, www.design-cad.de" 
  sMessage &= "(c) 2012-2024, www.design-cad.de" 
  
  Select Case Message.Question(sMessage, ("Mehr..."), ("Veränderte Dateien"), ("Abbrechen"))
    Case 1
      sMessage = sComponentsText 
      ' Message.Info(sMessage, ("Abbrechen"))
      sMessage = MessageSize(sMessage) 'as String. x11, wayland
      
      Select Case Message.Question(sMessage, ("Infos kopieren"), ("Abbrechen"))
        Case 1 'Directory
          Clipboard.Clear
          Clipboard.Copy(sMessage, "text/html")
        Case 2
          '...
      End Select
      
    Case 2
      FileChangeList()
    Case 3
      ''...
  End Select
  ''________________________________________________________________''
  'Gambas3: CDate() "Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Gambas3: Val() "The current localization is used for converting numbers and dates. So beware that date, time, decimal and thousands separators change with the language!"
  
  ' Gambas3 Info:
  ' GTK+3 and QT5 components now support Wayland.
  ' GTK+3, QT4 and QT5 new web browser components using the same interface.
  ' GTK+3 component is now on a par with QT5 component, allowing the development environment to run with GTK+3! 
  ' Compiler is now faster by using all the CPU cores. 
  
Catch
  FMain.ErrorText
  
End

Public Function MessageSize(Optional sMessage As String = "") As String 
  
  If String.LCase(Desktop.Platform) = "x11" Then sMessage = "<font size=2>" & sMessage & "</font>"
  If String.LCase(Desktop.Platform) = "wayland" Then sMessage = "<font size=3>" & sMessage & "</font>"
  
  Return sMessage
  
Catch
  FMain.ErrorText
  
End

Public Sub FileChangeList()
  
  Dim sPath, sMessage As String 
  Dim ssSpli As String[]
  Dim iCount As Integer
  
  sMessage = "<h3><font color=darkgreen>" & ("Neue oder aktualisierte Dateien") & ": " & "</font></h3>" 
  
  If FMain.F_sFilesChangedList Then
    ssSpli = Split(FMain.F_sFilesChangedList & gb.NewLine, gb.NewLine)
    For Each sPath In ssSpli.Sort()
      If Exist(sPath) = True Then 
        sMessage &= sPath & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPath).Size) & "<br>"
        iCount = iCount + 1
        If iCount > 20 Then 
          sMessage &= "..."
          Break
        Endif
      Endif 
    Next  
  Else 
    sMessage &= "<font color=blue>" & ("Keine") & "</font>" & "<br>"
  Endif 
  sMessage &= "<br>"
  sMessage &= "<font color=gray>" & ("Tipp: Abfrage wiederholen") & "</font>" 
  
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
    Case 1
      If Exist(sPath) = True Then 
        M01Functions.FileManagerOpen(sPath)
      Else 
        M01Functions.FileManagerOpen(File.Dir(sPath))  
      Endif 
    Case 2
      ''...
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub SoftwareInfo()
  
  Dim sMessage, sDir, sSoftwareCenter, sText As String 
  'MyApp = Application.Name
  
  ' ''Installed in Root?  Root-Example: "/usr/..."   User-Example: "/home/user/..."
  ' ' sDirFile = System.Path '"/usr/"   Components "/usr/lib/gambas3/..."  MyApp: '"/usr/share/MyApp/..."
  ' sDirFile = System.Find(Application.Name) 'Find Program, Software, App
  ' If sDirFile = "" Then sDirFile = Application.Path &/ Application.Name & ".gambas"
  
  sText = InfoInstalledSoftware() 'Check and show Info
  If sText Then 
    PanelTextArea.Visible = True 
    PanelTextArea.Raise()
    TextArea2.SelectAll()
    TextArea2.Insert(sText)
    TextArea2.Pos = 1
    TextArea2.EnsureVisible()
  Endif 
  ' sText &= M01Functions.CheckComponents() 'as String  'leer oder Text
  
  ' Form3Text.Tag = sText 
  ' Form3Text.Show
  ' Form3Text.Visible = True 
  
  ''Software-Center  *.deb > Install > De-Install
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("snap-store")
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("gnome-software")
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("ubuntu-software")
  If sSoftwareCenter = "" Then 
    sSoftwareCenter = System.Find("gnome-control-center")
    If sSoftwareCenter <> "" Then sSoftwareCenter = sSoftwareCenter & Space(1) & "applications"
  Endif 
  
  ''Components:
  sMessage = ("Programm (Software), Komponenten (Components), Pakete (Packages)") & "<br>"
  sMessage &= M01Functions.CheckComponents() 'as String  'leer oder Text
  sMessage &= "<br>" '& "<br>"
  sMessage &= ("Software-Center, Eingabe, Suche") & ": " & "<font color=darkgreen><b>" & Application.Name & "</b></font>"
  
  sMessage = MessageSize(sMessage) 'as String. x11, wayland
  
  Select Case Message.Question(sMessage, ("Ordner..."), ("Software-Center") & "...", ("Abbrechen"))
    Case 1 'Directory
      sDir = FMain.F_sDirAppName 'Extra private User-Dir, Work-Dir
      If Exist(sDir) = True Then 
        M01Functions.FileManagerOpen(sDir)
      Else 
        M01Functions.FileManagerOpen(User.Home)  
      Endif 
    Case 2
      If sSoftwareCenter <> "" Then Shell sSoftwareCenter  ' "gnome-control-center applications" 
    Case 3
      '...
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Function InfoInstalledSoftware() As String
  
  Dim sTool, sText As String 
  
  sTool = "dpkg-query"
  sTool = System.Find(sTool) 'Debian Package-Manager (Paket-Verwaltung)
  If sTool <> "" Then Try Shell sTool & Space(1) & "--status" & Space(1) & Application.Name To sText 'all infos about Software Name
  
  ' If sText Then 
  '   PanelTextArea.Visible = True 
  '   PanelTextArea.Raise()
  '   TextArea2.SelectAll()
  '   TextArea2.Insert(sText)
  '   TextArea2.Pos = 1
  '   TextArea2.EnsureVisible()
  ' Endif 
  ' Print sText
  
  Return sText 
  
Catch
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'Beispielaufruf: 
  'ohne Value         ProgressBarONoff(TRUE)
  'oder direkt mit    ProgressBar1.Value = Zaehler / ColumnView1.Count
  'oder direkt mit    ProgressBar1.Value = 0.99 / ColumnView1.Count * it
  'ProgressBar1.Pulse = True  '◀▷'[......■■...]  False: [■■■□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'zurück zum Anfang
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 'Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeichensatzG()
  
  M06InfoText.CharsetABCInfo()
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuHomepageG()
  
  Dim sMessage, sHomepage, sUpdatePath, sInternet As String 
  Dim bInternetON As Boolean
  
  bInternetON = Desktop.NetworkAvailable '(gb.desktop)
  If bInternetON = True Then sInternet = "<font color=darkgreen>" & ("Eingeschaltet, verbunden") & "</font>" Else sInternet = "<font color=red>" & ("Ausgeschaltet, getrennt") & "</font>"
  
  sHomepage = "https://www.design-cad.de"
  sUpdatePath = "https://www.design-cad.de/cad-design/software/terminwecker3linux_entpacken_.deb"
  
  sMessage = "<font size=5 color=darkgreen>" & ("Hersteller") & "</font><br><br><br>"
  sMessage &= "<font size=5 color=darkgreen>" & ("Internet-Seite") & ": " & "<br><b>" & sHomepage & "</b></font><br><br><br>"
  
  sMessage &= "<font size=5 color=darkgray>" & ("Internet") & ": " & sInternet & "</font><br>"
  
  sMessage &= "<font size=5 color=blue>" & ("Paket") & ": " & "</font><br><font color=gray>" & "www.design-cad.de/cad-design/software/" & "</font>" 
  sMessage &= "<font color=blue><b>" & ("terminwecker3linux_entpacken_.deb") & "</b></font><br><br><br>"
  sMessage &= "● " & ("Öffnen im externen Browser...")
  
  'Message.Question(0, 1, 2, 3)
  Select Case Message.Question(sMessage, ("Internet-Seite..."), "● " & ("Paket speichern..."), ("Abbrechen"))
    Case 1
      M01Functions.ExternStart("firefox", sHomepage)
    Case 2
      M01Functions.ExternStart("firefox", sUpdatePath) '...terminwecker3linux_entpacken_.deb
    Case 3
      '...Leerlauf
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub SoftwareVersionNumberLoadG()
  
  Dim sHomepage, sHomepageShort, sDirFile, sFile, sInternet, sMessage As String
  Dim bInternetON As Boolean
  
  bInternetON = Desktop.NetworkAvailable '(gb.desktop)
  If bInternetON = True Then sInternet = "<font color=darkgreen>" & ("Eingeschaltet, verbunden") & "</font>" Else sInternet = "<font color=red>" & ("Ausgeschaltet, getrennt") & "</font>"
  
  sFile = "terminwecker3linux_info-version-nr.txt"
  sHomepage = "https://www.design-cad.de/cad-design/software/" & sFile
  sHomepageShort = "https://www.design-cad.de/.../" & sFile
  
  sMessage = "<h3>" & ("Internet-Verbindung") & ": " & "</h3>" 
  sMessage &= sHomepageShort & "<br>"
  sMessage &= "<font color=gray>" & ("(Einfache Textdatei mit Versions-Nummer)") & "</font>" & "<br><br>" 
  sMessage &= "<h2>"
  sMessage &= "○ " & ("Installierte Version") & ": " & "<font color=darkgreen><b>" & Application.Version & "</b></font><br><br>" 
  sMessage &= "● " & ("Neue Version") & ": " & "<font color=blue><b>" & ("Versions-Nummer abfragen?") & "</b></font>"
  sMessage &= "</h2>"
  sMessage &= "<font size=5 color=darkgray>" & ("Internet") & ": " & sInternet & "</font><br>"
  
  Select Case Message.Question(sMessage, "● " & ("Versions-Nummer abfragen"), ("Abbrechen"))
    Case 1 
      sDirFile = M01Functions.SoftwareDownloadInternetVersionNumberTXT()
      If Exist(sDirFile) = True Then 
        F_sProgramVersionNrInternet = File.Load(sDirFile)
        SoftwareCheckVersionNumberG()
      Else 
        sMessage = ("Kein Runterladen (Download) möglich?") & "<br>"
        sMessage &= ("Programm-Version. Datei nicht gefunden.") & "<br>"
        Message.Info(sMessage, ("Abbrechen")) 
      Endif 
    Case 2
      ''...
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub SoftwareCheckVersionNumberG()
  
  Dim sDir, sFile, sPackageFile, sDirDownload, sDirFileFind, sDirFile, sNumber, sBrowser, sInternet, sMessage As String
  Dim sPackageInfo As String
  Dim bInternetON As Boolean
  
  bInternetON = Desktop.NetworkAvailable '(gb.desktop)
  If bInternetON = True Then sInternet = "<font color=darkgreen>" & ("Eingeschaltet, verbunden") & "</font>" Else sInternet = "<font color=red>" & ("Ausgeschaltet, getrennt") & "</font>"
  
  ''Package:
  sPackageFile = "terminwecker3linux_entpacken_.deb" 'ca. 3MB
  sDirDownload = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  
  If IsDir(sDirDownload) = True Then 
    sDirFileFind = FindDirFile(sDirDownload, "*" & Replace(sPackageFile, "_", "*"), 1)
  Endif 
  If Exist(sDirFileFind) = False Then 
    sDirFileFind = FindDirFile(User.Home, "*" & Replace(sPackageFile, "_", "*"), 3)
  Endif 
  If Exist(sDirFileFind) = False Then 
    sPackageInfo = sPackageFile & Space(1) & "<font color=red>" & ("Nicht gefunden") & "</font>"
  Else 
    sPackageInfo = sDirFileFind & "<br>"
    sPackageInfo &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileFind) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileFind).Size) & "</b></font>" & "<br>"
  Endif 
  sBrowser = M01Functions.FindFileExtDefaultProgram("text/html")
  
  ''Check:
  If Not F_sProgramVersionNrInternet Then 
    sDirFile = M01Functions.SoftwareDownloadInternetVersionNumberTXT()
    If Exist(sDirFile) = True Then F_sProgramVersionNrInternet = File.Load(sDirFile)
  Endif 
  
  If F_sProgramVersionNrInternet Then 
    ' sNumber = FromUrl(F_sProgramVersionNrInternet) 'as String (Error-html?)
    If String.InStr(String.LCase(F_sProgramVersionNrInternet), "html") > 0 Then '(Error-html?)
      sNumber = Null
    Else 
      sNumber = F_sProgramVersionNrInternet
    Endif 
  Endif 
  
  If Not sNumber Then  
    sDir = Desktop.GetDirectory("DOWNLOAD")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
    sFile = "terminwecker3linux_info-version-nr.txt"
    If Exist(sDir) = True Then sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then sNumber = File.Load(sDirFile)
  Endif 
  
  If sNumber Then 
    'Fehler vermeiden. Inhalt evtl. bereinigen, begrenzen
    If String.InStr(String.LCase(sNumber), "html") > 0 Then sNumber = Null '(Error-html?)
    sNumber = Replace(sNumber, FMain.F_sReturnCrLF, "")
    sNumber = Replace(sNumber, FMain.F_sTab, "")
    sNumber = Replace(sNumber, gb.NewLine, "")
    sNumber = String.Left(sNumber, 100)
    If sNumber = Null Then sNumber = ("Info fehlt")
    MenuUpdateVersionFile.Text = ("Update Info") & Space(1) & ("Installierte Version") & ": " & Space(1) & Application.Version & Space(1) & ("Neue Version") & ": " & sNumber
  Endif
  If String.Len(sNumber) = 0 Then 
    sNumber = "<font color=darkgreen><b>" & ("Keine") & "</b></font>"
  Else 
    sNumber = "<font color=blue><b>" & sNumber & "</b></font>"
  Endif 
  
  sMessage = "<h1><font color=darkgreen>" & ("Update Info") & "</font></h1>"
  sMessage &= "<h2><font color=gray>" & ("Installierte Version") & ": " & "</font><font color=darkgreen>" & Application.Version & "</font></h2>" 
  sMessage &= "<h2><font color=gray>" & ("Neue Version") & ": " & "</font>" & sNumber & "</h2>"
  sMessage &= sDirFile & "<br>" 
  sMessage &= "<br>" 
  sMessage &= ("(1.Download, 2.Programm beeenden, 3.Download-Datei ausführen.)") & "<br>" 
  sMessage &= "<font color=blue><b>" & sPackageInfo & "</b></font><br>"
  
  sMessage &= "<h3>" & ("Programm-Paket runterladen (Download)") & ":" & "</h3>"
  sMessage &= "<h3>" & "○" & Space(1) & ("über Internet-Browser") & Space(1) & "(" & sBrowser & ")" & "</h3>" 
  sMessage &= "<h3>" & "●" & Space(1) & ("direkt") & "</h3>"
  sMessage &= "<font size=5 color=darkgray>" & ("Internet") & ": " & sInternet & "</font><br>"
  
  Select Case Message.Question(sMessage, "○" & Space(1) & ("Download über Internet-Browser"), "●" & Space(1) & ("Download direkt"), ("Abbrechen"))
    Case 1 'Download with Internet-Browser
      mnuHomepageG()
      
    Case 2 'Install with Software-Center:
      sDirFile = M01Functions.SoftwareDownloadInternetPackageDEB() 
      ' If Exist(sDirFile) = False Then Wait 1
      ' If Exist(sDirFile) = False Then Wait 1
      ' If Exist(sDirFile) = True Then Desktop.Open(sDirFile) 'Example: ... terminwecker3linux_entpacken_.deb" 
      If Exist(sDirFile) = True Then 
        sMessage = "<h3><font color=blue>" & M01Functions.FileLastModifiedTimeSize(sDirFile) & "</font></h3>"
        sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & "<br>"
        sMessage &= "<br>"
      Else 
        sMessage = "<h3><font color=red>" & ("Datei fehlt. Keine Internet-Verbindung?") & "</font></h3>"
      Endif 
      sMessage &= "● " & ("Ordner... ▷ markierte Datei ▷ rechte Maustaste") & ":" & "<br>"
      sMessage &= ("Mit Software-Installation öffnen...") & "<br>"
      
      Select Case Message.Question(sMessage, "● " & ("Mit Software-Installation öffnen..."), ("Ordner..."), ("Abbrechen"))
        Case 1 ''Software-Installation...
          If Exist(sDirFile) = True Then 
            Desktop.Open(sDirFile)
          Else 
            M01Functions.FileManagerOpen(Desktop.GetDirectory("DOWNLOAD")) 
          Endif
        Case 2 ''Ordner...
          If Exist(sDirFile) = True Then 
            M01Functions.FileManagerOpen(sDirFile)
          Else 
            M01Functions.FileManagerOpen(Desktop.GetDirectory("DOWNLOAD")) 
          Endif 
        Case 3 ''Abbrechen
          ''...
      End Select 
      
    Case 3 'Cancel
      '...
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonDayMinusG() 'Abwärts
  
  F_iDaysMinusOrPlus = F_iDaysMinusOrPlus - 1
  ReadG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonDayPlusG() 'Aufwärts
  
  F_iDaysMinusOrPlus = F_iDaysMinusOrPlus + 1
  ReadG()
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonHolidaysG()
  
  Form8ZusFeiertage.Window.Show
  ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonEditG()
  
  Form2Bearb.Window.Show
  ' Form2Bearb.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelMinimi_MouseDown()
  
  FormHide()
  FMain.Window.Minimized = True 'Me.Minimized = 
  FMain.Window.Sticky = False 'window is visible in all virtual desktops.
  If Desktop.Platform = "x11" Then FMain.Window.Stacking = Window.Normal 'Fenster unter, über, normal. integer 2=Below. This constants is used by the Stacking property for windows that must stay below other windows.
  FMain.Window.TopOnly = False
  FMain.CheckTrayIconSystemOnOff()
  TrayIconColorize(0) 'iStop0_Plus1_Alarm2
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelMinimi_Enter()
  
  LabelMinimi.Background = Color.SetAlpha(LabelTime.Foreground, 200)
  
End

Public Sub LabelMinimi_Leave()
  
  LabelMinimi.Background = Color.Default
  
End

Public Sub ColumnView1_Click()
  
  LineToForm3Text(1)
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView2_Click()
  
  LineToForm3Text(2)
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView3_Click()
  
  LineToForm3Text(3)
  
Catch
  FMain.ErrorText
  
End

' Public Sub ColumnView1_DblClick()
'   
'   ColumnView1_GotFocus()
'   
' Catch
'   FMain.ErrorText
'   
' End
' 
' Public Sub ColumnView2_DblClick()
'   'ColumnView2_GotFocus
'   
' End
' 
' Public Sub ColumnView3_DblClick()
'   'ColumnView3_GotFocus
'   
' End
Public Sub ColumnView123Resize()
  
  Dim it As Integer
  
  ''ColumnView1:
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Single
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ColumnView1.Sorted = True 
  ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ' ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[1].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[5].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Width = 0 '0000-00-00  '.AutoResize = False? 
  ColumnView1.Columns[1].Width = 60 '00:00
  For it = 2 To ColumnView1.Columns.Max
    ColumnView1.Columns[it].Width = 0
  Next 
  
  ColumnView1.Columns.Sort = 1'F_iColumnSort                                              '00:00 Clock
  ColumnView1.Columns.Ascending = True '▲up▲ (aufsteigend A-z)
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[2].Left 
  
  ''ColumnView2:
  ColumnView2.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView2.Header = True                                                               'Title, Row index=0
  ColumnView2.Mode = Select.Single
  ' ColumnView2.AutoResize = True                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ColumnView2.Sorted = True 
  ColumnView2.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView2.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ' ColumnView2.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView2.Columns[1].Alignment = Align.Center                                         '| abc |
  ColumnView2.Columns[5].Alignment = Align.Left                                           '|123  |
  
  ColumnView2.Columns[0].Width = 0 '0000-00-00
  ColumnView2.Columns[1].Width = 60 '00:00
  For it = 2 To ColumnView2.Columns.Max
    ColumnView2.Columns[it].Width = 0 '.AutoResize = False? 
  Next 
  
  ColumnView2.Columns.Sort = 1'F_iColumnSort
  ColumnView2.Columns.Ascending = True '▲up▲ (aufsteigend A-z)
  '.AutoResize width = longest filename
  ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[2].Left 
  
  ''ColumnView3:
  ColumnView3.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView3.Header = True                                                               'Title, Row index=0
  ColumnView3.Mode = Select.Single
  ' ColumnView3.AutoResize = True                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ColumnView3.Sorted = True 
  ColumnView3.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView3.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ' ColumnView3.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView3.Columns[1].Alignment = Align.Center                                         '| abc |
  ColumnView3.Columns[5].Alignment = Align.Left                                           '|123  |
  
  ColumnView3.Columns[0].Width = 0 '0000-00-00
  ColumnView3.Columns[1].Width = 60 '00:00
  For it = 2 To ColumnView3.Columns.Max
    ColumnView3.Columns[it].Width = 0 '.AutoResize = False? 
  Next 
  
  ColumnView3.Columns.Sort = 1'F_iColumnSort
  ColumnView3.Columns.Ascending = True '▲up▲ (aufsteigend A-z)
  '.AutoResize width = longest filename
  ColumnView3.Columns[5].Width = ColumnView3.ClientWidth - ColumnView3.Columns[2].Left 
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Function LineToForm3Text(Optional Fenster1_2_3 As Integer = 1)
  
  Dim it As Integer
  Dim sLine As String
  Dim ColumnViewX As ColumnView
  
  Select Case Fenster1_2_3
    Case 1
      ColumnViewX = ColumnView1
    Case 2
      ColumnViewX = ColumnView2
    Case 3
      ColumnViewX = ColumnView3
  End Select
  
  If ColumnViewX.Count > 0 Then 
    it = Val(ColumnViewX.Key)
    If ColumnViewX[it].Text <> "" Then
      sLine = ""
      sLine &= ColumnViewX[it][0] & FMain.F_sTab  '0=Datum
      sLine &= ColumnViewX[it][1] & FMain.F_sTab
      sLine &= ColumnViewX[it][2] & FMain.F_sTab
      sLine &= ColumnViewX[it][3] & FMain.F_sTab
      sLine &= ColumnViewX[it][4] & FMain.F_sTab
      sLine &= ColumnViewX[it][5] & FMain.F_sReturnCrLF
      'Clipboard.Clear() ' Zwischenablage löschen. 
      'Clipboard.Copy(sLine) 'Text in Zwischenablage kopieren. 
      'sValue = Clipboard.Paste("text/plain") 'Wieder heraus holen
    Endif
    
    Form3Text.Tag = sLine
    F_bZeilenumbruchON = True
    Form3Text.Window.Show
    ' Form3Text.Window.Visible = True  'Wayland error?
  Endif 
  
Catch
  
  FMain.ErrorText
  
End

Public Sub mnuBisEingabeG()
  
  Form4Bis.Window.Show
  ' Form4Bis.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuSpracheG()
  'System.Language = 
  
  Dim sFoundDE, sFoundEN, sGerman, sEnglish, sMessage As String
  Dim iFound As Integer
  
  If String.InStr(String.LCase(System.Language), "de") > 0 Then iFound = 1
  If String.InStr(String.LCase(System.Language), "en") > 0 Then iFound = 2
  
  If iFound = 1 Then sFoundDE = "●" Else sFoundDE = "○"
  If iFound = 2 Then sFoundEN = "●" Else sFoundEN = "○"
  
  sGerman = "Sprache Betriebssystem: Sprache Programm  (automatisch in Englisch oder Deutsch)"
  sEnglish = "Language Operating-System: Language program (automatically in English or German)"
  sMessage = ("Test in nachfolgenden Seiten:") & "<br>"
  sMessage &= "<h3>" & ("System Sprache") & ": " & "<font color=blue><b>" & System.Language & "</b></font></h3>" 
  sMessage &= sFoundDE & Space(1) & "<font color=darkgreen>" & sGerman & "</font><br><br>" 
  sMessage &= sFoundEN & Space(1) & "<font color=red>" & sEnglish & "</font>"
  
  ' Message.Info(sMessage)
  Select Case Message.Question(sMessage, sFoundDE & Space(1) & ("deutsch"), sFoundEN & Space(1) & ("english"), ("Abbrechen"))
    Case 1 'deutsch
      System.Language = "de_DE.utf8"
      Settings[FMain.Name &/ "System.Language"] = System.Language
      
    Case 2 'english 
      System.Language = "en_GB.utf8" 
      Settings[FMain.Name &/ "System.Language"] = System.Language
      
    Case 3 'Cancel
      ''...
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTerminMeldungG()
  
  TermineaktuellTextArea2()
  Form3Text.Tag = TextArea2.Text & FMain.F_sReturnCrLF & FMain.F_sReturnCrLF '& F_sTermineActual
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelPathG()
  
  Dim sMessage, sDirFile As String 
  
  sDirFile = FMain.F_sPathTerminweckerActual_txt
  sMessage = "<h3><font color=darkgreen>" & sDirFile & "</font></h3>"
  If Exist(sDirFile) = True Then 
    sMessage &= ("Verändert") & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & "<br>" 
    sMessage &= M01Functions.FileSizeText(sDirFile) & "<br><br>"
  Else 
    sMessage &= "<h1><font color=red><b>" & ("Fehlt") & "!" & "</b></font></h1>" 
  Endif 
  sMessage &= "<h3><font color=darkgreen>" & "● " & ("Datei-Pfad sichtbar machen?") & "</font></h3>"
  
  Select Case Message.Question(sMessage, "● " & ("Sichtbar"), "○ " & ("Unsichtbar"), ("Abbrechen"))
    Case 1 'Ja
      F_bFilePathHideONoff = True
      Settings[FMain.Name &/ "F_bFilePathHideONoff"] = F_bFilePathHideONoff
    Case 2 'Nein
      F_bFilePathHideONoff = False
      Settings[FMain.Name &/ "F_bFilePathHideONoff"] = F_bFilePathHideONoff 
    Case 3 'Abbrechen
      'Leerlauf
  End Select
  FilePathHideONoff() 'Label5 aktualisieren
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuEinstellungenG()
  
  Form6Einst.Window.Show
  ' Form6Einst.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonCancelG() 'G = Gear (Gang) Example-Name, find: "*G()"
  
  PanelTextArea.Visible = False
  M01Functions.MusicStartStop("", False)
  ' Music.Stop()
  FMain.Window.TopOnly = False
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelTimeG()
  'sValue umschalten
  
  PanelTextArea.Visible = Not PanelTextArea.Visible
  If PanelTextArea.Visible = True Then TermineaktuellTextArea2()
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuHTMLSeiteG()
  'DIM Text AS Variant
  'Text = File.Load(FMain.F_sPathTerminweckerActual_txt)
  'F_sHTMLTEXT = Text
  
  Form7HTML.Window.Show
  ' Form7HTML.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuErgaenzungFeiertage_Click()
  
  Dim sValue As String
  
  sValue = Settings[FMain.Name &/ "OsterSonntag", ""]
  If sValue = "" Then M03Feiertage.HolidaysCalculate()
  Form8ZusFeiertage.Window.Show
  ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDesktopSymbolG()
  ' M01Functions.Symbol_Desktop
  
  M01Functions.LinkDesktopCreate()
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub ButtonYearG(Optional sLMR As String = "L")
  'mnuHTMLSeiteG
  
  Dim sDirFile, sMessage As String
  
  sDirFile = FMain.F_sPathTerminweckerActual_txt & ".html"
  If Exist(sDirFile) = False Then
    sMessage = sDirFile & "<br><br>"
    sMessage &= ("Datei mit Kalenderjahr (noch) nicht gefunden.")
    Select Case Message.Question(sMessage, ("Ordner..."), ("Vorschau-Fenster öffnen..."), ("Abbrechen"))
      Case 1
        Desktop.Open(FMain.F_sDirAppName)
      Case 2
        mnuHTMLSeiteG()
      Case 3 'Abbrechen
        'Leerlauf
    End Select
  Else
    If sLMR = "L" Then 
      F_iSecondCounter = 0
      F_bCalendarHTMLautomaticRefreshON = True
      BrowserG()
    Else If Mouse.Right Then 
      Desktop.Open(sDirFile) ' öffnet Datei.xyz mit bevorzugtem Programm wie Browser, Text- und Bildprogrammen
    Endif 
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuProjekteG()
  
  Form5Projekte.Window.Show
  ' Form5Projekte.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub TerminMeldungenEinAus()
  
  F_bClockMessageON = Settings[FMain.Name &/ "F_bClockMessageON", True]
  If F_bClockMessageON = True Then
    mnuTerminMeldungenOFF.Checked = True
    mnuTerminMeldungenON.Checked = False
    PicBoxSchloss.Visible = False
    F_bTerminMeldungenAusImmer = False 'zurücksetzen
  Else
    mnuTerminMeldungenOFF.Checked = False
    mnuTerminMeldungenON.Checked = True
    PicBoxSchloss.Visible = True
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTerminMeldungenOFFG()
  
  Dim sMessage, sT1, sT2 As String
  
  sMessage = "<h3>" & ("Ohne Termin-Meldungen") & "</h3>" 
  sT1 = "○" & Space(1) & ("Ja") & " = " & ("immer") & "<br><br>" 
  sT2 = "●" & Space(1) & ("Nein") & " = " & ("nur im laufenden Programm")
  sT1 = "<font color=blue><b>" & sT1 & "</b></font>"
  sT2 = "<font color=darkgreen><b>" & sT2 & "</b></font>"
  sMessage = sMessage & sT1 & sT2
  
  Select Case Message.Question(sMessage, "○" & Space(1) & ("Immer"), "●" & Space(1) & ("Nein"), ("Abbrechen"))
    Case 1 'im laufenden Programm
      F_bTerminMeldungenAusImmer = True ' Current, Today
    Case 2 'immer
      F_bTerminMeldungenAusImmer = False 'Current & Future
    Case 3   'Abbrechen
      Goto hEnde
  End Select
  
  Settings[FMain.Name &/ "F_bClockMessageON"] = False 'keine Meldungen
  TerminMeldungenEinAus()
  
hEnde:
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTerminMeldungenONG()
  
  Settings[FMain.Name &/ "F_bClockMessageON"] = True 'mit Meldungen
  TerminMeldungenEinAus()
  
Catch
  FMain.ErrorText
  
End

'Jahresschieber JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
Public Sub SliderYearDay()
  
  Dim iDays, iDiff, iPosition As Integer
  Dim dateBegin, dateEnd, dateNew As Date
  
  If Not F_dateNow Then F_dateNow = FMain.DateTimeActual() 'as Date  
  dateBegin = Date(Year(F_dateNow), 1, 1) 'as Date
  dateEnd = Date(Year(F_dateNow), 12, 31)
  iDiff = DateDiff(dateBegin, dateEnd, gb.day) 'as Integer
  iDays = (F_iMoveLineMaxH - F_iMoveLineMinH) / iDiff
  If iDays = 0 Then iDays = 1 '0=Error, no Division by zero
  iPosition = Int((MoveLine.Top - F_iMoveLineMinH) / iDays)
  MoveLine.ToolTip = iPosition & Space(1) & ("von") & Space(1) & iDiff
  dateNew = DateAdd(dateBegin, gb.day, iPosition) 'as Date
  
  F_iDaysMinusOrPlus = DateDiff(F_dateNow, dateNew, gb.day) 'as Integer
  LabelMinimi.Text = Format(dateNew, "ddd dd.mm.yyyy") 'as String
  If F_bMovingON = False Then ReadG()
Catch
  
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseDown()
  
  F_bMovingON = True
  F_iY1 = FMain.ScreenY - (FMain.ClientH - FMain.Height) + Mouse.Y
  MoveLine.Raise
  SliderYearDayONoff(True)
  
Catch
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseMove()
  
  If F_bMovingON = True Then
    MoveLine.Top = Mouse.ScreenY - F_iY1
    
    'Obergrenze
    If MoveLine.Top < F_iMoveLineMinH Then
      MoveLine.Top = F_iMoveLineMinH
      F_bMovingON = False
      Stop Event
    Endif
    
    'Untergrenze
    If MoveLine.Top > F_iMoveLineMaxH Then
      MoveLine.Top = F_iMoveLineMaxH
      F_bMovingON = False
      Stop Event
    Endif
    SliderYearDay()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseUp()
  
  F_bMovingON = False
  SliderYearDay()
  LabelMinimi.Text = LabelMinimi.Tag
  HorizontalUhrCheck()
  
End

Public Sub SliderYearDayONoff(Optional bONoff As Boolean = True)
  
  If bONoff = True Then
    'mehr Fläche
    'LabelSchieber.Width = PictureBox1.Width - ColumnView1.Left + ColumnView1.Width
    MoveLine.Left = LabelSchiebbereich.Left + 2
    MoveLine.Width = LabelSchiebbereich.Width - 4
    LabelSchiebbereich.Visible = True
    LabelMinimi.Foreground = LabelTime.Foreground
  Else
    LabelSchiebbereich.Visible = False
    MoveLine.Top = F_iMoveLineMinH
    LabelMinimi.Foreground = Color.White
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuSchieberJahrestagG()
  
  If LabelSchiebbereich.Visible = True Then
    SliderYearDayONoff(False)
  Else
    SliderYearDayONoff(True)
  Endif
  
Catch
  FMain.ErrorText
  
End
'Jahresschieber JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ

Public Sub mnuBearbeiten_Show()
  
  Dim sValue As String
  
  If LabelSchiebbereich.Visible = True Then
    mnuSchieberJahrestag.Checked = True
  Else
    mnuSchieberJahrestag.Checked = False
  Endif
  
  mnuHorizontaluhr.Checked = F_bClockHorizontalON
  
  mnuTerminweckerDateioeffnen.Text = ("Öffnen...") & Space(3) & FMain.F_sPathTerminweckerActual_txt
  If FMain.F_sProjectOnlyName <> "" Then
    mnuProjektAktuellOeffnen.Text = ("Öffnen... projekt_") & FMain.F_sProjectOnlyName & ".txt"
  Else
    mnuProjektAktuellOeffnen.Text = ("Öffnen... projekt_''ohne Projekt''.txt")
  Endif
  TerminMeldungenEinAus()
  
  ' mnuSymbolAutostart.Checked = Settings[FMain.Name &/ "Autostart", False]
  ' If Exist(FMain.F_sPathAutoStartDatei_desktop) = False Then mnuSymbolAutostart.Checked = False
  mnuSymbolAutostart.Checked = Exist(FMain.F_sPathAutoStartDatei_desktop)  'True or False, prüfen
  
  sValue = M01Functions.LinkDesktopExist()
  If sValue <> "" Then
    mnuSymbolerstellen.Checked = True
  Else
    mnuSymbolerstellen.Checked = False
  Endif 
  
  ''Reset:
  mnuSchongang.Checked = False 
  mnuStoppUhr.Checked = False 
  mnuZaehler.Checked = False 
  mnuUhrDigital.Checked = False
  mnuUhrDigitalHell.Checked = False
  MenuMyClockDesign.Checked = False 
  
  ''Select:
  Select Case F_iClockMap0Stop1Count2Digital3Design4
    Case 0
      mnuSchongang.Checked = True 
    Case 1
      mnuStoppUhr.Checked = True 
    Case 2
      mnuZaehler.Checked = True  
    Case 3
      If InStr(F_sTagsClockDigital, "red") > 0 Then 
        mnuUhrDigital.Checked = True
      Else 
        mnuUhrDigitalHell.Checked = True  
      Endif 
    Case 4
      MenuMyClockDesign.Checked = True 
  End Select 
  
  sValue = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", FMain.F_sPathMusicStandard_mp3]
  If Exist(sValue) = True And sValue <> FMain.F_sPathMusicStandard_mp3 Then 
    mnuWeckerton.Text = ("Uhr-Alarm  Musik...") & Space(2) & File.Name(sValue)
  Else
    mnuWeckerton.Text = ("Uhr-Alarm  Musik...") & Space(2) & ("Standard")
  Endif
  If F_bClockAlarmMusicON = True Then 
    MenuNote.Picture = PicTemplateNoteGreen.Picture
  Else 
    MenuNote.Picture = PicTemplateNoteRed.Picture
  Endif 
  MenuNote.Checked = F_bClockAlarmMusicON
  MenuPlusAlarm.Checked = F_bClockAlarmBeforeBehindON
  MenuPlusAlarm.Text = ("Plus-Alarm -vorher/+nachher") & Space(1) & F_iVorNachweckzeit60 & " / " & F_iVorNachweckzeit30 
  If F_bClockAlarmBeforeBehindON = True Then 
    MenuPlusAlarm.Picture = PicTemplateLEDgreen.Picture
    ' MenuPlusAlarm.Text = MenuPlusAlarm.Text & " ● " & ("EIN/aus")
  Else 
    MenuPlusAlarm.Picture = PicTemplateLEDgreen.Picture.Image.Desaturate().Picture
    ' MenuPlusAlarm.Text = MenuPlusAlarm.Text & " ○ " & ("ein/AUS")
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTimerplusG()
  
  Form12Timerplus.Window.Show
  ' Form12Timerplus.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub TimerRefreshAll_Timer()
  
  If F_bNeueinlesenStarten = True Then 
    F_bNeueinlesenStarten = False
    ' TimerRefreshAll.Stop
    ' Print "TimerRefreshAll_Timer", Time
    RefreshAll()
    ProgressBarONoff(False)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Timer2Calendar_Timer() 'unused
  'Timer2.Delay=1000 '=1Sek. Sekundentakt
  
  ProgressBarONoff(True)
  F_iSecondCounter = F_iSecondCounter + 1
  If F_iSecondCounter < 7 Then ' time limit (Wartezeit begrenzen).
    PicBoxKalender.Visible = True
    If F_iSecondCounter > 2 Then 
      F_iSecondCounter = 7 'deactive, only 1x
      ''New:
      F_sWebFileNew = M04Kalender.CalendarReadCreateHTML(FMain.F_sPathTerminweckerActual_txt) 'New
      ''Check:
      If Exist(F_sWebFileNew) = True Then 
        PicBoxKalender.Tooltip = ("Jahreskalender") & Space(1) & "(*.html)" & Space(1) & ("erneuert") & Space(3) & Format(Stat(F_sWebFileNew).LastChange, "yyyy-mm-dd ddd hh:nn:ss")
      Else 
        PicBoxKalender.Tooltip = ("Jahreskalender") & Space(1) & "(*.html)" & Space(1) & ("Fehlt") 
      Endif 
      PicBoxKalender.Raise()
      F_iSecondCounter = 0
      Timer2Calendar.Enabled = False
    Endif
  Else 
    Timer2Calendar.Enabled = False
    F_iSecondCounter = 0
  Endif  
  
  If F_iSecondCounter = 0 Or Timer2Calendar.Enabled = False Then 
    ProgressBarONoff(False)
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Timer3CounterClock_Timer()
  'Timer.Delay=1000 '=1Sek. Sekundentakt
  
  ' If mnuZaehler.Checked = True Or mnuStoppUhr.Checked = True Then 'Tastenzähler
  If F_iClockMap0Stop1Count2Digital3Design4 = 1 Or F_iClockMap0Stop1Count2Digital3Design4 = 2 Then
    If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
      If FMain.HasFocus = False Then FMain.SetFocus 'Fokus auf Form behalten, sonst reagiern Tasten nicht zugeordnet
    Endif 
    LabelProjectTime.Visible = False
    LabelPressCounter.Visible = True
    ' If mnuStoppUhr.Checked = True Then
    If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then  
      PicBoxClock.Visible = True
      If F_bStopwatchON = True Then
        F_iCounterStopwatch = F_iCounterStopwatch + 1
        DrawStopWatchTime()
        LabelPressCounter.Text = ("Stoppuhr = ") & M01Functions.SecondsInfoText(F_iCounterStopwatch) & Space(7) & ("Weiter")
        StoppuhrSekundenZaehlerspeichern() 'jede Sekunde sichern
      Else
        LabelPressCounter.Text = ("Stoppuhr = ") & M01Functions.SecondsInfoText(F_iCounterStopwatch) & Space(7) & ("Pause")
      Endif
    Endif
    ' If mnuZaehler.Checked = True Then PicBoxClock.Visible = False
    If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then PicBoxClock.Visible = False
    FMain.Window.Title = LabelPressCounter.Text
  Else 
    Timer3CounterClock.Stop
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub TimerIconError_Timer() ''>> Catch FMain.ErrorText
  
  'Delay = 30000 = 3 sec.?
  
  PicBoxKalender.Visible = False
  IconError.Visible = False
  Form2Bearb.IconError.Visible = False 
  Form0NurUhr.IconError.Visible = False 
  TimerIconError.Stop()
  
Catch 
  FMain.ErrorText
  
End

Public Sub BrowserG()
  
  Dim sPath, sProgram, sMessage As String
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  
  If Exist(sPath) = True Then
    ButtonBrowser.Background = Color.Green
    If String.LCase(File.Ext(sPath)) <> "html" Then sPath = sPath & ".html"
    If Exist(sPath) = False Then sPath = FMain.F_sPathTerminweckerActual_txt & ".html"
    sPath = "file://" & sPath & "#heute" 
    sProgram = Settings[FMain.Name &/ "F_sBrowserHTMLonlyName", "firefox"]
    If System.Exist(sProgram) = True Then 
      M01Functions.ExternStart(sProgram, sPath)
    Else 
      Desktop.Open(sPath)  
    Endif 
    ButtonBrowser.Background = Color.Default
  Else
    sMessage = sPath & "<br>"
    sMessage &= "<font color=red><b>" & ("Fehlt (noch)?") & "</b></font>"
    M01Functions.MessageQuestionON(sMessage, sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DrawStopWatchTime()
  
  Dim Img As Image
  Dim imgTemp As Image
  Dim sPath As String 
  
  If Not F_imgStopWatchBG Then 
    sPath = FMain.F_sDirClock &/ "stopwatch_128.png" 'user
    If Exist(sPath) = True Then F_imgStopWatchBG = Image.Load(sPath)
    If Not F_imgStopWatchBG Then F_imgStopWatchBG = Image.Load("images/stopwatch_128.png") 'program
    If Not F_imgStopWatchBG Then F_imgStopWatchBG = New Image(FMain.F_iIconSize, FMain.F_iIconSize, Color.Transparent) 'nothing
  Endif 
  If F_imgStopWatchBG Then Img = F_imgStopWatchBG.Copy()
  
  If Img Then  
    Paint.Begin(Img)
    imgTemp = M07Paint.ClockPhythagoras(DateAdd(Date, gb.Second, CInt(F_iCounterStopwatch))) 'as Image
    If imgTemp Then Paint.DrawImage(imgTemp, Img.W / 2 - imgTemp.Width / 2, Img.H / 2 - imgTemp.Height / 2) 'center, middle —▶○◀— )
    Paint.End
    PicBoxClock.Picture = Img.Picture 'without .Copy() not accurate
    F_picClock = Img.Picture  'Note: Image internally is faster than Picture   convert Image to Picture
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ClockOnly()
  
  LabelMinimi_MouseDown() '_Minimieren_
  
  Form0NurUhr.Window.Show
  Form0NurUhr.Window.Minimized = False
  Form0NurUhr.Window.Raise
  Form0NurUhr.TopOnly = True 
  Form0NurUhr.TopOnly = False 
  ' Try Form0NurUhr.Raise()
  ' Try Form0NurUhr.Window.TopOnly = True 
  ' Try Form0NurUhr.Window.Stacking = Window.Above '▲
  ' Print "ClockOnly()"
  ' TrayIcon1.Visible = False 
  If TrayIcon1.Visible = False And F_iTrayIconSystemON1 = 1 Then 
    TrayIcon1.Visible = False 
    TrayIconFile("read")
    CheckTrayIconSystemOnOff()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxClock_MouseDown()
  
  If Mouse.Left = True Then
    ClockOnly()
  Else
    Form14UhrDesign.Window.Show
    Form14UhrDesign.Window.Minimized = False
    ' Form14UhrDesign.Window.Visible = True  'Wayland error?
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxClock_Enter()
  
  PicBoxClock.Background = F_iSelectGreenAlpha150
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxClock_Leave()
  
  PicBoxClock.Background = Color.Default
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuHorizontaluhrG()
  
  mnuHorizontaluhr.Checked = Not mnuHorizontaluhr.Checked
  F_bClockHorizontalON = mnuHorizontaluhr.Checked
  Settings[FMain.Name &/ "F_bClockHorizontalON"] = F_bClockHorizontalON
  HorizontalUhrCheck()
  
Catch
  FMain.ErrorText  
  
End

Public Sub mnuProjektTimerweckerOeffnenG()
  
  Dim sPath As String
  
  sPath = F_sDirProject &/ ("project_") & Application.Name & ".txt"
  FileTextToForm3Text(sPath)
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuProjektAktuellOeffnenG()
  
  Dim sPath As String
  
  sPath = F_sDirProject &/ ("project_") & String.LCase(F_sProjectOnlyName) & ".txt"
  FileTextToForm3Text(sPath)
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTerminweckerDateioeffnenG()
  
  Dim sPath As String
  
  sPath = FMain.F_sPathTerminweckerActual_txt 'F_sDirAppName &/ Application.Name & ".txt"
  FileTextToForm3Text(sPath)
  
Catch
  FMain.ErrorText
  
End

Public Sub FileTextToForm3Text(Optional sDirFile As String = "")
  
  Form3Text.Tag = sDirFile
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuOeffnenAndereG()
  
  Form1FileOpen.Tag = FMain.F_sDirAppName
  If String.Right(Form1FileOpen.Tag, 1) <> "/" Then Form1FileOpen.Tag = FMain.F_sDirAppName & "/" 'bei Ordnern mit Schrägstrich am Ende
  
  Form1FileOpen.Window.Show
  ' Form1FileOpen.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Function Tastenzaehlerstand(Optional Standnachfragen As Boolean = False) As Boolean
  
  Dim bCancel As Boolean
  Dim sPath, sMessage As String
  
  sPath = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "-counter123-with-keypress.txt"
  'sPath = M01Functions.ProgramDirCache(sPath) '/Ordner/~Datei.txt
  If Exist(sPath) = True Then 
    F_iCounterWithKeyPress = Val(File.Load(sPath))  'Str() <> Val()
  Endif
  
  If Standnachfragen = True And F_iCounterWithKeyPress > 0 Then 
    sMessage = sPath & "<br><br><br>"
    sMessage &= "●" & Space(1) & ("Weiter zählen ab") & Space(1) & "<font color=darkgreen><b>" & Str(F_iCounterWithKeyPress) & "</b></font>" & "<br><br>"
    sMessage &= "○" & Space(1) & ("Neu starten ab") & Space(1) & "<font color=blue><b>" & "0" & "</b></font>"
    Select Case Message.Question(sMessage, "●" & Space(1) & ("Weiter") & Space(1) & Str(F_iCounterWithKeyPress), "○" & Space(1) & ("Neu") & Space(1) & "0", ("Abbrechen"))
      Case 1
        'Leerlauf
      Case 2
        F_iCounterWithKeyPress = 0
        Tastenzaehlerspeichern()
      Case 3 'Abbrechen
        'Leerlauf
        bCancel = True 
        F_iClockMap0Stop1Count2Digital3Design4 = 0 'Reset
        Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4"] = F_iClockMap0Stop1Count2Digital3Design4  'siehe Timer
        ClockSwitchCheck()
    End Select
  Endif 'Standnachfragen
  
  Return bCancel
  
Catch
  FMain.ErrorText
  
End

Public Sub Tastenzaehlerspeichern()
  
  Dim sDirFile As String
  
  sDirFile = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "-counter123-with-keypress.txt"
  'sPath = M01Functions.ProgramDirCache(sPath) '/Ordner/~Datei.txt
  File.Save(sDirFile, Str(F_iCounterWithKeyPress))  'Str() <> Val()
  If Exist(sDirFile) = False Then MessageMissingInfo(sDirFile, ("Die Zählung kann nicht gespeichert werden"))
  
Catch
  FMain.ErrorText
  
End

Public Sub MessageMissingInfo(Optional sDirFile As String, Optional sText As String)
  
  Dim sMessage As String 
  
  If Exist(sDirFile) = False Then 
    sMessage = sDirFile & "<br><br>" 
    sMessage &= "<font size=4 color=red><b>" & sText & "</b></font><br>"
    
    ' Message.Info(sMessage, ("Abbrechen"))
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory
        If Exist(sDirFile) = True Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          M01Functions.FileManagerOpen(File.Dir(sDirFile))  
        Endif 
      Case 2
        '...
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function StoppuhrSekundenZaehlerstand(Optional Standnachfragen As Boolean = False) As Boolean
  
  Dim bCancel As Boolean 
  Dim sPath As String
  Dim sStand1, sStand2, sMessage As String  
  
  sPath = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "-counter123-stopwatch-seconds.txt"
  'sPath = M01Functions.ProgramDirCache(sPath) '/Ordner/~Datei.txt
  If Exist(sPath) = True Then 
    F_iCounterStopwatch = Val(File.Load(sPath))  'Str() <> Val()
  Endif
  sStand1 = M01Functions.SecondsInfoText(F_iCounterStopwatch) '00:00:32
  sStand2 = M01Functions.SecondsInfoText(0) '00:00:00
  If Standnachfragen = True And F_iCounterStopwatch > 0 Then 
    sMessage = sPath & "<br><br>"
    sMessage &= "●" & Space(1) & ("Weiter zählen ab") & Space(1) & "<font color=darkgreen><b>" & sStand1 & "</b></font><br><br>" 
    sMessage &= "○" & Space(1) & ("Neu starten ab") & Space(1) & "<font color=blue><b>" & sStand2 & "</b></font>"
    
    Select Case Message.Question(sMessage, "●" & Space(1) & ("Weiter") & Space(1) & sStand1, "○" & Space(1) & ("Neu") & Space(1) & sStand2, ("Abbrechen"))
      Case 1
        'Leerlauf
      Case 2
        F_iCounterStopwatch = 0
        'M01Functions.FileTextPlus(sPath, Str(F_iCounterWithKeyPress), True)
        StoppuhrSekundenZaehlerspeichern()
      Case 3 'Abbrechen
        'Leerlauf
        bCancel = True 
        F_iClockMap0Stop1Count2Digital3Design4 = 0 'Reset
        Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4"] = F_iClockMap0Stop1Count2Digital3Design4  'siehe Timer
        ClockSwitchCheck()
    End Select
  Endif 'Standnachfragen
  
  Return bCancel
  
Catch
  FMain.ErrorText
  
End

Public Sub StoppuhrSekundenZaehlerspeichern()
  
  Dim sDirFile As String
  
  sDirFile = FMain.F_sDirTerminweckerCurrent &/ Application.Name & "-counter123-stopwatch-seconds.txt"
  File.Save(sDirFile, Str(F_iCounterStopwatch))  'Str() <> Val()
  If Exist(sDirFile) = False Then MessageMissingInfo(sDirFile, ("Die Zählung kann nicht gespeichert werden"))
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuZaehlerG()
  
  If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then 
    If Tastenzaehlerstand(True) = False Then 'Cancel=True, Stand nachfragen oder ab 0 weiter zählen
      PicBoxZaehler.Picture = mnuZaehler.Picture
      PicBoxZaehler.Visible = True
      PicBoxZaehler.Raise
      LabelPressCounter.Text = ("Zähler = ") & F_iCounterWithKeyPress & Space(5) & ("[Leertaste]")
      Timer3CounterClock.Start
      LabelPressCounter.Visible = True
    Endif 
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuStoppUhrG()
  
  If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
    If StoppuhrSekundenZaehlerstand(True) = False Then 'Cancel=True, Stand nachfragen oder ab 0 weiter zählen
      F_bStopwatchON = True 'Stopp/Weiter  über Leertaste
      PicBoxZaehler.Picture = mnuStoppUhr.Picture
      PicBoxZaehler.Visible = True
      PicBoxZaehler.Raise
      Timer3CounterClock.Start
      LabelProjectTime.Visible = False
      LabelPressCounter.Visible = True
    Endif 
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  Dim sPress As String 
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  
  ' If mnuZaehler.Checked = True Then
  If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then 
    If Key.Code = Key.Space Then F_iCounterWithKeyPress = F_iCounterWithKeyPress + 1
    If Key.Code = Asc("+") Then 
      sPress = "[+]"
      F_iCounterWithKeyPress = F_iCounterWithKeyPress + 1
    Endif 
    If Key.Code = Asc("-") Then 
      sPress = "[-]"
      F_iCounterWithKeyPress = F_iCounterWithKeyPress - 1
    Endif 
    LabelPressCounter.Text = ("Zähler = ") & Str(F_iCounterWithKeyPress) & Space(5) & sPress
    Tastenzaehlerspeichern()
    ' Else If mnuStoppUhr.Checked = True Then
  Else If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
    If Key.Code = Key.Space Then
      F_bStopwatchON = Not F_bStopwatchON
    Endif
    If Key.Code = Asc("+") Then
      sPress = "[+]"
      F_iCounterStopwatch = F_iCounterStopwatch + 1
    Endif 
    If Key.Code = Asc("-") Then 
      sPress = "[-]"
      F_iCounterStopwatch = F_iCounterStopwatch - 1
    Endif 
    LabelPressCounter.Text = LabelPressCounter.Text & sPress
    StoppuhrSekundenZaehlerspeichern()
  Endif
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch
  If Error Then Error.Clear()
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  Dim sInfo As String 
  
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then 
    PanelTextArea.Visible = False
    PanelTextArea.Raise()
    If F_iClockMap0Stop1Count2Digital3Design4 = 1 Or F_iClockMap0Stop1Count2Digital3Design4 = 2 Then sInfo = LabelPressCounter.Tooltip & gb.NewLine & gb.NewLine
    TextArea2.SelectAll()
    TextArea2.Insert(sInfo & ("Abbruch mit [ESC]")) 'Cancel with [ESC]
    F_bStopForWindowPhoto = False 
    LabelMinimi.Text = LabelMinimi.Tag ' Wiederherstellung
    IconError.Visible = False
    M01Functions.MusicStartStop("", False)
    Me.Maximized = False
    Me.FullScreen = False
    ' If Error.Text Then Message.Info(Error.Text & gb.NewLine & ("Abbruch mit Esc"))
  Else 
    PanelTextArea.Visible = False  
    PanelProgramClose.Visible = False 
  Endif 
  IconError.Visible = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If FMain.Window.Maximized = False Then
    FMain.Window.Maximized = True
  Else
    FMain.Window.Maximized = False
    FMain.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxZaehler_MouseDown()
  
  ''Close Functions:
  If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then
    F_iClockMap0Stop1Count2Digital3Design4 = 4
    ClockSwitchCheck()
  Endif 
  
  If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
    F_iClockMap0Stop1Count2Digital3Design4 = 4
    ClockSwitchCheck()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuStandardDateiG()
  
  mnuDateiOpenG() 'File open
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckStandardFile()
  
  Dim sDirFile1, sDirFile2 As String
  
  sDirFile1 = FMain.F_sPathTerminweckerStandard_txt
  sDirFile2 = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", sDirFile1]
  
  If Exist(sDirFile2) = True Then 
    If sDirFile1 = sDirFile2 Then 
      mnuStandardDatei.Text = ("Standard-Datei")
      mnuStandardDatei.Picture = Picture["images/apply_32.png"] 'Standard
    Else  
      mnuStandardDatei.Text = ("Alternative-Datei")
      mnuStandardDatei.Picture = Picture["images/checkon_32.png"] 'Alternative
    Endif 
  Endif
  If Exist(sDirFile2) = False Then
    mnuStandardDatei.Text = ("Datei fehlt. Öffnen...")
    mnuStandardDatei.Picture = Picture["images/checkoff_32.png"] 'file not found
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDatensicherungG()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup") 'Backup-Program
  If bExist = True Then
    Shell "deja-dup" 'start Program
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorbG()
  
  Dim bExist As Boolean
  Dim sText As String 
  
  sText = ("Fehlt")
  
  bExist = M01Functions.ExternTrash()
  If bExist = False And String.InStr(mnuPapierkorb.Text, sText) = 0 Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & sText
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTaschenrechnerG()
  
  Dim bExist As Boolean
  Dim sText As String 
  
  sText = ("Fehlt")
  
  bExist = M01Functions.ExternCalculator()
  If bExist = False And String.InStr(mnuTaschenrechner.Text, sText) = 0 Then mnuTaschenrechner.Text = mnuTaschenrechner.Text & Space(2) & sText
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuProjektAktuellOeffnenTabelleG()
  
  Dim sDirFile, sDirFileCSV As String
  
  sDirFile = F_sDirProject &/ ("project_") & F_sProjectOnlyName & ".txt"
  
  If Exist(sDirFile) = True Then 
    sDirFile = M01Functions.ProjectSumCSV(sDirFile)
    
    sDirFileCSV = M01Functions.ProgramDirCache(File.Name(sDirFile))
    Try Copy sDirFile To sDirFileCSV 'Temp
    
    M01Functions.ExternStart("libreoffice", sDirFileCSV) 
  Else 
    Message.Info(sDirFile & gb.NewLine & ("Nicht gefunden"))
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuExportG() 'ö=oe, ...
  
  Form13Export.Window.Show
  Form13Export.Visible = True
  
Catch
  FMain.ErrorText
  
End

Public Sub ClockSwitchCheck()
  
  If F_iClockMap0Stop1Count2Digital3Design4 < 1 Or F_iClockMap0Stop1Count2Digital3Design4 > 2 Then F_iClockSwitchBefore = F_iClockMap0Stop1Count2Digital3Design4
  
  Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4"] = F_iClockMap0Stop1Count2Digital3Design4  'siehe Timer
  
  ClockSwitchReset()
  
  Select Case F_iClockMap0Stop1Count2Digital3Design4
      
    Case 0 ''OnlyMap:
      mnuSchongangG()
      
    Case 1 ''Stopwatch:
      mnuStoppUhrG()
      
    Case 2 ''PressCounter:
      mnuZaehlerG()
      FMain.Window.TopOnly = True 'über allen anderen Fenstern (Windows, Frames)
      If Desktop.Platform = "x11" Then FMain.Window.Stacking = Window.Above 'as Integer, Windows in Desktop, Window.Normal = 0, Window.Above = 1,  Window.Below = 2
      
    Case 3 ''ClockDigital:
      mnuUhrDigitalG()
      
    Case 4 ''ClockDesign:
      DrawTime()
      
  End Select  
  
Catch
  FMain.ErrorText
  
End

Public Sub ClockSwitchReset()
  
  Timer3CounterClock.Stop
  F_bStopwatchON = False 'Stopp
  LabelPressCounter.Visible = False
  PicBoxZaehler.Visible = False
  LabelProjectTime.Visible = True
  FMain.Window.TopOnly = False 'über allen anderen Fenstern (Windows, Frames)
  If Desktop.Platform = "x11" Then FMain.Window.Stacking = Window.Normal 'as Integer, Windows in Desktop, Window.Normal = 0, Window.Above = 1,  Window.Below = 2
  FMain.Window.Sticky = False 'window is visible in all virtual desktops. False is Default
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuUhrDigitalG()
  
  DrawTime()
  Form_Resize()
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuUhrDesign1G()
  
  Form14UhrDesign.Window.Show
  Form_Resize()
  
Catch
  FMain.ErrorText
  
End

Public Sub HUhrLabel_MouseDown()
  
  If Mouse.Left Then 
    Form11Breitengrade.Window.Show
  Else If Mouse.Right Then 
    mnuHorizontaluhrG()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuFensterfotoG()
  
  Dim sFile, sDirFile As String
  Dim imgForm As Image
  Dim Img As Image 
  Dim iIconSize As Integer
  Dim bTimer, bMakeIcon As Boolean
  Dim dateActual As Date 
  
  '************************
  F_bStopForWindowPhoto = True
  ' F_bStopForWindowPhoto = False 
  iIconSize = 256 'Pixel
  '************************
  
  If F_bStopForWindowPhoto = True Then 
    If String.InStr(Application.Path, User.Home) = 0 Then F_bStopForWindowPhoto = False 'only in "/home/..."
  Endif 
  
  bMakeIcon = F_bStopForWindowPhoto
  bTimer = Timer1.Enabled
  mnuDatei.Close() 'Menü sicher ausblenden
  Wait 0.3
  Timer1.Enabled = False
  
  dateActual = FMain.F_dateNow
  
  ''Fix-Date-Time:
  If bMakeIcon = True Then '□
    ''Show individual:
    ' F_dateNow = Date(Year(Date), Month(Date), Day(Date), 10, 10, 30)
    FMain.F_dateNow = Date(2045, 5, 7, 10, 10, 30) 'So, 2045-05-10 10:10:30
    ' RefreshAll()
    LabelDateQuarterCWeekG()
    Timer1IntervalSecond()
    DrawTime(FMain.F_dateNow)
    If F_bClockHorizontalON = True Then Horizontaluhr()
    Wait 0.3
  Endif 
  
  ''Photo:
  imgForm = M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
  
  ''Extra Icon-Format:
  If bMakeIcon = True Then
    If imgForm Then 
      Img = New Image(imgForm.H, imgForm.H, Color.Transparent) '1:1
      Paint.Begin(Img)
      Paint.DrawImage(imgForm, (imgForm.H - imgForm.W) / 2, 0)
      Paint.End
      imgForm = Img.Stretch(iIconSize, iIconSize) 'Icon-Size max. WxH in Pixel
      
      sFile = "temp_" & ("foto") & "-" & Application.Name & "icon_" & iIconSize & ".png"
      sDirFile = M01Functions.ProgramDirCache(sFile) '/directory/file.png
      If IsDir(File.Dir(sDirFile)) = True Then imgForm.Save(sDirFile)
    Endif 
  Endif 
  
  ''Reset:
  F_bStopForWindowPhoto = False 
  FMain.F_dateNow = dateActual
  DrawTime(FMain.F_dateNow)
  Horizontaluhr()
  Timer1.Enabled = bTimer 'Reset
  
Catch
  FMain.ErrorText
  F_bStopForWindowPhoto = False
  
End

Public Sub mnuFotoG()
  
  FMain.Window.Minimized = True
  Form15Foto.Window.Show
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAutostart_Show()
  
  Dim sDirFile As String
  
  ' mnuSymbolAutostart2.Checked = Settings[FMain.Name &/ "Autostart", False]
  mnuSymbolAutostart2.Checked = Exist(FMain.F_sPathAutoStartDatei_desktop)  'True or False, prüfen
  
  sDirFile = M01Functions.LinkDesktopExist()
  If Exist(sDirFile) = True Then
    mnuSymbolDesktop2.Checked = True
  Else
    mnuSymbolDesktop2.Checked = False
  Endif
  
  If F_iTrayIconSystemON1 = 0 Then 
    MenuTrayIconOnOff.Checked = False 'TrayIcon1.Visible
  Else 
    MenuTrayIconOnOff.Checked = True  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MenusAllON(Optional bON As Boolean = True) 'unused
  
  Dim mnu As Menu
  
  For Each mnu In FMain.Window.Menus
    mnu.Visible = bON
  Next
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuSymbolziehenG()
  
  Dim sDirFile, sMessage As String
  '/ home / "user" / Schreibtisch / Terminwecker.gambas
  '/ home / "user" / .config / autostart
  sDirFile = "/usr/share/applications" &/ Application.Name & ".desktop"
  'Root-Wurzel Verzeichnis. Nur lesen, kein Zugriff erlaubt. 
  
  sMessage = sDirFile & "<br><br>" 
  sMessage &= ("Programm (Icon, Symbolbild)") & "<br>"
  sMessage &= ("Die kleine Datei vom Terminwecker") & ": " & "<font color=blue>" & ("''Kopieren nach...''") & "</font>" 
  sMessage &= ("Schreibtisch (Desktop, Start-Bildschirm)")
  
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
    Case 1
      If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
      M01Functions.FileManagerOpen(sDirFile)
    Case 2 'Abbrechen
      '...Leerlauf 
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDateipfadG()
  
  M01Functions.FileManagerOpen(F_sPathTerminweckerActual_txt)
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuSchongangG()
  
  Dim sPath As String 
  
  If F_iClockMap0Stop1Count2Digital3Design4 = 0 Then
    sPath = "images/earth_128.png"
    If Exist(sPath) = True Then PicBoxClock.Picture = Picture.Load(sPath) Else PicBoxClock.Picture = New Picture(PicBoxClock.W, PicBoxClock.H, True) 'Transparent
    F_picClock = PicBoxClock.Picture
    ' sPath = "terminweckericon.png"
    ' If Exist(sPath) = True Then F_picClock = Picture.Load(sPath) Else F_picClock = FMain.Window.Icon 'Leistung schonen
    ' FMain.Window.Icon = F_picClock 'Leistung schonen
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelCounterG()
  
  ' If mnuZaehler.Checked = True Then
  If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then
    If Mouse.Left = True Then F_iCounterWithKeyPress = F_iCounterWithKeyPress + 1
    If Mouse.Right = True Then F_iCounterWithKeyPress = F_iCounterWithKeyPress - 1
    LabelPressCounter.Text = ("Zähler = ") & F_iCounterWithKeyPress '& Space(5) & Chr(Key.Code)
    Tastenzaehlerspeichern()
  Endif
  
  ' If mnuStoppUhr.Checked = True Then 
  If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
    F_bStopwatchON = Not F_bStopwatchON
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDiagrammG()
  
  Form16Diagramm.Window.Show
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuProjektebearbeitenG()
  
  Form18Projektbearbeiten.Window.Show
  
Catch
  FMain.ErrorText  
  
End

Public Sub mnuTerminweckerdateiLesenG()
  
  Form3Text.Tag = FMain.F_sPathTerminweckerActual_txt
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuGeburtstagsdateiLesenG()
  
  Form3Text.Tag = FMain.F_sPathEveryYear
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuWeckertonG()
  
  M01Functions.MusicSelectionDialog()
  If FMain.HasFocus = False Then FMain.Raise 'Fokus zurück falls verloren
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuTerminweckerBackupG()
  
  Dim sDirFile, sPathBackup, sMissing, sMessage, sInfo1, sInfo2, sText As String 
  
  sDirFile = FMain.F_sPathTerminweckerActual_txt
  sPathBackup = Settings[FMain.Name &/ "F_sPathTerminweckerLastBackup_txt", FMain.F_sPathTerminweckerLastBackup_txt]
  If Exist(sPathBackup) = False Then 
    ' sPathBackup = sDirFile & "_backup." & File.Ext(sDirFile)
    sPathBackup = FindDirFile(User.Home, "*/" & Application.Name & ".txt*backup*.txt", 3) 'as String, with /media/
    If Exist(sPathBackup) = True Then Settings[FMain.Name &/ "F_sPathTerminweckerLastBackup_txt"] = sPathBackup
  Endif 
  
  If Exist(sDirFile) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) Else sInfo1 = ("Nicht gefunden")
  If Exist(sPathBackup) = True Then sInfo2 = M01Functions.FileLastModifiedText(sPathBackup) & Space(1) & M01Functions.FileSizeLongText(Stat(sPathBackup).Size) Else sInfo2 = ("Nicht gefunden")
  
  If Exist(sPathBackup) = False Then sMissing = ("Kein Backup gefunden")
  
  sMessage = "<h3><font color=gray><b>" & ("Aktuell") & "</b></font></h3>" 
  sMessage &= "<h3><font color=blue><b>" & "○ " & sDirFile & "</b></font></h3>" 
  sMessage &= "<font color=gray><b>" & ("vor") & Space(1) & sInfo1 & "</b></font>" & "<br>" & "<br>"
  
  sMessage &= "<h3><font color=gray>" & ("Backup") & ":" & "</font><br>"
  sMessage &= "<font color=darkgreen>" & "● " & sPathBackup & "</font></h3>"
  sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & sInfo2 & "</b></font>" & "<br>" 
  sMessage &= "<font color=gray>" & "+ " & ("Letztes Backup einlesen, hinzufügen") & ":" & "</font>" & "<br>" 
  
  sMessage &= "<br>"
  sMessage &= "<br>"
  sMessage &= "<font color=gray>" 
  sMessage &= "○ " & ("Tipp: +Bearbeiten. Sicherungskopie auswählen unter Menü > Datei") & "<br>"
  sMessage &= ("Backup-Auswahl Heute, Monat...") & ". " & "<br>"
  sMessage &= ("Das Anhängen ist wiederholbar, doppelte Zeilen werden nicht gespeichert") & "<br>" & "<br>"
  sMessage &= ("Eine Sicherungskopie (Backup) wird immer dann erstellt, wenn neu gespeichert wird mit einem Schalter 'Speichern'. ") 
  sMessage &= "</font>"
  
  Select Case Message.Question(sMessage, "●" & Space(1) & ("Backup einlesen"), "○ " & ("+Bearbeiten"), ("Abbrechen"))
      
    Case 1 ''Backup input:
      If Exist(sPathBackup) = True Then
        If M01Functions.isTerminweckerFile(sPathBackup, True) = True Then 
          sText = File.Load(sPathBackup)
          If sText Then sDirFile = M01Functions.FileTextPlus(sDirFile, sText, False) ' TRUE=overwrite (überschreiben)
        Endif 
      Endif
      ButtonRefreshG() 'Neu einlesen
      
    Case 2 '+Edit
      ButtonEditG() '+Bearbeiten
      
    Case 3 'Abbrechen
      '...Leerlauf
      
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Function FindDirFile(Optional sStartDir As String = User.Home, Optional sSearchPattern As String = "*", iType_Dir1_File2_DirFile3 As Integer = 3) As String 
  
  Dim sDirFile, sDir, sLatest As String 
  Dim it, iLine, iDirFile As Integer
  Dim ssSpli As New String[]
  Dim bExact As Boolean 
  
  Select Case iType_Dir1_File2_DirFile3
    Case 1
      iDirFile = gb.Directory
    Case 2
      iDirFile = gb.File
    Case 3
      iDirFile = gb.Directory + gb.File
  End Select 
  
  If String.InStr(sSearchPattern, "*") = 0 Then bExact = True Else bExact = False 'with "*"
  
  'Search in Sub-Directories (Recursively, Rekursiv, RDir):
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = File.Dir(sDirFile)
  
  ''Extern Media, USB-Stick, ...?
  If Exist(sDirFile) = True Then 
    ProgressBarONoff(True) 
    ssSpli = RDir(sDir, sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
    For it = 0 To ssSpli.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sDirFile = sDir &/ ssSpli[it]
      If bExact = True Then 
        If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
      Endif
      If Not sLatest And sDirFile Then 
        sLatest = sDirFile
      Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
        If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
      Endif
      ' sList &= sDirFile & gb.NewLine
    Next 
  Endif
  
  ssSpli = RDir(sStartDir, sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
  
  ''Start Directory:
  For it = 0 To ssSpli.Max
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sDirFile = sStartDir &/ ssSpli[it]
    If bExact = True Then 
      If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
    Endif
    If Not sLatest And sDirFile Then 
      sLatest = sDirFile
    Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
      If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
    Endif
    ' sList &= sDirFile & gb.NewLine
  Next 
  ProgressBarONoff(False) 
  
  Return sLatest ' Null or /Dir or file.ext or /Dir/File.ext  
  
Catch
  FMain.ErrorText
  ProgressBarONoff(False) 
  
End

Public Sub SoftwareVersionAenderungenChangeLogG()
  
  Dim sDirFile, sDir, sFile, sMessage As String
  
  sDir = "text/"
  sFile = "CHANGELOG" 'Text-File
  sDirFile = ".hidden/CHANGELOG" 'only in "/home/..."
  ''Access forbidden? 
  If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then  'Read=0 
    sDirFile = sDir &/ sFile 'Relative-Path  "dir/file" Begins not with "/",  Absolute-Path "/dir/file"
  Endif 
  
  If Exist(sDirFile) = True Then 
    Form3Text.Tag = sDirFile
    Form3Text.Tooltip = "" 'Path
    Form3Text.Window.Show
  Else 
    sMessage = sDirFile & "<br> "
    If Exist(sDirFile) = True Then 
      ''Access forbidden? 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then  'Read=0 
        sMessage &= ("Kein Zugang") & "<br>"
      Endif 
    Else  
      sMessage &= ("Nicht gefunden") & "<br>"
    Endif 
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory
        M01Functions.FileManagerOpen(File.Dir(sDirFile))
      Case 2
        '...
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  FMain.Window.Maximized = Not FMain.Window.Maximized 
  If FMain.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If FMain.Window.FullScreen = True Or FMain.Window.Maximized = True Then 
      F_bMovingON = False
      FMain.Window.FullScreen = False
      FMain.Window.Maximized = False
      If FMain.Left + FMain.W > Screen.AvailableWidth Then FMain.Move(FMain.Left, FMain.Top, Screen.AvailableWidth - FMain.Left, Screen.AvailableHeight - FMain.Top)
    Else
      F_bMovingON = True
      FMain.Window.FullScreen = False
      FMain.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = FMain.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = FMain.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(FMain.ClientW - WindowStretch.W, FMain.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then FMain.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    FMain.W = Mouse.ScreenX - F_iX1
    FMain.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(FMain.ClientW - WindowStretch.W, FMain.ClientH - WindowStretch.H)
    WindowStretch.Raise()
    'Example: FMain.W -> autom. Form_Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(FMain.ClientW - WindowStretch.W, FMain.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    FMain.Window.Maximized = Not FMain.Window.Maximized 
    If FMain.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  ' CheckFontSize()
  Form_Resize()  ' HorizontalUhrCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If FMain.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then mnuBearbeiten.Popup(PicBackground.ScreenX, PicBackground.ScreenY)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelClockHorizontal_Enter()
  
  PanelClockHorizontal.Background = Color.SetAlpha(Color.Yellow, 150)
  
End

Public Sub PanelClockHorizontal_Leave()
  
  PanelClockHorizontal.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicAutostartG(Optional sLMR As String = "L")
  
  If sLMR = "L" Then 'Left
    CheckPicAutostartG()
    M01Functions.LinkAutoStartCheck()
    CheckPicAutostartG()
  Else If sLMR = "R"
    mnuDesktopSymbolG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckPicAutostartG()
  
  If Exist(FMain.F_sPathAutoStartDatei_desktop) = True Then 
    PicBoxAutostart.Visible = True 
    PicBoxAutostart.Picture = PicTemplateConnectON.Picture
    PicBoxAutostart.Tooltip = ("Autostart-Datei gefunden") & ": " & ("Ja") & gb.NewLine & ("Computerstart") & Space(1) & ("mit") & Space(1) & ("Programm-Start") & " / " & ("Icon-Symbol im Bildschirm")
  Else 
    PicBoxAutostart.Visible = True 
    PicBoxAutostart.Picture = PicTemplateConnectOff.Picture  
    PicBoxAutostart.Tooltip = ("Autostart-Datei gefunden") & ": " & ("Nein") & gb.NewLine & ("Computerstart") & Space(1) & ("ohne") & Space(1) & ("Programm-Start") & " / " & ("Icon-Symbol im Bildschirm")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Last.Background = Color.SetAlpha(Color.Green, 220)
  If Object.Type(Last) = "Button" Then Last.Border = True 
  
  ''___________________________________________________________________''
  'Gambas3: 'Last.Border = True 'gb.gui: warning; Label.Transparent and TextLabel.Transparent are deprecated
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  Last.Background = Color.Default
  If Object.Type(Last) = "Button" Then Last.Border = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp()
  
  Dim sLMR As String 
  
  If Mouse.Left Then sLMR = "L"
  If Mouse.Middle Then sLMR = "M"
  If Mouse.Right Then sLMR = "R"
  ButtonGroupSelect(Last.Tag, sLMR)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "L")
  
  FMain.F_bESCpressedON = False 'Reset
  
  sMouseLMR = UCase(sMouseLMR)
  sLastTag = String.LCase(sLastTag)
  
  Select Case sLastTag
    Case "dateqkw"
      Message.Info("<h1>" & LabelDateQKW.Text & "</h1>", ("Abbrechen"))
    Case "cancel"
      ButtonCancelG()
    Case "photo"
      mnuFotoG()
    Case "iconerror"
      M01Functions.IconError()
    Case "autostart"
      PicAutostartG(sMouseLMR)
    Case "edit"
      ButtonEditG()
    Case "year"
      ButtonYearG(sMouseLMR)
    Case "kal"
      mnuHTMLSeiteG()
    Case "refresh"
      ButtonRefreshG()
    Case "path"
      If sMouseLMR = "L" Then 
        Form19FileInfo.Window.Show
      Else If sMouseLMR = "R" Then 
        LabelPathG()
      Endif 
    Case "minus"
      ButtonDayMinusG()
    Case "plus"
      ButtonDayPlusG()
    Case "time"
      If sMouseLMR = "L" Then 
        LabelTimeG()
      Else If sMouseLMR = "R" Then 
        mnuTerminMeldungG() 'Form3Text.Window.Show
      Endif 
    Case "counter"
      LabelCounterG()
    Case "projects"
      mnuProjekteG()
    Case "lock"
      mnuTerminMeldungenONG()
    Case "infomessage"
      mnuTermineAuslagern_Click()
    Case "buttoncopy"
      TextArea2.SelectAll()
      Clipboard.Copy(TextArea2.Selection.Text)
    Case "note"'music
      CheckClockAlarmButtonNoteOnOff(True)
    Case "mediainfo"
      MediaInfoG()
    Case "formopencount"
      MenuSides.Popup
    Case "closecancel"
      PanelProgramClose.Visible = False 
    Case "quit"  
      mnuBeendenG()
  End Select
  
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub MediaInfoG()
  
  Dim sMessage, sInfo, sPath, sPathStandard, sPathActual As String 
  
  sPathStandard = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt]
  sPathActual = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  
  '' Standard
  If Exist(sPathStandard) = False Then 
    sMessage &= sPathStandard & "<font color=red>" & Space(1) & ("Fehlt") & "</font>"  
  Else If M01Functions.isTerminweckerFile(sPathStandard) = False Then 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= FMain.F_sPathTerminweckerStandard_txt & "<br>"
  Endif
  
  ''Alternativ, Actual
  If Exist(sPathActual) = False Then 
    sMessage &= sPathActual & "<font color=red>" & Space(1) & ("Fehlt") & "</font>"  
  Else If M01Functions.isTerminweckerFile(sPathActual) = False Then 
    sMessage &= ("Die Datei hat keine erkennbare Struktur wie in") & ":" & "<br>" 
    sMessage &= FMain.F_sPathTerminweckerStandard_txt & "<br>"
  Endif
  
  sInfo = M01Functions.CheckLatestTerminweckerTXT(True) 'True=Info
  sMessage &= "<h3><font color=gray>" & sInfo & "</font></h3>"
  sMessage &= "<hr>" '—————————————————————
  sMessage &= "<h2>" & "● + ○ " & "<font color=darkgreen>" & ("Diese Dateien aktualisieren, angleichen, zusammenführen") & "</font></h2>"
  sMessage &= "<h5><font color=gray>" & ("Datei1 + Datei2 = Datei1 = Datei2 (ohne doppelte Zeilen)") & "</font></h5>"
  
  Select Case Message.Question(sMessage, "● + ○ " & ("Aktualisieren"), ("Ordner..."), ("Abbrechen"))
    Case 1
      '******************************************************************************************
      sPathStandard = M01Functions.FileRefreshWithoutDoubleLines(sPathStandard, sPathActual)
      '******************************************************************************************
      If Exist(sPathStandard) = True And Exist(sPathActual) = True Then 
        If Stat(sPathStandard).Size <> Stat(sPathActual).Size Then PicBoxMedia.Visible = True Else PicBoxMedia.Visible = False 
        PicBoxMedia.Background = Color.Red
      Endif 
      sInfo = M01Functions.CheckLatestTerminweckerTXT(True) 'True=Info
      sMessage = "<h3><font color=gray>" & ("Fertig") & "</font></h3>"
      sMessage &= "<h3><font color=gray>" & sInfo & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Ordner Backup") & "...", ("Öffnen") & "...", ("Abbrechen")) 'Info
        Case 1
          sPath = FMain.F_sLastCopyBackup
          If Exist(sPath) = False Then sPath = FMain.F_sDirBackup
          M01Functions.FileManagerOpen(sPath)
        Case 2
          Form1FileOpen.Show
          Form1FileOpen.Tag = sPathActual
          Form1FileOpen.Visible = True 
        Case 3
          ''...
      End Select 
      
    Case 2
      sPathStandard = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt]
      M01Functions.FileManagerOpen(sPathStandard)
    Case 3
      ''...Cancel
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuGroup_Click() 'bei Menu _Click()
  
  If Object.Type(Last) = "Menu" Then MenuGroupList(Last.Tag)
  TrayIconColorize(0) 'iStop0_Plus1_Alarm2
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuGroupList(Optional sLastTag As String = "")
  
  Select Case String.LCase(sLastTag)
      ''mnuDatei............................... File
    Case "open"
      mnuDateiOpenG()
    Case "standardfile"
      mnuStandardDateiG()
    Case "filepath"
      mnuDateipfadG()
    Case "backup"  
      mnuTerminweckerBackupG()
    Case "backupsettings"
      M01Functions.SettingsBackupConfig()
    Case "settingsdefaultextern"
      SettingsDefaultForExtern()
    Case "terminfileread"
      mnuTerminweckerdateiLesenG()
    Case "birthdays"
      mnuGeburtstagsdateiLesenG()
    Case "export"  
      mnuExportG() 
    Case "photowindow" 
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "photowindowfixtime"  
      mnuFensterfotoG()
    Case "photo"  
      mnuFotoG()
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "closeprogramreset"
      M01Functions.CloseProgramResetAll()
    Case "quit"  
      mnuBeendenG()
      
      ''mnuBearbeiten ............................... Edit
    Case "lockoff" 
      mnuTerminMeldungenONG()
    Case "lockon"  
      mnuTerminMeldungenOFFG()
    Case "note"
      CheckClockAlarmButtonNoteOnOff(True)
    Case "plusalarm"
      PlusAlarmON()
      FMain.TermineaktuellTextArea2()
    Case "projects"  
      mnuProjekteG()
    Case "esc"   
      ESCkeypress() '?
      
    Case "timerplus"  
      mnuTimerplusG()
    Case "dayplus"
      ButtonHolidaysG()
    Case "settings"  
      mnuEinstellungenG()
    Case "stopclock"  
      If F_iClockMap0Stop1Count2Digital3Design4 = 1 Then 
        F_iClockMap0Stop1Count2Digital3Design4 = F_iClockSwitchBefore
      Else 
        F_iClockMap0Stop1Count2Digital3Design4 = 1
      Endif 
      ClockSwitchCheck()
    Case "counter" 
      If F_iClockMap0Stop1Count2Digital3Design4 = 2 Then 
        F_iClockMap0Stop1Count2Digital3Design4 = F_iClockSwitchBefore
      Else 
        F_iClockMap0Stop1Count2Digital3Design4 = 2
      Endif 
      ClockSwitchCheck()
    Case "calculator"  
      mnuTaschenrechnerG()
      ''▶...............................
    Case "onlyclock"  ''□
      ClockOnly()
    Case "horizontalclock"  
      mnuHorizontaluhrG()
    Case "digitalclock" ''00:00 red
      F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      F_sTagsClockDigital = "-timelcd-big-red-sizemax-bold"
      Settings[FMain.Name &/ "F_sTagsClockDigital"] = F_sTagsClockDigital
      F_iClockMap0Stop1Count2Digital3Design4 = 3
      ClockSwitchCheck()
    Case "digitalclockwhite" ''00:00 white
      F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      F_sTagsClockDigital = "-timelcd-big-white-sizemax-bold"
      Settings[FMain.Name &/ "F_sTagsClockDigital"] = F_sTagsClockDigital
      F_iClockMap0Stop1Count2Digital3Design4 = 3
      ClockSwitchCheck()
    Case "schongang" ''only Map
      If F_iClockMap0Stop1Count2Digital3Design4 = 0 Then 
        F_iClockMap0Stop1Count2Digital3Design4 = 4 
      Else 
        F_iClockMap0Stop1Count2Digital3Design4 = 0
      Endif 
      ClockSwitchCheck()
    Case "myclockdesign"
      If F_iClockMap0Stop1Count2Digital3Design4 = 4 Then 
        F_iClockMap0Stop1Count2Digital3Design4 = 0 
      Else 
        F_iClockMap0Stop1Count2Digital3Design4 = 4
      Endif 
      ClockSwitchCheck()
    Case "clockdesign1" ''Building Set
      mnuUhrDesign1G()
    Case "slideryearday"  ''Day in Year
      mnuSchieberJahrestagG()
    Case "music"  
      mnuWeckertonG()
    Case "terminweckerfile"  
      mnuTerminweckerDateioeffnenG()
    Case "projectterminwecker"   
      mnuProjektTimerweckerOeffnenG()
    Case "projectactualopen"  
      mnuProjektAktuellOeffnenG()
    Case "projectedit" 
      mnuProjektebearbeitenG()
    Case "projectextern"  
      mnuProjektAktuellOeffnenTabelleG()
    Case "diagram"    
      mnuDiagrammG()
    Case "openall"  
      mnuOeffnenAndereG()
      
      ''mnuBisEingabe...............................
    Case "dateuntil" 
      mnuBisEingabeG()
      
      ''mnuAutostart...............................
    Case "autostartsymbol"  
      M01Functions.LinkAutoStartCheck() '2
      CheckPicAutostartG()
    Case "desktopsymbol"  
      mnuDesktopSymbolG() '2
      CheckPicAutostartG()
    Case "trayicononoff"
      If F_iTrayIconSystemON1 = 0 Then 
        Settings[F_sForm &/ "F_iTrayIconSystemON1"] = 1 '= -1
        F_iTrayIconSystemON1 = 1
      Else 
        Settings[F_sForm &/ "F_iTrayIconSystemON1"] = 0  '= 0
        F_iTrayIconSystemON1 = 0
      Endif 
      TrayIconFile("save")
      CheckTrayIconSystemOnOff()
    Case "dragsymbol"  
      mnuSymbolziehenG()
      
      ''mnuHilfe...............................help ?
    Case "info"  
      mnuInfoG()
    Case "filechangelist"
      FileChangeList()
    Case "softwareinfo"
      SoftwareInfo()
    Case "mediainfo"
      MediaInfoG()
    Case "homepage"  
      mnuHomepageG()
    Case "versionsnumberload"  
      SoftwareVersionNumberLoadG()
    Case "versionnumbercheck"
      SoftwareCheckVersionNumberG()
    Case "deinstall"
      M01Functions.SoftwareDeInstall()
      
    Case "changelog"     
      SoftwareVersionAenderungenChangeLogG()
    Case "opensource"
      Form20OpenSource.Window.Show
    Case "language"   
      mnuSpracheG()
    Case "terminmessages"  
      mnuTerminMeldungG() 'Form3Text.Window.Show
    Case "systeminfo"
      M01Functions.SystemControl("systeminfo")
    Case "checktools"
      M01Functions.CheckTools()
    Case "abc123" 
      mnuZeichensatzG()
    Case "errormessages", "iconerror"
      M01Functions.IconError()
    Case "backupfiles"
      mnuDatensicherungG()
    Case "trash"  
      mnuPapierkorbG()
      
      ''MenuTrayIconSystem.................... (siehe Icon-Schaltfläche Betriebssystem beenden, ausschalten)
    Case "trayiconterminwecker"
      FormShowTop() 'FMain <> Form0Clock
    Case "trayterminactual" '—▶MenuTrayIconSystem_Show()
      FormShowTop() 'FMain <> Form0Clock
    Case "trayedit"
      ButtonEditG()
    Case "trayiconproperties"
      Form6Einst.Show()
    Case "trayiconproject"
      Form5Projekte.Show()
    Case "trayiconphoto"
      Form15Foto.Show()
    Case "trayclockdesign"
      Form14UhrDesign.Show()
    Case "trayiconquit"
      mnuBeendenG()
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub FormShowTop() 'FMain <> Form0Clock
  
  ''Clock <> FMain
  If Form0NurUhr.Visible = False Then 
    ''Clock
    Form0NurUhr.Show() 
    Form0NurUhr.Visible = True 
    FMain.Minimized = True 
  Else 
    ''FMain
    FMain.Activate()
    FMain.Minimized = False 
    FMain.Visible = True 
    ' FMain.TopOnly = True 
    ' FMain.TopOnly = False
    Form0NurUhr.Close()
  Endif 
  ''Note: wayland (Fenster-Macher, Vorgänger x11 hat ein anderes Fensterverhalten)

Catch 
  FMain.ErrorText
  
End

Public Sub TrayIconFile(Optional sReadSave As String = "read")
  
  Dim sDir, sFile, sDirFile, sText As String 
  
  sDir = F_sDirTerminweckerCurrent
  sFile = "trayicon-onoff.txt"
  sDirFile = sDir &/ sFile 
  
  Select Case sReadSave
    Case "read"
      If Exist(sDirFile) = True Then sText = File.Load(sDirFile)
      If String.InStr(sText, "1") > 0 Then F_iTrayIconSystemON1 = 1 Else F_iTrayIconSystemON1 = 0
    Case "save"
      sText = F_iTrayIconSystemON1
      If IsDir(sDir) = True Then File.Save(sDirFile, sText)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckTrayIconSystemOnOff()
  
  ' Gambase3:
  ' • The old X11 freedesktop system tray specification.
  ' • The KDE DBus system tray protocol.
  ' • The Unity DBus system tray protocol.
  ' The component looks at run time which kind of system tray is available, and chooses the accurate protocol.
  
  ' Needs Component "gb.gui.trayicon"
  If Component.IsLoaded("gb.gui.trayicon") = True Then 'needs component "gb.dbus"  (D-Bus-Interface)
    If F_iTrayIconSystemON1 = 0 Then '= 0 = False
      TrayIcon1.Hide() 'Gambas3: "Hide the trayicon from the system tray. Call Show To show it again."
      TrayIcon1.Visible = False
    Else  
      TrayIcon1.Show()
      ' If Component.IsLoaded("gb.dbus") = True Then 'Gambas3: Component.Path "Returns the system path where all the components are stored." Ist die Komponente gb.dbus geladen, wird automatisch mit dem dbus verbunden. Daten-Bus. 
      ' sDBusApplicationName = "org.gambas." & Application.Name
      'DBus.Unique = True —▶ sDBusApplicationName = org.gambas.projektname
      'DBus.Unique = False (Default) —▶ sDBusApplicationName = org.gambas.projektname-PID  ' PID = Process Identification Number. Gambas3: "Return or set if the application registers on the D-Bus bus with an unique ID."
      'DBus.Name = "org.gambas." & Application.Name & "-PID"
      'DBus.Unique = True —▶ "org.gambas.terminwecker"
      'DBus.Unique = False —▶ "org.gambas.terminwecker-1234" plus PID
      ' Endif
    Endif 
  Endif 
  MenuTrayIconOnOff.Checked = TrayIcon1.Visible 'F_iTrayIconSystemON1  
  
  ''_______________________________________________________________________''
  ' Gambas3: "Warning.
  ' If your application has a DBus object like a TrayIcon added to the form designer it will initialize and set your applications DBus.Name before your Form_Open() method.
  ' If you experience problems setting your DBus.Name in this scenario then you must either instance your TrayIcon by code after setting DBus.Name or create a StartUp.module/class that first sets the DBus.Name and then opens your Form with the TrayIcon."
  
  ' "https://de.wikipedia.org/wiki/Gambas_%28Programmiersprache%29"  (Diese Seite wurde zuletzt am 19. Dezember 2023 um 09:49 Uhr bearbeitet.)
  'Gambas-Books (Bücher): https://gambaswiki.org/wiki/doc/book?nh&l=en
  
Catch 
  FMain.ErrorText
  
End

Private Function DBusApplicationPID() As Integer 'unused
  
  Dim ssList, ssSpli As String[]
  Dim sLine As String
  Dim iFound As Integer
  
  If Component.IsLoaded("gb.dbus") = True Then
    ssList = DBus.Session.Applications.Sort(gb.Natural) '.Natural as Integer = 8. Also 1,2,3,10,... not 1,10,2,3...
    If DBus.Name Like "*-?*" Then 
      sLine = DBus.Name
      ssSpli = Split(sLine & "-", "-")
      Try iFound = ssSpli[1]
    Else  
      For Each sLine In ssList
        If sLine Begins "org.gambas." & Application.Name Then
          ssSpli = Split(sLine & "-", "-")
          Try iFound = ssSpli[1]
          ' Print sLine 
          Break
        Endif
      Next
    Endif 
  Endif 
  Print sLine 
  
  Return iFound 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuInfoSystem_Click()
  
  M01Functions.SystemStandardApplications()                'Example: png > gimp, html > firefox, ...
  
End

Public Sub mnuTermineAllInsideAllOutside_Click()
  
  Dim sPath, sDirFile, sDirFileInside, sDirFileOutside, sDirFileBackup, sMessage As String 
  Dim sFromInside, sFromOutside, sTermineVergangene, sEmpty As String 
  Dim sDatumBis1, sDatumBis2, sHTMLa, sHTMLb, sInfoA, sInfoB, sInsideOrOutside As String
  Dim bCancel, bBigFile As Boolean
  Dim iLinesA, iLinesB As Integer
  Dim sInfo1, sInfo2 As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sEmpty = ""
  sDirFileInside = FilePathForm()
  sDirFileOutside = FilePathFormOldYears()
  
  If Exist(sDirFileInside) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFileInside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileInside).Size) Else sInfo1 = ("Nicht gefunden")
  If Exist(sDirFileOutside) = True Then sInfo2 = M01Functions.FileLastModifiedText(sDirFileOutside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOutside).Size) Else sInfo2 = ("Nicht gefunden")
  
  If Exist(sDirFileInside) = True Then 
    If Stat(sDirFileInside).Size > 1000000 Then bBigFile = True 
  Endif 
  If Exist(sDirFileOutside) = True Then 
    If Stat(sDirFileOutside).Size > 1000000 Then bBigFile = True 
  Endif 
  sHTMLa = "<h4><font color=darkgreen><b>"
  sHTMLb = "</b></font></h4>"
  
  sDatumBis1 = "○" & Space(1) & ("Alles") & Space(1) & ("auslagern") 
  sDatumBis2 = "●" & Space(1) & ("Alles") & Space(1) & ("einlagern") 
  
  sMessage = "<h3>" & ("Heute") & ":  " & Format(Date, "ddd dd-mm-yyyy") & "</h3>"
  
  ''All outside: —▶
  sMessage &= "<h2><font color=darkgreen>" & "○ " & ("Alle Termine") & Space(1) & "</font><font color=blue><b>" & ("auslagern") & Space(1) & ("(Leeren)") & "</b></font></h2>"
  
  sMessage &= "<h3><font color=gray>" & ("Von:") & "</font>" & "<br>"
  sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo1 & "</font></h3>"
  
  sMessage &= "<h3><font color=gray>" & ("Nach:") & "</font>" & "<br>"
  sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo2 & "</font></h3>"
  
  sMessage &= "<hr>" '——— String(50, "*")
  
  ''All inside: ◀—
  sMessage &= "<h2><font color=blue>" & "● " & ("Alle Termine") & Space(1) & "</font><font color=darkgreen><b> " & ("einlagern") & Space(1) & ("(Füllen)") & "</b></font></h2>"
  
  sMessage &= "<h3><font color=gray>" & ("Von:") & "</font>" & "<br>"
  sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo2 & "</font></h3>"
  
  sMessage &= "<h3><font color=gray>" & ("Nach:") & "</font>" & "<br>"
  sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo1 & "</font></h3>"
  
  If bBigFile = True Then 
    sMessage &= "<br>"
    sMessage &= "<font color=blue><b>" & ("Große Datei = Mehr Zeit") & "</b></font>"
  Endif 
  
  Select Case Message.Question(sMessage, sDatumBis1, sDatumBis2, ("Abbrechen"))
      
    Case 1 ''All outside: —▶
      'Save all outside: 
      sInsideOrOutside = ">"
      If Exist(sDirFileInside) = True Then sFromInside = File.Load(sDirFileInside)
      If Exist(sDirFileOutside) = True Then sFromOutside = File.Load(sDirFileOutside)
      If sFromOutside Then sFromOutside = sFromOutside & hReturn
      sFromOutside = sFromOutside & sFromInside
      
      'Save outside all:
      sPath = M01Functions.FileTextPlus(sDirFileOutside, sFromOutside, True) ' TRUE=overwrite (überschreiben)
      
      'Save inside empty:
      sPath = M01Functions.FileTextPlus(sDirFileInside, sEmpty, True) ' TRUE=overwrite (überschreiben)
      sFromInside = Null
      
    Case 2 ''All inside: ◀—
      'Find earlier:
      sInsideOrOutside = "<"
      If Exist(sDirFileInside) = True Then sDirFile = File.Dir(sDirFileInside) &/ String.LCase(Application.Name) & "_oldyears.txt"
      
      If Exist(sDirFile) = True Then sTermineVergangene = File.Load(sDirFile)
      If Exist(sDirFileInside) = True Then sFromInside = File.Load(sDirFileInside)
      If Exist(sDirFileOutside) = True Then sFromOutside = File.Load(sDirFileOutside)
      If sTermineVergangene Then sTermineVergangene = sTermineVergangene & hReturn
      If sFromInside Then sFromInside = sFromInside & hReturn
      sFromInside = sTermineVergangene & sFromInside & sFromOutside
      
      'Save inside all:
      sPath = M01Functions.FileTextPlus(sDirFileInside, sFromInside, True) ' TRUE=overwrite (überschreiben)
      
      'Save outside empty:
      sPath = M01Functions.FileTextPlus(sDirFileOutside, sEmpty, True) ' TRUE=overwrite (überschreiben)
      sFromOutside = Null
      
      If Exist(sDirFile) = True And Exist(sDirFileInside) = True Then 
        sDirFileBackup = F_sDirBackup &/ File.Name(sDirFile)
        Move sDirFile To sDirFileBackup '..."_vergangene.txt"
      Endif 
      
    Case 3 'Abbrechen
      bCancel = True  
  End Select
  
  If bCancel = False Then 
    If Exist(sDirFileInside) = True 
      sInfoA = ("Verändert") & ": " & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileInside) & "</b></font><br>" 
      sInfoA &= M01Functions.FileSizeLongText(Stat(sDirFileInside).Size) 
    Else 
      sInfoA = ("Vorhanden") & ": " & "<font color=red><b>" & ("Nein") & "</b></font>"
    Endif 
    If Exist(sDirFileOutside) = True 
      sInfoB = ("Verändert") & ": " & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileOutside) & "</b></font><br>"
      sInfoB = M01Functions.FileSizeLongText(Stat(sDirFileOutside).Size) 
    Else 
      sInfoB = ("Vorhanden") & ": " & "<font color=red><b>" & ("Nein") & "</b></font>"
    Endif 
    If Exist(sDirFileBackup) = False Then sDirFileBackup = FMain.F_sDirBackup
    
    iLinesA = Split(sFromInside, gb.NewLine).Count '(*1)
    iLinesB = Split(sFromOutside, gb.NewLine).Count
    
    If sInsideOrOutside = ">" Then 
      sMessage = "<h3>" & ("Alles") & Space(1) & ("ausgelagert") & "</h3>"
      
      sMessage &= "<font color=gray>" & ("Von:") & "</b></font><br>"
      sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font><br>"
      sMessage &= sInfoA & "<br>"
      sMessage &= ("Zeilen") & ": " & "<font color=darkgreen><b>" & Str(iLinesA) & "</b></font><br><hr><br>"
      
      sMessage &= "<font color=gray>" & ("Nach:") & "</font><br>"
      sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font><br>"
      sMessage &= sInfoB & "<br>"
      sMessage &= ("Zeilen") & ": " & "<font color=blue><b>" & Str(iLinesB) & "</b></font><br><br>"
    Else 
      sMessage = "<h3>" & ("Alles") & Space(1) & ("eingelagert") & "</h3>"
      
      sMessage &= "<font color=gray>" & ("Von:") & "</font><br>"
      sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font><br>"
      sMessage &= sInfoB & "<br>"
      sMessage &= ("Zeilen") & ": " & "<font color=blue><b>" & Str(iLinesA) & "</b></font><br><hr><br>"
      
      sMessage &= "<font color=gray>" & ("Nach:") & "</font><br>"
      sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font><br>"
      sMessage &= sInfoA & "<br>"
      sMessage &= ("Zeilen") & ": " & "<font color=darkgreen><b>" & Str(iLinesA) & "</b></font><br><br>"
    Endif 
    
    sMessage &= sDirFileBackup & "<br>"  
    sMessage &= "<font color=gray>" 
    sMessage &= ("Tipp: Lese-/Schreibschutz?") & Space(1) & ("Alternative") & ": " & ("+Bearbeiten") & "<br>"
    sMessage &= ("Doppelte Zeilen werden dort nicht gespeichert.") 
    sMessage &= "</font><br>"
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("+Bearbeiten") & "...", ("Abbrechen"))
        
      Case 1 'Directory
        M01Functions.FileManagerOpen(sDirFileInside)
        
      Case 2 '+Edit
        ButtonEditG() '+Bearbeiten
        
      Case 3 'Cancel
        FMain.F_bNeueinlesenStarten = True 'See FMain.RefreshAll()
        
    End Select 
  Endif 
  
  ''____________________________________________________________________________________''
  '(*1) Gambas3: "Separator and escape characters are just single one-byte ASCII characters. You cannot use this function to split a string with a non-ASCII character or a another string.
  ' For example: Split(MyString, "\r\n") will split MyString by using "\r" or "\n" as separator, but not the full string "\r\n"."
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTermineAuslagern_Click()
  
  Dim sDirFileInside, sDirFileOutside As String 
  Dim dateDatum, dateDatum1, dateDatum2 As Date
  Dim sDatumBis1, sDatumBis2, sMessage As String
  Dim sInfo1, sInfo2 As String
  
  sDirFileInside = FilePathForm()
  sDirFileOutside = FilePathFormOldYears()
  
  If Exist(sDirFileInside) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFileInside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileInside).Size) Else sInfo1 = ("Nicht gefunden")
  If Exist(sDirFileOutside) = True Then sInfo2 = M01Functions.FileLastModifiedText(sDirFileOutside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOutside).Size) Else sInfo2 = ("Nicht gefunden")
  
  dateDatum1 = Date(Year(Date) - 6, 12, 31)
  dateDatum2 = Date(Year(Date) - 1, 12, 31)
  sDatumBis1 = "○" & Space(1) & ("bis") & Space(1) & Format(dateDatum1, "yyyy") & Space(1) & ("auslagern") 'vor<<
  sDatumBis2 = "●" & Space(1) & ("bis") & Space(1) & Format(dateDatum2, "yyyy") & Space(1) & ("auslagern") 
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ":  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h2><font color=darkgreen><b>" & "○ ● " & ("Auslagern") & ": " & "</b>" & ("Vergangene Zeilen auslagern in die Datei") & "</font></h2>"
  
  sMessage &= "<h3><font color=gray>" & ("Von:") & "</font>" & "<br>"
  sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo1 & "</font></h3>"
  sMessage &= "<hr>" '———
  sMessage &= "<h3><font color=gray>" & ("Nach:") & "</font>" & "<br>"
  sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo2 & "</font></h3>"
  
  sMessage &= ("Ausnahme:  *Geburtstage oder andere Termine (*Jedes Jahr) werden nicht verschoben.") & "<br>"
  sMessage &= ("Ausnahme:  Timer SoMoDiMiDoFrSa (Jede Woche) werden nicht verschoben.") & "<br>" 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
  Select Case Message.Question(sMessage, sDatumBis1, sDatumBis2, ("Abbrechen"))
    Case 1 'Auslagern>>
      dateDatum = dateDatum1
    Case 2 'Auslagern>>
      dateDatum = dateDatum2
    Case 3 'Abbrechen
      dateDatum = Null
  End Select
  
  If dateDatum Then ''——▶
    ''*********************************
    sDirFileInside = FileSortInsideOrOutside(sDirFileInside, sDirFileOutside, ">", dateDatum)
    ''*********************************
  Endif 
  
Catch 
  FMain.ErrorText
  ProgressBarONoff(False)
  
End

Public Sub mnuTermineEinlagern_Click()
  
  Dim sDirFileInside, sDirFileOutside As String 
  Dim dateDatum, dateDatum1, dateDatum2 As Date
  Dim sDatumBis1, sDatumBis2, sMessage As String
  Dim sInfo1, sInfo2 As String
  
  ''Old and New:
  sDirFileInside = FilePathForm()
  sDirFileOutside = FilePathFormOldYears()
  
  If Exist(sDirFileInside) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFileInside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileInside).Size) Else sInfo1 = ("Nicht gefunden")
  If Exist(sDirFileOutside) = True Then sInfo2 = M01Functions.FileLastModifiedText(sDirFileOutside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOutside).Size) Else sInfo2 = ("Nicht gefunden")
  
  dateDatum1 = Date(Year(Date) - 7, 12, 31)
  dateDatum2 = Date(Year(Date) - 2, 12, 31)
  sDatumBis1 = ("ab") & Space(1) & Format(dateDatum1, "yyyy") & " ▶ " & ("einlagern") 'nach>>
  sDatumBis2 = ("ab") & Space(1) & Format(dateDatum2, "yyyy") & " ▷ " & ("einlagern") 
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ":  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h2><font color=darkgreen><b>" & "○ ● " & ("Einlagern") & ": " & "</b>" & ("Vergangene Zeilen einlagern in die Datei") & "</font></h2>"
  
  sMessage &= "<h3><font color=gray>" & ("Von:") & "</font>" & "<br>"
  sMessage &= "<font color=darkgreen><b>" & sDirFileOutside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo2 & "</font></h3>"
  sMessage &= "<hr>" '———
  sMessage &= "<h3><font color=gray>" & ("Nach:") & "</font>" & "<br>"
  sMessage &= "<font color=blue><b>" & sDirFileInside & "</b></font>" & "<br>"
  sMessage &= "<font color=gray>" & ("vor") & Space(1) & sInfo1 & "</font></h3>"
  
  sMessage &= ("Ausnahme:  *Geburtstage oder andere Termine (*Jedes Jahr) werden nicht verschoben.") & "<br>"
  sMessage &= ("Ausnahme:  Timer SoMoDiMiDoFrSa (Jede Woche) werden nicht verschoben.") & "<br>" 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
  Select Case Message.Question(sMessage, sDatumBis1, sDatumBis2, ("Abbrechen"))   '(0,1,2,3)
    Case 1 'Einlagern<<
      dateDatum = dateDatum1  'input very old
    Case 2 'Einlagern<<
      dateDatum = dateDatum2  'input old
    Case 3 'Abbrechen
      dateDatum = Null        'Cancel
  End Select
  
  If dateDatum Then ''◀——
    ''*********************************
    sDirFileInside = FileSortInsideOrOutside(sDirFileInside, sDirFileOutside, "<", dateDatum)
    ''*********************************
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileSortInsideOrOutside(Optional sDirFileInside As String = "", Optional sDirFileOutside As String = "", Optional sInsideOrOutside As String = ">", Optional dateDatum As Date = Date) As String
  
  Dim sPath, sDirFileBackup, sLine, sColumn, sMessage, sInfoA, sInfoB As String
  Dim sFromInside, sFromOutside, sTextAdd, sTextMinus As String
  Dim iYYYYLine, iYYYYmax, iYYYYminFound, iLines As Integer 
  Dim iLinesA, iLinesA2, iLinesB, iLinesB2 As Integer
  Dim ssSpliLine, ssSpliPart As String[] 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  If Not sDirFileInside Or Not sDirFileOutside Then Goto JumpEnd 'ein Datei-Name muß vorhanden sein
  FMain.F_bESCpressedON = False
  
  If Exist(sDirFileInside) = True And Exist(sDirFileOutside) = True Then 
    If Stat(sDirFileInside).Size > 500000 Or Stat(sDirFileOutside).Size > 500000 Then 
      sMessage = sDirFileInside & "<br>" 'HTML-Break = New Line
      sMessage &= M01Functions.FileSizeText(sDirFileInside) & "<br>"
      sMessage &= "<br>"
      sMessage = sDirFileOutside & "<br>"
      sMessage &= M01Functions.FileSizeText(sDirFileOutside) & "<br>"
      sMessage &= "<br>"
      sMessage &= "<font color=red><b>" & ("Große Datei = Mehr Zeit") & "</b></font><br>"
      Select Case Message.Question(sMessage, ("weiter einlesen") & "...", ("Abbrechen"))
        Case 1
          '...go on
        Case 2
          Goto JumpEnd 'Goto outside, not in a loop For..Next
      End Select
    Endif 
  Endif 
  ProgressBarONoff(True)
  
  ''YYYY
  iYYYYmax = Year(dateDatum) 'as Integer
  iYYYYminFound = iYYYYmax
  
  If Exist(sDirFileInside) = True Then Try sFromInside = File.Load(sDirFileInside) 'as String 
  If Exist(sDirFileOutside) = True Then Try sFromOutside = File.Load(sDirFileOutside) 'as String 
  iLinesA = Split(sFromInside, gb.NewLine).Count '(*1)
  iLinesB = Split(sFromOutside, gb.NewLine).Count
  
  ''Inside ◀——
  If sInsideOrOutside = "<" Then 
    For Each sLine In Split(sFromOutside & hReturn, hReturn) '(*1) [yyyy-mm-dd, 00:00, ...., Notiz]
      iLines = iLines + 1 
      If iLines Mod 100 Then ProgressBarONoff(True)
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFileInside & "<br>" & "◀— " & ("Einlagern") & "<br>", ("weiter..."), ("Abbrechen"))
          Case 1
            ''...
          Case 2
            sDirFileInside = Null
            Goto JumpEnd
        End Select
      Endif 
      
      If Replace(sLine, hTab, "") = "" Then 'leere Zeile
        ssSpliLine = Null
      Else 
        ssSpliLine = Split(sLine & String(6, hTab), hTab)
      Endif 
      If ssSpliLine Then 
        ''no Birthdays (*everyYear), no -Timer
        If String.Left(ssSpliLine[5], 1) = "*" Or IsNumber(String.Left(ssSpliLine[0], 1)) = False Then 
          sTextMinus = sTextMinus & sLine & hReturn ''Example: "*" or 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
        Else 
          sColumn = Replace(ssSpliLine[0], Space(1), "")
          ssSpliPart = Split(sColumn & "-" & "-", "-") ''yyyy-mm-dd
          If ssSpliPart Then 
            If IsInteger(ssSpliPart[0]) = True Then 
              iYYYYLine = CInteger(ssSpliPart[0]) ''yyyy
              ''Compare Year
              If iYYYYLine < iYYYYmax Then 
                If iYYYYLine < iYYYYminFound Then iYYYYminFound = iYYYYLine
                sTextAdd = sTextAdd & sLine & hReturn 'New
              Else 
                sTextMinus = sTextMinus & sLine & hReturn  
              Endif 
            Endif 
          Endif 
        Endif 
      Endif 
    Next
    ''Append, Save:
    If sTextAdd Then ''+''Inside ◀——
      sFromInside = sFromInside & sTextAdd
      sFromOutside = sTextMinus
      sPath = M01Functions.FileTextPlus(sDirFileInside, sFromInside, True) ' TRUE=overwrite (überschreiben)
      sPath = M01Functions.FileTextPlus(sDirFileOutside, sFromOutside, True) ' TRUE=overwrite (überschreiben)
    Endif 
  Endif
  
  ''Outside ——▶
  If sInsideOrOutside = ">" Then 
    For Each sLine In Split(sFromInside & hReturn, hReturn) '(*1) [yyyy-mm-dd, 00:00, ...., Notiz]
      iLines = iLines + 1 
      If iLines Mod 100 Then ProgressBarONoff(True)
      If FMain.F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFileInside & "<br>" & "—▶ " & ("Auslagern") & "<br>", ("weiter..."), ("Abbrechen"))
          Case 1
            ''...
          Case 2
            sDirFileInside = Null
            Goto JumpEnd
        End Select
      Endif 
      
      If Replace(sLine, hTab, "") = "" Then 'leere Zeile
        ssSpliLine = Null
      Else 
        ssSpliLine = Split(sLine & String(6, hTab), hTab)
      Endif 
      If ssSpliLine Then 
        ''no Birthdays (*everyYear), no -Timer
        If String.Left(ssSpliLine[5], 1) = "*" Or IsNumber(String.Left(ssSpliLine[0], 1)) = False Then 
          sTextMinus = sTextMinus & sLine & hReturn ''Example: "*" or 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
        Else ''YYYY
          sColumn = Replace(ssSpliLine[0], Space(1), "")
          ssSpliPart = Split(sColumn & "-" & "-", "-") ''yyyy-mm-dd
          If ssSpliPart Then 
            If IsInteger(ssSpliPart[0]) = True Then 
              iYYYYLine = CInteger(ssSpliPart[0]) ''yyyy
              ''Compare Year
              If iYYYYLine < iYYYYmax Then 
                If iYYYYLine < iYYYYminFound Then iYYYYminFound = iYYYYLine
                sTextAdd = sTextAdd & sLine & hReturn 'New
              Else 
                sTextMinus = sTextMinus & sLine & hReturn 
              Endif 
            Endif 
          Endif 
        Endif 
      Endif 
    Next
    ''Append, Save:
    If sTextAdd Then ''+''Outside ——▶
      sFromInside = sTextMinus
      sFromOutside = sFromOutside & sTextAdd
      sPath = M01Functions.FileTextPlus(sDirFileInside, sFromInside, True) ' TRUE=overwrite (überschreiben)
      sPath = M01Functions.FileTextPlus(sDirFileOutside, sFromOutside, True) ' TRUE=overwrite (überschreiben)
    Endif 
  Endif
  
  ProgressBarONoff(False)
  iLinesA2 = Split(sFromInside, gb.NewLine).Count '(*1)
  iLinesB2 = Split(sFromOutside, gb.NewLine).Count
  
  ''Check
  If Exist(sDirFileInside) = False Or Exist(sDirFileOutside) = False Then 'Check
    If M01Functions.AccessDirFileReadWrite(sDirFileInside, 1) = False Then '1=write
      sMessage = FMain.F_sErrorMessagesExtra & "<br>"
      sMessage &= sDirFileInside & "<br>" & "<br>"
      sMessage &= ("Nicht beschreibbar?") & "<br>"
      sMessage &= ("Pfad oder Zugriffsrechte überprüfen (siehe Ordner/Datei Eigenschaften)") & "<br>"
      Message.Error(sMessage)
    Endif
  Else
    ''Message:
    If Exist(sDirFileInside) = True Then 
      sInfoA = ("Verändert") & ": " & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileInside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileInside).Size) & "</b></font>" & "<br>"
    Else 
      sInfoA = ("Vorhanden") & ": " & "<font color=red><b>" & ("Nein") & "</b></font>" & "<br>"
    Endif 
    sInfoA &= ("Zeilen") & Space(1) & ("vorher") & ": " & "<font color=darkgreen><b>" & Str(iLinesA) & "</b></font><br>"
    sInfoA &= ("Zeilen") & Space(1) & ("nachher") & ": " & "<font color=darkgreen><b>" & Str(iLinesA2) & "</b></font><br>"
    
    If Exist(sDirFileOutside) = True Then 
      sInfoB = ("Verändert") & ": " & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileOutside) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOutside).Size) & "</b></font>" & "<br>"
    Else 
      sInfoB = ("Vorhanden") & ": " & "<font color=red><b>" & ("Nein") & "</b></font>" & "<br>"
    Endif 
    sInfoB &= ("Zeilen") & Space(1) & ("vorher") & ": " & "<font color=darkgreen><b>" & Str(iLinesB) & "</b></font><br>"
    sInfoB &= ("Zeilen") & Space(1) & ("nachher") & ": " & "<font color=darkgreen><b>" & Str(iLinesB2) & "</b></font><br>"
    
    If Exist(sDirFileBackup) = False Then sDirFileBackup = FMain.F_sDirBackup
    
    ''Outside ——▶
    If sInsideOrOutside = ">" Then 
      sMessage = "<h3><b>" & ("Ausgelagert") & ":" & "</b></h3>"
      sMessage &= "<font color=gray>" & ("Von:") & "</font><br>"
      sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font><br>"
      sMessage &= sInfoA & "<br>"
      sMessage &= "<hr>" '———
      sMessage &= "<br>"
      sMessage &= "<font color=gray>" & ("Nach:") & "</font><br>"
      sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font><br>"
      sMessage &= sInfoB & "<br>"
    Endif 
    
    ''Inside ◀——
    If sInsideOrOutside = "<" Then 
      sMessage = "<h3><b>" & ("Eingelagert") & ":" & "</b></h3>" 'head (Kopf, Titel, Überschrift)
      sMessage &= "<font color=gray>" & ("Von:") & "</font><br>"
      sMessage &= "<font color=blue><b>" & sDirFileOutside & "</b></font><br>" 'break (Zeilenumbruch, nächste Zeile, Return, Zeilenvorschub)
      sMessage &= sInfoB & "<br>"
      sMessage &= "<hr>" '——— horizontal ruler (horizontales Lineal)
      sMessage &= "<font color=gray>" & ("Nach:") & "</font><br>"
      sMessage &= "<font color=darkgreen><b>" & sDirFileInside & "</b></font><br>"
      sMessage &= sInfoA & "<br>"
    Endif 
    
    sMessage &= ("Zeilen") & Space(1) & ("verschoben") & ": " & "<font color=blue><b>" & Str(iLinesA2 - iLinesA) & "</b></font><br><br>"
    sMessage &= ("Gefundene Jahre") & ": " & "<font color=blue><b>" & iYYYYminFound & "-" & iYYYYmax & "</b></font><br><br>"
    
    sMessage &= sDirFileBackup & "<br>"  
    sMessage &= ("Tipp: Lese-/Schreibschutz?") & Space(1) & ("Alternative") & ": " & ("+Bearbeiten") & "<br>"
    sMessage &= ("Doppelte Zeilen werden dort nicht gespeichert.") & "<br>"
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("+Bearbeiten") & "...", ("Abbrechen")) '(0,1,2,3)
        
      Case 1 'Directory
        M01Functions.FileManagerOpen(sDirFileInside)
        
      Case 2 '+Edit
        ButtonEditG() '+Bearbeiten
        
      Case 3 'Cancel
        FMain.F_bNeueinlesenStarten = True 'See FMain.RefreshAll()
        
    End Select 
  Endif 
  
  If Not Error And Exist(sDirFileInside) = True Then
    '...vorhanden
  Else
    sDirFileInside = "" 'Fehler?
  Endif 
  
JumpEnd:
  Return sDirFileInside 'Rückgabe
  
  ''____________________________________________________________________________________''
  '(*1) Gambas3: "Separator and escape characters are just single one-byte ASCII characters. You cannot use this function to split a string with a non-ASCII character or a another string.
  ' For example: Split(MyString, "\r\n") will split MyString by using "\r" or "\n" as separator, but not the full string "\r\n"."
  
Catch 
  FMain.ErrorText
  ProgressBarONoff(False)
  
End

Public Sub SideGroup_Click()
  
  F_sMenuLastName = Last.Name
  SideGroupSelect(F_sMenuLastName)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideGroupSelect(Optional sLastName As String = "")
  
  Select Case sLastName
    Case MenuOnlyClock.Name 
      ClockOnly()
    Case MenuOeffnen.Name
      Form1FileOpen.Window.Show
    Case MenuEdit.Name 
      Form2Bearb.Window.Show
    Case MenuText.Name 
      Form3Text.Window.Show
    Case MenuUntil.Name
      Form4Bis.Window.Show
    Case MenuProjects.Name
      Form5Projekte.Window.Show
    Case MenuSettings.Name
      Form6Einst.Window.Show
    Case MenuHTML.Name 
      Form7HTML.Window.Show
    Case MenuHolidaysPlus.Name 
      Form8ZusFeiertage.Window.Show
    Case MenuSunUpDown.Name
      Form11Breitengrade.Window.Show
    Case MenuTimerPlus.Name 
      Form12Timerplus.Window.Show
    Case MenuReplace.Name
      Form13Export.Window.Show
    Case MenuClockDesign.Name 
      Form14UhrDesign.Window.Show
    Case MenuPhoto.Name 
      Form15Foto.Window.Show
    Case MenuColorPoint.Name
      Form21Colors.Window.Show
    Case MenuDiagram.Name 
      Form16Diagramm.Window.Show
    Case MenuProjectEdit.Name 
      Form18Projektbearbeiten.Window.Show
    Case MenuFileInfo.Name 
      Form19FileInfo.Window.Show
  End Select   
  
  ''___________________________________________________________''
  'Window Life Cycle: "https://gambaswiki.org/wiki/doc/window"
  
Catch 
  FMain.ErrorText
  
End '.........................................................






Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M03Feiertage.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M03Feiertage.module
20,1 KB
' Gambas module file

Public Function HolidaysCalculate(Optional sDatum As String = "", Optional sHinzufuegen As String = "-") As String 
  'Calculate Holdidays
  
  Dim sMuttertag, sErntedankfest, sBettag, sVolkstrauertag, sAdvent1, sAdvent2, sAdvent3, sAdvent4, sSommerzeitAnfang, sSommerzeitEnde As String
  Dim sFruehling, sSommer, sHerbst, sWinter, sSchaltjahrFruehlingInfo, sSchaltjahr28Febr, sSchaltjahr28FebrInfo As String
  Dim ssText As New String[]
  Dim it, iDiff, iDay As Integer
  Dim sYearYYYY As String 
  Dim sYYYYMMDD As String 
  Dim dateEasterDayOstern, dateDatum, hDate, dateAdvent1, dateTemp As Date
  Dim sAlleFeierTageText, sFeiertageTextPlus, sFeiertage As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sYYYYMMDD = "yyyy-mm-dd" 'Format
  
  If sDatum Not Like "????-??-??" Then 
    dateDatum = Now
  Else
    ' sDatum = Format(Now, sYYYYMMDD)
    dateDatum = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
  Endif 
  iDiff = M02Astro.SommerzeitAnfangEnde(dateDatum) 'as Integer, Calculate
  
  hDate = Null
  If FMain.F_dateTimeSummerBegin Then 
    hDate = FMain.F_dateTimeSummerBegin
  Else 
    hDate = Settings[FMain.Name &/ "F_dateTimeSummerBegin", Null] 
  Endif 
  ' hDate = M02Astro.SommerzeitDate(">", dateDatum) 'as Date
  If Not hDate Then 
    dateTemp = Date(Year(dateDatum), 3, 31)
    hDate = DateAdd(dateTemp, gb.Day, 0 - WeekDay(dateTemp)) 'Last sunday in month
  Endif 
  sSommerzeitAnfang = Format(hDate, sYYYYMMDD)
  
  hDate = Null
  If FMain.F_dateTimeSummerEnd Then 
    hDate = FMain.F_dateTimeSummerEnd
  Else 
    hDate = Settings[FMain.Name &/ "F_dateTimeSummerEnd", Null]
  Endif 
  ' hDate = M02Astro.SommerzeitDate("<", dateDatum) 'as Date
  If Not hDate Then 
    dateTemp = Date(Year(dateDatum), 10, 31)
    hDate = DateAdd(dateTemp, gb.Day, 0 - WeekDay(dateTemp)) 'Last sunday in month
  Endif 
  sSommerzeitEnde = Format(hDate, sYYYYMMDD)
  
  ''sMuttertag = Format(Datum, "yyyy") & "-05-06"  'Muttertag = 2. Sonntag im Mai
  hDate = Date(Year(dateDatum), 5, 6)
  For it = 6 To 31
    hDate = DateAdd(hDate, gb.Day, 1)
    If WeekDay(hDate) = gb.Sunday Then
      sMuttertag = Format(hDate, sYYYYMMDD)
      Break
    Endif
  Next
  
  ''Erntedankfest = '1.Sonntag nach Michaelistag 29.Nov. oder 1. So im Okt.
  hDate = Date(Year(dateDatum), 9, 29)
  For it = 29 To 40
    hDate = DateAdd(hDate, gb.Day, 1)
    If WeekDay(hDate) = gb.Sunday Then
      sErntedankfest = Format(hDate, sYYYYMMDD)
      Break
    Endif
  Next
  
  ''Advent
  dateAdvent1 = Date(Year(dateDatum), 11, 26) 'So nach 26.Nov.
  For it = 26 To 40
    dateAdvent1 = DateAdd(dateAdvent1, gb.Day, 1)
    If WeekDay(dateAdvent1) = gb.Sunday Then Break
  Next
  sAdvent1 = Format(dateAdvent1, sYYYYMMDD)
  sAdvent2 = Format(DateAdd(dateAdvent1, gb.Day, 7), sYYYYMMDD)
  sAdvent3 = Format(DateAdd(dateAdvent1, gb.Day, 14), sYYYYMMDD)
  sAdvent4 = Format(DateAdd(dateAdvent1, gb.Day, 21), sYYYYMMDD)
  sBettag = Format(DateAdd(dateAdvent1, gb.Day, -11), sYYYYMMDD)
  sVolkstrauertag = Format(DateAdd(dateAdvent1, gb.Day, -14), sYYYYMMDD) 'siehe unten
  
  ''Oster-Datum
  sYearYYYY = Format(dateDatum, "yyyy")
  dateEasterDayOstern = Date.Easterday(Year(dateDatum)) 'neu in Gambas
  If IsDate(Str(dateEasterDayOstern)) = False Then dateEasterDayOstern = M03Feiertage.OsterterminDate(dateDatum) 'as Date
  
  ''4 Jahreszeiten
  iDay = M02Astro.JahreszeitenSeasons(1, Year(dateDatum)) 'as Integer
  If iDay > 0 Then sFruehling = sYearYYYY & "-03-" & Str(iDay)
  iDay = M02Astro.JahreszeitenSeasons(2, Year(dateDatum)) 'as Integer
  If iDay > 0 Then sSommer = sYearYYYY & "-06-" & Str(iDay)
  iDay = M02Astro.JahreszeitenSeasons(3, Year(dateDatum)) 'as Integer
  If iDay > 0 Then sHerbst = sYearYYYY & "-09-" & Str(iDay)
  iDay = M02Astro.JahreszeitenSeasons(4, Year(dateDatum)) 'as Integer
  If iDay > 0 Then sWinter = sYearYYYY & "-12-" & Str(iDay)
  
  If Month(DateAdd(Date(Year(dateDatum), 2, 28), gb.Day, 1)) = Month(Date(Year(dateDatum), 2, 28)) Then 'Febr = Febr or next Month?
    'Schaltjahr +1 Tag   (alle 4 Jahre, mit seltener Ausnahme)
    ' If Format(Date(Year(dateDatum), 2, 29), "-mm-dd") = "-02-29" Then 'Date Error
    If Not sFruehling Then 
      sFruehling = sYearYYYY & "-03-21"
      sSommer = sYearYYYY & "-06-22"
      sHerbst = sYearYYYY & "-09-23"
      sWinter = sYearYYYY & "-12-22"
    Endif 
    sSchaltjahrFruehlingInfo = Space(1) & ("(19, 20 oder 21)(Febr=29, Schaltjahr=366 Tage)") '—▶ Fruehling
    sSchaltjahr28Febr = sYearYYYY & "-02-28" '+ 1 = 29
    sSchaltjahr28FebrInfo = ": " & ("Ja") & Space(1) & ("+ 1 = 366 Tage (-02-29 Rhythmus 4 Jahre)")
  Else
    ' Fixtag + - 1 Tag
    '2005 astronomischer Fruehling am 20.Maerz um 13.33 Uhr MEZ
    If Not sFruehling Then 
      sFruehling = sYearYYYY & "-03-20" ' Zeitzonen vor und nach der Sommerzeit beachten
      sSommer = sYearYYYY & "-06-21"
      sHerbst = sYearYYYY & "-09-22"
      sWinter = sYearYYYY & "-12-21"
    Endif 
    sSchaltjahrFruehlingInfo = Space(1) & ("(19, 20 oder 21)(Febr=28, kein Schaltjahr=365 Tage") & ")"
    sSchaltjahr28Febr = sYearYYYY & "-02-28" ' + 0 = 28
    sSchaltjahr28FebrInfo = ": " & ("Nein") & Space(1) & ("+ 0 = 365 Tage (-02-29 Rhythmus 4 Jahre)")
  Endif
  
  ''Bewegliche Feiertage:  (vor oder nach Ostern (-)(+))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, -48), sYYYYMMDD) & hTab & ("#(Rosenmontag)"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, -46), sYYYYMMDD) & hTab & ("#(Aschermittwoch)"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, -7), sYYYYMMDD) & hTab & ("#Palmsonntag"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, -3), sYYYYMMDD) & hTab & ("#(Gruendonnerstag)"))
  
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, -2), sYYYYMMDD) & hTab & ("#Karfreitag"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 0), sYYYYMMDD) & hTab & ("#Ostersonntag"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 1), sYYYYMMDD) & hTab & ("#Ostermontag"))
  'ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 7), sYYYYMMDD) & hTab & ("#(Weißer Sonntag)")) 
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 39), sYYYYMMDD) & hTab & ("#Christi Himmelfahrt"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 49), sYYYYMMDD) & hTab & ("#Pfingstsonntag"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 50), sYYYYMMDD) & hTab & ("#Pfingstmontag"))
  ssText.Add(hTab & Format(DateAdd(dateEasterDayOstern, gb.Day, 60), sYYYYMMDD) & hTab & ("#(Fronleichnam)"))
  
  ssText.Add(hTab & sFruehling & hTab & ("#(Fruehling)") & sSchaltjahrFruehlingInfo) ' " & FruehlingUhr & "h)")   'Achtung: ue=ü, intern ohne Umlaute ü, ö...
  ssText.Add(hTab & sSchaltjahr28Febr & hTab & ("#(Schaltjahr)") & sSchaltjahr28FebrInfo)
  ssText.Add(hTab & sSommer & hTab & ("#(Sommer)")) ' " & SommerUhr & "h)")
  ssText.Add(hTab & sHerbst & hTab & ("#(Herbst)")) ' " & Herbstuhr & "h)")
  ssText.Add(hTab & sWinter & hTab & ("#(Winter)")) ' " & WinterUhr & "h)")
  ssText.Add(hTab & sMuttertag & hTab & ("#(Muttertag)"))
  ssText.Add(hTab & sErntedankfest & hTab & ("#(Erntedankfest)"))
  ssText.Add(hTab & sBettag & hTab & ("#(Buss- u. Bettag)"))
  ssText.Add(hTab & sAdvent1 & hTab & ("#1. Advent"))
  ssText.Add(hTab & sAdvent2 & hTab & ("#2. Advent"))
  ssText.Add(hTab & sAdvent3 & hTab & ("#3. Advent"))
  ssText.Add(hTab & sAdvent4 & hTab & ("#4. Advent"))
  ssText.Add(hTab & sVolkstrauertag & hTab & ("#(Volkstrauertag)"))
  ssText.Add(hTab & sSommerzeitAnfang & hTab & ("#(Sommerzeit Anfang +1h)"))
  ssText.Add(hTab & sSommerzeitEnde & hTab & ("#(Sommerzeit Ende -1h)"))
  
  ''Feststehende Feiertage
  ssText.Add(hTab & sYearYYYY & "-01-01" & hTab & ("#Neujahr"))
  ssText.Add(hTab & sYearYYYY & "-01-06" & hTab & ("#(Heilige Drei Koenige)"))
  ssText.Add(hTab & sYearYYYY & "-05-01" & hTab & ("#Maifeiertag"))
  ssText.Add(hTab & sYearYYYY & "-09-29" & hTab & ("#(Michaelis)"))
  ssText.Add(hTab & sYearYYYY & "-10-03" & hTab & ("#Deutsche Einheit"))
  ssText.Add(hTab & sYearYYYY & "-10-31" & hTab & ("#(Reformationstag)"))
  ssText.Add(hTab & sYearYYYY & "-11-01" & hTab & ("#(Allerheiligen)"))
  ssText.Add(hTab & sYearYYYY & "-11-11" & hTab & ("#(Martinstag)"))
  ssText.Add(hTab & sYearYYYY & "-12-06" & hTab & ("#(Nikolaus)"))
  ssText.Add(hTab & sYearYYYY & "-12-24" & hTab & ("#(Heiligabend)"))
  ssText.Add(hTab & sYearYYYY & "-12-25" & hTab & ("#1. Weihnachtstag/Christmas"))
  ssText.Add(hTab & sYearYYYY & "-12-26" & hTab & ("#2. Weihnachtstag/Christmas"))
  ssText.Add(hTab & sYearYYYY & "-12-31" & hTab & ("#(Silvester)"))
  
  ''Alle Feiertage in Variable einlesen:
  sAlleFeierTageText = Null
  
  If sHinzufuegen = "+" Then 
    sAlleFeierTageText = Settings[FMain.Name &/ "F_sFeiertage", sAlleFeierTageText] 
    If String.InStr(sAlleFeierTageText, Str(Year(dateEasterDayOstern))) > 0 Then 
      sAlleFeierTageText = Null 'new, refresh
    Else 
      '...sAlleFeierTageText + ssText  
    Endif 
  Endif 
  
  ssText.Sort() 'A-Z, 0-9
  For it = 0 To ssText.Count - 1
    sAlleFeierTageText &= ssText[it] & hReturn
  Next
  sFeiertageTextPlus = M03Feiertage.HolidaysPlusCalculate(dateDatum) 'as String
  
  ''Speichern:
  sFeiertage = sAlleFeierTageText & sFeiertageTextPlus
  FMain.F_sFeiertage = sFeiertage
  Settings[FMain.Name &/ "F_sFeiertage"] = sFeiertage 
  Settings[FMain.Name &/ "dateEasterDayOstern"] = Format(dateEasterDayOstern, sYYYYMMDD) 
  ' Print FMain.F_sFeiertage
  
  Return sFeiertage
  
  'dateEasterDayOstern berechnen
  'Tage vor/nach dateEasterDayOstern:
  'Ostern ist am ersten Sonntag nach dem ersten Vollmond des Fruehlingsanfangs (21.03).
  'Muttertag = 2. Sonntag im Mai
  'Rosenmontag = -48
  'Aschermittwoch = -46
  'Palmsonntag = -7
  'Gruendonnerstag = -3 Tage vor dateEasterDayOstern
  'Karfreitag =  -2
  'dateEasterDayOstern = 0
  'Ostermontag = +1
  'Christi Himmelfahrt = +39
  'Pfingstsonntag = +49
  'Pfingstmontag = +50
  'Fronleichnam = +60
  'Mariae Himmelfahrt = 15.08.
  'Michaelis = 29.9 Namenstag
  'Deutsche Einheit = 03.10
  'Reformationstag = 31.10
  'Buß- und Bettag = 11 Tage vor 1. Advent
  'Nikolaus = 6.12 Namenstag
  '1. Advent  = Sonntag nach 26. Nov. oder  4. Sonntag vor 25.12.
  'Heilig Abend = 24.12
  '1. Weihnachtstag = 25.12
  '2. Weihnachstag = 26.12
  'Neujahr = 01.01
  'Trinitatis. Sonntag nach Pfingstsonntag.
  'Maifeiertag / Tag der Arbeit = 01.05
  'Erntedankfest = 1. Sonntag im Oktober (kath.) oder 1. So in 40KW oder Sonntag nach Michaelis ((evang., hl. Michael) das ist der 29. September)
  'sLine. Martin 11.November
  'Volkstrauertag. 22. Sonntag nach Trinitatis oder zweiten Sonntag vor erstem Advent, 3 Tage vor Buß-und Bettag
  'Allerheiligen 1.November
  'Silvester = 31.12
  
  'Valentinstag = +44
  'Fruehlingsanfang  + 79 (+ evtl. Schalttag)
  'Sommeranfang  + 171 (+ evtl. Schalttag)
  'Friedensfest (nur in Augsburg/Bayern)  + 219 (+ eventuell Schalttag)
  'Herbstanfang  + 275 (+ event. Schalttag)
  'Winteranfang  + 355 (+ event. Schalttag)
  
  'Jahreszeiten nördliche Erdhalbkugel
  '19/20/21 Maerz Fruehling (Spring)
  '20/21 Juni Sommer (Summer)
  '22/23 Sept. Herbst (Autum)
  '20/21/22 Dez. Winter (Winter)
  
  'Beginn Sommerzeit letzter Sonntag im Maerz
  'Beginn Winterzeit letzter Sonntag im Oktober
  
  ''__________________________________________________________________________________''
  'Programme mit Terminkalender, Bearbeitet: Jahr 2001, 2005, 2011, 2018, 2020
  
  'dateEasterDayOstern berechnen
  'PTB-Bundesanstalt, Deutschland = MEZ +1 Stunde, Deutschland = MEZ + 1 + 1 (Sommerzeit)
  'MEZ = Koordinierte Welt (UTC) + 1h
  'MESZ = UTC + 2h
  'Mitteleuropaeische Sommerzeit MESZ
  'Definitionen Zeit u.a. in DIN 1355, Mo = 1 Tag, So = 7 Tag (in VB So = 1, Sa = 7)
  
Catch 
  FMain.ErrorText
  
End

Public Function HolidaysPlusCalculate(Optional YDate As Date = Date) As String 
  'Calculate Holidays +Plus
  
  Dim sDatum As String
  Dim dateEasterDayOstern, hDate As Date
  Dim F, Z, D, W, T, P As String 
  Dim ssASpli, ssFSpli, ssDSpli As New String[]
  Dim A, sText, Sep, KA, KE As String 
  Dim it, iZahl As Integer
  Dim sNotExamples As String = String.LCase(("Ostersonntag") & ";" & ("Rosenmontag") & ";" & ("Pfingstsonntag") & ";" & ("Weihnachten") & ";")
  Dim sPath As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sPath = Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt", FMain.F_sPathHolidaysPlus_txt] 'FeiertagePlus01
  Sep = hTab 'gb.Tab 'Separator. Trenner
  KA = "#("
  KE = ")"
  'Tage vor/nach OsterSonntagDate:
  'Ostern ist am ersten Sonntag nach dem ersten Vollmond des Fruehlingsanfangs (21.03).
  'Bewegliche Feiertage z.B.:
  'Pfingstsonntag = + 49
  'Rosenmontag = -48
  'Unbewegliche Feiertage z.B.:
  '1. Weihnachtstag = 25.12
  dateEasterDayOstern = Date.EasterDay(Year(YDate)) '(YYYY)
  If IsDate(Str(dateEasterDayOstern)) = False Then 
    ' sDatum = Settings[FMain.Name &/ "OsterSonntag", sDatum] ' "mm/dd/yyyy"
    YDate = M03Feiertage.OsterterminDate(YDate) 'as Date
    sDatum = Format(YDate, "yyyy-mm-dd")
    dateEasterDayOstern = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
  Endif 
  'Example:  Settings[FMain.Name &/ "HolidaysPlus"] = Z0.Text & hTab & D0.Text & hTab & W0.Text & hTab & T0.Text & hReturn ' Ostern ... Z0 bis Z13
  
  A = Settings[FMain.Name &/ "sHolidaysPlus", Null] 
  If A = Null Then 
    If Exist(sPath) = True Then A = File.Load(sPath) 'alternative
  Endif
  
  If A Then 
    ssASpli = Split(A & hReturn, hReturn)
    For it = 0 To ssASpli.Max
      hDate = Null
      F = ssASpli[it]
      If F And String.InStr(String.LCase(F), String.LCase("HolidaysPlus")) > 0 Then 
        ssFSpli = Split(F & String(4, hTab), hTab)
        P = ssFSpli[0] 'Example: "HolidaysPlus01"
        Z = Replace(ssFSpli[1], "+", "") 'Example: -48 or Date
        D = ssFSpli[2] 
        W = ssFSpli[3] 
        T = ssFSpli[4] 
        
        If String.InStr(sNotExamples, String.LCase(T) & ";") = 0 Then  'Ostern, wihtout Examples: Rosenmontag -48, Pfingsten +49, Weihnachten 25.12. 
          If IsInteger(Z) = True Then  
            Try iZahl = CInteger(Z)
            Try hDate = DateAdd(dateEasterDayOstern, gb.day, iZahl) 'relative to Easterday  -48
          Else If D Like "*????-??-??*" Then 'HolidaysPlus10 > 13 =4x with fix date TestFeiertag 2020-01-04 
            ssDSpli = Split(D & "-" & "-", "-")
            If ssDSpli Then 
              D = Format(dateEasterDayOstern, "yyyy") & "-" & ssDSpli[1] & "-" & ssDSpli[2]
              sDatum = D
              hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
            Endif 
          Endif 
          If IsDate(Str(hDate)) = True Then D = Format(hDate, "yyyy-mm-dd")
          
          If D And T Then sText = sText & hTab & D & hTab & KA & T & KE & hReturn ' gb.Tab =hTab Example: TAB2018-12-31TAB#(Silvester)
        Endif 
      Endif
    Next 
  Endif 
  
  Return sText 
  ''___________________________________________________________''
  'Neu, Jahr 2018
  
Catch  
  FMain.ErrorText
  
End

Public Function OsterterminDate(Optional dateYear As Date = Date) As Date
  
  Dim dateEasterDayOstern As Date
  
  dateEasterDayOstern = Date.Easterday(Year(dateYear)) 'new in Gambas3
  
  ''Check:
  If IsDate(Str(dateEasterDayOstern)) = False Then 
    dateEasterDayOstern = Osterterminberechnen(dateYear)
  Endif 
  
  Return dateEasterDayOstern
  
  ''___________________________________________________________''
  'Neu, Jahr 2020
  
Catch  
  FMain.ErrorText
  
End

Public Function Osterterminberechnen(Optional dateYear As Date = Date) As Date
  'Calculate Easterday (Ostern)
  
  Dim K, M, S, A, D, R, OG, SZ, OE, OS, iRest As Integer
  Dim iJahr As Integer
  Dim dateEasterDayOstern As Date 
  ' Dim it As Integer
  ' Dim OT As String[] 'OsterTermin
  ' Dim sOTyyyymmmdd As String 
  
  'Jahreszeiten "nördliche" Erdhalbkugel
  '20/21 Maerz Fruehling
  '21/22 Juni Sommer
  '22/23 Sept. Herbst
  '21/22 Dez. Winter
  'Gueltigkeitsbereich ist vom Jahre 1583  - 8202
  ' If IsDate(Str(dateYear)) = False Then dateYear = Date
  If Not dateYear Then dateYear = Date
  iJahr = Year(dateYear) 'as Integer
  'JahrYYYY = 2012, 2018
  
  '*********************************************************
  'Diese Funktion rechnet das OsterSonntag-Datum des Vollmondes aus
  'For it = 2018 To 2040 'intern zur Kontrolle
  'iJahr = it
  K = Int(iJahr \ 100)
  M = 15 + Int((3 * K + 3) \ 4) - Int((8 * K + 13) \ 25)
  S = 2 - Int((3 * K + 3) \ 4)
  A = iJahr Mod 19
  D = (19 * A + M) Mod 30
  R = Int(D \ 29) + (Int(D \ 28) - Int(D \ 29)) * Int(A \ 11)
  OG = 21 + D - R ' Märzdatum des Ostervollmonds
  SZ = 7 - (iJahr + Int(iJahr \ 4) + S) Mod 7  'Datum des 1. Sonntags im März
  OE = 7 - (OG - SZ) Mod 7
  OS = OG + OE 'ist das Datum des Ostersonntags, als Datum im Monat März dargestellt. (Der 32. März entspricht also dem 1. April, usw.) 
  'März und Oktober haben laut DIN immer 31 Tage 
  If OS > 31 Then 
    iRest = OS - 31
    dateEasterDayOstern = Date(iJahr, 4, iRest) '> April
  Else 
    dateEasterDayOstern = Date(iJahr, 3, OS)  '< März
  Endif 
  
  'OG ist das Märzdatum des Ostervollmonds. Dies entspricht dem 14. Tag des ersten Monats im Mondkalender, genannt Nisanu. SZ ist das Datum des ersten Sonntags im März.
  'OS = OG + OE ist das Datum des Ostersonntags, als Datum im Monat März dargestellt. (Der 32. März entspricht also dem 1. April, usw.) 
  'Liegt der Ostertermin(OS)erst einmal fest, so berechnen sich daraus weitere besondere Kalenderdaten, und zwar 
  'OS - 46: Aschermittwoch,
  'OS + 39: Christi Himmelfahrt,
  'OS + 49: Pfingstsonntag,
  'OS + 60: Fronleichnam.
  'Osterfesttabelle
  'Osterfestdaten für die Jahre 1980 bis 2031, berechnet nach den oben angegebenen Formeln. Trotz aller Sorgfalt bei der Programmierung kann für die Richtigkeit der berechneten Daten keine Gewähr übernommen werden.
  'Im betrachteten Zeitraum wurden ermittelt 
  'als frühester Ostertermin: 23. März im Jahr 2008, 
  'als spätester Ostertermin: 24. April im Jahr 2011.
  
  ''Die Tabelle der OsterTermine:
  ' OT = ["1980-04-06", "1981-04-19", "1982-04-11", "1983-04-03", "1984-04-22", "1985-04-07", "1986-03-30", "1987-04-19", "1988-04-03",
  '   "1989-03-26", "1990-04-15", "1991-03-31", "1992-04-19", "1993-04-11", "1994-04-03", "1995-04-16", "1996-04-07", "1997-03-30", 
  '   "1998-04-12", "1999-04-04", "2000-04-23", "2001-04-15", "2002-03-31", "2003-04-20", "2004-04-11", "2005-03-27", "2006-04-16", 
  '   "2007-04-08", "2008-03-23", "2009-04-12", "2010-04-04", "2011-04-24", "2012-04-08", "2013-03-31", "2014-04-20", "2015-04-05", 
  '   "2016-03-27", "2017-16-04", "2018-04-01", "2019-04-21", "2020-04-12", "2021-04-04", "2022-04-17", "2023-04-09", "2024-03-31",
  '   "2025-04-20", "2026-04-05", "2027-03-28", "2028-04-16", "2029-04-01", "2030-04-21", "2031-04-13", "2032-03-28", "2033-04-17", 
  '   "2034-04-09", "2035-03-25", "2036-04-13", "2037-04-05", "2038-04-25", "2039-04-10", "2040-04-01"]
  'bestätigte Zahlen in ptb.de 1980-2031, wikipedia.de 2032-2040    
  
  'sOTyyyymmmdd = Format(dateEasterDayOstern, "yyyy-mm-dd")
  'If OT.Find(sOTyyyymmmdd, gb.String) = -1 Then Print sOTyyyymmmdd
  'Next 'it
  '*********************************************************
  
  ''Check:
  If IsDate(Str(dateEasterDayOstern)) = False Then dateEasterDayOstern = Date.Easterday(Year(dateYear)) 'neu in Gambas3
  ' Settings[FMain.Name &/ "dateEasterDayOstern"] = Format(dateEasterDayOstern, "yyyy-mm-dd") 
  
  Return dateEasterDayOstern 'as Date —▶
  
  ''________________________________________________________________''
  'Quelle: Vorlage PTB, selbst angepaßt
  'https://www.ptb.de
  'ptb, Physikalisch - Technische Bundesanstalt
  'Ostertermine 1980 - 2031
  'bearbeitet 2012, 2018, 2020
  
Catch  
  FMain.ErrorText
  
End



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form22DialogOpenSave.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form22DialogOpenSave.class
49,3 KB
' Gambas class file

'F_ = Form
Public F_bChangeON As Boolean '=False (Default)
Public F_bESCpressedON As Boolean
Public F_bMovingON As Boolean
Public F_iColorSelectBackground As Integer = Color.Lighter(Color.LightBackground)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iFileMusterType As Integer
Public F_iOnly1x As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sDirFileInput As String
Public F_sDirFileMuster As String
Public F_sDirFileOutput As String
Public F_sFileEndEXT As String 
Public F_sForm As String = Me.Name 
Public F_sOpenOrSave As String = "open"
Public F_ssDialogFilter As String[]

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Me.Tag 
  If Not sPath Then sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form22DialogOpenSave.Window.Maximized = False Then
    Form22DialogOpenSave.Window.Maximized = True
  Else
    Form22DialogOpenSave.Window.Maximized = False
    Form22DialogOpenSave.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub _call(Optional sDirFile As String) As String    'Without Form_Open(), Form_Close()
  
  If F_iOnly1x = 0 Then FormStart()
  
  Form22DialogOpenSave.Window.Title = Application.Name '& " - " & ("Dialog-Fenster")
  If Not Form22DialogOpenSave.Window.Icon Then Form22DialogOpenSave.Window.Icon = FMain.Window.Icon
  F_sDirFileInput = sDirFile
  
  Select Case Me.ShowModal() '——▶ Form_Activate(), FormStart(), ... ——▶
    Case 0 ''Cancel
      SettingsReadSave("save")
      Return Null  ' ◀—— Return to Send-Form    Me.Close(0), OpenSaveCloseG(), ... ◀——
    Case 1 ''Open
      SettingsReadSave("save")
      Return F_sDirFileOutput
    Case 2 ''Save
      SettingsReadSave("save")
      Return F_sDirFileOutput
  End Select
  
Catch 
  FMain.ErrorText
  
End 

' Public Sub Form_Open()
'   
' End

' Public Sub Form_Close() 
'
' End

Public Sub Form_Activate()
  ''see —▶Public Sub _call() ... Form_Activate()... Function CheckTextOrImage()... Sub OpenSaveCloseG() ◀—
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    FormStart()
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFileMuster()
  
  Dim sFile As String
  Dim iType As Integer
  
  sFile = File.Name(F_sDirFileMuster)
  
  Select Case sFile
    Case File.Name(Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt])
      iType = 1 ' "terminwecker"
      F_sFileEndEXT = ".txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear])
      iType = 1 ' "terminwecker" 
      F_sFileEndEXT = "_everyyear.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt])
      iType = 1 ' "terminwecker" 
      F_sFileEndEXT = "_until.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt])
      iType = 1 ' "terminwecker"   
      F_sFileEndEXT = "_projectsnames.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt])
      iType = 2 ' "project"    
      F_sFileEndEXT = "_projectsalltimes.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathProject_txt", FMain.F_sPathProject_txt])
      iType = 2 ' "project" 
      F_sFileEndEXT = "_" & Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName] & ".txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt])
      iType = 3 ' "color"   
      ' #terminwecker 3.0.364
      ' color="65280"
      F_sFileEndEXT = "_colors.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf])
      iType = 4 ' "config"   
      ' Example File-Muster:
      ' [FMain]
      ' Left=1440
      ' ... 
      F_sFileEndEXT = ".conf"
    Case Like "*" & Application.Name & "*.conf"
      iType = 4 ' "config"   
      ' Example File-Muster:
      ' [FMain]
      ' Left=1440
      ' ... 
      F_sFileEndEXT = ".conf"
    Case File.Name(Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt])
      iType = 5 ' "config"  
      'name=text 
      ' ...
      F_sFileEndEXT = "_bookmarks.txt" 
    Case File.Name(Settings[FMain.Name &/ "F_sPathTimerPlus_txt", FMain.F_sPathTimerPlus_txt])
      iType = 6 ' "config" 
      F_sFileEndEXT = "_timerplus.txt"
    Case Like "*" & File.Name(Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt]) & "*"
      iType = 7 ' "clockmuster" 
      ' #terminwecker 3.0.353 Clock-Levels
      ' #level number left selected path '0 1 2 3 4
      ' level=begin
      ' level=163=0=1==
      ' level=109=101=1==
      ' level=71=202=1==
      ' level=59=303=1==
      ' level=end
      ' ...
      F_sFileEndEXT = "_clockmuster.txt"
    Case LCase(Application.Name) & "-" & "demo_clockmuster.txt" 'Text-File
      iType = 7 ' "clockmuster" 
      F_sFileEndEXT = "_clockmuster.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt", FMain.F_sPathPhotoSubtitleDate_txt])
      iType = 8 ' "config" 
      ' #terminwecker 3.0.366
      ' quote="tagesschau.de"
      ' ...
      F_sFileEndEXT = "_subtitledate.txt"
    Case File.Name(Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt", FMain.F_sPathHolidaysPlus_txt])
      iType = 9 ' "config" 
      ' HolidaysPlus00  0  2022-04-17  So  Ostersonntag
      ' HolidaysPlus01  
      F_sFileEndEXT = "_holidaysplus.txt"
      
    Case File.Name(Settings[FMain.Name &/ "F_sPathMusicStandard_mp3", FMain.F_sPathMusicStandard_mp3])
      iType = 10
      F_sFileEndEXT = ".mp3"
    Case Like "*.mp3"
      iType = 10
      F_sFileEndEXT = ".mp3"
    Case File.Name(Settings[FMain.Name &/ "F_sPathClockBackground_png", FMain.F_sPathClockBackground_png])
      iType = 11
      F_sFileEndEXT = ".png" 'unused???
    Case Like "*.png"
      iType = 11
      F_sFileEndEXT = ".png" 'unused???
  End Select
  
  F_iFileMusterType = iType
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckTextOrImage(Optional sDirFile As String = "") As String
  
  Dim sExt, sFile, sOldyears As String
  Dim iMuster As Integer
  
  If F_bChangeON = True Then 
    sFile = File.Name(sDirfile) 
    sOldyears = "_oldyears.txt"
    sExt = String.LCase(File.Ext(sDirFile))
    ''Text: *.txt...
    
    If F_sOpenOrSave = "open" Then 
      If Exist(F_sDirFileInput) = False And IsDir(File.Dir(F_sDirFileInput)) = True Then File.Save(F_sDirFileInput, "") 'Empty (leere Datei erstellen) 
    Endif
    
    If Exist(sDirFile) = True Then 
      'Check file inside:
      ' sInfo = M01Functions.FileCheckTypeExtension(sDirFile, False) 'True=MimeType
      
      Select Case F_iFileMusterType
        Case 1
          If M01Functions.isTerminweckerFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*" & sOldyears & "*" Then iMuster = 1
        Case 2 
          If M01Functions.isProjectFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*project*" & sOldyears & "*" Then iMuster = 1
        Case 3
          If M01Functions.isColorFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*color*" Then iMuster = 1
        Case 4
          If M01Functions.isConfigurationFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "conf" And sFile Like "*terminwecker*" Then iMuster = 1
        Case 5
          If M01Functions.isBookmarkFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*bookmark*" Then iMuster = 1
        Case 6
          If M01Functions.isTimerPlusFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*timerplus*" Then iMuster = 1
        Case 7
          If M01Functions.isTerminweckerClockMusterFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*muster*" Then iMuster = 1
        Case 8
          If M01Functions.isPhotoSubtitleDateFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*subtitle*" Then iMuster = 1
        Case 9
          If M01Functions.isHolidaysPlusFile(sDirFile) = True Then iMuster = 1 
          If iMuster = 0 And sExt = "txt" And sFile Like "*terminwecker*holidays*plus*" Then iMuster = 1
        Case 10
          If M01Functions.isMusic(sDirFile) = True Then iMuster = 1 
        Case 11
          If M01Functions.isPicForPictureBox(sDirFile) = True Then iMuster = 1 
      End Select 
      
      If iMuster = 1 And Stat(sDirFile).Size = 0 Then iMuster = 2
      
      If iMuster = 0 Then  
        LabelFileNameInfo.Foreground = Color.Red
        TextBoxPath.Background = Color.SoftRed
        PicBoxLED.Picture = PicTemplateLEDred.Picture
      Else If iMuster = 1 Then  
        LabelFileNameInfo.Foreground = Color.DarkGreen
        TextBoxPath.Background = Color.SoftGreen
        PicBoxLED.Picture = PicTemplateLEDgreen.Picture
      Else 
        LabelFileNameInfo.Foreground = Color.DarkGray
        TextBoxPath.Background = Color.LightGray
        PicBoxLED.Picture = PicTemplateLEDyellow.Picture  '.Image.Desaturate().Picture 'Grayscale
      Endif 
    Endif 
    
    If F_sOpenOrSave = "open" And Exist(sDirFile) = True Then 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then '0=Read
        TextBoxPath.Foreground = Color.DarkGray
        TextBoxPath.Background = Color.LightGray
        PicBoxLED.Picture = PicTemplateClosed.Picture
      Endif
    Endif 
    
    If F_sOpenOrSave = "save" And Exist(sDirFile) = True Then 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 1) = False Then '1=Write
        TextBoxPath.Foreground = Color.DarkGray
        TextBoxPath.Background = Color.LightGray
        PicBoxLED.Picture = PicTemplateClosed.Picture
      Endif
    Endif 
    
    If TextBoxPath.Background = Color.SoftGreen Then 
      ButtonSave.Background = Color.SoftGreen
      ButtonOpen.Background = Color.SoftGreen
    Else 
      ButtonSave.Background = Color.Default 
      ButtonOpen.Background = Color.Default 
    Endif 
    
  Endif 
  
  Return sDirFile
  
Catch 
  FMain.ErrorText
  
End

Public Sub OpenSaveCloseG(Optional sOpenSaveClose As String = "open")
  
  Dim sExt1, sExt2 As String 
  Dim sMessage As String
  
  Select Case sOpenSaveClose
      
    Case "close"
      F_sDirFileOutput = Null
      Me.Close(0)
      
    Case "open"
      ' F_sDirFileOutput = FileChooser1.Dir &/ File.Name(TextBoxPath.Text) 'FileChooser1.SelectedPath
      F_sDirFileOutput = FileChooser1.SelectedPath '/dir/file.ext
      F_sDirFileOutput = CheckTextOrImage(F_sDirFileOutput)
      If Exist(F_sDirFileOutput) = False Then F_sDirFileOutput = Null
      Me.Close(1)
      
    Case "save"
      F_sDirFileOutput = FileChooser1.Dir &/ File.Name(TextBoxPath.Text)
      F_sDirFileOutput = CheckTextOrImage(F_sDirFileOutput)
      ' If Exist(F_sDirFileOutput) = True Then F_sDirFileOutput = Null
      sExt1 = String.LCase(File.Ext(F_sDirFileInput))
      sExt2 = String.LCase(File.Ext(F_sDirFileOutput))
      If sExt1 And sExt1 <> sExt2 Then F_sDirFileOutput = File.SetExt(F_sDirFileOutput, sExt1)
      
      If M01Functions.FileNameCheckWithoutLastbackup(F_sDirFileOutput) = F_sDirFileOutput Then 
        If Exist(F_sDirFileOutput) = True Then 
          sMessage = "<h3><font color=darkgreen>" & ("Die Datei existiert schon") & Space(1) & "</font></h3>"
          sMessage &= "<h2><font color=red>" & ("Überschreiben, aktualisieren?") & "</font></h2>"
          sMessage &= "<h3>" & "● " & "<font color=darkgreen>" & File.Dir(F_sDirFileOutput) &/ "</font><font color=red>" & File.Name(F_sDirFileOutput) & "</font>" & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(F_sDirFileOutput) & "</b></font>" & Space(1) & "<font color=gray>" & M01Functions.FileSizeLongText(Stat(F_sDirFileOutput).Size) & "</font></h3>" 
          PanelBorder.Visible = False 
          PanelOverwrite.Background = Color.Background
          PanelOverwrite.Visible = True 
          PanelOverwrite.Raise
          TextLabelHTML.Text = sMessage
          '—▶MessageOverwrite()
        Else 'New File
          Me.Close(2)
        Endif
      Endif 
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub MessageOverwrite(Optional iOverwrite1_Cancel2 As Integer = 2)
  
  Select Case iOverwrite1_Cancel2
    Case 1 'Save
      Me.Close(2)
    Case 2 'Cancel
      ''...
  End Select
  PanelOverwrite.Visible = False 
  PanelBorder.Visible = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim sDir, sFile, sDirFile As String
  
  'Me. = 
  If Desktop.Platform = "x11" Then Me.TopOnly = True 
  Menu1.Visible = False

  Me.Title = Application.Name & " - " & ("Dialog-Fenster")
  
  F_bChangeON = False
  SettingsReadSave("read")
  FormBackgroundColor()
  
  WindowStretchCursor()
  CheckFileMuster()
  
  Form_Resize()
    
  ''From File:
  sDirFile = F_sDirFileInput
  If Not sDirFile Then sDirFile = FilePathForm()
  
  If String.InStr(F_sOpenOrSave, "open") > 0 Then 
    ButtonOpen.Visible = True 
    LabelTitle1.Text = ("Öffnen") & "..."
  Else 
    ButtonOpen.Visible = False 
    LabelTitle1.Text = ("Speichern") & "..."
  Endif 
  LabelTitle1b.Text = LabelTitle1.Text
  ButtonSave.Visible = Not ButtonOpen.Visible
  
  LabelInfoG(sDirFile)
  LabelInfo.ToolTip = LabelInfo.Text
  LabelPathType.Text = ("Beispiel Datei-Typ") & ": " & File.Dir(F_sDirFileInput) &/ File.BaseName(F_sDirFileInput) & "<font color=blue><b>" & "." & File.Ext(F_sDirFileInput) & "</b></font>"  
  LabelPathType.ToolTip = F_sDirFileInput
  AplusG()
  
  If sDirFile Then 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(File.Name(sDirFile))
  Endif 
  
  TextBoxPath.Background = F_iColorSelectGreen150
  TextAreaPreview.Background = F_iColorSelectGreen150
  ButtonOpen.ToolTip = ("Öffnen") & ": " & Space(1) & sDirFile
  ButtonSave.ToolTip = ("Speichern") & ": " & Space(1) & sDirFile
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  TextBoxPath.SetFocus
  
  If F_ssDialogFilter Then 
    FileChooser1.Filter = F_ssDialogFilter '[Filter1, Filtertext1, ...]
  Else 
    FileChooser1.Filter = FileChooserFilterReturn(sDirFile) 'no Dialog, Filter
  Endif 
  
  If F_sOpenOrSave = "openbackup" Then sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  If IsDir(sDir) = False Then sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  
  FileChooser1.FilterIndex = 0 '-1 '-1 all files (*)
  
  If IsDir(sDir) = True Then FileChooser1.Dir = sDir
  If Exist(sDirFile) = True Then FileChooser1.FileView.Current = sFile
  ' FileChooser1.ShowDetailed = True 'gb.form: warning: 'FileView.ShowDetailed' is deprecated. Use 'FileView.View' instead.
  FileChooser1.FileView.View = True 
  FileChooser1.ShowPreview = False 
  ' FileChooser1.ShowBookmark = True 
  FileChooser1.Font.Size = Settings[F_sForm &/ "FileChooser1.Font.Size", FileChooser1.Font.Size]
  AplusG()
  
  ' F_bListChanged = False
  ' F_bChangeON = True  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() '▼Level Bottom▼
  ButtonSave.Raise()
  IconError.Raise()
  PanelPreview.Raise()
  ButtonRead.Raise()
  ButtonFileFind.Raise()
  ProgressBar1.Raise()
  WindowStretch.Raise() '▲Level Top▲
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileChooserFilterReturn(Optional sDirFile As String = "") As String[]
  
  Dim ssFilter As String[] 
  Dim sFilePattern, sFilePatternDate, sTitle, sDate, sDir, sDirBackup, sFile, sName, sExt As String 
  Dim it As Integer
  
  sDirBackup = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  sFilePattern = Replace(sFile, Space(1), "*") & "*" ' sFile & "*" 
  sFilePattern = Replace(sFilePattern, "-", "*")
  sFilePattern = Replace(sFilePattern, ",", "*")
  ' sFilePattern = Replace(sFilePattern, ".", "*")
  sFilePattern = Replace(sFilePattern, "_", "*")
  
  it = Dir(sDir, sFilePattern, gb.File).Max '-1 not found
  If it = -1 Then sFilePattern = "*" & sFilePattern
  sFilePatternDate = "*" & F_sFileEndEXT & "*" & "_date_" & "*" '& "." & File.Ext(sFile)  'File.ext_backup_date_*
  
  ssFilter = New String[]
  
  ssFilter.Add(sFilePattern) ''Example: *terminwecker*.txt, "*terminwecker*project*.txt"
  ssFilter.Add(("Letzter Datei-Name"))
  
  ssFilter.Add("*.txt")
  ssFilter.Add(("Nur-Text"))
  
  If M01Functions.isTerminweckerFile(sDirFile) = True Then 
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*" & Application.Name & "*.txt*;*" & sExt & ";")
    ssFilter.Add(Application.Name & Space(1) & ("Dateien"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Text Termine")
  Else If M01Functions.isTerminweckerClockMusterFile(sDirFile) = True Then 
    sExt = "clockmuster.txt"
    ssFilter.Add("*clockmuster.txt*")
    ssFilter.Add(("Uhr-Muster-Dateien"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Text Uhr-Muster")
  Else If M01Functions.isPicForPictureBox(sDirFile) = True Then 
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*.png;*.jpg;*.jpeg;*.bmp;*.xpm;*.svg;*.ppm;*.xpm;*.tiff;*.gif;*" & sExt & ";")
    ssFilter.Add(("Bild-Dateien"))
    FileChooser1.View = FileView.Preview
    sTitle = ("Bild")
  Else If M01Functions.isColorFile(sDirFile) = True Then 
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*" & Application.Name & "*.txt*;*" & sExt & ";")
    ssFilter.Add(Application.Name & Space(1) & ("Farben"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Text Farb-Palette")
  Else If M01Functions.isConfigurationFile(sDirFile) = True Then 
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*" & Application.Name & "*.conf*;*" & sExt & ";")
    ssFilter.Add(Application.Name & Space(1) & ("Konfiguration"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Text Einstellungen")
  Else If M01Functions.isMusic(sDirFile) = True Then
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*.mp3;*.mid;*.wav;*.ogg;*" & sExt & ";")
    ssFilter.Add(("Musik-Dateien"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Musik")
  Else If M01Functions.isHolidaysPlusFile(sDirFile) = True Then
    sExt = "." & File.Ext(sDirFile)
    ssFilter.Add("*_holidaysplus.txt;*" & sExt & ";")
    ssFilter.Add(("Feiertage Gedenktage Timerplus+"))
    FileChooser1.View = FileView.Detailed
    sTitle = ("Text Feiertage")
  Endif
  If Exist(sDirFile) = True Then 
    If Stat(sDirFile).Size = 0 Then sTitle = ""
  Endif 
  
  Me.Title = Application.Name & " - " & sTitle & " *" & F_sFileEndEXT
  sDate = Format(DateAdd(Now, gb.Hour, -1), "yyyy-mm-dd-hh")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(("vor 1 Stunde"))
  
  sDate = Format(Date, "yyyy-mm-dd")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(("Heute"))
  
  sDate = Format(DateAdd(Date, gb.Day, -1), "yyyy-mm-dd")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(("Gestern") & Space(1) & sDate)
  
  sDate = Format(Date, "yyyy-mm-")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(Format(Date, "yyyy mmmm"))
  
  sDate = Format(DateAdd(Date, gb.Month, -1), "yyyy-mm-")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(Format(DateAdd(Date, gb.Month, -1), "yyyy mmmm"))
  
  sDate = Format(Date, "yyyy")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(sDate & Space(1) & ("Jahr"))
  
  sDate = Format(DateAdd(Date, gb.Year, -1), "yyyy")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(sDate & Space(1) & ("Jahr"))
  
  sDate = Format(Date, "yyyy-mm-dd")
  ssFilter.Add("*" & F_sFileEndEXT & "*" & sDate & "*")
  ssFilter.Add(("Heute"))
  
  sName = "*" & Application.Name
  
  ''Extra:
  If sFile Like "*terminwecker.txt*" Or sFile Like "*oldyears*.txt*" Or sFile Like "*project*.txt*" Then 
    sFilePattern = sName & "_oldyears" & "." & File.Ext(sFile) & "*" & ";" & sName & "_vergangene" & "." & File.Ext(sFile) & "*" & ";"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Ausgelagert, vergangene Jahre"))
  Endif
  If sDirFile Like "*geburtstag*" Or sDirFile Like "*birthday*" Or sDirFile Like "*everyyear*" Then 
    sFilePattern = sName & "_everyyear" & "." & File.Ext(sDirFile) & "*" & ";" & sName & "_geburtstage" & "." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Geburtstage *Jedes Jahr"))
  Endif
  If sDirFile Like "*.conf" Or sDirFile Like "*settings*" Then 
    sFilePattern = sName & "." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Configuration, Einstellungen, Settings"))
  Endif
  If sDirFile Like "*lastnotice*" Then 
    sFilePattern = sName & "*lastnotice." & File.Ext(sDirFile) & "*"
    ssFilter.Add(sFilePattern)
    ssFilter.Add(("Letzter Zeilen-Eintrag"))
  Endif
  
  'autom. Append (Anhang) ["*.*", "All Files"] = FilterIndex=-1
  If File.BaseName(sDirFile) = "" Then sDirFile = sDirFile &/ ("datei") & "." & File.Ext(sDirFile)
  If File.BaseName(sDirFile) <> "" And File.Ext(sDirFile) = "" Then sDirFile = sDirFile & "." & "txt"
  
  ' FileChooser1.Filter = ssFilter '[Filter1, Filtertext1, ...]
  ' Dialog.Filter = ssFilter '[Filter1, Filtertext1, ...]
  ' Dialog.Path = sDirFile
  Return ssFilter 
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub FileChooser1_Change() '/home/<user>/.config/gambas3/terminwecker.conf
  
  Dim sDirFile As String
  
  If F_bChangeON = True Then 
    sDirFile = FileChooser1.SelectedPath '.Multi = False, only one File
    If IsDir(File.Dir(sDirFile)) = True And Exist(sDirFile) = True Then  
      TextBoxPath.SelectAll
      TextBoxPath.Insert(File.Name(sDirFile))
      LabelInfoG(sDirFile) 
      CheckTextOrImage(sDirFile)
    Endif 
    If String.LCase(TextBoxPath.Text) Like "*termin*.txt" Then 
      LabelInfo.Background = F_iColorSelectBackground
    Else 
      LabelInfo.Background = Color.Default
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return Then 
    If Exist(FileChooser1.Dir &/ File.Name(TextBoxPath.Text)) = True Then 
      CheckTextOrImage(FileChooser1.Dir &/ File.Name(TextBoxPath.Text))
    Else 
      FileChooser1.Filter = ["*" & Replace(TextBoxPath.Text, Space(1), "*") & "*.*", ("*Sucheingabe*")]
      FileChooser1.FilterIndex = 0
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoG(Optional sInfoText As String = "") '<HTML>
  
  Dim sDirFile As String 
  
  sDirFile = sInfoText
  If Exist(sDirFile) = True Then
    sInfoText = M01Functions.InfoDirFileLastModifiedSizeMimeHTML(sDirFile) 'as String <HTML>
  Endif 
  
  LabelInfo.Visible = True 
  If sInfoText Then
    If Exist(sDirFile) = True Then
      LabelInfo.Text = ("Info") & ": " & Space(1) & sInfoText
    Else 
      If F_sOpenOrSave = "open" Then 
        LabelInfo.Text = ("Info") & ": " & Space(1) & sInfoText & Space(1) & "<font color=red>" & ("Fehlt") & "</font>"
      Else 
        LabelInfo.Text = ("Info") & ": " & Space(1) & sInfoText & Space(1) & "<font color=red>" & ("Frei") & "</font>"  
      Endif 
    Endif 
    LabelInfo.Background = F_iColorSelectBackground
  Else 
    LabelInfo.Text = sInfoText
    LabelInfo.Background = Color.Default
  Endif 
  LabelInfo.ToolTip = sDirFile
  LabelInfo2.Text = LabelInfo.Text 
  LabelInfo2.Tooltip = sDirFile
  LabelInfo2.Background = LabelInfo.Background
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileChooser1SelectPath(Optional sDirFile As String = "")
  
  Dim sDir, sFile As String 
  
  If Exist(sDirFile) = False Then sDirfile = FilePathForm()
  If InStr(String.LCase(sDirFile), "/media") > 0 And IsDir("/media") = True Then FileChooser1.Dir = "/media"
  
  FileChooser1.Dir = User.Home
  
  If Exist(sDirFile) = True Then
    If IsDir(sDirfile) = True Then 
      sDir = sDirfile
      sFile = ""
    Else 
      sDir = File.Dir(sDirFile) 
      sFile = File.Name(sDirfile)
    Endif 
    
    FileChooser1.Dir = sDir 
    FileChooser1.DirView.SetFocus
    
    If sFile Then 
      FileChooser1.FileView.Current = sFile
      FileChooser1.FileView.SetFocus
      FileChooser1.FilterIndex = 0 '-1
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize() 'in Modal! Not all functions possible (Einige Funktionen sind nicht aktiv)
  
  Dim iW, iH, iPH As Integer
  
  'Me.Resizable = False '?
  '********************
  iPH = 40 'as Integer, Panel Height
  '********************

  If Form22DialogOpenSave.Width < 200 Then Form22DialogOpenSave.Width = 200
  If Form22DialogOpenSave.Height < 200 Then Form22DialogOpenSave.Height = 200

  ' PicBackground.Move(0, 0, Form22DialogOpenSave.ClientW, Form22DialogOpenSave.ClientH)
  PicBackground.Move(0, 0, Form22DialogOpenSave.W, Form22DialogOpenSave.H)

  ' WindowStretch.Visible = False 'no stretch/resize
  
  iW = PicBackground.Width / 100 * 3 ' Randbreite
  iH = PicBackground.Height / 100 * 3
  
  IconError.Move(Form22DialogOpenSave.ClientW - 32, 0, 32, 32)
  
  If F_bMovingON = False Then
  '   FileChooser1.Visible = False
  ' Else 
    ''Panel:
    ' PanelBorder.Move(iW, iH, Form22DialogOpenSave.ClientW - (iW * 2), Form22DialogOpenSave.ClientH - (iH * 2))
    PanelBorder.Move(iW, iH, PicBackground.W - (iW * 2), PicBackground.H - (iH * 2))
    LabelTitle1.Move(0, 0, PanelBorder.W, LabelTitle1.Font.TextHeight(LabelTitle1.Text))
    LabelTitle1b.Move(LabelTitle1.Left - 2, LabelTitle1.Top + 2, LabelTitle1.Width, LabelTitle1.Height)
    LabelTitle1b.Font = LabelTitle1.Font
    ListAplus.Move(PanelBorder.W - (iPH * 6), LabelTitle1.Top, iPH, LabelTitle1.H)
    ButtonRead.Move(PanelBorder.W - (iPH * 5), LabelTitle1.Top, iPH * 4, LabelTitle1.H)
    ButtonOpenSave.Move(PanelBorder.W - iPH, LabelTitle1.Top, iPH, LabelTitle1.H)
    
    FileChooser1.Move(0, LabelTitle1.Top + LabelTitle1.H, PanelBorder.W, PanelBorder.H - (iPH * 5))
    
    PanelPath.Move(0, FileChooser1.Top + FileChooser1.H, FileChooser1.W, iPH)
    LabelFileNameInfo.Move(0, 0, iPH * 2.5, iPH)
    TextBoxPath.Move(LabelFileNameInfo.Left + LabelFileNameInfo.W, 0, PanelPath.W - (iPH * 4.5), iPH)
    ButtonFileFind.Move(TextBoxPath.Left + TextBoxPath.W, 0, iPH, iPH)
    PicBoxLED.Move(ButtonFileFind.Left + ButtonFileFind.W, 0, iPH, iPH)
    
    LabelPathType.Move(0, PanelPath.Top + PanelPath.H, PanelPath.W - (iPH * 3), iPH)
    ButtonDirAlternative.Move(FileChooser1.W - (iPH * 4), LabelPathType.Top, iPH, iPH)
    ButtonDirStandard.Move(FileChooser1.W - (iPH * 3), LabelPathType.Top, iPH, iPH)
    ButtonDirBackup.Move(FileChooser1.W - (iPH * 2), LabelPathType.Top, iPH, iPH)
    PicBoxTrashOpen.Move(FileChooser1.W - (iPH * 1), LabelPathType.Top, iPH, iPH)
    ProgressBar1.Move(0, TextBoxPath.Top + TextBoxPath.H, FileChooser1.W, iPH)
    LabelInfo.Move(0, LabelPathType.Top + LabelPathType.H, FileChooser1.W, iPH)
    
    ButtonOpen.Move(0, LabelInfo.Top + LabelInfo.H, PanelBorder.W / 2, iPH)
    ButtonSave.Move(ButtonOpen.Left, ButtonOpen.Top, ButtonOpen.W, ButtonOpen.H)
    ButtonCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, ButtonSave.W, iPH)
    
    ''Panel:
    PanelPreview.Move(PanelBorder.Left, PanelBorder.Top + ButtonRead.H, PanelBorder.W, PanelBorder.H - ButtonRead.H)
    TextAreaPreview.Move(0, 0, PanelPreview.W, PanelPreview.H - iPH - iPH)
    LabelInfo2.Move(0, TextAreaPreview.Top + TextAreaPreview.H, TextAreaPreview.W, iPH)
    PanelPreviewCancel.Move(0, LabelInfo2.Top + LabelInfo2.H, LabelInfo2.W, iPH)
    
    ''PanelOverwrite:
    PanelOverwrite.Move(PanelBorder.Left, PanelBorder.Top, PanelBorder.W, PanelBorder.H)
    TextLabelHTML.Move(0, 0, PanelOverwrite.W, PanelOverwrite.H - ButtonSave.H)
    ButtonOverwrite.Move(0, TextLabelHTML.Top + TextLabelHTML.H, PanelOverwrite.W / 2, ButtonSave.H)
    ButtonOverwriteCancel.Move(ButtonOverwrite.Left + ButtonOverwrite.W, ButtonOverwrite.Top, PanelOverwrite.W / 2, ButtonSave.H)
    
    ''Stretch:
    WindowStretch.Move(PicBackground.W - iPH - iW, PicBackground.H - iPH - iH, iPH, iPH) 'quadratisch
    RaiseOrder()
    FileChooser1.Visible = True
    Print "Form_Resize"
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadPreviewG()
  
  Dim sDirFile As String 
  
  PanelPreview.Visible = Not PanelPreview.Visible 
  
  If PanelPreview.Visible = True Then 
    PanelPreview.Raise()
    PanelPreview.Background = Color.Background
    sDirFile = FileChooser1.SelectedPath
    F_bChangeON = False 
    TextAreaPreview.Background = F_iColorSelectGreen150
    TextAreaPreview.SelectAll
    TextAreaPreview.Insert(File.Load(sDirFile))
    F_bChangeON = True
  Else 
    TextAreaPreview.Clear
  Endif 
  ButtonOpenSave.Enabled = PanelPreview.Visible
  
Catch 
  FMain.ErrorText
  
End

Public Sub SavePreviewG()
  
  Dim sDirFile, sDir, sFile, sMessage As String 
  
  sDirFile = LabelInfo2.Tooltip
  sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  
  sMessage = "<h1><font color=blue>" & "● " & ("Speichern") & "</font></h1>"
  If Exist(sDirFile) = False Then 
    sMessage &= "<h2><font color=red>" & ("Datei fehlt") & "</font></h2>"
    sMessage &= ("Ordner getrennt? Verschoben? Gelöscht im Papierkorb?")
  Endif
  If String.InStr("txt;csv", String.LCase(File.Ext(sDirFile))) = 0 Then 
    sMessage &= "<h2><font color=red>" & ("Änderung nicht empfohlen") & "</font></h2>"
    sMessage &= ("Nur einfache Text-Dokumente speichern (*.txt;*.csv;)")
  Endif  
  sMessage &= "<h2><font color=grey>" & sDir & "/" & "<font color=red>" & sFile & "</font>" & "</font></h2>"
  sMessage &= LabelInfo2.Text 
  sMessage &= "<br>"
  sMessage &= "<h1><font color=blue>" & "○ " & ("Speichern als") & "..." & "</font></h1>"
  sMessage &= "<h2><font color=grey>" & sDir &/ "<font color=red>" & "..." & "?" & "</font>" & "</font></h2>"
  sMessage &= "<br>"
  sMessage &= "<hr>" '--------------
  sMessage &= "<h3><font color=grey>" & ("Sicherungskopie in") & ": " & "<br>" & Settings[FMain.Name &/ "F_sDirBackup", "?"] &/ "..." & "?" & "</font></h3>"
  
  Select Case Message.Question(sMessage, "● " & ("Speichern") & Space(1) & ("und überschreiben!"), "○ " & ("Speichern als...") & ("andere Daei"), ("Abbrechen"))
    Case 1
      sDirFile = M01Functions.FileTextPlus(sDirFile, TextAreaPreview.Text, True) ' TRUE=overwrite (überschreiben)
      
    Case 2
      ''Dialog:
      sDirFile = M01Functions.FileDialogPathReturn(sDirFile, "save", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Save:
      sDirFile = M01Functions.FileTextPlus(sDirFile, TextAreaPreview.Text, True) ' TRUE=overwrite
      
    Case 3 'Cancel
      Goto JumpEnd
      
  End Select

  If Exist(sDirFile) = True Then
    LabelInfo2.Text = M01Functions.InfoDirFileLastModifiedSizeMimeHTML(sDirFile) 'as String <HTML>
    F_bChangeON = False
    TextAreaPreview.Background = F_iColorSelectGreen150
  Else 
    LabelInfo2.Text = sDirFile & Space(1) & "<font color=red>" & ("Fehlt") & "</font>"
  Endif 
  
  JumpEnd:
  
  F_bChangeON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_Change()
  
  CheckTextOrImage(FileChooser1.Dir &/ File.Name(TextBoxPath.Text))
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaPreview_MouseDown()
  If F_bChangeON = True Then 
    TextAreaPreview.Background = Color.White
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaPreview_Change()
  If F_bChangeON = True Then 
    TextAreaPreview.Background = Color.White
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form22DialogOpenSave.Left]
      iY = Settings[F_sForm &/ "Top", Form22DialogOpenSave.Top]
      iW = Settings[F_sForm &/ "Width", Form22DialogOpenSave.W]
      iH = Settings[F_sForm &/ "Height", Form22DialogOpenSave.H]
      ' Form22DialogOpenSave.Move(iX, iY, iW, iH)
      ' Form22DialogOpenSave.FullScreen = True 
      ' Form22DialogOpenSave.Maximized = True
      FileChooser1.ShowPreview = Settings[F_sForm &/ "FileChooser1.ShowPreview", FileChooser1.ShowPreview] 
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form22DialogOpenSave.Left
      Settings[F_sForm &/ "Top"] = Form22DialogOpenSave.Top
      Settings[F_sForm &/ "Width"] = Form22DialogOpenSave.Width
      Settings[F_sForm &/ "Height"] = Form22DialogOpenSave.Height
      Settings[F_sForm &/ "FileChooser1.ShowPreview"] = FileChooser1.ShowPreview 'True/False, show image thumbnails
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  Me.Visible = False 
  M01Functions.ErrorMessages()
  Me.Visible = False
  Wait 1
  Me.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = FileChooser1.SelectedPath  'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub FindLatestFile()
  
  Dim sDirFile, sSearchPattern, sMessage As String 
  
  sSearchPattern = Replace(TextBoxPath.Text, Space(1), "*")
  sDirfile = FindDirFile(User.Home, sSearchPattern, 3) 'as String, with /media/
  
  sMessage = "<h3><font color=gray>" & ("Such-Eingabe") & ": " & sSearchPattern & "</font></h3>"
  
  If Exist(sDirfile) = False Then
    sMessage &= "<h3><font color=blue>" & TextBoxPath.Text & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Nicht gefunden") & "</font></h3>"
    sDirFile = FileChooser1.SelectedPath
  Else 
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirfile) & "/" & "</font><font color=blue>" & File.Name(sDirfile) & "</font></h3>"
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirfile) & "</b></font>" & Space(1) & "<font color=darkgreen>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    sMessage &= "<h3><font color=darkgreen>" & ("Gefunden") & "</font></h3>"
  Endif 
  
  Select Case Message.Question(sMessage, ("Auswählen"), ("Ordner..."), ("Abbrechen"))
    Case 1
      FileChooser1.Dir = File.Dir(sDirfile)
      FileChooser1.FileView.UnselectAll()
      FileChooser1.FileView.Current = File.Name(sDirfile)
    Case 2
      M01Functions.FileManagerOpen(sDirFile)
    Case 3
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function FindDirFile(Optional sStartDir As String = User.Home, Optional sSearchPattern As String = "*", iType_Dir1_File2_DirFile3 As Integer = 3) As String 
  
  Dim sDirFile, sDir, sLatest As String 
  Dim it, iLine, iDirFile As Integer
  Dim ssSpli As New String[]
  Dim bExact As Boolean 
  
  Select Case iType_Dir1_File2_DirFile3
    Case 1
      iDirFile = gb.Directory
    Case 2
      iDirFile = gb.File
    Case 3
      iDirFile = gb.Directory + gb.File
  End Select 
  
  If String.InStr(sSearchPattern, "*") = 0 Then bExact = True Else bExact = False 'with "*"
  
  ' sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = "/media" &/ User.Name
  
  ''Extern Media, USB-Stick, ...?
  If IsDir(sDir) = True Then 
    ProgressBarONoff(True) 
    'Search in Sub-Directories (Recursively, Rekursiv, RDir):
    ssSpli = RDir(sDir, "*" & sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
    For it = 0 To ssSpli.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sDirFile = sDir &/ ssSpli[it]
      If bExact = True Then 
        If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
      Endif
      If Not sLatest And sDirFile Then 
        sLatest = sDirFile
      Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
        If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
      Endif
      ' sList &= sDirFile & gb.NewLine
    Next 
  Endif
  
  ssSpli = RDir(sStartDir, "*" & sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
  
  ''Start Directory:
  For it = 0 To ssSpli.Max
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sDirFile = sStartDir &/ ssSpli[it]
    If bExact = True Then 
      If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
    Endif
    If Not sLatest And sDirFile Then 
      sLatest = sDirFile
    Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
      If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
    Endif
  Next 
  ProgressBarONoff(False) 
  
  Return sLatest ' Null or /Dir or file.ext or /Dir/File.ext  
  
Catch
  FMain.ErrorText
  ProgressBarONoff(False) 
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form22DialogOpenSave.Window.Maximized = Not Form22DialogOpenSave.Window.Maximized 
  If Form22DialogOpenSave.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form22DialogOpenSave.Window.FullScreen = True Or Form22DialogOpenSave.Window.Maximized = True Then 
      F_bMovingON = False
      Form22DialogOpenSave.Window.FullScreen = False
      Form22DialogOpenSave.Window.Maximized = False
      If Form22DialogOpenSave.Left + Form22DialogOpenSave.W > Screen.AvailableWidth Then Form22DialogOpenSave.Move(Form22DialogOpenSave.Left, Form22DialogOpenSave.Top, Screen.AvailableWidth - Form22DialogOpenSave.Left, Screen.AvailableHeight - Form22DialogOpenSave.Top)
    Else
      F_bMovingON = True
      Form22DialogOpenSave.Window.FullScreen = False
      Form22DialogOpenSave.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form22DialogOpenSave.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form22DialogOpenSave.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form22DialogOpenSave.ClientW - WindowStretch.W, Form22DialogOpenSave.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form22DialogOpenSave.Window.Maximized = True
    If String.LCase(Desktop.Platform) = "wayland" Then 
      F_iX1 = Mouse.ScreenX - PicBackground.Left
      F_iY1 = Mouse.ScreenY - PicBackground.Top ' Desktop.Y '= Screens[0].AvailableY = 0
    Else 'If String.LCase(Desktop.Platform) = "x11" Then 
      F_iX1 = Mouse.X 
      F_iY1 = Mouse.Y ' Desktop.Y '= Screens[0].AvailableY = 0
    Endif 
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form22DialogOpenSave.W = Mouse.ScreenX - F_iX1 - Form22DialogOpenSave.ScreenX
    Form22DialogOpenSave.H = Mouse.ScreenY - F_iY1 - Form22DialogOpenSave.ScreenY
    WindowStretch.Move(Form22DialogOpenSave.ClientW - WindowStretch.W, Form22DialogOpenSave.ClientH - WindowStretch.H)
    WindowStretch.Raise
    Form_Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form22DialogOpenSave.ClientW - WindowStretch.W, Form22DialogOpenSave.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form22DialogOpenSave.Window.Maximized = Not Form22DialogOpenSave.Window.Maximized 
    If Form22DialogOpenSave.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()

Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form22DialogOpenSave.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub AplusG()
  
  ''Check:
  If FileChooser1.Font.Size = 12 Then 
    ListAplus.Picture = PicTemplateAplus.Picture
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
  Endif 
  
  ''Text-Height:
  LabelFileNameInfo.Font.Size = FileChooser1.Font.Size
  LabelInfo.Font.Size = FileChooser1.Font.Size
  LabelInfo2.Font.Size = FileChooser1.Font.Size
  ' LabelPathType.Font.Size = FileChooser1.Font.Size
  TextBoxPath.Font.Size = FileChooser1.Font.Size * 1.25 ' TextBoxPath1.Font.TextHeight("Abc123") / 1.5 '.Size as Float
  TextAreaPreview.Font.Size = FileChooser1.Font.Size
  
Catch
  FMain.ErrorText
  
End

Public Sub DirStandardAlternative(Optional bStandard As Boolean = True)
  
  Dim sDir, sMessage As String 
  
  Select Case bStandard
    Case True 
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
    Case False 
      sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  End Select
  If IsDir(sDir) = True Then 
    FileChooser1.Dir = sDir
  Else 
    sMessage = "<h3><font color=gray>" & ("Ordner") & ":" "</font></h3>" 
    sMessage &= "<h3><font color=gray>" & sDir & "</font></h3>" 
    sMessage &= "<font color=red>" & ("Nicht gefunden") & "</font>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Select Case Last.Tag
    Case "aplus"
      Last.Background = Color.Green 
    Case "read", "filefind"
      Last.Border = True
      Last.Background = Color.Green
    Case "open", "save"
      Last.Border = True
      Last.Background = Color.Green
    Case "cancel"
      Last.Border = True
      Last.Background = Color.Green
    Case Else 
      If Object.Type(Last) = "Button" Then 
        Last.Border = True
        Last.Background = Color.Green
      Endif
  End Select
  
  If PanelPreview.Visible = True Then 
    PanelPreviewCancel.Border = True 
    PanelPreviewCancel.Background = Color.Green
  Endif 
  
Catch 
  FMain.ErrorText 
  
End

Public Sub ButtonGroup_Leave()
  
  Select Case Last.Tag
    Case "aplus"
      Last.Background = Color.Default  
    Case "read", "filefind"
      If PanelPreview.Visible = False Then 
        Last.Border = False
      Else 
        Last.Border = True
        Last.Background = Color.Green
      Endif 
    Case "open", "save"
      Last.Border = F_bChangeON 
      Last.Background = Color.Default 
    Case "cancel", "datecancel"
      Last.Border = False
      Last.Background = Color.Default
    Case Else 
      If Object.Type(Last) = "Button" Then 
        Last.Border = False
        Last.Background = Color.Default
      Endif
  End Select
  
  If PanelPreview.Visible = True Then 
    PanelPreviewCancel.Border = True 
    PanelPreviewCancel.Background = Color.Default
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  ' Me.TopOnly = False 
  ' Me.Utility = False 
  ' Me.Resizable = True 'Form _□×
  ' Me.Stacking = Window.Normal 'Fenster unter, über, normal. integer 2=Below. "This constants is used by the Stacking property for windows that must stay below other windows."
  
  Select Case sLastTag 
    Case "aplus" 'A+, A-
      If FileChooser1.Font.Size <= 12 Then 
        FileChooser1.Font.Size = 16
      Else 
        FileChooser1.Font.Size = 12
      Endif 
      Settings[F_sForm &/ "FileChooser1.Font.Size"] = FileChooser1.Font.Size
      AplusG()
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      Me.Visible = False 
      Wait 1
      Me.Visible = True 
    Case "cancelform"
      Form22DialogOpenSave.Window.Close
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "dirstandard"
      DirStandardAlternative(True)
    Case "dirbackup"
      FileChooser1.Dir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
    Case "diralternative"
      DirStandardAlternative(False)
    Case "trashopen" '(Papierkorb)
      M01Functions.ExternTrash()
    Case "pathtype"
      TextBoxPath.SelectAll
      TextBoxPath.Insert(File.Name(F_sDirFileInput))
      FileChooser1.Filter = FileChooserFilterReturn(F_sDirFileInput)
      FileChooser1.FilterIndex = 0
      FileChooser1SelectPath(F_sDirFileInput)
    Case "filefind"
      FindLatestFile()
    Case "open"
      OpenSaveCloseG("open")
    Case "save"
      OpenSaveCloseG("save")
    Case "read", "previewcancel"
      ReadPreviewG()
    Case "opensave"
      SavePreviewG()
    Case "labelinfo"
      FileInfoG()
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "overwrite"
      MessageOverwrite(1)
    Case "overwritecancel"
      MessageOverwrite(2)
    Case "cancel"
      OpenSaveCloseG("close")
  End Select
  
  WindowStretch.Raise() '▲Level Top▲
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '............................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form5Projekte.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form5Projekte.class
233 KB
' Gambas class file

'F_ = Form level
Public F_bChangeON As Boolean
Public F_bCheckBoxAbc As Boolean
Public F_bESCpressedON As Boolean
Public F_bKeyboardInput As Boolean
Public F_bListChanged As Boolean
Public F_bMakeBackup As Boolean
Public F_bMoreButtons As Boolean
Public F_bMovingON As Boolean
Public F_bSaved As Boolean
Public F_dateNow As Date 
Public F_i22 As Integer = 22 'Example: 22 'Pixel Icon WxH —▶ColumnView
Public F_iColorBlue As Integer
Public F_iColorForegroundBlue As Integer = Color.DarkBlue
Public F_iColorGreen As Integer
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150) ' (Color,  Alpha-Transparent = 255)
Public F_iColorGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220) 
Public F_iColorRed As Integer
Public F_iColorRedAlpha150 As Integer = Color.SetAlpha(Color.Red, 150) 
Public F_iColorYellow As Integer
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iCVUndoRedoPointer As Integer
Public F_iCVUndoRedoPointerSave As Integer
Public F_iDateTimeNoticeBackupPointer As Integer
Public F_iListChangedCounter As Integer
Public F_iMoveLineMaxH As Integer
Public F_iMoveLineMinH As Integer
Public F_iMoveLineTop As Integer
Public F_iMusterTermine1Names2Projects3 As Integer = 2 '!!! ******************************************
Public F_iOldLines As Integer
Public F_iOnly1x As Integer
Public F_iSearchPosition As Integer
Public F_iSecondsFileRead As Integer
Public F_iText5SearchPosition As Integer
Public F_iText5Seconds As Integer
Public F_iUnknownCounter As Integer
Public F_iX1 As Integer
Public F_iX2 As Integer
Public F_iY1 As Integer
Public F_iY2 As Integer
Public F_longFilesRead As Long '>Files
Public F_ooColumnViewImages As Object[]
Public F_ooCVBackups As Object[]                                                   'ColumnView1 ->Backups
Public F_ooDateTimeNoticeBackup As Object[]
Public F_sCVinfoSelectLineFirst As String = ("Vorher eine Zeile markieren oder erstellen")
Public F_sDirDefault As String = Desktop.GetDirectory("PICTURES") &/ Application.Name
Public F_sForm As String = Me.Name 
Public F_sLinesCopy As String 
Public F_sPathText5Temp_txt As String 
Public F_sProjectOnlyName As String
Public F_ssCVImgNames As String[]
Public F_ssKeysCopy As String[]          'ColumnView1.Selection.Max > -1  'internally, instead of Clipboard.Copy()
Public F_statFilePathForm As Stat
Public F_sText5StartExampleName As String
Public F_sTitleBasicText As String
Public F_sUnknownLinesText As String

Public Struct F_multiColumnViewValues 'Example in Sub: Dim hColumnView as New F_multiColumnViewValues
  bSortAscending As Integer
  bSorted As Integer
  iMode As Integer
  iScrollY As Integer
  iSortColumn As Integer
  ssKeys As String[] 
  ssLines As String[]
End Struct 

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]  '... "terminwecker.txt"
    Case 2
      sPath = Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt] '..."projects_names.txt"
    Case 3
      sPath = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] '..."projects_all.txt"
  End Select 
  
  Return sPath 
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt")
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectOnlyName() As String 
  
  F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  Return F_sProjectOnlyName
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtons(Optional bMore As Boolean = True)
  
  Dim bON As Boolean
  
  ''More:
  PanelListMenu.Visible = bMore 
  TextUndo.Visible = bMore
  TextRedo.Visible = bMore
  TextNeu.Visible = bMore
  ButtonSearch2ON.Visible = Not bMore
  ButtonTabelleExtern.Visible = bMore 
  ButtonOpen.Visible = False  'unused, deaktivate (Deaktiviert)
  
  ''Reset:
  bON = False
  ButtonBis.Visible = bON '{until}
  CheckBox1.Visible = bON '*EveryYear
  LabelTimer.Visible = bON 'Timer-
  LabelTitle.Visible = bON 
  LabelTitle.Raise()
  LabelTitleB.Visible = bON 
  ButtonProjectON.Visible = bON 
  ButtonSum.Visible = bON 
  ButtonName.Visible = bON 
  Text2.Visible = bON 
  Text2BG.Visible = bON 
  ButtonDauer.Visible = bON 
  ButtonTest.Visible = bON 
  ButtonPathAdd.Visible = bON
  
  Select Case F_iMusterTermine1Names2Projects3
      
    Case 1
      ''Notice:
      If Form5Projekte.Name = Form2Bearb.Name Then 
        bON = True 
        ButtonBis.Visible = bON '{until}
        CheckBox1.Visible = bON '*EveryYear
        LabelTimer.Visible = bON 'Timer-
      Endif 
      
    Case 2
      ''Projects Names:
      If Form5Projekte.Name = Form5Projekte.Name Then 
        bON = True 
        LabelTitle.Visible = bON 
        LabelTitle.Raise()
        LabelTitleB.Visible = bON 
        ButtonProjectON.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
    Case 3
      ''Projects edit:
      If Form5Projekte.Name = Form18Projektbearbeiten.Name Then 
        bON = True
        ButtonSum.Visible = bON 
        ButtonName.Visible = bON 
        Text2.Visible = bON 
        Text2BG.Visible = bON 
        ButtonDauer.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH As Integer 'Border Width, Height (Rand Breite, Hoehe)
  Dim iPH, iPH2, iT0W, iT1W, iXW, iXH, iTH, iH, iW, iDis As Integer 'Panel Height
  
  If Form5Projekte.Width < 200 Then Form5Projekte.Width = 200
  If Form5Projekte.Height < 200 Then Form5Projekte.Height = 200
  
  PicBackground.Move(0, 0, Form5Projekte.ClientW, Form5Projekte.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Randbreite
  iBH = PicBackground.Height / 100 * 3
  
  '*************************************************
  iDis = 10
  iPH = 50  'Text0.Font.TextHeight("0000-00-00") + iDis 'Distance
  iPH2 = iPH / 2
  iTH = iPH2  'TextBoxSearch5.Font.TextHeight("Path") + iDis
  iT0W = 150  'Text0.Font.TextWidth("0000-00-00") + iDis
  iT1W = 100 ' Text1.Font.TextWidth("00:00") + iDis
  F_iMoveLineMinH = iBH
  F_iMoveLineMaxH = Form2Bearb.ClientH - (iPH * 5.5) - iBH 
  '*************************************************
  
  'Adjust to MoveLine (Ausrichten an ▼-Bewegungslinie-▲)
  '-----------------------------------------------------------------------
  MoveLine.Move(iBW, MoveLine.Top, PicBackground.Width - (iBW * 2), iPH2) '.Top Begin => Form_Open
  '-----------------------------------------------------------------------
  If MoveLine.Top < F_iMoveLineMinH Or MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH
  
  IconError.Move(Form5Projekte.ClientW - 32, 0, 32, 32)
  ProgressBar1.Move(MoveLine.Left, MoveLine.Top, MoveLine.Width, MoveLine.Height)
  
  ColumnView1.Move(iBW, iBH, MoveLine.Width, MoveLine.Top - iBH)
  
  ''Panel 0000-00-00 00:00...
  ' iXH = LabelTimer.Font.TextHeight("Timer-") + iDis
  iXH = iPH2
  PanelDatum.Move(iBW, MoveLine.Top + MoveLine.H, ColumnView1.W, iPH + iXH)
  Text0.Move(0, iPH / 3, iT0W, iPH / 3 * 2)
  Text0BG.Move(Text0.Left, Text0.Top, Text0.W, Text0.H)
  LabelTimer.Move(Text0.Left, Text0.Top + Text0.H, Text0.W * 0.65, iXH) 
  ButtonWeekDay.Move(LabelTimer.Left + LabelTimer.W, LabelTimer.Top, (LabelTimer.Left + LabelTimer.W + iDis + iT1W) - (LabelTimer.Left + LabelTimer.W), LabelTimer.H)
  Text1.Move(Text0.Left + Text0.W + iDis, Text0.Top, iT1W, Text0.H)
  Text1BG.Move(Text1.Left, Text1.Top, Text1.W, Text1.H)
  WindowT5plus.Move(PanelDatum.W - iXH, PanelDatum.H - iXH, iXH, iXH)
  ButtonSearch2ON.Move(WindowT5plus.Left, 0, WindowT5plus.W, WindowT5plus.H)
  LabelDateNow.Move(Text0.Left, 0, Text0.W, LabelDateNow.Font.TextHeight("0123"))
  LabelTimeNow.Move(Text1.Left, 0, Text1.W, LabelTimeNow.Font.TextHeight("0123"))
  ' LabelDateNow.Font.Size = LabelDateNow.Font.TextHeight("0123") * 0.65
  LabelTimeNow.Font.Size = LabelDateNow.Font.Size
  ' Text0.Font.Size = Text0.Font.TextHeight("0123") * 0.65
    
  Text1.Font.Size = Text0.Font.Size
  ' LabelTimer.Font.Size = LabelTimer.Font.TextHeight("0123") * 0.65
  ButtonWeekDay.Font.Size = LabelTimer.Font.Size
  LabelDateNow.Font.Size = LabelTimer.Font.Size
  LabelTimeNow.Font.Size = LabelTimer.Font.Size
  
  ''Extra —▶ Project:
  PanelTitle.Move(iBW, PanelDatum.Top + PanelDatum.H, PanelDatum.W, Form5Projekte.ClientH - (iBH * 2) - ColumnView1.H - MoveLine.H - PanelDatum.H - (iPH * 2) - iTH)
  ButtonName.Move(0, 0, Text0.Left + Text0.W, Text0.H)
  ButtonSum.Move(0, ButtonName.Top + ButtonName.H, Text1.Left - Text0.Left, PanelTitle.H - (ButtonName.Top + ButtonName.H)) 
  ButtonDauer.Move(Text1.Left, ButtonSum.Top, Text1.W, ButtonSum.H)
  Text2.Move(Text1.Left, 0, Text1.W, Text1.H)
  Text2BG.Move(Text2.Left, Text2.Top, Text2.W, Text2.H)
  ButtonTest.Move(PanelTitle.W - (iPH * 2), 0, iPH * 2, PanelTitle.H)
  ButtonProjectON.Move(0, 0, iPH, PanelTitle.H)
  LabelTitle.Move(iPH, 0, Text1.Left + Text1.W + iDis - iPH, PanelTitle.H)
  LabelTitleB.Move(LabelTitle.Left - 2, LabelTitle.Top + 2, LabelTitle.Width, LabelTitle.Height)
  LabelTitleB.Lower
  LabelTitleB.Text = LabelTitle.Text
  LabelTitleB.Font = LabelTitle.Font
  LabelTitleB.Alignment = LabelTitle.Alignment
  
  If F_iMusterTermine1Names2Projects3 = 1 Then 
    ''Termine:
    PanelText5.Move(0, 0, PanelTitle.W, PanelTitle.H)
  Else 
    ''Projects:
    PanelText5.Move(Text2.Left + Text2.W + iDis, 0, PanelTitle.W - (Text2.Left + Text2.W + iDis) - ButtonTest.W, PanelTitle.H)
  Endif 
  Text5.Move(0, 0, PanelText5.W, PanelTitle.H)
  
  ''Panel + ▶ Paste into List:
  PanelPaste.Move(iBW, PanelTitle.Top + PanelTitle.H, PanelDatum.W, iPH)
  ButtonAdd.Move(0, 0, iPH, iPH)
  ButtonInput.Move(iPH, 0, (PanelPaste.W / 2) - iPH, iPH)
  iXW = PanelPaste.W / 4
  CheckBox1.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  CheckBoxONoff.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  ButtonBis.Move(CheckBox1.Left + CheckBox1.W, 0, iXW - iPH, iPH)
  ButtonSearch5ON.Move(PanelPaste.W - iPH, 0, iPH, iPH)
  
  ''Panel Path:
  PanelPath.Move(iBW, PanelPaste.Top + PanelPaste.H, PanelDatum.W, iTH)
  ButtonFileInfo.Move(0, 0, iPH, PanelPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelPath.H)
  LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelPath.W - iTH, ButtonFileInfo.H)
  ButtonPathAdd.Move(LabelInfo.Left + LabelInfo.W, 0, PanelPath.W - (LabelInfo.Left + LabelInfo.W), iTH)
  
  ''Panel Text5 Search:
  PanelSearchText5.Move(PanelPaste.Left, PanelPaste.Top, PanelPaste.W, PanelPaste.H)
  TextBoxSearch5.Move(0, 0, PanelPath.W, PanelSearchText5.H)
  CancelSearch5.Move(PanelSearchText5.W - PanelSearchText5.H, 0, PanelSearchText5.H, PanelSearchText5.H)
  ButtonSearch5.Move(CancelSearch5.Left - (PanelSearchText5.H * 3), 0, PanelSearchText5.H * 3, PanelSearchText5.H)
  
  ''Panel Save:
  PanelSave.Move(iBW, PanelPath.Top + PanelPath.H, PanelDatum.W, iPH) 
  ButtonOpen.Move(0, 0, iPH, iPH)
  ButtonNewPlus.Move(0, 0, iPH, iPH)
  ButtonTabelleExtern.Move(ButtonNewPlus.Left + ButtonNewPlus.W, 0, iPH, iPH)
  ButtonSave.Move(ButtonTabelleExtern.Left + ButtonTabelleExtern.W, 0, ButtonInput.W, PanelSave.H)
  ButtonFormCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, PanelSave.W - (ButtonSave.Left + ButtonSave.W) - TextNeu.W, PanelSave.H)  
  ButtonCancelB.Move(PanelSave.W - PanelSave.H - TextNeu.W, ButtonSave.Top, PanelSave.H, PanelSave.H)
  
  ''Arrow Paste ▶ 0000-00-00 00:00...
  PfeilEinfuegen.Move(0, PanelDatum.Top, iBW, iPH)
  PanelSearchList.Move(PanelDatum.Left, PanelDatum.Top, PanelDatum.Width, PanelDatum.Height)
  PanelSearchResize()
  
  ''Panel Menu List:
  PanelListMenu.Move(Text1.Left + Text1.W + iDis, 0, PanelDatum.W - (Text1.Left + Text1.W + iDis), iPH * 0.7)
  If Form5Projekte.Window.Maximized = True Then PanelListMenu.H = Text1.H
  PanelListMenuResize()
  
  ''Panel Menu Text5:
  PanelTextMenu.Move(PanelListMenu.Left, ButtonWeekDay.Top, PanelListMenu.W - iPH, ButtonWeekDay.H)
  iW = PanelTextMenu.H
  iH = PanelTextMenu.H
  TextUndo.Move(0, 0, iW, iH)
  Text5UndoCounter.Move(iW, 0, iW * 3, iH)
  TextRedo.Move(iW * 4, 0, iW, iH)
  TextNeu.Move(iW * 6, 0, iW * 3, iH)
  ButtonLineNr.Move(iW * 9, 0, PanelTextMenu.W - (iW * 13), iH)
  ButtonS.Move(PanelTextMenu.W - (iW * 4), 0, iW * 4, iH)
  
  ''Find Lines:
  ColumnView2.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Select 0000-00-00 00:00
  DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Timer: 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  ScrollViewWeekDay.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Time 00:00 > 23:59
  ColumnView3.Move(iBW, iBH, Text1.W + iDis, DateChooser1.H)
  
  ''Panel Until {bis}:
  PanelBis.Move(iBW + Text1.Left + Text1.W + iDis, PanelDatum.Top, PanelDatum.W - (Text1.Left + Text1.W + iDis), PanelDatum.Height)
  Label7Bis.Move(0, 0, Label7Bis.W, Text0.Height)
  Text0b.Move(Label7Bis.Left + Label7Bis.Width, 0, Text0.Width, Text0.Height)
  Text0bBG.Move(Text0b.Left, Text0b.Top, Text0b.W, Text0b.H)
  Label3b.Move(Text0b.Left, Text0b.Top + Text0b.Height, Text0b.Width, PanelBis.Height - Text0b.Height)
  LabelbisX.Move(0, Label3b.Top, Label3b.H, Label3b.Height)
  CancelBis.Move(PanelBis.W - iPH, 0, iPH, iPH)
  ButtonDateCancel.Move(PanelBis.Left, PanelBis.Top, PanelBis.W, PanelBis.H)
  
  ''Panel Text5 stretch:
  If PanelText5.H < F_iMoveLineMaxH Then 
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture
  Else 
    WindowT5plus.Picture = PicTemplatePageMini.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture  
  Endif
  
  ''Form stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form5Projekte.ClientW - iBW - iPH, Form5Projekte.ClientH - iBH - iPH, iPH, iPH)  
  
  ''List resize:
  If F_iOnly1x > 0 And F_bMovingON = False Then ColumnView1Resize()
  
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub PanelSearchResize()
  
  Dim iXW As Integer
  
  iXW = PanelSearchList.H * 1.1
  TextListSearch.Move(0, 0, PanelSearchList.W - (iXW * 11), PanelSearchList.H)
  If TextListSearch.W < Text0.W Then 
    TextListSearch.W = Text0.W
    iXW = (PanelSearchList.W - TextListSearch.W) / 11
  Endif 
  ButtonSearchPanel.Move(TextListSearch.Left + TextListSearch.W, 0, iXW * 2, PanelSearchList.H)
  ListFound.Move(ButtonSearchPanel.Left + ButtonSearchPanel.W, 0, iXW, PanelSearchList.H)
  ButtonSearchListOn.Move(ListFound.Left + ListFound.W, 0, iXW * 2, PanelSearchList.H)
  ButtonSearchDown.Move(ButtonSearchListOn.Left + ButtonSearchListOn.W, 0, iXW, PanelSearchList.H)
  ButtonSearchUp.Move(ButtonSearchDown.Left + ButtonSearchDown.W, 0, iXW, PanelSearchList.H)
  LabelSearchLineNr.Move(ButtonSearchUp.Left + ButtonSearchUp.W, 0, iXW * 2, PanelSearchList.H)
  SaveSelection.Move(LabelSearchLineNr.Left + LabelSearchLineNr.W, 0, iXW, PanelSearchList.H)
  ButtonSearchCancel.Move(PanelSearchList.W - iXW, 0, iXW, PanelSearchList.H)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelListMenuResize()
  
  Dim iCount, iW, iH, iDis As Integer 'Width, Height, Distance
  
  iCount = 21 ' |i|i|...|iii|
  iW = PanelListMenu.H  
  iH = PanelListMenu.H 
  iDis = PanelListMenu.W - (iW * iCount)
  iDis = iDis / iCount 
  iDis = iW + iDis
  If iDis < iW Then iDis = iW
  
  ListDown.Move(0, 0, iW, iH)
  ListUp.Move(iDis, 0, iW, iH)
  ListCut.Move(iDis * 2, 0, iW, iH)
  ListCopy.Move(iDis * 3, 0, iW, iH)
  ListPaste.Move(iDis * 4, 0, iW, iH)
  ListSelectAll.Move(iDis * 5, 0, iW, iH)
  ListAdd.Move(iDis * 6, 0, iW, iH)
  ListUndo.Move(iDis * 7, 0, iW, iH)
  ListRedo.Move(iDis * 11, 0, iW, iH)
  ListBackupCounter.Move(ListUndo.Left, 0, (ListRedo.Left + ListRedo.W) - ListUndo.Left, iH)
  ListBackupCounter.Lower
  ListSearch.Move(iDis * 12, 0, iW, iH)
  ListMark.Move(iDis * 13, 0, iW, iH)
  ListRefresh.Move(iDis * 14, 0, iW, iH)
  ListReload.Move(iDis * 15, 0, iW, iH)
  ListAplus.Move(iDis * 16, 0, iW, iH)
  ListCheckBoxAZ.Move(iDis * 17, 0, iW, iH)
  ListCheckBoxAZLabel.Move(iDis * 17 + iW, 0, iW * 2, iH)
  ListIsChanged.Move(iDis * 20, 0, iW, iH)
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  WindowStretch.Raise() 'Level ▲Top▲
  ButtonSearchCancel.Raise()
  
  Text0BG.Raise() 'Changed auch bei Farbwechsel, deshalb extra Background für Farbhinweis (*1)
  Text1BG.Raise()
  Text2BG.Raise()
  Text0bBG.Raise()
  
  Text0.Raise()
  Text1.Raise()
  Text2.Raise()
  Text0b.Raise()
    
  LabelDateNow.Raise()
  LabelTimeNow.Raise()
  
  ''_____________________________________________________________________________''
  '(*1) Alternative in New Gambas-Version with TextBox. _Change() only Text, not Color) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True
  SelectHide0Date1Clock2Timer3(0)
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then ColumnViewInfo(("Abbruch mit [ESC]")) Else ColumnViewInfo()
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form5Projekte.Window.Maximized = False Then
    Form5Projekte.Window.Maximized = True
  Else
    Form5Projekte.Window.Maximized = False
    Form5Projekte.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Picture (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
    sValue = Replace(sValue, "bg_", "bglinie_")
    MoveLine.Picture = Picture.Load(sValue) 
    MoveLine.Stretch = True
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
    MoveLine.Background = PicBackground.Background
    MoveLine.Stretch = False
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  FMain.F_bNeueinlesenStarten = False
  IconError.Visible = False
  mnuMaus.Visible = False
  mnuMaus2.Visible = False
  If Not Form5Projekte.Window.Icon Then Form5Projekte.Window.Icon = FMain.Window.Icon
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1 'Termine
      Form5Projekte.Window.Title = Application.Name & " - " & ("Bearbeiten")
    Case 2 'Project-Names
      Form5Projekte.Window.Title = Application.Name & " - " & ("Projekte")
    Case 3 'Projects
      Form5Projekte.Window.Title = Application.Name & " - " & ("Projekt bearbeiten")
  End Select 
  F_sTitleBasicText = Form5Projekte.Window.Title
  MoveLine.Top = 0
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1 
    ColumnViewCheckAplus()
    FormStart()
    If F_iMusterTermine1Names2Projects3 = 1 Then Timer1.Start() Else Timer1.Stop()
    ReadG()
    If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1, 2 'Termine, Project-Names
      F_iColumnNr = 6                                  'Termine 6, in Projects 13
      F_iColumnUndo = 7                                'Termine 7, in Projects 10
      F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 9                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
      
    Case 3 'Projects
      F_iColumnNr = 13                                  'Termine 6, in Projects 13
      F_iColumnUndo = 10                                'Termine 7, in Projects 10
      F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 12                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  End Select 
  
  '******************************
  F_iColorYellow = ColumnView2.Background
  F_iColorGreen = Color.Green
  F_iColorRed = Color.Red 
  F_iColorBlue = Color.Lighter(Color.Lighter(Color.Blue))
  '******************************
  
  MoreButtons(F_bMoreButtons)
  FormBackgroundColor()
  ColumnViewImagesRead()
  ButtonSave.Background = Color.Default 
  
  F_bChangeON = False
  LabelInfoPathG(FilePathForm())
  WeekDays0to6()
  F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then 
    F_sText5StartExampleName = Text5TempFileLoad() 'as String, Read file
  Else 
    Text0Insert(Format(Date, "yyyy-mm-dd"))
    Text0bInsert(Format(Date, "yyyy-mm-dd"))
    Text1Insert(Format(Time, "hh:nn"))
    Text5Insert(F_sText5StartExampleName)
  Endif 
  Text5.Pos = String.Len(Text5.Text)
  Text5.SetFocus
  ButtonWeekDay.Text = Format(Date, "dddd")
  TextUndo.Picture = ListUndo.Picture.Image.Stretch(F_i22, F_i22).Picture
  TextRedo.Picture = ListRedo.Picture.Image.Stretch(F_i22, F_i22).Picture
  MenuSaveAsCopy.Picture = MenuSaveAsCopy.Picture.Image.Desaturate().Contrast(1).Picture

  TextBackgroundAll(Color.Transparent)
  F_bChangeON = True
  
  F_bListChanged = False
  F_bKeyboardInput = False
  ColorPicButtonReplace()
  WindowStretchCursor()

Catch 
  FMain.ErrorText
  
End

Public Sub FilePathCheck()
  
  Dim sDirFile As String
  ' TextBoxPath.Text = FilePathForm()
  sDirFile = TextBoxPath.Text 
  
  If sDirFile = "" Then TextBoxPath.Text = ("Datei fehlt?")  
  TextBoxPath.ToolTip = ("Datei=") & Space(1) & TextBoxPath.Text
  If Exist(sDirFile) = False Then
    TextBoxPath.Foreground = F_iColorRed
    ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture
  Else
    TextBoxPath.Foreground = Color.Gray
    If F_iSecondsFileRead = 2 Then 'slowly?
      ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture 'Pixel 22, 22
    Else 
      ButtonFileInfo.Picture = mnuInfo.Picture.Image.Stretch(F_i22, F_i22).Picture
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekDays0to6()
  
  Dim ssWeekdays As New String[]
  
  ssWeekDays = M01Functions.Weekdays0to6LocalLanguage() 'new in Gambas3
  
  If ssWeekdays.Count >= 7 Then 
    ToggleButtonW1.Text = ssWeekdays[0] 'So
    ToggleButtonW2.Text = ssWeekdays[1] 'Mo
    ToggleButtonW3.Text = ssWeekdays[2] 'Di
    ToggleButtonW4.Text = ssWeekdays[3] 'Mi
    ToggleButtonW5.Text = ssWeekdays[4] 'Do
    ToggleButtonW6.Text = ssWeekdays[5] 'Fr
    ToggleButtonW7.Text = ssWeekdays[6] 'Sa
  Endif 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewSortPics()
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_iColumnSelect < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView1.Columns.Sort = F_iColumnSelect
      If ColumnView1.Selection.Max > -1 Then
        ' sKey = ColumnView1.Selection[ColumnView1.Selection.Max]  'only Key, Example: Last sKey = "9"
        sKey = ColumnView1.Selection.Last
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If F_iColumnSelect < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView2.Columns.Sort = F_iColumnSelect
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection.Last  'only Key, Example: Last sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewImagesRead()  'Note: Work with Images = faster. Convert to Picture at End.
  
  Dim ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning As Image
  Dim iSize As Integer
  
  ''End-Names:
  F_ssCVImgNames = ["PicAdd", "PicCut", "PicDouble", "PicDown", "PicEmpty", "PicFind", "PicHome", "PicMarkGreen", "PicOFF", "PicOK", "PicON", "PicQuestion", "PicRefresh", "PicSave", "PicUp", "PicWarning"]
  
  iSize = F_i22 'Pixel 
  ImgAdd = ListAdd.Picture.Image.Stretch(iSize, iSize)
  ImgCut = ListCut.Picture.Image.Stretch(iSize, iSize)
  ImgDouble = PicTemplateDouble.Picture.Image.Stretch(iSize, iSize)
  ImgDown = ListDown.Picture.Image.Stretch(iSize, iSize)
  ImgEmpty = New Image(iSize, iSize, Color.Transparent) 'Image is faster than Picture
  ImgFind = ListSearch.Picture.Image.Stretch(iSize, iSize) 
  ImgHome = PicTemplateLEDgreen.Picture.Image.Stretch(iSize, iSize) 
  ImgMarkGreen = ListMark.Picture.Image.Stretch(iSize, iSize) 'Flag
  ImgOff = PicTemplateConnectOff.Picture.Image.Stretch(iSize, iSize)
  ImgOK = PicTemplateApply.Picture.Image.Stretch(iSize, iSize) 
  ImgON = PicTemplateConnectON.Picture.Image.Stretch(iSize, iSize)
  ImgQuestion = mnuZeilenvergleichen.Picture.Image.Stretch(iSize, iSize)
  ImgRefresh = PicTemplateReChange.Picture.Image.Stretch(iSize, iSize)
  ImgSave = ButtonSave.Picture.Image.Stretch(iSize, iSize)
  ImgUp = ListUp.Picture.Image.Stretch(iSize, iSize)
  ImgWarning = IconError.Picture.Image.Stretch(iSize, iSize)
  
  ''Images:
  F_ooColumnViewImages = [ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning]
  
  ''Example:
  'PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewImages(Optional sName As String = "PicEmpty") As Image
  
  Dim iFound As Integer
  
  If String.InStr(sName, "-") > 0 Then sName = Replace(sName, "-", "") '"-" for selected Line
  If F_ssCVImgNames And F_ooColumnViewImages Then iFound = F_ssCVImgNames.Find(sName) '-1 not found
  If iFound = -1 Then iFound = F_ssCVImgNames.Find("PicEmpty")
  
  Return F_ooColumnViewImages[iFound]
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG(Optional sDirFile As String = "", Optional bDialog As Boolean = False) ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File 'Stream
  Dim iColumn, iUnknownCounter, iEmptyOrDouble, iLine, iLines As Integer
  Dim sKey, sLine, sLinePart, sText, sUnknown, sMessage, sDemo As String
  Dim ssExist, ssRepair As String[]
  Dim PicEmpty As Picture
  Dim dateBegin, dateEnd As Date 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
  ''Reset:
  F_bESCpressedON = False
  IconError.Visible = False
  F_sUnknownLinesText = "" 
  dateBegin = Now
  Error.Clear()
  
  ''Dialog:
  If bDialog = True Then 'Add+
    sDirFile = FileDialogPathReturn(sDirFile, "open", FilePathForm()) 'no Path = cancel
    If Exist(sDirFile) = False Then Goto JumpEnd    'Cancel (Abgebrochen)
  Else 
    ColumnView1.Clear() 'delete all lines, but not title (header)
    F_longFilesRead = 0
  Endif
  
  ''File-Name or Standard or Demo:
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = False Then
    ''Empty, Demo-File
    sDemo = M01Functions.DemoFileTermineOrProjects(FilePathForm()) 'Terminwecker or Projects
    If Exist(sDemo) = True Then Try Move sDemo To sDirFile 
  Endif
  If sDirFile <> TextBoxPath.Text Then 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
  Endif 
  FilePathCheck()
  
  ''Check Columns:
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  F_iOldLines = ColumnView1.Count
  If F_iOldLines = 0 Then ColumnSortSettingCentral()
  ' If F_iOldLines = 0 Then PicNew = PicEmpty Else PicNew = PicAdd
  ' ColumnView1.Header = True 
  ColumnView1.Visible = False
  ' ColumnView1.Sorted = False     'Enter-List (Liste nach Eingang aus Datei)
  
  ProgressBarONoff(True)
  Form5Projekte.Window.Title = Application.Name & " - " & ("Datei lesen...")
  
  ''Check first lines. File-Format:
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    If M01Functions.isTerminweckerFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Else 
    If M01Functions.isProjectFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Endif 
  
  ''Backup:
  If Not F_ooCVBackups Then ColumnViewBackup()
  
  'Read and add Column Lines (Zeilen (rows) erzeugen)
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  If Exist(sDirFile) = True Then
    F_longFilesRead = F_longFilesRead + Stat(sDirFile).Size 'as Long
    ssExist = New String[]
    ColumnView1.Sorted = False 
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    If F_iMusterTermine1Names2Projects3 > 1 Then ssExist.Sort() '>Projects
    
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If sLine And String.Left(sLine, 1) <> "#" And ssExist.ExistSorted(sLine) = False Then '.FindSorted() > faster ~10x
        ''Test Rest:
        If sLine Like "*????-??-??*??:??*????-??-??*?Q" & gb.Tab & "*" Then 
          If sLine Then ssRepair = ReadRepairG(sLine) Else ssRepair = Null 'as String[]
          If ssRepair Then ssExist.Insert(ssRepair)
        Else 
          ssExist.Add(sLine) 
        Endif 
      Else 
        iEmptyOrDouble = iEmptyOrDouble + 1
      Endif 
      
      iLines = iLines + 1
      If iLines Mod 100 = 0 Then 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          sMessage = sDirFile & "<br>"
          If Stat(sDirFile).Size > 2000000 Then '2MiB
            sMessage &= M01Functions.FileSizeText(sDirFile) & "<br>"
            sMessage &= "<font color=red><b>" & ("Große Datei = Mehr Zeit") & "</b></font><br><br>"
            sMessage &= ("Zeile") & ": " & iLines & "<br>"
            sMessage &= ("Tipp: Menü > Datei > Auslagern...") 
          Endif 
          If MessageQuestionBreak(sMessage) = True Then Break
        Endif 
        ProgressBarONoff(True) 
      Endif 
    Next 
    
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  'Check "\r" Return,  Typ Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
  If Exist(sDirFile) = True And String.InStr(sLine, gb.Cr) > 0 Then 
    sText = File.Load(sDirFile)
    If sText Then 
      ssExist = New String[]
      sText = Replace(sText, gb.Cr, gb.NewLine)
      ssExist = Split(sText & gb.NewLine, gb.NewLine) 
    Endif 
  Endif 
  
  If Not Error Then 
    For iLine = 0 To ssExist.Max '.........................................
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form5Projekte.Window.Title) = True Then Break
      Endif 
      
      sLine = ssExist[iLine] 'one line
      
      If String.Len(sLine) > 10 Then 'min.
        If F_iMusterTermine1Names2Projects3 > 1 Then 'Project-Name, no Text
          sLine = Replace(sLine, gb.Newline, "")'no new line "\n" = Chr(10)
          sLine = Replace(sLine, gb.Cr, "")'no Return "\r" = Chr$(13)            gb.CrLF = Chr(13) & Chr(10)
        Endif  
        sKey = Str(ColumnView1.Count + 1)
        ColumnView1.Add(sKey, "")
        
        iColumn = 0
        For Each sLinePart In Split(sLine & String(F_iColumnsCount, hTab), hTab) ' Stringarray
          If iColumn = 0 Then 
            ColumnView1[sKey][iColumn] = Trim(sLinePart) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          Else If iColumn < F_iColumnsReadMax + 1 Then 
            ColumnView1[sKey][iColumn] = sLinePart
          Endif 
          If iColumn = F_iColumnsReadMax Then Break
          iColumn = iColumn + 1
        Next
        
        If iColumn = F_iColumnsReadMax Then
          ColumnView1[sKey][F_iColumnUndo] = sLine 'Original Line (Originalzeile)
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = sKey
          If F_iOldLines = 0 Then
            ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
          Else 
            ColumnView1[sKey][F_iColumnSelect] = "PicAdd"  
          Endif 
        Else  'too many or not enough Separators '(zu viele oder zu wenige sSeparator) '|0|1|2|3|4|5|> |
          ColumnView1[sKey][F_iColumnUndo] = sLine 
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = 0
          iUnknownCounter = iUnknownCounter + 1
          If iUnknownCounter < 5 Then F_sUnknownLinesText &= sLine & gb.NewLine 'ssUnknown.Add(sLine)
          ColumnView1[sKey][F_iColumnSelect] = "PicWarning" '!
        Endif 'F_iColumnsReadMax
      Endif 
      
    Next '................................................. 
  Endif 
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  
  F_iUnknownCounter = iUnknownCounter
  mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
  If iUnknownCounter > 0 Then 
    F_sUnknownLinesText = Str(iEmptyOrDouble) & Space(1) & ("von") & Space(1) & Str(ssExist.Count) & Space(1) & ("Zeilen leer oder doppelt") & gb.NewLine 
    F_sUnknownLinesText &= Str(iUnknownCounter) & Space(1) & ("?-Zeilen") & ". " & ("Beispiel") & ": " & gb.NewLine 
    sUnknown = M01Functions.CheckTextTerminwecker(F_sUnknownLinesText)
    F_sUnknownLinesText &= sUnknown
  Endif 
  ButtonSave.Background = Color.Default
  ColumnviewIcons()
  ColumnView1.UnselectAll() '>AddAppend
  ''Activate or Deactivate:
  ColumnViewAddAppend() ''with ColumnViewSort() 'with .EnsureVisible()
  ColumnViewBackup()
  If F_iMusterTermine1Names2Projects3 = 2 Then ProjectLineSelection() '>Form5Projekte
  ' TextBoxPath.SelectAll()
  ' TextBoxPath.Insert(sDirFile) '>Form18Diagramm
  ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  F_bListChanged = False
  If sDirFile = FilePathForm() Then F_statFilePathForm = Stat(sDirFile)
  
JumpEnd:
  ColumnView1Resize() 'with Title-Info
  If ColumnView1.Columns.Count > 5 Then 
    If ColumnView1.Columns[5].Title Then ColumnViewInfo(ColumnView1.Columns[5].Title)
  Endif 
  ColumnView1.Visible = True
  ProgressBarONoff(False)
  dateEnd = Now 
  F_iSecondsFileRead = DateDiff(dateEnd, dateBegin, gb.Second) 'as Integer
  WindowTitle()
  
Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
  IconError.Raise '▲top level▲  (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
  IconError.Visible = True
  TextBoxPath.Foreground = F_iColorRed
  If Exist(sDirFile) = True Then Close #hFile
  ColumnView1.Visible = True
  
End ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Public Function ReadRepairG(Optional sLine As String = "") As String[]
  Dim iColumn As Integer
  Dim sLinePart, sUnknown, sYYYYMMDD As String 
  Dim ssUnknown As String[]
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  iColumn = 0
  For Each sLinePart In Split(sLine & hTab, hTab) ' Stringarray
    ' Print sLinePart
    If sLinePart And sLinePart Like "*????-??-??*" Then 
      If iColumn < F_iColumnsReadMax Then 
        sUnknown &= sLinePart & hTab
      Else
        If Not ssUnknown Then ssUnknown = New String[]
        sYYYYMMDD = String.Right(sLinePart, 10)
        If sYYYYMMDD Like "*????-??-??*" Then 
          sUnknown &= String.Left(sLinePart, String.Len(sLinePart) - 10) 
          ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          iColumn = 0
          sUnknown = sYYYYMMDD & hTab ''Reset, Begin...
        Endif 
      Endif
    Else If iColumn > 0 Then 
      sUnknown &= sLinePart & hTab
    Endif 
    iColumn = iColumn + 1
  Next
  If Replace(sUnknown, hTab, "") Then 
    If Not ssUnknown Then ssUnknown = New String[]
    ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
  Endif  
  ' If ssUnknown Then sUnknown = ssUnknown.Join(hReturn)
  
  Return ssUnknown
  
  Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
End

Public Sub ColumnviewIcons()
  
  Dim sKey, sIcon As String 
  Dim iLine As Integer
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sIcon = ColumnView1[sKey][F_iColumnSelect]
    ColumnView1[sKey].Picture = ColumnViewImages(sIcon).Picture 
  Next
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowTitle()
  
  Dim sKey As String = "?"
  Dim sSpace, sProjectName As String 
  
  sSpace = Space(1)
  sProjectName = Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]
  If Not sProjectName Or sProjectName = String.LCase(Application.Name) Then sProjectName = String.LCase(Application.Name) & sSpace & ("(Standard)")
  ' Print sProjectName
    
  If ColumnView2.Visible = False Then 
    Form5Projekte.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView1.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & "), " & ("Aktiv") & ": " & ("Projekt") & Space(1) & String.Left(sProjectName, 30)
    If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last
    ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
  Else 
    Form5Projekte.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & "), " & ("Aktiv") & ": " & ("Projekt") & Space(1) & String.Left(sProjectName, 30)
    If ColumnView2.Selection.Max > -1 Then sKey = ColumnView2.Selection.Last
    If String.Len(sKey) < 4 Then 
      LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
    Else 
      LabelSearchLineNr.Text = sKey 'only Key (number)  
    Endif 
    SaveSelection.Tooltip = Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Auswahl speichern in...")
  Endif 
  ColumnViewAscending()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  If ColumnView2.Columns.Ascending = True Then  
    ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  
Catch 
  FMain.ErrorText
    
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
 
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub Form_Close() 
  
  Dim sStandard, sMessage As String 
  
  SettingsReadSave("save") 'Save window settings when application closes
  
  If F_bListChanged = False And F_bKeyboardInput = True Then
    sMessage = "<font color=gray>" & String.Left(Text5.Text, 50) & "</font>" & "<br>"
    sMessage &= "..." & "<br>"
    sMessage &= "<font color=red><b>" & ("Nicht gespeichert.") & "</b></font>" & "<br>"
    
    Select Message.Question(sMessage, ("Bearbeiten..."), ("Schliessen"), ("Abbrechen"))
      Case 1, 3 'Edit, Close
        Stop Event  ' Vorgang abbrechen
      Case 2 'Cancel
        '...
    End Select
  Endif
  
  If F_bListChanged = True Then
    sMessage = "<h1><font color=red>" & ("Veränderte Liste") & "</font></h1>" 
    sMessage &= "<font color=gray>" & FilePathForm() & "</font>" & "<br>"
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If F_sProjectOnlyName = String.LCase(Application.Name) Then 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font><font color=gray>" & Space(1) & ("(Standard)") & "</font></h3>"
      Else 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font></h3>"
      Endif 
      sMessage &= sStandard 
      sMessage &= CheckProjectOnlyName(F_sProjectOnlyName) & "<br>"
    Endif

    Select Message.Question(sMessage, "○ " & ("Speichern"), ("Schliessen"), ("Abbrechen"))
      Case 1 'Save:
        SaveG()
      Case 2 'Close:
        '...Leerlauf
      Case 3 'Cancel:
        Stop Event  ' Vorgang abbrechen
    End Select
  Endif
  
  F_bESCpressedON = False
  ' If F_iListChangedCounter > 0 Then FMain.F_bNeueinlesenStarten = True ' —▶ Timer
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form5Projekte.Left]
      iY = Settings[F_sForm &/ "Top", Form5Projekte.Top]
      iW = Settings[F_sForm &/ "Width", Form5Projekte.W]
      iH = Settings[F_sForm &/ "Height", Form5Projekte.H]
      Form5Projekte.Move(iX, iY, iW, iH)
      F_bMoreButtons = Settings[F_sForm &/ "F_bMoreButtons", F_bMoreButtons]
      F_i22 = Settings[F_sForm &/ "F_i22", F_i22] 
      TextListSearch.SelectAll()
      TextListSearch.Insert(Settings[F_sForm &/ "TextListSearch.Text", TextListSearch.Text])
      
    Case "s" ''Save
      'Save window settings when application closes (Fenster-Position sichern wenn es geschlossen wird)
      Settings[F_sForm &/ "Left"] = Form5Projekte.Left
      Settings[F_sForm &/ "Top"] = Form5Projekte.Top
      Settings[F_sForm &/ "Width"] = Form5Projekte.Width
      Settings[F_sForm &/ "Height"] = Form5Projekte.Height
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      Settings[F_sForm &/ "F_i22"] = F_i22
      Settings[F_sForm &/ "TextListSearch.Text"] = TextListSearch.Text
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG(Optional sDirFileAsCopy As String = "")
  
  Dim sText, sMessage As String
  Dim iLine, iColumn, iDoubleLines As Integer
  Dim sPath, sDirFile As String
  Dim sInfo1, sInfo2 As String
  Dim sKey, sLine As String
  Dim PicSave, PicDouble, PicQuestion As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 

  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicSave = ColumnViewImages("PicSave").Picture 
  PicDouble = ColumnViewImages("PicDouble").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture 
  
  If sDirFileAsCopy Then 
    sDirFile = sDirFileAsCopy
  Else 
    sDirFile = FilePathForm()
  Endif
  
  If Exist(sDirFile) = True Then 
    sInfo1 = Format(Stat(sDirFile).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sDirFile).Size 
  Else 
    sInfo1 = Format(Now, "yyyy-mm-dd hh:nn:ss.uu") & "0" 
  Endif 
  sInfo2 = sInfo1 
  
  If Not F_ooCVBackups Then ColumnViewBackup()
  TextBoxPath.Foreground = Color.Default
  IconError.Visible = False
  F_bESCpressedON = False
  Form5Projekte.Window.Title = Application.Name & " - " & File.Name(sDirFile) & Space(2) & ("speichern...")
  'Muster: SicherungsDatei = SicherungOrdner &/ "backup_" & Name & "_" & Format(Now, "yyyy-mm-dd_dddhh-nn-ss") & ".txt"
  ssExist = New String[]
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form5Projekte.Window.Title) = True Then Break
    Endif 
    
    If ColumnView1[sKey].Text <> "" Then
      sLine = ""
      For iColumn = 0 To ColumnView1.Columns.Max
        If iColumn < F_iColumnsReadMax Then 
          sLine &= ColumnView1[sKey][iColumn] & hTab
        Else
          sLine &= ColumnView1[sKey][iColumn] '& hReturn
          ' sLine = Replace(sLine, String.Chr(65533), String.Chr(182)) '"?" unknow, "¶" Return
          Break
        Endif
      Next
      If ssExist.Find(sLine) = -1 Then ' no double (nicht doppelte Zeilen)
        ssExist.Add(sLine)
        ' sText = sText & sLine 
        ColumnView1[sKey].Picture = PicSave
        ColumnView1[sKey][F_iColumnSelect] = "PicSave"
      Else
        '..Leerlauf
        iDoubleLines = iDoubleLines + 1
        ColumnView1[sKey].Picture = PicDouble
        ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
      Endif 
      
    Else 
      ColumnView1[sKey].Picture = PicQuestion
      ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
    Endif
  Next
  If ssExist Then sText = ssExist.Join(hReturn)  '& hReturn
  
  ''Title:
  If sText Then 
    If String.InStr(sText, "#" & Application.Name) = 0 Then sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Projekt-Zeiten") & Space(1) & ("Trenner: TABulator") & gb.NewLine & sText 
  Endif

  If F_bESCpressedON = True Then Goto Ende
  
  ''Save:
  sPath = M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
  
  If F_sProjectOnlyName Then 
    Settings[FMain.Name &/ "F_sProjectOnlyName"] = F_sProjectOnlyName
    FMain.F_sProjectOnlyName = F_sProjectOnlyName
    FMain.F_sPathProject_txt = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject] &/ ("project_") & String.LCase(F_sProjectOnlyName) & ".txt"
  Endif 
  If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = F_sProjectOnlyName
  
  If F_iMusterTermine1Names2Projects3 = 2 Then 
    ''Project change?
    If F_sProjectOnlyName <> FMain.F_sProjectOnlyName Then 
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, Now, False) 'TRUE (open/refresh), FALSE (close)
      FMain.F_sProjectOnlyName = F_sProjectOnlyName
      ''Save:
      Settings[FMain.Name &/ "F_sProjectOnlyName"] = F_sProjectOnlyName
      FMain.F_dateProjectStart = Now
      M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, Now, True) 'TRUE (open/refresh), FALSE (close)
    Endif 
  Endif 
  
  If Exist(sPath) = True Then 
    If iDoubleLines > 0 Then ButtonLineNr.Text = ("Doppelte Zeilen") & ": " & Str(iDoubleLines)
    F_bListChanged = False
    sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size
  Else ''Alternativ:
    sMessage = sPath & hReturn 
    sMessage &= ("Datei nicht gefunden") & "!" & hReturn & hReturn 
    sMessage &= ("Liste speichern?")
    Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
      Case 1
        Dialog.Path = sDirFile
        Dialog.AutoExt = True 
        Dialog.Title = ("Liste speichern...")
        'If Dialog.SaveFile() Then Return 'Kurzform
        If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
          Return ' User pressed Cancel -
        Else 'Gibt Datei-Name zurück
          '=False, nicht abgebrochen
        Endif
        sPath = M01Functions.FileTextPlus(Dialog.Path, sText, True) ' TRUE=overwrite (überschreiben)
        If Exist(sPath) = True Then sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size 
        F_bListChanged = False
        'FMain.F_bNeueinlesenStarten = TRUE ' über Timer
      Case 2
        '... Cancel
    End Select
  Endif
  
Ende:
  ProgressBarONoff(False)
  If Exist(sPath) = True Then ''Check
    F_statFilePathForm = Stat(sPath) 'Refresh
    If sInfo1 = sInfo2 Then ' nicht gespeichert nicht verändert?
      TextBoxPath.Foreground = F_iColorRed
      IconError.Visible = True
      sMessage = sPath & "<br><br>" 
      sMessage &= "<font color=red>" & ("Nicht gespeichert?") & "</font>"
      Select Case Message.Warning(sMessage, ("Ordner..."), ("Abbrechen"))
        Case 1 'Directory
          M01Functions.FileManagerOpen(sPath)
        Case 2 'Cancel
          '...
      End Select 
    Else ''gespeichert
      ButtonSave.Background = Color.Default 
      F_iCVUndoRedoPointerSave = F_iCVUndoRedoPointer
    Endif
    TextBoxPath.Text = sPath '& Space(1) & Format(Stat(sPath).LastModified, "ddd dd.mm.yyyy hh:nn") & Space(3) & File.FormatSize(Stat(sPath).Size, True) 'Format(statInfo2.Size, "#,###") & "" & "Bytes"
    LabelInfoPathG(sPath)
  Endif 'Exist
  F_bKeyboardInput = F_bListChanged
  ColumnViewBackup()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  ' ColumnViewListChangeLED()
  If F_bListChanged = False Then ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Form5Projekte.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise
  Form5Projekte.Window.Title = F_sTitleBasicText
  
End

Public Sub ColumnView1_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  If Mouse.Right Then mnuMaus.Popup 'or > Eigenschaften PopupMenu = mnuMaus
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions("cut")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewClick()
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim iT8 As Integer
  Dim sKey, sValue As String
  Dim hDate, dateTime As Date
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    sKey = ColumnViewCurrentKey()
    If ColumnView1.Exist(sKey) = True Then 
      T0 = ColumnView1[sKey][0] 'Datum
      T1 = ColumnView1[sKey][1] 'Uhr
      T2 = ColumnView1[sKey][2] 'WTag von
      T3 = ColumnView1[sKey][3] 'Q
      T4 = ColumnView1[sKey][4] 'KW
      T5 = ColumnView1[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView1[sKey][6] 'Uhr
        T7 = ColumnView1[sKey][7] 'WTag bis
        T8 = ColumnView1[sKey][8] 'Sek.
        T9 = ColumnView1[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr  
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView1.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView1.Columns.Max > 5 Then ColumnView1.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    ' sKey = ColumnViewCurrentKey()
    sKey = ColumnView2.Current.Key
    sKey = ColumnView2[sKey][F_iColumnNr]
    If ColumnView1.Exist(sKey) = True Then 
      ColumnView1[sKey].Selected = True 
      ColumnView1[sKey].EnsureVisible
    Endif 
    sKey = ColumnView2.Current.Key
    If ColumnView2.Exist(sKey) = True Then 
      T0 = ColumnView2[sKey][0] 'Datum
      T1 = ColumnView2[sKey][1] 'Uhr
      T2 = ColumnView2[sKey][2] 'WTag von
      T3 = ColumnView2[sKey][3] 'Q
      T4 = ColumnView2[sKey][4] 'KW
      T5 = ColumnView2[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView2[sKey][6] 'Uhr
        T7 = ColumnView2[sKey][7] 'WTag bis
        T8 = ColumnView2[sKey][8] 'Sek.
        T9 = ColumnView2[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr 
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr 
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView2.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView2.Columns.Max > 5 Then ColumnView2.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateTimeNoticeBackup(Optional UndoRedo As String = "+")
  
  Dim hObj As Object
  
  Select Case UndoRedo
    Case "+" ''Backup
      If Not F_ooDateTimeNoticeBackup Then F_ooDateTimeNoticeBackup = New Object[]  
      hObj = [Text0.Text, Text1.Text, Text5.Text, Text2.Text]
      F_ooDateTimeNoticeBackup.Push(hObj)
      F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
    Case "<" ''Undo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer - 1
        If F_iDateTimeNoticeBackupPointer < 0 Then F_iDateTimeNoticeBackupPointer = 0
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
    Case ">" ''Redo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer + 1
        If F_iDateTimeNoticeBackupPointer > F_ooDateTimeNoticeBackup.Max Then F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function Columnview1EnsureVisible() As String 'Key
  
  Dim sK2 As String 
  
  If ColumnView1.Visible = True Then 
    If ColumnView1.Current Then 
      sK2 = ColumnView1.Current.Key
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Else If ColumnView2.Visible = True Then 
    If ColumnView2.Current Then 
      sK2 = ColumnView2.Current.Key
      If ColumnView2.Exist(sK2) = True Then ColumnView2[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Endif 
  
  Return sK2
  
  Catch 
    FMain.ErrorText
  
End

Public Sub ButtonInputG() 'Zeileneintrag einfügen
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim T0b, T1b, T2b, T3b, T4b, T5b As String 
  Dim sLine, sText, sMessageLines As String
  Dim sValue, sMessage, sHTMLa, sHTMLb, sSpace, sUntil As String
  Dim sKey As String
  Dim iSecond, iHH, iMM As Integer
  Dim it, iLine, iDiff, iCounter, iOnly1x As Integer
  Dim hDate0, hDate1, hDate2, hDateNr As Date
  Dim sTime1, sTime2 As String 
  Dim ssTime As String[]
  Dim PicRefresh As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  F_bESCpressedON = False
  PicRefresh = ColumnViewImages("PicRefresh").Picture 
  
  sHTMLa = "<font color=darkgreen><b>"
  sHTMLb = "</b></font>"
  sSpace = "&nbsp;" 'Leerzeichen 1x
  Try sUntil = "<font color=#" & Hex(Label7Bis.Foreground, 6) & ">" & ButtonBis.Text & "</font>"
  
  If Not F_ooCVBackups Then ColumnViewBackup()
  
  Columnview1EnsureVisible()
  
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T1 = Text1.Text
    T2 = Format(hDate1, "ddd")
    T3 = Str(M01Functions.DateQuarterG(hDate1)) & ("Q")
    T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      T6 = Text2.Text
      T7 = T2
      T8 = ButtonSum.Tooltip
      T9 = ButtonDauer.Text
      
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then iSecond = 0
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Else 
    ''Timer
    T0 = Text0.Text
    T1 = Text1.Text
    T2 = T0
    T3 = ("-Q")
    T4 = ("-KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
  Endif
  
  sKey = ColumnViewCurrentKey() 'as String 
  If sKey Then
    ColumnView1[sKey][0] = T0
    ColumnView1[sKey][1] = T1
    ColumnView1[sKey][2] = T2
    ColumnView1[sKey][3] = T3
    ColumnView1[sKey][4] = T4
    ColumnView1[sKey][5] = T5
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      If Not T8 Then T8 = ButtonSum.Tooltip
      If Not T9 Then T9 = ButtonDauer.Text
      ButtonSum.Tooltip = T8
      ButtonDauer.Text = T9
      ColumnView1[sKey][6] = T6
      ColumnView1[sKey][7] = T7
      ColumnView1[sKey][8] = T8
      ColumnView1[sKey][9] = T9
    Endif 
    ColumnView1[sKey].Picture = PicRefresh
    ColumnView1[sKey][F_iColumnSelect] = "PicRefresh"
    F_bListChanged = True
    F_iListChangedCounter = F_iListChangedCounter + 1
  Endif 
  
  If PanelBis.Visible = True Then '{{{{{{{{{{{{{...}}}}}}}}}}}}}
    sValue = Text0b.Text
    If sValue Like "*????-??-??*" Then
      hDate2 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
      iDiff = DateDiff(hDate1, hDate2, gb.day)
      T5 = Replace(String.Left(T5, 3), "{", "") & String.Mid(T5, 4) 'erst vorne Klammern entfernen
      T5 = Replace(String.Left(T5, 3), "}", "") & String.Mid(T5, 4)
      Try it = String.InStr(T5, "_", -Len(T5)) ' Ende mit mehreren "_" entfernen 
      If it > 0 Then T5 = String.Left(T5, it)
      sText = ""
      iCounter = 0
      iOnly1x = 0
      For it = 0 To iDiff
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        iCounter = iCounter + 1
        hDateNr = DateAdd(hDate1, gb.Day, it) 'gb.Day=Integer, it=Integer
        T0b = Format(hDateNr, "yyyy-mm-dd")
        T1b = T1
        T2b = Format(hDateNr, "ddd")
        T3b = Str(M01Functions.DateQuarterG(hDateNr)) & ("Q")
        T4b = Format(M01Functions.DateCalenderWeek(hDateNr), "00") & ("KW") '00...52
        T5b = String.Left(T5, 30) & "_"
        If it = 0 Then T5b = T5 & "_"  'Anfang mit ganzem Text & "_"
        If it = iDiff Then T5b = "}" & T5b
        If it = 0 Then T5b = "{" & T5b  '{}
        sLine = T0b & hTab & T1b & hTab & T2b & hTab & T3b & hTab & T4b & hTab & T5b & hReturn
        sText = sText & sLine ' —▶ append (kompletter Text für Datei, > anhängen)
        If it < 4 Or it = iDiff Then '1,2,3... + last line
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Else If it = 4 Then '1x...
          sMessageLines &= "<br><b>" & "..." & "</b><br>" 
        Else If it > iDiff - 4 Then 
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Endif
      Next
      sMessageLines &= "<hr>"  'Separator line (Trennlinie) ———————— 
      If iCounter = 1 Then
        sValue = ("Zeile")
      Else
        sValue = ("Zeilen")
      Endif
      sMessage = "<h3>" & sHTMLa & Format(hDate1, "yyyy-mm-dd ddd") & sSpace & sUntil & sSpace & Format(hDate2, "yyyy-mm-dd ddd") & sHTMLb & "</h3>"  
      sMessage &= sMessageLines & "<br>" 
      sMessage &= "<h3>" & "+" & Str(iCounter) & sSpace & sValue & "." & sSpace & sHTMLa & ("+Einfügen in die Liste") & "?" & sHTMLb & "</h3>"
      
      ProgressBarONoff(False) 
      Select Case Message.Question(sMessage, ("+Einfügen"), ("Abbrechen"))
        Case 1
          PanelBis.Visible = False
          F_sLinesCopy = sText 
          ColumnViewPaste() 
          F_bListChanged = True
        Case 2 ' Cancel
          '...
      End Select
      
    Endif 
  Endif 'PanelBis {{{{{{{{{{{{{{{{{{{{{{{{{{
  
  TextBackgroundAll(Color.White)
  ButtonSave.Background = Color.Red
  ButtonInput.Background = F_iColorGreen
  ColumnViewBackup()
  ColumnViewListChangeLED()
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonInputCheck() 'calculate Line new (Zeileneintrag neu berechnen)
  
  Dim T0, T5, T8, T9 As String 
  Dim iSecond, iT8, iHH, iMM As Integer
  Dim hDate0, hDate1, hDate2 As Date
  Dim sTime1, sTime2 As String
  Dim ssTime As String[]
  Dim sValue As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Returnzeichen ¶ ersetzen
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If T0 <> Text0.Text Then Text0Insert(T0)
    If T5 <> Text5.Text Then Text5Insert(T5)
    
    If F_iMusterTermine1Names2Projects3 = 3 Then
      T8 = ButtonSum.Tooltip
      If IsInteger(T8) = True Then iT8 = CInteger(T8)
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        If iT8 > 0 Then hDate2 = DateAdd(hDate1, gb.Second, iT8) 'Seconds (genauer)—▶ 00:00:00
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then 
          iSecond = 0
          ColumnViewInfo(("Projekt-Zeit eingeben/korrigieren."))
        Else 
          ColumnViewInfo(("=neu berechnet"))
        Endif 
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Endif
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektEin_Click()
  
  ProjectONoff(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektAus_Click()
  
  ProjectONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLineSelection()
  
  Dim bFound As Boolean
  Dim sKey, sK1, sT5, sPath As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicOff = ColumnViewImages("PicOFF").Picture 
  
  If Not F_sProjectOnlyName Then F_sProjectOnlyName = ProjectOnlyName()
  
  ' ColumnView1.UnselectAll()   
  ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey][0] <> "" Then
      ColumnView1[sKey].Picture = PicOff
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF"
      sT5 = String.LCase(ColumnView1[sKey][5])
      sT5 = Replace(sT5, gb.NewLine, "") 'no new line "\n" = Chr(10)
      sT5 = Replace(sT5, gb.Cr, "") 'no Return "\r" = Chr$(13)            gb.CrLF = Chr(13) & Chr(10)
      If sT5 = F_sProjectOnlyName Then
        ColumnView1[sKey].Picture = PicON
        ColumnView1[sKey][F_iColumnSelect] = "PicON"
        ColumnView1[sKey].EnsureVisible
        ColumnView1[sKey].Selected = True
        sK1 = sKey
        bFound = True
        Text0Insert(ColumnView1[sKey][0])
        Text1Insert(ColumnView1[sKey][1])
        Text5Insert(ColumnView1[sKey][5])
        ButtonProjectON.Picture = PicTemplateConnectON.Picture
      Endif
    Endif
  Next
  CheckBoxONoff.Value = bFound
  CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
  sPath = CheckProjectOnlyName(Text5.Text) 'Dir/File.txt < (F_sProjectOnlyName) 
  sPath = Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt] '..."projects_names.txt"
  If Exist(sPath) = True Then
    TextBoxPath.Text = sPath
  Else
    TextBoxPath.Text = ("Ohne Datei")
  Endif
  If ColumnView1.Exist(sK1) = False Then sK1 = ColumnView1.Keys.Last
  If ColumnView1.Exist(sK1) = True Then 
    If ColumnView1[sK1][5] = F_sProjectOnlyName And bFound = True Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture 
    Else 
      ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    Endif 
    ColumnView1[sK1].EnsureVisible
    If ColumnView1[sK1][5] = "" Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture
    Endif 
  Endif 
  
  ColumnViewInfo(("Aktivieren") & ": " & Space(1) & F_sProjectOnlyName)
  WindowTitle()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectONoff(Optional bONoff As Boolean = False)
  
  Dim bFound As Boolean 
  Dim sKey, sK1, sT5 As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  If F_iMusterTermine1Names2Projects3 = 2 Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    PicON = ColumnViewImages("PicON").Picture 
    PicOff = ColumnViewImages("PicOFF").Picture 
    
    If Not F_sProjectOnlyName Then F_sProjectOnlyName = ProjectOnlyName()
    
    sK1 = ColumnViewCurrentKey()
    
    If ColumnView1.Exist(sK1) = True Then 
      If Not ColumnView1[sK1][5] Then 
        F_sProjectOnlyName = ProjectOnlyName()
        Text0Insert(Format(Now, "yyyy-mm-dd"))
        Text1Insert(Format(Now, "hh:nn"))
        Text5Insert(F_sProjectOnlyName)
      Else 
        F_sProjectOnlyName = ColumnView1[sK1][5]
        Text0Insert(ColumnView1[sK1][0])
        Text1Insert(ColumnView1[sK1][1])
        Text5Insert(ColumnView1[sK1][5])
      Endif 
    Endif 
    
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView1[sKey].Picture = PicOff 
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF" 'all
      ColumnView1[sKey].Selected = False
    Next 
    F_bListChanged = True
    If sK1 And bONoff = True Then
      If ColumnView1[sK1][0] <> "" Then
        ColumnView1[sK1].Picture = PicON
        ColumnView1[sK1][F_iColumnSelect] = "PicON"
        ColumnView1[sK1].EnsureVisible
        ColumnView1[sK1].Selected = True
        'Check Name:
        sT5 = ColumnView1[sK1][5]
        ' sT5 = Text5.Text
        sT5 = Replace(sT5, "/", "_") 'no Directory
        sT5 = Replace(sT5, Space(1), "_") 'no Space
        sT5 = Replace(sT5, gb.Tab, "") 'no Tabulator
        sT5 = Replace(sT5, gb.NewLine, "") 'no Return
        
        ColumnView1[sK1][5] = String.LCase(sT5)
        bFound = True
        Text0Insert(ColumnView1[sK1][0])
        Text1Insert(ColumnView1[sK1][1])
        Text5Insert(ColumnView1[sK1][5])
        F_sProjectOnlyName = ColumnView1[sK1][5]
        F_bListChanged = True
        ButtonSave.Background = Color.Red
        ColumnViewBackup()
        ColumnViewListChangeLED()
        WindowTitle()
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Endif
    Endif
    If bONoff = False Then F_sProjectOnlyName = String.LCase(Application.Name)
    CheckBoxONoff.Value = bONoff 
    CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
    ' If bFound = False Then ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    ' If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
    ColumnViewInfo(("Aktivieren") & ": " & Space(1) & F_sProjectOnlyName)
    ' Print F_sProjectOnlyName
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLinesSaveRefresh()
  
  Dim sKey As String 
  Dim PicEmpty, PicON, PicAdd, PicSave As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicAdd = ColumnViewImages("PicAdd").Picture 
  PicSave = ColumnViewImages("PicSave").Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Picture = PicON Then F_sProjectOnlyName = ColumnView1[sKey][5]
    If ColumnView1[sKey].Picture <> PicAdd Then 
      ColumnView1[sKey].Picture = PicEmpty ' Bild entladen
      ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
    Endif 
    If ColumnView1[sKey][0] <> "" Then 
      ColumnView1[sKey].Picture = PicSave
      ColumnView1[sKey][F_iColumnSelect] = "PicSave"
    Endif 
  Next
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckProjectOnlyName(Optional sCheckProjectName As String = "") As String 
  
  Dim sDir, sTempPathTest As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  If Not sCheckProjectName Then sCheckProjectName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]) 'Einheitliche kleinschreibung
  
  ''Check
  sCheckProjectName = Replace(sCheckProjectName, "/", "_") 'no Directory
  sCheckProjectName = Replace(sCheckProjectName, Space(1), "_") 'no Space
  sCheckProjectName = Replace(sCheckProjectName, gb.NewLine, "") 'no Return
  sCheckProjectName = String.LCase(sCheckProjectName)
  
  ' sTempPathTest = M01Functions.FileTempDirFileTxt(sCheckProjectName)
  sTempPathTest = M01Functions.CheckDirectoryCache() &/ sCheckProjectName & ".txt"
  Try File.Save(sTempPathTest, "Test" & Now) 'temp-Files werden am Programm-Ende automatisch gelöscht.
  If Exist(sTempPathTest) = True Then 
    Text5Insert(sCheckProjectName)
    ButtonTest.Picture = PicTemplateBookA.Picture
    ButtonTest.Tooltip = ("Test. Als Datei-Name geeignet") & ": " & Space(1) & ("project_") & sCheckProjectName & ".txt"
    PanelText5.Background = F_iColorGreenAlpha150
  Else 
    ButtonTest.Picture = PicTemplateBookQuestion.Picture 'Picture["icon:/32/help"]
    ButtonTest.Tooltip = ("Test. Nicht als Datei-Name geeignet. Ungültige Zeichen?") & Space(1) & ("Eingabe") & ": " & ("Abc-z, 0-9")
    PanelText5.Background = F_iColorRedAlpha150
  Endif 
  ColumnViewInfo(ButtonTest.Tooltip)
  Return sDir &/ ("project_") & sCheckProjectName & ".txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewCurrentKey() As String 
  
  Dim sKey As String 
  
  If ColumnView1.Selection.Max = -1 Then ListMenuGroupFunctions("addappend")
  If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last 'only Key (number)
  ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  Return sKey
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5_MouseDown()
  
  PanelText5.Background = Color.White
  F_iText5SearchPosition = Text5.Pos
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_KeyPress()
  
  DateChooser1.Tag = "0"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_Change()
  
  Dim hDate As Date
  
  hDate = M01Functions.DateCheckyyyymmddhhnn(Text0b.Text, "00:00") 'as Date
  If hDate Then
    Label3b.Text = Format(hDate, "dddd") 'as Date
    Label3b.Foreground = Color.Default
    Text0bBG.Background = F_iColorGreenAlpha150
  Else
    Label3b.Text = "?"
    Label3b.Foreground = Color.Red
    Text0bBG.Background = F_iColorRedAlpha150
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_KeyPress()
  
  DateChooser1.Tag = "0b"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SelectHide0Date1Clock2Timer3(Optional iHide0_Date1_Clock2_Timer3_Clock4 As Integer = 0)
  
  Dim sValue As String
  Dim hDate As Date
  
  DateChooser1.Visible = False
  ColumnView1.Visible = True
  ColumnView2.Visible = False
  ColumnView3.Visible = False
  ScrollViewWeekDay.Visible = False
  ButtonDateCancel.Visible = False
  PanelSearchList.Visible = False
  
  Select Case iHide0_Date1_Clock2_Timer3_Clock4
    Case 0 'ohne
      ColumnView1.Visible = True
      If LabelTimerWT.Tag And Text0.Text <> LabelTimerWT.Tag Then Text0Insert(LabelTimerWT.Tag)
      LabelTimerWT.Tag = Null
    Case 1 'Datum
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
      If DateChooser1.Tag = "0" Then
        sValue = Text0.Text
      Else
        PanelBis.Visible = True
        sValue = Text0b.Text
        If sValue Like "????-??-??" Then
          '...Leerlauf
        Else
          sValue = Format(Date, "yyyy-mm-dd")
        Endif
      Endif
      
      If String.InStr(sValue, "-") = 0 Then
        '...Leerlauf
        hDate = Date
      Else
        If sValue Like "????-??-??" Then
          
          hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        Else
          hDate = Date
        Endif
      Endif
      DateChooser1.Mode = DateChooser1.DateOnly
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      ButtonDateCancel.Visible = True
    Case 2 ''Uhr
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView3.Left + ColumnView3.W, ColumnView1.Top, ColumnView1.Width - ColumnView3.W, ColumnView1.Height)
      DateChooser1.Mode = DateChooser1.DateTime 'TimeOnly
      If DateChooser1.Tag = "1" Then 
        If IsDate(Text1.Text) = True Then Try hDate = Time(CDate(Text1.text)) Else hDate = Time
      Else  
        If IsDate(Text2.Text) = True Then Try hDate = Time(CDate(Text2.text)) Else hDate = Time
      Endif 
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      
      ClockTimeList0to24h()
      ButtonDateCancel.Raise 
      ColumnView3.Raise 
      ColumnView3.Visible = True
      ButtonDateCancel.Visible = True
    Case 3 ''Timer
      ScrollViewWeekDay.Raise 
      ButtonDateCancel.Raise
      ScrollViewWeekDay.Visible = True
      If Text0.Text Not Like "????-??-??" Then TextBoxWT.Insert(Text0.Text)
      ButtonDateCancel.Visible = True
    Case 4 ''{Bis}
      If F_iMusterTermine1Names2Projects3 = 1 Then 
        If Text0b.Text Like "????-??-??" Then
          'Leerlauf
        Else
          Text0bInsert(Format(Date, "yyyy-mm-dd"))
        Endif
        PanelBis.Visible = True
        PanelBis.Raise
        ButtonBis.Background = Label7Bis.Background
        Text0b.Pos = String.Len(Text0b.Text)
        ' Text0b.SetFocus
      Endif 
    Case Else ''ohne
      ColumnView1.Visible = True
  End Select
  ButtonInput.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0Insert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0.Text <> sDatum Then 
    Text0.SelectAll()
    Text0.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0bInsert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0b.Text <> sDatum Then 
    Text0b.SelectAll()
    Text0b.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1Insert(Optional sTime As String = "hh:nn")
  
  If Text1.Text <> sTime Then 
    Text1.SelectAll()
    Text1.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2Insert(Optional sTime As String = "hh:nn")
  
  If Text2.Text <> sTime Then 
    Text2.SelectAll()
    Text2.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Insert(Optional sNotiz As String = ("Notiz"))
  
  Text5.Clear()
  Text5.SelectAll()
  Text5.Insert(sNotiz)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_Change() 'yyyy-mm-dd
  
  Dim sValue, sLine, Info As String
  Dim hDate As Date
  
  If Text0.Tag <> "" Then Goto Ende
  Text0BG.Background = Color.White
  If Text0.Text = "" Then Goto Ende
  If Text0.Text Like "????-??-??" Then                                                  ''Datum
    If Error Then Error.Clear()
    sValue = Text0.Text
    
    hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    If hDate = Null Then
      Text0BG.Background = F_iColorRedAlpha150
      ButtonWeekDay.Text = "?"
      ButtonWeekDay.Tooltip = ("Wochentag")
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Else
      ButtonWeekDay.Text = Format(hDate, "ddd") 'as Date
      ButtonWeekDay.Tooltip = Format(Date, "dddd")
      Text0BG.Background = Color.White
    Endif
  Else If String.InStr(sValue, "-") = 0 Then                                                     ''Timer
    sValue = String.LCase(Text0.Text)
    sLine = M01Functions.CheckTimerTextWeekdays0to6(sValue) 'as String, Check  Timer  SoMoDiMiDoFrSa
    If sLine <> "" Then
      Text0BG.Background = F_iColorGreenAlpha150
      Info = ("Timer") & ": " & sLine
    Else
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Endif
  Endif
  If Info Then ColumnViewInfo(Info)
Ende:
  F_bChangeON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBackgroundAll(Optional iColor As Integer = Color.Transparent)
  
  Text0BG.Background = iColor
  Text0bBG.Background = iColor
  Text1BG.Background = iColor
  Text2BG.Background = iColor
  PanelText5.Background = iColor
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Data(dateValue As Date) ' dateValue frei gewählter Variablenname  gambas3
  
  If WeekDay(dateValue) = gb.Friday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Blue, 220) '&HC3DDFF
  Else If WeekDay(dateValue) = gb.Sunday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Yellow, 200)
  Endif 
  DateChooser1.Colors[Date] = Color.Green 'heute
  'Info:
  'DateChooser1.Mode = DateChooser1.DateOnly
  'DateChooser1.Colors.Clear()
  'DateChooser1.Data.Foreground = Color.Red
  'DateChooser1.Data.Font = Font["Italic"] 
  'DateChooser1.Colors["12/31/2000"] = Color.Green ' System, engl. 
  'DateChooser1.Mode = DateChooser1.DateTime 'Kalender- und Zeit-Tabelle, Heute + aktuelle Uhr
  
Catch 
  FMain.ErrorText
  
End ' DateChooser1_Data(dateValue As Date)

Public Sub TextNeuClear()
  
  Dim sMessage As String 
  
  sMessage = "<h3><font color=blue>" & "□" & Space(1) & TextNeu.Tooltip & "?" & "</font></h3>" 
  
  Select Message.Question(sMessage, "+" & ("Neue Zeile"), "□" & Space(1) & TextNeu.Tooltip, ("Abbrechen")) '(0,1,2,3)
    Case 1 'New Line
      NewLineG()
      
    Case 2 'New Input
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd")) 'Text0.Text
      Text1Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      ' Text5.SetFocus
      TextBackgroundAll(Color.White)
      
    Case 3 'Cancel
      '...Abbrechen
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text1.Tag <> "" Then Goto Ende
  Text1BG.Background = Color.White
  If Text1.Text Like "??:??" Then 
    Text1BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text1.Text, 1, 2)
    sMM = String.Mid(Text1.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text1BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text1BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text1.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text2.Tag <> "" Then Goto Ende
  Text2BG.Background = Color.White
  If Text2.Text Like "??:??" Then 
    Text2BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text2.Text, 1, 2)
    sMM = String.Mid(Text2.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text2BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text2BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text2.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewReload()
  
  If F_bListChanged = True Then
    ColumnView2.Visible = False 
    Select Message.Question("<h3><font color=red>" & ("Veränderte Liste") & "</font></h3>", ("Speichern + Neu laden"), ("Neu laden"), ("Abbrechen"))
      Case 1 'Save + Reload (Speichern + neu laden)
        SaveG()
        ReadG()
      Case 2 'Reload (Neu laden)
        ReadG()
      Case 3 'Cancel (Abbrechen)
        '...
    End Select
  Else
    ReadG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSucheG()
  
  If PanelSearchList.Visible = False Then
    PfeilEinfuegen.Visible = False 
    PanelSearchList.Raise() 'Top ▲Level▲ (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    PanelSearchList.Visible = True
    If ButtonSearchListOn.Background <> Color.Green Then 
      ColumnView2.Visible = False
    Else
      ColumnView2.Visible = True
    Endif
    If TextListSearch.Text = "" Then TextListSearch.Text = Format(Date, "yyyy-mm-")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
    TextListSearch.SetFocus
  Else
    PanelSearchList.Visible = False
    PfeilEinfuegen.Visible = True 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CancelSearchG()
  
  PanelSearchList.Visible = False
  SelectHide0Date1Clock2Timer3(0)
  PanelDatum.Visible = True 
  PfeilEinfuegen.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchMinusPlus(Optional sMinusPlus As String = "+")
  
  Dim sSearchText, sLine, sKey As String
  Dim it, iLine As Integer
  Dim iBefore As Integer
  Dim bFound As Boolean
  
  If ColumnView2.Visible = True Then 
    SearchListG()
    If sMinusPlus = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnselectAll()
    Goto Ende
  Endif
  
  If String.InStr(TextListSearch.Text, gb.NewLine) > 0 Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, "")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
  Endif
  sSearchText = String.LCase(TextListSearch.Text)
  sSearchText = Replace(sSearchText, Space(1), "*") ' Leerzeichen ersetzen für beliebige Zeichen bei Suche
  sSearchText = "*" & sSearchText & "*"
  iBefore = F_iSearchPosition
  
  If sMinusPlus = "+" Then '+++++++++++++++++++++++++++++
    F_iSearchPosition = F_iSearchPosition + 1
    If F_iSearchPosition > ColumnView1.Count - 1 Then F_iSearchPosition = ColumnView1.Count - 1
    For it = F_iSearchPosition To ColumnView1.Count - 1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Else '-------------------------------------------------
    F_iSearchPosition = F_iSearchPosition - 1
    If F_iSearchPosition < 0 Then F_iSearchPosition = 0
    For it = F_iSearchPosition To 0 Step -1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Endif
  
  If bFound = True
    ButtonSearchDown.Background = Color.Default
    ButtonSearchUp.Background = Color.Default
  Else
    F_iSearchPosition = iBefore
    If sMinusPlus = "-" Then
      ButtonSearchDown.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
    If sMinusPlus = "+" Then
      ButtonSearchUp.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
  Endif ' bFound
Ende:
  
  If ColumnView1.Selection.Max > -1 Then sKey = (Val(ColumnView1.Current.Key) + 1) Else sKey = "?" 
  LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  LabelSearchLineNr.ToolTip = LabelSearchLineNr.Text
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelSearchLineNr_MouseDown()
  
  TextListSearch.Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextListSearch_KeyPress()
  
  If Key.Code = Key.Return Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, String.Chr(182)) '¶
    Timer3KeyPress.Start 'ButtonSearchG() not in Loop _KeyPress
    Stop Event 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSearchG()
  'SearchMinusPlus("+")
  
  ColumnViewFind("+")
  If Timer3KeyPress.Enabled = False Then SearchListG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchListG()
  
  If ButtonSearchListOn.Background <> Color.Green Then 
    ColumnView2.Visible = False
    ColumnView1.Visible = True
    ColumnView2select1() 'ColumnView2 —▶ ColumnView1
  Else 
    SearchPanelList()
    ColumnView2.Raise
    ColumnView2.Visible = True
    ColumnView1.Visible = False
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelList()
  
  Dim it, iColumn, iLine As Integer
  Dim sK1, sSearchText, sLine As String
  Dim PicFind As Picture
  
  PicFind = ColumnViewImages("PicFind").Picture 
  sSearchText = "*" & Replace(TextListSearch.Text, Space(1), "*") & "*"
  ColumnView2.Clear()
  ColumnView2.Header = True  ' Sichtbar
  'Create Columns (Spalten erzeugen):
  If ColumnView2.Columns.Count <> ColumnView1.Columns.Count Then ColumnView2.Columns.Count = ColumnView1.Columns.Count '+ 1
  For it = 0 To ColumnView1.Columns.Count - 1 'Header/Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
    ColumnView2.Columns[it].Text = ColumnView1.Columns[it].Text
    ColumnView2.Columns[it].Alignment = ColumnView1.Columns[it].Alignment
  Next
  For Each sK1 In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sLine = String.LCase(Str(ColumnView1[sK1][0] & ColumnView1[sK1][1] & ColumnView1[sK1][2] & ColumnView1[sK1][3] & ColumnView1[sK1][4] & ColumnView1[sK1][5] & ColumnView1[sK1][F_iColumnSelect]))
    If sLine Like sSearchText Then 
      ColumnView2.Add(sK1, "", PicFind)
      ColumnView2[sK1][F_iColumnSelect] = "PicFind"
      For iColumn = 0 To ColumnView1.Columns.Count - 1
        ColumnView2[sK1][iColumn] = ColumnView1[sK1][iColumn]
      Next
    Endif
  Next
  ColumnView2.Columns[5].Title = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")   '"  [Strg+Maus]")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_Click()
  
  Dim sKey As String 
  
  sKey = Val(ColumnView2.Current.Key) + 1
  LabelSearchLineNr.Text = ("Zeile") & Space(1) & Str(sKey)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2select1()                                                               'ColumnView2 —▶ ColumnView1
  
  Dim sK2 As String 
  Dim iLine As Integer
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    ColumnView1.Mode = Select.Multiple
    For Each sK2 In ColumnView2.Selection 'Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].Selected = True
    Next
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  Dim sInfo, sSizeAll As String
  Dim it As Integer
  
  sSizeAll = Space(1) & "=" & Space(1) & File.FormatSize(F_longFilesRead, False) 'as String   
  
  If ColumnView1.Count < 2 Then 
    sInfo = Space(2) & ("Leer. Datei öffnen oder +Einfügen") 
  Else 
    If F_iMusterTermine1Names2Projects3 > 1 Then sInfo = Space(3) & ("Projekt-Name") 
    sInfo = ("Notiz") & sInfo & Space(2) & ("Zeilen") & ": " & ColumnView1.Count & sSizeAll
  Endif 
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ColumnView1.Columns[1].Title = ("Uhr")     '00:00 Begin
  ColumnView1.Columns[2].Title = Space(1)    'Su Weekday (Wochentag) 
  ColumnView1.Columns[3].Title = Space(1)    '0Q Quater (Quartal)
  ColumnView1.Columns[4].Title = Space(1)    '0CW CalenderWeek (KalenderWoche)
  ColumnView1.Columns[5].Title = sInfo       'Notice (Notiz)
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Title = ""          'Nr
    ColumnView1.Columns[7].Title = ""          'Undo
    ColumnView1.Columns[8].Title = ""          'Select01
    ColumnView1.Columns[9].Title = ""          'Sort
  Else 
    ColumnView1.Columns[6].Title = ("Uhr")     '00:00 End
    ColumnView1.Columns[7].Title = ""          'Su Weekday (Wochentag)
    ColumnView1.Columns[8].Title = ""          'Seconds 123 (Sekunden)
    ColumnView1.Columns[9].Title = ("Dauer")   '00:00:00 Duration  
  Endif 
  
  ColumnView1.Columns[0].Width = 200
  ColumnView1.Columns[1].Width = 80
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 80
  ColumnView1.Columns[5].Width = 0           'Notice
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Width = 0
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 0  
  Else 
    ColumnView1.Columns[6].Width = 50          '00:00 End
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 100         '00:00:00 Duration  
  Endif 
  
  For it = 10 To ColumnView1.Columns.Max     '>9 or >13
    ColumnView1.Columns[it].Title = ""         'ColumnsUndo
    ColumnView1.Columns[it].Width = 0          'ColumnsUndo
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[F_iColumnUndo].Left 
  
  If ColumnView2.Visible = True Then ColumnView2Resize() 
  ColumnViewAscending()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13     F_iColumnsCount=14
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnView2Resize()                                                            'ColumnView2 = ColumnView1
  
  Dim sInfo As String
  Dim it As Integer
  
  sInfo = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")
  ColumnView2.Columns.Count = ColumnView1.Columns.Count                                   'Columns:|0|1|2|3|...|max|
  ColumnView2.Header = ColumnView1.Header                                                 'Title, Row index=0
  ColumnView2.Mode = ColumnView1.Mode
  ColumnView2.AutoResize = ColumnView1.AutoResize 'last column in last row  |abc| => |abcdef>>| 
  ColumnView2.Sorted = ColumnView1.Sorted
  ColumnView2.Resizable = ColumnView1.Resizable                                           'Header <|> <|> Resize with Mouse
  ColumnView2.Columns.Ascending = ColumnView1.Columns.Ascending     '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ColumnView2.Columns[0].Alignment = ColumnView1.Columns[0].Alignment                     '|  123|
  ColumnView2.Columns[2].Alignment = ColumnView1.Columns[2].Alignment                     '| abc |
  ColumnView2.Columns[6].Alignment = ColumnView1.Columns[6].Alignment                     '|  123|
  
  For it = 0 To ColumnView1.Columns.Max
    ColumnView2.Columns[it].Title = ColumnView1.Columns[it].Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
  Next
  ColumnView2.Columns[5].Width = 0
  ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[F_iColumnUndo].Left
  ColumnView2.Columns[5].Title = sInfo
  '.AutoResize width = longest text in Column in last row
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ColumnView2_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  If Mouse.Right Then mnuMaus2.popup '> Eigenschaften PopupMenu = mnMaus2
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions(ListCut.Tag) '"cut"
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBox1G() '*every Year, Birthsdays (*jedes Jahr, Geburtstage)
  
  Select Case CheckBox1.Value
    Case True
      If String.Left(Text5.Text, 1) <> "*" Then Text5Insert("*" & Text5.Text) 'with (mit)
    Case False
      If String.Left(Text5.Text, 1) = "*" Then Text5Insert(String.Mid(Text5.Text, 2)) 'without (ohne)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5JedesJahrpruefen()
  
  If String.Left(Text5.Text, 1) = "*" Then
    CheckBox1.Value = True
  Else
    CheckBox1.Value = False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_MouseUp()
  
  DateChooser1.Tag = "0"
  If DateChooser1.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(1)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_MouseUp()
  
  DateChooser1.Tag = "0b"
  SelectHide0Date1Clock2Timer3(1)
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Change()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then
    Text0Insert(sYYYYMMDD)
  Else If DateChooser1.Tag = "0b"
    Text0bInsert(sYYYYMMDD) 'gambas3
  Else If DateChooser1.Tag = "1"
    If Text0.Text Like "????-??-??" Then 
      If Text0.Text <> sYYYYMMDD Then Text0Insert(sYYYYMMDD)
    Endif 
    Text1Insert(sHHNN)
  Else If DateChooser1.Tag = "2"
    Text2Insert(sHHNN)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Click()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then Text0Insert(sYYYYMMDD)
  If DateChooser1.Tag = "0b" Then Text0bInsert(sYYYYMMDD)
  If DateChooser1.Tag = "1" Then Text1Insert(sHHNN) '00:00 A
  If DateChooser1.Tag = "2" Then Text2Insert(sHHNN) '00:00 B
  If ColumnView3.Visible = True Then ColumnView3Select(sHHNN)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_MouseUp()
  
  DateChooser1.Tag = "1"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_MouseUp()
  
  DateChooser1.Tag = "2"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h()
  
  Dim iHH, iMM, iCounter, iSelect As Integer
  Dim sValue As String
  
  ColumnView3.Clear()
  ColumnView3.Header = False 'without Title (ohne Titel)
  ColumnView3.Sorted = False 'no sort (nicht sortieren!)
  ColumnView3.Columns.Count = 1 'Number Columns (Anzahl Spalten)
  ColumnView3.Columns[0].Width = ColumnView3.Width
  For iHH = 0 To 23 'Hours (Stunden) hh:
    For iMM = 0 To 59 'Minutes (Minuten) :nn
      sValue = Format(iHH, "00") & ":" & Format(iMM, "00")
      iCounter = ColumnView3.Count + 1
      ColumnView3.Add(iCounter, sValue)
      If iMM Mod 10 = 0 Then ''00:00, 00:15, 00:30, ...
        ColumnView3[iCounter].Foreground = Color.Default 
      Else 
        ColumnView3[iCounter].Foreground = Color.LightGray  
      Endif 
      If iMM Mod 30 = 0 Then ''00:00, 00:30, 01:00, ... 
        ColumnView3[iCounter].Background = Color.LightGray 
      Endif 
      If Text1.Text = ColumnView3[iCounter].Text Then
        iSelect = iCounter
      Endif
    Next
  Next
  sValue = "00:00"
  iCounter = ColumnView3.Count + 1
  ColumnView3.Add(iCounter, sValue)
  ColumnView3[iSelect].Selected = True
  ColumnView3[iSelect].EnsureVisible
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3Select(Optional sClock As String = "00:00")
  
  Dim sKey, sFound As String 
  
  If ColumnView3.Keys Then 
    ColumnView3.UnSelectAll()
    For Each sKey In ColumnView3.Keys
      If ColumnView3[sKey].Text = sClock Then 
        ColumnView3[sKey].Selected = True
        sFound = sKey  
        Break
      Endif 
    Next 
    If ColumnView3.Exist(sFound) = True Then 
      ColumnView3[sFound].Selected = True
      ColumnView3[sFound].EnsureVisible()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_Click()
  
  If DateChooser1.Tag = "1" Then Text1Insert(ColumnView3[ColumnView3.Current.key][0])
  If DateChooser1.Tag = "2" Then Text2Insert(ColumnView3[ColumnView3.Current.key][0])
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_MouseUp()
  
  Dim dDate, dTime As Date 
  
  If ColumnView3.Current.Text Then 
    dDate = DateChooser1.Value 'as Date
    dTime = CDate(ColumnView3.Current.Text) '00:00 (*1)
    F_dateNow = Date(Year(dDate), Month(dDate), Day(dDate), Hour(dTime), Minute(dTime), Second(dTime)) 'as Date 
    DateChooser1.Value = F_dateNow
    If DateChooser1.Tag = "1" Then Text1Insert(Format(F_dateNow, "hh:nn"))
    If DateChooser1.Tag = "2" Then Text2Insert(Format(F_dateNow, "hh:nn"))
  Endif 
  
  ''______________________________________________________________________________________________''
  '(*1) Gambas3: "CDate(): Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Hier nur bei hh:nn
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_KeyPress()
  
  DateChooser1.Tag = "1"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_KeyPress()
  
  DateChooser1.Tag = "2"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeichensatz2_Click()
  
  M06InfoText.CharsetABCInfo()
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuShow()
  
  Dim sFileOld As String
  
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1 ''Termine
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Checked = CheckBox1.Value
      mnuJedesJahr.Enabled = True  
      
      mnubirthdaysoutside.Enabled = True 
      mnubirthdaysinside.Enabled = True 
      mnuAuswahlBis.Enabled = True  
      mnuAuswahlTimer.Enabled = True  
      mnueditortermine.Text = ("Termine")
      
    Case 2 ''Project-Names
      mnuProjektEin.Enabled = True 
      mnuProjektAus.Enabled = True 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt-Namen")
      
    Case 3 ''Projects
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt")
      
  End Select 
  
  mnuProjektEin.Visible = mnuProjektEin.Enabled 
  mnuProjektAus.Visible = mnuProjektAus.Enabled 
  
  sFileOld = FilePathFormOldYears()
  sFileOld = File.Name(sFileOld)
  mnuTermineAuslagern.Text = ("Auslagern...") & Space(1) & (" >> ") & Space(1) & sFileOld & Space(1) & ("=schneller")
  mnuTermineEinlagern.Text = ("Einlagern...") & Space(1) & (" << ") & Space(1) & sFileOld 
  mnuexportselection.Text = Replace(mnuexportselection.Text, ("(Suche)"), ("(Suche ") & Format(Now, "yyyy") & "-)")
  mnuMehrSchalter.Checked = PanelListMenu.Visible
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuBearbeiten_Show() 'Edit
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatei_Show() 'File
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahl_Show() 'Select
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelG()
  
  If PanelSearchList.Visible = False Then
    ButtonSucheG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Click()
  
  Dim sLine As String
  
  If ToggleButtonW1.Value = True Then sLine = sLine & ToggleButtonW1.Text & gb.Sunday '0
  If ToggleButtonW2.Value = True Then sLine = sLine & ToggleButtonW2.Text & gb.Monday '1
  If ToggleButtonW3.Value = True Then sLine = sLine & ToggleButtonW3.Text & gb.Tuesday '2
  If ToggleButtonW4.Value = True Then sLine = sLine & ToggleButtonW4.Text & gb.Wednesday '3
  If ToggleButtonW5.Value = True Then sLine = sLine & ToggleButtonW5.Text & gb.Thursday '4
  If ToggleButtonW6.Value = True Then sLine = sLine & ToggleButtonW6.Text & gb.Friday '5
  If ToggleButtonW7.Value = True Then sLine = sLine & ToggleButtonW7.Text & gb.Saturday '6
  TextBoxWT.Text = sLine
  Text0Insert(sLine)
  LabelTimerWT.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Enter()
  
  Last.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Leave()
  
  Last.Border = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelTimerG()
  
  If ScrollViewWeekDay.Visible = False Then
    SelectHide0Date1Clock2Timer3(3)
  Else
    SelectHide0Date1Clock2Timer3(0)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ApplyWT_Click()
  
  Text0Insert(TextBoxWT.Text)
  LabelTimerWT.Tag = TextBoxWT.Text
  SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowT5plusG()
  
  Form3Text.Tag = Text5.Text
  FMain.F_bZeilenumbruchON = False
  Form3Text.Tooltip = "" 'Path
  Form3Text.Tag = Text5.Text
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilen1_Click()
  
  Form3Text.Tag = F_sUnknownLinesText
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub AuswahlDatumUhrTimerGroup_Click() 'Gruppe
  
  SelectHide0Date1Clock2Timer3(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtonsG()
  
  If F_bMoreButtons = True Then
    F_bMoreButtons = False
    SelectHide0Date1Clock2Timer3(0)
  Else
    F_bMoreButtons = True
  Endif
  MoreButtons(F_bMoreButtons)
  
Catch 
  FMain.ErrorText
  
End

Public Sub NewLineG()
  
  ColumnView1.UnselectAll()
  ListMenuGroupFunctions("addappend")
  Text5.Pos = String.Len(Text5.Text)
  ' Text5.SetFocus
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxWT_Change()
  
  If TextBoxWT.Text = "" Then
    ApplyWT.Background = Color.ButtonBackground
  Else
    ApplyWT.Background = Color.SelectedBackground
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewOrig()
  
  Dim it, iLine As Integer
  Dim sOrigText As String 
  Dim PicEmpty As Picture
  Dim sKey, sLine As String 
  Dim hTab As String 
  
  ''ColumnView1
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView1[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView1[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView1[sKey].Picture = PicEmpty
          ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView2[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView2[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView2[sKey].Picture = PicEmpty
          ColumnView2[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseDown()
  
  F_bMovingON = True
  F_iY1 = Mouse.Y
  MoveLine.Raise
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseMove()
  
  If F_bMovingON = True Then
    MoveLine.Top = MoveLine.Top + Mouse.Y - F_iY1 
    If MoveLine.Top < F_iMoveLineMinH Then MoveLine.Top = F_iMoveLineMinH 'Top▲ (Obergrenze)
    If MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH 'Bottom▼ (Untergrenze)
    Form_Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseUp()
  
  Dim sKey As String
  
  F_bMovingON = False
  sKey = ColumnViewCurrentKey()
  If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuMehrSchalter_Click()
  
  MoreButtonsG()
  
End

Public Sub mnuInfo_Click()
  
  Dim sMessage As String 
  
  sMessage = "(c) www.design-cad.de" & "<br><br>"
  'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub Text5_KeyPress()
  
  PanelText5.Background = Color.White
  ButtonInput.Background = Color.Default
  If F_iMusterTermine1Names2Projects3 > 1 Then 
    If InStr(Text5.Text, String.Chr(47)) > 0 Then 'stop sign "/"=chr(47) /Directory/File.xy
      ButtonTest.Picture = PicTemplateBookQuestion.Picture
      PanelText5.Background = F_iColorRedAlpha150
    Endif 
  Endif 
  F_bKeyboardInput = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSortAZ_Click()
  
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    ColumnView1.Sorted = True 
    ColumnView1.Columns.Sort = 0 'Datum sortieren
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFensterplus_Click()
  
  WindowT5plusG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuJedesJahr_Click()
  
  CheckBox1.Value = Not CheckBox1.Value
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSchliessen_Click()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExportSelectionG()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuexportselection_Click()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveSelectionG()
  
  Dim sFileBefore, sFileBehind, sDir, sPath, sDirFile, sExistFiles As String 
  Dim sK2, sLine, sText, sExistLines, sSpace, sMessage As String
  Dim iColumn, iLine As Integer
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sSpace = Space(1)
  sPath = FilePathForm()
  sDir = File.Dir(sPath)
  For Each sK2 In ColumnView2.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView2[sK2].Selected = True Then
      If ColumnView2[sK2][0] <> "" Then
        sLine = ""
        For iColumn = 0 To 5
          If iColumn < 5 Then
            sLine = sLine & ColumnView2[sK2][iColumn] & hTab
          Else
            sLine = sLine & ColumnView2[sK2][iColumn] & hReturn
            Break
          Endif
        Next
        If String.InStr(sExistLines, sLine) > 0 Then 'no double Lines (ohne doppelte Zeilen)
          '...Leerlauf
        Else
          sExistLines = sExistLines & gb.Tab & sLine & gb.Tab
          sText = sText & sLine
        Endif
      Endif
    Endif
  Next
  
  If sText = "" Then
    Message.Info(("Auswahl") & " = 0", ("Abbrechen"))
    Goto Ende
  Endif
  ColumnView2.Columns[5].Text = ("markierte Zeilen") & sSpace & ColumnView2.Selection.Count & sSpace & ("von") & sSpace & ColumnView2.Count
  sDirFile = sDir &/ "export_" & Format(Now, "yyyy") & Application.Name & ".txt" ' kleine y
  
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  Dialog.Filter = ["*.txt", ("Nur-Text")]
  Dialog.Path = sDirFile
  Dialog.AutoExt = True
  Dialog.Title = ("Datei speichern...")
  'If Dialog.SaveFile() Then Return 'Kurzform
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
    'Goto Ende
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  sDirFile = Dialog.Path
  
  If Exist(sDirFile) = True Then
    hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
    sFileBefore = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
  Endif
  sExistFiles = M01Functions.FileExistQuestionText(sDirFile)
  If sExistFiles <> "" Then sExistFiles = sExistFiles & hReturn & hReturn
  sMessage = ("(Tipp: Mit einem Textprogramm den Zeichensatz verändern)") & "<br>" & "<br>"
  sMessage &= sExistFiles & sDirFile & "<br>"
  
  Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
    Case 1 'Speichern
      'File.Save(sDirFile, sText)
      M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
      If Exist(sDirFile) = True Then
        hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
        sFileBehind = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
      Endif
      If sFileBefore = sFileBehind Then
        Message.Warning(sFileBehind & "<br>" & "<br>" & ("Nicht erfolgreich gespeichert?"))
      Endif
    Case 2 'Abbrechen
      'Leerlauf
  End Select
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  
  ''Show File-Data:
  Form3Text.Tag = sDirFile
  Form3Text.Tooltip = sDirFile
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCompare(Optional bExact As Boolean = False)
  
  Dim iLine, iFoundLines, iCheck As Integer
  Dim sExists, T0, T1, T5 As String
  Dim sKey, sLeft, sMid, sRight, sKeyFirstQuestion, sSeparator As String
  Dim PicHome, PicQuestion As Picture
  
  PicHome = ColumnViewImages("PicHome").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture
  ' PicQuestion = Picture["icon:/22/question"] 'in icon ohne Endung .png
  
  sSeparator = Settings[FMain.Name &/ "hTab", gb.Tab]
  F_bESCpressedON = False
  
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      iCheck = 0 'Reset
      
      T0 = ColumnView1[sKey][0] 'yyyy-mm-dd
      T1 = ColumnView1[sKey][1] '00:00
      T5 = String.LCase(ColumnView1[sKey][5]) 'Notiz
      ' T6 = ColumnView1[sKey][6] '00:00
      ' T8 = ColumnView1[sKey][8] 'Sek.
      ' T9 = ColumnView1[sKey][9] '00:00:00 Dauer
      
      If bExact = True Then
        If String.InStr(sExists, T0 & T1 & T5) > 0 Then iCheck = 10 'faster
        ' If sExists Like "*" & T5 & "*" Then iCheck = 10
      Else 
        sLeft = String.Left(T5, 5)                                                                'linker Teil Notizen
        If String.Len(T5) > 20 Then
          sMid = String.Mid(T5, String.Len(T5) / 2, 10)                                           'mittiger Teil Notizen
        Else
          sMid = ""
        Endif 
        sRight = String.Right(T5, 5)                                                              'rechter Teil Notizen
        If String.InStr(sExists, sLeft) > 0 Then iCheck = iCheck + 1
        If sMid <> "" Then
          If String.InStr(sExists, sMid) > 0 Then iCheck = iCheck + 1
        Endif
        If String.InStr(sExists, sRight) > 0 Then iCheck = iCheck + 1
      Endif 'bExact
      
      If iCheck > 1 Then
        ColumnView1[sKey].Picture = PicQuestion '"?"
        ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
        iFoundLines = iFoundLines + 1
        ColumnView1[sKey][F_iColumnSort] = Replace(String.Left(T5, 10), "*", "Z") & Str(iFoundLines)
      Else
        ColumnView1[sKey].Picture = PicHome 'Bild
        ColumnView1[sKey][F_iColumnSelect] = "PicHome"
        ColumnView1[sKey][F_iColumnSort] = iLine 
        sKeyFirstQuestion = sKey
      Endif
      sExists &= T0 & T1 & T5 & gb.NewLine
      ' sExists = sExists & sLine & T0 & T1 & T5 & T6 & T8 & T9 & gb.NewLine  ' 0-1-2-3...
    Next
    If bExact = True Then
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen genauer") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine
    Else 
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine 
    Endif 
    ColumnViewInfo(ColumnView1.Columns[5].Title)
    ColumnViewSort(F_iColumnSort) 
    If ColumnView1.Exist(sKeyFirstQuestion) = True Then 
      ColumnView1.UnSelectAll()
      ColumnView1[sKeyFirstQuestion].Selected = True 
      ColumnView1[sKeyFirstQuestion].EnsureVisible
    Else 
      ColumnView1[ColumnView1.Count].Selected = True 
      ColumnView1[ColumnView1.Count].EnsureVisible  
    Endif 
  Endif 
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewDouble() '= ● ●
  
  Dim sKey, sLine As String
  Dim it, iLine, iFound, iFoundLines As Integer
  Dim PicDouble, PicHome As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView1.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView1.Mode = Select.Multiple 
      ColumnView1.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView1[sKey].Picture = PicDouble
          ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView1[sKey][F_iColumnSort] = ColumnView1.Count + iLine
          ColumnView1[sKey].Selected = True
          ColumnView1[sKey].EnsureVisible
        Else
          ColumnView1[sKey].Picture = PicHome
          ColumnView1[sKey][F_iColumnSelect] = "PicHome"
          ColumnView1[sKey][F_iColumnSort] = iLine
          ColumnView1[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView2.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView2.Mode = Select.Multiple 
      ColumnView2.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView2[sKey].Picture = PicDouble
          ColumnView2[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView2[sKey][F_iColumnSort] = ColumnView2.Count + iLine
          ColumnView2[sKey].Selected = True
          ColumnView2[sKey].EnsureVisible
        Else
          ColumnView2[sKey].Picture = PicHome
          ColumnView2[sKey][F_iColumnSelect] = "PicHome"
          ColumnView2[sKey][F_iColumnSort] = iLine
          ColumnView2[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines()
  
  Dim iLine, iDay, iColumn, iCorrectedLines, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim sK1, sTimerDays, sLine As String
  Dim hDate0, hDate1, hDate2 As Date
  Dim iSecond, iHH, iMM As Integer
  Dim sTime1, sTime2 As String
  Dim sValue As String
  Dim ssWeekdays, ssTime As String[]  
  Dim PicRefresh, PicOK, PicQuestion As Picture
  
  PicRefresh = ColumnViewImages("PicRefresh").Picture 
  PicOK = ColumnViewImages("PicOK").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture 
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  
  If ColumnView1.Count > 0 Then
    If ColumnView1.Selection.Max > -1 Then 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = ""
        For iColumn = 0 To F_iColumnsReadMax
          sLine = sLine & ColumnView1[sK1][iColumn]
        Next
        
        T0 = Trim(ColumnView1[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView1[sK1][1]) '00:00
        T2 = Trim(ColumnView1[sK1][2]) 'Mo
        T3 = Trim(ColumnView1[sK1][3]) 'Q
        T4 = Trim(ColumnView1[sK1][4]) 'KW
        T5 = Trim(ColumnView1[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView1[sK1][6]) '00:00
          T7 = Trim(ColumnView1[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView1[sK1][8]) 'Sek.
          T9 = Trim(ColumnView1[sK1][9]) '00:00:00
        Endif 
        'T10 = Trim(ColumnView1[sK1][10]) 'ColumnsUndo
        'T11 = Trim(ColumnView1[sK1][11]) 'Icon, Edit
        'T12 = Trim(ColumnView1[sK1][12]) 'Sortieren
        'T13 = Trim(ColumnView1[sK1][13]) 'Nr
        
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T0 <> "" Then
          If T1 Like "??:??" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue) 
          Else If T1 Like "*??:??*" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Else
            sValue = ""
            For iColumn = 0 To ColumnView1.Columns.Max
              If ColumnView1[sK1][iColumn] Like "*??:??*" Then
                sValue = Str(ColumnView1[sK1][iColumn])
                Break
              Endif
            Next
            If sValue = "" Then sValue = "00:00"
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            If T6 Like "??:??" Then
              '...Leerlauf
            Else If T6 Like "*??:??*" Then
              sValue = Str(T6)
              Try T6 = M01Functions.TimeCheckHHMM(sValue)
            Endif 
          Endif 
        Endif
        
        sValue = T0
        hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If hDate1 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDate1, "yyyy-mm-dd")
          T2 = Format(hDate1, "ddd")
          T3 = M01Functions.DateQuarterG(hDate1) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
        Else 'kein Datum oder Timer?  TTTTTTTTTTTTTTTTTTTTTTTT
          If M01Functions.isZahl(T0) = True Then 'unbekannte Zahl?
            sLine = ""
          Else
            For iDay = 0 To 6 ' 7-Tage
              If String.LCase(T0) Like "*" & String.LCase(ssWeekdays[iDay]) & "*" Then sTimerDays = sTimerDays & ssWeekdays[iDay] 'Teile von SoMoDiMiDoFrSa
            Next
            If sTimerDays <> "" Then
              T0 = sTimerDays
              If T1 = "" Then T1 = "00:00"
              T3 = "-Q"
              T4 = "-KW"
            Else
              sLine = ""
            Endif
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            sTime1 = T1
            sTime2 = T6
            If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
              hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
              ssTime = Split(sTime1 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              ssTime = Split(sTime2 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
              T8 = Str(iSecond)
              If iSecond < 0 Then iSecond = 0
              T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
              ' Endif 
            Endif 
            T7 = T2 'Mo > Mo
          Endif 
        Endif
        
        'Compare (mit korrigierter Zeile vergleichen)
        If sLine = "" Then
          ColumnView1[sK1].Picture = PicQuestion '?  Fragezeichen
          ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
          iUnknown = iUnknown + 1
        Else If Not Trim(sLine) = Trim(T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9) Then
          ColumnView1[sK1].Picture = PicRefresh 'verändert
          ColumnView1[sK1][F_iColumnSelect] = "PicRefresh"
          iCorrectedLines = iCorrectedLines + 1
        Else
          ColumnView1[sK1].Picture = PicOK 'OK
          ColumnView1[sK1][F_iColumnSelect] = "PicOK"
        Endif
        
        'Back (Korrigierte Zeilen zurückschreiben)
        ColumnView1[sK1][0] = T0
        ColumnView1[sK1][1] = T1
        ColumnView1[sK1][2] = T2
        ColumnView1[sK1][3] = T3
        ColumnView1[sK1][4] = T4
        ColumnView1[sK1][5] = T5
        If F_iMusterTermine1Names2Projects3 = 3 Then
          ColumnView1[sK1][6] = T6
          ColumnView1[sK1][7] = T7
          ColumnView1[sK1][8] = T8
          ColumnView1[sK1][9] = T9
        Endif 
      Next
      sValue = ""
      If iUnknown > 0 Then sValue = Space(1) & ("Unbekannte=") & iUnknown & "?"
      ColumnView1.Columns[5].Title = ("Formate korrigiert=") & iCorrectedLines & sValue
      If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
      If iCorrectedLines > 0 Then 
        ButtonSave.Background = Color.Red
      Endif
      Form5Projekte.Title = F_sTitleBasicText & Space(5) & Str((ColumnView1.Count) & sValue)
      LabelInfo.Text = ColumnView1.Columns[5].Title
      LabelInfo.Visible = True 
    Endif 'ColumnView1.Selection.Max 
  Endif 'ColumnView1.Count
  
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form5Projekte.Window.Maximized = Not Form5Projekte.Window.Maximized 
  If Form5Projekte.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form5Projekte.Window.FullScreen = True Or Form5Projekte.Window.Maximized = True Then 
      F_bMovingON = False
      Form5Projekte.Window.FullScreen = False
      Form5Projekte.Window.Maximized = False
      If Form5Projekte.Left + Form5Projekte.W > Screen.AvailableWidth Then Form5Projekte.Move(Form5Projekte.Left, Form5Projekte.Top, Screen.AvailableWidth - Form5Projekte.Left, Screen.AvailableHeight - Form5Projekte.Top)
    Else
      F_bMovingON = True
      Form5Projekte.Window.FullScreen = False
      Form5Projekte.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form5Projekte.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form5Projekte.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form5Projekte.ClientW - WindowStretch.W, Form5Projekte.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form5Projekte.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form5Projekte.W = Mouse.ScreenX - F_iX1
    Form5Projekte.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form5Projekte.ClientW - WindowStretch.W, Form5Projekte.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form5Projekte.ClientW - WindowStretch.W, Form5Projekte.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form5Projekte.Window.Maximized = Not Form5Projekte.Window.Maximized 
    If Form5Projekte.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form5Projekte.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
  ' MoveLine.Cursor = New Cursor(Picture["images/size_32.png"].Image.Stretch(MoveLine.H, MoveLine.H).RotateLeft().Picture, 0, 0)
  ' MoveLine.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then mnuDatei.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuErgaenzungFeiertage2_Click()
  
  Dim sValue As String 
  
  sValue = Settings[FMain.Name &/ "OsterSonntag", ""] 'EasterDay
  If sValue = "" Then M03Feiertage.HolidaysCalculate()
  Form8ZusFeiertage.Window.Show
  ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExternOpenGroup_Click()
  
  ButtonExternStartG(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonExternStartG(Optional sTag As String = "")
  
  Dim sPath, sCopy, sProgram As String
  
  sPath = FilePathForm()
  If Exist(sPath) = True Then
    Select Case String.LCase(sTag)
      Case "editor"
        sProgram = "gedit"
      Case "office"
        sProgram = "libreoffice"
      Case "browser"
        sProgram = "firefox"
      Case "csv"
        sProgram = "libreoffice"
        sCopy = File.SetExt(sPath, "csv")
        sCopy = M01Functions.ProgramDirCache(sCopy) '/Temp/File.txt
        If Exist(sCopy) = True Then Try Kill sCopy
        If Exist(sCopy) = False And IsDir(File.Dir(sCopy)) = True Then Try Copy sPath To sCopy
        If Exist(sCopy) = True Then sPath = sCopy
    End Select
    If System.Exist(sProgram) = True Then 
      M01Functions.ExternStart(sProgram, sPath) 
    Else 
      Desktop.Open(sPath)
    Endif
    ColumnViewInfo(("Siehe extern") & ": " & ": " & sPath)
  Else 
    ColumnViewInfo(("Datei nicht gefunden") & ": " & sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuHilfe_Show()
  
  Dim longFreeMedia As Long
  Dim sText As String 
  
  longFreeMedia = M01Functions.DirectoryFreeBytesLong("/") 'Alles auf Gerät "/"
  sText = ("Freier Speicher") & ": " & Format(longFreeMedia / 1024 / 1024 / 1024, "0,0") & " GB" & Space(5) & "(" & Format(longFreeMedia, "0,0") & Space(1) & "Bytes)"
  mnuFestplattenbelegung.Text = ("Festplatte") & ", " & sText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSonderzeichen_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gucharmap")
  If bExist = True Then 
    M01Functions.ExternStart("gucharmap") 'Sonderzeichen, Zeichentabelle
  Else 
    bExist = System.Exist("gnome-characters")
    ' Shell "gnome-control-center"
    M01Functions.ExternStart("gnome-characters", "")
    ' M01Functions.ExternStartAlternative("gnome", "info")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuSonderzeichen.Text, "Fehlt") = 0 Then mnuSonderzeichen.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSonderzeichen.Text)
  Endif
  '/usr/share/applications
  'gcalctool 'Taschenrechner
  'gnome-session-properties 'Startprogramme
  'gnome-control-center --overview 'Systemeinstellungen
  'gnome-control-center indicator-datetime  'Zeit und Datum
  'gnome-control-center deja-dup 'Datensicherung
  'gnome-search-tool ' Suche im PC
  'baobab 'Festplattenbelegung
  
Catch 
  FMain.ErrorText
  ''______________________________________________________________''
  'https://manpages.ubuntu.com/manpages/trusty/man1/gucharmap.1.html
  'https://manpages.ubuntu.com/manpages/trusty/man1/gnome-session-properties.1.html
  
End

Public Sub mnuSuchePC_Click()
  
  Dim sPath As String
  
  sPath = FilePathForm()
  ' M01Functions.FileManagerOpen(sPath) 'Suche im PC
  M01Functions.ExternStart("nautilus", sPath)
  ColumnViewInfo(("Siehe extern:" & Space(1) & mnuSuchePC.Text))
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFestplattenbelegung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("baobab")
  If bExist = True Then
    Shell "baobab" 'startet Programm
    ' M01Functions.ExternStart("baobab") 'Festplattenbelegung
  Else
    bExist = System.Exist("nautilus") 'Filemanager (Dateiverwaltung)
    M01Functions.ExternStart("nautilus", "")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuFestplattenbelegung.Text, "Fehlt") = 0 Then mnuFestplattenbelegung.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuFestplattenbelegung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup") 'Backup-Program
  If bExist = True Then
    Shell "deja-dup" 'start Program
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
    mnuDatensicherung2.Text = mnuDatensicherung.Text
    ColumnViewInfo(mnuDatensicherung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSystemDatumZeit_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gnome-control-center") 'System
  If bExist = True Then
    Shell "gnome-control-center datetime" 'startet Programm
    ' M01Functions.ExternStart("gnome-control-center", "info-overview") 'Zeit und Datum, Seite Betriebssysem-Info
  Endif
  If bExist = False Then bExist = System.Exist("unity-control-center")
  If bExist = True Then
    Shell "unity-control-center datetime" ' Datum und Zeit, Einstellungen im Betriebssystem
    'M01Functions.ExternStart("unity-control-center", "datetime") 'Zeit und Datum
  Endif
  If bExist = False Then
    If String.InStr(mnuSystemDatumZeit.Text, "Fehlt") = 0 Then mnuSystemDatumZeit.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSystemDatumZeit.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTaschenrechner_Click()
  
  Dim bExist As Boolean
  
  'M01Functions.ExternStart("gcalctool") 'gcalctool 'Taschenrechner
  bExist = M01Functions.ExternCalculator()
  If bExist = False Then 
    If String.InStr(mnuTaschenrechner.Text, "Fehlt") = 0 Then mnuTaschenrechner.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuTaschenrechner.Text)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuExport_Click() 'ö=oe, ...
  
  Form13Export.Window.Show
  ' Form13Export.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlExportieren_Click()
  
  SaveSelectionG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelDatumInfo()
  
  Dim sMessage, hTab, hReturn, hSpace As String
  
  hTab = String(5, "&nbsp;") ' Count empty Space (Anzahl Leerzeichen)
  hReturn = "<br>"
  hSpace = "&nbsp;" 'Empty Space (Leerzeichen 1x)
  'Terminwecker/Project-Line-Format:
  sMessage = M01Functions.TerminweckerLine(Format(Now, "yyyy-mm-dd"), Format(Now, "hh:nn"), ("Notiz"))
  sMessage = Replace(sMessage, gb.Tab, hTab)
  sMessage = "<b><font color=gray>" & sMessage & "</font></b>" & hReturn & hReturn
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'As String
  sMessage &= ("Wochentag, Quartal und Kalenderwoche werden automatisch berechnet und ergänzt.") & hReturn & hReturn
  sMessage &= ("Tipp") & ": " & hReturn 
  sMessage &= ("*Geburtstage, #Feiertage oder +Timerplus können durch ein einheitliches Zeichen") & hReturn
  sMessage &= ("unter 'Suche' zusammen angezeigt, bearbeitet, exportiert oder gelöscht werden.") & hReturn
  sMessage &= ("Begriffe einheitlich anwenden, mindestens 1x im Text, für eine spätere 'Suche'.") & hReturn 
  sMessage &= ("Beispiel") & hSpace & "<font color=darkgreen>" & ("Suche: *Jahrestreffen xy") & "</font>" & hReturn 
  
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer2KeyPress_Timer()
  
  Dim sPath As String 
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  
  sPath = TextBoxPath.Text 
  sPath = Replace(sPath, gb.NewLine, "")
  ReadG(sPath, True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer3KeyPress_Timer()
  
  Timer3KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  ButtonSearchG() 'not in _KeyPress > Error
  
Catch 
  FMain.ErrorText
  
End

Public Function Text5TempPathReturn() As String
  Dim sFile As String 
  
  F_sPathText5Temp_txt = Settings[FMain.Name &/ "F_sPathText5Temp_txt", FMain.F_sPathText5Temp_txt]
  sFile = File.BaseName(F_sPathText5Temp_txt)
        
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1
      F_sText5StartExampleName = ("Notiz")
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-termin.txt"
    Case 2
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-projectname.txt"
    Case 3
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-project.txt"
  End Select 

  Return F_sPathText5Temp_txt
  
  Catch 
  FMain.ErrorText
  
End

Public Function Text5TempFileLoad() As String 
  
  Dim sText As String 
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then
    sText = File.Load(F_sPathText5Temp_txt)
    PasteLineArrow(sText) 'Chr(182) = "¶"
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5TempFileRefresh()
  Dim T5, sText, sPath As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  
  T5 = Text5.Text
  T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
  ''Chr$(13) & Chr$(10) = "\r\n" = gb.CrLF = gb.Cr & gb.LF, gb.LF = gb.NewLine = "\n" = Chr$(10)
  T5 = Replace(T5, gb.NewLine, String.Chr(182))
  T5 = Replace(T5, hTab, Space(3))

  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      If String.Len(Text5.Text) > 0 Then 
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 2
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 3
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.ProjectLine(Text0.Text, Text1.Text, T5 & Text2.Text & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
  End Select

  Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer() '>Termine
  '.Delay=1000 =1 second
  
  If F_iMusterTermine1Names2Projects3 = 1 And F_bKeyboardInput = True Then 
    F_iText5Seconds = F_iText5Seconds + 1 
    If F_iText5Seconds > 10 Then 
      Text5TempFileRefresh()
      F_iText5Seconds = 0
      F_bKeyboardInput = False
    Endif
  Endif 
  
  If F_statFilePathForm Then 
    If Exist(F_statFilePathForm.Path) = True Then  
      If F_statFilePathForm.Time <> Stat(F_statFilePathForm.Path).Time Then ColumnViewInfo(("Info") & ": " & ("Datei extern geändert") & Space(1) & Format(F_statFilePathForm.LastModified, "hh:nn:ss"))
      F_statFilePathForm = Stat(F_statFilePathForm.Path) 'Refresh
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer4Now_Timer()
  
  LabelDateNow.Text = Format(Now, "yyyy-mm-dd") & Space(3) & Format(Now, "ddd")
  If Second(Time) Mod 2 Then 
    LabelTimeNow.Text = Format(Now, "hh:nn")
  Else 
    LabelTimeNow.Text = Format(Now, "hh nn")
  Endif 
  
Catch 
  FMain.ErrorText

End

Public Sub ButtonCancelB_MouseDown()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTerminweckerdateiLesen_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTermineDateiOeffnenSpeichern_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PasteLineArrow(Optional sLinePaste As String = "")
  
  Dim T0, T1, T5, T6, T8, T9 As String
  Dim sValue As String 
  Dim ssLines, ssLine As String[]
  Dim sLine, sPart As String
  Dim it, iLine, iCounter As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If String.InStr(sLinePaste, gb.Tab) > 0 Then 
    sValue = sLinePaste
  Else If Clipboard.Type = Clipboard.Text Then 'nur wenn Text in Zwischenablage ist
    sValue = Clipboard.Paste("text/plain") '()Klammer nicht vergessen!
  Endif 
  
  If sValue Then 
    If String.InStr(sValue, hTab) > 0 And sValue Like "????-??-??*??:??*" Then
      ssLines = Split(sValue & String(2, hReturn), hReturn)
      For Each sLine In ssLines
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, hTab) > 0 And sLine Like "????-??-??*??:??*" Then
          iCounter = iCounter + 1
          ssLine = Split(sLine & String(6, hTab), hTab)
          it = 0
          For Each sPart In ssLine
            If it = 0 Then T0 = sPart
            If it = 1 Then T1 = sPart
            If it = 5 Then T5 = sPart
            If it = 6 Then T6 = sPart 
            If it = 8 Then T8 = sPart
            If it = 9 Then T9 = sPart
            it = it + 1
            If it > F_iColumnsReadMax Then Break
          Next
          If iCounter > 0 Then Break 'only 1 sPart
        Endif
      Next
      Text0Insert(T0) '0000-00-00 
      Text1Insert(T1) '00:00 'A
      Text5Insert(T5) 'Project/Notice
      If F_iMusterTermine1Names2Projects3 = 3 Then 
        Text2Insert(T6) '00:00 'B
        ButtonSum.Tooltip = T8 'Seconds 12345
        ButtonDauer.Text = T9 '00:00:00 Duration
      Endif 
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineEinlagernG()
  
  ''Plus
  ReadG(FilePathFormOldYears(), True) 'True: with Dialog
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineAuslagernG()
  
  Dim iDiffDays, iOldLines, it, iLine As Integer
  Dim sKey, sKeyLast, sValue, sLine, sWithoutDoubles, sTextInside, sTextOutside, sTitleInfo, sMessage As String
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim dateA, dateB, dateDatum1, dateDatum2 As Date
  Dim sBisDatum1, sBisDatum2 As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = FilePathFormOldYears()
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  dateDatum1 = Date(Year(Date) - 6, 12, 31)
  dateDatum2 = Date(Year(Date) - 1, 12, 31)
  sBisDatum1 = ("vor") & " ◀ " & Format(dateDatum1, "yyyy") & Space(1) & ("auslagern") 'vor<<
  sBisDatum2 = ("vor") & " ◁ " & Format(dateDatum2, "yyyy") & Space(1) & ("auslagern") 
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("Vergangene Zeilen auslagern in die Datei") & ":" & "</font></h3>"
  sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
  sMessage &= ("Ausnahme:  *Geburtstage oder andere Termine (*Jedes Jahr) werden nicht verschoben.") & "<br>"
  sMessage &= ("Ausnahme:  Timer SoMoDiMiDoFrSa (Jede Woche) werden nicht verschoben.") & "<br>" 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
  Select Case Message.Question(sMessage, sBisDatum1, sBisDatum2, ("Abbrechen"))
    Case 1 'Move outside (Auslagern)
      dateA = dateDatum1
    Case 2 'Move outside (Auslagern)
      dateA = dateDatum2
    Case 3 'Cancel (Abbrechen)
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form5Projekte.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form5Projekte.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''No Birthdays "*", no Timer SoSa, Muster: 0000-00-00 00:00 WD Q CW Notice
    If String.Left(ColumnView1[sKey][5], 1) = "*" Or IsInteger(String.Left(ColumnView1[sKey][0], 1)) = False Then 'no *EveryYear (ohne *Geburtstage), no Timer SaSoMoDiMiDoFrSa
      ''...
    Else If ColumnView1[sKey][0] Like "*????-??-??" Then
      If ColumnView1[sKey][5] <> "" Then
        sValue = ColumnView1[sKey][0]
        dateB = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If dateB Then
          iDiffDays = DateDiff(dateA, dateB, gb.day)
          If iDiffDays < 0 Then
            sLine = ""
            For it = 0 To ColumnView1.Columns.Max
              If it < F_iColumnsReadMax + 1 Then 
                sLine = sLine & ColumnView1[sKey][it] & hTab
                ColumnView1[sKey][it] = ""
              Else 
                sLine = sLine & ColumnView1[sKey][it] & hReturn
                ColumnView1[sKey][it] = ""
                ColumnView1[sKey].Picture = PicCut
                ColumnView1[sKey][F_iColumnSelect] = "PicCut"
                ColumnView1[sKey].Selected = True
                sKeyLast = sKey
                Break
              Endif
            Next
            sTextInside = sTextInside & sLine
            iOldLines = iOldLines + 1
          Endif 'iDiffDays
        Endif 'dateB
      Endif 'ColumnView1[sKey][0]
    Endif 'ColumnView1[sKey][0] LIKE "*????-??-??"
  Next
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then sTextOutside = File.Load(sDirFileOldYears)
    sTextOutside = sTextOutside & sTextInside
    For Each sLine In Split(sTextOutside & gb.NewLine, gb.NewLine)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(("Auslagern")) = True Then Break
      Endif 
      
      If String.InStr(sWithoutDoubles, sLine) = 0 Then sWithoutDoubles &= sLine & hReturn
    Next 
    'File.save(sDirFileOldYears, sTextOutside)
    sPath = M01Functions.FileTextPlus(sDirFileOldYears, sWithoutDoubles, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      Form5Projekte.Window.Title = F_sTitleBasicText & " - " & ("auslagern...fertig")
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iOldLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
      
      sMessage = Str(iOldLines) & Space(1) & ("Zeilen verschoben in Datei") & "<br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen"))
        Case 1 
          SaveG() 'with backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
    Message.Info(sTitleInfo, ("Abbrechen"))
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form5Projekte.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub GeburtstageAuslagernG() '*EveryYear Outside (*Jedes Jahr, auslagern)
  
  Dim iOldLines, iDoubleLines, iUnknownLines, iMoveLines, it, iLine As Integer
  Dim sKey, sKeyLast, sLine, sTextLine, sPart, sTextInside, sTextOutside, sExist, sTitleInfo, sMessage As String 
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear] '*EveryYear (*jedes Jahr, Geburtstage)
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("*Zeilen auslagern in die Datei") & ":" & "</font></h3>" '*Every Year (*Jedes Jahr)
  sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
  sMessage &= ("Nur Zeilen (*Jedes Jahr) werden verschoben.") & "<br>"
  sMessage &= ("Beispiel: *Geburtstage")
  
  Select Case Message.Question(sMessage, "*" & ("Zeilen") & Space(1) & ("auslagern"), ("Abbrechen"))
    Case 1 'Move outside —▶ birthsdays list
      '...
    Case 2 'Cancel
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form5Projekte.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form5Projekte.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''Birthdays "*" 
    If String.Left(ColumnView1[sKey][5], 1) = "*" Then 'Muster: 0000-00-00 00:00 WD Q CW *Notice
      sLine = ""
      For it = 0 To ColumnView1.Columns.Max
        If it < F_iColumnsReadMax + 1 Then
          sLine = sLine & ColumnView1[sKey][it] & hTab
          ColumnView1[sKey][it] = ""
        Else 
          Break
        Endif 
      Next
      ColumnView1[sKey].Picture = PicCut
      ColumnView1[sKey].Selected = True
      sKeyLast = sKey
      If sLine Then
        sTextInside = sTextInside & sLine & hReturn
        iOldLines = iOldLines + 1
      Endif 
    Endif  
  Next
  If F_bESCpressedON = True Then Goto Ende
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then
      sTextOutside = File.Load(sDirFileOldYears) '*EveryYear
    Endif
    sTextOutside = sTextOutside & sTextInside
    For Each sTextLine In Split(sTextOutside & hReturn, hReturn)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form5Projekte.Window.Title) = True Then Break
      Endif 
      
      If sTextLine Then 
        it = 0
        sLine = ""
        For Each sPart In Split(sTextLine & hTab, hTab) 'Muster: 0000-00-00 00:00 WD Q CW *Notice
          If it < F_iColumnsReadMax + 1 Then sLine = sLine & sPart & hTab
          If it = F_iColumnsReadMax Then Break
          it = it + 1
        Next
        If it = F_iColumnsReadMax And sLine Then 
          sLine = sLine & hReturn
          If String.InStr(sExist, sLine) > 0 Then 
            iDoubleLines = iDoubleLines + 1
          Else 
            sExist &= sLine  'no double
            iMoveLines = iMoveLines + 1
          Endif 
        Else If sLine Then 
          iUnknownLines = iUnknownLines + 1
        Endif 
      Endif 
    Next
    If F_bESCpressedON = True Then Goto Ende
    
    'File.save(sDirFileOldYears, sExist)
    If sExist Then sPath = M01Functions.FileTextPlus(sDirFileOldYears, sExist, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iMoveLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen") & sSpace & ("Doppelt") & ": " & Str(iDoubleLines)
      
      sMessage = ("Fehlerhafte Zeilen") & ": " & sHTMLaRed & Str(iUnknownLines) & sHTMLbRed & "<br>"
      sMessage &= ("Doppelte *Zeilen") & ": " & sHTMLaRed & Str(iDoubleLines) & sHTMLbRed & "<br>"
      sMessage &= ("Zeilen verschoben in Datei") & ": " & "<font color=darkgreen><b>" & Str(iMoveLines - iDoubleLines) & Space(1) & ("von") & Space(1) & Str(iMoveLines) & "</b></font><br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen")) '(0,1,2,3)
        Case 1 'Save now
          SaveG() ' with Backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3 'No, Cancel
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
    Message.Info(sTitleInfo, ("Abbrechen"))
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form5Projekte.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahlBis_Click()
  
  ButtonUntil()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonUntil()
  'Switch central (zentrale Umstellung)
  
  If PanelBis.Visible = False Then
    SelectHide0Date1Clock2Timer3(4)
  Else
    SelectHide0Date1Clock2Timer3(0)
    PanelBis.Visible = False
    ButtonBis.Background = F_iColorGreen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlOriginal_Click()
  
  ListMenuGroupFunctions("original2")
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung2_Click()
  
  mnuDatensicherung_Click
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Search()
  
  Dim iLen As Integer
  
  F_iText5SearchPosition = String.InStr(String.LCase(Text5.Text), String.LCase(TextBoxSearch5.Text), F_iText5SearchPosition) 'as Integer
  If F_iText5SearchPosition > 0 Then 
    Text5.Pos = F_iText5SearchPosition
    iLen = String.Len(TextBoxSearch5.Text) 'as Integer   UTF-8 with String.x
    Text5.Select(F_iText5SearchPosition - 1, iLen)
    Text5.EnsureVisible
    ' Text5.SetFocus
    F_iText5SearchPosition = F_iText5SearchPosition + 1
    TextBoxSearch5.Background = F_iColorGreenAlpha150
    TextBoxSearch5.SetFocus
  Else 
    TextBoxSearch5.Background = F_iColorRedAlpha150
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Resize()
  
  If MoveLine.Top <> F_iMoveLineMinH Then 
    F_iMoveLineTop = MoveLine.Top 
    MoveLine.Top = F_iMoveLineMinH
    WindowT5plus.Picture = PicTemplatePageMini.Picture
  Else 
    MoveLine.Top = F_iMoveLineTop
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCopy()
  
  If ColumnView1.Selection.Max > -1 Then
    F_ssKeysCopy = ColumnView1.Selection.Copy()    'only Keys, Example: "3", "1", "2",... without .Sort()
    ColumnViewInfo(("Einfügen der Kopie, nach markierter Zeile."))
    ColumnViewClipboardCopy()
  Else 
    ListCopy.Background = Color.Red
    ColumnViewInfo(("ausgewählte Zeilen") & ": 0")  'No Selection
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewClipboardCopy() 'intern
  
  Dim it, iColumn, iLine As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView1.Columns.Max
          sLine = ColumnView1[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Else ''ColumnView2:
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView2.Columns.Max
          sLine = ColumnView2[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewMarkGreen()
  
  Dim sK1 As String
  Dim PicEmpty As Picture
  Dim PicMarkGreen As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView1.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView1[sK1].Background <> Color.Default Then 
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView1[sK1].Background = F_iColorGreenAlpha150
        ColumnView1[sK1].Foreground = F_iColorForegroundBlue
        ColumnView1[sK1].Picture = PicMarkGreen
        ColumnView1[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
    
  Else ''ColumnView2:
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView2.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView2[sK1].Background <> Color.Default Then 
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView2[sK1].Background = F_iColorGreenAlpha150
        ColumnView2[sK1].Foreground = F_iColorForegroundBlue
        ColumnView2[sK1].Picture = PicMarkGreen
        ColumnView2[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCut()
  
  Dim iColumn, iLine As Integer
  Dim PicCut As Picture
  Dim sK1 As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sK1].Picture = PicCut
        ColumnView1[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView1[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sK1].Picture = PicCut
        ColumnView2[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView2[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView2to1()                                                               'ColumnView2 ▶ ColumnView1
  
  Dim iColumn, iLine As Integer
  Dim sK2 As String 
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    For Each sK2 In ColumnView2.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) Then 
        For iColumn = 0 To ColumnView2.Columns.Max
          ColumnView1[sK2][iColumn] = ColumnView2[sK2][iColumn] 
        Next
        ''ColumnView1 ▶ ColumnView2
        ColumnView1[sK2].Picture = ColumnView2[sK2].Picture
        ColumnView1[sK2].Selected = ColumnView2[sK2].Selected
      Endif 
    Next
  Else 
    ListCut.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUp() '▲
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicUp As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicUp
        ColumnView1[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView1.MoveTo(sK1)
        ' M = ColumnView1.MoveBelow() '▼down
        M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort]
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicUp
        ColumnView2[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView2.MoveTo(sK1)
        ' M = ColumnView2.MoveBelow() '▼down
        M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort]
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewDown() '▼
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicDown As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicDown
        ColumnView1[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView1.MoveTo(sK1)
        M = ColumnView1.MoveBelow() '▼down
        'M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort] 'Read Column
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicDown
        ColumnView2[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView2.MoveTo(sK1)
        M = ColumnView2.MoveBelow() '▼down
        'M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort] 'Read Column
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewPaste() 
  
  Dim iColumn, iLine As Integer
  Dim sK0, sK1, sKeySort, sValue, sMessage As String 
  Dim M As Integer = -1 'True -1, False 0 (meaning here True!)
  Dim PicAdd As Picture
  Dim ssKeys As New String[]
  Dim sLine, sPart As String 
  Dim bInfo As Boolean 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView1.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView1.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView1.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then 
      If ColumnView1.Exist(sK0) = False Then 
        M = ColumnView1.MoveLast()
        If M = 0 Then ColumnView1.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView1.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView1.UnselectAll()
      ColumnView1.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView1.Count + 1 
          ColumnView1.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView1.Columns.Max Then 
              ColumnView1[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView1[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView1[sK1].Selected = True
        Next
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True
    Endif
  Else ''ColumnView2:
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView2.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView2.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView2.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then   
      If ColumnView2.Exist(sK0) = False Then 
        M = ColumnView2.MoveLast()
        If M = 0 Then ColumnView2.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView2.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView2.UnselectAll()
      ColumnView2.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView2.Count + 1 
          ColumnView2.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView2[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView2.Columns.Max Then 
              ColumnView2[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView2[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView2[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView2[sK1].Selected = True
        Next
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True 
    Endif
  Endif 
  
  If bInfo = True Then 
    If sValue Then 
      sMessage = String.Left(sValue, 300) & "..." 
      sMessage &= "<h3><font color=blue>" & ("Kein") & "</font>" & Space(1) & ("+Einfügen in Liste") & "</h3>" 
      sMessage &= ("Tabulatoren fehlen (Trenner)") & "<br>"
      
      Select Case Message.Question(sMessage, "?", ("Abbrechen"))
        Case 1 
          'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
          sMessage = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
          Message.Info(sMessage)
        Case 2
          '...
      End Select 
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCheckAplus()
  
  Dim sKey As String
  
  If F_i22 < 22 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
    ColumnView1.Font.Size = 12
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
    ColumnView1.Font.Size = 16
  Endif 
  
  ''Size picture
  If ColumnView1.Keys.Max > -1 Then 
    For Each sKey In ColumnView1.Keys
      If ColumnView1[sKey].Picture Then ColumnView1[sKey].Picture = ColumnView1[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView1Resize()
  Endif 
  If ColumnView2.Keys.Max > -1 Then 
    For Each sKey In ColumnView2.Keys
      If ColumnView2[sKey].Picture Then ColumnView2[sKey].Picture = ColumnView2[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView2Resize()
  Endif 
  ColumnView2.Font.Size = ColumnView1.Font.Size
  Text5.Font.Size = ColumnView1.Font.Size
  Text0.Font.Size = ColumnView1.Font.Size
  Text1.Font.Size = ColumnView1.Font.Size
  Text2.Font.Size = ColumnView1.Font.Size
  Text0b.Font.Size = ColumnView1.Font.Size
  TextBoxSearch5.Font.Size = TextBoxSearch5.H / 2
    
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAdd()                                                           '1x new Line at the End
  
  Dim sK0, sK1, sKeySort As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Columns.Sort <> F_iColumnsCount Then ColumnSortSettingCentral()
  
  If ColumnView1.Selection.Max > -1 Then 
    sK0 = ColumnView1.Selection.Last 
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    sK1 = ColumnView1.Count + 1 '=>Add After Last Key .count-1
    If ColumnView1.Exist(sK1) = False Then 
      sKeySort = ColumnView1[sK0][F_iColumnSort] & ".1" 
      ColumnView1.UnselectAll()
      PicAdd = ColumnViewImages("PicAdd").Picture 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                    'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][1] = ""
      ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1][F_iColumnNr] = sK1 
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
    Endif 
  Else 
    ColumnViewAddMin1xCount()
    M = ColumnView1.MoveLast() 'M=0=False>Exist. M=-1=True>Missing
    If M = 0 Then sK0 = ColumnView1.Item.Key Else sK0 = ColumnView1.Count 
    If ColumnView1.Exist(sK0) = True Then 
      ColumnView1[sK0].Selected = True
      ColumnView1[sK0].EnsureVisible()  
    Endif 
    ColumnSortSettingCentral()
    
    ListAdd.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddAppend()                                                          '1x new Line at end
  
  Dim sK0, sK1 As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  PicAdd = ColumnViewImages("PicAdd").Picture 
  '.Header=True is first Line (Title)
  
  M = ColumnView1.MoveLast()
  If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
    sK0 = ColumnView1.Item.Key                                'only Keys     index 0,1,2,3... Keys "1","2","3"...
    ColumnView1[sK0].EnsureVisible()  
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    ColumnView1.UnselectAll()
    M = ColumnView1.MoveNext() 'M=0=False>Exist. M=-1=True>Missing
    If M = -1 Then sK1 = ColumnView1.Count + 1 '+Plus new Line at the End
    If ColumnView1.Exist(sK1) = False Then 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                  'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][F_iColumnNr] = sK1
      ColumnView1[sK1][F_iColumnSort] = sK1                                   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
      M = ColumnView1.MoveLast()
      ColumnViewSort(F_iColumnSort)
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Endif 
  Else 
    ColumnViewAddMin1xCount()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddMin1xCount()
  
  Dim sK1 As String 
  Dim PicAdd As Picture
  
  If ColumnView1.Keys Then '1 > only Header (Title)
    If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
    sK1 = ColumnView1.Count + 1
    PicAdd = ColumnViewImages("PicAdd").Picture 
    ColumnView1.Add(sK1, "", PicAdd)
    ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
    ColumnView1[sK1][1] = ""
    ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
    ColumnView1[sK1][F_iColumnNr] = sK1 
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnSortSettingCentral()
  
  ColumnView1.Mode = Select.Multiple
  If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
  ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  If ColumnView1.Columns.Sort <> F_iColumnSort Then ColumnView1.Columns.Sort = F_iColumnSort 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0)
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If iSortColumnNr < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True 'Important (wichtig)
      ' If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView1.Columns.Sort <> iSortColumnNr Then ColumnView1.Columns.Sort = iSortColumnNr 
      If ColumnView1.Selection.Max > -1 Then
        sKey = ColumnView1.Selection.Last  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If iSortColumnNr < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True 'Important (wichtig)
      ' If ColumnView2.Sorted = False Then ColumnView2.Sorted = True 'faster
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView2.Columns.Sort <> iSortColumnNr Then ColumnView2.Columns.Sort = iSortColumnNr 
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection[ColumnView2.Selection.Max]  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewRefresh() 
  
  Dim sK1 As String 
  Dim PicEmpty As Picture
  Dim iLine As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1[sK1][0] = "" Or ColumnView1[sK1][5] = "" Then
        ColumnView1.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
    
  Else ''ColumnView2:
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView2[sK1][0] = "" Or ColumnView2[sK1][5] = "" Then
        ColumnView2.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewBackup()
  
  Dim iColumn, iLine, iBackupsMax As Integer 
  Dim sK1, sLine As String
  Dim hColumnView As New F_multiColumnViewValues 'see Form head▲
  
  '****************
  iBackupsMax = 30
  '****************
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
    If Not F_ooCVBackups Then F_ooCVBackups = New Object[]
    hColumnView.iMode = ColumnView1.Mode 'Multi or Single
    hColumnView.iScrollY = ColumnView1.ScrollY
    hColumnView.iSortColumn = ColumnView1.Columns.Sort
    hColumnView.bSortAscending = ColumnView1.Columns.Ascending   'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    hColumnView.bSorted = ColumnView1.Sorted 'as Boolean
    hColumnView.ssKeys = Null 
    hColumnView.ssLines = New String[]
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ''Selected on?
      If ColumnView1[sK1].Selected = False Then 
        ColumnView1[sK1][F_iColumnSelect] = Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'False
      Else 
        ColumnView1[sK1][F_iColumnSelect] = "-" & Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'True
      Endif 
      
      sLine = "" 'Reset
      For iColumn = 0 To ColumnView1.Columns.Max
        sLine = sLine & ColumnView1[sK1][iColumn] & gb.NewLine 'Note: gb.Tab in Column Undo
      Next 
      hColumnView.ssLines.Add(sLine) 'Not forget: New String[]
    Next 
    If F_bESCpressedON = False Then 
      hColumnView.ssKeys = ColumnView1.Keys '-1 Null
      
      ''Backup:   
      F_ooCVBackups.Add(hColumnView) 'added at the end
      
      If F_ooCVBackups.Max > iBackupsMax Then 
        F_ooCVBackups.Delete(1, 1)    'Object Position 1, 1x
        F_ooCVBackups.Remove(1, 1)    '0,|x|,2,3...removed first List-Nr 1x, not 0. -1 all Rest until End
      Endif 
      F_iCVUndoRedoPointer = F_ooCVBackups.Max
      CVUndoRedoLabelCounter()  'Example: "0/0"
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUndoRedo()
  
  Dim it, iLine As Integer   
  Dim sK1, sPicName, sLine As String 
  Dim ssColumns As String[]
  Dim hColumnView As New F_multiColumnViewValues
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ooCVBackups Then 
      ' PicEmpty = ColumnViewImages("PicEmpty").Picture
      If F_iCVUndoRedoPointer < 0 Then F_iCVUndoRedoPointer = 0
      If F_iCVUndoRedoPointer > F_ooCVBackups.Max Then F_iCVUndoRedoPointer = F_ooCVBackups.Max
      
      hColumnView = F_ooCVBackups[F_iCVUndoRedoPointer] 'Object Position, 1x
      If TypeOf(hColumnView) = gb.Object Then '16 Struct
        ColumnView1.Mode = hColumnView.iMode  'Multi or Single
        ' ColumnView1.ScrollY = hColumnView.iScrollY '->see End
        If ColumnView1.Sorted <> hColumnView.bSorted Then ColumnView1.Sorted = hColumnView.bSorted 'faster
        If ColumnView1.Columns.Sort <> hColumnView.iSortColumn Then ColumnView1.Columns.Sort = hColumnView.iSortColumn
        ColumnView1.Columns.Ascending = hColumnView.bSortAscending 'as Boolean
        ' ColumnView1.Keys 'Read only. hColumnView.ssKeys -> ColumnView1.Keys.Insert()
        
        ''Empty?
        If Not hColumnView.ssKeys Then 
          ColumnView1.Clear()
          ColumnSortSettingCentral()
        Else 
          ColumnView1.Keys.Insert(hColumnView.ssKeys)
          If hColumnView.ssLines.Count < ColumnView1.Count Then hColumnView.ssLines.Resize(ColumnView1.Count)
          
          iLine = 0
          If hColumnView.ssKeys Then
            For Each sK1 In ColumnView1.Keys
              sLine = hColumnView.ssLines[iLine]
              iLine = iLine + 1
              If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
              ''[ESC]?
              If F_bESCpressedON = True Then 
                If MessageQuestionBreak() = True Then Break
              Endif 
              
              ssColumns = Split(sLine & String(ColumnView1.Columns.Count, gb.NewLine), gb.Newline) 'Note: gb.Tab in Column Undo
              For it = 0 To ColumnView1.Columns.Max
                ColumnView1[sK1][it] = ssColumns[it]
              Next 
            Next 
          Else 
            ColumnView1.Clear()
          Endif 
          
          ''Selection + Pictures:
          For Each sK1 In ColumnView1.Keys
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ''Selected on? 
            If String.InStr(ColumnView1[sK1][F_iColumnSelect], "-") = 0 Then   'True "-1", False "0"
              ColumnView1[sK1].Selected = False 
              ' ColumnView1[sK1].Background = Color.Default
              ColumnView1[sK1].Foreground = Color.Default
              If String.InStr(ColumnView1[sK1][F_iColumnSelect], "PicMarkGreen") > 0 Then 'Flag
                ColumnView1[sK1].Background = F_iColorGreenAlpha150
                ColumnView1[sK1].Foreground = F_iColorForegroundBlue
              Endif 
            Else 
              ColumnView1[sK1].Selected = True
              ColumnView1[sK1].Background = F_iColorGreenAlpha220
              ColumnView1[sK1].EnsureVisible()
            Endif 
            sPicName = ColumnView1[sK1][F_iColumnSelect]
            ColumnView1[sK1].Picture = ColumnViewImages(sPicName).Picture 'without "-"
          Next
          ColumnViewSort(F_iColumnSort) 
          ColumnView1.ScrollY = hColumnView.iScrollY
        Endif 
      Endif
    Endif
    
    CVUndoRedoLabelCounter() 'Example: "0/0"
    F_bSaved = False
  Else ''ColumnView2: 
    ColumnViewInfo(("Such-Liste ohne Rückgängig / Wiederherstellen")) ' Search-List without Undo/Redo
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CVUndoRedoLabelCounter()
  
  Dim sText, T1, T2, sSpace, sMin, sMax As String 
  
  sSpace = Space(1)
  sMin = ("min.")
  sMax = ("max.")
  If F_ooCVBackups Then 
    T1 = Str(F_ooCVBackups.Max)
    sText = T1
    If F_iCVUndoRedoPointer <= F_ooCVBackups.Max Then sText = Str(F_iCVUndoRedoPointer) & "/" & T1
  Else 
    T1 = "0"
    sText = T1 & "/" & T1
  Endif 
  If F_ooDateTimeNoticeBackup Then
    T2 = Str(F_ooDateTimeNoticeBackup.Max)
  Else 
    T2 = "0"
  Endif
  ListBackupCounter.Text = sText
  ListBackupCounter.Tooltip = ("<rückgängig") & sSpace & sText & sSpace & ("wiederherstellen>")
  
  MenuUndoMin1.Text = "0/" & T1 & sSpace & sMin
  MenuRedoMax1.Text = T1 & "/" & T1 & sSpace & sMax
  
  MenuUndoMin2.Text = "0/" & T2 & sSpace & sMin
  MenuRedoMax2.Text = T2 & "/" & T2 & sSpace & sMax
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewInfo(Optional CVText As String = "")
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    If CVText = "" Then  
      If ColumnView1.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView1.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView1.Selection.Count) & Space(1) & ("Edit") 
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView1.Columns.Max < 4 Then ColumnView1Resize()
    ColumnView1.Columns[5].Title = CVText
    
  Else ''ColumnView2:
    If CVText = "" Then  
      If ColumnView2.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView2.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView2.Selection.Count) & Space(1) & ("Edit")
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView2.Columns.Max < 4 Then ColumnView2Resize()
    ColumnView2.Columns[5].Title = CVText
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewFind(Optional UpDown As String = "+")
  
  Dim M, it, iLine, iPosition As Integer
  Dim sK1, sText, sFindText As String 
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Count > 0 Then 
      sFindText = TextListSearch.Text
      sFindText = String.LCase(Replace(sFindText, gb.NewLine, "", gb.String))
      PanelSearchList.Visible = True 
      PanelDatum.Visible = False 
      M = ColumnView1.MoveCurrent()
      If ColumnView1.Mode <> Select.Single Then ColumnView1.Mode = Select.Single
      TextListSearch.Foreground = Color.DarkRed
      For it = 0 To ColumnView1.Count - 1 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If UpDown = "+" Then 
          M = ColumnView1.MoveBelow() '▼
          If M = -1 Then M = ColumnView1.MoveFirst() 'M=0=False>Exist. M=-1=True>Missing
        Else 
          M = ColumnView1.MoveAbove() '▲
          If M = -1 Then M = ColumnView1.MoveLast()  
        Endif 
        If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
          sK1 = ColumnView1.Item.Key
          sText = String.LCase(ColumnView1[sK1][F_iColumnUndo]) 
          iPosition = String.InStr(sText, sFindText)  
          If iPosition > 0 Then Break
        Endif 
      Next
      If iPosition > 0 Then
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1].EnsureVisible
        TextListSearch.Foreground = Color.DarkGreen
        ListFound.Picture = PicTemplateApply.Picture
        ListFound.Visible = True 
        ListFound.Raise
        If String.Len(sK1) < 4 Then 
          LabelSearchLineNr.Text = ("Zeile") & Space(1) & sK1 'only Key (Nummer)  
        Else 
          LabelSearchLineNr.Text = sK1 'only Key (Nummer)  
        Endif 
      Else 
        Try ListFound.Picture = PicTemplateQuestionRound.Picture '[?]
        ListFound.Visible = True 
        ListFound.Raise
        LabelSearchLineNr.Text = ("Zeile") & Space(1) & "?"
      Endif 
      ButtonSearchPanel.Background = TextListSearch.Foreground
    Endif 
  Else 
    If UpDown = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnSelectAll()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Menu1Group_Click()
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ColumnViewCheckBoxAbc()
  
  Dim sKey, sK1, sSort As String
  Dim ssKeys, ssSort As New String[]
  Dim it, iLine, it2, M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    ColumnView1.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView1.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView1[sKey][0] & ColumnView1[sKey][1] '0000-00-00 & 00:00
        If ColumnView1[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView1[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView1.Sorted = True
      ' ColumnView1.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1][F_iColumnSort] = iLine
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView1.Count > 1 Then '1 > only Header (Title)
      ColumnView1.Sorted = True 
      ColumnView1.Columns.Ascending = True
      ColumnView1.Columns.Sort = F_iColumnSort
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView1.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then 
        ColumnView1[sKey].Selected = True 
        ColumnView1[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
    
  Else ''ColumnView2:
    ColumnView2.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView2.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView2[sKey][0] & ColumnView2[sKey][1] '0000-00-00 & 00:00
        If ColumnView2[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView2[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView2.Sorted = True
      ' ColumnView2.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        it2 = it2 + 1
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1][F_iColumnSort] = it2
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sKey][F_iColumnSort] = ColumnView2[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView2.Count > 1 Then '1 > only Header (Title)
      ColumnView2.Sorted = True 
      ColumnView2.Columns.Ascending = True
      ColumnView2.Columns.Sort = F_iColumnSort
      M = ColumnView2.MoveLast()
      If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView2.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView2.Exist(sKey) = True Then 
        ColumnView2[sKey].Selected = True 
        ColumnView2[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnAbcInfo()
  
  Dim sInfo As String 
  
  If F_bCheckBoxAbc = False Then 
    sInfo = ("Datei")
  Else 
    sInfo = ("Datum")
  Endif 
  ListCheckBoxAZLabel.Text = sInfo 
  ListCheckBoxAZ.Picture = ListCheckBoxAZ.Picture.Image.Mirror(False, True).Picture
  ColumnViewAscending()
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewListChangeLED() '○ ●
  
  If F_iCVUndoRedoPointerSave > 0 And F_iCVUndoRedoPointer < F_iCVUndoRedoPointerSave Then
    ListIsChanged.Picture = PicTemplateLEDyellow.Picture
  Else If F_iCVUndoRedoPointer < 2 Or F_iCVUndoRedoPointer = F_iCVUndoRedoPointerSave Then 
    ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Else 
    ListIsChanged.Picture = PicTemplateLEDred.Picture
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListButtonsRefresh()
  
  Dim iColor As Integer
  ''Reset
  LabelInfo.Visible = False
  iColor = Color.Default
  If ListDown.Background <> iColor Then ListDown.Background = iColor
  If ListUp.Background <> iColor Then ListUp.Background = iColor
  If ListCut.Background <> iColor Then ListCut.Background = iColor
  If ListCopy.Background <> iColor Then ListCopy.Background = iColor
  If ListPaste.Background <> iColor Then ListPaste.Background = iColor
  If ListSelectAll.Background <> iColor Then ListSelectAll.Background = iColor
  If ListAdd.Background <> iColor Then ListAdd.Background = iColor
  If ListMark.Background <> iColor Then ListMark.Background = iColor
  If ListRefresh.Background <> iColor Then ListRefresh.Background = iColor
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True
  If Object.Type(Last) = "Button" Then Last.Background = F_iColorGreenAlpha150
  If Object.Type(Last) = "PictureBox" Then Last.Background = F_iColorGreenAlpha150 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Blue 
  If Object.Type(Last) = "Label" Then Last.Background = F_iColorGreenAlpha150
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = F_iColorGreenAlpha150 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = F_iColorGreenAlpha150
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = F_iColorGreenAlpha150 
    ListCheckBoxAZLabel.Background = F_iColorGreenAlpha150 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False
  If Object.Type(Last) = "Button" Then Last.Background = Color.Default
  If Object.Type(Last) = "PictureBox" Then Last.Background = Color.Default 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Default 
  If Object.Type(Last) = "Label" Then Last.Background = Color.Default
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = Color.Default 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = Color.Default
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = Color.Default 
    ListCheckBoxAZLabel.Background = Color.Default 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColorPicButtonReplace()
  
  Dim cPic As Picture
  
  cPic = ListSelectAll.Picture
  cPic = cPic.Image.Replace(Color.Black, Color.SelectedBackground).Picture  '(Oldcolor, Newcolor)
  ListSelectAll.Picture = cPic
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxSearch5_MouseDown()
  
  If TextBoxSearch5.Text = ("Suche") Then TextBoxSearch5.Text = ""
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = True 
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150 
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Blue
    Case "new" 
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "linenumber"
      ColumnView1.Background = F_iColorGreenAlpha220
    Case "moreswitches"
      PanelListMenu.Background = F_iColorGreenAlpha150
    Case "text5resize", "searchtext5"
      PanelText5.Background = F_iColorGreenAlpha150
    Case "arrowpaste"
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "newplus"
      Text0.Visible = False 
      Text0b.Visible = False 
      Text1.Visible = False
      Text2.Visible = False
      Text5.Visible = False 
      TextBackgroundAll(Color.White)
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
    Case "save" 
      ColumnView1.Background = F_iColorGreenAlpha220
      LabelInfoPathG(FilePathForm())
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = F_iColorBlue
      TextBoxPath.Foreground = Color.Default
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = True
      ButtonSum.Background = F_iColorGreenAlpha150
      ButtonDauer.Border = True
      ButtonDauer.Background = F_iColorGreenAlpha150
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  End Select
  
  If FMain.F_sErrorInfos Then 
    IconError.Visible = True 
    IconError.Raise() '▲Top▲
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Last.Tag = ButtonDateCancel.Tag Then 
    '...
  Else If Object.Type(Last) = "Button" Then
    Last.Border = False 
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Default
    Case "new"
      TextBackgroundAll(Color.Transparent)
    Case "linenumber"
      ColumnView1.Background = Color.Transparent
    Case "moreswitches"
      PanelListMenu.Background = Color.Transparent
    Case "text5resize", "searchtext5"
      PanelText5.Background = Color.Transparent
    Case "arrowpaste"
      TextBackgroundAll(Color.Transparent)
    Case "newplus"
      Text0.Visible = True   
      Text0b.Visible = True  
      Text1.Visible = True
      Text2.Visible = ButtonSum.Visible  
      Text5.Visible = True 
      TextBackgroundAll(Color.Transparent)
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "save"
      ColumnView1.Background = Color.Transparent
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Gray
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = False
      ButtonSum.Background = Color.Default
      ButtonDauer.Border = False
      ButtonDauer.Background = Color.Default
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = Color.Default
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp() 'PictureBox
  
  If Object.Type(Last) = "PictureBox" Or Object.Type(Last) = "Label" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click() 'Click with Buttons or Menue
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "Left")
  
  Dim sKey, sPath, sDir, sFile As String 
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form5Projekte.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  ' ColumnViewAddMin1xCount()
  sMouseLMR = String.Lower(String.Left(sMouseLMR, 1)) 'Example: "L" '> Left, Middle, Right
  
  Select Case String.LCase(sLastTag)
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "add"
      ButtonPathAddG()
    Case "opentermine"
      sPath = FilePathForm() 
      ReadG(sPath, True) 'True: with Dialog
    Case "openbackup"
      sPath = M01Functions.OpenBackupDirFile(FilePathForm())
      ReadG(sPath, True) 'True: with Dialog
    Case "birthdaysoutside" 'Outside —▶
      GeburtstageAuslagernG() '(Auslagern nach F_sPathEveryYear)
    Case "birthdaysinside" 'Inside ◀—
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      ReadG(sPath, True) 'True: with Dialog
    Case "newplus"
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd"))
      Text1Insert(Format(Time, "hh:nn"))
      Text2Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      PanelText5.Background = Color.White
      ColumnView1.UnselectAll()
      NewLineG()
    Case "reload"
      ColumnViewReload()
    Case "save"
      SaveG()
    Case "saveascopy"
      sPath = FilePathForm()
      sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
      sFile = File.Name(sPath) & "_copy." & File.Ext(sPath)
      sPath = FileDialogPathReturn(sDir &/ sFile, "save", sPath)
      If sPath Then  'Null = Canceled
        If Exist(sPath) = False Then File.Save(sPath, "empty")
        If Exist(sPath) = True Then SaveG(sPath)
      Endif 
        
    Case "exportselection"
      ExportSelectionG()
    Case "termineauslagern"
      TermineAuslagernG()
    Case "termineeinlagern"
      TermineEinlagernG()
    Case "openfeiertageplus"
      If Settings[FMain.Name &/ "OsterSonntag", ""] = "" Then M03Feiertage.HolidaysCalculate() 'Calculeted Holidays
      Form8ZusFeiertage.Window.Show
      ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
    Case "editortermine"
      sPath = FilePathForm()
      M01Functions.FileToForm3Text(sPath)
    Case "editorbirthdays"
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      M01Functions.FileToForm3Text(sPath)
    Case "exportzeichensatz"
      Form13Export.Window.Show
      ' Form13Export.Window.Visible = True  'Wayland error?
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "newline"
      ColumnView1.UnselectAll()
      NewLineG()
    Case "inputline"
      If F_iMusterTermine1Names2Projects3 = 2 Then CheckProjectOnlyName(Text5.Text) 'Test
      ButtonInputG()
      TextBackgroundAll(Color.Transparent)
      
    Case "windowt5plus"
      WindowT5plusG()
    Case "new"
      TextNeuClear()
    Case "searchpanel"
      ButtonSucheG()
    Case "searchpanel5notice"
      PanelSearchText5.Visible = True 
      PanelSearchText5.Raise
      F_iText5SearchPosition = 0
      TextBoxSearch5.SetFocus
    Case "cancelsearch5"
      PanelSearchText5.Visible = False
    Case "searchtext5"
      Text5Search()
    Case "text5resize"
      Text5Resize()
    Case "arrowpaste"
      PasteLineArrow()
      TextBackgroundAll(Color.White)
    Case "cancelbutton"
      SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
    Case "moreswitches"
      MoreButtonsG()
    Case "searchbutton", "search"
      ButtonSearchG()
      If ColumnView2.Visible = True Then ColumnViewFind("+") '↓
    Case "searchdown"
      ColumnViewFind("+") '↓
    Case "searchup"
      ColumnViewFind("-") '↑
    Case "searchliston"
      If ButtonSearchListOn.Background <> Color.Green Then ButtonSearchListOn.Background = Color.Green Else ButtonSearchListOn.Background = Color.Default
      SearchListG()
    Case "searchpanel"
      ListMenuGroupFunctions("searchpanel")
    Case "cancelsearch"
      CancelSearchG()
    Case "saveselection"
      SaveSelectionG()
    Case "labeldateinfo"
      LabelDatumInfo()
    Case "labeltimer"
      LabelTimerG()
    Case "linenumber"
      sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible
    Case "fileinfo"
      FileInfoG()
    Case "title"
      CheckProjectOnlyName(Text5.Text) 'Test
    Case "close"
      ButtonCancelG()
      
      'Extra:
    Case "csv"
      ButtonExternStartG(Last.Tag)
    Case "projectname"
      PanelText5.Background = Color.White
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Case "allyears"
      If F_iMusterTermine1Names2Projects3 = 1 Then CheckBox1G()
    Case "buttonprojecton"
      If F_iMusterTermine1Names2Projects3 = 2 Then 
        CheckBoxONoff.Value = Not CheckBoxONoff.Value
        ProjectONoff(CheckBoxONoff.Value)
      Endif 
    Case "checkbox"
      ' If F_iMusterTermine1Names2Projects3 = 2 Then ProjectONoff(CheckBoxONoff.Value)
    Case "t4", "dauer" 'Duration Button 00:00:00
      If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck() '=calculate new (neu berechnen)
      TextBackgroundAll(Color.White)
    Case "bis"
      If F_iMusterTermine1Names2Projects3 = 1 Then ButtonUntil()
      
  End Select
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ListMenuGroup_Click() '—▶ Menu _Click!
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroup_MouseDown() 'PanelListMenu □ □ □ □ □ □ □ □
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroupFunctions(Optional sLastTag As String = "")
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form5Projekte.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  If ColumnView1.Columns.Max > -1 Then 
    ListButtonsRefresh()
    If Not F_ooCVBackups Then ColumnViewBackup()
    
    Select Case String.LCase(sLastTag)
      Case "selectall"
        ColumnViewSelectAll() 'SelectAll<>UnselectAll
      Case "unselectall"
        ColumnView1.UnselectAll()  
      Case "selectall2"
        ColumnView2.Mode = Select.Multiple
        ColumnView2.SelectAll()  
        ColumnView2to1()
      Case "unselectall2" 
        ColumnView2.UnselectAll()
        ColumnView2to1()
      Case "copy"
        ColumnViewCopy()
      Case "copy2"
        ColumnViewCopy()
      Case "cut" 'delete, remove
        ColumnViewCut()
      Case "cut2"
        ColumnViewCut()
        ColumnView2to1()
      Case "new" 'Clear
        TextNeuClear()
      Case "add", "+1x"
        ColumnViewAdd()
      Case "addappend"
        ColumnViewAddAppend()
      Case "paste", "insert" 
        ColumnViewPaste()
      Case "up"
        ColumnViewUp()
      Case "down"
        ColumnViewDown()
      Case "markgreen"
        ColumnViewMarkGreen()
      Case "refresh", "clean" ', "reload"  'new Numbers 1,2,3...
        ColumnViewRefresh()
        ColumnView1Resize()
      Case "reload"
        ColumnViewReload()
      Case "searchpanel"
        SearchPanelG()
      Case "sortabc"
        ColumnViewCheckBoxAbc()
      Case "original"
        ColumnViewOrig()
      Case "original2"
        ColumnViewOrig()
        ColumnView2to1()
      Case "undo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer - 1
        ColumnViewUndoRedo()
      Case "counterlabel"
        MenuUndoRedo.Popup
      Case "redo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer + 1
        ColumnViewUndoRedo()
      Case "undomin"
        F_iCVUndoRedoPointer = 0
        ColumnViewUndoRedo()
      Case "redomax"
        F_iCVUndoRedoPointer = F_ooCVBackups.Max
        ColumnViewUndoRedo()
      Case "undotext"
        DateTimeNoticeBackup("<")
      Case "redotext"
        DateTimeNoticeBackup(">")
      Case "undotextmin"
        F_iDateTimeNoticeBackupPointer = 0
        DateTimeNoticeBackup("<")
      Case "redotextmax"
        F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        DateTimeNoticeBackup(">")
      Case "textundo"
        Text5.Undo()
      Case "textredo"
        Text5.Redo()
      Case "sortpics"
        ColumnViewSortPics()
      Case "correct"
        ColumnViewCorrectLines()
      Case "double"
        ColumnViewDouble()
      Case "compare1"
        ColumnViewCompare(False)
      Case "compare2"
        ColumnViewCompare(True)
      Case "aplus" 'A+
        If F_i22 < 22 Then 
          F_i22 = 22  'greater (groesser) +
        Else 
          F_i22 = 16 
        Endif 
        ColumnViewCheckAplus()
    End Select
    
    Select Case String.LCase(sLastTag)
      Case "selectall", "unselectall", "save", "changed", "counterlabel", "searchpanel"
      Case "undo", "redo", "undomin", "redomax", "textundo", "textredo", "undotext", "redotext", "undotextmin", "redotextmax"
      Case "double", "compare1", "compare2", "aplus"
        '... making no backup
      Case Else 
        F_bListChanged = True
        ColumnViewBackup()
    End Select
  Endif 
  ColumnViewListChangeLED()
  If LabelInfo.Text = "" Then ColumnViewInfo() 'Default Select
  WindowTitle()
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ColumnViewSelectAll()
  
  If ColumnView2.Visible = True Then 
    If ColumnView2.Selection.Max < 1 Then 
      ColumnView2.Mode = Select.Multiple
      ColumnView2.SelectAll()
    Else 
      ColumnView2.UnselectAll()  
    Endif 
  Else 
    If ColumnView1.Selection.Max < 1 Then 
      ColumnView1.Mode = Select.Multiple
      ColumnView1.SelectAll()
    Else 
      ColumnView1.UnselectAll()  
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonPathAddG()
  
  Dim sPath As String 
  
  sPath = TextBoxPath.Text 
  If Settings[FMain.Name &/ "ProjectTest"] = sPath Then 
    sPath = M01Functions.DemoDiagramFile() 'as String 
    ReadG(sPath, False) 'True=Dialogfenster
  Else
    If Exist(sPath) = False Then sPath = FilePathForm()
    ReadG(sPath, False) 'True=Dialogfenster
    ' ButtonPaintDiagramG() '>Form16Diagramm
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCancelG()
  
  Form5Projekte.Window.Close
  
Catch 
  FMain.ErrorText
  
End '...............................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form14UhrDesign.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form14UhrDesign.class
623 KB
' Gambas class file

'Note: Simplify structure (Struktur vereinfachen)
'Later designed and added (später entworfen und hinzugefügt)
'Note: Test it and make it better. (Teste es und mache es besser.)

'F_ = Form
Public F_bColorChangeON As Boolean
Public F_bEditChangeON As Boolean
Public F_bChangeON As Boolean '=False (Default, Voreinstellung)
Public F_bColorPickerAreaON As Boolean
Public F_bESCpressedON As Boolean '=False
Public F_bGallerySortON As Boolean 
Public F_bMoreButtons As Boolean 
Public F_bMovingON As Boolean
Public F_bMusterSideChanged As Boolean
Public F_bSelectionTopON As Boolean
Public F_bWhiteBorderON As Boolean = True
Public F_dateNow As Date
Public F_fFontSizePlus As Float 
Public F_iBackground As Integer = 3 'Wood
Public F_iClockSeconds As Integer
Public F_iColor0Picker1Transparent2 As Integer
Public F_iColorBefore As Integer
Public F_iColorBehind As Integer
Public F_iColorBoxesPointer As Integer = 0  'Number Box > .Max
Public F_iColorPicker As Integer
Public F_iColorPickerTrans As Integer
Public F_iColorSelect As Integer = Color.SetAlpha(1073807104, 190) '   Color.Green
Public F_iESCpressed As Integer '> 0 pressed
Public F_iiColorChangeUndoLevels As Integer[]
Public F_iiColorSelect As Integer[] = [Color.SetAlpha(1073807104, 190), Color.SetAlpha(-922812161, 190), Color.SetAlpha(1677787135, 100), Color.SetAlpha(16762880, 100), Color.SetAlpha(Color.DarkGreen, 150)]
Public F_iIconSize As Integer = 128 'px (Pixel) '—▶ FormStart()
Public F_iiLevelsLeft As Integer[]
Public F_iiPicBoxesVisibleLevelNr As Integer[]
Public F_iLastPicBoxColor As Integer
Public F_iLastPicBoxLeft As Integer
Public F_imgCenterPoint As Image
Public F_imgClockBG As Image 'Background
Public F_imgClockCutter As Image
Public F_imgClockNumbers As Image
Public F_imgDatePoint As Image
Public F_imgDigital As Image
Public F_imgGearWheel As Image
Public F_imgHour As Image
Public F_imgLastIconImage As Image 
Public F_imgLCD As Image
Public F_imgMinute As Image
Public F_imgNightSky As Image
Public F_imgPhythagoras As Image
Public F_imgSecond As Image
Public F_imgSumPaintClockLevels As Image
Public F_imgSunUpDown As Image
Public F_imgTimeSummer As Image
Public F_iMusterAddLast As Integer
Public F_iMusterSelectionCount As Integer
Public F_iOnly1x As Integer
Public F_iScrollPart As Integer
Public F_iSecondCounter As Integer
Public F_iSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iSelectButton0Levels1Gallery2Muster3 As Integer 'unused???
Public F_iSelectGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150) 
Public F_iSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iSelectYellow100 As Integer = Color.SetRGB(95, 95, 95) 'Color.SetAlpha(Color.Black, 100)
Public F_iUndoRedoLevelPointer As Integer '= -1
Public F_iUndoRedoMusterPointer As Integer '= -1
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_iZoomFactorCursor As Integer = 5
Public F_iZoomGallery As Integer
Public F_iZoomStandard As Integer 'Pixel
Public F_oColorPickerLastObj As Object
Public F_oLastPicBoxMuster As Object
Public F_oLastPicBoxObject As Object
Public F_ooButtonMuster As Object[]
Public F_ooButtonsLevels As Object[]
' Public F_ooColorChangeLevels As Object[]
Public F_ooPicBoxesDigital As Object[]
Public F_ooPicBoxesGallery As Object[]
Public F_ooPicBoxesLevels As Object[]
Public F_ooPicBoxesLevelsOnlyVisible As Object[]
Public F_ooPicBoxesMuster As Object[]
Public F_ooPicBoxesSekunde As Object[]
Public F_picClock As Picture 'created by all selected levels
Public F_picScreen As Picture
Public F_sBackgroundColorOrPath As String 
Public F_sBackgroundColorOrPathEnter As String
Public F_sClockPartsFileNames As String ' Example: "clockbackground.png" & gb.NewLine & "..."
Public F_sColorChangeLineStandard As String
Public F_sColorChangeLineUser As String
Public F_sEmptyText As String = ("Leer")
Public F_sForm As String = Me.Name 
Public F_sLabelMessageTextEmptyHTML As String = "<font color=red><b>" & ("Ein Bild auswählen") & ". " & ("Maustaste: Mitte") & "</b></font>"
Public F_sLastIconName As String
Public F_sLevelsTags As String 
Public F_sLoadUserPaths As String 
Public F_sMovableParts As String 
Public F_sMoveAblePartLast As String 
Public F_sMusterTags As String 
Public F_sPathClockBackground_png As String
Public F_sPathClockMuster_txt As String 
Public F_sRecentOpenMusterLastPath As String
Public F_ssEditLevels As String[]
Public F_ssEditLevelsUndo As String[]
Public F_ssEditLines As String[]
Public F_ssEditLinesUndo As String[]
Public F_ssEditTagsWords As String[]
Public F_ssMenuOpenRecent As String[]
Public F_ssMenuSaveRecent As String[]
Public F_ssParkingUndo As String[] 
Public F_ssPicBoxGalleryTags As String[]
Public F_ssPicBoxMusterTags As String[]
Public F_ssUndoRedoLevels As String[]
Public F_ssUndoRedoMuster As String[]
Public F_ssUndoRedoMusterSelection As String[]
Public F_sTagLastMenu As String 'Example: "rotateleft"
Public F_sTagsClockDigital As String 'Example: "FreeSans"
Public F_sTagsClockGearWheel As String 'Example: "-sun"
Public F_sTagsClockLCD As String 'Example: "timelcd-square-big-blue"
Public F_sTagsClockNumbers As String 
Public F_sTagsClockPhythagoras As String 
Public F_sTagsClockSunUpDown As String 'Example: "-stroke"
Public F_sWorkplaceLevelsLastTime As String

''Clock Colors, Module —▶ M05 
Public F_iColor As Integer '0
Public F_iColorBlue As Integer '1
Public F_iColorRed As Integer '2
Public F_iColorGray As Integer '3
Public F_iColorDarkGray As Integer '4
Public F_iColorWhite As Integer '5
Public F_iColorTransBlack As Integer '6
Public F_iColorYellow As Integer '7
Public F_iColorNature As Integer '8
Public F_iColorWaterTrans As Integer '9
Public F_iColorCut As Integer = Color.Background '10
Public F_iiIconClockColorsA As Integer[] '0,1,2,3,...= n+1
Public F_iiIconClockColorsB As Integer[] 
Public F_iiIconClockColorsBbefore As Integer[]
Public F_ooPicBoxesColorsA As Object[] '—▶ResizeColorBoxes() 'Default Colors
Public F_ooPicBoxesColorsB As Object[] 'User Colors

Public F_sTitleBasicText As String = Me.Window.Title
Public F_sURLblankempty As String = "about:blank" 'empty (leer) 
Public F_ooUndoRedoColors As Object[]
Public F_iUndoRedoColorsPointer As Integer
Public F_rectZoom As Rect
Public F_iSearchPosWeb As Integer
Public F_iSearchPosText As Integer
Public F_iSearchPosCode As Integer
Public F_iColumnUndo As Integer
Public F_iSearchPosColumnView As Integer

Public F_ooPicBoxesColorsBgrid As Object[]
Public F_ooUndoRedoPhoto As Object[] 
Public F_oPicBoxColorFind As Object
Public F_oPicBoxColorLast As Object
Public F_picPhotoLastUndo As Picture

Public F_bMemoryColorsPanelON As Boolean
Public F_fX1 As Float
Public F_fY1 As Float
Public F_fZoomFactor As Float = 10
Public F_iBackgroundColorEnter As Integer 
Public F_sBackgroundColorOrPathUndo As String 
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220)
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150) 
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)

Public F_bPanelColorsChanged As Boolean
Public F_bPanelGallery As Boolean
Public F_bPanelMenuEditON As Boolean
Public F_bPanelMuster As Boolean
Public F_bPanelPathON As Boolean
Public F_bPanelSave As Boolean
Public F_iColorsCount As Integer = 10
Public F_iColumn12Sort As Integer = 12  'Name=name=Hex=RGB=Dezi=...
Public F_iColumns13Undo As Integer = 13
Public F_iColumns14Count As Integer = 14
Public F_iiMusterSelection As Integer[]
Public F_iiMusterSort As Integer[]
Public F_iiPanelMemoryColorsUndo As Integer[]
Public F_iLastColor As Integer
Public F_iLastSide As Integer
Public F_iLastSideBefore As Integer
Public F_imgScreen As Image
Public F_imgZoom As Image
Public F_iPanelGalleryHeight As Integer
Public F_iPanelGalleryTop As Integer
Public F_iSaveQualityJPG As Integer = 80 '80%
Public F_iUndoRedoPhotosPointer As Integer
Public F_oCursorFillLast As Object
Public F_pointPickerXY As Point
Public F_sColorValueUndo1 As String
Public F_sColorValueUndo2 As String
Public F_sColorValueUndo3 As String
Public F_sFileClockMusterLastTemp_PNG As String = "clockmusterlasttemp.png"
Public F_sFileClockMusterLastTemp_TXT As String = "clockmusterlasttemp.txt"
Public F_sForm21ColorsText As String
Public F_sPathScreenphotoPNG As String
Public F_sSaveFormat As String
Public F_ssColorNames As String[] 
Public F_sSideG As String

Public Function FilePathForm() As String 
  
  Dim sDir As String
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If Exist(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  F_sPathClockMuster_txt = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt]
  
  Return F_sPathClockMuster_txt 'Example: "/home/<user>/terminwecker/terminwecker-clock/file_clockmuster.txt"
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub Form_Open()
  
  Me.Window.Title = Application.Name & " - " & ("Baukasten")
  If Not Me.Window.Icon Then Me.Window.Icon = FMain.Window.Icon
  TimerClock.Stop()
  
  LabelTimePause.Foreground = LabelTemplateClockColor.Background '00:00  FMain.F_iColorClockBlue
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1 'behind > wait...
    FormStart()
    PicBoxColorTransparentBG.Picture = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200)).Picture
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  F_bChangeON = False
  MenuWeb.Visible = False
  FormBackgroundColor()
  
  PanelBorder.Background = Color.Transparent
  PanelColorZoom.Background = Color.Transparent
  PanelColor.Background = Color.Transparent
  PanelColorSave1.Background = Color.Transparent
  PanelColorSave2.Background = Color.Transparent
  PanelSave.Background = Color.Transparent
  PanelPath.Background = Color.Transparent
  PanelMenuEdit.Background = Color.Transparent
  PanelMemoryColors.Background = Color.Transparent
  PanelLevels.Background = Color.Transparent
  PanelMusterMenu.Background = Color.Transparent
  PanelGallery.Background = Color.Transparent
  PanelMuster.Background = Color.Transparent
  
  ''Create little color picture for Menu:
  MenuMySelectionColor1.Picture = M01Functions.ColorCreateButton(16, 16, F_iiColorSelect[0]).Picture 'Color.Green
  MenuMySelectionColor2.Picture = M01Functions.ColorCreateButton(16, 16, F_iiColorSelect[1]).Picture 'Color.SoftPurple
  MenuMySelectionColor3.Picture = M01Functions.ColorCreateButton(16, 16, F_iiColorSelect[2]).Picture 'Color.SoftCyan
  MenuMySelectionColor4.Picture = M01Functions.ColorCreateButton(16, 16, F_iiColorSelect[3]).Picture 'Natur Penguin foots
  MenuMySelectionColor5.Picture = M01Functions.ColorCreateButton(16, 16, F_iiColorSelect[4]).Picture 'Color.DarkGreen
  
  MoreButtons(F_bMoreButtons)
  
  F_ssEditTagsWords = ["mirrorleftright", "mirrortopbottom", "rotateleft", "rotateright", "grayscale", "scaleminus", "scaleplus", "moveleft", "moveright", "moveup", "movedown", "fontsizeminus", "fontsizestandard", "fontsizeplus"] '0—▶13
  
  F_sMovableParts = "-timehh-timemm-timess-timesunupdown-timelcd-timedigital-timegearwheel-timeclocknumbers-timedatepoint" 
  F_sMovableParts &= "-timenightsky-timesummer-timephythagoras-clockhour-clockminute-clocksecond-cutter" 'moving parts (bewegliche Teile)
  F_iColorPicker = Settings[F_sForm &/ "F_iColorPicker", F_iColorSelect]
  F_iColorPickerTrans = Settings[F_sForm &/ "F_iColorPickerTrans", Color.Transparent]
  F_iColorBefore = F_iColorPicker
  F_iColorBehind = F_iColorPicker
  
  ''File:
  F_sPathClockBackground_png = Settings[FMain.Name &/ "F_sPathClockBackground_png", FMain.F_sPathClockBackground_png] 'as String
  F_sPathClockMuster_txt = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt]
  
  TextBoxPath.Selectall()
  TextBoxPath.Insert(F_sPathClockMuster_txt)
  LoadPicBoxPath() 'PanelBGPath: Info | Pic | PathText
  
  CreateMenuColorPicture()
  
  ''Date:
  DateTimeSetting(Now) 'as Date
  
  ''Clock?
  SchongangStatus()
  
  ''Clock pause?
  CheckTimerClockPausePicture()
  WindowStretchCursor()
  
  ReadG()  '+ 1x LabelUndoRedoCounter.Text = "1/1"
  ScrollViewLevels.ScrollX = 0
  
  ScrollViewGallery.ScrollY = Settings[F_sForm &/ "ScrollViewGallery.ScrollY", ScrollViewGallery.ScrollY]
  
  F_ssMenuOpenRecent = Settings[F_sForm &/ "F_ssMenuOpenRecent", Null]
  F_ssMenuSaveRecent = Settings[F_sForm &/ "F_ssMenuSaveRecent", Null]
  
  ' Me.FileChooser1.Bookmarks = Settings[FMain.Name &/ "FileChooser1.Bookmarks", Me.FileChooser1.Bookmarks]
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  PicBoxMusterAdd.Tooltip = ("Uhr als Muster speichern") & gb.NewLine & Settings[FMain.Name &/ "F_sPathClockMuster_txt", F_sPathClockMuster_txt]
  
  ''Default:
  UndoRedoLevelSave()
  
  SideG(F_sSideG)
  
  CheckButtonEdit()
  
  ''Start Clock:
  TimerClock.Start()
  
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  F_bChangeON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateRandomizeClockMuster10x()
  
  Dim ssNewMuster As String[]
  Dim iiTimeHH, iiTimeMM, iiTimeSS, iiFoot, iiZone, iiBackground, iiRest As Integer[]
  Dim it, iNr, iMuster, iLeft, iColor As Integer
  Dim iiRandomize, iiMusterNumbers, iiColorChange, iiColorMuster As Integer[]
  Dim bTimerON, bAddRandomMuster, bRandomColorsON As Boolean
  Dim sPath, sLevelsBefore, sLine, sMuster, sMessage, sLevels, sTitle As String
  Dim ooObject As Object[]
  
  ' F_ssEditTagsWords = ["mirrorleftright", "mirrortopbottom", "rotateleft", "rotateright", "grayscale", "scaleminus", "scaleplus", "moveleft", "moveright", "moveup", "movedown", "fontsizeminus", "fontsizestandard", "fontsizeplus"]
  ' 
  ' F_sMovableParts = "-timehh-timemm-timess-timesunupdown-timelcd-timedigital-timegearwheel-timeclocknumbers-timedatepoint" 
  ' F_sMovableParts &= "-timenightsky-timesummer-timephythagoras-clockhour-clockminute-clocksecond-cutter" 'moving parts (bewegliche Teile)
  
  If F_iESCpressed > 0 Then Goto JumpEnd 
  
  bTimerON = TimerClock.Enabled
  TimerClock.Stop
  F_bChangeON = False
  
  ''Check:
  If Not F_ooPicBoxesMuster Then CheckMusterSideFill()'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  If F_iESCpressed > 0 Then Goto JumpEnd 
  
  ''Levels fo Musterpots
  For it = 0 To F_ooPicBoxesGallery.Max
    ''[ESC]?
    If F_iESCpressed > 0 Then 
      If MessageQuestionBreak() > 0 Then Break
    Endif
    
    If F_ooPicBoxesGallery[it].Tag Like "*" & "timehh" & "*" Then 
      If Not iiTimeHH Then iiTimeHH = New Integer[]
      iiTimeHH.Add(it) 'level=number=left=selected=
    Else If F_ooPicBoxesGallery[it].Tag Like "*" & "timemm" & "*" Then 
      If Not iiTimeMM Then iiTimeMM = New Integer[]
      iiTimeMM.Add(it)
    Else If F_ooPicBoxesGallery[it].Tag Like "*" & "timess" & "*" Then 
      If Not iiTimeSS Then iiTimeSS = New Integer[]
      iiTimeSS.Add(it)
    Else If F_ooPicBoxesGallery[it].Tag Like "*" & "foot" & "*" Or F_ooPicBoxesGallery[it].Tag Like "*" & "watchstrap" & "*" Then 
      If Not iiFoot Then iiFoot = New Integer[]
      iiFoot.Add(it)
    Else If F_ooPicBoxesGallery[it].Tag Like "*" & "zone" & "*" Or F_ooPicBoxesGallery[it].Tag Like "*" & "wheel" & "*" Or F_ooPicBoxesGallery[it].Tag Like "*" & "numbers" & "*" Then 
      If Not iiZone Then iiZone = New Integer[]
      iiZone.Add(it)
    Else If F_ooPicBoxesGallery[it].Tag Like "*" & "background" & "*" Then 
      If Not iiBackground Then iiBackground = New Integer[]
      iiBackground.Add(it)
    Else 'Rest
      If Exist(F_ooPicBoxesGallery[it].Tag) = True Then sPath = F_ooPicBoxesGallery[it].Tag & "=" Else sPath = ""
      If Not iiRest Then iiRest = New Integer[]
      iiRest.Add(it)
    Endif
    
  Next
  If F_iESCpressed > 0 Then Goto JumpEnd 'Goto not in For...Next (Loops)
  
  ''Title:
  iMuster = 10 'x Count (Anzahl)
  
  ' iiEdit = New Integer[]
  ' If iiTimeHH Then iiEdit.Insert(iiTimeHH) 'add in the end
  ' If iiTimeMM Then iiEdit.Insert(iiTimeMM)
  ' If iiTimeSS Then iiEdit.Insert(iiTimeSS)
  ' If iiFoot Then iiEdit.Insert(iiFoot)
  ' If iiZone Then iiEdit.Insert(iiZone)
  ' If iiBackground Then iiEdit.Insert(iiBackground)
  ' If iiRest Then iiEdit.Insert(iiRest)
  
  ssNewMuster = New String[]
  ' If F_iiIconClockColorsB Then iiColorChange = F_iiIconClockColorsB
  ' iiColorChange = M01Functions.RandomColors(0, 255, F_iColorsCount)
  
  ''Muster as Text:
  For it = 0 To iMuster - 1 '.Max
    If F_iESCpressed > 0 Then Break
    sTitle = "#terminwecker" & Space(1) & Application.Version & Space(1) & "Clock-Levels" & Space(1) & ("Random, mit Zufallsgenerator erstellt") & gb.NewLine
    sTitle &= "#level number left selected path (0|1|2|3|4|) Muster: " & Str(it + 1) & Space(1) & ("von") & Space(1) & iMuster & gb.NewLine
    
    iiMusterNumbers = New Integer[]
    sLevels = sTitle & gb.NewLine
    sLevels &= "level=begin" & gb.NewLine
    
    If iiBackground Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiBackground.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiBackground.Count Then 
        iNr = iiBackground[iiRandomize.First]
        iiMusterNumbers.Add(iNr) '[Musterpot][Level-Number]
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif 
    Endif
    
    If iiFoot Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiFoot.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiFoot.Count Then 
        iNr = iiFoot[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If iiZone Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiZone.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiZone.Count Then 
        iNr = iiZone[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If iiRest Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiRest.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiRest.Count Then 
        iNr = iiRest[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If iiTimeHH Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiTimeHH.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiTimeHH.Count Then 
        iNr = iiTimeHH[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If iiTimeMM Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiTimeMM.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiTimeMM.Count Then 
        iNr = iiTimeMM[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If iiTimeSS Then
      iiRandomize = M01Functions.RandomIntegerNumbers(0, iiTimeSS.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < iiTimeSS.Count Then 
        iNr = iiTimeSS[iiRandomize.First]
        iiMusterNumbers.Add(iNr)
        Inc iLeft 'iLeft = iLeft + 1
        sLevels &= "level=" & iNr & "=" & iLeft & "=1=" & gb.NewLine
      Endif
    Endif
    
    If F_ssEditTagsWords And iiMusterNumbers Then 
      iiRandomize = M01Functions.RandomIntegerNumbers(0, F_ssEditTagsWords.Max, 1) '(von, bis, Anzahl) 'as Integer[]
      If iiRandomize.First > -1 And iiRandomize.First < F_ssEditTagsWords.Count Then 
        ' sLevels &= sLine & F_ssEditTagsWords[iiRandomize.First] & "=" & F_ssEditTagsWords[iiRandomize.First] & "=" & gb.NewLine
        sLine = F_ssEditTagsWords[iiRandomize.First]
        iiRandomize = M01Functions.RandomIntegerNumbers(0, iiMusterNumbers.Max, 1) '(von, bis, Anzahl) 'as Integer[]
        If iiRandomize.First > -1 And iiRandomize.First < iiMusterNumbers.Count Then 
          iNr = iiMusterNumbers[iiRandomize.First]
          iiMusterNumbers.Add(iNr)
          Inc iLeft 'iLeft = iLeft + 1
          If sLine Then sLevels &= "edit=" & iNr & "=" & iLeft & "=1=" & sLine & "=" & gb.NewLine
          ' Print sLevels 
        Endif 
      Endif 
    Endif 
    
    ' If it Mod 2 = 0 Then 
    iiColorChange = F_iiIconClockColorsA.Copy()
    If Not iiColorChange Then iiColorChange = Settings[F_sForm &/ "F_iiIconClockColorsA", F_iiIconClockColorsA]
    iiRandomize = M01Functions.RandomIntegerNumbers(0, iiColorChange.Count, 3) '(von, bis, Anzahl) 'as Integer[]
    If iiRandomize.First > -1 And iiRandomize.First < iiColorChange.Count Then 
      sLine = ""
      iiColorMuster = New Integer[]
      If iiColorChange.Count <> F_iColorsCount Then iiColorChange.Resize(F_iColorsCount)
      For iNr = 0 To iiColorChange.Max
        If iiRandomize.Find(iNr) > -1 Then 
          iColor = Color.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255), Rnd(0, 100)) 
        Else 
          iColor = iiColorChange[iNr]
        Endif 
        'Alpha: 0 = not transparent ◀—▷ 255 = full transparent
        ' iColor = Color.SetAlpha(Color.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255)), Rnd(100, 200))  'RGBA (Alpha)
        sLine &= Str(iColor) & "=" 
        iiColorMuster.Add(iColor)
      Next
      If Not ooObject Then ooObject = New Object[iMuster]
      ooObject[it] = iiColorMuster
      ' If iiColorChange Then F_iiIconClockColorsB = iiColorChange.Copy()
      If sLine Then sLevels &= "colorchange=" & sLine & gb.NewLine
      ' Print sLevels 
    Endif 
    ' Endif 
    
    sLevels &= "level=end" & gb.NewLine & gb.NewLine
    ssNewMuster.Add(sLevels)
    sLevels = "" 'Reset
  Next 
  If F_iESCpressed > 0 Then Goto JumpEnd 'Goto not in For...Next (Loops)
  
  If PanelMuster.Visible = False Then SideG("muster")
  
  sMessage = "<h3><font color=gray>" & ("Randomize: Zufällig erzeugte Muster als Grundlage zur weiteren Bearbeitung") & "</font></h3>"
  sMessage &= "<h3><font color=blue>" & "○ " & iMuster & Space(1) & ("zufällige Muster hinzufügen") & "?" & "</font></h3>"
  sMessage &= "<h3><font color=blue>" & "● " & ("mit Zufallsfarben") & "</font></h3>"
  
  Select Case Message.Question(sMessage, "○ " & ("+hinzufügen"), "● " & ("mit Zufallsfarben"), ("Abbrechen"))
    Case 1 'Add: 
      bAddRandomMuster = True 
      bRandomColorsON = False
      
    Case 2 'Add + color:
      bAddRandomMuster = True 
      bRandomColorsON = True 
      
    Case 3 'Cancel:
      '...
  End Select
  
  If bAddRandomMuster = True Then   
    sLevelsBefore = ReadLevelsTag()
    F_bMusterSideChanged = True
    
    For it = 0 To ssNewMuster.Max 
      sMuster = ssNewMuster[it]
      If F_iESCpressed > 0 Then Break 
      If sMuster And bRandomColorsON = False Then 
        sLevels = Null
        For Each sLine In Split(sMuster & gb.NewLine, gb.NewLine)
          If String.InStr(sLine, "colorchange=") = 0 Then sLevels &= sLine & gb.NewLine
        Next 
      Else 
        sLevels = sMuster 
      Endif 
      
      LoadLevelsNewNull()
      LoadLevels(sLevels) 
      ResizePanelLevels()
      SumPaintClockLevels()
      '**************************************
      Add1xMuster(F_picClock, sLevels)
      '**************************************
      
      If F_ooPicBoxesMuster Then F_ooPicBoxesMuster[F_ooPicBoxesMuster.Max].Background = F_iColorSelect
      sMuster = Null 'reset
    Next
    ResizePanelMuster()
    
    ''Reset:
    F_bChangeON = True 'Reset
    LoadLevelsNewNull()
    LoadLevels(sLevelsBefore) 'Reset
    ResizePanelLevels()
    SumPaintClockLevels()
    If F_ooPicBoxesMuster Then F_oLastPicBoxMuster = F_ooPicBoxesMuster.Last
    F_sLevelsTags = sLevels
    LabelMessageText(iMuster & Space(1) & ("zufällig erzeugte Grund-Muster zur weiteren Bearbeitung"), Color.DarkGreen)
    
    ''Info:
    MusterCounter() 'as String  "0/0"
    If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
    If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter()
  Endif 
  
JumpEnd:
  TimerClock.Enabled = bTimerON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FontsizeG(Optional sLastTag As String = "+") 'unused deactivated! xxxx
  
  Dim sTag, sMessage As String 
  Dim fFMainFontSizePlus, fStep, fFontSizePlus As Float
  Dim it, iFound, iLine As Integer
  Dim sPathCache1 As String
  Dim picMessage As Picture
  
  Return 'end here, deactivated!
  
  fStep = ((F_iIconSize / 10) * 0.1)
  
  Select Case sLastTag
    Case "+", PicFontPlus.Tag 'A+ Aplus
      fFontSizePlus = F_fFontSizePlus + fStep
      
    Case "-", PicFontMinus.Tag 'A- Aminus
      fFontSizePlus = F_fFontSizePlus - fStep
      
    Case "0", LabelFontSize.Tag '0 Aplus
      ' fFontSizePlus = 0
      sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
      iFound = -1
      If Object.IsValid(F_oLastPicBoxObject) = True Then 
        ' iFound = F_ssPicBoxMusterTags.Find("*" & F_sLevelsTags & "*", gb.Like)
        it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject)
        If F_oLastPicBoxObject.Tag Like "*timeclocknumbers*" Then iFound = it
        If F_oLastPicBoxObject.Tag Like "*clock-5*numbers*" Then iFound = it
        If F_oLastPicBoxObject.Tag Like "*clock*figure08*" Then iFound = it
        If F_oLastPicBoxObject.Tag Like "*clock*figure10*" Then iFound = it
        If F_oLastPicBoxObject.Tag Like "*clock*figure11*" Then iFound = it
      Endif
      If iFound = -1 Then 
        For it = 0 To F_ooPicBoxesLevels.Max
          
          iLine = iLine + 1
          ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          
          If F_ooPicBoxesLevels[it].Background = F_iColorSelect Then 
            If F_ooPicBoxesLevels[it].Tag Like "*timeclocknumbers*" Then iFound = it
            If F_ooPicBoxesLevels[it].Tag Like "*clock-5*numbers*" Then iFound = it
            If F_ooPicBoxesLevels[it].Tag Like "*clock*figure08*" Then iFound = it
            If F_ooPicBoxesLevels[it].Tag Like "*clock*figure10*" Then iFound = it
            If F_ooPicBoxesLevels[it].Tag Like "*clock*figure11*" Then iFound = it
          Endif 
        Next
      Endif 
      If Exist(sPathCache1) = True Then Try Kill sPathCache1
      If iFound > -1 Then picMessage = F_ooPicBoxesLevels[iFound].Picture 'Else picMessage = PicTemplateAplus.Picture
      If picMessage Then picMessage.Save(sPathCache1)
      
      sMessage &= "<h3><font color=gray>" & ("Auswahl mit Mittel-Klick") & "</font></h3><br>"
      If Exist(sPathCache1) = True Then 
        sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=100 height=100 >" & Space(1) & ("Text/Zahlen") & Space(1) & "0-1-2-3-4-...24" & "<br>"
      Endif 
      sMessage &= "<h3><font color=gray>" & ("Schrift-Größe-Plus in Icons") & Space(1) & ("+/-") & Str(Round(fStep, -1)) & "</font></h3>"
      sMessage &= "<h3><font size=6 color=gray>" & ("Aktuell") & ": " & LabelFontSize.Text & "</font></h3>"
      sMessage &= "<h3>" & "○ " & ("Standard") & " = " & "<font size=6 color=darkgreen>" & Str(0) & "</font>" & Space(1) & ("(Reset)") & "</h3>"
      
      Select Case Message.Question(sMessage, "○ " & ("Standard") & " = 0", ("Nein"), ("Abbrechen"))
        Case 1
          fFontSizePlus = 0 'Reset
        Case 2, 3
          Goto JumpEnd
      End Select
  End Select
  
  fFMainFontSizePlus = Settings[FMain.Name &/ "F_fFontSizePlus", 0]
  Me.F_fFontSizePlus = fFontSizePlus
  Settings[F_sForm &/ "F_fFontSizePlus"] = Me.F_fFontSizePlus
  
  FMain.F_fFontSizePlus = Me.F_fFontSizePlus
  Settings[FMain.Name &/ "F_fFontSizePlus"] = Me.F_fFontSizePlus
  ' If PanelMuster.Visible = True Then SideG("gallery")
  sTag = ReadLevelsTag()
  DefaultNewLevelsGallery()
  UndoRedoLevelRead(sTag)
  CreateLevelsGallery() ''Refresh
  LoadLevelsNewNull()
  LoadLevels(sTag)
  ResizePanelLevels()
  SumPaintClockLevels()
  
  F_fFontSizePlus = CheckLabelFontSize() 'as Float
  If PanelMuster.Visible = True Then MusterReloadAll()
  Settings[FMain.Name &/ "F_fFontSizePlus"] = fFMainFontSizePlus 'Reset
  
  'Note: rework, not finished! xxxx
  
JumpEnd:
  
Catch 
  FMain.ErrorText
  
End

' Public Sub FormBackgroundColorGroup_Click()
'   
'   If Last.Tag = MenuMyColorChooser.Tag Then 
'     Form21Colors.Show
'     Form21Colors.Visible = True 
'     Form21Colors.F_sForm21ColorsText = ("Hintergrund auswählen: Farbe, Holz, Metall")
'   Else 
'     F_sBackgroundColorOrPath = M01Functions.CheckFormBackgroundColorValue(Last.Tag) 'as String  
'     FormBackgroundColor()
'   Endif 
'   
' Catch 
'   FMain.ErrorText
'   
' End

Public Sub CreateMenuColorPicture()
  
  Dim Img As Image 
  Dim iColor As Integer
  
  iColor = Settings[FMain.Name &/ "ColorButton1.Value", Color.Background]
  
  Img = M01Functions.ColorCreateButton(32, 32, iColor) ' as Image
  
  MenuBackgroundMyColor.Picture = Img.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuView_Show()
  
  Dim it As Integer
  
  CreateMenuColorPicture()
  
  ''Checked:
  For it = 0 To MenuView.Children.Count - 1
    If MenuView.Children[it].Tag And F_sBackgroundColorOrPath Like "*" & MenuView.Children[it].Tag & "*" Then MenuView.Children[it].Checked = True Else MenuView.Children[it].Checked = False
  Next 
  If IsInteger(F_sBackgroundColorOrPath) = True Then MenuBackgroundMyColor.Checked = True Else MenuBackgroundMyColor.Checked = False
  
  MenuMoreButtons.Checked = F_bMoreButtons
  MenuLessButtons.Checked = Not F_bMoreButtons
  MenuGallerySort.Checked = F_bGallerySortON
  
  'Reset:
  MenuMySelectionColor1.Checked = False 
  MenuMySelectionColor2.Checked = False 
  MenuMySelectionColor3.Checked = False 
  MenuMySelectionColor4.Checked = False 
  MenuMySelectionColor5.Checked = False 
  
  If F_iiColorSelect Then 
    Select Case F_iColorSelect
      Case F_iiColorSelect[0] 
        MenuMySelectionColor1.Checked = True 
        
      Case F_iiColorSelect[1]  
        MenuMySelectionColor2.Checked = True 
        
      Case F_iiColorSelect[2]  
        MenuMySelectionColor3.Checked = True 
        
      Case F_iiColorSelect[3]  
        MenuMySelectionColor4.Checked = True 
        
      Case F_iiColorSelect[4]  
        MenuMySelectionColor5.Checked = True 
        
    End Select 
  Endif 
  
  If Me.Window.Maximized = True Or Me.Window.FullScreen = True Then MenuFullScreenF11.Checked = True Else MenuFullScreenF11.Checked = False
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Integer
  ''[ESC]?
  
  If F_iESCpressed > 0 Or F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_iESCpressed = 0
        F_bESCpressedON = False
      Case 2
        F_iESCpressed = 1
        F_bESCpressedON = True 
    End Select
  Endif 
  
  Return F_iESCpressed 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG()
  
  Dim time1, time2 As Date
  Dim iDiff, iSize128 As Integer 
  Dim sMessage, sPath, sZoom As String 
  Dim picZoom As Picture
  
  iSize128 = 128 'Icon-Size, px, Pixel
  time1 = Time
  DefaultNewLevelsGallery()
  CreatePanelMemoryColors() 'takes Colors —▶ behind Create Gallery
  CheckFontColor()
  LabelInfoPathG(FilePathForm())
  SideG("gallery")
  ' ColorChangePicturePath()
  ' ColorChangeLevelsPicture()
  time2 = Time 
  F_iZoomStandard = PanelLevels.H / 2 'Pixel
  
  ''Check:
  iDiff = DateDiff(time1, time2, gb.Second)
  
  If iDiff > 0 Or F_iIconSize > iSize128 Then 'slowly?
    If F_iIconSize = iSize128 Then iSize128 = iSize128 / 2
    sMessage = "<h2><font color=gray>" & ("Icon-Größe ändern") & "?" & "</font></h2>"
    sMessage &= "<h3><font color=red>" & iDiff & Space(1) & ("s") & Space(1) & ("(Sekunden)") & "</font></h3>"
    sMessage &= "<h3>" & ("Langsame Verarbeitung?") & "</h3>"
    sMessage &= "<h3><font color=red>" & "■ " & ("Icon-Größe") & Space(1) & F_iIconSize & "px" & " = " & ("langsamer") & "</font></h3>"
    sMessage &= "<h3><font color=darkgreen>" & "□ " & ("Icon-Größe") & Space(1) & iSize128 & "px" & "</font></h3>"
    
    picZoom = PicBoxZoomPlus.Picture
    sPath = M01Functions.TempDirFile("zoom.png")
    If picZoom And IsDir(File.Dir(sPath)) = True Then picZoom.Save(sPath)
    If Exist(sPath) = True Then sZoom = "<img src=" & Quote("file://" & sPath) & " width=50 height=50 >" 
    sMessage &= "<h4>" & sZoom & "<font color=gray>" & ("Tipp") & Space(1) & ("-Zoom+") & ": " & ("Die tatsächliche Bild-Grösse in Pixeln bleibt mit Zoom unverändert.") & "</font></h4>"
    
    Select Case Message.Question(sMessage, "■ " & ("Icon-Größe") & Space(1) & F_iIconSize & "px", "□ " & ("Icon-Größe") & Space(1) & iSize128 & "px", ("Abbrechen"))
      Case 1  '"■ "
        Settings[FMain.Name &/ "F_iIconSize"] = F_iIconSize 'as Integer, in Pixel. Example: 128
        CheckMenu1()
      Case 2  '"□ "
        Settings[FMain.Name &/ "F_iIconSize"] = iSize128 'as Integer, in Pixel. Example: 128
        CheckMenu1()
      Case 3
        '...
    End Select
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadPicBoxPath()
  
  Dim sPath As String 
  
  ' sPath = TextBoxPath.Text 
  sPath = F_sPathClockBackground_png
  PicBoxPath.Tooltip = sPath
  If Exist(sPath) = True Then PicBoxPath.Picture = Picture.Load(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub OpenLevelPath()
  
  Dim sPath As String
  Dim hPic As Picture
  
  sPath = Settings[FMain.Name &/ "sPathFoto", "?"]
  If Exist(sPath) = True Then 
    Try hPic = Picture.Load(sPath)
    If hPic Then 
      Add1xClockLevel(hPic, sPath)
      ResizePanelLevels()
      ResizePanelGallery()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadUserPaths()
  
  Dim sPath As String
  Dim ssSplit As String[]
  Dim hPic As Picture
  Dim iLine As Integer
  
  If F_iESCpressed > 0 Then Return 
  
  F_sLoadUserPaths = Settings[F_sForm &/ "F_sLoadUserPaths", Null]
  
  If F_sLoadUserPaths Then 
    ssSplit = Split(F_sLoadUserPaths & gb.NewLine, gb.NewLine)
    If ssSplit Then 
      For Each sPath In ssSplit
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif  
        hPic = Null
        If Exist(sPath) = True Then 
          Try hPic = Picture.Load(sPath)
        Else If String.InStr(sPath, "/") > 0 Then 
          hPic = PicTemplateQuestion.Picture
        Endif 
        If hPic Then 
          Add1xClockLevel(hPic, sPath)
        Endif 
      Next
    Endif 
    If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level Bottom▼
  LabelMyClockDesign.Lower()
  LabelUndoRedoCounter.Lower()
  PicBoxColorTransparentBG.Lower()
  PicBoxZoomLupe.Lower()
  PicturePhoto.Lower()
  PicBoxColorSelectBGGrid.Lower()
  
  PicBoxZoom.Raise()
  LabelMessage.Raise()
  PanelMenuEdit.Raise()
  PanelPath.Raise()
  
  PanelColorPicker.Raise()
  PanelColorChooser.Raise()
  PanelColorSave1.Raise()
  ' TextLabelColorInfo.Raise()
  PanelDateTime.Raise()
  PanelColorZoom.Raise()
  PanelClock.Raise()
  
  PicBoxClockBG.Lower()
  PicBoxClock.Raise()
  ButtonBrowser.Raise()
  ProgressBar1.Raise()
  PicBoxColorSelectedBorder.Raise() '□
  WindowStretch.Raise() 'Level Top▲
  
  ''___________________________________________________________________________''
  ' INC ME.TopOnly ' ZOrder, höchste Ebene, INC -> iValue = iValue +1 (1 addieren)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim B, H, iPH, iPH2, iH, iW, iPart, iDis, iScrollBorder, iTop As Integer
  Dim fRest, fW, fH As Float
  
  If Me.Width < 200 Then Me.Width = 200
  If Me.Height < 200 Then Me.Height = 200
  B = 0
  H = 0
  PicBackground.Move(0, 0, Me.ClientW, Me.ClientH)
  fW = PicBackground.Width / 100 * 3  '2.3 ' Randbreite
  fH = PicBackground.Height / 100 * 3 '2.3
  PanelBorder.Move(fW, fH, Me.ClientWidth - (fW * 2), Me.ClientHeight - (fH * 2))
  
  '*****************************
  ' iPH = 40 'Panel Height in Pixeln
  ' iPH2 = iPH / 2
  ' iDis = 5
    iDis = 10 'Pixel
    iPH = 46 'ButtonK1.Height
    iPH2 = iPH / 2
  '*****************************
  IconError.Move(Me.ClientW - 32, 0, 32, 32)
  
  If F_bMovingON = False Then 

    
    
    ' Print "F_bMovingON", F_bMovingON
    If FMain.F_iClockPictureBoxHeight > 0 Then PanelHead.H = FMain.F_iClockPictureBoxHeight Else PanelHead.H = 128
    iScrollBorder = Screen.AvailableY 'Example: 34
    ' iScrollBorder = Desktop.Y 'Example: 34
    If iScrollBorder < 20 Then iScrollBorder = 20 'iScrollBorder = Desktop.Y 'ca.28?
    
    
    ''Panels:
    PanelHead.Move(B, H, PanelBorder.W, PanelHead.H)
    PanelClock.Move(PanelHead.W - (PanelHead.H * 2), 0, (PanelHead.H * 2), PanelHead.H)
    PanelClockMenu.Move(PanelClock.H, 0, PanelClock.H, PanelClock.H) '>Info
    PanelLevels.Move(0, PanelHead.Top + PanelHead.H, PanelHead.W, iPH * 4)
    
    Select Case F_sSideG
      Case "gallery", "muster"
        If F_bMoreButtons = True Then 
          PanelMenuEdit.Move(0, PanelBorder.H - (iPH * 2.5), PanelBorder.W, iPH)
          PanelPath.Move(0, PanelBorder.H - iPH - iPH2, PanelBorder.W, iPH2)
          PanelSave.Move(0, PanelPath.Top + PanelPath.H, PanelHead.W, iPH)
          PanelGallery.Move(0, PanelLevels.Top + PanelLevels.H, PanelBorder.W, PanelMenuEdit.Top - (PanelLevels.Top + PanelLevels.H))
        Else 
          PanelSave.Move(0, PanelBorder.H - iPH, PanelHead.W, iPH)
          PanelGallery.Move(0, PanelLevels.Top + PanelLevels.H, PanelBorder.W, PanelSave.Top - (PanelLevels.Top + PanelLevels.H))
        Endif 
        PanelMenuEdit.Visible = F_bMoreButtons
        PanelPath.Visible = F_bMoreButtons
      Case "color"
        If F_bMemoryColorsPanelON = True Then 
          PanelMemoryColors.Move(0, PanelBorder.H - (iPH * 4.5), PanelBorder.W, iPH * 1.5)
        Else 
          PanelMemoryColors.Move(0, PanelBorder.H - (iPH * 3.5), PanelBorder.W, iPH * 1.5)
        Endif 
        PanelMemoryColors.Visible = F_bMemoryColorsPanelON
        PanelColor.Move(0, 0, PanelBorder.W, PanelMemoryColors.Top)
        PanelMenuColor.Move(iPH * 3, PanelBorder.H - (iPH * 3), PanelBorder.W - (iPH * 3), iPH * 3)
        PanelGallery.Move(0, PanelLevels.Top + PanelLevels.H, PanelBorder.W, PanelMemoryColors.Top - (PanelLevels.Top + PanelLevels.H))
      
      Case "colormemory"
        PanelMemoryColors.Move(0, PanelBorder.H - (iPH * 2.5), PanelBorder.W, iPH * 1.5)
        PanelMemoryColors.Visible = F_bMemoryColorsPanelON
        PanelColor.Move(0, 0, PanelBorder.W, PanelMemoryColors.Top)
        PanelMenuColor.Move(iPH * 3, PanelBorder.H - (iPH * 3), PanelBorder.W - (iPH * 3), iPH * 3)
        PanelGallery.Move(0, PanelLevels.Top + PanelLevels.H, PanelBorder.W, PanelMemoryColors.Top - (PanelLevels.Top + PanelLevels.H))
    End Select
    
    PanelColumnView4.Move(PanelMuster.Left, PanelMuster.Top, PanelMuster.W, PanelMuster.H)
    ColumnView4.Move(0, 0, PanelColumnView4.W, PanelColumnView4.H - iPH)
    ButtonCancelColumnView4.Move(0, ColumnView4.Top + ColumnView4.H, ColumnView4.W, iPH)
    
    PanelColorZoom.Move(PanelBorder.Left, PanelBorder.Top + PanelBorder.H - (iPH * 3), (iPH * 3), iPH * 3)
  
    PanelMuster.Move(PanelGallery.Left, PanelGallery.Top, PanelGallery.W, PanelGallery.H)
    ProgressBar1.Move(PanelBorder.Left, PanelBorder.Top + PanelBorder.H - iPH2, PanelBorder.Width, iPH2)
    
    ''Color Chooser:
    PanelColorPicker.Move(B, PanelGallery.Top, PanelHead.W - iScrollBorder, PanelGallery.H + iPH + iPH2)
    PanelColorChooser.Move(B, PanelGallery.Top, PanelColorPicker.W, PanelColorPicker.H - iPH - iPH2)
    ColorChooser1.Move(0, 0, PanelColorChooser.W - iPH, PanelColorChooser.H)
    ButtonColorChooserCancel.Move(ColorChooser1.Left + ColorChooser1.W, 0, iPH, ColorChooser1.H) '×
    
    ''Glass Picker:
    PicBoxScreenshot.Move(0, 0, PanelColorPicker.W, PanelColorPicker.H)

    ''PanelColorZoom Lupe:
    PicBoxZoomLupe.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)
    PicBoxZoomCross.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)'1:1
    
    ''Date + Time: 
    PanelDateTime.Move(0, 0, PanelBorder.W, PanelBorder.H)
    
    ''PanelHead:
    iW = PanelHead.H / 3
    iH = PicBoxPenguin.H - iPH - iPH2
    PicBoxPenguin.Move(0, 0, PanelHead.H, PanelHead.H) '1:1 WxH
    LabelTimePause.Move(PicBoxPenguin.Left + PicBoxPenguin.W, 0, PanelHead.W - (PicBoxPenguin.Left + PicBoxPenguin.W) - PanelClock.W - (iPH * 3), PanelHead.H - iPH)
    PicBoxPause.Move(LabelTimePause.Left + LabelTimePause.W, LabelTimePause.Top, LabelTimePause.H, LabelTimePause.H)
    
    PicBoxPhoto.Move(PicBoxPenguin.Left + PicBoxPenguin.W, LabelTimePause.Top + LabelTimePause.H, iPH, iPH)
    PicBoxPaste.Move(PicBoxPhoto.Left + PicBoxPhoto.W, PicBoxPhoto.Top, iPH, iPH)
    PicBoxParking0.Move(PicBoxPaste.Left + PicBoxPaste.W, PicBoxPhoto.Top, iPH, iPH)
    PicBoxParking1.Move(PicBoxParking0.Left + PicBoxParking0.W, PicBoxPhoto.Top, iPH, iPH)
    PicBoxParking2.Move(PicBoxParking1.Left + PicBoxParking1.W, PicBoxPhoto.Top, iPH, iPH)
    PicBoxParking3.Move(PicBoxParking2.Left + PicBoxParking2.W, PicBoxPhoto.Top, iPH, iPH)
    
    LabelIconSizeWxH.Move(PicBoxParking3.Left + PicBoxParking3.W, PicBoxPhoto.Top, iPH * 3, iPH)
    ButtonSchongang.Move(LabelIconSizeWxH.Left + LabelIconSizeWxH.W, LabelIconSizeWxH.Top, LabelTimePause.W - (iPH * 11), iPH)
    ButtonBrowser.Move(LabelTimePause.Left + LabelTimePause.W + LabelTimePause.H - (iPH * 4), ButtonSchongang.Top, iPH * 4, iPH)
    
    ''PanelZoom:
    PanelZoom.Move(PicBoxPenguin.Left, PicBoxPenguin.Top, PicBoxPenguin.W, PicBoxPenguin.H)
    PicBoxZoom.Move(0, 0, PanelZoom.W, PanelZoom.H)
    PicBoxColorZoom.Move(0, 0, PanelZoom.W, PanelZoom.H)
    
    ''PanelClock:
    LabelMyClockDesign.Move(0, 0, PanelClock.H, PanelClock.H)
    PicBoxClock.Move(0, 0, PanelClock.H, PanelClock.H) '1:1 WxH
    PicBoxClockBG.Move(PicBoxClock.Left, PicBoxClock.Top, PicBoxClock.W, PicBoxClock.H)
    
    ''PanelClockMenu
    PicBoxSelectLevelONoff.Move(iW, 0, iW, iW)
    PicBoxInfo.Move(PicBoxSelectLevelONoff.Left + PicBoxSelectLevelONoff.W, PicBoxSelectLevelONoff.Top, iW, iW)
    
    PicBoxLevelMinus.Move(PicBoxSelectLevelONoff.Left, PicBoxSelectLevelONoff.Top + PicBoxSelectLevelONoff.H, iW, iW)
    PicBoxLevelPlus.Move(PicBoxLevelMinus.Left + PicBoxLevelMinus.W, PicBoxLevelMinus.Top, iW, iW)
    
    PicBoxLevelsAll.Move(PicBoxLevelMinus.Left, PicBoxLevelMinus.Top + PicBoxLevelMinus.H, iW, iW)
    PicBoxRefreshSum.Move(PicBoxLevelsAll.Left + PicBoxLevelsAll.W, PicBoxLevelsAll.Top, iW, iW)
    
    ''PanelLevels:
    PicBoxLevelsNullNew.Move(0, 0, iW, iW)
    PicBoxOpenDialog.Move(PicBoxLevelsNullNew.Left + PicBoxLevelsNullNew.W, 0, iW, iW)
    PicBoxRandomize.Move(PicBoxOpenDialog.Left + PicBoxOpenDialog.W, 0, iW, iW)
    LabelCounter.Move(PicBoxRandomize.Left + PicBoxRandomize.W, 0, iW * 2, iW)
    PicBoxLevelsQuestionShowGalleryPart.Move(LabelCounter.Left + LabelCounter.W, 0, iW, iW)
    LabelMessage.Move(PicBoxLevelsQuestionShowGalleryPart.Left + PicBoxLevelsQuestionShowGalleryPart.W, 0, PanelLevels.W - (PicBoxLevelsQuestionShowGalleryPart.Left + PicBoxLevelsQuestionShowGalleryPart.W) - (iW * 8), iW)
    PicBoxReorder.Move(LabelMessage.Left + LabelMessage.W, 0, iW, iW)
    PicBoxLevelsEditNull.Move(PicBoxReorder.Left + PicBoxReorder.W, 0, iW, iW)
    PicBoxLevelsEditNullColor.Move(PicBoxLevelsEditNull.Left + PicBoxLevelsEditNull.W, 0, iW, iW)
    PicBoxMenuColorPicker.Move(PicBoxLevelsEditNullColor.Left + PicBoxLevelsEditNullColor.W, 0, iW, iW)
    PicBoxColors.Move(PicBoxMenuColorPicker.Left + PicBoxMenuColorPicker.W, 0, iW, iW)
    PicBoxMusterAdd.Move(PicBoxColors.Left + PicBoxColors.W, 0, iW, iW)
    PicBoxMusterChange.Move(PicBoxMusterAdd.Left + PicBoxMusterAdd.W, 0, iW, iW)
    PicBoxMusterSide.Move(PicBoxMusterChange.Left + PicBoxMusterChange.W, 0, iW, iW)
    
    ScrollViewLevels.Move(0, PicBoxLevelsNullNew.Top + PicBoxLevelsNullNew.H, PanelLevels.W, PanelLevels.H - iW)
    
    ''PanelMuster:
    ScrollViewMuster.Move(0, 0, PanelMuster.W, PanelMuster.H - iPH)
    PanelMusterMenu.Move(0, ScrollViewMuster.Top + ScrollViewMuster.H, PanelMuster.W, iPH)
    ButtonMusterNewOutside.Move(0, 0, iPH, iPH)
    ButtonMusterOpen.Move(ButtonMusterNewOutside.Left + ButtonMusterNewOutside.W, 0, iPH, iPH)
    ButtonMusterSaveDirect.Move(ButtonMusterOpen.Left + ButtonMusterOpen.W, 0, iPH, iPH)
    ButtonMusterSave.Move(ButtonMusterSaveDirect.Left + ButtonMusterSaveDirect.W, 0, iPH * 4, iPH)
    ButtonMusterSavePics.Move(ButtonMusterSave.Left + ButtonMusterSave.W, 0, iPH * 4, iPH)
    ButtonMusterOpenBackup.Move(ButtonMusterSavePics.Left + ButtonMusterSavePics.W, 0, iPH, iPH)
    ButtonMusterDir.Move(ButtonMusterOpenBackup.Left + ButtonMusterOpenBackup.W, 0, iPH, iPH)
    ButtonMusterUnSelectAll.Move(ButtonMusterDir.Left + ButtonMusterDir.W, 0, iPH, iPH)
    ButtonMusterSelectAll.Move(ButtonMusterUnSelectAll.Left + ButtonMusterUnSelectAll.W, 0, iPH, iPH)
    ButtonMusterCut.Move(ButtonMusterSelectAll.Left + ButtonMusterSelectAll.W, 0, iPH, iPH)
    ButtonFindMusterDouble.Move(ButtonMusterCut.Left + ButtonMusterCut.W, 0, iPH, iPH)
    ButtonFindMusterEdit.Move(ButtonFindMusterDouble.Left + ButtonFindMusterDouble.W, 0, iPH, iPH)
    ButtonFindMusterColor.Move(ButtonFindMusterEdit.Left + ButtonFindMusterEdit.W, 0, iPH, iPH)
    ButtonFindCurrentMuster.Move(ButtonFindMusterColor.Left + ButtonFindMusterColor.W, 0, iPH, iPH)
    ButtonMusterSelectionTop.Move(ButtonFindCurrentMuster.Left + ButtonFindCurrentMuster.W, 0, iPH, iPH)
    PicBoxLevelsEditNull2.Move(ButtonMusterSelectionTop.Left + ButtonMusterSelectionTop.W, 0, iPH, iPH)
    PicBoxLevelsEditNullColor2.Move(PicBoxLevelsEditNull2.Left + PicBoxLevelsEditNull2.W, 0, iPH, iPH)
    ButtonMusterReload.Move(PicBoxLevelsEditNullColor2.Left + PicBoxLevelsEditNullColor2.W, 0, iPH, iPH)
    
    fRest = ScrollViewMuster.W - (ButtonMusterReload.Left + ButtonMusterReload.W) - (iPH * 3)
    LabelCounterMuster.Move(ButtonMusterReload.Left + ButtonMusterReload.W, 0, fRest, iPH)
    ' PicBoxUndoMuster.Move(LabelCounterMuster.Left + LabelCounterMuster.W, 0, iPH, iPH)
    ' LabelUndoRedoCounterMuster.Move(PicBoxUndoMuster.Left + PicBoxUndoMuster.W, 0, iPH * 2, iPH)
    ' PicBoxRedoMuster.Move(LabelUndoRedoCounterMuster.Left + LabelUndoRedoCounterMuster.W, 0, iPH, iPH)
    ButtonMusterCancel.Move(LabelCounterMuster.Left + LabelCounterMuster.W, 0, ScrollViewMuster.W - (LabelCounterMuster.Left + LabelCounterMuster.W), iPH)
    
    ''PanelGallery:
    ScrollViewGallery.Move(0, 0, PanelGallery.W, PanelGallery.H)
    
    ''PanelMenuEdit:
    PicBoxColorsStandard.Move(0, 0, iPH, iPH)
    PicBoxCopy.Move(iDis + PicBoxColorsStandard.Left + PicBoxColorsStandard.W, 0, iPH, iPH)
    PicBoxCopyExtern.Move(iDis + PicBoxCopy.Left + PicBoxCopy.W, 0, iPH, iPH)
    PicBoxMirrorLeftRight.Move(iDis + PicBoxCopyExtern.Left + PicBoxCopyExtern.W, 0, iPH, iPH)
    PicBoxMirrorTopBottom.Move(iDis + PicBoxMirrorLeftRight.Left + PicBoxMirrorLeftRight.W, 0, iPH, iPH)
    PicBoxRotateLeft.Move(iDis + PicBoxMirrorTopBottom.Left + PicBoxMirrorTopBottom.W, 0, iPH, iPH)
    PicBoxRotateRight.Move(iDis + PicBoxRotateLeft.Left + PicBoxRotateLeft.W, 0, iPH, iPH)
    PicBoxGrayscale.Move(iDis + PicBoxRotateRight.Left + PicBoxRotateRight.W, 0, iPH, iPH) 
    PicBoxWhiteBorder.Move(iDis + PicBoxGrayscale.Left + PicBoxGrayscale.W, 0, iPH, iPH)
    PicBoxEditStandard.Move(iDis + PicBoxWhiteBorder.Left + PicBoxWhiteBorder.W, 0, iPH, iPH) 
    PicBoxScaleMinus.Move(iDis + PicBoxEditStandard.Left + PicBoxEditStandard.W + iPH, 0, iPH, iPH)
    PicBoxScalePlus.Move(iDis + PicBoxScaleMinus.Left + PicBoxScaleMinus.W, 0, iPH, iPH)
    PicBoxMoveLeft.Move(iDis + PicBoxScalePlus.Left + PicBoxScalePlus.W + iPH, 0, iPH, iPH) 
    PicBoxMoveRight.Move(iDis + PicBoxMoveLeft.Left + PicBoxMoveLeft.W, 0, iPH, iPH) 
    PicBoxMoveUp.Move(iDis + PicBoxMoveRight.Left + PicBoxMoveRight.W, 0, iPH, iPH) 
    PicBoxMoveDown.Move(iDis + PicBoxMoveUp.Left + PicBoxMoveUp.W, 0, iPH, iPH) 
    
    ' PicFontMinus.Move(iDis + PicBoxMoveDown.Left + PicBoxMoveDown.W, 0, iPH, iPH) 
    ' LabelFontSize.Move(iDis + PicFontMinus.Left + PicFontMinus.W, 0, iPH, iPH) 
    ' PicFontPlus.Move(iDis + LabelFontSize.Left + LabelFontSize.W, 0, iPH, iPH) 
    
    PicBoxUndo.Move(iPH + iDis + PicBoxMoveDown.Left + PicBoxMoveDown.W, 0, iPH, iPH)
    LabelUndoRedoCounter.Move(PicBoxUndo.Left + PicBoxUndo.W, 0, PanelMenuEdit.W - (PicBoxUndo.Left + PicBoxUndo.W) - (iPH * 4) - (iDis * 3), iPH)
    PicBoxRedo.Move(LabelUndoRedoCounter.Left + LabelUndoRedoCounter.W, 0, iPH, iPH)
    PicBoxGalleryReset.Move(iPH + iDis + PicBoxRedo.Left + PicBoxRedo.W, 0, iPH, iPH)
    ButtonMenuEditCancel.Move(iDis + PicBoxGalleryReset.Left + PicBoxGalleryReset.W, 0, iPH, iPH)
  
    ''PanelColorSave:
    iTop = 0
    iW = PanelColorSave1.H
    iPart = PanelColorSave1.W / 13
    ButtonColorsStandard.Move(0, iTop, iW / 2, iW)
    ButtonMenuColor.Move(ButtonColorsStandard.Left + ButtonColorsStandard.W, iTop, iW, iW)
    PicBoxPickerColor.Move(ButtonMenuColor.Left + ButtonMenuColor.W, iTop, iW, iW)
    PicBoxPickerTransparent.Move(PicBoxPickerColor.Left + PicBoxPickerColor.W, iTop, iW, iW)
    '□
    PicBoxColorSelectedBorder.Move(PicBoxPickerTransparent.Left + PicBoxPickerTransparent.W, 20, PanelColorSave1.H - 20, PanelColorSave1.H - 20)
    LabelColorSelected.Move(PicBoxColorSelectedBorder.Left, 0, PicBoxColorSelectedBorder.W, 20) 

    ''PanelDateTime:
    DateChooser1.Move(0, 0, PanelDateTime.W - (iPH * 2.5) - iPH, PanelDateTime.H)
    ColumnView3.Move(DateChooser1.Left + DateChooser1.W, 0, PanelDateTime.W - DateChooser1.W - iPH, DateChooser1.H)
    ButtonDateChooserCancel.Move(ColumnView3.Left + ColumnView3.W, 0, iPH, DateChooser1.H)
    
    ''PanelBGPath:
    ButtonFileInfo.Move(0, 0, PanelPath.H, PanelPath.H) '1:1 WxH
    PicBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, ButtonFileInfo.W, ButtonFileInfo.H)
    TextBoxPath.Move(PicBoxPath.Left + PicBoxPath.W, 0, PanelPath.W - (PicBoxPath.Left + PicBoxPath.W), PanelPath.H)
    LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), ButtonFileInfo.H)
    
    ''PanelSave:
    iW = PanelSave.W / 16
    ButtonMore.Move(0, 0, iW * 1.5, PanelSave.H)
    ButtonReset.Move(ButtonMore.Left + ButtonMore.W, 0, iW * 1.5, PanelSave.H)
    ButtonDir.Move(ButtonReset.Left + ButtonReset.W, 0, iW, PanelSave.H)
    PicBoxZoomMinus.Move(iDis + iPH + ButtonDir.Left + ButtonDir.W, 0, PanelSave.H, PanelSave.H) '+Distance
    LabelZoom.Move(iDis + PicBoxZoomMinus.Left + PicBoxZoomMinus.W, 0, PanelSave.H, PanelSave.H)
    PicBoxZoomPlus.Move(LabelZoom.Left + LabelZoom.W, 0, PanelSave.H, PanelSave.H)
    LabelCounterGallery.Move(PicBoxZoomPlus.Left + PicBoxZoomPlus.W, 0, PanelMenuEdit.W - (PicBoxZoomPlus.Left + PicBoxZoomPlus.W + (iW * 6) + PanelSave.H), PanelSave.H)
    If LabelCounterGallery.Font.TextWidth(String(12, "A")) > LabelCounterGallery.W Then 
      LabelCounterGallery.Font.Size = 10
    Else 
      LabelCounterGallery.Font.Size = 16
    Endif
    ButtonOpen.Move(iPH + LabelCounterGallery.Left + LabelCounterGallery.W, 0, PanelSave.H, PanelSave.H)
    ButtonSave.Move(iDis + ButtonOpen.Left + ButtonOpen.W, 0, iW * 2, PanelSave.H)
    ButtonClose.Move(ButtonSave.Left + ButtonSave.W, 0, PanelSave.W - (ButtonSave.Left + ButtonSave.W), PanelSave.H)
    
    iW = ButtonClose.H * 0.5 'Example: 32
    WindowStretch.Move(Me.ClientW - fW - iW, Me.ClientH - fH - iW, iW, iW)  
    
    If F_ooPicBoxesLevels Then ResizePanelLevels()
    If F_ooPicBoxesGallery Then ResizePanelGallery()
    ' If F_ooPicBoxesMuster Then ResizePanelMuster()
    FormResize2Panels()
  Endif 
  
  RaiseOrder()
  ProgressBar1.Pulse = False
  ProgressBar1.Visible = False 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub FormResize2Panels()
  
  Dim iPH, iPH2, iPHX, iBW, iBH, iDis As Integer
  Dim fPart, fText As Float
  
  ' If Me.W < 100 Then Me.W = 100
  ' If Me.H < 100 Then Me.H = 100        
                                                     'min.
  '*****************************
  iDis = 0'10 'Pixel
  iPH = 46 'ButtonK1.Height
  iPH2 = iPH / 2
  '*****************************
  
  ' PicBackground.Move(0, 0, Me.ClientWidth, Me.ClientHeight) 'Hintergrund Aluminium, Holz oder Farbe

  iBW = PanelBorder.Left 'PicBackground.Width / 100 * 3 ' Border Width (Randbreite)
  iBH = PanelBorder.Top 'PicBackground.Height / 100 * 3 'Border Height
  
  ' IconError.Move(Me.ClientW - iPH, 0, iPH, iPH)
  
  ' PanelBorder2.Move(iBW, iBH, PicBackground.W - (iBW * 2), PicBackground.H - (iBH * 2)) '□
  
  If F_bMovingON = False Then

    ColorChooser2.Move(0, 0, PanelColor.W, PanelColor.H - iPH)
    ButtonColorCancel.Move(0, PanelColor.H - iPH, PanelColor.W, iPH)
    PicturePhoto.Move(0, 0, PanelColor.W, PanelColor.H)
    PanelWebTextCode.Move(0, 0, PanelColor.W, PanelColor.H)
    
    ''Panel WebView, Text, Code, ColumnView
    WebView1.Move(0, 0, PanelWebTextCode.W, PanelWebTextCode.H - (iPH * 1.5))
    TextAreaText.Move(0, 0, WebView1.W, WebView1.H)
    TextAreaCode.Move(0, 0, WebView1.W, WebView1.H)
    ColumnView2.Move(0, 0, WebView1.W, WebView1.H)
    
    iPHX = PanelWebTextCode.W / 12
    LabelCopyExample.Move(0, WebView1.Top + WebView1.H, PanelWebTextCode.W, iPH * 0.5)
    PanelSearch.Move(0, LabelCopyExample.Top + LabelCopyExample.H, PanelWebTextCode.W, iPH)
    PicBoxSearchPaste.Move(0, 0, iPH, iPH)
    TextAreaSearch.Move(PicBoxSearchPaste.Left + PicBoxSearchPaste.W, 0, iPHX * 3, iPH)
    LabelBgSearch.Move(TextAreaSearch.Left, TextAreaSearch.Top, TextAreaSearch.W, TextAreaSearch.H)
    ButtonSearch.Move(TextAreaSearch.Left + TextAreaSearch.W, 0, iPHX * 2, iPH)
    ButtonSearchBack.Move(ButtonSearch.Left + ButtonSearch.W, 0, iPHX * 2, iPH)
    ButtonCancelWebTextCode.Move(ButtonSearchBack.Left + ButtonSearchBack.W, 0, PanelWebTextCode.W - (ButtonSearchBack.Left + ButtonSearchBack.W), iPH)
    
    ''Copy Image from Clipboard.Paste()
    PanelCopyImage.Move(0, 0, PicturePhoto.W, PicturePhoto.H)
    PicBoxCopyImage.Move(0, 0, PanelCopyImage.W, PanelCopyImage.H - (iPH * 2)) 
    ImageView1.Move(0, 0, PanelCopyImage.W, PanelCopyImage.H - (iPH * 2)) 
    LabelCopyImageInfo.Move(0, PicBoxCopyImage.Top + PicBoxCopyImage.H, PanelCopyImage.W, iPH) 
    ButtonCopyImageReload.Move(0, LabelCopyImageInfo.Top + LabelCopyImageInfo.H, iPH, iPH) 
    ButtonCancelCopyImage.Move(ButtonCopyImageReload.Left + ButtonCopyImageReload.W, LabelCopyImageInfo.Top + LabelCopyImageInfo.H, PanelCopyImage.W - (ButtonCopyImageReload.Left + ButtonCopyImageReload.W), iPH) 
    
    PicBoxPickerColor.Move(0, 0, iPH, iPH)
    PicBoxPhoto2.Move(PicBoxPickerColor.Left, PicBoxPickerColor.Top + PicBoxPickerColor.H, iPH, iPH)
    PicBoxMenu.Move(PicBoxPickerColor.Left, PicBoxPhoto2.Top + PicBoxPhoto2.H, iPH, iPH)
    
    fPart = PanelMenuColor.W / 10
    LabelZoom2.Move(PicBoxPickerColor.Left + PicBoxPickerColor.W, 0, iPH * 4, iPH)
    LabelInfo2.Move(LabelZoom2.Left + LabelZoom2.W, 0, PanelMenuColor.W - (iPH * 16), iPH)
    
    ''Panel Memory + color
    iPHX = PanelMemoryColors.H - 4
    PicBoxColorSelectBGGrid.Move(0, 0, iPH, PanelMemoryColors.H)
    PicBoxColorSelectFG.Move(PicBoxColorSelectBGGrid.Left, PicBoxColorSelectBGGrid.Top, PicBoxColorSelectBGGrid.W, PicBoxColorSelectBGGrid.H)
    PicBoxColorMemoryTop.Move(iPH, 0, iPHX * 0.5, iPHX * 0.5)
    PicBoxColorMemoryBottom.Move(iPH, PicBoxColorMemoryTop.Top + PicBoxColorMemoryTop.H, iPHX * 0.5, iPHX * 0.5)
    ScrollViewMemoryColors.Move(PicBoxColorMemoryBottom.Left + PicBoxColorMemoryBottom.W, 0, PanelMemoryColors.W - (iPHX * 8.5), PanelMemoryColors.H)
    PicBoxRefreshSum2.Move(ScrollViewMemoryColors.Left + ScrollViewMemoryColors.W, 0, iPHX, iPHX)  
    PicBoxResetMemoryColors.Move(PicBoxRefreshSum2.Left + PicBoxRefreshSum2.W, 0, iPHX, iPHX)   
    PanelColorsUndoRedo.Move(PicBoxResetMemoryColors.Left + PicBoxResetMemoryColors.W, 0, iPHX * 3, iPHX)
    PicBoxColorsUndo.Move(0, 0, iPHX, iPHX)
    ListBackupCounter2.Move(PicBoxColorsUndo.Left + PicBoxColorsUndo.W, 0, iPHX, iPHX)
    PicBoxColorsRedo.Move(ListBackupCounter2.Left + ListBackupCounter2.W, 0, iPHX, iPHX)
    PicBoxOpenColors.Move(PanelColorsUndoRedo.Left + PanelColorsUndoRedo.W, 0, iPHX, iPHX)
    PicBoxSaveColors.Move(PicBoxOpenColors.Left + PicBoxOpenColors.W, 0, iPHX, iPHX)
    ButtonCancelMemoryColors.Move(PicBoxSaveColors.Left + PicBoxSaveColors.W, 0, PanelMemoryColors.W - (PicBoxSaveColors.Left + PicBoxSaveColors.W), iPHX)
    
    ''Menu Color Background
    PanelColorBackground.Move(LabelInfo2.Left + LabelInfo2.W, 0, iPH * 3, iPH)
    PicBoxColorApply.Move(0, 0, iPH, iPH)
    PicBoxWood.Move(PicBoxColorApply.Left + PicBoxColorApply.W, 0, iPH, iPH)
    PicBoxMetal.Move(PicBoxWood.Left + PicBoxWood.W, 0, iPH, iPH)
    
    PicBoxColorApplyTop.Move(0, 0, iPH, iPH)
    PicBoxWoodTop.Move(PicBoxColorApply.Left + PicBoxColorApply.W, 0, iPH, iPH)
    PicBoxMetalTop.Move(PicBoxWood.Left + PicBoxWood.W, 0, iPH, iPH)
    
    ''Menu
    PicBoxResetstart.Move(PanelColorBackground.Left + PanelColorBackground.W, 0, iPH, iPH)
    ListAplus.Move(PicBoxResetstart.Left + PicBoxResetstart.W, 0, iPH, iPH)
    PicBoxPlus.Move(ListAplus.Left + ListAplus.W, 0, iPH, iPH)
    
    PicBoxWebColorNamesSort.Move(PicBoxPlus.Left + PicBoxPlus.W + iPH, 0, iPH, iPH)
    PicBoxColumnviewColorNamesFind.Move(PicBoxWebColorNamesSort.Left + PicBoxWebColorNamesSort.W, 0, iPH, iPH)
    PicBoxColorChooser.Move(PicBoxColumnviewColorNamesFind.Left + PicBoxColumnviewColorNamesFind.W, 0, iPH, iPH)
    PicBoxMemoryColors.Move(PicBoxColorChooser.Left + PicBoxColorChooser.W, 0, iPH, iPH)
        
    PanelPhotoUndoRedo.Move(PicBoxPhoto2.Left + PicBoxPhoto2.W, LabelZoom2.Top + LabelZoom2.H, (iPH * 4), iPH)
    ListUndo.Move(0, 0, iPH, iPH)
    ListBackupCounter1.Move(ListUndo.Left + ListUndo.W, 0, iPH * 2, iPH)
    ListRedo.Move(ListBackupCounter1.Left + ListBackupCounter1.W, 0, iPH, iPH)

    TextBoxHTML.Move(PanelPhotoUndoRedo.Left + PanelPhotoUndoRedo.W, LabelInfo2.Top + LabelInfo2.H, PanelMenuColor.W - (iPH * 17), iPH)
    WindowT5plus.Move(TextBoxHTML.Left + TextBoxHTML.W, TextBoxHTML.Top, iPH, iPH)
    TextBoxColorName.Move(WindowT5plus.Left + WindowT5plus.W, TextBoxHTML.Top, iPH * 6, iPH)
    ButtonCopy1.Move(TextBoxColorName.Left + TextBoxColorName.W, TextBoxHTML.Top, iPH, iPH)
    
    fText = TextBoxHTML.W / 2
    ButtonInsert.Move(PicBoxMenu.Left + PicBoxMenu.W, PanelPhotoUndoRedo.Top + PanelPhotoUndoRedo.H, iPH * 4, iPH) 
    TextBoxDezi.Move(ButtonInsert.Left + ButtonInsert.W, ButtonInsert.Top, fText, iPH)
    TextBoxHexa.Move(TextBoxDezi.Left + TextBoxDezi.W, ButtonInsert.Top, fText, iPH) 
    TextBoxHexaHTML.Move(TextBoxHexa.Left + TextBoxHexa.W + iPH, ButtonInsert.Top, iPH * 6, iPH)
    
    ButtonCopy2.Move(TextBoxHexaHTML.Left + TextBoxHexaHTML.W, TextBoxDezi.Top, iPH, iPH) 
    
    ButtonApply.Move(ButtonCopy1.Left + ButtonCopy1.W, ButtonCopy1.Top, iPH * 3, iPH * 2) 
    ButtonCancel.Move(ButtonApply.Left + ButtonApply.W, ButtonCopy1.Top, iPH, iPH) 
    
    ArrowR.Move(PanelBorder.Left + PanelBorder.W, PanelBorder.Top + PanelGallery.Top, iBW, PanelGallery.H)
    
  Endif 

  ResizeColorBoxes() 'A and B
  If ColumnView2.Visible = True Then ColumnView2Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtons(Optional bMore As Boolean = False)
  
  F_bMoreButtons = bMore
  ' PanelPath.Visible = bMore
  PanelMenuEdit.Visible = bMore
  PicBoxSelectLevelONoff.Visible = bMore
  PicBoxInfo.Visible = True
  PicBoxLevelMinus.Visible = bMore
  PicBoxLevelPlus.Visible = bMore
  PicBoxLevelsAll.Visible = bMore
  PicBoxRefreshSum.Visible = bMore
  LabelIconSizeWxH.Visible = bMore
  
  PicBoxParking0.Visible = bMore
  PicBoxParking1.Visible = bMore
  PicBoxParking2.Visible = bMore
  PicBoxParking3.Visible = bMore
  PicBoxPaste.Visible = bMore
  ButtonBrowser.Visible = bMore
  
  ' ButtonSchongang.Visible = bMore
  If bMore = True Then ButtonMore.Picture = PicTemplateMoreButtonsON.Picture Else ButtonMore.Picture = PicTemplateMoreButtonsOff.Picture
  ButtonMenuEditCancel.Picture = ButtonMore.Picture
  ButtonMenuEditCancel.Border = ButtonMore.Border
  
  Form_Resize()
  
Catch
  FMain.ErrorText
  
End

Public Sub DeleteCache() 
  
  Dim sDirCache, sDirPrintCache, sDirFile, sFile, sMessage As String 
  Dim iCount, iLine As Integer
  
  sDirCache = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] 
  sDirPrintCache = Settings[FMain.Name &/ "F_sDirPrintCache", FMain.F_sDirPrintCache] 
  If IsDir(sDirPrintCache) = True Then iCount = Dir(sDirPrintCache, "*", gb.File).Count 'Gambas3: "gb.File + gb.Directory for returning both."
  
  If iCount > 0 Then 
    sMessage = "<h3>" & File.Dir(sDirPrintCache) &/ "<font color=blue>" & File.Name(sDirPrintCache) & "</font></h3>"
    sMessage &= "<h3><font color=red>" & "○ " & iCount & Space(1) & ("Dateien löschen") & "?" & "</font></h3>"
    
    Select Case Message.Question(sMessage, "○ " & ("Löschen"), ("Ordner..."), ("Abbrechen"))
      Case 1'Delete all Files in Cache
        ' M01Functions.ProgramCache(False) 'Delete all Files with SubDir
        
        ''1. Delete all Files
        For Each sFile In Dir(sDirPrintCache, "*.*", gb.File)   '*.* 'Dir or RDir(Folder, Pattern*.*, gb.Directory and/or gb.File)
          iLine = iLine + 1
          If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif
          sDirFile = sDirPrintCache &/ sFile                        '* Files with and without .Extensions  file.txt, file,...
          If Exist(sDirFile) = True Then Try Kill sDirFile        'KILL, Removes a file.
        Next
        
      Case 2 'Directory
        M01Functions.FileManagerOpen(sDirCache)
      Case 3 'Cancel
        ''...
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  If F_bMusterSideChanged = True And F_ooPicBoxesMuster Then 
    If SaveMusterTxtClose() = False Then Stop Event
  Endif 
  
  TimerClock.Stop()
  
  If FMain.F_iClockMap0Stop1Count2Digital3Design4 > 0 Then FMain.F_iClockMap0Stop1Count2Digital3Design4 = 4
  
  ''Position:
  SettingsReadSave("save") 'needs component: gb.settings (*1)
  
  ' If F_picClock Then ClockPictureLastTemp(F_picClock)
  DeleteCache() 
  FormClose2()
  ''______________________________________________________________________''
  '(*1) Komponente muß zusätzlich aktiviert sein unter Komponenten 
  'Menü>Projekt>Eigenschaften>Komponenten
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
     
    Case "r" ''Read
      Me.Window.Minimized = False 
      ' Me.Window.Visible = True 'Wayland error?
      Me.Window.Maximized = False
      Me.Window.FullScreen = False
      
      iX = Settings[F_sForm &/ "Left", Me.Left]
      iY = Settings[F_sForm &/ "Top", Me.Top]
      iW = Settings[F_sForm &/ "Width", Me.W]
      iH = Settings[F_sForm &/ "Height", Me.H]
      Me.Move(iX, iY, iW, iH)
      F_iColorSelect = Settings[F_sForm &/ "F_iColorSelect", Color.SetAlpha(Color.Green, 190)] '   Color.Green
      PicBoxSelectLevelONoff.Tag = Settings[F_sForm &/ "PicBoxSelectLevelONoff.Tag", Null]
      F_bMoreButtons = Settings[F_sForm &/ "F_bMoreButtons", False]
      F_iIconSize = Settings[F_sForm &/ "F_iIconSize", 128]
      F_iZoomGallery = Settings[F_sForm &/ "F_iZoomGallery", F_iIconSize] 
      Me.F_bWhiteBorderON = Settings[F_sForm &/ "F_bWhiteBorderON", True]
      F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
      ScrollViewGallery.ScrollY = Settings[F_sForm &/ "ScrollViewGallery.ScrollY", ScrollViewGallery.ScrollY]
      F_fFontSizePlus = Settings[F_sForm &/ "F_fFontSizePlus", FMain.F_fFontSizePlus]
      F_bEditChangeON = Settings[F_sForm &/ "F_bEditChangeON", True] 'F_bEditChangeON
      F_bColorChangeON = Settings[F_sForm &/ "F_bColorChangeON", True] 'F_bColorChangeON
      F_bSelectionTopON = Settings[F_sForm &/ "F_bSelectionTopON", True]
      CheckLabelFontSize() 
      
      ''PanelBorder2
      F_iLastSide = Settings[F_sForm &/ "F_iLastSide", 1]
      F_iLastColor = Settings[F_sForm &/ "F_iLastColor", F_iColorPicker]
      F_iColorPicker = F_iLastColor
      F_bMemoryColorsPanelON = Settings[F_sForm &/ "F_bMemoryColorsPanelON", F_bMemoryColorsPanelON]
      ColorChooser2.SelectedColor = F_iLastColor
      F_iColorBoxesPointer = Settings[F_sForm &/ "F_iColorBoxesPointer", -1]
      ' SettingsColorsUserReadSave("read")
      ColumnView2.Font.Size = Settings[F_sForm &/ "ColumnView2.Font.Size", ColumnView2.Font.Size] 
      F_sBackgroundColorOrPathUndo = Settings[F_sForm &/ "F_sBackgroundColorOrPathUndo", "wood"]  'Path or Color
      F_sSideG = Settings[F_sForm &/ "F_sSideG", "gallery"]
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Me.Left
      Settings[F_sForm &/ "Top"] = Me.Top
      Settings[F_sForm &/ "Width"] = Me.Width
      Settings[F_sForm &/ "Height"] = Me.Height
      ' Settings[F_sForm &/ "F_iColorSelect"] = F_iColorSelect
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      Settings[F_sForm &/ "F_iIconSize"] = F_iIconSize
      Settings[F_sForm &/ "F_iZoomGallery"] = F_iZoomGallery 
      Settings[F_sForm &/ "F_bWhiteBorderON"] = Me.F_bWhiteBorderON
      Settings[F_sForm &/ "ScrollViewGallery.ScrollY"] = ScrollViewGallery.ScrollY
      Settings[F_sForm &/ "F_iColorPicker"] = F_iColorPicker
      Settings[F_sForm &/ "F_iColorPickerTrans"] = F_iColorPickerTrans
      Settings[F_sForm &/ "PicBoxSelectLevelONoff.Tag"] = PicBoxSelectLevelONoff.Tag
      ' If F_ooPicBoxesColorsB Then SettingsColorsUserReadSave("save")
      ' ColorsUserToBoxes()
      If F_iiIconClockColorsB Then Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
      If F_ooPicBoxesLevels Then SaveLevelTags()
      ' If F_ooPicBoxesMuster Then SaveMusterTags()
      Settings[F_sForm &/ "F_fFontSizePlus"] = 0 'Me.F_fFontSizePlus
      FMain.F_fFontSizePlus = Settings[FMain.Name &/ "F_fFontSizePlus", FMain.F_fFontSizePlus] 'Reset
      ' Settings[FMain.Name &/ "F_fFontSizePlus"] = FMain.F_fFontSizePlus
      Settings[F_sForm &/ "F_bGallerySortON"] = F_bGallerySortON
      ' If F_ssEditLevels Then Settings[F_sForm &/ "F_ssEditLevels"] = F_ssEditLevels
      ' Settings[F_sForm &/ "F_ssUndoRedoMuster"] = F_ssUndoRedoMuster
      ' Settings[F_sForm &/ "F_ssUndoRedoMusterSelection"] = F_ssUndoRedoMusterSelection
      Settings[F_sForm &/ "F_bEditChangeON"] = F_bEditChangeON
      Settings[F_sForm &/ "F_bColorChangeON"] = F_bColorChangeON
      Settings[F_sForm &/ "F_bSelectionTopON"] = F_bSelectionTopON
      
      ''PanelBorder2
      Settings[F_sForm &/ "F_iLastSide"] = F_iLastSide
      Settings[F_sForm &/ "F_iLastColor"] = ColorChooser2.SelectedColor
      Settings[F_sForm &/ "F_bMemoryColorsPanelON"] = F_bMemoryColorsPanelON
      Settings[F_sForm &/ "F_iColorBoxesPointer"] = F_iColorBoxesPointer
      Settings[F_sForm &/ "ColumnView2.Font.Size"] = ColumnView2.Font.Size
      Settings[F_sForm &/ "F_sBackgroundColorOrPathUndo"] = F_sBackgroundColorOrPathUndo 'Path or Color
      Settings[F_sForm &/ "F_sSideG"] = F_sSideG
  End Select
  
  SettingParkingReadSave(sReadSave)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingParkingReadSave(Optional sReadSave As String = "read")
  
  Dim sDir As String
  
  ' F_sForm = Me.Name 
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  
  Select Case String.LCase(String.Left(sReadSave, 1))
      
    Case "r" ''Read
      PicBoxParking0.Tag = Settings[F_sForm &/ "PicBoxParking0.Tag", Null] 'level=...
      PicBoxParking1.Tag = Settings[F_sForm &/ "PicBoxParking1.Tag", Null] 'level=...
      PicBoxParking2.Tag = Settings[F_sForm &/ "PicBoxParking2.Tag", Null] 'level=...
      PicBoxParking3.Tag = Settings[F_sForm &/ "PicBoxParking3.Tag", Null] 'level=...
      
      If Exist(sDir &/ "parking0.png") = True Then PicBoxParking0.Picture = Picture.Load(sDir &/ "parking0.png")
      If Exist(sDir &/ "parking1.png") = True Then PicBoxParking1.Picture = Picture.Load(sDir &/ "parking1.png")
      If Exist(sDir &/ "parking2.png") = True Then PicBoxParking2.Picture = Picture.Load(sDir &/ "parking2.png")
      If Exist(sDir &/ "parking3.png") = True Then PicBoxParking3.Picture = Picture.Load(sDir &/ "parking3.png")
      If Str(PicBoxParking0.Tag) Not Like "*level=*" Then PicBoxParking0.Picture = PicTemplateParking0.Picture
      If Str(PicBoxParking1.Tag) Not Like "*level=*" Then PicBoxParking1.Picture = PicTemplateParking1.Picture
      If Str(PicBoxParking2.Tag) Not Like "*level=*" Then PicBoxParking2.Picture = PicTemplateParking2.Picture
      If Str(PicBoxParking3.Tag) Not Like "*level=*" Then PicBoxParking3.Picture = PicTemplateParking3.Picture
      
    Case "s" ''Save´
      Settings[F_sForm &/ "PicBoxParking0.Tag"] = PicBoxParking0.Tag
      Settings[F_sForm &/ "PicBoxParking1.Tag"] = PicBoxParking1.Tag
      Settings[F_sForm &/ "PicBoxParking2.Tag"] = PicBoxParking2.Tag
      Settings[F_sForm &/ "PicBoxParking3.Tag"] = PicBoxParking3.Tag 
      
      If IsDir(sDir) = True Then 
        PicBoxParking0.Picture.Save(sDir &/ "parking0.png")
        PicBoxParking1.Picture.Save(sDir &/ "parking1.png")
        PicBoxParking2.Picture.Save(sDir &/ "parking2.png")
        PicBoxParking3.Picture.Save(sDir &/ "parking3.png")
      Endif 
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizePanelGallery()
  
  Dim iPicW, iPicH, iLeft, iTop, it, iNr, iLine, iColumns As Integer
  Dim ssSpli, ssGallerySort As String[]
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If F_ooPicBoxesGallery Then 
    ' ZoomMinMaxCheck()
    
    iPicW = F_iZoomGallery
    iPicH = iPicW '1:1 WxH
    iColumns = ScrollViewGallery.ClientW / iPicW
    F_bGallerySortON = Settings[F_sForm &/ "F_bGallerySortON", F_bGallerySortON]
    
    If F_bGallerySortON = True Then 
      ssGallerySort = GalleryShowCompare() 'as String[]
      ''Check:
      If Not ssGallerySort Then F_bGallerySortON = False
      If F_bGallerySortON = True Then
        iLeft = -1 'Begin with 0
        For it = 0 To F_ooPicBoxesGallery.Max
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          F_ooPicBoxesGallery[it].Visible = False
        Next
        If F_iESCpressed > 0 Then Goto JumpEnd
        
        For it = 0 To ssGallerySort.Max
          iLine = iLine + 1
          If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          ssSpli = Split(ssGallerySort[it] & "=", "=")
          iNr = CInteger(ssSpli[1])
          If iNr < F_ooPicBoxesGallery.Count Then 
            iLeft = iLeft + 1
            If iLeft > iColumns - 1 Then 
              iLeft = 0
              iTop = iTop + 1
            Endif 
            If iNr < F_ooPicBoxesGallery.Count Then 
              F_ooPicBoxesGallery[iNr].Move(iPicW * iLeft, iPicH * iTop, iPicW, iPicH) 
              F_ooPicBoxesGallery[iNr].Visible = True
            Endif 
          Endif 
        Next
        If F_iESCpressed > 0 Then Goto JumpEnd
        F_iScrollPart = iPicH * 0.6
      Endif 
    Endif 
    If F_iESCpressed > 0 Then Goto JumpEnd
    
    If F_bGallerySortON = False Then  
      iLeft = -1 'Begin with 0
      For it = 0 To F_ooPicBoxesGallery.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        iLeft = iLeft + 1
        If iLeft > iColumns - 1 Then 
          iLeft = 0
          iTop = iTop + 1
        Endif 
        F_ooPicBoxesGallery[it].Move(iPicW * iLeft, iPicH * iTop, iPicW, iPicH) 
        F_ooPicBoxesGallery[it].Visible = True
      Next
      F_iScrollPart = iPicH * 0.6
    Endif 
  Endif
  
JumpEnd:
  LabelCounterGallery.Text = GalleryCounter() 'as String  "0/0"
  ' If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomMinMaxCheck()
  
  LabelZoom.Foreground = Color.SoftBlue 
  If F_iZoomGallery < 20 Then 
    F_iZoomGallery = 20
    LabelZoom.Foreground = Color.Red
  Endif 
  If F_iZoomGallery > PanelLevels.H * 3 Then 
    F_iZoomGallery = PanelLevels.H * 3
    LabelZoom.Foreground = Color.Red
  Endif 
  LabelZoom.Text = "+" & F_iZoomGallery
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomMinusPlus(Optional iMinusPlusStandard As String = "1")
  
  Dim sMinMax, sMessage As String 
  
  If F_iESCpressed > 0 Then Return 
  LabelZoom.Background = F_iSelectGreenAlpha150
  
  Select Case iMinusPlusStandard
    Case "-", "<"
      F_iZoomGallery = F_iZoomGallery - 10
    Case "+", ">"
      F_iZoomGallery = F_iZoomGallery + 10
    Case Else '"1", "s"
      sMessage = "<h3>" & "○ " & ("Zoom Standard-Wert") & ": " & "<font color=darkgreen>" & F_iZoomStandard & "</font></h3>"
      
      Select Case Message.Question(sMessage, "○ " & ("Zoom") & " +" & F_iZoomStandard, ("Nein"), ("Abbrechen"))
        Case 1
          F_iZoomGallery = F_iZoomStandard 'Pixel
        Case 2, 3
          Goto JumpEnd
      End Select
      
  End Select 
  
  ZoomMinMaxCheck()
  
  If PanelGallery.Visible = True Then 
    ResizePanelGallery() 
    If Object.IsValid(F_oLastPicBoxObject) = True Then ScrollViewGallery.EnsureVisible(F_oLastPicBoxObject.Left, F_oLastPicBoxObject.Top, F_oLastPicBoxObject.W, F_oLastPicBoxObject.H)
  Else 
    ResizePanelMuster()
    If Object.IsValid(F_oLastPicBoxMuster) = True Then ScrollViewMuster.EnsureVisible(F_oLastPicBoxMuster.Left, F_oLastPicBoxMuster.Top, F_oLastPicBoxMuster.W, F_oLastPicBoxMuster.H)
  Endif 
  
  If F_iZoomGallery = 20 Then sMinMax = Space(1) & "<font color=blue>" & ("min") & "</font>" 
  If F_iZoomGallery = PanelLevels.H * 3 Then sMinMax = Space(1) & "<font color=blue>" & ("max") & "</font>"  
  LabelMessageText("<b>" & ("Zoom") & ": " & F_iZoomGallery & Space(1) & ("Pixel") & sMinMax & "</b>")
  
  Settings[F_sForm &/ "F_iZoomGallery"] = F_iZoomGallery
  ProgressBar1.Pulse = False
  ProgressBar1.Visible = False 
  
JumpEnd:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSchongangSwitchG()
  
  If Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4", FMain.F_iClockMap0Stop1Count2Digital3Design4] <> 0 Then 
    FMain.F_iClockMap0Stop1Count2Digital3Design4 = 0
  Else 
    FMain.F_iClockMap0Stop1Count2Digital3Design4 = 4
  Endif 
  FMain.ClockSwitchCheck()
  SchongangStatus()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SchongangStatus()
  
  Dim sPath As String 
  
  If F_iESCpressed > 0 Then Return 
  
  ''On:
  If Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4", FMain.F_iClockMap0Stop1Count2Digital3Design4] > 0 Then 
    ButtonSchongang.Text = ("Schongang=Aus")
    ButtonSchongang.Picture = PicTemplateSchongangRed.Picture 'Rot
    
    PicBoxPenguin.Picture = PicTemplatePenguinUp.Picture
    TimerClock.Start()
    F_iSecondCounter = 0 'Refresh Clock
    If Not F_picClock Then M07Paint.ClockLoadDefaultHourMinuteSecondCenter() 'alternative
  Else ''Off:
    ButtonSchongang.Text = "Schongang=An"
    ButtonSchongang.Picture = PicTemplateSchongangGreen.Picture 'Gruen
    PicBoxPenguin.Picture = PicTemplatePenguinDown.Picture
    TimerClock.Stop()
    sPath = "images/earth_128.png"
    If Exist(sPath) = True Then PicBoxClock.Picture = Picture.Load(sPath) Else PicBoxClock.Picture = New Picture(PicBoxClock.W, PicBoxClock.H, True) 'Transparent
    sPath = "terminwecker.png"
    If Exist(sPath) = True Then F_picClock = Picture.Load(sPath) Else F_picClock = FMain.Window.Icon 'Leistung schonen
    ''Start-Panel:
    ' If F_picClock Then Me.Window.Icon = F_picClock Else Me.Window.Icon = FMain.Window.Icon
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockMusterDemoG()
  
  Dim sDirFile, sDir, sFile, sDirCache, sMessage, sPathDemo, sPathDemoCopy As String
  
  sDir = "text/"
  sFile = LCase(Application.Name) & "-" & "demo_clockmuster.txt" 'Text-File
  sDirFile = sDir &/ sFile 'Relative-Path "text" &/ sFile
  sDirCache = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
  sPathDemoCopy = sDirCache &/ sFile
  If F_bMusterSideChanged = True Then SaveLevelTags() 
  
  ''Copy A > B
  If Exist(sDirFile) = True Then 
    sPathDemo = sDirFile
    If Exist(sPathDemoCopy) = True Then 'Check, Refresh?
      If Stat(sPathDemo).LastModified <> Stat(sPathDemoCopy).LastModified Then Try Copy sPathDemo To sPathDemoCopy  
    Else 
      Try Copy sPathDemo To sPathDemoCopy
    Endif 
  Endif 
  
  If Exist(sPathDemoCopy) = True Then 
    SideG("muster")
    LoadMusterFileText(sPathDemoCopy) 'Demo
  Else  
    sMessage = sDirFile & "<br> "
    If Exist(sDirFile) = True Then 
      ''Access forbidden? 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then  'Read=0 
        sMessage &= ("Kein Zugang") & "<br>"
      Endif 
    Else  
      sMessage &= ("Nicht gefunden") & "<br>"
    Endif 
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory
        M01Functions.FileManagerOpen(File.Dir(sDirFile))
      Case 2
        '...
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  
  If Key.Code = Key.Left Then ZoomMinusPlus("-")
  If Key.Code = Key.Right Then ZoomMinusPlus("+")
  If Key.Code = Key.Up Then ZoomMinusPlus("-")
  If Key.Code = Key.Down Then ZoomMinusPlus("+")
  
  If Key.Code = Key.F11 Then FullScreenONoff()
  If Key.Code = Key.Del Then CutLevelGalleryMuster()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  
  'F_bESCpressedON = Not F_bESCpressedON 'User pressed ESC-Key
  F_iESCpressed = F_iESCpressed + 1
  If F_iESCpressed > 0 Or F_bESCpressedON = True Then 
    'F_bESCpressedON 'Reset in ButtonGroupSelect()
    TimerColorPicker.Stop()
    If String.Len(FMain.F_sErrorInfos) > 300 Then TimerClock.Stop()
    If PanelColorPicker.Visible = True Then SideG("color")'SideG("gallery")
    LabelMessageText(("Abbruch mit [ESC]")) 
    Me.Window.Title = Application.Name & " - " & ("Abbruch mit [ESC]")
    Me.Maximized = False
    Me.FullScreen = False
  Else 
    LabelMessageText("")
  Endif 
  ProgressBarONoff(False)
  F_bChangeON = True 'Reset
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  ''[F11] —▶_KeyPress()
  If Me.Window.Maximized = False Then
    Me.Window.Maximized = True
  Else
    Me.Window.Maximized = False
    Me.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Add1xClockLevel(Optional hLastPic As Picture, Optional sTag As String = "")
  
  Dim W, H As Float
  Dim iCloseW, it, iLeft, iTop, iCount As Integer
  Dim hPicbox As PictureBox
  Dim hPicbox2 As PictureBox
  Dim hButton As Button
  Dim bFound As Boolean '= False
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If F_ooPicBoxesLevels Then
    ''Exist?
    If hLastPic Then 'no Picture?
      For it = 0 To F_ooPicBoxesLevels.Max
        If F_ooPicBoxesLevels[it].Tag = sTag Then 
          bFound = True 'not double
          Break 
        Endif 
      Next
      
    Else If sTag Then  'no Text?
      hLastPic = PicTemplateQuestion.Picture
      For it = 0 To F_ooPicBoxesLevels.Max
        If F_ooPicBoxesLevels[it].Tag = sTag Then 
          bFound = True 'not double
          Break 
        Endif 
      Next
    Endif
  Else
    F_ooButtonsLevels = New Object[]
    F_ooPicBoxesLevels = New Object[]
    F_ooPicBoxesGallery = New Object[]
    F_ssPicBoxGalleryTags = New String[]
  Endif 
  
  ''Add new:
  If bFound = False Then
    H = ScrollViewLevels.H - 20 '-Scrollbar
    W = H '1:1 WxH
    If Object.IsValid(F_oLastPicBoxObject) = True Then iLeft = (F_ooPicBoxesLevels.Count + 1) * W   '—▶  .Add()
    
    ''PictureBox
    hPicbox = New PictureBox(ScrollViewGallery) As "GroupGallery" '—▶Public Sub GroupLevels_MouseUp()
    iTop = 0 'hier nur eine horizontale Zeile |—▷   —▶ ResizePanelGallery()
    iCount = F_ooPicBoxesGallery.Count '+ 1    '—▶  .Add()
    
    hPicbox.Background = Color.Default
    hPicbox.Move(iLeft, iTop, W, H) ''—▶ ResizePanelGallery()
    hPicbox.Tooltip = iCount ''1,2,3,...
    hPicbox.Tag = sTag
    hPicbox.Visible = True 'True —▶ ResizePanelGallery()
    hPicbox.Border = Border.None
    hPicbox.Stretch = True
    hPicbox.Padding = 3 'grünen Rand sichtbar lassen
    hPicbox.Mouse = Mouse.Pointing  ''hand
    If hLastPic Then hPicbox.Picture = hLastPic
    
    F_ooPicBoxesGallery.Add(hPicbox)
    iCount = F_ooPicBoxesGallery.Count
    F_ooPicBoxesGallery[F_ooPicBoxesGallery.Max].Tooltip = iCount
    
    ''PictureBox Copy Levels
    hPicbox2 = New PictureBox(ScrollViewLevels) As "GroupLevels" '—▶Public Sub GroupLevels_MouseUp()
    
    hPicbox2.Background = hPicbox.Background
    hPicbox2.Move(iLeft, iTop, W, H) ''—▶ ResizePanelGallery()
    hPicbox2.Tooltip = iCount ''1,2,3,...
    hPicbox2.Tag = sTag
    hPicbox2.Visible = False 'True —▶ ResizePanelGallery()
    hPicbox2.Border = Border.Plain
    hPicbox2.Stretch = True
    hPicbox2.Padding = 3 'grünen Rand sichtbar lassen
    hPicbox2.Cursor = New Cursor(PicTemplateMove.Picture, PicTemplateMove.Picture.W / 2, PicTemplateMove.Picture.H / 2) ' hotspot x,y, center, middle ◀–▶
    hPicbox2.Mouse = Mouse.Custom  
    If hLastPic Then hPicbox2.Picture = hLastPic
    
    F_ooPicBoxesLevels.Add(hPicbox2)
    
    ''Button [x]
    hButton = New Button(ScrollViewLevels) As "GroupLevels"
    
    iCloseW = 25
    hButton.Background = hPicbox2.Background
    hButton.Move(iLeft + W - iCloseW, iTop, iCloseW, iCloseW) ''—▶ Form_Resize()
    hButton.Tooltip = ("Ebene entfernen") ''0,1,2,3,...
    hButton.Tag = sTag    '—▶  .Add()
    hButton.Visible = False
    hButton.Border = True
    hButton.Mouse = Mouse.Pointing  ''hand
    hButton.Picture = PicTemplateCloseCancel22.Picture 'Picture["icon:/22/close"]
    hButton.Raise()
    
    F_ooButtonsLevels.Add(hButton)
    
    F_oLastPicBoxObject = hPicbox
    F_ssPicBoxGalleryTags.Add(sTag)
    ' Print "Add1xClockLevel()", sTag
  Endif 
  'Note: "Loop" Add1xClockLevel() in IconListAdd()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub MoveLevelMinusPlus(Optional MinusPlus As String = "-")
  
  Dim it, iLine As Integer
  Dim oObj As Object
  
  If Object.IsValid(F_oLastPicBoxObject) = True Then oObj = F_oLastPicBoxObject
  If Object.IsValid(oObj) = True And F_ooPicBoxesLevels Then 
    For it = 0 To F_ooPicBoxesLevels.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      If oObj.Tag = F_ooPicBoxesLevels[it].Tag Then 
        Select Case MinusPlus
            
          Case "-" ', "<"
            F_ooPicBoxesLevels[it].Left = F_ooPicBoxesLevels[it].Left - F_ooPicBoxesLevels[it].W - 1 
            
          Case "+"  ', ">"
            F_ooPicBoxesLevels[it].Left = F_ooPicBoxesLevels[it].Left + F_ooPicBoxesLevels[it].W + 1 
            
        End Select  
        F_oLastPicBoxObject = oObj
        Break
      Endif   
    Next
  Endif 
  ResizePanelLevels()
  
Catch
  FMain.ErrorText
  
End

Public Sub ResizePanelLevels(Optional oObj As Object = Null)
  
  Dim it, iLine, iW, iCloseW, iFound As Integer '= 0
  Dim iiPicBoxesLeft As Integer[]
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If F_ooPicBoxesLevels And F_ooButtonsLevels Then 
    If Object.IsValid(oObj) = False And Object.IsValid(F_oLastPicBoxObject) = True Then oObj = F_oLastPicBoxObject
    iiPicBoxesLeft = New Integer[]
    For it = 0 To F_ooPicBoxesLevels.Max
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      
      iFound = iiPicBoxesLeft.Find(F_ooPicBoxesLevels[it].Left)
      If iFound > -1 Then F_ooPicBoxesLevels[it].Left = F_ooPicBoxesLevels[it].Left + 1 'not double, not about it
      If F_ooPicBoxesLevels[it].Visible = True Then 
        iiPicBoxesLeft.Add(F_ooPicBoxesLevels[it].Left) 
      Else 
        F_ooPicBoxesLevels[it].Left = -ScrollViewLevels.W  'park outside
      Endif 
    Next
    If F_iESCpressed > 0 Then Goto JumpEnd
    
    If iiPicBoxesLeft Then 
      iiPicBoxesLeft = iiPicBoxesLeft.Sort()
      If F_ooPicBoxesLevels.Count > 0 Then iW = F_ooPicBoxesLevels[0].W
      If F_ooButtonsLevels.Count > 0 Then iCloseW = F_ooButtonsLevels[0].W Else iCloseW = 25
      ' F_ooPicBoxesLevelsOnlyVisible = New Object[]
      For it = 0 To F_ooPicBoxesLevels.Max
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif
        
        iFound = iiPicBoxesLeft.Find(F_ooPicBoxesLevels[it].Left) '-1 not found
        If iFound > -1 Then 
          F_ooPicBoxesLevels[it].Left = iFound * iW
          F_ooPicBoxesLevels[it].H = iW
          F_ooButtonsLevels[it].Left = F_ooPicBoxesLevels[it].Left + F_ooPicBoxesLevels[it].W - iCloseW
          F_ooPicBoxesLevels[it].Raise()
          F_ooButtonsLevels[it].Raise() 'Button [x]
          ' F_ooPicBoxesLevelsOnlyVisible.Add(F_ooPicBoxesLevels[it])
        Endif 
      Next
    Endif 
  Endif 
JumpEnd:
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelCounterText(Optional iVisibleCount As Integer = 0, Optional iLevelsCount As Integer = 0)
  
  LabelCounter.Text = Str(iVisibleCount) & Space(1) & ("von") & Space(1) & Str(iLevelsCount)
  LabelCounter.Visible = True 
  LabelCounter.Raise() '▲Top▲
  
Catch
  FMain.ErrorText
  
End

Public Sub RefreshSelectColorGroupLevelsGallery(Optional oObj As Object)
  
  Dim it As Integer
  
  If F_iESCpressed > 0 Then Return 
  
  If Object.IsValid(oObj) = False Then oObj = F_oLastPicBoxObject
  
  If Object.IsValid(oObj) = True Then 
    If oObj.Background <> F_iColorSelect Then 
      oObj.Background = F_iColorSelect 
    Else 
      oObj.Background = Color.Default
    Endif
    
    ''Levels
    If F_ooPicBoxesLevels And F_ooPicBoxesGallery And F_ooButtonsLevels Then 
      it = F_ooPicBoxesLevels.Find(oObj) '-1 not found
      If it = -1 Then it = F_ooPicBoxesGallery.Find(oObj)
      If it > -1 Then 
        If oObj.Tag = F_ooPicBoxesGallery[it].Tag Then 
          F_ooPicBoxesGallery[it].Background = oObj.Background
          F_ooPicBoxesGallery[it].Border = Border.Plain 'checked, it was already been clicked 
          F_ooPicBoxesGallery[it].Visible = True
        Endif
        If oObj.Tag = F_ooPicBoxesLevels[it].Tag Then 
          If F_ooPicBoxesLevels[it].Visible = False Then F_ooPicBoxesLevels[it].Left = F_ooPicBoxesLevels.Count * oObj.W 
          F_ooPicBoxesLevels[it].Background = oObj.Background
          F_ooPicBoxesLevels[it].Raise()
          F_ooPicBoxesLevels[it].Visible = True
          'Button [x]:
          F_ooButtonsLevels[it].Visible = True
          F_ooButtonsLevels[it].Raise() 
        Endif
      Endif 
    Endif 
    ResizePanelLevels(oObj)
    PicBoxSelectLevelONoffRefresh(oObj)
    ' SumPaintClockLevels() '—▶ extra
    
    ''Show action
    F_iLastPicBoxColor = oObj.Background
    If oObj.Background = Color.Default Then oObj.Background = Color.Red Else oObj.Background = F_iColorSelect
    If F_iOnly1x > 0 Then Wait 0.3 'Pause, show change, realize
    oObj.Background = F_iLastPicBoxColor
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub SynchronizeLevelsToGallery()
  
  Dim it, iLast As Integer
  
  If F_iESCpressed > 0 Then Return 
  
  ''Reset:
  If F_ooPicBoxesGallery Then 
    For it = 0 To F_ooPicBoxesGallery.Max
      F_ooPicBoxesGallery[it].Background = Color.Default 'Reset
      F_ooPicBoxesGallery[it].Border = Border.None 
    Next
  Endif 
  
  ''Synchronize Levels —▶ Gallery
  If F_ooPicBoxesLevels And F_ooButtonsLevels And F_ooPicBoxesGallery Then 
    For it = 0 To F_ooPicBoxesLevels.Max
      If F_ooPicBoxesLevels[it].Visible = True Then
        F_ooPicBoxesGallery[it].Background = F_ooPicBoxesLevels[it].Background
        F_ooPicBoxesGallery[it].Border = Border.Plain 
        'Buttons [x]:
        F_ooButtonsLevels[it].Visible = F_ooPicBoxesLevels[it].Visible
        F_ooButtonsLevels[it].Raise() '▲top▲
        iLast = it
      Endif 
    Next
    ScrollViewGallery.EnsureVisible(F_ooPicBoxesGallery[iLast].Left, F_ooPicBoxesGallery[iLast].Top, F_ooPicBoxesGallery[iLast].W, F_ooPicBoxesGallery[iLast].H)
  Endif 
  LabelCounterGallery.Text = GalleryCounter() 'as String  "0/0"
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupLevels_KeyPress()
  
  F_oLastPicBoxObject = Last
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupLevels_Enter()
  
  Dim bMoveable As Boolean
  
  If F_iESCpressed > 0 Then Return 
  
  If Object.Type(Last) = "Button" Then 
    Last.Background = Color.Red
  Endif 
  
  If Object.Type(Last) = "PictureBox" Then 
    PicBoxClock.Border = Border.Plain
    bMoveable = isMoveableParts(Last) 'as Boolean, True or False
    If Last.Background <> F_iColorSelect Then 
      If bMoveable = True Then Last.Background = F_iSelectYellow100
    Endif 
    LabelMessageCheck(Last)
    F_oCursorFillLast = Last
  Endif 
  
  If F_bColorPickerAreaON = True Then  
    F_oCursorFillLast = Last
    TimerColorPicker.Start()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupLevels_Leave()
  
  If F_iESCpressed > 0 Then Return 
  
  If Object.Type(Last) = "Button" Then 
    Last.Background = Color.Default 
  Endif 
  
  If Object.Type(Last) = "PictureBox" Then 
    PicBoxClock.Border = Border.None
    If Last.Background <> F_iColorSelect Then Last.Background = Color.Default
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub HideLevel(Optional oObj As Object = Null)
  
  Dim it As Integer
  
  If F_iESCpressed > 0 Then Return 
  
  If Object.IsValid(oObj) = True And F_ooButtonsLevels Then 
    it = F_ooButtonsLevels.Find(oObj)
    If it = -1 Then it = F_ooPicBoxesLevels.Find(oObj)
    If it > -1 Then 
      F_ooButtonsLevels[it].Visible = False
      F_ooButtonsLevels[it].Background = Color.Default
      F_ooPicBoxesLevels[it].Visible = False
      F_ooPicBoxesLevels[it].Background = Color.Default
      F_ooPicBoxesGallery[it].Background = Color.Default
    Endif 
  Endif 
  
  ResizePanelLevels()
  SumPaintClockLevels()
  
Catch
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub GroupLevels_MouseDown()
  
  Dim oObj As Object
  Dim iFound As Integer
  
  F_iSelectButton0Levels1Gallery2Muster3 = 1
  F_oLastPicBoxObject = Last
  F_bMovingON = True 
  F_iX1 = Mouse.X
  F_iY1 = Mouse.Y
  
  If Mouse.Left Then 
    If Object.Type(Last) = "PictureBox" Then
      If F_bColorPickerAreaON = True Then 
        ColorPickerMousedownSelected()
      Else
        F_iLastPicBoxLeft = Last.Left
        F_iLastPicBoxColor = Last.Background
        Last.Background = Color.Red
        If F_ooPicBoxesLevels Then iFound = F_ooPicBoxesLevels.Find(Last)
        If iFound > -1 And F_ooPicBoxesGallery Then oObj = F_ooPicBoxesGallery[iFound]
        If Object.IsValid(oObj) = True Then ScrollViewGallery.EnsureVisible(oObj.Left, oObj.Top, oObj.W, oObj.H)
      Endif 
    Endif 
    Last.Raise()
    LabelMessageText(Last.Tag) 
    CheckMoveAble()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuFile_Show()
  
  CheckMenu1()
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupLevels_MouseMove()
  
  If F_bMovingON = True Then 
    If Object.Type(Last) = "PictureBox" Then Last.Left = Last.Left + Mouse.X - F_iX1
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupLevels_MouseUp()
  
  If Mouse.Left Then 
    Select Case Object.Type(Last) 
        
      Case "Button" 
        HideLevel(Last)
        UndoRedoLevelSave()
        
      Case "PictureBox" 
        If F_bMovingON = True Then 
          Last.Background = F_iLastPicBoxColor
          If F_iLastPicBoxLeft <> Last.Left Then 
            If Last.Background <> F_iColorSelect Then Last.Background = F_iColorSelect Else Last.Background = Color.Default
          Endif
          RefreshSelectColorGroupLevelsGallery(Last)
          ResizePanelLevels()
          SumPaintClockLevels()
          UndoRedoLevelSave()
        Endif 
    End Select
  Endif 
  
  F_oLastPicBoxObject = Last
  PicBoxSelectLevelONoff.Tag = Last.Tag
  PicBoxSelectLevelONoff.ToolTip = Last.ToolTip
  PicBoxSelectLevelONoff.Picture = Last.Picture 
  
  If Mouse.Right Then 
    CheckMenu1()
    MenuEdit.Popup()
  Endif 
  
  If Mouse.Middle Then 
    If PanelGallery.Visible = True Then ScrollViewEnsureVisibleG()
    ' If PanelMuster.Visible = True Then MusterFindLevel()
  Endif 
  
  F_bMovingON = False
  LabelCounterGallery.Text = GalleryCounter() 'as String  "0/0"
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxSelectLevelONoffRefresh(Optional oObj As Object)
  
  If Object.IsValid(oObj) = True Then  
    PicBoxSelectLevelONoff.Picture = oObj.Picture
    PicBoxSelectLevelONoff.Tooltip = oObj.Tooltip
    PicBoxSelectLevelONoff.Padding = 3
    PicBoxSelectLevelONoff.Background = oObj.Background 
    PicBoxSelectLevelONoff.Tag = oObj.Tag 'PicBox not in Group, no overwrite
    '.Tag —▶ ButtonGroupSelect(Last.Tag)
    PicBoxLevelsQuestionShowGalleryPart.Picture = oObj.Picture 
    PicBoxLevelsQuestionShowGalleryPart.Tooltip = oObj.ToolTip
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuIconSize_Show()
  
  CheckMenu1()
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuEdit_Show()
  
  CheckMenu1()
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuSide_Show()
  
  CheckMenu2Panels()
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuMusterEdit_Show()
  
  MenuMuster2.Checked = PanelMuster.Visible 
  MenuMusterSelectionTop.Checked = F_bSelectionTopON
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckMenu1()
  
  Dim iSize As Integer
  Dim bON As Boolean
  Dim sTag, sToolTip, sPath As String 
  Dim oObj As Object
  Dim hPic As Picture
  
  If F_iESCpressed > 0 Then Return 
  
  ' If Not F_oLastPicBoxObject And PicBoxSelectLevelONoff.Picture Then F_oLastPicBoxObject = PicBoxSelectLevelONoff
  
  iSize = F_iIconSize
  If iSize = 0 Then 
    F_iIconSize = CInteger(Settings[F_sForm &/ "F_iIconSize", 128])
    iSize = F_iIconSize
  Endif 
  MenuIconSize.Text = ("Icon") & "=" & Str(F_iIconSize) & "px"
  MenuCopy1.Text = ("Bild kopieren") & Space(1) & Str(iSize) & "x" & Str(iSize) & Space(1) & ("px (Pixel)")
  MenuCopy2.Text = ("Bild kopieren") & Space(1) & "64" & "x" & "64" & Space(1) & ("px (Pixel)")
  MenuCopy3.Text = ("Bild kopieren") & Space(1) & "32" & "x" & "32" & Space(1) & ("px (Pixel)")
  
  MenuSize0.Text = Str(iSize) & "x" & Str(iSize) & Space(1) & ("Pixel") & Space(1) & ("akutell")
  MenuSize0.Tag = Str(iSize)
  MenuSize5.Text = Str(Screen.W) & "x" & Str(Screen.W) & Space(1) & ("Pixel") & Space(1) & ("(langsamer)")
  MenuSize5.Tag = Screen.W
  
  If MenuSize0.Tag = Str(iSize) Then MenuSize0.Checked = True Else MenuSize0.Checked = False 
  If MenuSize1.Tag = Str(iSize) Then MenuSize1.Checked = True Else MenuSize1.Checked = False 
  If MenuSize2.Tag = Str(iSize) Then MenuSize2.Checked = True Else MenuSize2.Checked = False 
  If MenuSize3.Tag = Str(iSize) Then MenuSize3.Checked = True Else MenuSize3.Checked = False 
  If MenuSize4.Tag = Str(iSize) Then MenuSize4.Checked = True Else MenuSize4.Checked = False 
  If MenuSize5.Tag = Str(iSize) Then MenuSize5.Checked = True Else MenuSize5.Checked = False 
  
  If PanelGallery.Visible = True Or PanelColorSave1.Visible = True Then 
    oObj = F_oLastPicBoxObject
  Else If PanelGallery.Visible = True Then 
    oObj = F_oLastPicBoxMuster
  Endif  
  If Object.IsValid(oObj) = False Then oObj = PicBoxSelectLevelONoff
  
  If Object.IsValid(oObj) = True Then 
    If Object.Type(oObj) = "PictureBox" And oObj.Picture Then  
      hPic = oObj.Picture
      sTag = oObj.Tag
      sToolTip = oObj.ToolTip
      PicBoxSelectLevelONoff.Picture = oObj.Picture 
      PicBoxSelectLevelONoff.Tooltip = oObj.ToolTip
      PicBoxSelectLevelONoff.Tag = oObj.Tag
      MenuCopy1.Picture = oObj.Picture.Image.Stretch(32, 32).Picture
      bON = True
    Else 
      MenuCopy1.Picture = PicTemplateCopyImage.Picture
      bON = False 'no picture
    Endif 
  Else 
    MenuCopy1.Picture = PicTemplateCopyImage.Picture
    bON = False 'no picture
  Endif
  
  MenuCopy1.Enabled = bON 
  MenuCopy2.Enabled = bON 
  MenuCopy3.Enabled = bON 
  MenuSave1.Enabled = bON 
  
  If PanelMuster.Visible = False Then CheckMoveAble()
  
  ' CheckButtonEdit()
  If PicBoxClock.Picture Then MenuClockPictureExtern.Picture = PicBoxClock.Picture.Image.Stretch(32, 32).Picture Else MenuClockPictureExtern.Picture = MenuClockPartExtern.Picture
  
  MenuMusterSelectAll.Enabled = PanelMuster.Visible 'True or False
  MenuMusterUnselectAll.Enabled = MenuMusterSelectAll.Enabled 
  
  If Object.IsValid(F_oLastPicBoxObject) = True Then
    If Object.Type(F_oLastPicBoxObject) = "PictureBox" Then sPath = F_oLastPicBoxObject.Tag
    If Exist(sPath) = True Then bON = True Else bON = False 
    MenuCutGalleryPic.Enabled = bON 
  Endif 
  
  If PanelGallery.Visible = True And Object.IsValid(F_oLastPicBoxObject) = True Then
    MenuClockPartExtern.Enabled = True
  Else If PanelMuster.Visible = True And Object.IsValid(F_oLastPicBoxMuster) = True Then
    MenuClockPartExtern.Enabled = True
  Else 
    MenuClockPartExtern.Enabled = False 'Uhren-Teil
  Endif 
  
  ' MenuPicOriginal.Enabled = FileTempExist(F_oLastPicBoxObject) 'as Boolean, Exist=True or False
  If F_bMoreButtons = True Then 
    MenuMoreButtons.Checked = True '+
    MenuLessButtons.Checked = False '-
  Else 
    MenuMoreButtons.Checked = False
    MenuLessButtons.Checked = True '-
  Endif 
  
  If PicBoxClock.Picture Then 
    MenuCopyClockImage.Enabled = True 
  Else 
    MenuCopyClockImage.Enabled = False 
  Endif
  If PicBoxSelectLevelONoff.Picture Then 
    MenuCopyImage.Enabled = True 
  Else 
    MenuCopyImage.Enabled = False 
  Endif
  
  MenuOpenRecentG()
  MenuSaveRecentG()
  CheckMenu2Panels()
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckMenu2Panels()
  
  MenuGallery.Checked = PanelGallery.Visible
  MenuMuster.Checked = PanelMuster.Visible  '>Side
  MenuMuster2.Checked = PanelMuster.Visible 
  MenuColor.Checked = PanelColorSave1.Visible
  MenuPanelEdit.Checked = PanelMenuEdit.Visible
  MenuDateTime.Checked = PanelDateTime.Visible
  
  MenuPanelEdit.Picture = ButtonMore.Picture
  MenuPanelEdit.Checked = F_bMoreButtons
  
Catch
  FMain.ErrorText
  
End

Public Sub CheckMoveAble()
  
  Dim bON, bVisible As Boolean 
  
  If Object.IsValid(F_oLastPicBoxObject) = True Then
    If isMoveableParts(F_oLastPicBoxObject) = True Then bON = False Else bON = True 
    bVisible = True
    PicBoxMirrorLeftRight.Visible = bVisible
    PicBoxMirrorTopBottom.Visible = bVisible
    PicBoxRotateLeft.Visible = bVisible
    PicBoxRotateRight.Visible = bVisible
    PicBoxGrayscale.Visible = bVisible
    
    PicBoxScaleMinus.Visible = bVisible
    PicBoxScalePlus.Visible = bVisible
    PicBoxMoveLeft.Visible = bVisible
    PicBoxMoveRight.Visible = bVisible
    PicBoxMoveUp.Visible = bVisible
    PicBoxMoveDown.Visible = bVisible
    
    MenuMirrorLeftRight.Enabled = bVisible
    MenuMirrorTopBottom.Enabled = bVisible
    MenuRotateLeft.Enabled = bVisible
    MenuRotateRight.Enabled = bVisible
    
    MenuScaleMinus.Enabled = bVisible
    MenuScalePlus.Enabled = bVisible
    MenuMoveLeft.Enabled = bVisible
    MenuMoveRight.Enabled = bVisible
    MenuMoveUp.Enabled = bVisible
    MenuMoveDown.Enabled = bVisible
    
    If bON = False Then '& ("Bearbeitung nur für unbewegliche Teile")
      LabelInfo.Text = "<b>" & ("Nr") & "." & F_oLastPicBoxObject.ToolTip & "</b>" & Space(1) & "<font color=white><b>" & "▪●▪" & Space(1) & ("Bewegliches Teil") & ". " & "</b></font>" & Space(1) & F_oLastPicBoxObject.Tag
      LabelInfo.Visible = True 
    Else 
      LabelInfo.Visible = False
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupGallery_Enter()
  
  If Last.Background <> F_iColorSelect Then 
    If isMoveableParts(Last) = True Then 
      Last.Background = F_iSelectYellow100 
    Else 
      Last.Background = F_iSelectGreenAlpha150
    Endif 
    If Exist(Last.Tag) = True Then Last.Background = F_iSelectBlue150
  Endif 
  
  LabelMessageCheck(Last)
    
  ''ColorPicker 'Change ●
  ' F_iCursorFillLevel0Gallery1Muster2 = 1
  If F_bColorPickerAreaON = True Then  
    F_oCursorFillLast = Last
    TimerColorPicker.Start()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CursorFillObject()
  Dim pointXY As Point
  Dim Img As Image
  
  ' If PanelMemoryColors Or PanelMenuColor Then 
  If PanelGallery Or PanelMuster Then 
    If F_oCursorFillLast Then 
      PicBoxMenuColorPicker.Background = Color.Green
      pointXY = Point(Mouse.ScreenX - F_oCursorFillLast.ScreenX, Mouse.ScreenY - F_oCursorFillLast.ScreenY)
      Img = F_oCursorFillLast.Picture.Image.Stretch(F_oCursorFillLast.W, F_oCursorFillLast.H)
      F_iColorPicker = Img[pointXY.X, pointXY.Y]
      
      ''ColorPicker 'Change ●
      F_oCursorFillLast.Cursor = New Cursor(PicBoxPickerColor.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 'as Picture, x, y
      F_oCursorFillLast.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
      
      F_picScreen = Img.Picture
      F_imgScreen = Img
      PicBoxColorSelectFG.Background = F_iColorPicker
      ColorChooser2.SelectedColor = F_iColorPicker
      ' If String.LCase(Desktop.Platform) = "wayland" Then 
      '   F_fX1 = Mouse.ScreenX - PanelBorder2.Left 
      '   F_fY1 = Mouse.ScreenY - PanelBorder2.Top ' Desktop.Y '= Screens[0].AvailableY = 0
      ' Else 'If String.LCase(Desktop.Platform) = "x11" Then 
      '   F_fX1 = Mouse.ScreenX - PanelBorder2.ScreenX
      '   F_fY1 = Mouse.ScreenY - PanelBorder2.ScreenY ' Desktop.Y '= Screens[0].AvailableY = 0
      ' Endif 
      
      ''Pick Color Pixel-Point:
      ' F_iColorPicker = F_imgScreen[F_fX1, F_fY1] 'as Integer
  
      ZoomLupeG()
  
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelMessageCheck(Optional oObj As Object = Null)
  
  Dim sText As String 
  
  If F_iESCpressed > 0 Then Return 
  
  If Object.IsValid(oObj) = True Then 
    If Object.Type(oObj) = "PictureBox" Then 
      
      ''Check:
      If PanelGallery.Visible = True Then
        If String.InStr(oObj.Tag, "cutter") > 0 Then 
          sText = "<b>" & ("Nr") & "." & oObj.ToolTip & "</b>" & Space(1) & "<font color=gray><b>" & "▪○▪" & Space(1) & ("Schneidende Schablone") & "</b></font>" & Space(1) & oObj.Tag
        Else If isMoveableParts(oObj) = True 'as Boolean, True or False
          sText = "<b>" & ("Nr") & "." & oObj.ToolTip & "</b>" & Space(1) & "<font color=blue><b>" & "▪●▪" & Space(1) & ("Bewegliches Teil") & "</b></font>" & Space(1) & oObj.Tag
          sText = Replace(sText, F_sMoveAblePartLast, "<font color=blue>" & F_sMoveAblePartLast & "</font>")
        Else 
          sText = "<b>" & ("Nr") & "." & oObj.ToolTip & "</b>" & Space(1) & oObj.Tag
        Endif 
      Endif 
      
      ''Check:
      If PanelMuster.Visible = True Then
        sText = "<b>" & ("Nr") & "." & oObj.ToolTip & "</b>" & Space(1) & oObj.Tag
      Endif 
      
      '**************************
      LabelMessageText(sText)
      '**************************
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupGallery_Leave()
  
  If Last.Background <> F_iColorSelect Then Last.Background = Color.Default
  
Catch
  FMain.ErrorText
  
End

Public Function isMoveableParts(Optional oObj As Object = Null) As Boolean
  
  Dim sPart, sTag As String 
  Dim bFound As Boolean
  
  If F_iESCpressed > 0 Then Return 'end here
  'F_sMovableParts = "-timehh-timemm-timess-..." 'see FormStart()
  If Object.IsValid(oObj) = False And Object.IsValid(F_oLastPicBoxObject) = True Then oObj = F_oLastPicBoxObject
  If Object.IsValid(oObj) = True Then 
    ' Print oObj.Tag
    If Object.Type(oObj) = "PictureBox" And oObj.Tag Then sTag = oObj.Tag
    If sTag And F_sMovableParts Then 
      For Each sPart In Split(F_sMovableParts & "-", "-")
        If sPart Then 
          If String.InStr(sTag, sPart) > 0 Then 
            bFound = True 
            F_sMoveAblePartLast = sPart 
            Break  
          Endif 
        Endif
      Next
    Endif
  Endif
  Return bFound
  
Catch
  FMain.ErrorText
  
End

Public Sub ScrollViewGallery_Scroll()
  
  If PanelColorPicker.Visible = True Then ScreenshotPhotoStop()
  
Catch
  FMain.ErrorText
  
End

Public Sub ScrollViewMuster_Scroll()
  
  If PanelColorPicker.Visible = True Then ScreenshotPhotoStop()
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupGallery_MouseDown()
  
  Dim it As Integer

  F_iSelectButton0Levels1Gallery2Muster3 = 2
  F_oLastPicBoxObject = Last
  
  If F_bColorPickerAreaON = True Then
    F_bColorPickerAreaON = False
    PicBoxMenuColorPicker.Background = Color.Default
    PicBoxPickerColor.Background = Color.Default
    PicBoxPickerColor2.Background = PicBoxPickerColor.Background
    PicBoxPickerColor3.Background = PicBoxPickerColor.Background
    PicBoxPickerTransparent.Background = Color.Default
    PicBoxPickerTransparent2.Background = PicBoxPickerTransparent.Background
    TimerColorPicker.Stop()
    ColorPickerCursorAllReset()
    SideG("color")
    CheckFontColor()

  Else 
    If Mouse.Left Then 
      If Last.Tag Like "*-time*" Then ''Example: "...-timehh-hours-..."
        it = F_ooPicBoxesGallery.Find(Last) '-1 not found
        If it > -1 Then
          If F_ooPicBoxesLevels.Exist(F_ooPicBoxesLevels[it]) = True Then 
            F_ooPicBoxesLevels[it].Left = (Last.W * F_ooPicBoxesLevels.Max) + 1
            F_ooPicBoxesLevels[it].Visible = True 
            ResizePanelLevels()
          Endif 
        Endif 
      Endif 
      F_bChangeON = True 'Reset
      RefreshSelectColorGroupLevelsGallery(Last)
      ResizePanelLevels()
      SumPaintClockLevels()
      UndoRedoLevelSave()
      LabelMessageText(Last.Tag)
      CheckMoveAble()
    Endif 
  Endif 
  
  If Mouse.Right Then 
    F_oLastPicBoxObject = Last
    CheckMenu1()
    CheckMoveAble()
    MenuEdit.Popup()
  Endif
  
  If Mouse.Middle Then ScrollViewEnsureVisibleG(Last.Tag)
  
  LabelCounterGallery.Text = GalleryCounter() 'as String  "0/0"
  
Catch
  FMain.ErrorText
  
End

Public Sub ColorPickerMousedownSelected()
  
  If F_bColorPickerAreaON = True Then 
    F_bColorPickerAreaON = False
    PicBoxMenuColorPicker.Background = Color.Default
    PicBoxPickerColor.Background = Color.Default
    PicBoxPickerColor2.Background = PicBoxPickerColor.Background
    PicBoxPickerColor3.Background = PicBoxPickerColor.Background
    PicBoxPickerTransparent.Background = Color.Default
    PicBoxPickerTransparent2.Background = PicBoxPickerTransparent.Background
    TimerColorPicker.Stop()
    ColorPickerCursorAllReset()
    SideG("color")
    CheckFontColor()
  Endif
  
  Catch
  FMain.ErrorText
  
End

Public Sub GroupGallery_MouseUp()
  
  F_oLastPicBoxObject = Last
  PicBoxSelectLevelONoff.Tag = Last.Tag 
  PicBoxSelectLevelONoff.Picture = Last.Picture 
  
Catch
  FMain.ErrorText
  
End

Public Sub CreateColorBoxes() 'unused?
  
  Dim hLabel As Label
  Dim hPicBox As PictureBox
  Dim it, iW, iH, iColorsCount As Integer
  
  If Not F_iiIconClockColorsB Then SettingsColorsUserReadSave("read")  'M05.ColorClockGetSettings()
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  ' F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
  
  ' M05.ColorClockGetSettings()
  
  ''Colors A: Default □□□□□□□□□□
  PanelColorBoxesA.Children.Clear()
  F_ooPicBoxesColorsA = New Object[]
  iColorsCount = F_iColorsCount '0,1,2... n-1    '0...10=11
  
  iW = PanelColorBoxesA.W / iColorsCount 
  iH = PanelColorBoxesA.H 
  
  F_sColorChangeLineStandard = "colorchange="
  
  For it = 0 To iColorsCount - 1
    hPicBox = New PictureBox(PanelColorBoxesA) As "GroupColorBoxesA"
    If it < F_iiIconClockColorsA.Count Then  
      hPicBox.Background = F_iiIconClockColorsA[it]
      F_sColorChangeLineStandard &= F_iiIconClockColorsA[it] & "="
    Endif 
    hPicBox.Tooltip = Str(it + 1) & Space(1) & ("Standard-Farbe Uhr") 
    hPicBox.Tag = it '=Position
    hPicBox.Move(iW * it, 0, iW, iH)
    hPicBox.Mouse = Mouse.Cross
    hPicBox.Visible = True 
    hPicBox.Border = Border.Plain
    
    F_ooPicBoxesColorsA.Add(hPicBox)
  Next
  
  ''Colors B: User  □□□□□□□□□□
  PanelColorBoxesB.Children.Clear()
  F_ooPicBoxesColorsB = New Object[]
  
  iW = PanelColorBoxesB.W / iColorsCount 
  iH = PanelColorBoxesB.H 
  
  For it = 0 To iColorsCount - 1
    hLabel = New Label(PanelColorBoxesB) As "GroupColorBoxesB"
    
    If it < F_iiIconClockColorsB.Count Then  
      hLabel.Background = F_iiIconClockColorsB[it]
    Endif 
    
    hLabel.Tooltip = Str(it + 1) & Space(1) & ("Farb-Palette Uhr") 
    hLabel.Tag = it '=Position
    hLabel.Move(iW * it, 0, iW, iH)
    ' hLabel.Cursor = New Cursor(PicBoxPicker2.Picture, 0, 0) 
    ' hLabel.Mouse = Mouse.Custom
    hLabel.Alignment = Align.Center
    hLabel.Mouse = Mouse.Pointing
    hLabel.Visible = True 
    hLabel.Font.Bold = False
    hLabel.Text = it + 1
    hLabel.Border = Border.None
    
    If M01Functions.ColorInfoRGB(hLabel.Background, "L") < 150 Then hLabel.Foreground = Color.White Else hLabel.Foreground = Color.Black
    
    F_ooPicBoxesColorsB.Add(hLabel)  
  Next
  
  ResizeColorBoxes()
  
Catch 
  FMain.ErrorText
  
End

' Public Sub GroupColorBoxesA_Enter()
'   
'   LabelMessageText(Last.ToolTip)
'   
' Catch 
'   FMain.ErrorText
'   
' End
' 
' Public Sub GroupColorBoxesA_MouseDown()
'   
'   F_iColorBoxesPointer = Last.Tag '0 To F_iiIconClockColorsB.Max
'   Print F_iColorBoxesPointer; Last.Tag
'   If F_ooPicBoxesColorsA Then F_iColorPicker = F_ooPicBoxesColorsA[F_iColorBoxesPointer].Background
'   LabelColorSelected.Background = F_iColorPicker
'   F_bChangeON = False
'   ColorChooser1.Value = F_iColorPicker
'   PanelColorChooser.Visible = True 
'   F_bChangeON = True
'   CheckFontColor()'B
'   
' Catch 
'   FMain.ErrorText
'   
' End

' Public Sub GroupColorBoxesB_Enter()
'   
'   LabelMessageText(Last.ToolTip)
'   
' Catch 
'   FMain.ErrorText
'   
' End
' 
' Public Sub GroupColorBoxesB_MouseDown()
'   
'   F_iColorBoxesPointer = Last.Tag '0 To F_iiIconClockColorsB.Max
'   
'   If Mouse.Left = True Then 
'     ' If ButtonColorPotNumber.Mouse = Mouse.Custom Then 
'       If F_iColor0Picker1Transparent2 = 0 Then 
'         Last.Background = ColorChooser1.SelectedColor
'       Else If F_iColor0Picker1Transparent2 = 1 Then 
'         Last.Background = F_iColorPicker '◀
'       Else If F_iColor0Picker1Transparent2 = 2 Then  
'         Last.Background = Color.SetAlpha(F_iColorPicker, 255)
'         
'       Endif 
'     ' Else  
'     '   If F_ooPicBoxesColorsB Then 
'     '     If F_iColorBoxesPointer < F_ooPicBoxesColorsB.Count Then F_iColorPicker = F_ooPicBoxesColorsB[F_iColorBoxesPointer].Background
'     '   Endif 
'     ' Endif 
'     
'     ' LabelColorSelected.Background = Last.Background
'     F_bChangeON = False
'     ColorChooser1.Value = F_iColorPicker
'     ' PanelColorChooser.Visible = True 
'     ' ButtonColorPotNumber.Text = ("Farbe") & Space(1) & Str(F_iColorBoxesPointer + 1) & ">"
'     F_bChangeON = True
'     CheckFontColor()
'   Endif 
'   
'   If Mouse.Right = True Then 
'     If PanelColorChooser.Visible = False Then 
'       SideG("colorchooser")
'     Else 
'       SideG("color")
'     Endif 
'   Endif 
'   
' Catch 
'   FMain.ErrorText
'   
' End

' Public Sub ResizeColorBoxes()
'   
'   Dim it, iH As Integer
'   Dim iW As Float 
'   
'   'Alternative: F_ooPicBoxesColorsA[it] = PanelColorBoxesA.Children[it]
'   
'   If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
'   If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = M05.ColorPaletteStandardii() 'as Integer[]
'   If F_iColorBoxesPointer < 0 Then F_iColorBoxesPointer = Settings[F_sForm &/ "F_iColorBoxesPointer", 0]
'   ' If Not F_ooPicBoxesColorsB Then CreateColorBoxes() 'Loop?
'   
'   ''Colors A: Default □□□□□□□□□□
'   If F_ooPicBoxesColorsA Then 
'     iW = PanelColorBoxesA.W / F_ooPicBoxesColorsA.Count
'     iH = PanelColorBoxesA.H 
'     For it = 0 To F_ooPicBoxesColorsA.Max
'       F_ooPicBoxesColorsA[it].Move(iW * it, 0, iW, iH)
'       If it < F_iiIconClockColorsA.Count Then F_ooPicBoxesColorsA[it].Background = F_iiIconClockColorsA[it]
'     Next
'   Endif 
'   
'   ''Colors B: User □□□□□□□□□□
'   If F_ooPicBoxesColorsB Then 'Boxes
'     iW = PanelColorBoxesB.W / F_ooPicBoxesColorsB.Count
'     iH = PanelColorBoxesB.H 
'     
'     For it = 0 To F_ooPicBoxesColorsB.Max
'       If it < F_iiIconClockColorsB.Count Then F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
'       F_ooPicBoxesColorsB[it].Font.Bold = False 
'       ' F_ooPicBoxesColorsB[it].Font.Size = ButtonColorPotNumber.Font.Size
'       F_ooPicBoxesColorsB[it].Move(iW * it, 0, iW, iH)
'       F_ooPicBoxesColorsB[it].Raise()'▲
'     Next
'     ''Selected:
'     F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Bold = True 
'     ' F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = ButtonColorPotNumber.Font.Size
'   Endif
'   
'   CheckFontColor() 
'   
' Catch 
'   FMain.ErrorText
'   
' End

Public Sub CreateLevelsGallery()
  
  Dim sPath, sFile As String 
  Dim hPic As Picture 
  Dim ssFiles As New String[]
  
  ' Me.Mouse = Mouse.Wait
  F_iESCpressed = 0 
  F_iIconSize = CInteger(Settings[F_sForm &/ "F_iIconSize", F_iIconSize]) 'as Integer, in Pixel. Example: 128
  LabelIconSizeWxH.Text = F_iIconSize & "x" & F_iIconSize & "px"
  MenuIconSize.Text = ("Icon") & "=" & Str(F_iIconSize) & "px"
  
  ''Show area:
  ScrollViewGallery.Background = LabelTemplateClockColor.Background
  
  Me.F_bWhiteBorderON = Settings[F_sForm &/ "F_bWhiteBorderON", True]
  FMain.F_bWhiteBorderON = Me.F_bWhiteBorderON
  If F_bWhiteBorderON = True Then PicBoxWhiteBorder.Background = F_iColorSelect Else PicBoxWhiteBorder.Background = Color.Default
  
  F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
  If F_iiIconClockColorsB = Null Then F_iiIconClockColorsB = M05.ColorPaletteStandardii()'as Integer[]
  ' FMain.F_iiIconClockColorsB = Me.F_iiIconClockColorsB.Copy()
  F_iColorBoxesPointer = Settings[F_sForm &/ "F_iColorBoxesPointer", 0]
  
  ''Load pictures calculated:
  M05.CreateIconClock() 'as Picture    —▶ M05   —▶ IconListAdd —▶ Add1xClockLevel()
  M07Paint.ClockCreatePartFiles() 'Create Files
  
  ''Load pictures default:
  ssFiles = Dir("images", "{earth,europe}*.png")
  ' ssFiles.Add("images/europe_800.png")
  ' ssFiles.Add("images/earth-openstreetmap.png")
  '...
  ssFiles.Add("musicnote_64.png")
  ssFiles.Add("penguinblue_64.png")
  ssFiles.Add("workplace_128.png")
  ssFiles.Add("penguinup_256.png")
  ssFiles.Add("penguindown_256.png")
  ssFiles.Add("calendar-k_128.png")
  ssFiles.Add("squares3x3_128.png")
  ssFiles.Add("plus-big_128.png")
  ssFiles.Add("table4chairs_128.png")
  
  For Each sFile In ssFiles.Sort()
    sPath = "images" &/ sFile
    If Exist(sPath) = True Then 
      hPic = Picture[sPath]
      If hPic Then Add1xClockLevel(hPic, sPath)
    Endif 
  Next 
  
  ''Laod pictures user:
  LoadUserPaths()
  
  ''Load extra clock-parts-files:
  ' LoadExtraPartsPaths() 'Load Files
  
  '*********************************************************
  LoadLevels(Settings[F_sForm &/ "F_sLevelsTags", Null]) 'level=begin...level=
  '*********************************************************
  
  ''Area pictures:
  ResizePanelLevels()
  ResizePanelGallery()
  SynchronizeLevelsToGallery()
  
  ''Create clock:
  SumPaintClockLevels()
  
  If F_iOnly1x > 0 Then Wait 0.3 'show action
  ScrollViewGallery.Background = Color.Default
  
  Me.Mouse = Mouse.Default 'Reset
  
Catch
  FMain.ErrorText
  Me.Mouse = Mouse.Default
  
End

Public Sub IconListAdd() ''◀— M05
  
  If F_iESCpressed > 0 Then 
    Select Case Message.Question(("Baukasten") & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
      Case 1
        F_iESCpressed = 0
      Case 2
        F_iESCpressed = 1
    End Select
  Endif 
  If F_iESCpressed = 0 Then Add1xClockLevel(F_imgLastIconImage.Picture, F_sLastIconName)
  
Catch
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ButtonBrowserTrueG(Optional bCache As Boolean = False)
  
  Dim sPath As String 
  
  sPath = ClockPictureLastTemp(F_picClock) 'as String 
  If bCache = False Then
    M01Functions.ExternStart("", sPath) 'Standard-Program
  Else 
    M01Functions.ExternStart("firefox", sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Function ClockPictureLastTemp(Optional hPic As Picture, Optional bCache As Boolean = False) As String 'sPath
  
  Dim sDir, sPath As String 
  
  sDir = File.Dir(F_sPathClockBackground_png)
  If IsDir(sDir) = False Then 
    sDir = M01Functions.CheckDirectoryCache()
  Endif 
  
  If IsDir(sDir) = True Then 
    If bCache = True Then 
      sPath = sDir &/ File.BaseName(F_sFileClockMusterLastTemp_PNG) & "_temp." & File.Ext(F_sFileClockMusterLastTemp_PNG) 'Directory program-cache
    Else 
      sPath = sDir &/ F_sFileClockMusterLastTemp_PNG 'Directory program-cache
    Endif 
    
    If Not hPic Then hPic = PicTemplateQuestion.Picture 
    If hPic And IsDir(sDir) = True Then hPic.Save(sPath)
  Endif 
  
  Return sPath
  
  ''____________________________________________________________''
  ' M01Functions.CheckDirectoryCache() 
  ' sPath = Temp() 'This function only returns a path.
  ' All files located in the /tmp/gambas [...] directory are automatically removed when the Gambas program ends.
  ' /tmp/gambas.<UserId>/<ProcessId>/<Prefix>.tmp
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ButtonDirG()
  
  Dim sDir As String
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  Desktop.Open(sDir)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonMusterDirG()
  
  Dim sDir As String
  
  sDir = Desktop.GetDirectory("PICTURES") ''Settings[FMain.Name &/ "sPathFoto",sPath]
  If Exist(sDir &/ Application.Name) = True Then sDir = sDir &/ Application.Name
  If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  Desktop.Open(sDir)
  
Catch 
  FMain.ErrorText
  
End

Public Sub DefaultNewLevelsGallery()
  
  Dim iScrollY As Integer
  
  If PanelGallery.Visible = False Then SideG("gallery") 
  iScrollY = ScrollViewGallery.ScrollY 'as Integer
  
  If ScrollViewLevels.Children Then ScrollViewLevels.Children.Clear() 'delete all
  If ScrollViewGallery.Children Then ScrollViewGallery.Children.Clear() 'delete all
  ' If ScrollViewMuster.Children Then ScrollViewMuster.Children.Clear() 'delete all
  If F_ooButtonsLevels Then F_ooButtonsLevels.Clear() 'empty all
  If F_ooPicBoxesLevels Then F_ooPicBoxesLevels.Clear()
  If F_ooPicBoxesGallery Then F_ooPicBoxesGallery.Clear()
  ' If F_ooPicBoxesMuster Then F_ooPicBoxesMuster.Clear()
  ' If F_ooButtonMuster Then F_ooButtonMuster.Clear()
  ' If F_ssEditLevels Then F_ssEditLevels.Clear()
  
  F_ooButtonsLevels = Null
  F_ooPicBoxesLevels = Null
  F_ooPicBoxesGallery = Null
  ' F_ooPicBoxesMuster = Null
  ' F_ooButtonMuster = Null
  F_imgCenterPoint = Null
  F_imgClockBG = Null
  F_imgClockCutter = Null
  F_imgDatePoint = Null
  F_imgDigital = Null
  F_imgGearWheel = Null
  F_imgHour = Null
  F_imgLCD = Null
  F_imgMinute = Null
  F_imgNightSky = Null
  F_imgPhythagoras = Null
  F_imgSecond = Null
  F_imgSunUpDown = Null
  F_imgTimeSummer = Null
  F_iiIconClockColorsB = Null
  F_bWhiteBorderON = True
  ' F_iZoomGallery = Settings[FMain.Name &/ "F_iZoomGallery", F_iZoomStandard]
  ZoomMinMaxCheck()
  
  ''***********************
  CreateLevelsGallery()
  ''***********************
  
  F_oLastPicBoxObject = Null
  
  CheckTimerClockPausePicture()
  
  ScrollViewGallery.ScrollY = iScrollY 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub TimerClock_Timer()
  ' Timer1.Delay = 1000 '=1Sekunde
  ' F_dateNow = Date(Year(Date), Month(Date), Day(Date), 18, 30, 0) 'Test 
  
  If F_bChangeON = True Then 'Reset
    ''changed weekday:   Example: So —▶ Mo
    ' If Abs(DateDiff(F_dateNow, Now, gb.Day)) > 0 Then...  
    ' If WeekDay(F_dateNow) <> WeekDay(Now) Then  '0=Sunday....7=Saturday
    ' If WeekDay(F_dateNow) = 0 Then... 
    ' If Day(F_dateNow) = 1 then...
    ' If Hour(F_dateNow) = 0 Then... 
    
    F_dateNow = FMain.F_dateNow 
    ' If Not F_dateNow Then F_dateNow = Now
    
    LabelTimePause.Text = Format(F_dateNow, "hh:nn:ss")  ''Example: "12:00:00"
    
    ''Map:
    If FMain.F_iClockMap0Stop1Count2Digital3Design4 = 0 Then 'no clock-picture ○
      ' TimerClock.Stop()
      SchongangStatus()
    Else
      ''Clock:
      F_iSecondCounter = Second(F_dateNow) 'Seconds ..., 58, 59, 0, 1, 2, 3...  
      RefreshClock()
    Endif
    'Start-Panel:
    ' If F_picClock Then Me.Window.Icon = F_picClock Else Me.Window.Icon = FMain.Window.Icon
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RefreshClock()
  'Check:  min. 1 Clock
  
  If F_ooPicBoxesGallery Then F_imgSumPaintClockLevels = DrawTime(F_dateNow) Else F_imgSumPaintClockLevels = M07Paint.ClockPhythagoras(F_dateNow, "-hour-minute-second-centerpoint")'as Image 
  
  If F_imgSumPaintClockLevels Then 
    PicBoxClock.Picture = F_imgSumPaintClockLevels.Picture
    F_picClock = F_imgSumPaintClockLevels.Picture
  Endif 
  ' PicBoxPenguin.Picture = F_picClock 'Test
  
Catch 
  FMain.ErrorText
  
End

Public Function DrawTime(Optional dateTime As Date = Now) As Image  'paint all in one clock-picture
  
  Dim imgTemp As Image
  Dim Img As Image'(F_iIconSize, F_iIconSize, Color.Transparent) 'Transparent True
  Dim iIconSizeHalf As Integer
  ' Print "DrawTime", datetime
  
  ''1 Second:
  ' If FMain.F_bClockDigitalON = True Then '00:00
  If FMain.F_iClockMap0Stop1Count2Digital3Design4 = 3 Then 
    ' F_picClock = M07Paint.ClockDigital().Picture ' Rückgabe Picture  Klammern nicht vergessen()
    If Not F_sTagsClockDigital Then F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", Null]
    F_picClock = M07Paint.ClockDigital(F_dateNow, F_sTagsClockDigital).Picture 'as Image
  Else 
    
    ''...Level+Level=Sum Clock:  
    If F_iIconSize = 0 Then F_iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128]
    If Not Img Then Img = New Image(F_iIconSize, F_iIconSize, Color.Transparent)
    iIconSizeHalf = F_iIconSize / 2
    
    Paint.Begin(Img) 'rotate and add Clock-Parts
    Paint.AntiAlias = True                                                                     '...----...
    
    If F_imgClockBG Then 'Basis, Background, Clock-Design
      Paint.DrawImage(F_imgClockBG, iIconSizeHalf - F_imgClockBG.Width / 2, iIconSizeHalf - F_imgClockBG.Height / 2) 'center, middle —▶○◀—
      ' If F_imgClockCutter Then
      '   
      ' Endif
    Endif
    
    If F_imgGearWheel Then 
      If Not F_sTagsClockGearWheel Then F_sTagsClockGearWheel = Settings[FMain.Name &/ "F_sTagsClockGearWheel", Null]
      If F_sTagsClockGearWheel Then F_imgGearWheel = AddImagesTags("F_imgGearWheel", F_sTagsClockGearWheel) 'as Image
      ' imgTemp = imgTemp.Rotate(-Second(Now) * Pi(2 / 60)) 'Example in Gambas3
      ' imgTemp = imgTemp.Rotate(Rad(-Second(dateTime) * 6)) 'my Short-Version '360°Degree / 60 = 6° = 1 Part Minute=Second  |....!....|....!... 12:01, 12:02, ...
      If F_imgGearWheel Then Paint.DrawImage(F_imgGearWheel, iIconSizeHalf - F_imgGearWheel.Width / 2, iIconSizeHalf - F_imgGearWheel.Height / 2) 'center, middle —▶○◀—
    Endif 
    
    If F_imgNightSky Then 
      If Not FMain.F_dateSunUp Then M02Astro.AstroSunUpDown(dateTime) 'as Date
      If dateTime < FMain.F_dateSunUp Or dateTime > FMain.F_dateSunDown Then 
        Paint.DrawImage(F_imgNightSky, iIconSizeHalf - F_imgNightSky.Width / 2, iIconSizeHalf - F_imgNightSky.Height / 2) 'center, middle —▶○◀—
      Endif 
    Endif
    
    If F_imgTimeSummer Then '02:00<>03:00 Begin +h <> End -h
      If PanelDateTime.Visible = True Then 
        If Not FMain.F_dateTimeSummerBegin Then FMain.F_iTimeSummerMinutesDiff = M02Astro.SommerzeitAnfangEnde(F_dateNow) 'calculate
        If Abs(DateDiff(FMain.F_dateTimeSummerBegin, F_dateNow, gb.Day)) < 3 Or Abs(DateDiff(FMain.F_dateTimeSummerEnd, F_dateNow, gb.Day)) < 3 Then 
          'Days before or after the time change (Tage vor oder nach der Zeitumstellung)
          Paint.DrawImage(F_imgTimeSummer, iIconSizeHalf - F_imgTimeSummer.Width / 2, F_imgTimeSummer.Height / 2 - F_imgTimeSummer.Height / 2) 'center, middle —▶○◀—
          LabelMessage.Text = "<font color=darkblue><b>" & ("Sommerzeit") & ": " & Format(FMain.F_dateTimeSummerBegin, "ddd dd-mm-yyyy") & Space(1) & ("Sonnenuntergang") & ": " & Format(FMain.F_dateSunDown, "hh:nn") & "</b></font>"
          LabelMessage.Visible = True 
          LabelInfo.Text = "<font color=white><b>" & ("Hinweis: Einige bewegliche Teile erscheinen nur zu bestimmten Zeiten im Hauptfenster.") & "</b></font>" & Space(1) & ("Sommerzeit") & ": " & Format(FMain.F_dateTimeSummerBegin, "ddd dd-mm-yyyy") & Space(1) & ("Sonnenuntergang") & ": " & Format(FMain.F_dateSunDown, "hh:nn") 
          LabelInfo.Visible = True 
        Endif 
      Else 
        Paint.DrawImage(F_imgTimeSummer, iIconSizeHalf - F_imgTimeSummer.Width / 2, F_imgTimeSummer.Height / 2 - F_imgTimeSummer.Height / 2) 'center, middle —▶○◀—
      Endif 
    Endif
    
    If F_imgSunUpDown Then 
      If F_iSecondCounter = 0 Then 'only 1x in one Minute  0,1,2,3,..,58,59,0
        If Not F_sTagsClockSunUpDown Then F_sTagsClockSunUpDown = Settings[FMain.Name &/ "F_sTagsClockSunUpDown", Null]
        F_imgSunUpDown = AddImagesTags("F_imgSunUpDown", F_sTagsClockSunUpDown)
        ' Print F_sTagsClockSunUpDown
      Endif 
      If F_imgSunUpDown Then Paint.DrawImage(F_imgSunUpDown, iIconSizeHalf - F_imgSunUpDown.Width / 2, iIconSizeHalf - F_imgSunUpDown.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgClockNumbers And F_sTagsClockNumbers Then 
      If F_iSecondCounter = 0 Then 'only 1x in one Minute
        If Not F_sTagsClockNumbers Then F_sTagsClockNumbers = Settings[FMain.Name &/ "F_sTagsClockNumbers", Null]
        F_imgClockNumbers = AddImagesTags("F_imgClockNumbers", F_sTagsClockNumbers) 'as Image
      Endif 
      If F_imgClockNumbers Then Paint.DrawImage(F_imgClockNumbers, iIconSizeHalf - F_imgClockNumbers.Width / 2, iIconSizeHalf - F_imgClockNumbers.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgHour Then 'short ●———
      ' imgTemp = imgTemp.Rotate(-((Hour(dateTime) * 60) + Minute(dateTime)) * Pi(1 / 360)) '360°Degree / 12 = 30° = 1 Part Hour  12:00, 13:00,...  |....!....|....!...
      imgTemp = F_imgHour.Rotate(Rad(-Hour(dateTime) * 30 + (-Minute(dateTime) * 0.5))) '1h=30°, 30/5m=6
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - imgTemp.Width / 2, iIconSizeHalf - imgTemp.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgMinute Then 'long ●———————
      ' imgTemp = imgTemp.Rotate(-Minute(Now) * Pi(2 / 60))
      imgTemp = F_imgMinute.Rotate(Rad(-Minute(dateTime) * 6))
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - imgTemp.Width / 2, iIconSizeHalf - imgTemp.Height / 2) 'center, middle —▶○◀—
    Endif 
    
    If F_imgSecond Then 'longest ●——————————
      ' imgTemp = imgTemp.Rotate(-Second(Now) * Pi(2 / 60))
      imgTemp = F_imgSecond.Rotate(Rad(-Second(dateTime) * 6)) '360°Degree / 60 = 6° = 1 Part Minute=Second  |....!....|....!... 12:01, 12:02, ...
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - imgTemp.Width / 2, iIconSizeHalf - imgTemp.Height / 2) 'center, middle —▶○◀—
    Endif 
    
    If F_imgDatePoint Then '—▶ user terminwecker
      imgTemp = F_imgDatePoint
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - imgTemp.Width / 2, iIconSizeHalf - imgTemp.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgCenterPoint Then '●
      Paint.DrawImage(F_imgCenterPoint, iIconSizeHalf - F_imgCenterPoint.Width / 2, iIconSizeHalf - F_imgCenterPoint.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgPhythagoras Then 'hour-minute-second-centerpoint = 1 Picture
      If Not F_sTagsClockPhythagoras Then F_sTagsClockPhythagoras = Settings[FMain.Name &/ "F_sTagsClockPhythagoras", "-hour-minute-second-centerpoint"]
      If F_sTagsClockPhythagoras Then imgTemp = AddImagesTags("F_imgPhythagoras", F_sTagsClockPhythagoras) 'as Image
      If imgTemp Then Paint.DrawImage(imgTemp, iIconSizeHalf - imgTemp.Width / 2, iIconSizeHalf - imgTemp.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgDigital Then '00:00 Text
      If Not F_sTagsClockDigital Then F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", Null]
      If F_sTagsClockDigital Then F_imgDigital = AddImagesTags("F_imgDigital", F_sTagsClockDigital) 'as Image
      If F_imgDigital Then Paint.DrawImage(F_imgDigital, iIconSizeHalf - F_imgDigital.Width / 2, iIconSizeHalf - F_imgDigital.Height / 2) 'center, middle —▶○◀—
    Endif
    
    If F_imgLCD Then '00:00 LCD
      If Not F_sTagsClockLCD Then F_sTagsClockLCD = Settings[FMain.Name &/ "F_sTagsClockLCD", Null]
      If F_sTagsClockLCD Then F_imgLCD = AddImagesTags("F_imgLCD", F_sTagsClockLCD) 'as Image
      If F_imgLCD Then Paint.DrawImage(F_imgLCD, iIconSizeHalf - F_imgLCD.Width / 2, iIconSizeHalf - F_imgLCD.Height / 2) 'center, middle —▶○◀—
    Endif
    
    Paint.End
    ' PicBoxClock.Picture = Img.Picture 'without .Copy() not accurate
    ' F_picClock = Img.Picture  'Note: Image internally is faster than Picture   convert Image to Picture
    ' F_imgSumPaintClockLevels = Img
  Endif 
  
  Return Img 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End 'DrawTime

Public Function AddImagesTags(Optional sClockPart As String = "F_imgSunUpDown", Optional sTags As String = Null) As Image
  
  Dim imgTemp As Image
  Dim sTag As String 
  Dim it As Integer
  
  If sClockPart Then 
    imgTemp = Null
    Select Case sClockPart 'moving parts (bewegliche Teile)
      Case "F_imgGearWheel"
        imgTemp = M07Paint.ClockGearWheel(F_dateNow, sTags) 'as Image
      Case "F_imgSunUpDown"
        imgTemp = M07Paint.ClockSunUpDown(F_dateNow, sTags) 'as Image
      Case "F_imgClockNumbers" '1x from Gallery
        imgTemp = M07Paint.ClockNumbers(F_dateNow, sTags) 'as Image
      Case "F_imgDigital"
        imgTemp = M07Paint.ClockDigital(F_dateNow, sTags) 'as Image
      Case "F_imgLCD"
        imgTemp = M07Paint.ClockLCD(F_dateNow, sTags) 'as Image
      Case "F_imgPhythagoras"
        imgTemp = M07Paint.ClockPhythagoras(F_dateNow, sTags) 'as Image
    End Select
    
    ''Image edit:
    ' If it = -1 Then it = CInteger(PicBoxSelectLevelONoff.Tooltip) - 1
    If F_ssPicBoxGalleryTags Then it = F_ssPicBoxGalleryTags.Find(sTags)
    If it = -1 Then it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject) '-1 not found 
    
    If it > -1 And F_ssEditLevels Then 
      If Not F_iiPicBoxesVisibleLevelNr Then F_iiPicBoxesVisibleLevelNr = New Integer[]
      If F_iiPicBoxesVisibleLevelNr.Find(it) = -1 Then F_iiPicBoxesVisibleLevelNr.Add(it)
      For Each sTag In Split(F_ssEditLevels[it] & "=", "=")
        If sTag Then imgTemp = ImageEditReturn(imgTemp, sTag)
      Next
    Endif  
  Endif 
  
  Return imgTemp
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Sub SumPaintClockLevels()
  
  Dim it, it2, iLine, iFound, iCount, iColor, iIconSizeHalf As Integer
  Dim iiLevels As Integer[]
  Dim iiSelectionNr As Integer[]
  Dim iiCounts As Integer[]
  Dim Img, NewImg As Image 
  Dim sTag As String 
  Dim imgNumber As Image
  Dim bTimerON As Boolean
  
  bTimerON = TimerClock.Enabled
  TimerClock.Stop
  
  If F_ooPicBoxesLevels Then 
    F_imgSumPaintClockLevels = Null 'Muster-Side
    F_imgCenterPoint = Null
    F_imgClockBG = Null
    F_imgClockCutter = Null
    F_imgDatePoint = Null
    F_imgDigital = Null
    F_imgGearWheel = Null
    F_imgHour = Null
    F_imgLCD = Null
    F_imgMinute = Null
    F_imgNightSky = Null
    F_imgPhythagoras = Null
    F_imgSecond = Null
    F_imgSunUpDown = Null
    F_imgTimeSummer = Null
    PicBoxClock.Picture = Null
    PicBoxClockBG.Picture = Null
    F_sTagsClockSunUpDown = Null
    F_sTagsClockGearWheel = Null
    F_sTagsClockNumbers = Null
    F_sTagsClockDigital = Null
    F_sTagsClockLCD = Null
    F_sTagsClockPhythagoras = Null
    
    iiLevels = New Integer[]
    iiSelectionNr = New Integer[]
    iiCounts = New Integer[]
    iIconSizeHalf = F_iIconSize / 2
    
    ''Position: .Left
    For it = 0 To F_ooPicBoxesLevels.Max
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      
      iiCounts.Add(F_ooPicBoxesLevels[it].Left)
      If F_ooPicBoxesLevels[it].Visible = True Then 
        iCount = iCount + 1
        If F_ooPicBoxesLevels[it].Background = F_iColorSelect Then iiLevels.Add(F_ooPicBoxesLevels[it].Left)
      Else 
        iiLevels.Add(-1)
      Endif 
    Next
    
    If F_iESCpressed > 0 Then Goto JumpEnd
    
    ''Position: Number
    If iiLevels Then 
      iiLevels = iiLevels.Sort()
      For it = 0 To iiLevels.Max
        iFound = iiCounts.Find(iiLevels[it])
        If iFound > -1 Then iiSelectionNr.Add(iFound)
      Next
    Endif
    
    ''Add Levels: Nr
    If iiSelectionNr Then 
      For it2 = 0 To iiSelectionNr.Max
        it = iiSelectionNr[it2]
        sTag = String.LCase(F_ooPicBoxesLevels[it].Tag)
        If F_ooPicBoxesLevels[it].Picture Then 
          imgNumber = F_ooPicBoxesLevels[it].Picture.Image 'convert to image 
        Else 
          F_ooPicBoxesLevels[it].Picture = PicTemplateQuestion.Picture '?
          imgNumber = PicTemplateQuestion.Picture.Image  
        Endif 
        
        If imgNumber Then 
          ''colorchange=
          For iColor = 0 To F_iiIconClockColorsB.Max
            If F_iiIconClockColorsA[iColor] <> F_iiIconClockColorsB[iColor] Then 
              imgNumber = imgNumber.Replace(F_iiIconClockColorsA[iColor], F_iiIconClockColorsB[iColor]) 
            Endif 
          Next 
          
          ''Check Size:
          If imgNumber.W <> F_iIconSize Or imgNumber.H <> F_iIconSize Then 
            imgNumber = imgNumber.Stretch(F_iIconSize, F_iIconSize)
          Endif
          
          If String.InStr(sTag, "timegearwheel") > 0 Or String.InStr(sTag, "clockgearwheel") > 0 Then  
            If Not F_sTagsClockGearWheel Then 
              F_sTagsClockGearWheel = sTag 'single
            Else 
              F_sTagsClockGearWheel = F_sTagsClockGearWheel & gb.NewLine & sTag  'multi
            Endif 
            F_imgGearWheel = imgNumber.Copy()
            
          Else If String.InStr(sTag, "timehh") > 0 Or String.InStr(sTag, "clockhour") > 0 Then 
            F_imgHour = imgNumber
            
          Else If String.InStr(sTag, "timemm") > 0 Or String.InStr(sTag, "clockminute") > 0 Then  
            F_imgMinute = imgNumber
            
          Else If String.InStr(sTag, "timess") > 0 Or String.InStr(sTag, "clocksecond") > 0 Then  
            F_imgSecond = imgNumber
            
          Else If String.InStr(sTag, "timecenterpoint") > 0 Or String.InStr(sTag, "clockcenterpoint") > 0 Then  
            F_imgCenterPoint = imgNumber
            
          Else If String.InStr(sTag, "timedatepoint") > 0 Or String.InStr(sTag, "clockdatepoint") > 0 Then  
            F_imgDatePoint = imgNumber
            
          Else If String.InStr(sTag, "timephythagoras") > 0 Then 
            If Not F_sTagsClockPhythagoras Then 
              F_sTagsClockPhythagoras = sTag 
            Else 
              F_sTagsClockPhythagoras = F_sTagsClockPhythagoras & gb.NewLine & sTag  
            Endif 
            F_imgPhythagoras = imgNumber
            
          Else If String.InStr(sTag, "timedigital") > 0 Then '12:34 Text
            If Not F_sTagsClockDigital Then 
              F_sTagsClockDigital = sTag 
            Else 
              F_sTagsClockDigital = F_sTagsClockDigital & gb.NewLine & sTag  
            Endif 
            F_imgDigital = imgNumber
            
          Else If String.InStr(sTag, "timelcd") > 0 Then '00:00
            If Not F_sTagsClockLCD Then 
              F_sTagsClockLCD = sTag 
            Else 
              F_sTagsClockLCD = F_sTagsClockLCD & gb.NewLine & sTag  
            Endif 
            F_imgLCD = imgNumber
            
          Else If String.InStr(sTag, "timesunupdown") > 0 Then '00:00
            If Not F_sTagsClockSunUpDown Then 
              F_sTagsClockSunUpDown = sTag 
            Else 
              F_sTagsClockSunUpDown = F_sTagsClockSunUpDown & gb.NewLine & sTag  
            Endif 
            F_imgSunUpDown = imgNumber 'Example-Image
            
          Else If String.InStr(sTag, "timeclocknumbers") > 0 Then '00:00
            If Not F_sTagsClockNumbers Then 
              F_sTagsClockNumbers = sTag 
            Else 
              F_sTagsClockNumbers = F_sTagsClockNumbers & gb.NewLine & sTag  
            Endif 
            F_imgClockNumbers = imgNumber
            
          Else If String.InStr(sTag, "timenightsky") > 0 Then '00:00
            F_imgNightSky = imgNumber
            
          Else If String.InStr(sTag, "timesummer") > 0 Then '00:00 'only in FMain?
            F_imgTimeSummer = imgNumber
            
          Else If String.InStr(sTag, "cutter") > 0 Then 
            F_imgClockCutter = imgNumber
            ' iColorCutter = imgNumber[0, 0] 'as Integer
            ' iColorCutter = F_iColorCut
            ' If F_imgClockCutter Then 
            '   Img = New Image(F_iIconSize, F_iIconSize, iColorCutter)
            '   Paint.Begin(Img)
            '   Paint.DrawImage(F_imgClockCutter, 0, 0)
            '   Paint.Brush = Paint.Color(Color.Transparent)
            '   Paint.Operator = Paint.OperatorClear
            '   Paint.Fill()
            '   Paint.End
            '   F_imgClockCutter = Img
            '   ' F_imgClockCutter = Img.Replace(iColorCutter, Color.Transparent)
            ' Endif 
            If F_imgClockBG Then 
              Paint.Begin(F_imgClockBG)
              Paint.DrawImage(imgNumber, iIconSizeHalf - imgNumber.Width / 2, iIconSizeHalf - imgNumber.Height / 2) 'center, middle —▶○◀—
              Paint.End
              F_imgClockBG = F_imgClockBG.Replace(F_iColorCut, Color.Transparent)
            Endif 
            
          Else 'Clock design
            If imgNumber Then
              ' If Exist(sTag) = True Then 
              '   imgNumber = imgNumber.Replace(F_iColorPicker, PicTemplateGridTrans.Background) 
              '   F_ooPicBoxesLevels[it].Picture = imgNumber.Picture
              ' Endif 
              If Not Img Then Img = New Image(F_iIconSize, F_iIconSize, Color.Transparent)
              Paint.Begin(Img)
              NewImg = imgNumber.Stretch(Img.W, Img.H).Copy()
              Paint.DrawImage(NewImg, iIconSizeHalf - NewImg.Width / 2, iIconSizeHalf - NewImg.Height / 2) 'center, middle —▶○◀—
              Paint.End
              F_imgClockBG = Img
            Endif 
          Endif 
          If imgNumber Then F_ooPicBoxesLevels[it].Picture = imgNumber.Picture
        Endif 
      Next
    Endif 
    
  Endif 'Clock-Background
  'Clock-Foreground —▶ RefreshClock() PicBoxClock.Picture = F_picClock ' Sum/all pictures or empty (Gesamtbild oder leer)
  
  If F_ooPicBoxesLevels And iiSelectionNr Then 
    LabelCounterText(iiSelectionNr.Count, iCount)
  Else 
    LabelCounterText(0, 0)
  Endif 
  
  If iCount > 0 Then 
    LabelMyClockDesign.Visible = False 
  Else 
    LabelMyClockDesign.Visible = True ''Empty, show Text
  Endif
  
  F_iSecondCounter = 0 'Start New —▶ Clock-Picture
  RefreshClock() '1x before —▶Timer
  ' PicBoxPenguin.Picture = F_picClock 'Test
  
JumpEnd:
  If F_bChangeON = True Then 
    CheckButtonEdit()
    CheckTimerClockPausePicture()
  Endif 
  TimerClock.Enabled = bTimerON
  
Catch
  FMain.ErrorText
  Me.Mouse = Mouse.Default
  
End

Public Sub UndoRedoLevelSave(Optional sTag As String = Null)
  
  If Not F_ssUndoRedoLevels Then F_ssUndoRedoLevels = New String[]
  If Not sTag Then sTag = ReadLevelsTag()
  
  ''Save:
  If F_ssUndoRedoLevels.Max = -1 Then 
    F_ssUndoRedoLevels.Add(sTag)
  Else 
    If F_ssUndoRedoLevels.Last <> sTag Then F_ssUndoRedoLevels.Add(sTag)
  Endif 
  
  ''Info:
  F_iUndoRedoLevelPointer = F_ssUndoRedoLevels.Max
  LabelUndoRedoCounter.Text = Str(F_iUndoRedoLevelPointer + 1) & "/" & Str(F_ssUndoRedoLevels.Max + 1)
  
Catch
  FMain.ErrorText
  
End

Public Function UndoRedoLevelRead(Optional sUndoRedo As String = "-") As String
  
  Dim sTag As String 
  
  If Not F_ssUndoRedoLevels Then 
    F_ssUndoRedoLevels = New String[]
    F_ssUndoRedoLevels.Add("") 'first empty
  Endif 
  
  ''"-" Minus, Undo
  If sUndoRedo = "-" Then 
    F_iUndoRedoLevelPointer = F_iUndoRedoLevelPointer - 1
  Else ''"+" Plus, Redo
    F_iUndoRedoLevelPointer = F_iUndoRedoLevelPointer + 1
  Endif
  If F_iUndoRedoLevelPointer < -1 Then F_iUndoRedoLevelPointer = -1
  If F_iUndoRedoLevelPointer > F_ssUndoRedoLevels.Max Then F_iUndoRedoLevelPointer = F_ssUndoRedoLevels.Max
  ''Pointer x.Max 0,1,2...n-1, Text x.Count 1,2,...n+1
  LabelUndoRedoCounter.Text = Str(F_iUndoRedoLevelPointer + 1) & "/" & Str(F_ssUndoRedoLevels.Max + 1) 
  
  ''Read:
  If F_iUndoRedoLevelPointer > -1 Then sTag = F_ssUndoRedoLevels[F_iUndoRedoLevelPointer]
  
  Return sTag 
  
Catch
  FMain.ErrorText
  
End

Public Function UndoRedoMusterSelection(Optional sReadSave As String = "save") As String
  
  Dim sSelection, sTag As String 
  Dim it, iLine, iNr, iLastSelection As Integer
  Dim ssSpli, ssSelection As String[]
  
  ' If F_iESCpressed > 0 Then Return 'end here
  
  Select Case sReadSave
      
    Case "save"
      If F_ooPicBoxesMuster Then 
        If Not F_ssUndoRedoMusterSelection Then F_ssUndoRedoMusterSelection = New String[]
        If Not F_ssUndoRedoMuster Then UndoRedoMusterSave()
        If F_ssUndoRedoMusterSelection.Max <> F_ssUndoRedoMuster.Max Then F_ssUndoRedoMusterSelection.Resize(F_ssUndoRedoMuster.Count)
        
        For it = 0 To F_ooPicBoxesMuster.Max
          iLine = iLine + 1
          ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif  
          If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then 
            iLastSelection = it
            sSelection &= it & "=1"
          Else 
            sSelection &= it & "=0" 
          Endif 
          If F_ooPicBoxesMuster[it].Picture Then 
            sSelection &= "=1"
          Else 
            sSelection &= "=0"
          Endif 
          sSelection &= gb.NewLine
        Next  

        F_ssUndoRedoMusterSelection[F_iUndoRedoMusterPointer] = sSelection
        sTag = F_ooPicBoxesMuster[iLastSelection].Tag
      Else 
        F_ssUndoRedoMusterSelection = Null
        sTag = Null
      Endif 
      
    Case "read"
      If F_ooPicBoxesMuster And F_ssUndoRedoMuster Then 
        iLastSelection = -1
        If Not F_ssUndoRedoMusterSelection Then F_ssUndoRedoMusterSelection = New String[]
        If F_ssUndoRedoMusterSelection.Max <> F_ssUndoRedoMuster.Max Then F_ssUndoRedoMusterSelection.Resize(F_ssUndoRedoMuster.Count)
        If F_ssUndoRedoMusterSelection.Max > -1 Then 
          sSelection = F_ssUndoRedoMusterSelection[F_iUndoRedoMusterPointer]
          ssSelection = Split(sSelection & gb.NewLine, gb.NewLine)
          For it = 0 To ssSelection.Max
            iLine = iLine + 1
            ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_iESCpressed > 0 Then 
              If MessageQuestionBreak() > 0 Then Break
            Endif  
            sSelection = ssSelection[it]
            ssSpli = Split(sSelection & String(4, "="), "=")
            If ssSpli Then 
              If IsInteger(ssSpli[0]) = True Then iNr = CInteger(ssSpli[0]) Else iNr = -1
              If iNr > -1 And iNr < F_ooPicBoxesMuster.Count Then 
                If ssSpli[1] = "1" Then 
                  F_ooPicBoxesMuster[iNr].Background = F_iColorSelect
                  iLastSelection = iNr
                Else 
                  F_ooPicBoxesMuster[iNr].Background = Color.Default
                Endif 
              Endif 
            Endif 
          Next 
          If iLastSelection > -1 Then sTag = F_ooPicBoxesMuster[iLastSelection].Tag
        Endif 
      Else 
        F_ssUndoRedoMusterSelection = Null
        sTag = Null
      Endif
      
  End Select
  ' ProgressBarONoff(False) 
  
  Return sTag
  
Catch
  FMain.ErrorText
  
End

Public Sub UndoRedoMusterSave(Optional sTag As String = Null)
  
  If Not F_ssUndoRedoMuster Then F_ssUndoRedoMuster = New String[]
  
  If Not sTag Then sTag = ReadMusterTags()
  
  ''Save:
  If F_ssUndoRedoMuster.Max = -1 Then 
    F_ssUndoRedoMuster.Add(sTag)
  Else 
    If F_ssUndoRedoMuster.Last <> sTag Then F_ssUndoRedoMuster.Add(sTag)
  Endif 
  
  ''Info:
  F_iUndoRedoMusterPointer = F_ssUndoRedoMuster.Max
  LabelUndoRedoCounterMuster.Text = Str(F_iUndoRedoMusterPointer + 1) & "/" & Str(F_ssUndoRedoMuster.Max + 1)
  UndoRedoMusterSelection("save")
  
Catch
  FMain.ErrorText
  
End

Public Function UndoRedoMusterRead(Optional iPointer As Integer = -1) As String
  
  Dim sTag As String 
  
  If Not F_ssUndoRedoMuster Then 
    F_ssUndoRedoMuster = New String[]
    F_ssUndoRedoMuster.Add("") 'first empty
  Endif 
  
  F_iUndoRedoMusterPointer = iPointer
  If F_iUndoRedoMusterPointer < -1 Then F_iUndoRedoMusterPointer = -1
  If F_iUndoRedoMusterPointer > F_ssUndoRedoMuster.Max Then F_iUndoRedoMusterPointer = F_ssUndoRedoMuster.Max
  ''Pointer x.Max 0,1,2...n-1, Text x.Count 1,2,...n+1
  LabelUndoRedoCounterMuster.Text = Str(F_iUndoRedoMusterPointer + 1) & "/" & Str(F_ssUndoRedoMuster.Max + 1) 
  
  ''Read:
  If F_iUndoRedoMusterPointer = -1 Then 
    MusterNullNew()
    sTag = ""
  Else 
    sTag = F_ssUndoRedoMuster[F_iUndoRedoMusterPointer]
  Endif 
  
  Return sTag 
  
Catch
  FMain.ErrorText
  
End

Public Function LoadMusterNewTagsPictures(Optional sMusterTags As String = "") As Picture 'xxxx????
  
  Dim ssSpli, ssNewMusterTags As String[]
  Dim it, iLine, iFound, iOld, iNew As Integer
  Dim sPicBoxMusterTags, sLevelTags, sTag, sMuster, sLevelExist As String 
  Dim picMuster As Picture
  
  sLevelTags = ReadLevelsTag() 'save at the beginning —▶ Reset
  sPicBoxMusterTags = F_ssPicBoxMusterTags.Join(gb.NewLine)
  
  If F_ooPicBoxesMuster Then iOld = F_ooPicBoxesMuster.Max
  ssSpli = New String[]
  ssSpli = Split(sMusterTags & gb.NewLine, gb.NewLine)  'IgnoreVoids=True without empty String (Part) 
  ssNewMusterTags = New String[]
  
  'Exist:
  For it = 0 To ssSpli.Max 
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_iESCpressed > 0 Then 
      If MessageQuestionBreak() > 0 Then Break
    Endif  
    sTag = ssSpli[it]
    sTag = Replace(sTag, gb.Cr, "") '"\r" '(*1) '\r
    ' iFound = F_ssPicBoxMusterTags.Find("*" & sTag & "*", gb.Like) '-1 not found 
    iFound = String.InStr(sPicBoxMusterTags, sTag) 
    If iFound = 0 Then 
      ''Create Muster-Picture:
      iNew = iNew + 1
      sLevelExist = sLevelExist & gb.NewLine & sMuster
      LoadLevelsNewNull()
      LoadLevels(sMuster) 
      ResizePanelLevels()
      SumPaintClockLevels()
      '**************************************
      Add1xMuster(F_picClock, sMuster)
      '**************************************
    Endif
  Next
  
  ''Add:
  For it = 0 To ssNewMusterTags.Max 
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_iESCpressed > 0 Then 
      If MessageQuestionBreak() > 0 Then Break
    Endif  
    sMuster = ssNewMusterTags[it]
    ''Create Muster-Picture:
    iNew = iNew + 1
    sLevelExist = sLevelExist & gb.NewLine & sMuster
    LoadLevelsNewNull()
    LoadLevels(sMuster) 
    ResizePanelLevels()
    SumPaintClockLevels()
    '**************************************
    Add1xMuster(F_picClock, sMuster)
    '**************************************
    picMuster = F_picClock
  Next 
  ResizePanelMuster()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
  
  ''Info:
  MusterCounter() 'as String  "0/0"
  If iOld > 0 Then LabelCounterMuster.Text = LabelCounterMuster.Text & Space(1) & ("Neu") & ": " & Space(1) & Str(iNew - iOld)
  
  ''Reset at the beginning:
  LoadLevelsNewNull()
  LoadLevels(sLevelTags) 'Reset
  ResizePanelLevels()
  SumPaintClockLevels()
  
  Return picMuster
  
Catch
  FMain.ErrorText
  
End

Public Function LoadMusterOnePicture(Optional sMusterOneTag As String = "") As Picture
  
  Dim sLevelsBefore As String
  Dim picMuster As Picture
  
  If F_iESCpressed > 0 Then Return 'end here
  
  sLevelsBefore = ReadLevelsTag() 'save at the beginning —▶ Reset
  
  ''Create Muster-Picture:
  LoadLevelsNewNull()
  LoadLevels(sMusterOneTag) 
  ResizePanelLevels()
  SumPaintClockLevels()
  
  '**************************************
  picMuster = F_picClock
  '**************************************
  
  ''Reset at the beginning:
  LoadLevelsNewNull()
  LoadLevels(sLevelsBefore) 'Reset
  ResizePanelLevels()
  SumPaintClockLevels()
  
  Return picMuster
  
Catch
  FMain.ErrorText
  
End

Public Function CheckDoubleLevelMusterReturn(Optional sTag As String = "") As String 
  
  Dim sLevel, sMuster, sMusterAllBefore As String
  Dim ssExistLevels, ssExistMuster, ssSplitGroups As String[]
  Dim it, iCount, iLine, iMuster, iDouble As Integer
  Dim bBeginON As Boolean
  
  If F_iESCpressed > 0 Then Return 'end here
  If Not F_ooPicBoxesMuster Then CheckMusterSideFill()
  If Not sTag Then sTag = ReadMusterTags(True) 'True=All
  sMusterAllBefore = sTag
  
  ''sTag > level=?
  If sTag And String.InStr(sTag, "level=end") > 0 Then 
    sTag = CheckMusterBeginEnd(sTag, False) 'True= Muster 1x
    If F_iESCpressed > 0 Then Goto JumpEnd
    ' sLevelTags = ReadLevelsTag() 'save at the beginning —▶ Reset
    ''Exist:
    sMuster = Null 'reset
    
    ''sLevel: level=begin —▶ level=end
    ssSplitGroups = Split(sTag & gb.NewLine, gb.NewLine)
    ' ProgressBarONoff(True)
    ProgressBar1.Pulse = False
    ssExistLevels = New String[]
    
    If ssSplitGroups Then 
      Me.Window.Title = Application.Name & " - " & MenuCorrectTags.Text & "..."
      LabelMessageText(MenuCorrectTags.Text & "...", Color.Red)
      ' iCount = ssSplitGroups.Count 
      ' iCount = Split(sTag & "level=begin", "level=begin").Max
      iCount = Split(sTag & gb.NewLine & gb.NewLine, gb.NewLine & gb.NewLine).Max
      If iCount < 1 Then iCount = 1 'not 0 (Counter/0=Error)
      For Each sLevel In ssSplitGroups 'Lines
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True)
        If iLine Mod 100 = 0 Then
          ProgressBar1.Value = iLine / iCount
          Wait 0.000001
          ProgressBar1.Visible = True
        Endif 
        
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        If sLevel Then 
          If String.InStr(String.LCase(sLevel), "level=begin") > 0 And bBeginON = False Then
            ssExistLevels = New String[]
            ssExistLevels.Add(sLevel)
            bBeginON = True
          Else If String.InStr(String.LCase(sLevel), "level=begin") = 0 And String.InStr(String.LCase(sLevel), "level=end") = 0 And String.InStr(String.LCase(sLevel), "=") > 0 And bBeginON = True Then
            If ssExistLevels.Find(sLevel) = -1 Then ssExistLevels.Add(sLevel)
          Else If String.InStr(String.LCase(sLevel), "level=end") > 0 And bBeginON = True Then 
            sMuster = "" 'Reset
            bBeginON = False
            If ssExistLevels.Find(sLevel) = -1 Then  
              ssExistLevels.Add(sLevel)
              For it = 0 To ssExistLevels.Max
                sMuster &= ssExistLevels[it] & gb.NewLine
              Next
            Endif 
            ssExistLevels = Null 'Reset
            If sMuster Then 
              If Not ssExistMuster Then ssExistMuster = New String[] 
            Endif 
            
            If ssExistMuster Then 
              If ssExistMuster.Find(sMuster) = -1 Then 
                ssExistMuster.Add(sMuster)
                iMuster = ssExistMuster.Count
              Else 
                iDouble = iDouble + 1
              Endif 
            Endif 
            LabelCounterMuster.Text = iMuster & Space(1) & ("von") & Space(1) & iCount & Space(1) & ("Doppelt") & ": " & (-iDouble) 
          Endif 
        Endif 
      Next 
      
      If ssExistMuster Then sTag = ssExistMuster.Join(gb.NewLine & gb.NewLine)
      
      LabelInfo.Text = "<font color=white><b>" & LabelCounterMuster.Text & "</b></font>"
      LabelInfo.Visible = True 
    Endif  
    F_bMusterSideChanged = True
  Endif 
JumpEnd:
  If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
  Return sTag
  
Catch
  FMain.ErrorText
  
End

Public Sub FindCurrentMuster()
  
  Dim it, it2, iFound, iLine, iLastMax, iCount, iAll, iCounter, iSelectMax, iTopSelect As Integer
  Dim s1, s2, s3, sMessage, sLine, sLine2, sMustertags As String
  Dim ssSpliTags, ssSpli As String[]
  Dim iiMusterSelect, iiMusterUnselect As Integer[]
  Dim ffMusterSort As Float[]
  Dim fNr As Float
  
  iSelectMax = 1
  
  Me.Window.Title = Application.Name & " - " & MenuFindCurrentMuster.Text & "..."
  LabelMessageText(MenuFindCurrentMuster.Text & "...", Color.Red)
      
  F_sLevelsTags = ReadLevelsTag() 'Refresh after loading Muster
  
  sMessage = "<h2><font color=red>" & ("Keine Suche ohne Vorlage") & "</font></h2>"
  
  If Not F_sLevelsTags Then 
    sMessage &= "<h2><font color=blue>" & ("Ein aktueller Uhr-Entwurf fehlt (noch).") & "</font></h2>"
  Endif     
       
  If Not F_ooPicBoxesMuster Then 
    sMessage &= "<h2><font color=blue>" & ("Die Muster-Seite ist (noch) leer.") & "</font></h2>"
    Select Case Message.Question(sMessage, ("Öffnen") & "...", ("Ordner..."), ("Abbrechen"))
      'Case 0 is sMessage
      
      Case 1
        ButtonGroupSelect(ButtonMusterOpen.Tag)
        Goto JumpCancel
        
      Case 2
        If Exist(F_sPathClockMuster_txt) = False Then F_sPathClockMuster_txt = FilePathForm() 'as String
        M01Functions.FileManagerOpen(F_sPathClockMuster_txt)
        Goto JumpCancel
        
      Case 3
        Goto JumpCancel
    End Select
  Endif
  
  sMusterTags = ReadMusterTags() 'as String 
  F_ssPicBoxMusterTags = Split(sMustertags & gb.NewLine, gb.newline)
  
  If F_sLevelsTags And F_ooPicBoxesMuster And F_ssPicBoxMusterTags Then 
      ffMusterSort = New Float[F_ooPicBoxesMuster.Count]
      iiMusterSelect = New Integer[F_ooPicBoxesMuster.Count]
      iiMusterUnselect = New Integer[]
      ssSpliTags = New String[] 
      iLastMax = -1
      iAll = F_ooPicBoxesMuster.Count 
      For it = 0 To F_ooPicBoxesMuster.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 

        ssSpliTags = Split(F_ooPicBoxesMuster[it].Tag & gb.NewLine, gb.NewLine)
        iCounter = 0 'Reset
        For Each sLine In ssSpliTags 
          For Each sLine2 In Split(F_sLevelsTags & gb.NewLine, gb.NewLine)
            If sLine And sLine2 Then 
              If sLine Like "*" & sLine2 & "*" Then iCounter = iCounter + 1
            Endif 
          Next
        Next 
        ffMusterSort[it] = CFloat(Str(iCounter) & "." & Str(it))
        F_ooPicBoxesMuster[it].Background = Color.Default 'Reset
      Next
      
      If ffMusterSort.Empty = False Then 
        ffMusterSort.Sort(gb.Descent) '(gb.Descent) 'Example: 9,8,7...
        For it2 = 0 To F_ooPicBoxesMuster.Max
          iLine = iLine + 1
          If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          fNr = ffMusterSort[it2]
          s3 = Str(fNr)
          s3 = Trim(s3)
          If String.InStr(s3, ".") > 0 Then s2 = "." Else s2 = ","
          ssSpli = Split(s3 & s2, s2)
          If ssSpli Then ' [0|1]
            s1 = ssSpli[1]
            If IsInteger(s1) = True Then it = CInteger(s1) Else it = 0
          Endif
          If it > -1 And it < F_ooPicBoxesMuster.Count Then 
            ' If Not iiMusterSelect Then iiMusterSelect = New Integer[]
            ' If iiMusterSelect.Find(it) = -1 Then 
            iiMusterSelect[it2] = it 'not double
          Endif
        Next
        
        If iiMusterSelect Then 
          iFound = -1
          iTopSelect = -1
          For Each it In iiMusterSelect
            iFound = iFound + 1 
            If iFound < iSelectMax Then
              F_ooPicBoxesMuster[it].Background = F_iColorSelect
              If iTopSelect = -1 Then iTopSelect = iiMusterSelect[0] '- 1 
            Else 
              F_ooPicBoxesMuster[it].Background = Color.Default
            Endif 
          Next
        Endif 
      Endif  
      If F_ooPicBoxesMuster.Exist(F_ooPicBoxesMuster[iTopSelect]) = True Then 
        ' oObjectBefore = F_oLastPicBoxMuster
        F_oLastPicBoxMuster = F_ooPicBoxesMuster[iTopSelect]
      Endif
  Endif 
  iCount = iTopSelect + 1
  ResizePanelMuster()
  ' If oObjectBefore Then F_oLastPicBoxMuster = oObjectBefore
  
  JumpCancel:
  If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter() 'as String  "0/0"
  LabelCounterMuster.Text = ("Ähnlich zum Uhr-Entwurf") & ": " & ("Nr.") & Str(iCount) & Space(1) & ("von") & Space(1) & Str(iAll)
  LabelCounterMuster.Tooltip = LabelCounterMuster.Text
  LabelInfo.Text = "<font color=white><b>" & LabelCounterMuster.Text & "</b></font>"
  LabelInfo.Visible = True 
 
  Catch
  FMain.ErrorText
  
End

Public Sub LoadMuster(Optional sTag As String = Null, Optional bDoubleCheck As Boolean = False)
  
  Dim sLevel, sMuster, sReplace, sNew, sLevelsBefore, sMusterExist, sInfo, sESC As String
  Dim iFound, iOld, iNew, iLine, iCount, iAll, iDouble, iTooMany, iMuster As Integer
  Dim ssSplitGroups As String[]
  Dim bTimerON As Boolean
  Dim sMessage As String
  
  If F_iESCpressed > 0 Then Return 'end here
  
  bTimerON = TimerClock.Enabled
  TimerClock.Stop
  
  sLevelsBefore = ReadLevelsTag()
  
  If bDoubleCheck = True Then 
    ''New without double
    If F_ooPicBoxesMuster Then 
      iOld = F_ooPicBoxesMuster.Count
      ' sOld = ReadMusterTags()
      sNew = Null
    Endif 
  Endif 
  
  ''sTag > level=?
  If sTag And String.InStr(sTag, "level=begin") > 0 Then 
    F_bChangeON = False
    iMuster = M01Functions.TextFindCounter(sTag, "level=begin") 'as Integer
    If iMuster > 100 Then
      sMessage = "<h2><font color=red>" & ("Viele Muster") & "..." & "</font></h2>" 
      sMessage &= "<h1><font color=blue>" & Str(iMuster) & Space(1) & ("einlesen") & "?" & "</font></h1>"
      sMessage &= ("Alle Muster neu berechnen nach aktuellen Einstellungen mit Farb-Palette.")
      Select Case Message.Question(sMessage, ("Weiter einlesen..."), ("Nein"), ("Abbrechen"))
        Case 1 'Go on
          '...
        Case 2, 3
          Goto JumpCancel
          
      End Select
    Endif
    
    'Check "\r" Return,  Type Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
    If String.InStr(sTag, gb.Cr) > 0 Then sTag = Replace(sTag, gb.Cr, Null) '"\r" '(*1) '\r     carriage return, Zeilenvorschub, Chr$(13).
    ' sLevelTags = ReadLevelsTag() 'save at the beginning —▶ Reset
    ' sLevelTags = CheckMusterBeginEnd(sLevelTags, True)'True= Muster 1x
    ' sTag = CheckMusterBeginEnd(sTag, False)'True= Muster 1x
    
    ''Exist:
    sMuster = Null 'reset
    ''sLevel: level=begin —▶ level=end
    ssSplitGroups = Split(sTag & gb.NewLine, gb.NewLine)
    ' iAll = ssSplitGroups.Count
    ' ssSplitGroups = New String[]
    ' ssSplitGroups = Split(sTag & gb.NewLine & "level=begin", "level=begin" & gb.NewLine)
    ' iAll = ssSplitGroups.Count
    ' ProgressBarONoff(True)
    ProgressBar1.Pulse = False
    If ssSplitGroups Then 
      Me.Window.Title = Application.Name & " - " & ("Berechne Muster-Liste") & "..."
      LabelMessageText("<font color=red><b>" & ("Berechne Muster-Liste") & "..." & "</b></font>")
      iCount = ssSplitGroups.Count 
      sReplace = Replace(sTag, "level=begin", "")
      iAll = (String.Len(sTag) - String.Len(sReplace)) / String.Len("level=end")
      ' iCount = Split(sTag & "level=begin", "level=begin").Max
      If iCount < 1 Then iCount = 1 'not 0 (Counter/0=Error)
      For Each sLevel In ssSplitGroups
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True)
        If iLine Mod 100 = 0 Then
          ProgressBar1.Value = iLine / iCount
          Wait 0.000001
          ProgressBar1.Visible = True
        Endif 
        
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        'Check "\r" Return,  Type Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
        ' sLevel = Replace(sLevel, gb.Cr, "") '"\r" '(*1) '\r     carriage return, Zeilenvorschub, Chr$(13).
        If sLevel And String.InStr(String.LCase(sLevel), "=") > 0 Then
          sMuster &= sLevel & gb.NewLine
          ' sMuster = "level=begin" & gb.NewLine & sMuster & sLevel & gb.NewLine
          iTooMany = iTooMany + 1
          If String.InStr(String.LCase(sLevel), "level=end") > 0 Then 
            If iTooMany > 20 Then 
              sInfo = ("Muster Text:") & gb.NewLine
              sInfo &= "level=begin" & gb.NewLine
              sInfo &= "..." & ("zuviele levels im Muster?") & "..." & gb.NewLine
              sInfo &= "level=end" & gb.NewLine
              sInfo &= ("Fehler") & Space(1) & ("Tipp: Andere Datei oder Reset") & gb.NewLine
            Endif 
            If sMusterExist Like "*" & sMuster & "*" Then   
              ''...not double
              iDouble = iDouble + 1
            Else 
              iNew = iNew + 1
              sMusterExist = sMusterExist & gb.NewLine & sMuster
              If F_iESCpressed > 0 Then Break 
              LoadLevelsNewNull()
              LoadLevels(sMuster) 
              ResizePanelLevels()
              SumPaintClockLevels()
              '**************************************
              Add1xMuster(F_picClock, sMuster)
              '**************************************
              sMuster = Null 'reset
              iTooMany = 0
            Endif 
            LabelCounterMuster.Text = ("Muster") & Space(1) & iNew & Space(1) & ("von") & Space(1) & iAll & ", " & ("Doppelt") & ": " & (-iDouble) 
            sMuster = Null 'reset
          Endif 
        Endif 
      Next 
      ' If F_iESCpressed = 0 Then Settings[F_sForm &/ "F_sMusterTags"] = sMusterExist
      If F_iESCpressed > 0 Then sESC = Space(1) & ("Abgebrochen") 
      If F_ooPicBoxesMuster Then iNew = F_ooPicBoxesMuster.Count
      If F_iESCpressed > 0 Then Goto JumpEnd
      ' F_iESCpressed = 0 
      ' MusterColorRefreshSelection()
      ResizePanelMuster()
      
      ''Reset to the beginning:
      LoadLevelsNewNull()
      LoadLevels(sLevelsBefore) 'Reset
      ResizePanelLevels()
      SumPaintClockLevels()
      F_sLevelsTags = sLevelsBefore
      If F_ssPicBoxMusterTags And F_ooPicBoxesMuster Then 
        iFound = F_ssPicBoxMusterTags.Find("*" & Replace(sLevelsBefore, gb.NewLine, "*") & "*")
        If iFound > -1 And iFound < F_ooPicBoxesMuster.Count Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[iFound]
      Endif 
      ResizePanelMuster()
    Endif 
    ' F_oLastPicBoxMuster = Null 'only 1x 
    ' If F_ooPicBoxesMuster And F_sMusterTags Then Settings[F_sForm &/ "F_sMusterTags"] = sMusterExist
  Endif
  
JumpEnd:
  F_bChangeON = True 'Reset
  ' If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
  SideG("muster")
  
  ''Info:
  MusterCounter() 'as String  "0/0"
  If iOld > 0 Then LabelCounterMuster.Text = LabelCounterMuster.Text & Space(1) & ("Neu") & ": " & Space(1) & Str(iNew - iOld) & sESC
  
  If iDouble > 0 Then LabelCounterMuster.Text = LabelCounterMuster.Text & Space(1) & ("Doppelt") & ": " & Space(1) & Str(-iDouble) & sESC
  If sESC Then 
    LabelInfo.Text = LabelCounterMuster.Text 
    LabelInfo.Visible = True 
  Endif 
  
  ''Save undo◀—▶redo
  UndoRedoMusterSelection("save") '0/0
  
  If sInfo Then 
    If String.InStr(FMain.F_sInfoMessagesExtra, sInfo) = 0 Then FMain.F_sInfoMessagesExtra &= sInfo 
  Endif 
  If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter()
  
  JumpCancel:
  TimerClock.Enabled = bTimerON
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub CheckMusterCorrectTags() 
  
  Dim sPath, sLine, sLevelLines, sLevelTags, sLevelTagsNew, sMusterAllBefore, sMusterAll As String
  Dim it, it2, it3, iCount, iLine, iFound, iUnselect, iChange As Integer
  Dim ssSplitGroups, ssSpli, ssGallery, ssExistMuster, ssExistNr As String[]
  Dim sP0, sP1, sP2, sP3, sP4, sP5Rest As String 
  Dim iBefore, iBehind, iDiff As Integer
  
  'sLevelTags Example:
  ' level=begin
  ' level=59=0=1==
  ' level=164=91=1==
  ' level=277=182=1=images/earth-planet_128.png=
  ' level=end
  ' If F_iESCpressed > 0 Then Return 'end here
  
  IconError.Visible = False 
  If Not F_ooPicBoxesMuster Then CheckMusterSideFill()
  If F_ooPicBoxesGallery And F_ooPicBoxesMuster Then
    Me.Window.Title = Application.Name & " - " & MenuCheckDoubleMuster.Text & "..."
    LabelMessageText(MenuCheckDoubleMuster.Text & "...", Color.Red)
    sMusterAllBefore = ReadMusterTags(True) 'True=All
    iBefore = F_ooPicBoxesMuster.Count
    ssExistMuster = New String[]
    ssGallery = New String[]
    If F_ooPicBoxesGallery Then 
      For it = 0 To F_ooPicBoxesGallery.Max
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        ssGallery.Add(F_ooPicBoxesGallery[it].Tag) 'Check found for Muster
      Next 
    Endif
    If F_iESCpressed > 0 Then Goto JumpEnd
    
    ProgressBar1.Pulse = False
    iCount = F_ooPicBoxesMuster.Count
    If F_ooPicBoxesMuster Then 
      For it = 0 To F_ooPicBoxesMuster.Max
        iLine = iLine + 1
        
        If iLine Mod 100 = 0 Then
          ProgressBar1.Value = iLine / iCount
          Wait 0.000001
          ProgressBar1.Visible = True
        Endif 
        
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        sLevelTags = F_ooPicBoxesMuster[it].Tag ''——▶
        ssExistNr = New String[]
        ssSplitGroups = Split(sLevelTags & gb.NewLine, gb.NewLine)
        
        For it2 = 0 To ssSplitGroups.Max 'level=begin .... level=end
          iLine = iLine + 1
          ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif  
          ProgressBar1.Pulse = False
          
          sLine = ssSplitGroups[it2]
          If sLine Then 
            If String.InStr(sLine, "colorchange=") > 0 Or sLine Like "*color*=*" Then 
              sLevelTagsNew &= CheckColorChangeLine(sLine) & gb.NewLine
            Else If String.InStr(sLine, "edit=") > 0 Then 
              sLevelTagsNew &= CheckEditLine(sLine) & gb.NewLine
            Else 
              sP0 = Null  'Reset
              sP1 = Null
              sP2 = Null
              sP3 = Null
              sP4 = Null
              sP5Rest = Null
              If sLine Like "*=*" Then 
                ssSpli = Split(sLine & "=", "=")
                ''level=number=left=selected=path= '0=1=2=3=4=
                For it3 = 0 To ssSpli.Max
                  If it3 = 0 Then sP0 = Trim(ssSpli[it3])
                  If it3 = 1 Then sP1 = Trim(ssSpli[it3])
                  If it3 = 2 Then sP2 = Trim(ssSpli[it3])
                  If it3 = 3 Then sP3 = Trim(ssSpli[it3])
                  If it3 = 4 Then sP4 = Trim(ssSpli[it3])'/ Path?
                  If it3 > 4 Then sP5Rest &= Trim(ssSpli[it3]) & "="
                Next 
                If ssExistNr.Find(sP1) = -1 Then 
                  ssExistNr.Add(sP1) 
                  If sP0 Like "*level*" Then sP0 = "level"
                  If IsInteger(sP1) = True Then sP1 = CInteger(sP1) 'Nr
                  If IsInteger(sP2) = True Then sP2 = CInteger(sP2) '.Left
                  If IsInteger(sP3) = True Then sP3 = CInteger(sP3) '.Selected
                  If Exist(sP4) = True Then sPath = sP4 Else sPath = ""
                  iFound = ssGallery.Find(sPath)
                  If iFound > -1 Then ''Change Picture-Number 
                    iFound = iFound + 1 
                    If iFound > F_ooPicBoxesGallery.Count Then iFound = F_ooPicBoxesGallery.Count
                    sP1 = iFound
                  Endif
                  
                  If sP3 = 1 Then 'Selected
                    If IsInteger(sP3) = True And F_ssEditLevels Then 
                      iFound = CInteger(sP3)
                      If iFound < F_ssEditLevels.Count Then 
                        sP4 = F_ssEditLevels[iFound]
                        If sP4 And String.InStr(sP4, "/") = 0 Then sP0 = "edit"
                      Endif 
                    Endif  
                    ''level=number=left=selected=path= '0=1=2=3=4=
                    ''Lines...
                    sLevelTagsNew &= sP0 & "=" & sP1 & "=" & sP2 & "=" & sP3 & "=" & sP4 & "=" & gb.NewLine
                  Else
                    ''... no select
                    iUnselect = iUnselect + 1 
                  Endif
                Endif  
              Endif 
            Endif 
          Endif 
        Next 
        If F_iESCpressed > 0 Then Break
        iChange = iChange + 1
        ' If sLevelTagsNew Then 
        sLevelLines = sLevelTagsNew 
        If String.InStr(sLevelTagsNew, "level=begin") = 0 Then sLevelTagsNew = "level=begin" & gb.NewLine & sLevelLines
        If String.InStr(sLevelTagsNew, "level=end") = 0 Then sLevelTagsNew = sLevelTagsNew & "level=end" & gb.NewLine 
        ' sLevelTagsNew = "level=begin" & gb.NewLine & sLevelTagsNew & "level=end" & gb.NewLine & gb.NewLine
        If ssExistMuster.Find("*" & sLevelTagsNew & "*", gb.Like) = -1 Then 
          ssExistMuster.Add(sLevelTagsNew)
          ' F_ooPicBoxesMuster[it].Tag = sLevelTagsNew ''◀——
          sMusterAll &= sLevelTagsNew & gb.NewLine
        Endif 
        
        sLevelTagsNew = Null 'Reset
      Next 
      MusterNullNew()
      LoadMuster(sMusterAll)
      ResizePanelMuster()
      ' If ssExistMuster Then iBehind = ssExistMuster.Count
      If F_ooPicBoxesMuster Then iBehind = F_ooPicBoxesMuster.Count
      iDiff = iBehind - iBefore
      ' If iDiff < 1 Then sLinesMinus = ("korrigiert") & ", " & ("weniger Zeilen") & ": " & Str(iDiff) Else sLinesMinus = ("korrigiert") & ", " & ("mehr Zeilen") & ": +" & Str(iDiff)
      ' LabelInfo.Text = "<font color=white><b>" & iBehind & Space(1) & ("von") & Space(1) & iBefore & ", " & sLinesMinus & "</b></font>"
      LabelInfo.Text = MenuCorrectTags.Text & "..." & ("fertig") & ". " & "<font color=white><b>" & ("Muster") & Space(1) & iBehind & Space(1) & ("von") & Space(1) & iBefore & Space(1) & ("Differenz") & ": " & Str(iDiff) & "</b></font>"
      LabelInfo.Visible = True
      ' LabelInfo.Text= iMuster & Space(1) & ("von") & Space(1) & iCount & Space(1) & ("Doppelt") & ": " & (-iDiff) 
      LabelMessageText(LabelInfo.Text, Color.Blue)
      
    Endif  
    F_bMusterSideChanged = True
  Endif 
  
JumpEnd:
  If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Function CheckColorChangeLine(Optional sColorChange As String = "") As String 
  
  Dim ssSpli As String[]
  Dim it, iPos As Integer
  Dim sColorChangeCorrectLine As String
  
  ssSpli = Split(sColorChange & String(F_iColorsCount, "="), "=")
  ' Example: "colorchange=65280=8421631=16744576=12632256=4210752=16777215=1073807104=16762880=-1774174144=0=0="
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii
  ssSpli.Resize(F_iiIconClockColorsA.Count)
  
  For it = 0 To F_iiIconClockColorsA.Max 'colorchange ist 0, begin with 1
    iPos = it + 1
    If iPos < ssSpli.Count Then 
      If IsInteger(ssSpli[iPos]) = False Then ssSpli[iPos] = F_iiIconClockColorsA[it] 'if not Color then Default-Color
      sColorChangeCorrectLine &= ssSpli[iPos] & "="
    Endif 
  Next
  If sColorChangeCorrectLine Then sColorChangeCorrectLine = "colorchange" & "=" & sColorChangeCorrectLine
  
  Return sColorChangeCorrectLine
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckEditLine(Optional sEditLine As String = "") As String 
  
  Dim ssSpli, ssExist As String[]
  Dim iiExist As Integer[]
  Dim it As Integer
  Dim sEditCorrectLine As String
  
  If F_ssEditTagsWords Then 
    ''F_ssEditTagsWords = ["mirrorleftright", "mirrortopbottom", "rotateleft", "rotateright", "grayscale", "scaleminus", "scaleplus", "moveleft", "moveright", "moveup", "movedown", "fontsizeminus", "fontsizestandard", "fontsizeplus"]
    ssExist = New String[]
    iiExist = New Integer[F_ssEditTagsWords.Count]
    
    ''level=number=left=selected=path= '0=1=2=3=4=
    ' Example: "edit=146=182=1=scaleplus=scaleplus=scaleminus="
    ssSpli = Split(sEditLine & "=", "=")
    If ssSpli.Count > 3 Then 
      If IsInteger(ssSpli[1]) = False Then ssSpli[1] = "0"
      If IsInteger(ssSpli[2]) = False Then ssSpli[2] = "0"
      If IsInteger(ssSpli[3]) = False Then ssSpli[3] = "0"
      If ssSpli[3] = "0" Or ssSpli[3] = "1" Then 
        ''...
      Else 
        ssSpli[3] = "1" '.Visible=True, Selected
      Endif
    Endif
    
    For it = 4 To ssSpli.Max
      If TypeOf(ssSpli[it]) = gb.String Then 
        Select Case Trim(ssSpli[it])
          Case "mirrorleftright"
            iiExist[0] = iiExist[0] + 1
            iiExist[1] = iiExist[1] - 1
          Case "mirrortopbottom"
            iiExist[1] = iiExist[1] + 1
            iiExist[0] = iiExist[0] - 1
            
          Case "rotateleft"
            iiExist[2] = iiExist[2] + 1  
            iiExist[3] = iiExist[3] - 1
          Case "rotateright"
            iiExist[3] = iiExist[3] + 1  
            iiExist[2] = iiExist[2] - 1
            
          Case "grayscale" 'only 1x
            ' iiExist[4] = iiExist[4] + 1  
            iiExist[4] = 1  
            
          Case "scaleminus"
            iiExist[5] = iiExist[5] + 1 
            iiExist[6] = iiExist[6] - 1
          Case "scaleplus"
            iiExist[6] = iiExist[6] + 1 
            iiExist[5] = iiExist[5] - 1
            
          Case "moveleft"
            iiExist[7] = iiExist[7] + 1
            iiExist[8] = iiExist[8] - 1
          Case "moveright"
            iiExist[8] = iiExist[8] + 1 
            iiExist[7] = iiExist[7] - 1
            
          Case "moveup"
            iiExist[9] = iiExist[9] + 1 
            iiExist[10] = iiExist[10] - 1
          Case "movedown"
            iiExist[10] = iiExist[10] + 1 
            iiExist[9] = iiExist[9] - 1
            
          Case "fontsizeminus"
            iiExist[11] = iiExist[11] + 1 
            iiExist[13] = iiExist[13] - 1
          Case "fontsizestandard"
            iiExist[12] = 0
          Case "fontsizeplus"
            iiExist[13] = iiExist[13] + 1 
            iiExist[11] = iiExist[11] - 1
            
        End Select
        
      Endif
    Next
    
    For it = 0 To F_ssEditTagsWords.Max
      If iiExist[it] > 0 Then sEditCorrectLine &= String(iiExist[it], F_ssEditTagsWords[it] & "=")
    Next  
    If sEditCorrectLine Then sEditCorrectLine = "edit" & "=" & ssSpli[1] & "=" & ssSpli[2] & "=" & ssSpli[3] & "=" & sEditCorrectLine    
  Else 
    ' sEditCorrectLine = sEditCorrectLine 'Null
  Endif 
  
  Return sEditCorrectLine
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterCut(Optional oObj As Object = Null)
  
  Dim sTag As String 
  Dim it, iLine, iPic, iFound, iFirst, iCut, iReload, iAll As Integer
  Dim picCancel, picReload As Picture
  
  ' Settings[F_sForm &/ "F_sMusterTags"] = ReadMusterTags(True)
  ' UndoRedoMusterSave(Settings[F_sForm &/ "F_sMusterTags"])
  
  If F_ooPicBoxesMuster Then 
    picCancel = PicTemplateCloseCancel22.Picture 'Picture["icon:/22/close"]
    picReload = ListReload.Picture.Image.Stretch(22, 22).Picture
    F_oLastPicBoxObject = Null
    iFirst = -1
    iFound = -1
    If oObj Then '1x
      iFound = F_ooButtonMuster.Find(oObj) 'as Integer -1 not found
      If iFound = -1 Then iFound = F_ooPicBoxesMuster.Find(oObj)
      If iFound = -1 Then oObj = Null
      iCut = 1
      iAll = 1
    Endif 
    
    If Not oObj Then ''selection
      
      iCut = 0
      iAll = F_ooPicBoxesMuster.Count
      For it = 0 To F_ooPicBoxesMuster.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif  
        
        If F_ooPicBoxesMuster[it].Background <> F_iColorSelect Then 
          sTag = sTag & F_ooPicBoxesMuster[it].Tag & gb.NewLine
          F_ooButtonMuster[it].Picture = picCancel '□
        Else
          If iFirst = -1 Then iFirst = it
          If iPic = 0 And Not F_ooPicBoxesMuster[it].Picture Then iPic = 1
          ' F_ooPicBoxesMuster[it].Tag = Null
          If iPic = 0 Then 
            F_ooPicBoxesMuster[it].Picture = Null
            F_ooButtonMuster[it].Picture = picReload  '■
            iCut = iCut + 1
          Else 
            F_ooPicBoxesMuster[it].Picture = LoadMusterOnePicture(F_ooPicBoxesMuster[it].Tag) 'as Picture
            sTag = sTag & F_ooPicBoxesMuster[it].Tag & gb.NewLine
            F_ooPicBoxesMuster[it].Background = F_iColorSelect
            F_ooButtonMuster[it].Picture = picCancel
            iReload = iReload + 1  
          Endif 
        Endif 
      Next
    Else ''[x] '1x  
      
      iCut = 0
      iAll = F_ooPicBoxesMuster.Count
      For it = 0 To F_ooPicBoxesMuster.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif  
        
        If it <> iFound Then 
          sTag = sTag & F_ooPicBoxesMuster[it].Tag & gb.NewLine
        Else
          If iFirst = -1 Then iFirst = it
          ' F_ooPicBoxesMuster[it].Tag = Null
          ''Cut:
          If F_ooPicBoxesMuster[it].Picture Then 
            F_ooPicBoxesMuster[it].Picture = Null
            F_ooPicBoxesMuster[it].Background = F_iColorSelect
            F_ooButtonMuster[it].Picture = picReload
            iCut = iCut + 1
          Else ''New Refresh:
            F_ooPicBoxesMuster[it].Picture = LoadMusterOnePicture(F_ooPicBoxesMuster[it].Tag) 'as Picture
            sTag = sTag & F_ooPicBoxesMuster[it].Tag & gb.NewLine
            F_ooPicBoxesMuster[it].Background = F_iColorSelect
            F_ooButtonMuster[it].Picture = picCancel
            iReload = iReload + 1
          Endif 
          
        Endif 
      Next
    Endif 
    
    ' Settings[F_sForm &/ "F_sMusterTags"] = sTag 'Rest or Null (Selectall)
    
    If iCut > 0 Then LabelCounterMuster.Text = ("Ausgeschnitten") & ": " & Str(iCut) & Space(1) & ("von") & Space(1) & Str(iAll) & Space(1)
    If iReload > 0 Then LabelCounterMuster.Text = ("Wiederhergestellt") & ": " & Str(iReload) & Space(1) & ("von") & Space(1) & Str(iAll)  
    
    LabelInfo.Text = "<font color=white><b>" & LabelCounterMuster.Text & "</b></font>"
    LabelInfo.Visible = True 
    LabelMessageText("<font color=red><b>" & LabelCounterMuster.Text & "</b></font>")
    ' UndoRedoMusterSave(sTag)
    F_bMusterSideChanged = True
  Endif 
  
JumpEnd:
  
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch
  FMain.ErrorText
  
End

Public Sub MusterCutSortNew()''???
  
  Dim sTag As String 
  Dim it, iLine, iNrNew, iCut, iAll As Integer
  ' Dim picCancel, picReload As Picture
  Dim ooPictureMuster As Object[]
  Dim ssTagMuster As String[]
  Dim iiCutSortNew As Integer[]
  
  ' Settings[F_sForm &/ "F_sMusterTags"] = ReadMusterTags(True)
  ' UndoRedoMusterSave(Settings[F_sForm &/ "F_sMusterTags"])
  
  If F_ooPicBoxesMuster Then 
    Me.Window.Title = Application.Name & " - " & MenuCheckDoubleMuster.Text & "..."
    ooPictureMuster = New Object[]
    ssTagMuster = New String[]
    iiCutSortNew = New Integer[]
    ' picCancel = PicTemplateCloseCancel22.Picture 'Picture["icon:/22/close"]
    ' picReload = ListReload.Picture.Image.Stretch(22, 22).Picture
    F_oLastPicBoxObject = Null
    
    iCut = 0
    iAll = F_ooPicBoxesMuster.Count
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif  
      
      If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then 
        iCut = iCut + 1
      Else 
        iNrNew = iNrNew + 1
        ' F_ooPicBoxesMuster[it].ToolTip = iNrNew
        ' iiCutSortNew.Add(iNrNew)
        ooPictureMuster.Add(F_ooPicBoxesMuster[it].Picture)
        ssTagMuster.Add(F_ooPicBoxesMuster[it].Tag)
        ' sTag = sTag & F_ooPicBoxesMuster[it].Tag & gb.NewLine
        ' F_ooButtonMuster[it].Picture = picCancel
      Endif 
    Next
    F_ooPicBoxesMuster.Clear
    F_ooButtonMuster.Clear
    ScrollViewMuster.Children.Clear
    
    For it = 0 To ooPictureMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif  
      
      Add1xMuster(ooPictureMuster[it], ssTagMuster[it])
    Next
    
    ' F_ooPicBoxesMuster = Null
    ' F_ooPicBoxesMuster = ooPicBoxesMuster'.Copy
    ' F_ooButtonMuster = Null
    ' F_ooButtonMuster = ooButtonMuster'.Copy
    
    sTag = ""
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif  
      
      sTag &= F_ooPicBoxesMuster[it].Tag & gb.NewLine & gb.NewLine
    Next
    ' ResizePanelMuster(iiCutSortNew)
    ResizePanelMuster()
    ' Settings[F_sForm &/ "F_sMusterTags"] = sTag 'Rest or Null (Selectall)
    MusterCounter() 'as String  "0/0"
    LabelCounterMuster.Text = ("Ausgeschnitten") & ": " & Str(iCut) & Space(1) & ("von") & Space(1) & Str(iAll)
    LabelInfo.Text = "<font color=white><b>" & LabelCounterMuster.Text & "</b></font>"
    LabelInfo.Visible = True 
    LabelMessageText("<font color=red><b>" & LabelCounterMuster.Text & "</b></font>")
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h()
  
  Dim it, it2 As Integer
  Dim sZeile As String
  Dim iCounter As Integer
  Dim sValueBox1Text As String
  
  sValueBox1Text = "12:00"
  If F_dateNow Then sValueBox1Text = Format(F_dateNow, "hh:nn") 'String.Left(ValueBox1.Text, 5) 'as String 'ValueBox1.Type = Time
  
  ColumnView3.Clear()
  'ColumnView3.Header = 1 ' Sichtbar
  ColumnView3.Sorted = False ' nicht sortieren!
  'ColumnView2.Columns.Sort = TRUE
  'Spalten (Columns) erzeugen
  ColumnView3.Columns.Count = 1
  ColumnView3.Columns[0].Width = ColumnView3.Width
  
  For it = 0 To 23 'Stunden SS:
    For it2 = 0 To 59 'Minuten :MM
      sZeile = Format(it, "00") & ":" & Format(it2, "00")
      iCounter = iCounter + 1
      ColumnView3.Add(iCounter, sZeile)
      If it2 Mod 10 = 0 Then 
        ColumnView3[iCounter].Foreground = Color.Default 
      Else 
        ColumnView3[iCounter].Foreground = Color.Gray  
      Endif 
      If sValueBox1Text = ColumnView3[iCounter].Text Then
        ColumnView3[iCounter].Selected = True
        ColumnView3[iCounter].EnsureVisible
      Endif
    Next
  Next
  sZeile = "00:00"
  iCounter = iCounter + 1
  ColumnView3.Add(iCounter, sZeile)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonTimeListCancel_Click()
  
End

Public Sub ColumnView3_MouseUp()
  
  Dim dDate, dTime As Date 
  
  If ColumnView3.Current.Text Then 
    TimerClock.Stop()
    dDate = DateChooser1.Value 'as Date
    dTime = CDate(ColumnView3.Current.Text) '00:00 (*1)
    F_dateNow = Date(Year(dDate), Month(dDate), Day(dDate), Hour(dTime), Minute(dTime), Second(dTime)) 'as Date 
    DateChooser1.Value = F_dateNow
    F_iSecondCounter = 0
    DateTimeCheck()
  Endif 
  
  ''______________________________________________________________________________________________''
  '(*1) Gambas3: "CDate(): Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Hier nur bei hh:nn
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonClose_Click()
  
  Me.Window.Close
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelTimePause_MouseDown()
  
  If FMain.F_iClockMap0Stop1Count2Digital3Design4 = 0 Then ButtonSchongangSwitchG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelTimePause_Enter()
  
  LabelTimePause.Background = Color.LightBackground
  
End

Public Sub LabelTimePause_Leave()
  
  LabelTimePause.Background = Color.Default
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Me.Window.Maximized = Not Me.Window.Maximized 
  If Me.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Me.Window.FullScreen = True Or Me.Window.Maximized = True Then 
      F_bMovingON = False
      Me.Window.FullScreen = False
      Me.Window.Maximized = False
      If Me.Left + Me.W > Screen.AvailableWidth Then Me.Move(Me.Left, Me.Top, Screen.AvailableWidth - Me.Left, Screen.AvailableHeight - Me.Top)
    Else
      F_bMovingON = True
      Me.Window.FullScreen = False
      Me.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Me.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Me.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Me.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Me.W = Mouse.ScreenX - F_iX1
    Me.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Me.ClientW - WindowStretch.W, Me.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Me.Window.Maximized = Not Me.Window.Maximized 
    If Me.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = F_iColorSelect
  LabelMessageText(WindowStretch.Tag)
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Me.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then MenuFile.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonFotoG()
  
  'Me.Minimized = True
  Form15Foto.Window.Show
  ' Form15Foto.Window.Visible = True 'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelMessageText(Optional sText As String = "", Optional iColorText As Integer = Color.DarkGray)
  
  LabelMessage.Background = Color.Default
  If F_bChangeON = True Then
    LabelMessage.Visible = True 
    LabelMessage.Text = sText 
    LabelMessage.Tooltip = SText
    LabelMessage.Foreground = iColorText
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconSizeMenu(Optional sLastTag As String)
  
  Dim sMessage, sInfo, sPath, sZoom As String 
  Dim iSize As Integer
  Dim picZoom As Picture
  
  If IsInteger(sLastTag) = True Then iSize = CInteger(sLastTag)
  
  If F_iIconSize <> iSize Then 
    picZoom = PicBoxZoomPlus.Picture
    sPath = M01Functions.TempDirFile("zoom.png")
    If picZoom And IsDir(File.Dir(sPath)) = True Then picZoom.Save(sPath)
    sMessage = "<h2><font color=gray>" & ("Icon-Größe ändern") & "?" & "</font></h2>"
    If Exist(sPath) = True Then sZoom = "<img src=" & Quote("file://" & sPath) & " width=50 height=50 >" 
    If iSize > 128 Then 
      sInfo = Space(1) & "=" & Space(1) & "<font color=red><b>" & ("langsamer") & "</b></font>"
    Endif 
    sMessage &= "<h2>" & "□ " & iSize & " x " & iSize & Space(1) & "px " & ("(Pixel, Breite x Höhe)") & sInfo & "</h2>"
    
    sInfo = "" 
    sMessage &= "<h2>" & "■ " & F_iIconSize & " x " & F_iIconSize & Space(1) & "px " & ("(Pixel, Breite x Höhe)") & sInfo & "</h2>"
    
    sMessage &= "<h4>" & sZoom & "<font color=gray>" & ("Tipp") & Space(1) & ("-Zoom+") & ": " & ("Die tatsächliche Bild-Grösse in Pixeln bleibt mit Zoom unverändert.") & "</font></h4>"
    
    Select Case Message.Question(sMessage, "□ " & ("Ändern") & " = " & iSize & "px", "■ " & ("Nein, behalten") & " = " & F_iIconSize & "px", ("Abbrechen"))
      Case 1  '"□ "
        Settings[F_sForm &/ "F_iIconSize"] = iSize
        SaveLevelTags()
        DefaultNewLevelsGallery()
        OriginalPicturesTemp()
        CheckMenu1()
      Case 2  '"■ "
        Settings[F_sForm &/ "F_iIconSize"] = F_iIconSize
        SaveLevelTags()
        DefaultNewLevelsGallery()
        OriginalPicturesTemp()
        CheckMenu1()
      Case 3 'Cancel
        ''...
    End Select 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub OriginalPicturesTemp()
  
  Dim it As Integer
  Dim sDir, sFile, sPath, sPattern As String 
  Dim ssFiles As String[]
  Dim hPic As Picture
  
  If F_ooPicBoxesLevels Then 
    sPattern = "*.png" ' if more Format then Example: "*.{png,jpg}" 
    sDir = M01Functions.CheckDirectoryCache() '"/tmp/gambas.<UserId>/<ProcessId>/<Prefix>.tmp"
    ssFiles = Dir(sDir, sPattern, gb.File) 'as String[]
    If ssFiles Then 
      For it = 0 To F_ooPicBoxesLevels.Max
        sPath = F_ooPicBoxesLevels[it].Tag   'ToolTip & ".tmp.png" 'Example: "123.tmp.png"
        If ssFiles.Find(sPath) > -1 Then 
          sFile = File.Name(sPath)
          hPic = F_ooPicBoxesLevels[it].Picture
          Try hPic.Save(sDir &/ sFile) 'Refresh picture with new IconSize
        Endif 
      Next
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG(Optional sDirFile As String = "")
  
  If Exist(sDirFile) = True Then 
    Form19FileInfo.Tag = sDirFile
  Else 
    Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Endif
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True 'Wayland error?
  
Catch 
  FMain.ErrorText
  
End 

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = "<font color=white><b>" & File.Name(sDirFile) & "</b></font>" & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub OpenExtern(Optional sImageFormat As String = "png")
  
  Dim sDir, sFile, sPath As String
  Dim hPic As Picture
  Dim oObj As Object
  Dim sNumber As String 
  
  ''Exist File?
  If PanelGallery.Visible = True Or PanelColorSave1.Visible = True Then 
    oObj = F_oLastPicBoxObject
  Else If PanelMuster.Visible = True Then 
    oObj = F_oLastPicBoxMuster
  Endif  
  
  If Object.IsValid(oObj) = False Then oObj = PicBoxSelectLevelONoff
  
  If Object.IsValid(oObj) = True Then 
    If Object.Type(oObj) = "PictureBox" Then  
      sPath = oObj.Tag
      If oObj.Picture Then hPic = oObj.Picture
      sNumber = oObj.ToolTip
    Endif 
    
    ''Alternative: Save as temp-file:
    If hPic And Exist(sPath) = False Then   
      sDir = M01Functions.CheckDirectoryCache() '"/tmp/gambas.<UserId>/<ProcessId>/<Prefix>.tmp"
      sFile = sNumber & ".tmp." & sImageFormat
      sFile = FileNameClear(sFile) 'as String
      sPath = File.Dir(sDir) &/ sFile 'Directory program-cache
      hPic.Save(sPath)
    Endif 
    
    ''Check:
    If Exist(sPath) = True Then 
      hPic = Picture.Load(sPath)
      PicBoxCopyExtern.Picture = hPic
      ''Open-Extern: 
      Desktop.Open(sPath) 
      ' Wait 2
      PicBoxCopyExtern.Picture = PicTemplateOpenExtern1.Picture '?
    Endif 
  Endif 
  
  ''Check:
  If Exist(sPath) = False Then LabelMessageText("<font color=red><b>" & ("Ein Bild markieren (Mittel-Klick)") & ". " & PicBoxCopyExtern.Tooltip & "</b></font>")
  
Catch 
  FMain.ErrorText
  
End

Public Function FileNameClear(Optional sName As String = "") As String 
  
  sName = Replace(sName, "/", "_")
  sName = Replace(sName, Space(1), "_")
  
  Return sName
  
Catch 
  FMain.ErrorText
  
End

Public Function PictureSelect() As Picture
  
  Dim oObj As Object
  Dim picSelect As Picture
  Dim sPath, sExtern, sMessage, sMissing, sInfo As String 
  
  If PanelGallery.Visible = True Or PanelColorSave1.Visible = True Then 
    oObj = F_oLastPicBoxObject
  Else If PanelGallery.Visible = True Then 
    oObj = F_oLastPicBoxMuster
  Endif  
  If Object.IsValid(oObj) = False Then oObj = PicBoxSelectLevelONoff
  
  If Object.IsValid(oObj) = True Then picSelect = oObj.Picture
  If Not picSelect And PicBoxSelectLevelONoff.Picture Then picSelect = PicBoxSelectLevelONoff.Picture
  sPath = M01Functions.TempDirFile("copy.png")
  If picSelect Then 
    picSelect.Save(sPath)
    CopyToClipboard(picSelect)
    If Clipboard.Format <> Clipboard.Image Then sMissing &= ("Nicht in der Zwischenablage") & "<br>"
    
  Endif 
  
  If Exist(sPath) = False Then 
    sMissing = ("Auswahl fehlt") & "<br>"
  Else 
    sInfo = "<font color=blue><b>" & File.Name(sPath) & "</b></font>" & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPath).Size) & "</font>"
  Endif 
  If sMissing Then sMissing = "<font color=red><b>" & sMissing & "</b></font>"
  
  sMessage = "<font color=gray>" & ("Auswahl mit Mittel-Klick") & "</font>"
  sMessage &= "<h3>"
  sMessage &= "<img src=" & Quote("file://" & sPath) & " width=100 height=100 >" & "<br>" 
  sMessage &= ("Bild in der") & Space(1) & ("[Zwischenablage]") & Space(1) & "<br>" & "<br>"
  sMessage &= ("Bereit zum 'Einfügen' in andere Programme") 
  sMessage &= "</h3>"
  sMessage &= sInfo & "<br>"
  sMessage &= sMissing & "<br>"
  
  Select Case Message.Question(sMessage, ("Öffnen im Standard-Programm"), ("Ordner..."), ("Abbrechen"))
    Case 1 'open
      sExtern = M01Functions.ExternStandardProgramName("image/png") 'as String 
      If Exist(sPath) = True Then M01Functions.ExternStart(sExtern, sPath)
    Case 2 'Directory
      M01Functions.FileManagerOpen(sPath)
    Case 3 'Cancel
      '...
  End Select
  
  Return picSelect
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyToClipboard(Optional picSelect As Picture = Null)
  
  If picSelect Then 
    PicBoxPaste.Background = Color.Blue '■
    ' Clipboard.Clear() 'no longer?
    Clipboard.Copy(picSelect.Image) ' copy in Clipboard "[Zwischenablage]"
    If Clipboard.Type = Clipboard.Image Then PicBoxPaste.Picture = Clipboard.Paste().Picture
    Wait 1
    PicBoxPaste.Background = Color.Default '□
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckSaveBefore() As String 
  
  Dim sDir, sFile, sDirFile, sInfoFile As String 
  Dim sExistFiles, sMessage As String
  Dim iExistFiles As Integer
  Dim HTMLgreen, HTMLred, HTMLend As String 
  
  HTMLgreen = "<font color=darkgreen><b>" & "□ "
  HTMLred = "<font color=red><b>" & "■ "
  HTMLend = "</b></font>"
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  If Exist(sDir) = False Then Try Mkdir sDir
  If Exist(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  
  ' SumPaintClockLevels() ' Refresh, new Picture
  
  ''Check:    templates
  If F_imgClockBG Then 
    sFile = "clockbackground.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgClockCutter Then 
    sFile = "clockcutter.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgGearWheel Then 
    sFile = "clockgearwheel.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgNightSky Then 
    sFile = "clocknightsky.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgTimeSummer Then 
    sFile = "clocktimesummer.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgSunUpDown Then 
    sFile = "clocksunupdown.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgClockNumbers Then 
    sFile = "clocknumbers.png"  '0-3-6-9-12 or 15-18-21-24
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgHour Then 
    sFile = "clockhour.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgMinute Then 
    sFile = "clockminute.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgSecond Then 
    sFile = "clocksecond.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgCenterPoint Then 
    sFile = "clockcenterpoint.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgDatePoint Then 
    sFile = "clockdatepoint.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgDigital Then 
    sFile = "clockdigital.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_imgLCD Then 
    sFile = "clocklcd.png" 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif
  
  If F_picClock Then    'Images —▶ Picture
    sFile = F_sFileClockMusterLastTemp_PNG 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
    sFile = F_sFileClockMusterLastTemp_TXT 
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then 
      sInfoFile = InfoFileModifiedSize(sDirFile) 'as String 
      sExistFiles &= HTMLred & sFile & sInfoFile & HTMLend & "<br>" 
      iExistFiles = iExistFiles + 1
    Else 
      sExistFiles &= HTMLgreen & sFile & HTMLend & "<br>"   
    Endif 
  Endif 
  
  If sExistFiles Then 
    sExistFiles &= "<br>" & HTMLred & Str(iExistFiles) & Space(1) & ("Dateien werden überschrieben und aktualisiert") & HTMLend & "<br>"
  Endif 
  If Exist(sDir) = False Then sExistFiles &= "<br>" & HTMLred & ("Ordner fehlt") & HTMLend & "<br>" 
  sMessage = "<font color=blue>" & sDir &/ "..." & "</font>" & "<br><br>" 
  
  sMessage &= sExistFiles
  
  Return sMessage
  
Catch 
  FMain.ErrorText
  
End

Public Function InfoFileModifiedSize(Optional sDirFile As String = "") As String 
  
  Dim sInfoFile As String 
  
  If Exist(sDirFile) = True Then 
    sInfoFile = Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Else 
    sInfoFile = Space(1) & "<font color=red>" & ("Fehlt") & "</font>"
  Endif 
  
  Return sInfoFile
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG()
  
  Dim sDir, sFile, sDirFile, sLastClockLevelsTags, sPathMedia, sPathPNG, sPathTXT, sPathPNG2, sPathTXT2, sMessage As String 
  Dim bSave, bTimer1, bTimer2, bTimerON As Boolean
  Dim sPathCache1, sPathCache2 As String
  Dim picMessage1, picMessage2 As Picture
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  If Exist(sDir) = False Then Try Mkdir sDir
  If Exist(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  ''Clock Muster: complete
  sFile = F_sFileClockMusterLastTemp_PNG 
  sDirFile = sDir &/ sFile
  ' SumPaintClockLevels() ' Refresh, new Picture
  
  bTimer1 = TimerClock.Enabled 
  bTimer2 = TimerColorPicker.Enabled 
  TimerClock.Stop()
  TimerColorPicker.Stop()
  
  sMessage = CheckSaveBefore()  'as String 
  If Error Then 
    IconError.Visible = True 
    Error.Clear
  Endif 
  
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
  picMessage1 = FMain.F_picClock
  If Not picMessage1 Then picMessage1 = PicTemplateQuestion.Picture
  If picMessage1 Then picMessage1.Save(sPathCache1)
  
  sPathCache2 = M01Functions.TempDirFile("2.png") ' Temp() & ".png"
  picMessage2 = Me.F_picClock
  If Not picMessage2 Then picMessage2 = PicTemplateQuestion.Picture
  If picMessage2 Then picMessage2.Save(sPathCache2)
  
  If Exist(sPathCache1) = True Then 
    sMessage &= "<h3><img src=" & Quote("file://" & sPathCache1) & " width=100 height=100 >" & Space(1) & "<font color=darkgreen>" & ("Aktuell im Hauptfenster") & "</font></h3>"
  Endif 
  If Exist(sPathCache2) = True Then 
    sMessage &= "<h3><img src=" & Quote("file://" & sPathCache2) & " width=100 height=100 >" & Space(1) & "<font color=blue>" & ("Neu") & "</font></h3>"
  Endif 
  
  If F_imgTimeSummer Or F_imgNightSky Or F_imgDatePoint Then 
    sMessage &= "<h3><font color=gray>" & ("Hinweis: Einige bewegliche Teile erscheinen nur zu bestimmten Zeiten im Hauptfenster.") & "</font></h3>"
  Endif
  
  sMessage &= "<h3><font color=blue>" & "● " & ("Speichern?") & "</font></h3>" 
  
  ''Info, Save?
  Select Case Message.Question(sMessage, "● " & ("Speichern"), ("Ordner..."), ("Abbrechen"))
    Case 1  ''Save
      bSave = True
      
    Case 2  ''Directory...
      If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      ' Desktop.Open(sDir)
      M01Functions.FileManagerOpen(sDirFile)
      
    Case 3  ''Cancel
      ''...
  End Select
  
  ''Save...
  If bSave = True Then
    SettingsColorsUserReadSave("save")
    sMessage = CheckSaveBehind() 'as String  in User.Home
    
    bTimerON = FMain.Timer1.Enabled
    FMain.Timer1.Enabled = False 
    
    ''Settings for FMain: 
    FMain.F_bWhiteBorderON = Me.F_bWhiteBorderON
    Settings[FMain.Name &/ "F_bWhiteBorderON"] = Me.F_bWhiteBorderON
    FMain.F_fFontSizePlus = Me.F_fFontSizePlus
    Settings[FMain.Name &/ "F_fFontSizePlus"] = Me.F_fFontSizePlus
    FMain.F_iIconSize = Me.F_iIconSize
    Settings[FMain.Name &/ "F_iIconSize"] = Me.F_iIconSize
    
    ' Settings[FMain.Name &/ "F_iiIconClockColorsA"] = Me.F_iiIconClockColorsA
    FMain.F_iiIconClockColorsB = Me.F_iiIconClockColorsB'.Copy()
    Settings[FMain.Name &/ "F_iiIconClockColorsB"] = Me.F_iiIconClockColorsB'.Copy() 'save only here (nur hier speichern)
    Settings[F_sForm &/ "F_iiIconClockColorsB"] = Me.F_iiIconClockColorsB'.Copy()
    Settings[FMain.Name &/ "F_sClockPartsFileNames"] = Me.F_sClockPartsFileNames
    FMain.F_sClockPartsFileNames = Me.F_sClockPartsFileNames
    Settings[F_sForm &/ "F_sClockPartsFileNames"] = Me.F_sClockPartsFileNames
    sLastClockLevelsTags = ReadLevelsTag()
    If sLastClockLevelsTags Then 
      sDirFile = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ F_sFileClockMusterLastTemp_TXT 
      sLastClockLevelsTags = CheckFileTitleClockMuster(sLastClockLevelsTags)
      Settings[FMain.Name &/ "sLastClockLevelsTags"] = sLastClockLevelsTags
      If IsDir(File.Dir(sDirFile)) = True Then File.Save(sDirFile, sLastClockLevelsTags)
    Endif 
    
    FMain.F_ssEditLevels = Me.F_ssEditLevels'.Copy()
    Settings[FMain.Name &/ "F_ssEditLevels"] = Me.F_ssEditLevels'.Copy()
    FMain.F_iiPicBoxesVisibleLevelNr = Me.F_iiPicBoxesVisibleLevelNr'.Copy()
    Settings[FMain.Name &/ "F_iiPicBoxesVisibleLevelNr"] = Me.F_iiPicBoxesVisibleLevelNr'.Copy()
    
    TextBoxPath.Selectall()
    TextBoxPath.Insert(F_sPathClockMuster_txt)
    ' TextBoxPath.Text = F_sPathClockBackground_png
    LoadPicBoxPath() 'Refresh 'PanelBGPath: Info | Pic | PathText
    PicBoxMusterAdd.Tooltip = ("Uhr als Muster speichern") & gb.NewLine & F_sPathClockMuster_txt
    MenuSaveRecentG(sDirFile)
    
    FMain.F_iClockMap0Stop1Count2Digital3Design4 = 4
    Settings[FMain.Name &/ "F_iClockMap0Stop1Count2Digital3Design4"] = 4
    FMain.F_dateTimeSummerBegin = Null 'Reset, read new
    ' FMain.LoadClockG()
    ' FMain.DrawTime()
    ' FMain.ClockSwitchCheck()
    ' LoadClockG()
          
      ''Copy on USB?
      sPathMedia = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
      ' If String.InStr(sPathMedia, User.Home) = 0 And Exist(sPathMedia) = True Then 
      ''Home:
        sPathPNG = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ F_sFileClockMusterLastTemp_PNG 
        sPathTXT = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ F_sFileClockMusterLastTemp_TXT 
      ''USB:
        sPathPNG2 = File.SetDir(sPathPNG, File.Dir(sPathMedia))
        sPathTXT2 = File.SetDir(sPathTXT, File.Dir(sPathMedia))
        If Exist(sPathTXT) = True And Exist(File.Dir(sPathTXT2)) = True Then 
          If Exist(sPathTXT2) = True Then Kill sPathTXT2
          Copy sPathTXT To sPathTXT2
        Endif 
        If Exist(sPathPNG) = True And Exist(File.Dir(sPathPNG2)) = True Then 
          If Exist(sPathPNG2) = True Then Kill sPathPNG2
          Copy sPathPNG To sPathPNG2
        Endif 
        If Exist(sPathCache2) = True Then 
          sMessage &= "<h3><img src=" & Quote("file://" & sPathCache2) & " width=100 height=100 >" & Space(1) & "<font color=blue>" & ("Gespeichert") & ":" & "</font></h3>"
          sMessage &= "<font color=gray>" & File.Dir(sPathTXT2) &/ "</font><font color=blue>" & File.Name(sPathTXT2) & "</font>" & Space(1)
          sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathTXT) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPathTXT).Size) & "</font>" & "<br>"
        Endif 

    FMain.F_bNeueinlesenStarten = True 'See FMain.RefreshAll()
    FMain.Timer1.Enabled = bTimerON
    Wait 1
    ' Print F_sClockPartsFileNames
    ' Print Settings[FMain.Name &/ "F_sClockPartsFileNames", Null] 
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        If Exist(sPathTXT2) = True Then M01Functions.FileManagerOpen(sPathTXT2) Else Message.Info("<h2><font color=red>" & ("Fehlt") & ":" & "</h2>" & sPathTXT2)
        
        ' If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
        ' M01Functions.FileManagerOpen(sDirFile)
      Case 2
        ''... Cancel
    End Select
    
    If Error Then 
      IconError.Visible = True 
      Error.Clear
    Endif 
  Endif 'bSave  
  
  TimerClock.Enabled = bTimer1
  TimerColorPicker.Enabled = bTimer2
  
Catch 
  FMain.ErrorText
  
End

Public Sub OpenG()
  
  Dim sLevels, sDirFile, sPath, sPathTXT, sMessage As String 
  Dim picQuestion As Picture
  
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt] 
  
  sPath = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ F_sFileClockMusterLastTemp_PNG 
  sPathTXT = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ F_sFileClockMusterLastTemp_TXT 
  
  If Exist(sDirFile) = True Then 
    sPath = File.SetDir(sPath, File.Dir(sDirFile))
    sPathTXT = File.SetDir(sPathTXT, File.Dir(sDirFile))
  Endif
  
  If Exist(sPathTXT) = True Then sLevels = File.Load(sPathTXT)
  
  If sLevels And sLevels Like "*level=*" Then
    '...
  Else 'from settings
    sLevels = Settings[FMain.Name &/ "sLastClockLevelsTags", Null]
  Endif 
  
  If String.InStr(sLevels, "level=") > 0 Then 
    sMessage = "<h3><font color=gray>" & "● " & ("Uhr-Muster für das Hauptfenster") & "</font></h3>"

    If Exist(sPath) = True Then 
      sMessage &= "<br>"
      sMessage &= "<img src=" & Quote("file://" & sPath) & " width=100 height=100 >" & "<br>"
      sMessage &= "<h3><font color=darkgreen>" & ("Gespeicherte Uhr-Vorlage") & ":" & Space(1) & ("Ja") & "</font></h3>" 
      sMessage &= "<font color=gray>" & File.Dir(sPath) &/ "</font><font color=blue>" & File.Name(sPath) & "</font>" & Space(1)
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPath).Size) & "</font>" & "<br>"
    Endif 
    If Exist(sPathTXT) = True Then 
      sMessage &= "<font color=blue><b>" & File.Name(sPathTXT) & "</b></font>" & Space(1)
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathTXT) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sPathTXT).Size) & "</font>" & "<br>"
    Endif
    sMessage &= "<h3><font color=gray>" & "● " & ("Öffnen, bearbeiten, 'Speichern...'") & "</font></h3>" 
    
    Select Case Message.Question(sMessage, "● " & ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1
        LoadLevelsNewNull()
        LoadLevels(sLevels)
        ResizePanelLevels()
        SumPaintClockLevels()
        SynchronizeLevelsToGallery()
      Case 2 'Directory
        If Exist(sPath) = True Then M01Functions.FileManagerOpen(sPath) Else M01Functions.FileManagerOpen(File.Dir(sPath))
      Case 3 'Cancel
        '...
    End Select
    
  Else 
    sPath = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] &/ "question.png" 
    ' picQuestion = Picture.Load("icon:/256/question") 'Note: without ".png"
    picQuestion = PicBoxMusterSide.Picture
    If IsDir(File.Dir(sPath)) = True Then picQuestion.Save(sPath)
    sMessage = "<h3><font color=gray>" & "○ " & ("Uhr-Muster für das Hauptfenster") & "</font></h3>"
    sMessage &= "<h3><font color=darkgreen>" & ("Gespeicherte Uhr-Vorlage") & ":" & Space(1) & "<font color=blue>" & ("Keine") & "</font></font></h3>" 
    sMessage &= "<br>" 
    If Exist(sPath) = True Then 
      sMessage &= "<img src=" & Quote("file://" & sPath) & " width=100 height=100 border=1 bordercolor=black >" & "<br>"
    Endif 
    sMessage &= "<h3><font color=gray>" & ("Auswählen, bearbeiten, 'Speichern...'") & "</font></h3>" 
    
    Message.Info(sMessage, ("Abbrechen"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckSaveBehind() As String 
  
  Dim sDir, sFile, sDirFile, sText, sPath As String 
  Dim sMissingFiles, sClockPartsFileNames, sMessage As String
  Dim it As Integer
  Dim HTMLgreen, HTMLred, HTMLend As String 
  
  HTMLgreen = "<font color=darkgreen><b>"
  HTMLred = "<font color=red><b>"
  HTMLend = "</b></font>"
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  
  If Exist(sDir) = True Then 
    sClockPartsFileNames = Null
    
    ''Background: ▪▪○▪▪ watch case
    sFile = "clockbackground.png" 'Photo, User-Picture...
    sDirFile = sDir &/ sFile
    If F_imgClockBG Then 
      Try F_imgClockBG.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine '' (String = String &) or short (String &=)
    Endif 
    
    ''Cutter: □
    sFile = "clockcutter.png" 'Template, clipping mask, cut out (schneidende Schablone)
    sDirFile = sDir &/ sFile
    If F_imgClockCutter Then 
      Try F_imgClockCutter.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine '' (String = String &) or short (String &=)
    Endif 
    
    ''NightSky ·●•
    sFile = "clocknightsky.png" 'Photo, User-Picture...
    sDirFile = sDir &/ sFile
    If F_imgNightSky Then 
      Try F_imgNightSky.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''GearWheel: ○▴▴▴▴▴▴
    sFile = "clockgearwheel.png" 'Photo, User-Picture...
    sDirFile = sDir &/ sFile
    If F_imgGearWheel Then 
      Try F_imgGearWheel.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockGearWheel"] = F_sTagsClockGearWheel
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''TimeSummer: -●--○--●-
    sFile = "clocktimesummer.png" '02:00<>03:00, begin & end, Year: 2x
    sDirFile = sDir &/ sFile
    If F_imgTimeSummer Then 
      Try F_imgTimeSummer.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''SunUpDown:  △○—————●▼
    sFile = "clocksunupdown.png"
    sDirFile = sDir &/ sFile
    If F_imgSunUpDown Then 
      Try F_imgSunUpDown.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockSunUpDown"] = F_sTagsClockSunUpDown
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Numbers: 0-3-6-9-12 ... 
    sFile = "clocknumbers.png" '0-3-6-9-12 or 15-18-21-24
    sDirFile = sDir &/ sFile
    If F_imgClockNumbers Then 
      Try F_imgClockNumbers.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockNumbers"] = F_sTagsClockNumbers
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Hour: ●■■■▶
    sFile = "clockhour.png" 
    sDirFile = sDir &/ sFile
    If F_imgHour Then 
      Try F_imgHour.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Minute: ●▪▪▪▪▪►
    sFile = "clockminute.png" 
    sDirFile = sDir &/ sFile
    If F_imgMinute Then 
      Try F_imgMinute.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Second: ●———————▸
    sFile = "clocksecond.png"
    sDirFile = sDir &/ sFile
    If F_imgSecond Then 
      Try F_imgSecond.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''CenterPoint: ●
    sFile = "clockcenterpoint.png"
    sDirFile = sDir &/ sFile
    If F_imgCenterPoint Then 
      Try F_imgCenterPoint.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''DatePoint: ○
    sFile = "clockdatepoint.png" 
    sDirFile = sDir &/ sFile
    If F_imgDatePoint Then 
      Try F_imgDatePoint.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Phythagoras:  hour-minute-second-centerpoint
    sFile = "clockphythagoras.png" 
    sDirFile = sDir &/ sFile
    If F_imgPhythagoras Then 
      Try F_imgPhythagoras.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockPhythagoras"] = F_sTagsClockPhythagoras
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Digital: 00:00
    sFile = "clockdigital.png" 
    sDirFile = sDir &/ sFile
    If F_imgDigital Then 
      Try F_imgDigital.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockDigital"] = F_sTagsClockDigital
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''LCD: 00:00
    sFile = "clocklcd.png" 
    sDirFile = sDir &/ sFile
    If F_imgLCD Then 
      Try F_imgLCD.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      Settings[FMain.Name &/ "F_sTagsClockLCD"] = F_sTagsClockLCD
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
    
    ''Clock Muster: complete
    sFile = F_sFileClockMusterLastTemp_PNG 
    sDirFile = sDir &/ sFile
    If F_picClock Then 'Me.Icon
      If IsDir(sDir) = True Then F_picClock.Save(sDirFile) 
      sClockPartsFileNames &= sFile & gb.NewLine 
      If Exist(sDirFile) = False Then sMissingFiles &= sFile & gb.NewLine
    Endif 
  Endif 'sDir
  
  ''Plus user-pictures:
  If F_ooPicBoxesGallery Then 
    For it = 0 To F_ooPicBoxesGallery.Max
      sPath = F_ooPicBoxesGallery[it].Tag
      If Exist(sPath) = True And String.InStr(sPath, "images/") = 0 Then F_sLoadUserPaths = F_sLoadUserPaths & gb.NewLine & sPath
    Next 
    If F_sLoadUserPaths Then Settings[F_sForm &/ "F_sLoadUserPaths"] = F_sLoadUserPaths
  Endif
  
  ''Last workplace
  If F_ooPicBoxesLevels Then SaveLevelTags()
  Settings[F_sForm &/ "F_sWorkplaceLevelsLastTime"] = Format(Now, "ddd dd.mm.yyyy hh:nn:ss")
  F_sClockPartsFileNames = sClockPartsFileNames
  Settings[F_sForm &/ "F_sClockPartsFileNames"] = F_sClockPartsFileNames 
  
  If sMissingFiles Then sMissingFiles = "<h3><font color=red>" & ("Datei fehlt") & ": " & "<br>" & sMissingFiles & "</font></h3><br>"
  If Exist(sDir) = False Then sMissingFiles = "<h3><font color=red>" & ("Ordner fehlt") & ": " & "<br>" & sDir & "</font></h3><br>" & sMissingFiles
  
  If Error Or sMissingFiles Then 
    sText = "<font color=red>" & ("Fehler beim Speichern?") & "</font><br><br>" & sMissingFiles
    If Error Then 
      IconError.Visible = True 
      Error.Clear
    Endif 
  Else 
    sText = "<h3><font color=darkgreen>" & ("Fertig. Siehe im Ordner...") & "</font></h3>"
  Endif 
  sMessage = "<font color=blue>" & sDir &/ "..." & "</font>" & "<br>" 
  sMessage &= sText
  
  Return sMessage
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Function ReadLevelsTag(Optional bAllVisible As Boolean = True) As String 
  ''—▶ ReadLevel...SaveLevel...LoadLevel...
  
  Dim it, iFound, iSelect As Integer '= 0
  Dim sColors, sEdit, sLevel, sLevelTags, sPicPath As String 
  Dim iiPicBoxesLeftSort As Integer[]
  Dim iiPicBoxesLeftAll As Integer[]
  Dim bColorChanged As Boolean
  Dim ssEdits As New String[]
  
  If F_ooPicBoxesLevels Then  'F_ooButtonsLevels
    iiPicBoxesLeftSort = New Integer[]
    iiPicBoxesLeftAll = New Integer[] 'Not sort!
    
    ''all visible listing: 
    If bAllVisible = True Then 
      For it = 0 To F_ooPicBoxesLevels.Max
        iiPicBoxesLeftAll.Add(F_ooPicBoxesLevels[it].Left) 
        If F_ooPicBoxesLevels[it].Visible = True Then iiPicBoxesLeftSort.Add(F_ooPicBoxesLevels[it].Left) Else iiPicBoxesLeftSort.Add(-1) 
      Next
    Else 
      ''only visible selected:
      For it = 0 To F_ooPicBoxesLevels.Max
        iiPicBoxesLeftAll.Add(F_ooPicBoxesLevels[it].Left) 
        If F_ooPicBoxesLevels[it].Visible = True And F_ooPicBoxesLevels[it].Background = F_iColorSelect Then iiPicBoxesLeftSort.Add(F_ooPicBoxesLevels[it].Left) Else iiPicBoxesLeftSort.Add(-1) 
      Next
    Endif 
    
    If iiPicBoxesLeftSort Then iiPicBoxesLeftSort = iiPicBoxesLeftSort.Sort()
    For it = 0 To iiPicBoxesLeftSort.Max
      iFound = iiPicBoxesLeftAll.Find(iiPicBoxesLeftSort[it]) '-1 not found
      sLevel = ""
      ''Path:
      If iFound > -1 And iFound < F_ooPicBoxesLevels.Count Then 
        If String.InStr(F_ooPicBoxesLevels[iFound].Tag, "/") > 0 And F_ooPicBoxesLevels[iFound].Picture <> PicTemplateQuestion.Picture Then 
          sPicPath = F_ooPicBoxesLevels[iFound].Tag 
        Else 
          sPicPath = ""
        Endif 
        
        ''Level:
        If F_ooPicBoxesLevels[iFound].Background = F_iColorSelect Then iSelect = 1 Else iSelect = 0
        'Note: Clock 15:00h —▶ Angle 0° or 360°, ◁ horizontal base ▷
        ''level=number=left=selected=path= '0=1=2=3=4=
        sLevel = "level=" & F_ooPicBoxesLevels[iFound].ToolTip & "=" & F_ooPicBoxesLevels[iFound].Left & "=" & iSelect & "=" & sPicPath & "=" & gb.NewLine
        
        ''Edit:
        If F_ssEditLevels Then 
          If F_ssEditLevels.Count <> F_ooPicBoxesLevels.Count Then F_ssEditLevels.Resize(F_ooPicBoxesLevels.Count)
          If F_ssEditLevels[iFound] Then
            sEdit = "edit=" & F_ooPicBoxesLevels[iFound].ToolTip & "=" & F_ooPicBoxesLevels[iFound].Left & "=" & iSelect & "=" & F_ssEditLevels[iFound] & "=" & gb.NewLine
            If ssEdits.Find(sEdit) = -1 Then 
              ssEdits.Add(sEdit) 'not double
              sEdit = Null
            Endif 
          Else 
            sEdit = Null
          Endif 
        Endif 
        
        sLevelTags = sLevelTags & sLevel & sEdit
      Endif 
    Next
    
    If sLevelTags Then 
      ''Color:
      If F_iiIconClockColorsB Then
        If F_iiIconClockColorsA.Count <> F_iColorsCount Then F_iiIconClockColorsA.Resize(F_iColorsCount)
        If F_iiIconClockColorsB.Count <> F_iColorsCount Then F_iiIconClockColorsB.Resize(F_iColorsCount)
        For it = 0 To F_iiIconClockColorsB.Max
          If F_iiIconClockColorsA[it] = F_iiIconClockColorsB[it] Then 
            bColorChanged = False 
          Else 
            bColorChanged = True
            Break
          Endif 
        Next 
        If bColorChanged = True Then   
          For it = 0 To F_iiIconClockColorsB.Max
            sColors &= Str(F_iiIconClockColorsB[it]) & "="
          Next 
          If sColors Then sLevelTags &= "colorchange=" & sColors & gb.NewLine
          ' F_ooColorChangeLevels = F_iiIconClockColorsB
        Endif 
      Endif 
      
      If ssEdits.Max > -1 Then sLevelTags &= ssEdits.Join(gb.NewLine) & gb.NewLine
      sLevelTags = Replace(sLevelTags, gb.NewLine & gb.NewLine, gb.NewLine) 'not double
      ' F_ssEditLevels = ssEdits.Copy()
      ' sLevelTags = gb.NewLine & "level=begin" & gb.NewLine & sLevelTags & "level=end" & gb.NewLine & gb.NewLine
      sLevelTags = "level=begin" & gb.NewLine & sLevelTags & "level=end" & gb.NewLine 
    Endif 
  Endif  
  F_sLevelsTags = sLevelTags
  
  Return sLevelTags
  
  ''level=number=left=selected=path= '0=1=2=3=4=
  ''Example:
  ' level=begin
  ' level=133=0==
  ' level=227=60=0=/home/<user>/Bilder/ExamplePicture.png=
  ' level=end
  
  'gb.Newline = "\n" or "<br>"
  
Catch
  FMain.ErrorText
  
End

Public Sub ReadMusterTagsToEditlevels(Optional sTag As String = "") '??? —▶LoadLevels()
  
  Dim ssSpli As String[]
  Dim sLine, sEdit As String 
  Dim it, iNr As Integer
  
  ''level=number=left=selected=path= '0=1=2=3=4=
  ''Example:
  ' level=begin
  ' level=133=0==
  ' level=227=60=0=/home/<user>/Bilder/ExamplePicture.png=
  ' level=end
  
  If sTag Then 
    F_ssEditLevels = New String[]
    If F_ssEditLevels Then 
      If F_ssEditLevels.Count <> F_ooPicBoxesLevels.Count Then F_ssEditLevels.Resize(F_ooPicBoxesLevels.Count)
      
      For Each sLine In Split(sTag & gb.NewLine, gb.NewLine)
        If sLine Then
          If sLine Like "*edit=*" Then 
            ssSpli = Split(sLine & "=", "=")
            it = -1 'Reset
            iNr = -1
            For Each sEdit In ssSpli 
              it = it + 1
              If it = 1 Then 
                If IsInteger(sEdit) = True Then iNr = CInteger(sEdit)
              Endif
              If F_ssEditTagsWords.Find(sEdit) > -1 Then 'Example: ["grayscale", "otherfunction", ...]
                F_ssEditLevels[iNr] = F_ssEditLevels[iNr] & sEdit & "="  
              Endif 
            Next
          Endif
        Endif
      Next
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function ReadGalleryTags(Optional bAll As Boolean = True) As String 
  
  Dim it As Integer
  Dim sLevel, sGalleryTags As String 
  
  If F_ooPicBoxesGallery Then
    For it = 0 To F_ooPicBoxesGallery.Max
      If bAll = True Or F_ooPicBoxesGallery[it].Background = F_iColorSelect Then
        If F_ooPicBoxesGallery[it].Tag And F_ooPicBoxesGallery[it].Picture <> PicTemplateQuestion.Picture Then
          '' 0 False, -1 True (selected)
          ''level=number=left=selected=path=
          sLevel = ("level=") & F_ooPicBoxesGallery[it].ToolTip & "=" & F_ooPicBoxesLevels[it].Left & "=" & "-1" & "=" & F_ooPicBoxesGallery[it].Tag & "="
          sGalleryTags = sGalleryTags & sLevel & gb.NewLine
        Endif 
        If Object.IsValid(F_oLastPicBoxObject) = False Then F_oLastPicBoxObject = F_ooPicBoxesGallery[it]
      Endif 
    Next
  Endif 
  
  Return sGalleryTags
  
Catch 
  FMain.ErrorText
  
End

Public Function ReadMusterTags(Optional bAll As Boolean = True) As String 
  
  Dim it, iLine As Integer
  Dim sMusterTags As String 
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If F_ooPicBoxesMuster Then
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif  
      
      If bAll = True Or F_ooPicBoxesMuster[it].Background = F_iColorSelect Then
        If F_ooPicBoxesMuster[it].Tag And F_ooPicBoxesMuster[it].Picture Then 
          sMusterTags &= F_ooPicBoxesMuster[it].Tag & gb.NewLine
        Endif 
      Endif 
    Next
    ' If Object.IsValid(F_oLastPicBoxObject) = False Then F_oLastPicBoxObject = F_ooPicBoxesMuster.Last
    If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
  Endif 
  
  Return sMusterTags
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveLevelTags(Optional sSaveLevelsTag As String = Null)
  
  If Not sSaveLevelsTag Then sSaveLevelsTag = ReadLevelsTag() 'as String
  
  If sSaveLevelsTag Then 
    ' sSaveLevelsTag = Replace(sSaveLevelsTag, gb.NewLine & gb.NewLine, gb.NewLine)
    Settings[F_sForm &/ "F_sLevelsTags"] = sSaveLevelsTag
  Endif
  
  ' PicBoxResetGallery.Tooltip = ("Reset. Bilder-Galerie neu berechnen. Zustand, letzte Speicherung") & ": " & Space(1) & Settings[F_sForm &/ "F_sWorkplaceLevelsLastTime", "-"]
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckMusterBeginEnd(Optional sTag As String = "", Optional bAll As Boolean = False) As String
  
  ''Check
  Dim iLine, iMusterCount As Integer
  Dim sLine, sText As String 
  
  If F_iESCpressed > 0 Then Return 'end here
  ' If F_iESCpressed > 0 Then Goto JumpEnd 'end here
  
  If String.InStr(sTag, "level=") > 0 Then 
    If String.InStr(sTag, "level=begin") = 0 Then sTag = "level=begin" & gb.NewLine & sTag
    If String.InStr(sTag, "level=end") = 0 Then sTag = sTag & gb.NewLine & "level=end" & gb.NewLine 
  Endif
  If String.InStr(sTag, "level=begin") > 0 Then 
    If String.InStr(sTag, "level=end" & "level=begin") > 0 Then sTag = Replace(sTag, "level=end" & "level=begin", "level=end" & gb.NewLine & gb.NewLine & "level=begin")
    If String.InStr(sTag, "level=end" & gb.NewLine & "level=begin") > 0 Then sTag = Replace(sTag, "level=end" & gb.NewLine & "level=begin", "level=end" & gb.NewLine & gb.NewLine & "level=begin")
    
    If bAll = True Then 
      ' it = Split(sTag & "level=begin", "level=begin").Max 
      ' If it > -1 Then 
      ' Me.Window.Title = Application.Name & " - " & MenuCheckDoubleMuster.Text & "..."
      ' LabelMessageText(MenuCheckDoubleMuster.Text & "...", Color.Red)
      For Each sLine In Split(sTag & gb.NewLine, gb.NewLine)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        ' ProgressBar1.Pulse = False
        If String.InStr(sLine, "level=begin") > 0 Then iMusterCount = iMusterCount + 1
        sText &= sLine & gb.NewLine 
        If String.InStr(sLine, "level=end") > 0 Then 
          iMusterCount = iMusterCount - 1
          Break 
        Endif 
      Next
      ' Endif
      If iMusterCount > 0 Then sText &= "level=end" & gb.NewLine & gb.NewLine
      sTag = sText
      ' ProgressBarONoff(False) 
    Endif 
  Endif 
  F_bMusterSideChanged = True
  
  ' JumpEnd:
  
  Return sTag 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveMusterTags(Optional sSaveMusterTags As String = Null)
  
  Dim sDirFileStandard, sDirFile As String 
  
  If sSaveMusterTags Then 'Old & New
    '...sSaveMusterTags
  Else 
    sSaveMusterTags = ReadMusterTags(True) 'as String, (False)—▶Selection
  Endif 
  
  If sSaveMusterTags Like "*level=*" Then 
    
    sSaveMusterTags = CheckMusterBeginEnd(sSaveMusterTags, False) ''True= Muster 1x, False=All
    
    ''Save in Settings:
    ' If sSaveMusterTags Then Settings[F_sForm &/ "F_sMusterTags"] = sSaveMusterTags
    
    ''Save in File:
    sDirFileStandard = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 
    If IsDir(sDirFileStandard) = False Then 
      sDirFile = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ File.Name(sDirFileStandard)
    Endif 
    
    If sSaveMusterTags Like "*level=*" Then 
      If File.Dir(sDirFileStandard) <> File.Dir(sDirFile) Then 'USB-Stick?
        sDirFileStandard = M01Functions.FileTextPlus(sDirFileStandard, sSaveMusterTags, True) 'TRUE=overwrite (überschreiben) with Backup
        If Exist(sDirFileStandard) = True And Exist(FMain.F_sLastCopyBackup) = True Then 
          MenuSaveRecentG(FMain.F_sLastCopyBackup)
        Endif 
      Else 
        ''*********************************
        If IsDir(File.Dir(sDirFileStandard)) = True Then File.Save(sDirFileStandard, sSaveMusterTags)
        ''*********************************
        If Exist(sDirFileStandard) = False Then 
          Message.Info("<h3><font color=red>" & ("Fehlt") & "</font></h3>" & sDirFileStandard, ("Abbrechen"))
        Else 
          MenuSaveRecentG(sDirFileStandard)
        Endif 
        
      Endif
      LabelInfoPathG(TextBoxPath.Text)
      ''Append last to file
      ' If IsDir(File.Dir(sPathLast)) = True Then 
      '   sSaveLevelsTag = ReadLevelsTag() 'as String
      '   If sSaveLevelsTag Like "*level=*" Then sPathLast = M01Functions.FileAppendText(sPathLast, sSaveLevelsTag)
      '   If Exist(sPathLast) = True Then MenuSaveRecentG(sPathLast)
      ' Endif
    Endif 
  Endif 
  
  MusterCounter() 'as String  "0/0"
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckMusterDoubleNewToOldyear()
  
  Dim sOld, sLast, sAll, sDirFile, sPathCache1, sDirFileOldyears, sMessage As String 
  Dim iMuster As Integer
  Dim picMessage As Picture
  
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
  picMessage = MenuMusterOldyearOutside.Picture
  If picMessage Then picMessage.Save(sPathCache1)
  
  ''File:
  sDirFile = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 
  sDirFileOldyears = File.SetExt(sDirFile, "txt_oldyears.txt")
  
  If Not F_ooPicBoxesMuster Then 
    sMessage = "<h3><font color=red><b>" & ("Die Muster-Liste ist (noch) leer") & "</b></font></h3>" 
  Endif
  sMessage &= "<br>" & "<img src=" & Quote("file://" & sPathCache1) & " width=50 height=50 >" 
  sMessage &= "<h3><font color=gray>" & "● " & ("Die Muster-Liste auslagern in die Datei:") & "</font></h3>" 
  sMessage &= "<font color=gray>" & File.Dir(sDirFileOldyears) & "</font>" &/ "<font color=darkgreen><b>" & File.Name(sDirFileOldyears) & "</b></font>" & "<br>" 
  
  If Exist(sDirFileOldyears) = True Then 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileOldyears) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOldyears).Size) & "</font>"
  Endif 
  sMessage &= "<h3><font color=gray>" & ("Ohne doppelte Muster, beliebig wiederholbar.") & "</font></h3>" 
  sMessage &= "<font color=gray>" & FMain.F_sLastCopyBackup & "</font>" & "<br>" 
  
  Select Case Message.Question(sMessage, "● " & ("Auslagern"), ("Ordner..."), ("Abbrechen"))
    Case 1 'Append, Save
      '...
      If Not F_ooPicBoxesMuster Then 
        Message.Info(("Abbrechen") & "<br>" & ("Die Muster-Liste ist (noch) leer"), ("Abbrechen"))
        Goto JumpEnd
      Endif 
      
    Case 2 'Directory
      If Exist(sDirFileOldyears) = True Then M01Functions.FileManagerOpen(sDirFileOldyears) Else M01Functions.FileManagerOpen(sDirFile)
      Goto JumpEnd
      
    Case 3 'Cancel
      Goto JumpEnd
      
  End Select
  
  If F_ooPicBoxesMuster Then 
    sLast = ReadMusterTags(True) 'all
    iMuster = F_ooPicBoxesMuster.Count
  Endif 
  
  If F_iESCpressed > 0 Then Goto JumpEnd
  
  If sLast Then 
    If Exist(sDirFileOldyears) = True Then sOld = File.Load(sDirFileOldyears)
    If sOld Then sOld &= gb.NewLine & gb.NewLine 
    sAll = sOld & sLast
    sAll = CheckDoubleLevelMusterReturn(sAll)
    If String.InStr(sAll, "level=") > 0 Then sAll = CheckFileTitleClockMuster(sAll) 
    '*****************************************************
    sDirFileOldyears = M01Functions.FileTextPlus(sDirFileOldyears, sAll, True) 'TRUE=overwrite (überschreiben) with Backup
    '*****************************************************
    
    If Exist(sDirFileOldyears) = True Then 
      ' UndoRedoMusterSave(sLast)
      MusterNullNew()
      MusterCounter() 'as String  "0/0"
      ''emtpy
      sDirFile = M01Functions.FileTextPlus(sDirFile, "#", True) 'TRUE=overwrite (überschreiben) with Backup
      MenuSaveRecentG(sDirFile)
      ' UndoRedoMusterSave("")
      F_bMusterSideChanged = False
      
      If PanelMuster.Visible = False Then SideG("muster")
      sMessage = "<h3><font color=gray>" & "● " & iMuster & Space(1) & ("Muster ausgelagert in:") & "</font></h3>" 
      sMessage &= "<font color=gray>" & File.Dir(sDirFileOldyears) & "</font>" &/ "<font color=darkgreen><b>" & File.Name(sDirFileOldyears) & "</b></font>" & "<br>" 
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileOldyears) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOldyears).Size) & "</font>" & "<br>" 
      sMessage &= "<font color=gray>" & ("Ohne doppelte Muster") & ": " & "<br>" 
      sMessage &= LabelCounterMuster.Text & "</font>" & "<br>" 
      sMessage &= "<h3><font color=gray>" & "● " & ("Fertig") & "</font></h3>" 
      
      Select Case Message.Question(sMessage, ("Modell-Daten..."), ("Ordner..."), "● " & ("Abbrechen"))
        Case 1 'show Text
          Form3Text.Tag = sAll
          Form3Text.Window.Show()
          ' Form3Text.Window.Visible = True 'Wayland error?
        Case 2 'Directory
          If Exist(sDirFileOldyears) = True Then M01Functions.FileManagerOpen(sDirFileOldyears) Else M01Functions.FileManagerOpen(sDirFile)
          
        Case 3 'Cancel
          '...
          
      End Select
    Endif 
  Endif 
  
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckMusterDoubleOldyeartoNew() 
  
  Dim sOld, sAll, sPath, sDirFileOldyears, sMessage As String 
  Dim iBefore, iBehind As Integer
  Dim sNew As String
  
  ''File:
  sPath = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 
  sDirFileOldyears = File.SetExt(sPath, "txt_oldyears.txt")
  
  If Exist(sDirFileOldyears) = False Then 
    sMessage = "<h3><font color=red><b>" & ("Fehlt. Datei nicht gefunden.") & "</b></font></h3>" 
    sMessage &= "<h3><font color=gray>" & ("Alternativ: Öffnen... oder Sicherungskopien...") & "</font></h3>" 
  Else 
    sMessage = "<font color=gray>" & File.Dir(sDirFileOldyears) & "</font>" &/ "<font color=darkgreen><b>" & File.Name(sDirFileOldyears) & "</b></font>" & "<br>" 
  Endif 
  
  If Exist(sDirFileOldyears) = True Then 
    sOld = File.Load(sDirFileOldyears)
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileOldyears) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileOldyears).Size) & "</font>"
  Endif 
  sMessage &= "<h3><font color=darkgreen>" & "● " & ("Aus der Sammel-Datei wieder einlagern in die aktuelle Muster-Liste.") & "</font></h3>" 
  sMessage &= "<h3><font color=gray>" & ("Ohne doppelte Muster, beliebig wiederholbar.") & "</font></h3>" 
  
  Select Case Message.Question(sMessage, "● " & ("Einlagern"), ("Ordner..."), ("Abbrechen"))
    Case 1 'Open
      '...
      
    Case 2 'Directory
      If Exist(sDirFileOldyears) = True Then M01Functions.FileManagerOpen(sDirFileOldyears) Else M01Functions.FileManagerOpen(sPath)
      Goto JumpEnd
      
    Case 3 'Cancel
      Goto JumpEnd
      
  End Select
  
  If Exist(sDirFileOldyears) = True Then 
    sOld = File.Load(sDirFileOldyears)
  Endif 
  
  If F_iESCpressed > 0 Then Goto JumpEnd
  
  If sOld Then 
    sNew = ReadMusterTags(True) 'All
    If F_ooPicBoxesMuster Then 
      iBefore = F_ooPicBoxesMuster.Count
      iBehind = iBefore 'if not, then: iBehind - iBefore = 0
    Endif 
    sOld &= gb.NewLine & gb.NewLine 
    sAll = sOld & sNew
    sAll = CheckDoubleLevelMusterReturn(sAll)
    ' UndoRedoMusterSave(sLast)
    MusterNullNew()
    LoadMuster(sAll) 
    MusterCounter() 'as String  "0/0"
    F_bMusterSideChanged = True
    If PanelMuster.Visible = False Then SideG("muster")
    If F_ooPicBoxesMuster Then iBehind = F_ooPicBoxesMuster.Count
    
    sMessage = "<h3><font color=gray>" & "● " & Str(iBehind - iBefore) & Space(1) & ("Eingelagert in die Muster-Liste") & "</font></h3>" 
    sMessage &= "<font color=gray>" & ("Ohne doppelte Muster") & ": " & "<br>" 
    sMessage &= LabelCounterMuster.Text & "</font>" & "<br>" 
    
    Select Case Message.Question(sMessage, "● " & ("Modell-Daten..."), ("Ordner..."), ("Abbrechen"))
      Case 1 'show Text
        sNew = ReadMusterTags(True) 'All
        sNew = CheckFileTitleClockMuster(sNew)
        Form3Text.Tag = sNew
        Form3Text.Window.Show()
        ' Form3Text.Window.Visible = True 'Wayland error?
      Case 2 'Directory
        If Exist(sDirFileOldyears) = True Then M01Functions.FileManagerOpen(sDirFileOldyears) Else M01Functions.FileManagerOpen(sPath)
        
      Case 3 'Cancel
        '...
        
    End Select
  Endif 
  
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckExistMuster(Optional sLevelsTags As String = "") 
  
  Dim sNew, sDir, sPath, sOld, sInfoExist, sPathCache1, sInfoAdd, sNumber, sMessage As String 
  Dim iFound As Integer
  Dim picMessage As Picture
  
  If Not F_ooPicBoxesMuster Then CheckMusterSideFill()
  If sLevelsTags Then sNew = sLevelsTags Else sNew = ReadLevelsTag()
  sOld = ReadMusterTags()
  
  If sOld And sOld Like "*" & sNew & "*" Then 
    If F_ssPicBoxMusterTags Then 
      iFound = F_ssPicBoxMusterTags.Find("*" & sNew & "*") '-1 not found 
      If iFound > -1 Then sNumber = iFound + 1
      If iFound > -1 And F_ooPicBoxesMuster Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[iFound]
    Endif 
    sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
    If PicBoxClock.Picture Then picMessage = PicBoxClock.Picture.Image.Stretch(100, 100).Picture 
    If picMessage Then picMessage.Save(sPathCache1) Else PicTemplateQuestion.Picture.Save(sPathCache1)
    sPath = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 
    sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
    sInfoExist = "<font color=darkgreen><b>" & ("Das Uhr-Muster war schon in der Liste.") & "</b></font>"
    sInfoAdd = "<font color=blue><b>" & ("Als Muster gespeichert") & "</b></font>"
    If PanelMuster.Visible = False Then SideG("muster")
    ScrollViewEnsureVisibleG(sNew)
    ''...not double
    sMessage = "<h3>" & ("Speichern") & "</h3>" 
    sMessage &= "<h3>" & sInfoExist & "<br><br>" & ("Abbrechen") & "</h3>"
    sMessage &= "● " & "<font color=gray>" & sPath & "</font>" & "<br>"
    sMessage &= "○ " & "<font color=gray>" & sDir &/ "..." & "Backup" & "</font>" & "<br>" & "<br>"
    If Exist(sPathCache1) = True Then 
      sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=100 height=100 >" & Space(1) & ("Neu") & Space(1) & sNumber & "<br>"
    Endif 
    
    Select Case Message.Question(sMessage, ("Noch einmal hinzufügen"), "● " & ("Ordner..."), ("Abbrechen"))
      Case 1 'Save New 
        F_bMusterSideChanged = True
        Add1xMuster(F_picClock, sNew)
        SaveMusterTags(sOld & sNew)
        ResizePanelMuster()
        LabelMessageText(sInfoAdd)
        If F_ooPicBoxesMuster Then ScrollViewEnsureVisibleG(F_ooPicBoxesMuster.Max)
        
      Case 2 'Directory:
        If Exist(sPath) = False Then sPath = sDir
        M01Functions.FileManagerOpen(sPath)
        LabelMessageText(sInfoExist)
      Case 3 'Cancel:
        LabelMessageText(sInfoExist)
    End Select
    
  Else
    F_bMusterSideChanged = True
    Add1xMuster(F_picClock, sNew)
    ResizePanelMuster()
    If F_ooPicBoxesMuster Then F_ooPicBoxesMuster[F_iMusterAddLast].Background = F_iColorSelect
    SaveMusterTags(sOld & sNew)
    sInfoAdd = "<font color=blue><b>" & ("Als Muster gespeichert") & "</b></font>"
    LabelMessageText(sInfoAdd)
    
    SideG("muster")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadLevels(Optional sTag As String = Null)
  
  Dim sLevel, sPart As String
  Dim iPos, n, iLine As Integer
  Dim iiColorsUser As Integer[]
  Dim ssSpliLevels, ssSpliParts As String[]
  Dim picPart As Picture
  Dim Img As Image 
  Dim bColorsLine As Boolean
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If sTag Then 
    sTag = CheckMusterBeginEnd(sTag, True)'True= Muster 1x
    If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
    If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
    If F_iiIconClockColorsA.Max <> F_iiIconClockColorsB.Max Then F_iiIconClockColorsB.Resize(F_iiIconClockColorsA.Count)
    If F_ooPicBoxesLevels And F_ooPicBoxesGallery And String.InStr(sTag, "level=") > 0 Then 
      ' If F_ssEditLevels Then F_ssEditLevels.Clear()
      ssSpliLevels = Split(sTag & gb.NewLine, gb.NewLine) 'Lines
      If ssSpliLevels Then 
        F_ssEditLevels = New String[]
        If F_ooPicBoxesLevels.Max > -1 Then F_ssEditLevels.Resize(F_ooPicBoxesLevels.Count)
        bColorsLine = False
        iiColorsUser = F_iiIconClockColorsA.Copy() 'with ()  Reset
        For Each sLevel In ssSpliLevels
          iLine = iLine + 1
          ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          
          If String.InStr(sLevel, "level=end") > 0 Then Break
          If sLevel Then 
            
            ''color:    cccccccccccccccccccccccccccccccccccccc read colors first
            If F_bColorChangeON = True And String.InStr(sLevel, "colorchange=") > 0 Then
              bColorsLine = True 
              ssSpliParts = Split(sLevel & String(6, "="), "=")
              If String.InStr(sLevel, "=") = 0 Then ssSpliParts = Null
              iPos = -1
              n = -1
              If ssSpliParts Then 
                iiColorsUser = F_iiIconClockColorsB.Copy()
                For Each sPart In ssSpliParts 
                  ''Color:
                  If sPart Then 
                    If IsInteger(sPart) = True And F_iiIconClockColorsB Then 
                      n = n + 1
                      If n > -1 And n < F_iiIconClockColorsB.Count Then  'n=0 is "colorchange", begin with n=1
                        iiColorsUser[n] = CInteger(sPart)
                      Endif 
                    Endif
                  Endif
                Next
              Endif 
            Endif 'cccccccccccccccccccccccccccccccccccccccccccccccccccc
          Endif 
        Next 
        
        If Not iiColorsUser Then iiColorsUser = F_iiIconClockColorsA.Copy() 'with ()
        If iiColorsUser Then 
          F_iiIconClockColorsB = iiColorsUser.Copy()
          SettingsColorsUserReadSave("save")
          If Not F_ooPicBoxesColorsB Then CreatePanelMemoryColors()
          ColorChangeLevelsPicture()
        Endif 
        
        F_ooPicBoxesLevelsOnlyVisible = New Object[]
        For Each sLevel In ssSpliLevels
          If F_iESCpressed > 0 Then Break 
          If String.InStr(sLevel, "level=end") > 0 Then Break
          If sLevel Then 
            ''level:  llllllllllllllllllllllllllllllllllllllllllllllllll
            ''level=number=left=selected=path=    0=1=2=3=4=
            If String.InStr(sLevel, "level=begin") = 0 And String.InStr(sLevel, "level=") > 0 Then
              ssSpliParts = Split(sLevel & String(6, "="), "=")
              If String.InStr(sLevel, "=") = 0 Then ssSpliParts = Null
              iPos = -1
              n = -1
              If ssSpliParts Then 
                For Each sPart In ssSpliParts 
                  n = n + 1
                  If n > 4 Then Break
                  If sPart And F_ooPicBoxesLevels Then 
                    ''Number: 0,1,2,3...
                    If n = 1 Then 
                      If IsInteger(sPart) = True Then 
                        iPos = CInteger(sPart) - 1 '.ToolTip Number n-1
                        If iPos < 0 Or iPos > F_ooPicBoxesLevels.Max Then iPos = -1 
                      Endif
                    Endif
                    If iPos > -1 And iPos < F_ooPicBoxesLevels.Count Then 
                      If n = 1 Then 
                        F_ooPicBoxesLevels[iPos].Background = F_iColorSelect
                        F_ooPicBoxesLevels[iPos].Visible = True
                        F_ooButtonsLevels[iPos].Visible = True 
                        F_ooButtonsLevels[iPos].Raise() '▲top▲ |x|
                        F_ooPicBoxesLevels[iPos].Picture = F_ooPicBoxesGallery[iPos].Picture
                        F_ooPicBoxesLevelsOnlyVisible.Add(F_ooPicBoxesLevels[iPos])
                      Endif 
                      
                      ''Left: |◀
                      If n = 2 Then 
                        If IsInteger(sPart) = True Then F_ooPicBoxesLevels[iPos].Left = CInteger(sPart)
                      Endif 
                      
                      '''Selected: □■□
                      If n = 3 Then ' 0 False, -1 True (selected)
                        If sPart = "0" Then F_ooPicBoxesLevels[iPos].Background = Color.Default Else F_ooPicBoxesLevels[iPos].Background = F_iColorSelect
                      Endif 
                      
                      '''Picture-Path: /
                      If n = 4 Then 
                        If String.InStr(sPart, "/") > 0 Then 'File?
                          picPart = Null
                          If Exist(sPart) = True Then picPart = Picture.Load(sPart) 'Else picPart = PicTemplateQuestion.Picture
                          If picPart Then 
                            Add1xClockLevel(picPart, sPart)
                            F_ooPicBoxesLevels[F_ooPicBoxesGallery.Max].Picture = F_ooPicBoxesGallery[F_ooPicBoxesGallery.Max].Picture
                          Endif 
                        Endif
                      Endif
                      
                    Endif 
                  Endif 
                Next
              Endif 
            Endif 'llllllllllllllllllllllllllllllllllllllllllllllll
            
            ''edit:  eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
            If F_bEditChangeON = True And String.InStr(sLevel, "edit=") > 0 Then
              ' ReadMusterTagsToEditlevels(sLevel)
              ssSpliParts = Split(sLevel & String(6, "="), "=")
              If String.InStr(sLevel, "=") = 0 Then ssSpliParts = Null
              iPos = -1
              n = -1
              If ssSpliParts Then 
                For Each sPart In ssSpliParts 
                  If F_iESCpressed > 0 Then Break
                  n = n + 1
                  ''n = 0 '"edit"
                  If sPart Then 
                    ''Number: 0,1,2,3...
                    If n = 1 Then 
                      If IsInteger(sPart) = True Then 
                        iPos = CInteger(sPart) - 1 '.ToolTip Number n-1
                        If iPos < 0 Or iPos > F_ooPicBoxesLevels.Max Then iPos = -1 
                        If iPos > -1 Then Img = F_ooPicBoxesLevels[iPos].Picture.Image
                      Endif
                    Endif
                    '' "mirrorleftright", "mirrortopbottom", "rotateleft", "rotateright", "grayscale", "scaleminus", "scaleplus", "moveleft", "moveright", "moveup", "movedown"
                    If Img And n > 3 And iPos > -1 And iPos < F_ooPicBoxesLevels.Count Then 
                      '*********************************************
                      F_ssEditLevels[iPos] = F_ssEditLevels[iPos] & sPart & "="
                      Img = ImageEditReturn(Img, sPart) 'as Image
                      '*********************************************
                    Endif 
                  Endif 
                  
                Next
                If iPos > -1 And iPos < F_ooPicBoxesLevels.Count Then 
                  F_ooPicBoxesLevels[iPos].Picture = Img.Picture
                Endif 
              Endif 
            Endif 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
            
          Endif 
        Next 
        If iPos > -1 And iPos < F_ooPicBoxesLevels.Count Then PicBoxSelectLevelONoffRefresh(F_ooPicBoxesLevels[iPos])
      Endif 
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterCounter() 'As String 
  
  Dim it, iSelect, iAll As Integer
  Dim sText, sToolTip, sNr As String
  
  If F_ooPicBoxesMuster Then
    it = -1 
    For it = 0 To F_ooPicBoxesMuster.Max
      If Object.IsValid(F_ooPicBoxesMuster[it]) = True Then 
        If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then iSelect = iSelect + 1  '.Count
      Endif 
    Next 
    iAll = F_ooPicBoxesMuster.Max
  Else 
    iAll = -1
  Endif 
  If Object.IsValid(F_oLastPicBoxMuster) = True Then 
    it = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster) ' -1 not found 
    If it > -1 Then sNr = Space(1) & ("Nr") & "." & Str(it + 1)
  Endif
  F_iMusterSelectionCount = iSelect

  sText = ("Muster") & sNr & Space(1) & "(" & Str(iSelect) & ("/") & Str(iAll + 1) & ")" 'Intern .Max, .Count (+1) for User "
  sToolTip = ("Muster") & sNr & Space(1) & "(" & ("Auswahl") & Space(1) & Str(iSelect) & Space(1) & ("von") & Space(1) & Str(iAll + 1) & ")" 
  
  If F_iESCpressed > 0 Then sText &= Space(3) & ("Abbruch mit [ESC]")
  Me.Window.Title = Application.Name & " - " & sText
  
  LabelCounterMuster.Text = sText 
  LabelCounterMuster.Tooltip = sToolTip
  
  ' Return sText
  
Catch 
  FMain.ErrorText
  
End

Public Function GalleryCounter() As String 
  
  Dim it, iSelect, iAll As Integer
  Dim sInfo, sText As String 
  
  If F_ooPicBoxesGallery Then 
    it = -1
    For it = 0 To F_ooPicBoxesGallery.Max
      If F_ooPicBoxesGallery[it].Background = F_iColorSelect Then iSelect = iSelect + 1 '.Count
    Next 
    iAll = F_ooPicBoxesGallery.Max
  Else 
    iAll = -1
  Endif 
  If F_bGallerySortON = True Then sInfo = Space(1) & ("Sortiert")
  
  sText = Str(iSelect) & Space(1) & ("von") & Space(1) & Str(iAll + 1) & sInfo
  LabelCounterGallery.Tooltip = ("Auswahl von Bauteilen") & gb.NewLine & sText
  
  Return sText
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadClockG() 'about picture file. See FMain.LoadClockG()
  
  Dim sDir, sFile, sPath As String 
  ' sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  F_sClockPartsFileNames = Settings[F_sForm &/ "F_sClockPartsFileNames", F_sClockPartsFileNames]
  
  If Exist(sDir) = True Then 
    
    sFile = "clockbackground.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgClockBG = Image.Load(sPath) Else F_imgClockBG = Null
    If F_imgClockBG Then Add1xClockLevel(F_imgClockBG.Picture, sPath)
    
    sFile = "clockcutter.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgClockCutter = Image.Load(sPath) Else F_imgClockCutter = Null
    If F_imgClockCutter Then Add1xClockLevel(F_imgClockCutter.Picture, sPath)
    
    sFile = "clocksunupdown.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgSunUpDown = Image.Load(sPath) Else F_imgSunUpDown = Null
    If F_imgSunUpDown Then Add1xClockLevel(F_imgSunUpDown.Picture, sPath)
    ' If F_imgSunUpDown Then F_sTagsClockSunUpDown = Settings[FMain.Name &/ "F_sTagsClockSunUpDown", F_sTagsClockSunUpDown]
    
    sFile = "clockgearwheel.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgGearWheel = Image.Load(sPath) Else F_imgGearWheel = Null
    If F_imgGearWheel Then Add1xClockLevel(F_imgGearWheel.Picture, sPath)
    
    sFile = "clocknumbers.png" '0-3-6-9-12 or 15-18-21-24
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgClockNumbers = Image.Load(sPath) Else F_imgClockNumbers = Null
    If F_imgClockNumbers Then Add1xClockLevel(F_imgClockNumbers.Picture, F_sTagsClockNumbers)
    
    sFile = "clockhour.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgHour = Image.Load(sPath) Else F_imgHour = Null
    If F_imgHour Then Add1xClockLevel(F_imgHour.Picture, sPath)
    
    sFile = "clockminute.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgMinute = Image.Load(sPath) Else F_imgMinute = Null
    If F_imgMinute Then Add1xClockLevel(F_imgMinute.Picture, sPath)
    
    sFile = "clocksecond.png"
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgSecond = Image.Load(sPath) Else F_imgSecond = Null
    If F_imgSecond Then Add1xClockLevel(F_imgSecond.Picture, sPath)
    
    sFile = "clockcenterpoint.png" '●
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgCenterPoint = Image.Load(sPath) Else F_imgCenterPoint = Null
    If F_imgCenterPoint Then Add1xClockLevel(F_imgCenterPoint.Picture, sPath)
    
    sFile = "clockdatepoint.png" '● terminwecker
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgDatePoint = Image.Load(sPath) Else F_imgDatePoint = Null
    If F_imgDatePoint Then Add1xClockLevel(F_imgDatePoint.Picture, sPath)
    
    sFile = "clockphythagoras.png" 
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgPhythagoras = Image.Load(sPath) Else F_imgPhythagoras = Null
    If F_imgPhythagoras Then 
      ' F_sTagsClockPhythagoras = Settings[FMain.Name &/ "F_sTagsClockPhythagoras", F_sTagsClockPhythagoras]
      Add1xClockLevel(F_imgPhythagoras.Picture, sPath)
    Endif 
    
    sFile = "clockdigital.png" '00:00 Text
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgDigital = Image.Load(sPath) Else F_imgDigital = Null
    If F_imgDigital Then 
      ' F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      Add1xClockLevel(F_imgDigital.Picture, F_sTagsClockDigital)
    Endif 
    
    sFile = "clocklcd.png" '00:00 Text
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgLCD = Image.Load(sPath) Else F_imgLCD = Null
    If F_imgLCD Then 
      ' F_sTagsClockDigital = Settings[FMain.Name &/ "F_sTagsClockDigital", F_sTagsClockDigital]
      Add1xClockLevel(F_imgLCD.Picture, F_sTagsClockLCD)
    Endif 
    
    sFile = "clocktimesummer.png" '02:00<>03:00 Begin +h <> End -h
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then 
      Try F_imgTimeSummer = Image.Load(sPath)
      FMain.F_dateTimeSummerBegin = Settings[FMain.Name &/ "F_dateTimeSummerBegin", Null]
      If FMain.F_dateTimeSummerBegin = Null Then M02Astro.SommerzeitAnfangEnde(F_dateNow) 'calculate
    Else 
      F_imgTimeSummer = Null
    Endif 
    If F_imgTimeSummer Then 
      Add1xClockLevel(F_imgTimeSummer.Picture, sPath)
    Endif 
    
    sFile = "clocknightsky.png" '02:00<>03:00 Begin +h <> End -h
    If String.InStr(F_sClockPartsFileNames, sFile) > 0 Then sPath = sDir &/ sFile Else sPath = Null
    If Exist(sPath) = True Then Try F_imgNightSky = Image.Load(sPath) Else F_imgNightSky = Null
    
  Endif 
  '' —▶ load levels
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckTimerClockPausePicture()
  
  If TimerClock.Enabled = False Then 
    PicBoxPause.Picture = PicTemplatePause.Picture 'Picture["images/stop_32.png"] 
  Else 
    PicBoxPause.Picture = PicTemplateStart.Picture 'Picture["images/start_32.png"] 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckButtonEdit()
  
  ' If Not F_sLevelsTags Then ReadLevelsTag()
  
  Dim iColor1, iColor2 As Integer
  
  ''edit Line
  ' If F_sLevelsTags And String.InStr(F_sLevelsTags, "edit=") > 0 Then
  If F_bEditChangeON = True Then 
    iColor1 = F_iColorSelect
    MenuResetEditLine.Picture = Picture["images/resetedit-on_32.png"]
  Else 
    iColor1 = Color.Default
    MenuResetEditLine.Picture = Picture["images/resetedit-off_32.png"]
  Endif 
  PicBoxLevelsEditNull.Picture = MenuResetEditLine.Picture
  PicBoxLevelsEditNull2.Picture = MenuResetEditLine.Picture
  PicBoxLevelsEditNull.Background = iColor1
  PicBoxLevelsEditNull2.Background = iColor1
  
  ''colorchange Line
  ' If F_sLevelsTags And String.InStr(F_sLevelsTags, F_sColorChangeLineStandard) > 0 Or F_sColorChangeLineStandard <> F_sColorChangeLineUser Then 
  If F_bColorChangeON = True Then 
    iColor2 = F_iColorSelect
    MenuResetColorchangeLine.Picture = Picture["images/colorproperties-rgba_32.png"]
  Else 
    iColor2 = Color.Default 
    MenuResetColorchangeLine.Picture = Picture["images/colorproperties-null_32.png"]
  Endif 
  PicBoxLevelsEditNullColor.Picture = MenuResetColorchangeLine.Picture
  PicBoxLevelsEditNullColor2.Picture = MenuResetColorchangeLine.Picture
  PicBoxLevelsEditNullColor.Background = iColor2
  PicBoxLevelsEditNullColor2.Background = iColor2
  
Catch 
  FMain.ErrorText
  
End

Public Sub LevelsAllSelect()
  
  Dim it As Integer
  
  If PicBoxSelectLevelONoff.Background <> F_iColorSelect Then 
    PicBoxSelectLevelONoff.Background = F_iColorSelect
    ScrollViewLevels.Background = F_iColorSelect
  Else 
    PicBoxSelectLevelONoff.Background = Color.Default
    ScrollViewLevels.Background = Color.Red
  Endif
  
  For it = 0 To F_ooPicBoxesLevels.Max
    F_ooPicBoxesLevels[it].Background = PicBoxSelectLevelONoff.Background
  Next
  ResizePanelLevels()
  SumPaintClockLevels()
  
  Wait 0.5
  ScrollViewLevels.Background = Color.Transparent
  
Catch 
  FMain.ErrorText
  
End

Public Sub LevelsNullEditsOnOff() 
  
  Dim sLevelsTags, sLevel, sLine As String 
  Dim it, iEdits As Integer
  Dim ssSpli, ssSpliParts As String[]
  
  ''On<>Off
  If String.InStr(F_sLevelsTags, "edit=") > 0 Then ''Remove □
    ssSpli = Split(F_sLevelsTags & gb.NewLine, gb.NewLine)
    For Each sLine In ssSpli
      If String.InStr(sLine, "edit=") = 0 Then 
        sLevelsTags &= sLine & gb.NewLine
      Else 
        ssSpliParts = Split(sLine & String(4, "="), "=")
        sLevel = "level=" & "=" & ssSpliParts[1] & "=" & ssSpliParts[2] & "=" & ssSpliParts[3] & "="
        If IsInteger(ssSpliParts[1]) = True Then it = CInteger(ssSpliParts[1]) Else it = -1
        If it > -1 And Object.IsValid(F_ooPicBoxesLevels[it]) = True Then F_ooPicBoxesLevels[it].Border = Border.Plain
        If String.InStr(F_sLevelsTags, sLevel) = 0 Then 
          sLevelsTags &= sLevel & gb.NewLine
          If Not F_ssEditLines Then F_ssEditLines = New String[]
          F_ssEditLines.Add(sLine)
        Endif 
      Endif 
    Next 
    If F_ssEditLines Then F_ssEditLinesUndo = F_ssEditLines.Copy()
    If F_ssEditLevels Then F_ssEditLevelsUndo = F_ssEditLevels.Copy()
    ' F_ssEditLevels = Null
    iEdits = 0
    sLevelsTags = sLevelsTags & gb.NewLine
    F_sLevelsTags = sLevelsTags
    
  Else  ''Redo ■
    If F_ssEditLinesUndo Then F_ssEditLines = F_ssEditLinesUndo.Copy() ''◀——
    If F_ssEditLevels Then 
      ssSpli = Split(F_sLevelsTags & gb.NewLine, gb.NewLine)
      For Each sLine In ssSpli
        If String.InStr(sLine, "level=end") = 0 Then 
          sLevelsTags &= sLine & gb.NewLine
        Else 
          sLevel = "" 'Reset
          If F_ssEditLines Then 
            For it = 0 To F_ssEditLines.Max
              If F_ssEditLines[it] And String.InStr(F_sLevelsTags, F_ssEditLines[it]) = 0 Then 'not double
                sLevel &= F_ssEditLines[it] & gb.NewLine
                iEdits = iEdits + 1
              Endif 
            Next 
          Endif
          sLevelsTags &= sLevel & gb.NewLine 'level=end
          Break
        Endif 
      Next 
      sLevelsTags = sLevelsTags & gb.NewLine
      F_sLevelsTags = sLevelsTags
      F_ssEditLines = Null
    Endif 
  Endif
  
  LoadLevelsNewNull()
  LoadLevels(F_sLevelsTags)
  ResizePanelLevels()
  SumPaintClockLevels()
  
  LabelMessageText(("edit") & " = " & iEdits)
  ' CheckButtonEdit()
  ' Print F_sLevelsTags
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub LevelsNullColorChangeOnOff() 
  
  Dim sLevelsTags, sLevel, sLine As String 
  Dim it, iEdits As Integer
  Dim ssSpli As String[]
  
  ''On<>Off
  If Not F_iiColorChangeUndoLevels Or String.InStr(F_sLevelsTags, "colorchange=") > 0 Then 
    F_iiColorChangeUndoLevels = F_iiIconClockColorsB.Copy()
    F_iiIconClockColorsB = F_iiIconClockColorsA
    ssSpli = Split(F_sLevelsTags & gb.NewLine, gb.NewLine)
    For Each sLine In ssSpli
      If String.InStr(sLine, "colorchange=") = 0 Then sLevelsTags &= sLine & gb.NewLine
    Next 
    sLevelsTags = sLevelsTags & gb.NewLine
    F_sLevelsTags = sLevelsTags
    ' Print "A", F_sLevelsTags  
  Else  ''Redo
    If F_iiColorChangeUndoLevels Then F_iiIconClockColorsB = F_iiColorChangeUndoLevels.Copy()
    If F_iiIconClockColorsB Then 
      F_iiColorChangeUndoLevels = Null
      ssSpli = Split(F_sLevelsTags & gb.NewLine, gb.NewLine)
      For Each sLine In ssSpli
        If String.InStr(sLine, "level=end") = 0 Then 
          sLevelsTags &= sLine & gb.NewLine
        Else 
          sLevel = "colorchange="
          For it = 0 To F_iiIconClockColorsB.Max
            sLevel &= F_iiIconClockColorsB[it] & "="
          Next 
          sLevelsTags &= sLevel & gb.NewLine 'level=end
          sLevelsTags &= sLine & gb.NewLine
          iEdits = iEdits + 1 
          Break
        Endif 
      Next 
      sLevelsTags = sLevelsTags & gb.NewLine
      F_sLevelsTags = sLevelsTags
    Endif 
    ' Print "B", F_sLevelsTags
  Endif 
  ' ColorsUserToBoxes(F_iiIconClockColorsB)
  ' ColorChangeLevelsPicture(F_iiIconClockColorsB)
  LoadLevelsNewNull()
  LoadLevels(F_sLevelsTags)
  ResizePanelLevels()
  SumPaintClockLevels()
  LabelMessageText(("colorchange") & " = " & iEdits)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub LoadLevelsNewNull() 'hide, not delete
  
  Dim it As Integer
  
  If F_iESCpressed > 0 Then Return 'end here
  
  ''On —▶ Off
  If F_ooPicBoxesLevels Then 
    For it = 0 To F_ooPicBoxesLevels.Max
      F_ooButtonsLevels[it].Visible = False 
      F_ooPicBoxesLevels[it].Visible = False
      F_ooPicBoxesLevels[it].Picture = F_ooPicBoxesGallery[it].Picture ''Gallery = Original
    Next 
    F_ssEditLevels = Null
    F_iiIconClockColorsB = F_iiIconClockColorsA
    
    For it = 0 To F_ooPicBoxesGallery.Max
      F_ooPicBoxesGallery[it].Background = Color.Default 
    Next 
    PicBoxSelectLevelONoff.Picture = Null
    PicBoxSelectLevelONoff.Background = Color.Default
    PicBoxClockBG.Picture = Null
    ' F_oLastPicBoxObject = Null
  Endif
  ' If F_ssEditLevels Then F_ssEditLevels = Null
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub MusterNullNew() ' delete all
  
  If F_iESCpressed > 0 Then Return 'end here
  
  ''On —▶ Off
  If F_ooPicBoxesMuster Then 
    ''Clear:
    If ScrollViewMuster.Children Then ScrollViewMuster.Children.Clear() 'delete all
    If F_ooPicBoxesMuster Then F_ooPicBoxesMuster.Clear()
    If F_ooButtonMuster Then F_ooButtonMuster.Clear()
    F_ooPicBoxesMuster = Null
    F_ooButtonMuster = Null
    LabelInfo.Visible = False
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub OpenDialogPicture(Optional sDirFile As String = "")
  
  Dim sPathLast, sPath, sDir As String
  Dim hPic As Picture
  
  'Beispiel--------------------------
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  'Dialog.Filter = ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .save(JPG-Datei, Qualität 1 bis 100)
  If Exist(sDirFile) = True Then
    sPath = sDirFile
  Else 
    ''File:
    sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
    sDirFile = Settings[FMain.Name &/ "F_sPathClockBackground_png", FMain.F_sPathClockBackground_png]
    sPathLast = Settings[FMain.Name &/ "sPathFoto", sDirFile]
    ' sDir = File.Dir(sPathLast)
    ''Filter1:
    ' If Exist(sDir) = True Then 
    '   ' Filter1 = "*.png" 
    '   ' FilterText1 = ("Bilder")
    ' Else 
    '   ' sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
    '   ' Filter1 = "*.png;*.jpg;"
    '   ' FilterText1 = ("Bilder")
    ' Endif
    sPath = FileDialogPathReturn(sPathLast, "open", sDirFile) 'Last-Path, open/save, Standard-Path
    If Not sPath Then Return 
    
    ''Filter2:
    ' sPattern = "*.{png,jpg,jpeg,gif,bmp,xpm,svg}" 'Attention, not as Filter: ["*.png;*jpg;*.jpeg;*.gif;"]
    ' iFound = Dir(sDir, sPattern, gb.File).Count 'as Integer
    ' sDirName = File.BaseName(sDir)
    ' Filter2 = "*.png;*.jpg;*.jpeg;*.gif;*.bmp;*.xpm;*.svg;"
    ' FilterText2 = Str(iFound) & Space(1) & ("Bilder in") & ": " & sDirName & "..."
    ' 
    ' ''Dialog:
    ' Dialog.Title = ("Eine Bild-Datei auswählen...")
    ' Dialog.Filter = [Filter1, FilterText1, Filter2, FilterText2] 'as String[] ' + "*.* "All files"  'autom. 
    ' Dialog.Path = sPathLast
    ' If Dialog.OpenFile() Then Return '=Kurzform ' TRUE=User pressed Cancel
    
    ''Open:
    ' sPath = Dialog.Path
  Endif 
  
  If Exist(sPath) = True Then 'Null is Canceled
    Try hPic = Picture.Load(sPath)
    If hPic Then 
      Settings[FMain.Name &/ "sPathFoto"] = sPath
      MenuOpenRecentG(sPath)
      F_sLoadUserPaths = Settings[F_sForm &/ "F_sLoadUserPaths", Null]
      If String.InStr(F_sLoadUserPaths, sPath) = 0 Then 
        Settings[F_sForm &/ "F_sLoadUserPaths"] = F_sLoadUserPaths & gb.NewLine & sPath 'add, but not double
        ''open and add the picture:
        Add1xClockLevel(hPic, sPath) 
        If Object.IsValid(F_oLastPicBoxObject) = True Then FileTempSave(F_oLastPicBoxObject)
        ResizePanelLevels()
        ResizePanelGallery()
        RefreshSelectColorGroupLevelsGallery()
        SumPaintClockLevels()
        ' ScrollViewGallery.ScrollY = ScrollViewGallery.ScrollH
        MenuOpenRecentG(sPath)
      Else 
        ScrollViewEnsureVisibleG(sPath)
        Message.Info(sPath & "<h3><font color=darkgreen><b>" & "Das Bild wurde bereits hinzugefügt." & "</b></font></h3>")
      Endif 
    Else 
      ''Error, not loaded?
      Message.Info(sPath & "<h3><font color=red><b>" & "Das Bild konnte nicht geladen werden." & "</b></font></h3>")
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideG(Optional sSide As String = "gallery")
  
  ''Reset:
  PicBoxPenguin.Visible = False 
  PanelHead.Visible = False 
  PanelLevels.Visible = False
  PanelMenuEdit.Visible = False
  PanelZoom.Visible = False 
  PanelMenuColor.Visible = False 
  PanelMemoryColors.Visible = False 
  PanelColorSave2.Visible = False 
  PanelColor.Visible = False 
  PanelSave.Visible = False 
  PanelPath.Visible = False 
  PanelColorZoom.Visible = False 

  F_bPanelMenuEditON = False 
  F_bMemoryColorsPanelON = False 
  F_bPanelPathON = False 
  Me.Window.Title = Application.Name & " - " & ("Baukasten")
  
  PanelColorPicker.Visible = False
  PanelColorChooser.Visible = False
  ' PanelColorSave.Visible = False
  PanelDateTime.Visible = False
  LabelCounterGallery.Foreground = Color.LightGray
  F_sSideG = sSide
  
  Select Case sSide
    Case "gallery" 'engl. Gallery, german Galerie, italienisch Galleria
      PanelHead.Visible = True 
      PanelLevels.Visible = True 
      PicBoxPenguin.Visible = True 
      PanelMuster.Visible = False 
      PanelGallery.Visible = True
      ' PanelPath.Visible = F_bMoreButtons 
      F_bPanelMenuEditON = True
      ' F_bPanelMenuEditON = F_bMoreButtons 
      F_bPanelPathON = F_bMoreButtons
      PanelSave.Visible = True
      CheckTimerClockPausePicture()
      PicBoxMusterSide.Background = Color.Default
      LabelCounterGallery.Foreground = Color.Gray
      Form_Resize()
      
    Case "muster"
      ' PanelColumnView4.Visible = True 'xxxxxx
      
      
      PanelHead.Visible = True 
      PanelLevels.Visible = True 
      PicBoxPenguin.Visible = True 
      PanelGallery.Visible = False
      PanelMuster.Visible = True 
      PanelSave.Visible = True
      PicBoxMusterChange.Background = Color.Default
      PicBoxMusterSide.Background = F_iColorSelect
      F_bPanelMenuEditON = True
      ' F_bPanelMenuEditON = F_bMoreButtons 
      F_bPanelPathON = F_bMoreButtons
      Form_Resize()
      MusterCounter() 'as String  "0/0"
      
    Case "color" 'colors
      ' TimerColorPicker.Stop()
      PicBoxPenguin.Visible = True 
      ' PanelColorSave1.Visible = True
      ' PanelGallery.Visible = True
      PanelHead.Visible = True
      PanelLevels.Visible = True 
      PicBoxPickerColor.Background = Color.Default
      PicBoxPickerTransparent.Background = Color.Default
      PicBoxMusterSide.Background = Color.Default
      ColorChooser1.SelectedColor = F_iColorPicker
      PanelColor.Visible = True
      PanelMenuColor.Visible = True
      PanelColorZoom.Visible = True 
      F_bMemoryColorsPanelON = True
      Form_Resize()
      F_iiIconClockColorsBbefore = F_iiIconClockColorsB
      
     Case "colormemory" 'colors
      ' TimerColorPicker.Stop()
      PicBoxPenguin.Visible = True 
      ' PanelColorSave1.Visible = True
      ' F_bMemoryColorsPanelON = True
      PanelHead.Visible = True
      PanelLevels.Visible = True 
      PicBoxPickerColor.Background = Color.Default
      PicBoxPickerTransparent.Background = Color.Default
      PicBoxMusterSide.Background = Color.Default
      ColorChooser1.SelectedColor = F_iColorPicker
      PanelSave.Visible = True 
      F_bMemoryColorsPanelON = True 
      ' PanelColor.Visible = True
      ' PanelMenuColor.Visible = True
      ' PanelColorZoom.Visible = True 
      ' If sSide = "colormemory" Then PanelColor = True
      Form_Resize()
      
    Case "colorchooser", ButtonMenuColor.Tag 'colors
      PanelZoom.Visible = True  
      PanelColorSave1.Visible = True
      PanelColorChooser.Visible = True
      ' TimerColorPicker.Stop()
      PicBoxPickerColor.Background = Color.Default
      PicBoxPickerTransparent.Background = Color.Default
      PicBoxMusterSide.Background = Color.Default
      ColorChooser1.SelectedColor = F_iColorPicker
      
    Case "colorpicker"
      PanelZoom.Visible = True  
      ' PanelColorPicker.Visible = True
      ' PanelColorSave1.Visible = True
      PicBoxMusterSide.Background = Color.Default
      
    Case "datetime" ', LabelTimePause.Tag 
      PicBoxPenguin.Visible = True  
      PanelDateTime.Visible = True
      
      If F_dateNow Then DateChooser1.Value = F_dateNow
      DateChooser1.Mode = DateChooser1.DateTime 'Attention: in properties > Font-Error (stretch min.?)
      ClockTimeList0to24h()
      
  End Select
  ' PanelSave.Visible = Not PanelMenuColor.Visible
  ' If PanelSave.Visible = True And F_bMoreButtons = True Then PanelPath.Visible = True Else PanelPath.Visible = False
  RefreshLabelUndoRedoCounterText()
  
Catch 
  FMain.ErrorText()
  IconError.Visible = True
  IconError.Raise() 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  Me.Mouse = Mouse.Default
  
End

Public Sub SideG2(Optional iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 As Integer = 0)
  TimerZoomLupe.Stop()
  PanelColor.Visible = True 
  ColorChooser2.Visible = False 
  PicturePhoto.Visible = False
  PanelWebTextCode.Visible = False
  PanelCopyImage.Visible = False
  Webview1.Visible = False 
  TextAreaText.Visible = False 
  TextAreaCode.Visible = False
  ColumnView2.Visible = False 
  PicBoxWebColorNamesSort.Border = Border.None
  PicBoxColumnviewColorNamesFind.Border = Border.None
  PicBoxColorChooser.Border = Border.None
  ' PicBoxMemoryColors.Border = Border.None
  WindowT5plus.Picture = PicTemplatePageMini.Picture
  
  ' If F_iLastSide = iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 Then 
  '   iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7 = 2
  ' Endif
  
  ' Select Case F_iLastSide
  '   Case 1
  '     PicBoxColorChooser.Border = Border.Plain
  '   Case 3
  '     PicBoxColumnviewColorNamesFind.Border = Border.Plain
  '   Case 4
  '     PicBoxWebColorNamesSort.Border = Border.Plain
  ' End Select
  
  Select Case iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
    Case 0
      ''...
    Case 1 ''ColorChooser
      ColorChooser2.Visible = True  
      PicBoxColorChooser.Border = Border.Plain
      F_iLastSideBefore = F_iLastSide
    Case 2 ''Photo
      PicturePhoto.Visible = True
      TimerZoomLupe.Start()
      F_iLastSideBefore = F_iLastSide
    Case 3 ''ColumnView
      PanelWebTextCode.Visible = True 
      ColumnView2.Visible = True  
      PicBoxColumnviewColorNamesFind.Border = Border.Plain
      If ColumnView2.Columns.Max < F_iColumns14Count Then 
        ColumnView2.Clear
        ReadG2()
        ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      Endif 
      F_iLastSideBefore = F_iLastSide
    Case 4  ''Web, HTML
      PanelWebTextCode.Visible = True 
      Webview1.Visible = True 
      WebView1.FindText(TextBoxHexaHTML.Text, False, True, False) 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      PanelWebTextCode.Raise()
      TextAreaSearch.SelectAll()
      TextAreaSearch.Insert(TextBoxColorName.Text)
      PicBoxWebColorNamesSort.Border = Border.Plain
      F_iLastSideBefore = F_iLastSide
    Case 5 ''CopyImage
      PanelCopyImage.Visible = True 
    Case 6 ''Text
      PanelWebTextCode.Visible = True 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      TextAreaText.Wrap = False '---line---->|
      TextAreaText.Visible = True 
      TextAreaText.SelectAll()
      TextAreaText.Insert(TextBoxHTML.Text & gb.NewLine & gb.NewLine & ColorRGBtoHUEinfo(ColorChooser2.SelectedColor) & gb.NewLine & gb.NewLine & WebView1.Text)
      TextAreaText.Pos = 1
      WindowT5plus.Picture = PicTemplatePageMaxi.Picture
      F_iLastSideBefore = F_iLastSide
      
    Case 7 ''Code
      PanelWebTextCode.Visible = True 
      If Not WebView1.Url Then WebViewURL("colornamessort.htm")
      TextAreaCode.Visible = True 
      TextAreaCode.SelectAll()
      TextAreaCode.Insert(WebView1.Document.HTML)
      TextAreaCode.Pos = 1
      F_iLastSideBefore = F_iLastSide
    Case Else 
      ''...
  End Select
  
  F_iLastSide = iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  
  If PicturePhoto.Visible = False And F_rectZoom Then 
    PicBoxZoomLupe.Picture = PicturePhoto.Picture
    ' PicBoxZoomLupe.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)
    PicBoxZoomLupe.Move(F_rectZoom.X, F_rectZoom.Y, F_rectZoom.W, F_rectZoom.H)
    PicBoxZoomLupe.Visible = True 
    ' PicBoxZoomLupe.Mouse = Mouse.Cross
  Endif 

  If PanelMenuColor.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
  If PicturePhoto.Visible = False Then PicBoxPickerColor.Background = Color.Default
  If Not PicturePhoto.Picture Then 
    F_picScreen = PicBoxPhoto2.Picture
    PicturePhoto.Picture = F_picScreen
    PicBoxZoomLupe.Picture = F_picScreen
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RefreshLabelUndoRedoCounterText()
  
  Dim iMax As Integer
  
  If PanelMuster.Visible = True Then 
    'only .Max
    If Not F_ssUndoRedoMuster Then iMax = -1 Else iMax = F_ssUndoRedoMuster.Max 
    LabelUndoRedoCounterMuster.Text = Str(F_iUndoRedoMusterPointer + 1) & "/" & Str(iMax + 1) 
    PicBoxUndo.Visible = True 
    LabelUndoRedoCounter.Visible = True 
    PicBoxRedo.Visible = True 
  Else 
    If Not F_ssUndoRedoLevels Then iMax = -1 Else iMax = F_ssUndoRedoLevels.Max 
    LabelUndoRedoCounter.Text = Str(F_iUndoRedoLevelPointer + 1) & "/" & Str(iMax + 1) 
    PicBoxUndo.Visible = True 
    LabelUndoRedoCounter.Visible = True 
    PicBoxRedo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TimerColorPicker_Timer() ''CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  '.Delay = 1000  1Secound
  ' F_bColorPickerAreaON = True
  If F_bColorPickerAreaON = True Then  
    ' F_picScreen = Desktop.Screenshot() 'as Picture  Refresh
    ' If F_picScreen Then PickerColorFill()
    PicBoxMenuColorPicker.Background = Color.Green
    PicBoxPickerColor3.Background = Color.Green
    
    ' PicBoxScreenshot.Visible = False
    CursorFillObject()
    ' PicBoxZoomLupe.Visible = True 
    ' ZoomArea()
  Else 
    PicBoxMenuColorPicker.Background = Color.Default 
    PicBoxPickerColor3.Background = Color.Default 
    TimerColorPicker.Stop()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ScreenshotPhotoNew()
  
  ' F_picScreen = Desktop.Screenshot() 'as Picture  Refresh
  F_picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  If M01Functions.ScreenshotImageExist(F_picScreen.Image) = False Then 
    F_picScreen = M01Functions.ScreenshotImageAlternative().Picture
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PickerColorFill()
  '.Delay = 1000  1Secound
  
  Dim Img As Image '(PicBoxPicker1.W, PicBoxPicker1.H, True)
  Dim iZoom As Integer
  
  iZoom = F_iZoomFactorCursor
  
  ''Zoom:
  If F_picScreen Then
    ''Picker: 
    If F_iColor0Picker1Transparent2 = 1 Then 
      Img = PicBoxPickerColor.Picture.Image.Copy() 'Default ColorPicker 1
    Else If F_iColor0Picker1Transparent2 = 2 Then 
      Img = PicBoxPickerTransparent.Picture.Image.Copy() 'Default ColorPicker 1
    Else 
      Img = Null
    Endif 
    PicBoxColorZoom.Picture = F_picScreen.Copy(Mouse.ScreenX - iZoom, Mouse.ScreenY - iZoom, iZoom * 2, iZoom * 2)
  Endif 
  
  If Img Then 
    ''Color:
    If PanelColorChooser.Visible = True Then 
      F_iColorPicker = ColorChooser1.SelectedColor
    Else If F_picScreen Then 
      F_iColorPicker = F_picScreen.Image[Mouse.ScreenX, Mouse.ScreenY] 'as Integer
      F_iColorBefore = F_iColorPicker
      F_iColorBehind = F_iColorPicker
      LabelColorSelected.Background = F_iColorBefore
    Endif
    'New Cursor ( Picture As Picture [ , X As Integer, Y As Integer ] )
    ' PicBoxScreenshot.Cursor = New Cursor(Img.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 
    ' PicBoxScreenshot.Mouse = Mouse.Custom
    PicturePhoto.Cursor = New Cursor(Img.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 
    PicturePhoto.Mouse = Mouse.Custom
    CheckFontColor()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxScreenshot_Enter()
  
  ' F_bColorPickerAreaON = True 
  F_oColorPickerLastObj = PicBoxScreenshot 'as PictureBox
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxScreenshot_Leave()
  
  ' F_bColorPickerAreaON = False 
  F_oColorPickerLastObj = Null
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxScreenshot_MouseDown()
  
  Dim it, iColor As Integer
  
  ' F_iColor0Picker1Transparent2 = 0
  TimerColorPicker.Stop()
  SideG("color")
  CheckFontColor()
  PicBoxPickerColor.Background = Color.Default
  PicBoxPickerTransparent.Background = Color.Default
  ' ButtonColorApply.Background = F_iColorSelect
  ' ButtonColorApply.Border = True 
  
  If PicBoxClock.Picture Then
    Select Case F_iColor0Picker1Transparent2
      Case 0
        '...
      Case 1
        ''Picker Color: 
        PicBoxClock.Picture = PicBoxClock.Picture.Image.Replace(F_iColorBefore, F_iColorPicker).Picture
      Case 2
        ''Picker Transparent: 
        PicBoxClock.Picture = PicBoxClock.Picture.Image.Replace(F_iColorBefore, F_iColorPickerTrans).Picture
    End Select
  Endif 
  
  If PanelColorBoxesB.Children Then 
    For it = 0 To PanelColorBoxesB.Children.Max
      If F_iColorPicker = PanelColorBoxesB.Children[it].Background Then 
        'Show for user
        iColor = PanelColorBoxesB.Children[it].Background
        PanelColorBoxesB.Children[it].Background = F_iSelectBlue150
        Wait 0.3
        PanelColorBoxesB.Children[it].Background = iColor 
        Wait 0.3
        PanelColorBoxesB.Children[it].Background = F_iSelectBlue150
        Wait 0.3
        PanelColorBoxesB.Children[it].Background = iColor 'Reset
        If F_iColor0Picker1Transparent2 = 2 Then 
          PanelColorBoxesB.Children[it].Background = Color.SetAlpha(PanelColorBoxesB.Children[it].Background, 0)
        Endif
        Break 
      Endif
    Next
    ' TextLabelColorInfo.Visible = True 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ScreenshotPhotoStop()
  
  ' F_iColor0Picker1Transparent2 = 0
  PanelColorPicker.Visible = False 
  TimerColorPicker.Stop()
  ' SideG("color")
  CheckFontColor()
  PicBoxPickerColor.Background = Color.Default
  PicBoxPickerTransparent.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorChangePicturePath()
  
  Dim it As Integer
  Dim Img As Image
  Dim it2 As Integer
  
  If F_iiIconClockColorsA And F_iiIconClockColorsB Then 
    If F_iiIconClockColorsA.Count <> F_iColorsCount Then F_iiIconClockColorsA.Resize(F_iColorsCount)
    If F_iiIconClockColorsB.Count <> F_iColorsCount Then F_iiIconClockColorsB.Resize(F_iColorsCount)
    For it = 0 To F_ooPicBoxesGallery.Max
      If Exist(F_ooPicBoxesGallery[it].Tag) = True Then 'is User-Picture
        If F_ooPicBoxesGallery[it].Picture Then 
          Img = F_ooPicBoxesGallery[it].Picture.Image
          For it2 = 0 To F_iiIconClockColorsB.Max
            Img = Img.Replace(F_iiIconClockColorsA[it2], F_iiIconClockColorsB[it2])
          Next
          F_ooPicBoxesGallery[it].Picture = Img.Picture
        Endif
      Endif 
    Next
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorChangeLevelsPicture()
  
  Dim it, it2 As Integer
  Dim Img As Image
  Dim iiColorsUser As Integer[]
  
  ' If F_ooPicBoxesLevelsOnlyVisible Then 
  '   ooPicBoxesLevelsVisible = F_ooPicBoxesLevelsOnlyVisible 'Min. Selection
  ' Else 
  ' ooPicBoxesLevelsVisible = F_ooPicBoxesLevels 'Max. All
  ' Endif
  
  If F_ooPicBoxesGallery And F_ooPicBoxesLevels Then 
    If Not iiColorsUser Then iiColorsUser = F_iiIconClockColorsB
    If Not iiColorsUser Then 
      If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
      If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
      iiColorsUser = F_iiIconClockColorsB
    Endif 
    If Not F_ooPicBoxesColorsB Then CreatePanelMemoryColors()
    ' If iiColorsUser.Count <> F_ooPicBoxesColorsB.Count Then iiColorsUser.Resize(F_ooPicBoxesColorsB.Count)
    
    For it = 0 To F_ooPicBoxesLevels.Max 'Note: F_ooPicBoxesLevels.Max = F_ooPicBoxesGallery.Max
      ' If Object.IsValid(ooPicBoxesLevelsVisible[it]) = True Then 'is User-Picture
      If F_ooPicBoxesLevels[it].Visible = True And F_ooPicBoxesLevels[it].Picture Then 
        ' iNr = CInteger(ooPicBoxesLevelsVisible[it].ToolTip) - 1
        ' iNr = F_ooPicBoxesLevels.Find(ooPicBoxesLevelsVisible[it])
        ' If iNr > -1 And iNr < F_ooPicBoxesLevels.Count Then 
        ' Img = F_ooPicBoxesLevels[iNr].Picture.Image 'from original
        Img = F_ooPicBoxesGallery[it].Picture.Image
        For it2 = 0 To iiColorsUser.Max
          If it2 < F_iiIconClockColorsB.Count Then 
            If F_iiIconClockColorsA[it2] = iiColorsUser[it2] Then 
              '...
            Else 
              ' F_ooPicBoxesColorsB[it2].Background = iiColorsUser[it2]
              Img = Img.Replace(F_iiIconClockColorsA[it2], iiColorsUser[it2])
            Endif
          Endif 
        Next
        ' F_ooPicBoxesLevels[iNr].Picture = Img.Picture
        F_ooPicBoxesLevels[it].Picture = Img.Picture
        
        ' Endif 
      Endif
      ' Endif 
    Next
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFontColor() '1 2 3 ...
  
  Dim oObj As Object
  Dim iColor, iFound As Integer
  
  'Alternative: F_ooPicBoxesColorsA[it] = PanelColorBoxesA.Children[it]
  
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[FMain.Name &/ "F_iiIconClockColorsB", Null]
  If F_iColorBoxesPointer < 0 Then F_iColorBoxesPointer = Settings[FMain.Name &/ "F_iColorBoxesPointer", 0]
  
  If F_iiIconClockColorsA Then 
    iFound = F_iiIconClockColorsA.Find(F_iColorPicker)
    If iFound > -1 Then F_iColorBoxesPointer = iFound '□■□□□
  Endif
  
  ''Colors: User
  If F_ooPicBoxesColorsB Then 'Boxes
    If F_iColor0Picker1Transparent2 < 2 Then 
      iColor = F_iColorPicker
    Else If F_iColor0Picker1Transparent2 = 2 Then 
      iColor = Color.SetAlpha(F_iColorPicker, 255)
    Endif 
    PicBoxColorSelectedBorder.Background = iColor
    ' ButtonColorPotNumber.Background = iColor 'without Alpha-Transparent. Show Color, .Border = True? 
    ' TextLabelColorNr.Text = "<font size=3>"
    ' TextLabelColorNr.Text &= "RGBA(<font color=red>" & M01Functions.ColorInfoRGB(iColor, "Red") & "</font>" & ", "
    ' TextLabelColorNr.Text &= "<font color=green>" & M01Functions.ColorInfoRGB(iColor, "Green") & "</font>" & ", "
    ' TextLabelColorNr.Text &= "<font color=blue>" & M01Functions.ColorInfoRGB(iColor, "Blue") & "</font>" & ", "
    ' TextLabelColorNr.Text &= "<font color=gray>" & M01Functions.ColorInfoRGB(iColor, "Alpha") & "</font>" & ")"
    ' TextLabelColorNr.Text &= "</font>"
    
    ' If M01Functions.ColorInfoRGB(iColor, "L") < 150 Then ButtonColorPotNumber.Foreground = Color.White Else ButtonColorPotNumber.Foreground = Color.Black
  Endif
  
  ''Button-Text readable on dark and light color:
  'I can't see the text? ○—▷□ White text in white background? ●—▶■ Black text in black background?
  ' ButtonColorPotNumber.Text = ("Farbe") & Space(1) & Str(F_iColorBoxesPointer + 1) & ">"
  ' ButtonColorPotNumber.Tooltip = ("Neue Farbe für") & Space(1) & Str(F_iColorBoxesPointer + 1)
  ' TextLabelColorNr.Tooltip = ("Farb-Punkt (Rot, Grün, Blau, Transparent)")
  
  If F_ooPicBoxesColorsB Then 
    For Each oObj In F_ooPicBoxesColorsB
      If Object.IsValid(oObj) = True Then
        oObj.Font.Bold = False
        ' oObj.Font.Size = ButtonColorPotNumber.Font.Size
        If M01Functions.ColorInfoRGB(oObj.Background, "L") < 150 Then oObj.Foreground = Color.White Else oObj.Foreground = Color.Black
        If F_iColor0Picker1Transparent2 = 2 Then oObj.Foreground = Color.Gray
      Endif 
    Next
    'Check Min-Max
    If F_iColorBoxesPointer < 0 Then F_iColorBoxesPointer = 0
    If F_iColorBoxesPointer > F_ooPicBoxesColorsB.Max Then F_iColorBoxesPointer = F_ooPicBoxesColorsB.Max
    
    If F_ooPicBoxesColorsB Then 
      If F_ooPicBoxesColorsB.Max > 0 Then  
        ''Selected:
        F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Bold = True 
        F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = 22
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxScreenshot_MouseWheel()
  
  If Mouse.Delta >= 0 Then 'as Float
    ' If Mouse.Forward = Then 'as Boolean
    ScrollViewGallery.ScrollY = ScrollViewGallery.ScrollY - F_iScrollPart
  Else 
    ScrollViewGallery.ScrollY = ScrollViewGallery.ScrollY + F_iScrollPart
  Endif
  PicBoxScreenshot_MouseDown()
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelColorPicker_MouseWheel()
  
  If Mouse.Delta >= 0 Then 'as Float
    ' If Mouse.Forward = Then 'as Boolean
    ScrollViewGallery.ScrollY = ScrollViewGallery.ScrollY - F_iScrollPart
  Else 
    ScrollViewGallery.ScrollY = ScrollViewGallery.ScrollY + F_iScrollPart
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorChooser1_Change()
  
  If F_bChangeON = True Then 
    TimerColorPicker.Stop()
    ' F_bColorPickerAreaON = True 
    F_oColorPickerLastObj = Null
    F_iColorPicker = ColorChooser1.SelectedColor
    F_iColorBehind = F_iColorPicker
    ' CheckFontColor()
    PicBoxColorSelectFG.Background = ColorChooser1.SelectedColor
  Endif 

Catch 
  FMain.ErrorText
  
End

Public Sub ColorChooser2_Change()

  ColorSelected()

Catch 
  FMain.ErrorText
  
End

Public Sub ColorChooser1_Leave()
  
  ' F_bColorPickerAreaON = False 
'   
' Catch 
'   FMain.ErrorText
  
End

Public Sub MenuGroup_Click()
  Dim sDirFile, sText As String
  
  ''[ESC]?
  
  F_iESCpressed = 0 'Reset
  F_bESCpressedON = False
  
  Select Case String.LCase(Last.Tag)
    Case "findcurrentmuster"
      FindCurrentMuster()
      
    Case "mustertextentwurf"
      sText = ReadLevelsTag() 'level=begin...level=
      If Not sText Then sText = ("Leer. Aktuell kein Entwurf in Bearbeitung als Uhr-Muster.")
      If sText Then 
        Form3Text.Tag = sText
        Form3Text.Show()
      Endif  
      
    Case "mustertextaktuell"
      sText = ReadMusterTags() 'level=begin...level=
      If Not sText Then sText = ("Leer. Aktuell keine Uhr-Muster in der Seite.")
      If sText Then 
        Form3Text.Tag = sText
        Form3Text.Show()
      Endif  
    Case "mustertextsettings"
      sText = Settings[F_sForm &/ "F_sLevelsTags", Null] 'level=begin...level=
      If Not sText Then sText = ("Leer. Aktuell keine Uhr-Muster gespeichert in Settings[].")
      If sText Then 
        Form3Text.Tag = sText
        Form3Text.Show()
      Endif  
    Case "mustertextfile"
       sDirFile = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 
       Form3Text.Tag = sDirFile
       Form3Text.Show()
       
    Case "cancel", MenuCancel1.Tag
      '...
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      ' Clipboard.Copy(M01Functions.ScreenshotImageAreaFormWayland())
      ' Clipboard.Copy(M01Functions.ScreenshotImageDesktopx11Window())
    Case "cancelform"
      Me.Window.Close
      
    Case "myselectioncolor1"
      'F_iiColorSelect = [Color.SetAlpha(Color.Green, 190), Color.SetAlpha(-922812161, 190), Color.SetAlpha(1677787135, 100)]
      'HTML-Color-Name alternative: indianred,aquamarine,moccasin,yellowgreen,springgreen,tan,limegreen
      ColorSelectChange(F_iColorSelect, F_iiColorSelect[0]) '   Color.Green
      
    Case "myselectioncolor2"
      ColorSelectChange(F_iColorSelect, F_iiColorSelect[1])'   like Softpurple
      
    Case "myselectioncolor3"
      ColorSelectChange(F_iColorSelect, F_iiColorSelect[2])'   like Aqua (Wasser, Himmelblau)
      
    Case "myselectioncolor4"
      ColorSelectChange(F_iColorSelect, F_iiColorSelect[3])'   Natur, Penguin foots like orange
      
    Case "myselectioncolor5"
      ColorSelectChange(F_iColorSelect, F_iiColorSelect[4])'   Color.DarkGreen
      
    Case "opensource"
      Form20OpenSource.Window.Show
      ' Form20OpenSource.Window.Visible = True 'Wayland error?
      
    Case MenuPhoto.Tag 
      Form15Foto.Window.Show
      
    Case "randomizeinfo", MenuRandomizeInfo.Tag
      Form3Text.Tag = M06InfoText.RandomizeInfo()
      Form3Text.Show()
      Form3Text.Visible = True 
      Form3Text.Raise()
      Form3Text.TextArea1.Wrap = True '—▶Public TRUE?
      
    Case "formmaximal"
      FullScreenONoff() ''F11
      
    Case Else 
      F_sTagLastMenu = Last.Tag
      ButtonGroupSelect(Last.Tag)
      
  End Select
  If Object.Type(Last) = "Menu" Then Last.Close()
  ProgressBar1.Pulse = False
  ProgressBar1.Visible = False 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FindMusterColor()
  
  Dim it, iCount, iAll As Integer
  Dim sColorChange As String
  
  sColorChange = "colorchange="
  If F_ooPicBoxesColorsB Then 
    For it = 0 To F_ooPicBoxesColorsB.Max
      sColorChange &= F_ooPicBoxesColorsB[it].Background & "="
    Next
  Endif 
  
  If F_ooPicBoxesMuster Then 
    For it = 0 To F_ooPicBoxesMuster.Max
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif 
      
      If F_ooPicBoxesMuster[it].Tag Like "*" & sColorChange & "*" Then 
        F_ooPicBoxesMuster[it].Background = F_iColorSelect 
      Else 
        F_ooPicBoxesMuster[it].Background = Color.Default
      Endif 
    Next
    iAll = F_ooPicBoxesMuster.Count
  Endif 
  
  MusterCounter()
  LabelCounterMuster.Text = ("Gleiche Farben") & ": " & Str(iCount) & Space(1) & ("von") & Space(1) & Str(iAll)
  LabelInfo.Text = "<font color=white><b>" & LabelCounterMuster.Text & "</b></font>"
  LabelInfo.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckColorsChangeMessage() As Boolean

  Dim sMessage As String
  Dim bCancel As Boolean
  
  If F_ooPicBoxesColorsB Then 
    If F_iiIconClockColorsBbefore <> F_iiIconClockColorsB Then  
      sMessage = InfoColorPaletteMessage() 'as String 
    
    ''Changed (verändert?)
      sMessage &= ("<h2><font color=red>" & ("Icon-Farben verändern?") & "</font></h2>")
      Select Case Message.Question(sMessage, ("Farben anwenden"), ("Nein"), ("Abbrechen"))
        Case 1
          F_iiIconClockColorsBbefore = F_iiIconClockColorsB
          TimerPanelColorsChange.Start()
          
        Case 2
          F_iiIconClockColorsBbefore = F_iiIconClockColorsB
        
        Case 3
          bCancel = True 
      End Select
    Endif
  Endif 
  
  Return bCancel
  
  Catch 
  FMain.ErrorText
  
End

Public Sub ColorSelectChange(Optional iColorOld As Integer, Optional iColorNew As Integer)
  
  Dim it As Integer
  
  If F_ooPicBoxesLevels Then 
    For it = 0 To F_ooPicBoxesLevels.Max
      If F_ooPicBoxesLevels[it].Background = iColorOld Then F_ooPicBoxesLevels[it].Background = iColorNew
    Next
  Endif 
  
  If F_ooPicBoxesGallery Then 
    For it = 0 To F_ooPicBoxesGallery.Max
      If F_ooPicBoxesGallery[it].Background = iColorOld Then F_ooPicBoxesGallery[it].Background = iColorNew
    Next
  Endif 
  
  If F_ooPicBoxesMuster Then 
    For it = 0 To F_ooPicBoxesMuster.Max
      If F_ooPicBoxesMuster[it].Background = iColorOld Then F_ooPicBoxesMuster[it].Background = iColorNew
    Next
  Endif 
  
  F_iColorSelect = iColorNew
  Settings[F_sForm &/ "F_iColorSelect"] = F_iColorSelect
  
Catch 
  FMain.ErrorText
  
End

Public Function GalleryShowCompare() As String[]
  
  Dim iFormatCount, it, it2, iNr, iLine As Integer
  
  Dim sSort As String
  Dim ssSpli, ssGallerySort As String[]
  Dim iiGallerySort As Integer[]
  
  If PanelGallery.Visible = False Then SideG("gallery") 
  
  If PanelGallery.Visible = True Then 
    If F_ooPicBoxesGallery And F_sMovableParts Then  
      iFormatCount = String.Len(Str(F_ooPicBoxesGallery.Count))
      ssGallerySort = New String[]
      iiGallerySort = New Integer[]
      ' If Not F_ssPicBoxGalleryTags Then F_ssPicBoxGalleryTags = New String[]
      For it = 0 To F_ooPicBoxesGallery.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        LabelCounterGallery.Text = Str(it) & Space(1) & ("von") & Space(1) & Str(F_ooPicBoxesGallery.Count)
        
        sSort = "-timehh-timemm-timess-hours-minutes-second-datepoint-phythagoras-centerpoint-timelcd-timedigital-numbers-only-step-ring-sun-timenightsky-cutter-background-rectangle-button-wheel-timesummer-figure"
        
        ssSpli = Split(sSort & "-", "-")
        For it2 = 0 To ssSpli.Max
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          If ssSpli[it2] Then 
            iNr = String.InStr(F_ooPicBoxesGallery[it].Tag, ssSpli[it2]) '0 not found
            ''Sort:
            If iNr > 0 And iiGallerySort.Find(it) = -1 Then 
              ssGallerySort.Add(Format(it2, String(iFormatCount, "0")) & "=" & Format(it, String(iFormatCount, "0")))
              iiGallerySort.Add(it)
            Endif 
          Endif 
        Next
      Next 
      If F_iESCpressed > 0 Then Goto JumpEnd 
      
      For it = 0 To F_ooPicBoxesGallery.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        If iiGallerySort.Find(it) = -1 Then ''Rest:
          ssGallerySort.Add(Format(ssSpli.Count, String(iFormatCount, "0")) & "=" & Format(it, String(iFormatCount, "0")))
          iiGallerySort.Add(it)
        Endif
      Next
      
      ssGallerySort = ssGallerySort.Sort()
    Endif 
  Endif 
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
  Return ssGallerySort
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResetStandardSideG()
  
  Dim sMessage, sDir, sFile, sDirFile, sRedo As String
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]     
  If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  sFile = "settings-pageclockdesign.txt"
  sDirFile = sDir &/ sFile
  
  sMessage &= "<h3><font color=red>" & "○ " & ("Standard-Einstellungen für dieses Fenster") & "</font></h3>"
  
  If Exist(sDirFile) = True Then 
    sRedo = "● " & ("Wiederherstellen")
    sMessage &= "<h4><font color=darkgreen>" & sRedo & "</font></h4>" 
    sMessage &= "<font color=gray>" & sDirFile & "</font>" & Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>"
  Else 
    sRedo = ("Ordner...")
  Endif
  
  Select Case Message.Question(sMessage, "○ " & ("Standard"), sRedo, ("Abbrechen"))
    Case 1
      SettingsOnlyForm("undo")
      ' SettingsReadSave("read")
      ' Settings.Reload()
      ' FormStart()
      ' Form_Resize()
    Case 2
      If sRedo = ("Ordner...") Then 
        M01Functions.FileManagerOpen(sDir)
      Else 
        SettingsOnlyForm("redo")
        ' SettingsReadSave("read")
        ' Settings.Reload()
        ' FormStart()
        ' Form_Resize()
      Endif 
    Case 3
      ''...
  End Select
Catch 
  FMain.ErrorText
  
End

Public Function SettingsOnlyForm(Optional sUndoRedo As String = "redo")
  
  Dim sKey, sDir, sFile, sDirFile, sBackup, sText, sLevelTags As String 
  Dim hSettings As New Settings
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]     
  If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  sFile = "settings-pageclockdesign.txt"
  sDirFile = sDir &/ sFile
  
  ''Refresh before Backup:
  Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
  Settings[F_sForm &/ "F_bWhiteBorderON"] = F_bWhiteBorderON
  Settings[F_sForm &/ "F_iColorBoxesPointer"] = F_iColorBoxesPointer
  Settings[F_sForm &/ "F_iColorPicker"] = F_iColorPicker
  Settings[F_sForm &/ "F_iColorPickerTrans"] = F_iColorPickerTrans
  Settings[F_sForm &/ "F_iIconSize"] = F_iIconSize
  Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
  Settings[F_sForm &/ "F_sClockPartsFileNames"] = F_sClockPartsFileNames
  Settings[F_sForm &/ "F_sDirPrintCache"] = FMain.F_sDirPrintCache
  Settings[F_sForm &/ "ScrollViewGallery.ScrollY"] = ScrollViewGallery.ScrollY
  Settings[F_sForm &/ "F_sLoadUserPaths"] = F_sLoadUserPaths
  Settings[F_sForm &/ "F_sWorkplaceLevelsLastTime"] = F_sWorkplaceLevelsLastTime
  Settings[F_sForm &/ "F_ssEditLevels"] = F_ssEditLevels
  ' Settings[F_sForm &/ "F_ssParking"] = F_ssParking
  Settings[F_sForm &/ "F_sLevelsTags"] = ReadLevelsTag()
  ' Settings[F_sForm &/ "F_sMusterTags"] = ReadMusterTags()
  Settings[F_sForm &/ "F_iZoomGallery"] = F_iZoomGallery
  Settings[F_sForm &/ "F_ssMenuOpenRecent"] = F_ssMenuOpenRecent
  Settings[F_sForm &/ "F_ssMenuSaveRecent"] = F_ssMenuSaveRecent
  SettingsReadSave("save")
  
  Select Case String.LCase(sUndoRedo)
    Case "redo"
      ''Backup:
      If IsDir(sDir) = True Then sBackup = File.Load(sDirFile)
      ''Read:
      If IsDir(Settings.Path) = True Then sText = File.Load(Settings.Path) '*.conf
      ''Append:
      If sText Then sText &= gb.NewLine & sBackup Else sText = sBackup
      
      ''Save:      
      If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
      If IsDir(sDir) = True Then File.Save(sDirFile, sText)
      
    Case "undo"
      ''Read:
      For Each sKey In Settings.Keys[F_sForm]
        sText &= sKey & "=" & hSettings.ToString(Settings[F_sForm &/ sKey]) & gb.NewLine
      Next
      ''Save:      
      If IsDir(sDir) = True Then File.Save(sDirFile, sText)
      
      ''Clear:
      If Exist(sDirFile) = True Then Settings.Clear(F_sForm) 
      
  End Select
  
  ''Refresh:
  F_bMoreButtons = Settings[F_sForm &/ "F_bMoreButtons", True]
  F_bWhiteBorderON = Settings[F_sForm &/ "F_bWhiteBorderON", True]
  F_iColorBoxesPointer = Settings[F_sForm &/ "F_iColorBoxesPointer", 0]
  F_iColorPicker = Settings[F_sForm &/ "F_iColorPicker", 0]
  F_iColorPickerTrans = Settings[F_sForm &/ "F_iColorPickerTrans", 0]
  F_iIconSize = Settings[F_sForm &/ "F_iIconSize", 128]
  F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", Null]
  F_sClockPartsFileNames = Settings[F_sForm &/ "F_sClockPartsFileNames", Null]
  FMain.F_sDirPrintCache = Settings[F_sForm &/ "F_sDirPrintCache", FMain.F_sDirPrintCache]
  ScrollViewGallery.ScrollY = Settings[F_sForm &/ "ScrollViewGallery.ScrollY", 0]
  F_sLoadUserPaths = Settings[F_sForm &/ "F_sLoadUserPaths", Null]
  F_sWorkplaceLevelsLastTime = Settings[F_sForm &/ "F_sWorkplaceLevelsLastTime", Null]
  F_ssEditLevels = Settings[F_sForm &/ "F_ssEditLevels", Null]
  ' F_ssParking = Settings[F_sForm &/ "F_ssParking", Null]
  sLevelTags = Settings[F_sForm &/ "F_sLevelsTags", Null]
  ' sMusterTags = Settings[F_sForm &/ "F_sMusterTags", Null]
  F_iZoomGallery = Settings[F_sForm &/ "F_iZoomGallery", 80]
  F_ssMenuOpenRecent = Settings[F_sForm &/ "F_ssMenuOpenRecent", Null]
  F_ssMenuSaveRecent = Settings[F_sForm &/ "F_ssMenuSaveRecent", Null]
  F_fFontSizePlus = Settings[F_sForm &/ "F_fFontSizePlus", 0]
  
  SettingsReadSave("read")
  
  F_bMovingON = False
  SideG("gallery")
  FormStart()
  LoadLevelsNewNull()
  LoadLevels(sLevelTags)
  ResizePanelLevels()
  SumPaintClockLevels()
  SynchronizeLevelsToGallery()
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorOpenSaveStandardGxxx(Optional sOpenSaveStandard As String = "standard")
  
  Dim sPathLast, sDir, sFile, sDirFile, sLine, sLines, sSquare, sColors, sMessage As String 
  Dim ssColor As String[]
  Dim iColor, iDiff, it As Integer
  Dim iiColors As Integer[]
  Dim bApply As Boolean
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
  iiColors = New Integer[]
  iiColors = F_iiIconClockColorsA
  sPathLast = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
  
  Select Case String.LCase(sOpenSaveStandard) 
      
    Case "open", "opencolors"
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      If sDirFile Then sFile = File.Name(sDirFile) 
      If Exist(sDir) = False Then sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = FileDialogPathReturn(sPathLast, "open", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Load:
      If Exist(sDirFile) = True Then 
        sLines = File.Load(sDirFile)
        If Not iiColors Then iiColors = New Integer[]
        it = -1
        For Each sLine In Split(sLines & gb.NewLine, gb.NewLine)
          If String.LCase(sLine) Like "*" & "color=" & "*" Then 
            ssColor = Split(sLine & "=", "=")
            If ssColor Then
              ssColor[1] = Trim(UnQuote(ssColor[1]))
              If IsInteger(ssColor[1]) = True Then 
                it = it + 1
                iColor = CInteger(ssColor[1]) 
                If it < iiColors.Count Then iiColors[it] = iColor
              Endif 
            Endif 
          Endif 
        Next 
        If iiColors.Max > -1 Then 
          sMessage = "<h3><font color=gray>" & "■ " & ("Standard Icon-Farben") & "</font></h3>"
          sColors = ""
          For it = 0 To F_ooPicBoxesColorsA.Max
            If F_ooPicBoxesColorsA[it].Background = Color.Background Then 
              sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
            Else 
              sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsA[it].Background, 6) & ">" & "■" & "</font>"  
            Endif 
          Next   
          If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
          
          sColors = ""
          sMessage &= "<h3>" & "■ " & ("Aktuelle Icon-Farben") & "</h3>"
          For it = 0 To F_iiIconClockColorsB.Max
            If F_iiIconClockColorsB[it] = Color.Background Then 
              sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
            Else 
              sColors &= "<font color=#" & Hex(F_iiIconClockColorsB[it], 6) & ">" & "■" & "</font>"  
            Endif 
          Next   
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<br><br>"
          sMessage &= "<h3>" & "● " & ("Neue Icon-Farben aus der Datei") & "</h3>"
          ' If iiColors.Max < F_iiIconClockColorsB.Max Then iiColors.Resize(F_iiIconClockColorsB.Count)
          sColors = Null
          For it = 0 To iiColors.Max
            If iiColors[it] = F_iiIconClockColorsB[it] Then 
              sSquare = "■"
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
            Else 
              iDiff = iDiff + 1
              sSquare = "●" 'Changed
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
            Endif 
            sColors &= "<font color=#" & Hex(iiColors[it], 6) & ">" & sSquare & "</font>"
          Next  
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & iiColors.Count & Space(1) & ("Icon-Farben") & Space(1) & "</font></h3>"
          sMessage &= "<font color=gray>" & sDirFile & "</font>" & "<br>"
          If Exist(sDirFile) = True Then sMessage &= "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
          
          Select Case Message.Question(sMessage, "● " & ("Öffnen"), ("Ordner..."), ("Abbrechen"))
            Case 1  '"● "
              ''...Open
            Case 2 'Directory
              If Exist(sDirFile) = True Then M01Functions.FileManagerOpen(sDirFile) Else M01Functions.FileManagerOpen(sDir)
            Case 3 'Cancel
              Goto JumpEnd
          End Select
          F_iiIconClockColorsB = iiColors'.Copy()
          Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
          SettingsColorsUserReadSave("read")
          bApply = True
        Else 
          sMessage = ""
          sColors = ""
          If F_iiIconClockColorsB Then
            sColors &= String(F_iiIconClockColorsB.Count, "□") & "<br>"
          Endif 
          If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
          sMessage &= sDirFile 
          sMessage &= "<h3><font color=red>" & ("Keine Farb-Palette?") & "</font></h3>"
          
          Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
            Case 1
              sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
              M01Functions.FileManagerOpen(sDir)
            Case 2
              ''...
          End Select
        Endif 
      Endif 
      
    Case "save", "savecolors" 
      sMessage = "<h3><font color=gray>" & "■ " & ("Standard Icon-Farben") & "</font></h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsA.Max
        If F_ooPicBoxesColorsA[it].Background = Color.Background Then 
          sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
        Else 
          sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsA[it].Background, 6) & ">" & "■" & "</font>"  
        Endif 
      Next   
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<br><br>"
      sMessage &= "<h3>" & "● " & ("Aktuelle Icon-Farben") & Space(1) & ("speichern") & "</h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsB.Max 
        If F_iiIconClockColorsA[it] = F_ooPicBoxesColorsB[it].Background Then 
          sSquare = "■"
        Else 
          iDiff = iDiff + 1
          sSquare = "●" 'Changed
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
        Endif 
        sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & F_iiIconClockColorsA.Count & Space(1) & ("Icon-Farben") & Space(1) & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Speichern"), ("Ordner..."), ("Abbrechen"))
        Case 1  '"● "
          ''...Save
          
        Case 2 'Directory
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
          Goto JumpEnd
          
        Case 3 'Cancel
          Goto JumpEnd
      End Select
      
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      sFile = File.Name(sDirFile)
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = M01Functions.FileDialogPathReturn(sPathLast, "save", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Save:
      If sDirFile Then 
        If F_ooPicBoxesColorsB Then 
          sLines = "#" & Application.Name & Space(1) & Application.Version & ("Icon-Color-Palette") & gb.NewLine
          For it = 0 To F_ooPicBoxesColorsB.Max
            sLines &= "color=" & Quote(Str(F_ooPicBoxesColorsB[it].Background)) & gb.NewLine
          Next 
          '*****************************************************
          sDirFile = M01Functions.FileTextPlus(sDirFile, sLines, True) 'TRUE=overwrite (überschreiben)
          '*****************************************************
        Endif 
      Endif 
      
      ''Check:
      If sDirFile And Exist(sDirFile) = False Then 
        sMessage = ""
        sColors = ""
        If F_iiIconClockColorsA Then
          sColors &= String(F_iiIconClockColorsA.Count, "□") & "<br>"
        Endif 
        If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
        sMessage &= sDirFile 
        sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            M01Functions.FileManagerOpen(sDir)
          Case 2
            ''...
        End Select
      Endif 
      
    Case "standard", "standardcolors", "reset" 
      sMessage = "<h3><font color=gray>" & "■ " & ("Standard Icon-Farben") & "</font></h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsA.Max
        If F_ooPicBoxesColorsA[it].Background = Color.Background Then 
          sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
        Else 
          sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsA[it].Background, 6) & ">" & "■" & "</font>"  
        Endif 
      Next   
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<br><br>"
      sMessage &= "<h3>" & "● " & ("Aktuelle Icon-Farben") & "</h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsB.Max
        If F_ooPicBoxesColorsA[it].Background = F_ooPicBoxesColorsB[it].Background Then 
          sSquare = "■"
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
        Else 
          iDiff = iDiff + 1
          sSquare = "●" 'Changed
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
        Endif 
        sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & F_iiIconClockColorsA.Count & Space(1) & ("Icon-Farben") & Space(1) & "</font></h3>"
      
      Select Message.Question(sMessage, "■ " & ("Standard Icon-Farben wiederherstellen (Reset)"), ("Ordner..."), ("Abbrechen"))
        Case 1 'Reset Colors
          F_iiIconClockColorsB = Settings[FMain.Name &/ "F_iiIconClockColorsA", Null]
          Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB 
          SettingsColorsUserReadSave("read")
          bApply = True
          If PanelColorPicker.Visible = False Then SideG("color")
        Case 2 
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
        Case 3 'Cancel
          '...
      End Select 
      
  End Select 
  
  ' If bApply = True Then ButtonGroupSelect(ButtonColorApply.Tag) 'Refresh
  
JumpEnd:
  
Catch 
  FMain.ErrorText()
  
End

Public Sub ResetStandardEdit()
  
  Dim sMessage, sM1, sM2, sColor1, sColor2 As String 
  
  sM1 = InfoButtonPictureMessage(PicTemplateWhiteBorderON.Picture, "1.png") 'as String
  sM2 = InfoButtonPictureMessage(PicTemplateWhiteBorderOff.Picture, "2.png") 'as String
  
  sMessage &= "<h3>" & PicBoxWhiteBorder.Tooltip & "</h3>"
  If Form14UhrDesign.F_bWhiteBorderON = True Then 
    sColor1 = "black"
    sColor2 = "gray"
  Else 
    sColor1 = "gray"
    sColor2 = "black"
  Endif
  
  sMessage &= "<h3>" & sM1 & Space(1) & "<font color=" & sColor1 & ">" & ("Mit weißem Rand") & "</font>" & "</h3>"
  sMessage &= "<h3>" & sM2 & Space(1) & "<font color=" & sColor2 & ">" & ("Ohne weißem Rand") & "</font>" & "</h3>"
    
  Select Message.Question(sMessage, ("Mit"), ("Ohne"), ("Abbrechen"))
    Case 1 '"● "
      Settings[F_sForm &/ "F_bWhiteBorderON"] = True
      Form14UhrDesign.F_bWhiteBorderON = True 
      ' ButtonGroupSelect(ButtonColorApply.Tag) 'Refresh
      WhiteBorderMessageONoff()  
      
    Case 2 '"○ "
      Settings[F_sForm &/ "F_bWhiteBorderON"] = False
      Form14UhrDesign.F_bWhiteBorderON = False 
      ' ButtonGroupSelect(ButtonColorApply.Tag) 'Refresh
      WhiteBorderMessageONoff()  
      
    Case 3 'Cancel
      ''...
  End Select 
  
Catch 
  FMain.ErrorText()
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckLastPicBoxObject()'??? —▶ScrollViewEnsureVisibleG()
  
  Dim it, iCol As Integer
  Dim sToolTipNumber As String 
  Dim picTemp As Picture
  
  ''Last clock-levels:
  If Object.IsValid(F_oLastPicBoxObject) = True And PanelMuster.Visible = False Then
    sToolTipNumber = F_oLastPicBoxObject.ToolTip
    If IsInteger(sToolTipNumber) = True Then it = CInteger(sToolTipNumber) - 1 Else it = -1 'as Integer
    If it > -1 And it < F_ooPicBoxesLevels.Count Then 
      picTemp = F_ooPicBoxesGallery[it].Picture
      F_ooPicBoxesGallery[it].Picture = F_oLastPicBoxObject.Picture
      F_ooPicBoxesLevels[it].Picture = F_oLastPicBoxObject.Picture
      iCol = F_ooPicBoxesLevels[it].Background
      ScrollViewGallery.EnsureVisible(F_ooPicBoxesGallery[it].Left, F_ooPicBoxesGallery[it].Top, F_ooPicBoxesGallery[it].W, F_ooPicBoxesGallery[it].H)
      ''Wait and show for user:
      F_ooPicBoxesLevels[it].Background = Color.Blue
      F_ooPicBoxesGallery[it].Background = Color.Blue
      Wait 0.5
      F_ooPicBoxesLevels[it].Background = iCol
      F_ooPicBoxesGallery[it].Background = iCol
      F_ooPicBoxesGallery[it].Picture = picTemp
    Endif 
    ' SumPaintClockLevels()
  Endif 
  
  ''Last clock-levels (muster):
  If F_ooPicBoxesMuster And PanelMuster.Visible = True Then
    sToolTipNumber = F_oLastPicBoxMuster.ToolTip
    If IsInteger(sToolTipNumber) = True Then it = CInteger(sToolTipNumber) - 1 Else it = -1 'as Integer
    If it > -1 And it < F_ooPicBoxesMuster.Count Then 
      iCol = F_ooPicBoxesMuster[it].Background
      ScrollViewMuster.EnsureVisible(F_ooPicBoxesMuster[it].Left, F_ooPicBoxesMuster[it].Top, F_ooPicBoxesMuster[it].W, F_ooPicBoxesMuster[it].H)
      F_ooPicBoxesMuster[it].Picture = F_oLastPicBoxMuster.Picture
      ''Wait and show for user:
      F_ooPicBoxesMuster[it].Background = Color.Blue
      Wait 0.5
      F_ooPicBoxesMuster[it].Background = iCol
    Endif
    ' SumPaintClockLevels()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SavePictureAs(Optional hPic As Picture = Null)
  
  Dim sDir, sFile, sDirFile, sExt, sText, sToolTip As String
  Dim iW As Integer
  
  If Not hPic Then hPic = PicBoxSelectLevelONoff.Picture
  If hPic Then iW = hPic.W Else iW = F_iIconSize 
  If IsInteger(PicBoxSelectLevelONoff.ToolTip) = True Then sToolTip = Format(PicBoxSelectLevelONoff.ToolTip, "00") Else sToolTip = Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss")
  sExt = "png"
  sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  sFile = Application.Name & sToolTip & "_" & iW & "." & sExt
  sDirFile = sDir &/ sFile    'Settings[FMain.Name &/ "sPathFoto",sDirFile]
  
  If Not hPic Then 
    ''Check:
    sText = "<font color=red><b>" & ("Speichern") & "</b></font>"
    sText = sText & "<br><br>" & "<font color=red><b>" & ("Fehler. Kein Bild vorhanden.") & "</b></font>"
    
    Select Message.Question(sText, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDir)
      Case 2 
        '...
    End Select
    
  Else 
    
    ''Save:
    sDirFile = FileDialogPathReturn(sDirFile, "save", sDirFile) 'Last-Path, open/save, Standard-Path
    If Not sDirFile Then Return  
    
    If hPic Then hPic.Save(sDirFile)
    
    ''Infos:
    If Exist(sDirFile) = True Then 
      sText = "<b>" & sDirFile & "</b>"
      sText = sText & "<br><br>" & M01Functions.FileSizeText(sDirFile) 'as String
      sText = sText & "<br>" & iW & "x" & iW & Space(1) & ("Pixel") 
      MenuSaveRecentG(sDirFile)
    Else 
      ''Check:
      sText = "<br><br>" & "<font color=red><b>" & ("Fehler. Bild nicht gespeichert.") & "</b></font>"
    Endif 
    
    Select Message.Question(sText, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory:
        If Exist(sDirFile) = True Then M01Functions.FileManagerOpen(sDirFile) Else M01Functions.FileManagerOpen(sDir) '(*1)
        
      Case 2 'canceld:
        '...
    End Select
  Endif 
  
  ''_____________________________________________________________________________''
  ' (*1) 'Note: no space(1). Space(1) is Separator in Shell "nautilus" & Space(1) & sDirFile
  ' String & space(1) & String & space(1)...  
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveAllMusterDirectTxt()
  
  Dim sDirFile, sDirFileExtra, sDirFileStandard, sTag, sMessage As String
  
  ' If F_iESCpressed > 0 Then Return 'end here
  
  sDirFileStandard = Settings[FMain.Name &/ "F_sPathClockMuster_txt", F_sPathClockMuster_txt]
  sDirFile = sDirFileStandard
  
  ''Check:
  sMessage = "<h3><font color=gray><b>" & ("Muster-Modelle als Text") & "</b></font></h3>"
  sMessage &= "<h3><font color=darkgreen><b>" & "● " & ("Alle Muster speichern in die Sammel-Datei") & "</b></font></h3>"
  
  If Exist(sDirFileStandard) = False Then 
    sMessage &= "<h3><font color=gray><b>" & "● " & ("Fehlt, neu erstellen?") & "</b></font></h3>"
  Else
    sMessage &= "<font color=gray>" & File.Dir(sDirFileStandard) &/ "</font><font color=blue><b>" & File.Name(sDirFileStandard) & "</b></font>" & "<br>" 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileStandard) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileStandard).Size) & "</font>" & "<br>" 
  Endif 
  
  Select Message.Question(sMessage, "● " & ("Speichern"), ("Speichern als Kopie..."), ("Abbrechen"))
    Case 1
      ''read Clock-Muster-Tags
      sTag = ReadMusterTags(True) '(False) —▶Selection
      sDirFile = sDirFileStandard
      F_bMusterSideChanged = False
    
    Case 2
      ''read Clock-Muster-Tags
      sTag = ReadMusterTags(True) '(False) —▶Selection
      sDirFileExtra = File.Dir(sDirFileStandard) &/ Application.Name & "-" & ("meineMuster") & "_clockmuster.txt"
      sDirFile = FileDialogPathReturn(sDirFileExtra, "save", sDirFileStandard) 'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd  
      
    Case 3 'Cancel:
      Goto JumpEnd
      
  End Select
  
  ''File-Title:
  sTag = CheckFileTitleClockMuster(sTag)
  
  ''Save:
  '*****************************************************
  sDirFile = M01Functions.FileTextPlus(sDirFile, sTag, True) 'TRUE=overwrite (überschreiben)
  '*****************************************************
  
  ''Check:
  If Exist(sDirFile) = True Then 
    If Not F_ssMenuSaveRecent Then F_ssMenuSaveRecent = New String[]
    F_ssMenuSaveRecent.Add(sDirFile)
    Settings[F_sForm &/ "F_ssMenuSaveRecent"] = F_ssMenuSaveRecent
    
    LabelInfoPathG(sDirFile)
    MenuSaveRecentG(sDirFile)
    TextBoxPath.Selectall()
    TextBoxPath.Insert(sDirFile)
    F_bMusterSideChanged = False 
  Else   
    ''Check:
    sMessage = "<font color=red><b>" & sDirFile & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & ("Fehler. Datei nicht gespeichert.") & "</b></font><br>"
    
    Select Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDirFile)
      Case 2 'Cancel:
        '...
    End Select
    F_bMusterSideChanged = True 
  Endif
  
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveSelectionMusterTxt()
  
  Dim sDirFileSelection, sDirFileStandard, sTag, sAll, sSelection, sMessage As String
  
  ' If F_iESCpressed > 0 Then Return 'end here
  
  sDirFileStandard = Settings[FMain.Name &/ "F_sPathClockMuster_txt", F_sPathClockMuster_txt]
  sDirFileSelection = File.Dir(sDirFileStandard) &/ Application.Name & "-selection_clockmuster.txt" 
  
  If F_ooPicBoxesMuster Then sAll = F_ooPicBoxesMuster.Count
  sSelection = F_iMusterSelectionCount  
  
  ''Check:
  sMessage = "<h3><font color=gray><b>" & ("Muster-Modelle als Text") & "</b></font></h3>"
  sMessage &= "<h3><font color=darkgreen><b>" & "○ " & ("Nur Auswahl speichern") & "</b></font></h3>"
  sMessage &= "<h3><font color=darkgreen><b>" & "● " & ("Alle speichern") & "</b></font></h3>"
  
  If Exist(sDirFileSelection) = True Then 
    sMessage &= "<font color=gray>" & File.Dir(sDirFileSelection) &/ "</font><font color=blue><b>" & File.Name(sDirFileSelection) & "</b></font>" & "<br>" 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileSelection) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileSelection).Size) & "</font>" & "<br>" 
  Else 
    sMessage &= "<h3><font color=gray><b>" & "● " & ("Fehlt, neu erstellen?") & "</b></font></h3>"
  Endif 
  
  Select Case Message.Question(sMessage, "● " & ("Alle speichern") & "..." & sAll, "○ " & ("Nur Auswahl speichern") & "..." & sSelection, ("Abbrechen"))
      
    Case 1 'Save all
      ''read Clock-Muster-Tags
      sTag = ReadMusterTags(True) '(False) —▶Selection
      sDirFileSelection = FileDialogPathReturn(sDirFileSelection, "save", sDirFileStandard) 'Last-Path, open/save, Standard-Path
      If Not sDirFileSelection Then Goto JumpEnd  
      
    Case 2 'Save selection
      ''read Clock-Muster-Tags
      sTag = ReadMusterTags(False) '(False) —▶Selection
      sDirFileSelection = FileDialogPathReturn(sDirFileSelection, "save", sDirFileStandard) 'Last-Path, open/save, Standard-Path
      If Not sDirFileSelection Then Goto JumpEnd  
      
    Case 3 'Cancel:
      Goto JumpEnd
      
  End Select
  
  ''File-Title:
  sTag = CheckFileTitleClockMuster(sTag)
  
  ''Save:
  '*****************************************************
  sDirFileSelection = M01Functions.FileTextPlus(sDirFileSelection, sTag, True) 'TRUE=overwrite (überschreiben)
  '*****************************************************
  
  ''Check:
  If Exist(sDirFileSelection) = True Then 
    If Not F_ssMenuSaveRecent Then F_ssMenuSaveRecent = New String[]
    F_ssMenuSaveRecent.Add(sDirFileSelection)
    Settings[F_sForm &/ "F_ssMenuSaveRecent"] = F_ssMenuSaveRecent
    
    LabelInfoPathG(sDirFileSelection)
    MenuSaveRecentG(sDirFileSelection)
    TextBoxPath.Selectall()
    TextBoxPath.Insert(sDirFileStandard)
  Else   
    ''Check:
    sMessage = "<font color=red><b>" & sDirFileSelection & "</b></font><br>"
    sMessage &= "<br>"
    sMessage &= "<font color=red><b>" & ("Fehler. Datei nicht gespeichert.") & "</b></font><br>"
    
    Select Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDirFileSelection)
      Case 2 'Cancel:
        '...
    End Select
  Endif
  
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  
Catch 
  FMain.ErrorText
  
End

Public Function SaveMusterTxtClose() As Boolean
  
  Dim sDirFile, sTagAll, sMessage As String
  Dim iAll As Integer
  Dim bClose As Boolean
  
  sDirFile = Settings[FMain.Name &/ "F_sPathClockMuster_txt", F_sPathClockMuster_txt]
  
  If F_ooPicBoxesMuster Then iAll = F_ooPicBoxesMuster.Count
  If iAll = 0 Then Goto JumpEnd
  
  sMessage = "<h3><font color=red><b>" & "● " & ("Veränderte Muster-Liste") & "</b></font></h3>"
  
  If Exist(sDirFile) = False Then 
    sMessage &= "<h3><font color=blue><b>" & ("Datei erstellen") & "</b></font></h3>"
  Else
    sMessage &= "<font color=gray>" & File.Dir(sDirFile) &/ "</font><font color=blue><b>" & File.Name(sDirFile) & "</b></font>" & "<br>" 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>" & "<br>" 
  Endif 
  
  Select Message.Question(sMessage, "● " & ("Speichern") & Space(1) & iAll, ("Nein"), ("Abbrechen"))
      
    Case 1 'Save
      sTagAll = ReadMusterTags(True) 'as String
      sTagAll = CheckFileTitleClockMuster(sTagAll)
      bClose = True 
    Case 2 'No 
      bClose = True 
      Goto JumpEnd
    Case 2 'Cancel:
      bClose = False 
      Goto JumpEnd
      
  End Select
  
  ''Save:
  '*****************************************************
  sDirFile = M01Functions.FileTextPlus(sDirFile, sTagAll, True) 'TRUE=overwrite (überschreiben)
  '*****************************************************
  F_bMusterSideChanged = False
  
JumpEnd:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Return bClose
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckFileTitleClockMuster(Optional sText As String = "") As String 
  
  Dim sTitle, sMusterCount As String
  
  If String.InStr(sText, "#" & Application.Name) = 0 Then 
    
    sMusterCount = LabelCounterMuster.Text
    
    sTitle = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Clock-Levels") & gb.NewLine 
    sTitle &= ("#level number left selected path (0|1|2|3|4|)") & Space(1) & ("Muster") & ": " & sMusterCount & gb.NewLine 
    sTitle &= gb.NewLine 
    sText = sTitle & sText
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileExistQuestion(Optional sDirFile As String = Null) As Boolean
  
  Dim sMessage As String 
  Dim bSave As Boolean '=False
  
  If Exist(sDirFile) = True Then  
    sMessage = "<font color=gray>" & sDirFile & "</font><br><br>"
    sMessage &= "<font color=gray>" & M01Functions.FileSizeText(sDirFile) & "</font><br><br>"
    sMessage &= ("Geändert") & ": " & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" 
    sMessage &= "<br><br><br>"
    sMessage &= "<font color=red><b>" & ("Die Datei existiert schon. Überschreiben, aktualisieren?") & "</b></font>"
    
    Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
      Case 1
        bSave = True 
      Case 2
        bSave = False  
    End Select
  Endif 
  
  Return bSave
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
  
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Function OpenDirBackupG() As String
  
  Dim sPath, sDir, sFile, sDirFile As String 
  Dim ssFiles As String[]
  
  sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  sPath = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt]
  sFile = File.Name(sPath)
  sDirFile = sDir &/ sFile
  Dialog.FilterIndex = 2 'Now (Heute)
  
  ssFiles = Dir(sDir, sFile & "*", gb.File) 'as String[]
  If ssFiles Then 
    ssFiles.Sort(gb.Descent)
    If ssFiles.Max > -1 Then 
      sFile = ssFiles.First
      sDirFile = sDir &/ sFile
    Endif 
  Endif 
  
  Return sDirFile 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadMusterFileText(Optional sPath As String = "", Optional sOpenOrOpenbackup As String = "open")
  
  Dim sPathLast, sPathStandard, sFile, sNew, sMusterTags, sMessage As String
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If PanelMuster.Visible = False Then SideG("muster")
  
  sPathStandard = Settings[FMain.Name &/ "F_sPathClockMuster_txt", F_sPathClockMuster_txt] ''... '*.muster.txt
  
  sFile = LCase(Application.Name) & "-" & "demo_clockmuster.txt" 'Text-File
  If File.Name(sPath) = sFile Then sPathLast = sPath Else sPathLast = sPathStandard
  
  ''Dialog:
  '*************************************************
  sPath = FileDialogPathReturn(sPathLast, sOpenOrOpenbackup, sPathStandard) 'autom.: "All files(*.*) 'Last-Path, open/save, Standard-Path
  If Not sPath Then Return
  '*************************************************
  
  ''Load:
  If Exist(sPath) = True Then Try sNew = File.Load(sPath) ' *.txt
  
  ''Check:
  If Exist(sPath) = True And String.InStr(sNew, "level=") = 0 Then
    ''Infos:
    sMessage = "<b>" & File.Dir(sPath) & "<br>" & File.Name(sPath) & "</b><br><br>"
    If String.LCase(File.Ext(sPath)) = "txt" Then
      sMessage &= M01Functions.FileSizeText(sPath) 'as String
      sMessage &= "<br>"
      sMessage &= "<font color=red><b>" & ("Leer/ohne Muster?") & "</b></font><br><br>"
    Else   
      sMessage &= "<font color=red><b>" & ("Fehler? Keine Datei mit Uhr-Mustern?") & "</b></font>" & "<br><br>"
    Endif 
    
    Select Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sPath)
      Case 2 
        '...
    End Select
  Else 
    sMusterTags = ReadMusterTags() 'as String,(False)—▶Selection
    
    sMessage = "<h2><font color=darkgreen><b>" & "○" & Space(1) & ("Neu = Mit neuer Muster-Seite?") & "</b></font></h2>" 
    sMessage &= "<br>"
    sMessage &= "<h2><font color=darkblue>" & "●" & Space(1) & ("Alt + Neu = hinzufügen ohne doppelte Muster") & "</font></h2>"
    sMessage &= "<br>"
    sMessage &= "<font color=gray>" & ("Tipp") & ": " & "</font><br>"
    sMessage &= "<font color=gray>" & ("Sicherungskopien") & ": " & FMain.F_sDirBackup &/ "..." & "</font><br>"
    sMessage &= "<font color=gray>" & ("Menü") & ": " & MenuShowCompare.Text & "</font><br>"
    sMessage &= "<font color=gray>" & ButtonMusterCut.Tooltip & " + " & ButtonMusterReload.Tooltip & "</font><br>"
    
    If sMusterTags Then 
      Select Case Message.Question(sMessage, "○" & Space(1) & ("Neu"), "●" & Space(1) & ("Alt + Neu"), ("Abbrechen"))
        Case 1 ''New List:
          SaveMusterTags(sMusterTags) 'Settings and Backup file
          MusterNullNew()
          LoadMuster(sNew)
        Case 2 ''Add List:
          sNew = sMusterTags & gb.NewLine & gb.NewLine & sNew 
          LoadMuster(sNew, True) 'True = Double-Check
        Case 3 ''Canceled
          ''...
      End Select
    Else 
      SaveMusterTags(sMusterTags) 'Settings and Backup file
      LoadMuster(sNew)
    Endif 
    If Exist(sPath) = True Then MenuOpenRecentG(sPath)
    
    If F_iESCpressed = 0 Then 
      LabelMessageText("<font color=darkgreen><b>" & ("Die Muster-Liste wurde berechnet und ist fertig") & "</b></font>")
    Endif 
    If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter() 'as String  "0/0"
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPasteToolTipRefresh()
  
  If Clipboard.Type = Clipboard.Image Then PicBoxPaste.Picture = Clipboard.Paste().Picture
  If PicBoxPaste.Picture Then 'Control picture
    PicBoxPaste.Tag = ("Kopiertes Bild in der [Zwischenablage]") & Space(2) & PicBoxPaste.Picture.W & "x" & PicBoxPaste.Picture.H & Space(1) & ("px (Pixel, Bildpunkte)")
    LabelMessageText(PicBoxPaste.Tag, Color.DarkGreen)
  Else 
    PicBoxPaste.Tag = ("Leer. Kein Bild in der [Zwischenablage]")
    LabelMessageText(PicBoxPaste.Tag, Color.Red)  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPaste_Enter()
  
  PicBoxPasteToolTipRefresh()
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPaste_MouseDown()
  
  ' CheckMenu1()
  If Mouse.Right Then MenuEdit.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupParking_Enter()
  
  LabelMessageText(Last.ToolTip)
  Last.Background = F_iColorSelect
  ScrollViewLevels.Background = Color.Lighter(Color.Blue)
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupParking_Leave()
  
  LabelMessageText("")
  Last.Background = Color.Default
  ScrollViewLevels.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupParking_MouseUp()
  
  Dim iNr As Integer
  Dim sTag As String
  
  Select Case Last.Name
    Case PicBoxParking0.Name
      iNr = 0
    Case PicBoxParking1.Name
      iNr = 1
    Case PicBoxParking2.Name
      iNr = 2
    Case PicBoxParking3.Name
      iNr = 3
  End Select
  
  If Mouse.Left Then ParkingChange(iNr) '——▶ P  or  P ◀——
  
  If Mouse.Middle Then 
    If F_picClock Then 
      Last.Tag = ReadLevelsTag()
      If iNr = 0 Then PicBoxParking0.Picture = F_picClock
      If iNr = 1 Then PicBoxParking1.Picture = F_picClock
      If iNr = 2 Then PicBoxParking2.Picture = F_picClock
      If iNr = 3 Then PicBoxParking3.Picture = F_picClock
    Endif 
  Endif 
  
  If Mouse.Right Then
    If Not F_ssParkingUndo Then F_ssParkingUndo = New String[4]
    If String.InStr(Last.Tag, "level=") > 0 Then  
      ''Null
      F_ssParkingUndo[iNr] = Last.Tag
      Last.Tag = iNr
      Select Case iNr 
        Case 0
          Last.Picture = PicTemplateParking0.Picture  'P0
        Case 1
          Last.Picture = PicTemplateParking1.Picture  'P1
        Case 2
          Last.Picture = PicTemplateParking2.Picture  'P2
        Case 3
          Last.Picture = PicTemplateParking3.Picture  'P3
      End Select
    Else 
      ''Undo
      sTag = F_ssParkingUndo[iNr]
      F_ssParkingUndo[iNr] = Null
      Last.Tag = sTag
      F_ssParkingUndo[iNr] = iNr
      LoadLevelsNewNull()
      LoadLevels(sTag)
      ResizePanelLevels()
      SumPaintClockLevels()
      UndoRedoLevelSave(sTag)
      If F_picClock Then Last.Picture = F_picClock
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ParkingChange(Optional iLastTag As Integer = 0) 'ChangeBox □◁——▶■
  
  Dim sDir, sParkA, sParkB, sParkX As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock]
  
  Select Case iLastTag
    Case 0
      ' PicBoxParking0.Tag = Settings[F_sForm &/ "PicBoxParking0.Tag", Null] 'level=...
      sParkA = PicBoxParking0.Tag
      sParkB = ReadLevelsTag()
      
      ''Change:
      sParkX = sParkA
      sParkA = sParkB
      sParkB = sParkX
      PicBoxParking0.Tag = sParkA 
      
      If PicBoxParking0.Tag And PicBoxParking0.Tag Like "*level=*" Then 
        PicBoxParking0.Picture = F_picClock 'New
      Else 
        PicBoxParking0.Picture = PicTemplateParking0.Picture 'Empty "P"
        LabelMessageText("P0" & " = " & ("leer"), Color.Red)
      Endif 
      If IsDir(sDir) = True Then PicBoxParking0.Picture.Save(sDir &/ "parking0.png")
      ' Settings[F_sForm &/ "PicBoxParking0.Tag"] = PicBoxParking0.Tag
      'Show user:
      PicBoxParking0.Visible = False 
      Wait 0.3
      PicBoxParking0.Visible = True 
      
    Case 1
      ' PicBoxParking1.Tag = Settings[F_sForm &/ "PicBoxParking1.Tag", Null] 'level=...
      sParkA = PicBoxParking1.Tag
      sParkB = ReadLevelsTag()
      
      ''Change:
      sParkX = sParkA
      sParkA = sParkB
      sParkB = sParkX
      PicBoxParking1.Tag = sParkA 
      
      If PicBoxParking1.Tag And PicBoxParking1.Tag Like "*level=*" Then 
        PicBoxParking1.Picture = F_picClock 'New
      Else 
        PicBoxParking1.Picture = PicTemplateParking1.Picture 'Empty "P"
        LabelMessageText("P1" & " = " & ("leer"), Color.Red)
      Endif 
      If IsDir(sDir) = True Then PicBoxParking1.Picture.Save(sDir &/ "parking1.png")
      ' Settings[F_sForm &/ "PicBoxParking1.Tag"] = PicBoxParking1.Tag
      'Show user:
      PicBoxParking1.Visible = False 
      Wait 0.3
      PicBoxParking1.Visible = True 
      
    Case 2
      ' PicBoxParking2.Tag = Settings[F_sForm &/ "PicBoxParking2.Tag", Null] 'level=...
      sParkA = PicBoxParking2.Tag
      sParkB = ReadLevelsTag()
      
      ''Change:
      sParkX = sParkA
      sParkA = sParkB
      sParkB = sParkX
      PicBoxParking2.Tag = sParkA 
      
      If PicBoxParking2.Tag And PicBoxParking2.Tag Like "*level=*" Then 
        PicBoxParking2.Picture = F_picClock 'New
      Else 
        PicBoxParking2.Picture = PicTemplateParking2.Picture 'Empty "P"
        LabelMessageText("P2" & " = " & ("leer"), Color.Red)
      Endif 
      If IsDir(sDir) = True Then PicBoxParking2.Picture.Save(sDir &/ "parking2.png")
      ' Settings[F_sForm &/ "PicBoxParking2.Tag"] = PicBoxParking2.Tag
      'Show user:
      PicBoxParking2.Visible = False 
      Wait 0.3
      PicBoxParking2.Visible = True 
      
    Case 3
      ' PicBoxParking3.Tag = Settings[F_sForm &/ "PicBoxParking3.Tag", Null] 'level=...
      sParkA = PicBoxParking3.Tag
      sParkB = ReadLevelsTag()
      
      ''Change:
      sParkX = sParkA
      sParkA = sParkB
      sParkB = sParkX
      PicBoxParking3.Tag = sParkA '◀——   
      
      If PicBoxParking3.Tag And PicBoxParking3.Tag Like "*level=*" Then 
        PicBoxParking3.Picture = F_picClock 'New
      Else 
        PicBoxParking3.Picture = PicTemplateParking3.Picture 'Empty "P"
      Endif 
      If IsDir(sDir) = True Then PicBoxParking3.Picture.Save(sDir &/ "parking3.png")
      ' Settings[F_sForm &/ "PicBoxParking3.Tag"] = PicBoxParking3.Tag
      'Show user:
      PicBoxParking3.Visible = False 
      Wait 0.3
      PicBoxParking3.Visible = True 
      
  End Select
  
  If sParkB Like "*level=*" Then 
    LoadPanelLevels1x(sParkB)
  Else 
    LoadLevelsNewNull()
  Endif 
  SumPaintClockLevels()
  UndoRedoLevelSave()
  If sParkA Not Like "*level=*" Then LabelMessageText("P" & iLastTag & " = " & ("leer"), Color.Red) 'Example: "P1 = empty"
  If PanelMuster.Visible = True Then ScrollViewEnsureVisibleG(sParkB)
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView3Select(Optional sClock As String = "00:00")
  
  Dim sKey, sFound As String 
  Dim iLine As Integer
  
  If ColumnView3.Keys Then 
    ColumnView3.UnSelectAll()
    For Each sKey In ColumnView3.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      
      If ColumnView3[sKey].Text = sClock Then 
        ColumnView3[sKey].Selected = True
        sFound = sKey  
        Break
      Endif 
    Next 
    If ColumnView3.Exist(sFound) = True Then 
      ColumnView3[sFound].Selected = True
      ColumnView3[sFound].EnsureVisible()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Click()
  
  TimerClock.Stop()
  DateTimeSetting(DateChooser1.Value) 'as Date
  DateTimeCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateTimeCheck()
  
  TimerClock.Stop()
  CheckTimerClockPausePicture()
  DateTimeSetting(F_dateNow) 'as Date
  ColumnView3Select(Format(F_dateNow, "hh:nn"))
  ResizePanelLevels()
  SumPaintClockLevels()
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateTimeSetting(Optional dateTime As Date = Now) 
  
  F_dateNow = dateTime 'as Date
  F_iSecondCounter = 0 'Start new all Images to Clock-Picture
  
  If F_dateNow Then 
    If Abs(DateDiff(F_dateNow, Now, gb.Minute)) > 0 Then LabelTimePause.Text = Format(F_dateNow, "ddd dd.mm.yyyy hh:nn:ss")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Add1xMuster(Optional hLastPic As Picture, Optional sTag As String = "")
  
  Dim W, H As Float
  Dim iCloseW, iLeft, iTop, iCount As Integer
  Dim hPicbox As PictureBox
  Dim hButton As Button
  
  If F_iESCpressed > 0 Then Return 'end here
  
  ' If Not F_ooPicBoxesMuster Then UndoRedoMusterSave("")
  
  ''Check picture
  If Not hLastPic Then 
    If String.InStr(String.LCase(sTag), "level=") > 0 Then hLastPic = PicTemplateQuestion.Picture '?
  Endif 
  If hLastPic Then 
    If hLastPic.Width <> F_iIconSize Then hLastPic = hLastPic.Image.Stretch(F_iIconSize, F_iIconSize).Picture
  Endif
  
  If F_ooPicBoxesMuster Then
    '...
  Else
    ScrollViewMuster.Children.Clear()
  Endif 
  
  ''Add new:
  If sTag Then 
    If Not F_ooPicBoxesMuster Then F_ooPicBoxesMuster = New Object[]
    If Not F_ooButtonMuster Then F_ooButtonMuster = New Object[]
    If Not F_ssPicBoxMusterTags Then F_ssPicBoxMusterTags = New String[]
    H = PanelLevels.H
    W = H '1:1 WxH
    
    ''PictureBox
    hPicbox = New PictureBox(ScrollViewMuster) As "GroupMuster" '—▶Public Sub GroupLevels_MouseUp()
    iTop = 0 'hier nur eine horizontale Zeile |—▷   —▶ ResizePanelGallery()
    iCount = F_ooPicBoxesMuster.Count '+ 1    '—▶  .Add()
    
    hPicbox.Background = Color.Default
    hPicbox.Move(iLeft, iTop, W, H) ''—▶ ResizePanelGallery()
    hPicbox.Tooltip = iCount ''1,2,3,...
    hPicbox.Tag = sTag
    hPicbox.Visible = False 'True —▶ ResizePanelGallery()
    hPicbox.Border = Border.None
    hPicbox.Stretch = True
    hPicbox.Padding = 3 'grünen Rand sichtbar lassen
    hPicbox.Mouse = Mouse.Pointing  ''hand
    If hLastPic Then hPicbox.Picture = hLastPic
    
    F_ooPicBoxesMuster.Add(hPicbox)
    iCount = F_ooPicBoxesMuster.Count
    F_ooPicBoxesMuster[F_ooPicBoxesMuster.Max].Tooltip = iCount
    F_ssPicBoxMusterTags.Add(sTag)
    F_iMusterAddLast = F_ooPicBoxesMuster.Max
    
    ''Button [x]
    hButton = New Button(ScrollViewMuster) As "GroupMuster"
    
    iCloseW = 25
    hButton.Background = hPicbox.Background
    hButton.Move(iLeft + W - iCloseW, iTop, iCloseW, iCloseW) ''—▶ Form_Resize()
    hButton.Tooltip = Quote("Muster ausschneiden") & Space(1) & ("oder") & Space(1) & Quote("Neu berechnen") ''0,1,2,3,...
    hButton.Tag = sTag    '—▶  .Add()
    hButton.Visible = False
    hButton.Border = True
    hButton.Mouse = Mouse.Pointing  ''hand
    hButton.Picture = PicTemplateCloseCancel22.Picture 'Picture["icon:/22/close"]
    hButton.Raise()
    
    F_ooButtonMuster.Add(hButton)
    
    F_oLastPicBoxMuster = hPicbox
  Endif 
  
  'Note: "Loop" Add1xClockLevel() in IconListAdd()
  
Catch
  FMain.ErrorText
  
End

Public Sub SaveSelectMusterPictures()
  
  Dim sPathLast, sDir, sFile, sPath, sExt, sMessage, sTime As String
  Dim it, iLine, iSelect, iAll, iSaved, iFormat As Integer
  Dim sFileNames As String 
  Dim hPic As Picture
  Dim bSaveAll As Boolean
  
  sTime = Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss")
  sExt = "png"
  
  ''Selection:
  If F_ooPicBoxesMuster Then 
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif 
      
      If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then iSelect = iSelect + 1
    Next   
    iAll = F_ooPicBoxesMuster.Count
    iFormat = String.Len(Str(F_ooPicBoxesMuster.Max)) 'as Integer, Example: 3 > 001, 002, 003, ...
  Endif 
  
  ''Check:
  sMessage &= "<h3><font color=gray><b>" & ("Bild-Größe") & ": " & F_iIconSize & " x " & F_iIconSize & Space(1) & ("px (Pixel)") & "</b></font></h3>"
  sMessage &= "<h3><font color=gray><b>" & ("Muster. Bilder im Ordner... hinzufügen mit Zeitangabe") & "</b></font></h3>"
  sMessage &= "<h3><font color=gray><b>" & ("Auswahl") & Space(1) & iSelect & Space(1) & ("von") & Space(1) & iAll & "</b></font></h3>"
  
  sMessage &= "<h3><font color=blue><b>" & "○ " & ("Auswahl speichern") & "</b></font></h3>"
  sMessage &= "<h3><font color=darkgreen><b>" & "● " & ("Alles speichern") & "</b></font></h3>"
  
  Select Message.Question(sMessage, "● " & ("Alles speichern") & "..." & iAll, "○ " & ("Auswahl speichern") & "..." & iSelect, ("Abbrechen"))
    Case 1
      bSaveAll = True
      
    Case 2 
      bSaveAll = False 
      
    Case 3 'Cancel:
      Goto JumpEnd
      
  End Select
  
  ''Check:
  If bSaveAll = False And iSelect = 0 Then
    ''no selection: 
    sMessage = "<font color=red><b>" & ("Speichern") & "</b></font>" & "<br><br>"
    sMessage &= "<font color=red><b>" & ("Keine markierten Bilder") & "</b></font>" & "<br>" & "<br>"
    sMessage &= "<font size=5 color=darkgreen><b>" & Str(iSaved) & "</b></font>" & Space(1) & ("von") & Space(1) & "<font size=5><b>" & Str(iSelect) & "</b></font>" & Space(1) & ("gespeichert") & "<br>" & "<br>"
    If Exist(sDir) = False Then sMessage &= "<font color=red><b>" & ("Fehler? Ordner fehlt") & "</b></font>" & "<br>"
    
    Select Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
        If IsDir(sDir) = False Then sDir = File.Dir(sDir)
        M01Functions.FileManagerOpen(sDir)
      Case 2 
        '...
    End Select
    Goto JumpEnd
  Endif 
  
  ''Directory:
  sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  
  ' ''Selection:
  ' Dialog.Path = sDir
  ' Dialog.Title = Application.Name & " - " & ("Bilder speichern unter...")
  ' 
  ' If Dialog.SelectDirectory() = True Then Return ''-1=TRUE=Cancel  file is not saved, procedure ends here
  ' 
  ' ''Save:
  ' sDir = Dialog.Path
  sPath = Settings[FMain.Name &/ "F_sPathClockBackground_png", FMain.F_sPathClockBackground_png]
  sPathLast = File.SetDir(sPath, sDir)
  ''Save:
  sPath = FileDialogPathReturn(sPathLast, "save", sPath)  'Last-Path, open/save, Standard-Path
  If Not sPath Then Goto JumpEnd  
  
  iSelect = 0
  iSaved = 0
  For it = 0 To F_ooPicBoxesMuster.Max
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_iESCpressed > 0 Then 
      If MessageQuestionBreak() > 0 Then Break
    Endif 
    
    If F_ooPicBoxesMuster[it].Picture Then
      If bSaveAll = False And F_ooPicBoxesMuster[it].Background = F_iColorSelect Then 
        iSelect = iSelect + 1
        sFile = String.LCase(Application.Name & "_" & sTime & "_" & F_iIconSize & "pixel" & "_nr" & Format(Str(it), String(iFormat, "0")) & "." & sExt)
        hPic = F_ooPicBoxesMuster[it].Picture 
        sPath = sDir &/ sFile
        If Exist(sPath) = True Then Try Kill sPath
        hPic.Save(sPath)
        If Exist(sPath) = True Then 
          iSaved = iSaved + 1
          sFileNames = sFileNames & sFile & "<br>"
        Endif
      Else 'All
        iSelect = iSelect + 1
        sFile = String.LCase(Application.Name & "_" & sTime & "_" & F_iIconSize & "pixel" & "_nr" & Format(Str(it), String(iFormat, "0")) & "." & sExt)
        hPic = F_ooPicBoxesMuster[it].Picture 
        sPath = sDir &/ sFile
        If Exist(sPath) = True Then Try Kill sPath
        hPic.Save(sPath)
        If Exist(sPath) = True Then 
          iSaved = iSaved + 1
          sFileNames = sFileNames & sFile & "<br>"
        Endif
      Endif 
    Endif 
  Next   
  
  ''Infos:
  If iSaved > 0 Then 
    sMessage = "<b>" & sDir & "</b>" & "<br>"
    sMessage &= F_iIconSize & "x" & F_iIconSize & Space(1) & ("Pixel") & "<br>"
    sMessage &= String.Left(sFileNames, 500) & "<br>"
    sMessage &= "<font size=5 color=darkgreen><b>" & Str(iSaved) & "</b></font>" & Space(1) & ("von") & Space(1) & "<font size=5><b>" & Str(iSelect) & "</b></font>" & Space(1) & ("gespeichert")
    MenuSaveRecentG(sPath)
  Else 
    ''Check:
    sMessage = "<font color=red><b>" & ("Fehler. Bilder nicht gespeichert.") & "</b></font>"
  Endif 
  
  Select Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
    Case 1
      If Exist(sPath) = True Then M01Functions.FileManagerOpen(sPath) Else M01Functions.FileManagerOpen(sDir) '(*1)
    Case 2 
      '...
  End Select
  
JumpEnd:
  ProgressBarONoff(False) 
  
  ''_____________________________________________________________________________''
  ' (*1) 'Note: no Space(1). Space(1) is Separator in Shell "nautilus" & Space(1) & sPath
  'String & Space(1) & String & Space(1)...  
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizePanelMuster()
  
  Dim iCount, iPicW, iPicH, iLeft, iTop, iColumns, iCloseW, it, iLine As Integer
  Dim iiSelect, iiUnselect, iiSelectNoTop, iiMuster As Integer[]
  

  If F_iESCpressed > 0 Then Return 'end here
  
  If F_ooPicBoxesMuster Then 
    iiSelect = New Integer[]
    iiUnselect = New Integer[]
    iiSelectNoTop = New Integer[]
    iiMuster = New Integer[]
    
    If Not F_iiMusterSort Then 
      ''Selection?
      For it = 0 To F_ooPicBoxesMuster.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_iESCpressed > 0 Then 
          If MessageQuestionBreak() > 0 Then Break
        Endif 
        
        iiSelectNoTop.Add(it)
        
        If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then 
          iiSelect.Add(it)
        Else 
          iiUnselect.Add(it)
        Endif 
      Next
    Else 
      If F_iiMusterSort Then 
        iiSelectNoTop = F_iiMusterSort.Copy()
        ''Selection?
        For Each it In iiSelectNoTop
          iLine = iLine + 1
          If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          
          ' iiSelectNoTop.Add(it)
          If it < F_ooPicBoxesMuster.Count Then 
            If F_ooPicBoxesMuster[it].Background = F_iColorSelect Then 
              iiSelect.Add(it)
            Else 
              iiUnselect.Add(it)
            Endif  
          Endif 
        Next
      Endif 
    Endif 
    
    If F_bSelectionTopON = True Then
      iiMuster.Insert(iiSelect)
      iiMuster.Insert(iiUnselect)
    Else
      iiMuster.Insert(iiSelectNoTop)
    Endif 

    ''Resize and Sort:
    If F_iESCpressed = 0 Then 
      ' ZoomMinMaxCheck()

      iPicW = F_iZoomGallery
      iPicH = iPicW '1:1 WxH
      iColumns = (ScrollViewMuster.W - Desktop.Y) / iPicW  'not .ClientWidth, different empty or full
      If F_ooButtonMuster.Max > -1 Then iCloseW = F_ooButtonMuster[0].W Else iCloseW = 25
      iLeft = -1 'Begin with 0
      ProgressBar1.Pulse = False
      iCount = F_ooPicBoxesMuster.Count
      If iCount < 2 Then iCount = 1 'Not Division by zero 
      
        ''Selection:
        For Each it In iiMuster
          iLine = iLine + 1
          ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
          ''[ESC]?
          If F_iESCpressed > 0 Then 
            If MessageQuestionBreak() > 0 Then Break
          Endif 
          
          If iLine Mod 100 = 0 Then 'show processing for user
            ProgressBar1.Value = iLine / iCount
            Wait 0.000001
            ProgressBar1.Visible = True
          Endif 
          
          'Positions PictureBoxes
          iLeft = iLeft + 1
          If iLeft > iColumns - 1 Then 
            iLeft = 0
            iTop = iTop + 1
          Endif 
          
          If it > -1 And it < F_ooPicBoxesMuster.Count Then 
            If Object.Type(F_ooPicBoxesMuster[it]) = "PictureBox" Then 
              F_ooPicBoxesMuster[it].Move(iPicW * iLeft, iPicH * iTop, iPicW, iPicH) 
              F_ooPicBoxesMuster[it].Visible = True
              If iiSelect.Find(it) > -1 Then 
                F_ooPicBoxesMuster[it].Background = F_iColorSelect
              Else 
                F_ooPicBoxesMuster[it].Background = Color.Default
              Endif 
            Endif 
            If Object.Type(F_ooButtonMuster[it]) = "Button" Then 
              F_ooButtonMuster[it].Move((iPicW * iLeft) + iPicW - iCloseW, iPicH * iTop, iCloseW, iCloseW) 
              F_ooButtonMuster[it].Visible = True
              F_ooButtonMuster[it].Raise()
              F_ooButtonMuster[it].Background = Color.Default
            Endif 
          Endif 
          ' If Not F_ooPicBoxesMuster[it].Picture Then F_ooPicBoxesMuster[it].Picture = LoadMusterOnePicture(F_ooPicBoxesMuster[it].Tag) 'as Picture
        Next
      
    Endif
    F_iScrollPart = iPicH * 0.6 'F_iZoomGallery
    If iiSelect.Empty = False Then F_iiMusterSelection = iiSelect.Copy() Else F_iiMusterSelection = Null
  Endif
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)  
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterSelectionTopInfo()
  Dim sMessage As String 
  Dim iCounter, iAll As Integer
  
  If F_iiMusterSelection Then iCounter = F_iiMusterSelection.Count
  If F_ooPicBoxesMuster Then iAll = F_ooPicBoxesMuster.Count
  
  sMessage = InfoButtonPictureMessage(ButtonMusterSelectionTop.Picture) 'as String
  sMessage &= "<h2>" & ("Muster") & "</h2>"
  sMessage &= "<h2>" & "<font size=7>" & iCounter & Space(1) & "</font>" & ("von") & Space(1) & iAll & Space(1) & ("ausgewählt/markiert") & "</h2>"
  ' sMessage &= "<br>"
  ' sMessage &= InfoColorPaletteMessage()
  
  Message.Info(sMessage, ("Abbrechen"))
  
  Catch 
  FMain.ErrorText
  
End

Public Sub GroupMuster_Enter()
  ' If F_bMovingON = False Then  
  
  If F_bChangeON = True Then  
    If Object.Type(Last) = "PictureBox" Then 
      F_oCursorFillLast = Last
      If Last.Background <> F_iColorSelect Then 
        If isMoveableParts(Last) = True Then Last.Background = F_iSelectYellow100 Else Last.Background = F_iSelectGreenAlpha150
      Endif 
      LabelMessageText("<b>" & ("Nr") & "." & Last.ToolTip & "</b>" & Space(1) & Last.Tag)
    Else If Object.Type(Last) = "Button" Then 
      Last.Background = F_iSelectRed150
    Endif 
  Endif 
  If F_bColorPickerAreaON = True Then  
    F_oCursorFillLast = Last
    TimerColorPicker.Start()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupMuster_Leave()
  ' If F_bMovingON = False Then 
  
  If F_bChangeON = True Then 
    If Object.Type(Last) = "PictureBox" Then 
      If Last.Background <> F_iColorSelect Then Last.Background = Color.Default
    Else If Object.Type(Last) = "Button" Then 
      Last.Background = Color.Default
    Endif  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub GroupMuster_MouseDown()
  
  F_iSelectButton0Levels1Gallery2Muster3 = 3
  F_oLastPicBoxMuster = Last 'before
  
  If Mouse.Left = True Then 
    If Object.Type(Last) = "PictureBox" Then 
      If F_bColorPickerAreaON = True Then 
        ColorPickerMousedownSelected()
      Else
        If Last.Background = F_iColorSelect Then Last.Background = Color.Default Else Last.Background = F_iColorSelect 
        If String.InStr(Last.Tag, "level=") > 0 Then 
          F_sLevelsTags = Last.Tag
          LoadPanelLevels1x(Last.Tag) 
          UndoRedoLevelSave()
          UndoRedoMusterSave()
        Endif 
      Endif 
    Else If Object.Type(Last) = "Button" Then
      F_sLevelsTags = Last.Tag
      MusterCut(Last) 
      UndoRedoLevelSave()
      UndoRedoMusterSave()
    Endif 
    MusterCounter() 'as String  "0/0"
    
  Else If Mouse.Middle = True Then 
    F_sLevelsTags = Last.Tag
    ScrollViewEnsureVisibleG(Last.Tag)  
    MusterCounter() 'as String  "0/0"
    
  Else If Mouse.Right = True Then 
    CheckMenu1()
    MenuEdit.Popup()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ReloadPicOriginal() '◀—▶ CutLevelGalleryMuster 
  
  Dim it As Integer
  Dim sPath, sTag, sLevelsBefore As String
  
  If PanelGallery.Visible = True Or F_iSelectButton0Levels1Gallery2Muster3 < 3 Then 
    If Object.IsValid(F_oLastPicBoxObject) = True Then 
      it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject) '-1 not found
      If it = -1 Then it = F_ooPicBoxesGallery.Find(F_oLastPicBoxObject) '-1 not found
      If it > -1 Then 
        If F_ooPicBoxesGallery[it].Picture = PicTemplateQuestion.Picture Then 
          sPath = F_ooPicBoxesGallery[it].Tag
          If Exist(sPath) = True Then F_ooPicBoxesGallery[it].Picture = Picture.Load(sPath)
        Endif
        F_ooPicBoxesLevels[it].Picture = F_ooPicBoxesGallery[it].Picture
        If F_ssEditLevels Then F_ssEditLevels[it] = ""
        sTag = ReadLevelsTag()
        LoadLevelsNewNull()
        LoadLevels(sTag)
        SumPaintClockLevels()
        UndoRedoLevelSave()
      Endif 
    Endif
  Endif 
  
  If PanelMuster.Visible = True Or F_iSelectButton0Levels1Gallery2Muster3 = 3 Then 
    If Object.IsValid(F_oLastPicBoxMuster) = True Then 
      it = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster) '-1 not found
      If it > -1 Then 
        If F_ooPicBoxesMuster[it].Picture = PicTemplateQuestion.Picture Then 
          sPath = F_ooPicBoxesMuster[it].Tag
          If Exist(sPath) = True Then F_ooPicBoxesMuster[it].Picture = Picture.Load(sPath)
        Endif
        sLevelsBefore = ReadLevelsTag()
        sTag = F_ooPicBoxesMuster[it].Tag
        LoadLevelsNewNull()
        LoadLevels(sTag)
        SumPaintClockLevels()
        F_ooPicBoxesMuster[it].Picture = PicBoxClock.Picture
        
        ''Reset:
        LoadLevelsNewNull()
        LoadLevels(sLevelsBefore)
        SumPaintClockLevels()
        UndoRedoLevelSave()
      Endif 
    Endif
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LoadPanelLevels1x(Optional sTag As String = "") 
  
  If sTag Like "*level=*" Then 
    LoadLevelsNewNull()
    LoadLevels(sTag)
    ResizePanelLevels()
    SumPaintClockLevels()
    SynchronizeLevelsToGallery()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MusterUnselectAll()
  
  Dim it As Integer
  
  If F_ooPicBoxesMuster Then 
    For it = 0 To F_ooPicBoxesMuster.Max
      F_ooPicBoxesMuster[it].Background = Color.Default
    Next
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MusterSelectAll()
  
  Dim it As Integer
  
  If F_ooPicBoxesMuster Then 
    ''selected?
    For it = 0 To F_ooPicBoxesMuster.Max
      F_ooPicBoxesMuster[it].Background = F_iColorSelect
    Next
    If Object.IsValid(F_oLastPicBoxObject) = False Then F_oLastPicBoxObject = F_ooPicBoxesMuster[0]
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MusterChange()
  
  Dim iFound As Integer 
  Dim sTag, sMessage, sNumber As String 
  Dim sPathCache1, sPathCache2 As String
  Dim picQuestion As Picture 
  
  If Not F_ooPicBoxesMuster Then CheckMusterSideFill()'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  
  iFound = -1
  If F_ooPicBoxesMuster Then 
    
    If Object.IsValid(F_oLastPicBoxMuster) = True Then iFound = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster)
    If iFound = -1 Then iFound = F_ooPicBoxesMuster.Max 
    If iFound > -1 Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[iFound]
    
    ScrollViewEnsureVisibleG()
    
    picQuestion = Picture.Load("icon:/32/question")
    sNumber = "<font color=gray>" & F_oLastPicBoxMuster.ToolTip & "</font>"
    
    sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
    If PicBoxClock.Picture Then PicBoxClock.Picture.Save(sPathCache1) Else picQuestion.Save(sPathCache1)
    
    sPathCache2 = M01Functions.TempDirFile("2.png") ' Temp() & ".png"
    If Object.IsValid(F_oLastPicBoxMuster) = True Then
      If F_oLastPicBoxMuster.Picture Then F_oLastPicBoxMuster.Picture.Save(sPathCache2) Else picQuestion.Save(sPathCache2)
    Else 
      picQuestion.Save(sPathCache2)
    Endif 
    
    sMessage = "<font color=gray>" & ("Auswahl mit Mittel-Klick") & "</font>"
    sMessage &= "<h3>"
    sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=100 height=100 >" & Space(1) & ("Neu") & Space(1) & sNumber & "<br>"
    sMessage &= "<img src=" & Quote("file://" & sPathCache2) & " width=100 height=100 >" & Space(1) & ("Alt") & Space(1) & sNumber & "<br>" & "<br>" & "<br>"
    sMessage &= "● " & ("Muster") & Space(1) & sNumber & Space(1) & ("ersetzen") & "?" 
    sMessage &= "</h3>"
    
    Select Case Message.Question(sMessage, "○ " & ("+Hinzufügen"), "● " & ("Ersetzen"), ("Abbrechen"))
      Case 1 'add, append+
        CheckExistMuster() 
      Case 2 'Change New > Old
        If iFound > -1 Then 
          sTag = ReadLevelsTag()
          F_ooPicBoxesMuster[iFound].Picture = PicBoxClock.Picture
          F_ooPicBoxesMuster[iFound].Tag = sTag
          F_bMusterSideChanged = True 
          F_oLastPicBoxMuster = F_ooPicBoxesMuster[iFound]
          F_sLevelsTags = sTag
          ' UndoRedoMusterSave(sTag)  'ReadMusterTags(True) 'All
          SaveMusterTags()
          If PanelMuster.Visible = False Then SideG("muster")
        Endif
      Case 3 'Cancel
        '...
    End Select
    
  Else 
    LabelMessageText(("Ein Bild markieren (Mittel-Klick)"), Color.Red)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterColorRefreshSelection()
  
  Dim sTagBefore, sLine, sColorChange, sMuster, sColors, sMusterRefresh As String 
  Dim it, iLine, iSelect, iAll, iSelectLast As Integer 
  Dim ssSpli, ssMuster As String[]
  Dim sMessage, sSelectInfo As String
  Dim bTimerON As Boolean
  
  If F_iESCpressed > 0 Then Return 'end here
  
  bTimerON = TimerClock.Enabled
  TimerClock.Stop
  F_bChangeON = False 
  
  If F_ooPicBoxesMuster Then 
    iAll = F_ooPicBoxesMuster.Count
    sTagBefore = ReadLevelsTag()
    ' SettingsColorsUserReadSave("save")
    ssMuster = New String[]
    ssMuster.Resize(F_ooPicBoxesMuster.Count)
    
    ''User-Colors (Farb-Palette)
    sColorChange = "colorchange=" 
    For it = 0 To F_ooPicBoxesColorsB.Max
      sColorChange &= F_ooPicBoxesColorsB[it].Background & "="
    Next
    
    ''Selection Muster
    For it = 0 To F_ooPicBoxesMuster.Max 
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif  
      
      If F_ooPicBoxesMuster[it].Background = F_iColorSelect And F_ooPicBoxesMuster[it].Picture Then 
        iSelect = iSelect + 1 
        sMusterRefresh = Null 'Reset
        sMuster = F_ooPicBoxesMuster[it].Tag
        ssSpli = Split(sMuster & gb.NewLine, gb.NewLine)
        For Each sLine In ssSpli
          If String.InStr(sLine, "level=end") = 0 Then 
            ''all lines without colors
            If String.InStr(sLine, "colorchange=") = 0 Then sMusterRefresh &= sLine & gb.NewLine
          Else 
            If String.InStr(sMusterRefresh, "colorchange=") = 0 Then sMusterRefresh &= sColorChange & gb.NewLine 'Replace Colors
            ''last line:
            sMusterRefresh &= sLine & gb.NewLine
          Endif 
        Next
        ssMuster[it] = sMusterRefresh
        iSelectLast = it
        
        sMuster = Null 'reset
      Endif 
    Next
  Endif 
  
  If F_iESCpressed > 0 Then Goto JumpEnd 
  
  sColors = ""
  If F_ooPicBoxesColorsB Then  
    For it = 0 To F_ooPicBoxesColorsB.Max
      If F_ooPicBoxesColorsB[it].Background = Color.Background Then 
        sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
      Else 
        sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & "■" & "</font>"  
      Endif 
    Next   
    sMessage = "<font size=5>" & sColors & "</font>"
  Endif 
  sSelectInfo = iSelect & Space(1) & ("von") & Space(1) & iall
  sMessage &= "<h3><font color=gray>" & ("Farb-Palette anwenden") & "</font></h3>"
  sMessage &= "<h3><font color=gray>" & ("Markierte Muster") & Space(1) & sSelectInfo & "</font></h3>"
  
  If iSelect = 0 Then 
    sMessage = "<font color=gray>" & sMessage & "</font>"
    sMessage &= "<h3><font color=red>" & ("Eine Auswahl fehlt (noch)") & "</font></h3>"
  Endif 
  
  Select Case Message.Question(sMessage, "● " & ("Markierte") & Space(1) & sSelectInfo, ("Ordner..."), ("Abbrechen"))
      
    Case 1 ''Selection
      If F_ooPicBoxesMuster Then 
        If Not F_ssPicBoxMusterTags Then F_ssPicBoxMusterTags = New String[]
        If F_ssPicBoxMusterTags.Max <> F_ooPicBoxesMuster.Max Then F_ssPicBoxMusterTags.Resize(F_ooPicBoxesMuster.Count)
        For it = 0 To ssMuster.Max
          If ssMuster[it] Like "*level=*" Then 
            sMuster = ssMuster[it]
            LoadLevelsNewNull()
            F_oLastPicBoxMuster = F_ooPicBoxesMuster[it]
            LoadLevels(sMuster) 
            SumPaintClockLevels()
            '**************************************
            F_ooPicBoxesMuster[it].Picture = F_imgSumPaintClockLevels.Picture 'F_picClock
            F_ooPicBoxesMuster[it].Tag = sMuster
            F_ssPicBoxMusterTags[it] = sMuster
            '**************************************
          Endif 
        Next 
      Endif 
      UndoRedoMusterSave() 'All
      LoadPanelLevels1x(sTagBefore)
      MusterCounter()
      If Object.IsValid(F_ooPicBoxesMuster[iSelectLast]) = True Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[iSelectLast]
      sMessage = "<h3><font color=blue>" & "● " & ("Alle Muster neu berechnen?") & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Neu berechnen"), ("Ordner..."), ("Abbrechen"))
        Case 1 ''Reload
          MusterReloadAll()
        Case 2 'Directory
          M01Functions.FileManagerOpen(FilePathForm())
        Case 3
          '..
      End Select 
      
    Case 2 'Directory
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case 3 'Cancel
      ''...
      
  End Select
  
JumpEnd:
  TimerClock.Enabled = bTimerON
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CutLevelGalleryMuster() '◀—▶ ReloadPicOriginal() 
  
  Dim it As Integer
  Dim sPath, sMessage As String 
  
  Select Case F_iSelectButton0Levels1Gallery2Muster3
      
    Case 1 'Levels
      If Object.IsValid(F_oLastPicBoxObject) = True Then HideLevel(F_oLastPicBoxObject)
      
    Case 2 'Gallery
      If F_ooPicBoxesGallery And Object.IsValid(F_oLastPicBoxObject) = True Then 
        it = F_ooPicBoxesGallery.Find(F_oLastPicBoxObject) '-1 not found
        If it > -1 Then 
          sPath = F_ooPicBoxesGallery[it].Tag
          If sPath Like "images/*" Then 
            sMessage = ("Das Bild ist Teil des Programms und nicht löschbar.")
          Else If String.InStr(sPath, "/") > 0 Then 
            FileTempSave(F_ooPicBoxesGallery[it])
            F_ooPicBoxesGallery[it].Picture = PicTemplateQuestion.Picture
            F_ooPicBoxesLevels[it].Picture = PicTemplateQuestion.Picture
            
            F_sLoadUserPaths = Settings[F_sForm &/ "F_sLoadUserPaths", Null]
            F_sLoadUserPaths = Replace(F_sLoadUserPaths, sPath, "")
            Settings[F_sForm &/ "F_sLoadUserPaths"] = F_sLoadUserPaths
            SumPaintClockLevels()
            ' ScrollViewEnsureVisibleG(it)
          Else 
            sMessage = ("Intern berechnetes Bild, keine Datei.")
          Endif 
        Else  
          sMessage = ("Ein Bild markieren (Mittel-Klick)")
        Endif 
        If sMessage Then 
          sMessage = "<font color=red><b>" & sMessage & "</b></font>"
          Message.Info(sMessage, ("Abbrechen"))
        Endif 
      Endif 
    Case 3 'Muster
      If F_oLastPicBoxMuster Then MusterCut(F_oLastPicBoxMuster)
      
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub PanelMenuColor_Enter()
  
  CheckMenu1()
  GallerySelectPic(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelMenuColor_Leave()
  
  GallerySelectPic(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub GallerySelectPic(Optional bSelectON As Boolean = False)
  
  Dim it As Integer
  Dim sNumber As String 
  
  If F_ooPicBoxesGallery And Object.IsValid(F_oLastPicBoxObject) = True Then 
    sNumber = F_oLastPicBoxObject.ToolTip
    If IsInteger(sNumber) = True Then it = CInteger(sNumber) - 1 'as Integer
    ' it = it - 1   'Array 0,1,2,... ToolTip 1,2,...
    If it > -1 And it < F_ooPicBoxesGallery.Count Then 
      If bSelectON = True Then 
        F_iLastPicBoxColor = F_ooPicBoxesGallery[it].Background 
        F_ooPicBoxesGallery[it].Background = Color.Blue
      Else 
        F_ooPicBoxesGallery[it].Background = F_iLastPicBoxColor 
      Endif 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function ToolTipNumberToArrayNr(Optional sToolTipNumber As String) As Integer
  
  Dim it As Integer = -1
  
  If F_ooPicBoxesGallery Then  
    If IsInteger(sToolTipNumber) = True Then it = CInteger(sToolTipNumber) - 1 'as Integer
    ' it = it - 1   'Array 0,1,2,... ToolTip 1,2,...
    If it < 0 Or it > F_ooPicBoxesGallery.Max Then it = -1 'not found
  Endif 
  
  Return it
  
Catch 
  FMain.ErrorText
  
End

Public Function LevelSelectNumber() As Integer
  
  Dim it As Integer = -1
  Dim sNumber As String 
  
  If Object.IsValid(F_oLastPicBoxObject) = True Then 
    sNumber = F_oLastPicBoxObject.ToolTip
    If IsInteger(sNumber) = True Then it = CInteger(sNumber) - 1 'as Integer
    ' it = it - 1   'Array 0,1,2,... ToolTip 1,2,...
    If F_ooPicBoxesLevels Then
      If it > F_ooPicBoxesLevels.Max Then it = F_ooPicBoxesLevels.Max '1 'not found
    Endif 
  Endif 
  
  Return it
  
Catch 
  FMain.ErrorText
  
End

Public Function MusterSelectNumber() As Integer
  
  Dim it As Integer = -1
  
  If Object.IsValid(F_oLastPicBoxMuster) = True Then  
    If F_ooPicBoxesMuster Then 
      it = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster)'-1 'not found
      If it < 0 Or it > F_ooPicBoxesMuster.Max Then it = F_ooPicBoxesMuster.Max 
    Endif 
  Endif 
  
  Return it
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileTempSave(Optional oObj As Object = Null)
  
  Dim sDir, sFile, sPath As String 
  Dim it As Integer
  Dim hPic As Picture
  
  ''Save Original in program-cache temp:
  ' If Exist(sPathTag) = True Then 
  If Object.IsValid(oObj) = True Then 
    If FileTempExist(oObj) = False Then 
      sDir = M01Functions.CheckDirectoryCache()
      ' sDir = File.Dir(sDir)
      ' sFile = sToolTipNumber & ".tmp.png" 'Example File-Name: 123.tmp.png
      ' sFile = FileNameClear(sFile) 'as String
      If IsInteger(oObj.ToolTip) = True Then 
        it = CInteger(oObj.ToolTip) 
        sFile = it
        sPath = sDir &/ sFile & ".png"
      Endif 
      ' sFile = oObj.ToolTip
      ' sPath = sDir &/ sFile & ".png"
      ' it = ToolTipNumberToArrayNr(sToolTipNumber) 'as Integer   '0,1,2,3,...,n-1
      ' If it > -1 And it < F_ooPicBoxesGallery.Count Then hPic = F_ooPicBoxesGallery[it].Picture
      ' If hPic And Exist(sPath) = False Then hPic.Save(sPath) 'only 1x
      If Exist(sPath) = False Then 
        ' it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject) '-1 not found
        ' If it > -1 Then 
        hPic = oObj.Picture
        If IsDir(sDir) = True And hPic Then hPic.Save(sPath)
        ' Endif 
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileTempLoad(Optional oObj As Object = Null) As Image
  
  Dim sDir, sFile, sPath As String 
  Dim hPic As Picture
  Dim Img As Image
  Dim it As Integer
  
  ''Save Original in program-cache temp:
  If Object.IsValid(oObj) = False And Object.IsValid(F_oLastPicBoxObject) = True Then oObj = F_oLastPicBoxObject 
  
  If Object.IsValid(oObj) = True Then 
    If IsInteger(oObj.ToolTip) = True Then 
      sDir = M01Functions.CheckDirectoryCache() 
      ' Temp(): Example File-Name: .../123.tmp
      ' sDir = File.Dir(sPath)
      ' sFile = sToolTipNumber & ".tmp.png" 'Example File-Name: 123.tmp.png
      ' sFile = FileNameClear(sFile) 'as String
      
      it = CInteger(oObj.ToolTip) 
      sFile = it
      sPath = sDir &/ sFile & ".png"
      
      ''Load:
      If Exist(sPath) = True Then hPic = Picture.Load(sPath) 
      
      If hPic Then 
        ' it = ToolTipNumberToArrayNr(sToolTipNumber) 'as Integer 0,1,2,3,...,n-1
        ' If it > -1 And it < F_ooPicBoxesLevels.Count Then 
        '   F_ooPicBoxesLevels[it].Picture = hPic
        '   F_ooPicBoxesGallery[it].Picture = hPic
        ' Endif 
        ' If F_oLastPicBoxObject Then 
        ' it = F_ooPicBoxesGallery.Find(F_oLastPicBoxObject) '-1 not found
        ' If it > -1 Then 
        ' If IsInteger(oObj.ToolTip) = True Then 
        '   it = CInteger(oObj.ToolTip) - 1
        ' F_ooPicBoxesLevels[it].Picture = hPic
        ' F_ooPicBoxesGallery[it].Picture = hPic
        ' Endif 
        ' Endif 
        Img = hPic.Image 
      Endif
      
    Endif 
  Endif 
  
  Return Img
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileTempExist(Optional oObj As Object = Null) As Boolean
  
  Dim sDir, sFile, sPath As String 
  Dim bFileExist As Boolean
  Dim it As Integer
  
  ''Save Original in program-cache temp:
  If Object.IsValid(oObj) = True Then 
    ' If oObj.ToolTip Then 
    sDir = M01Functions.CheckDirectoryCache() ''Example File-Name: .../123.tmp
    ' sDir = File.Dir(sPath)
    ' sFile = sToolTipNumber & ".tmp.png" 'Example File-Name: 123.tmp.png
    If IsInteger(oObj.ToolTip) = True Then 
      it = CInteger(oObj.ToolTip) 
      sFile = it
      sPath = sDir &/ sFile & ".png"
    Endif 
    ' sFile = FileNameClear(sFile) 'as String
    ' sPath = sDir &/ sFile & ".png"
    If Exist(sPath) = True Then bFileExist = True Else bFileExist = False
  Endif 
  
  Return bFileExist
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageEdit(Optional sLastTag As String = "")
  
  Dim Img, imgCopy As Image
  Dim picOriginal As Picture
  Dim bCopy As Boolean
  Dim sToolTip, sTag As String 
  Dim it As Integer
  
  ''Gallery:
  If Object.IsValid(F_oLastPicBoxObject) = True Then 
    If F_iSelectButton0Levels1Gallery2Muster3 = 1 Or F_iSelectButton0Levels1Gallery2Muster3 = 2 Then
      ' If F_ooPicBoxesLevels Then iFound = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject) ' -1 not found
      If F_oLastPicBoxObject.Picture Then 
        it = F_ooPicBoxesLevels.Find(F_oLastPicBoxObject)
        If it > -1 Then F_oLastPicBoxObject = F_ooPicBoxesLevels[it]
        Img = F_oLastPicBoxObject.Picture.Image'.Copy()
        sTag = F_oLastPicBoxObject.Tag
        LabelMessageText(sTag)
        ' sText = Img.Format 'as String "RGBA", "ARGB", "BGRA", And so on. component: gb.image
        sToolTip = F_oLastPicBoxObject.ToolTip
        picOriginal = F_oLastPicBoxObject.Picture
      Endif 
      If Not Img Then 
        If PicBoxSelectLevelONoff.Picture Then 
          Img = PicBoxSelectLevelONoff.Picture.Image
          sToolTip = PicBoxSelectLevelONoff.ToolTip
          sTag = PicBoxSelectLevelONoff.Tag
        Endif 
      Endif 
    Endif 
  Endif
  
  ''Muster:
  ' Img = Null 
  If F_oLastPicBoxMuster And F_iSelectButton0Levels1Gallery2Muster3 = 3 Then  
    If F_oLastPicBoxMuster.Picture Then 
      Img = F_oLastPicBoxMuster.Picture.Image.Copy()
      LabelMessageText(F_oLastPicBoxMuster.Tag)
      ' sText = Img.Format 'as String "RGBA", "ARGB", "BGRA", And so on. component: gb.image
      sToolTip = F_oLastPicBoxMuster.ToolTip
      picOriginal = F_oLastPicBoxMuster.Picture
    Endif 
  Endif  
  
  If Img Then '—▶ Menu1
    
    Select Case sLastTag
        
      Case "copy1", MenuCopy1.Tag
        bCopy = True 
        
      Case "copy2", MenuCopy2.Tag
        Img = Img.Stretch(64, 64)
        bCopy = True 
        
      Case "copy3", MenuCopy3.Tag
        Img = Img.Stretch(32, 32)
        bCopy = True 
        
      Case "save1", MenuSave1.Tag
        SavePictureAs(Img.Picture)
        bCopy = False 
        
    End Select 
    
    If bCopy = False Then  
      '' "mirrorleftright", "mirrortopbottom", "rotateleft", "rotateright", "grayscale", "scaleminus", "scaleplus", "moveleft", "moveright", "moveup", "movedown"
      
      If F_iSelectButton0Levels1Gallery2Muster3 = 1 Or F_iSelectButton0Levels1Gallery2Muster3 = 2 And Object.IsValid(F_oLastPicBoxObject) = True And Img Then 
        ' If isMoveableParts(F_oLastPicBoxObject) = False Then
        If Not F_ssEditLevels Then F_ssEditLevels = New String[F_ooPicBoxesLevels.Count]
        If F_ssEditLevels.Count < F_ooPicBoxesLevels.Count Then F_ssEditLevels.Resize(F_ooPicBoxesLevels.Count)
        If IsInteger(sToolTip) = True Then it = CInteger(sToolTip) - 1
        If it < F_ssEditLevels.Count Then F_ssEditLevels[it] = F_ssEditLevels[it] & sLastTag & "=" 
        
        ''Save Original in program-cache temp:
        ' If F_oLastPicBoxObject Then FileTempSave(F_oLastPicBoxObject) 'Example File-Name: .../123.tmp.png
        ' Img = F_ooPicBoxesLevels[it].Picture.Image
        '***********************************************
        Img = ImageEditReturn(Img, sLastTag) 'as Image
        '***********************************************
        
        If Img Then 
          F_ooPicBoxesLevels[it].Picture = Img.Picture
          If F_ooPicBoxesLevels[it].Visible = False Then 
            F_ooPicBoxesLevels[it].Left = (F_ooPicBoxesLevels[it].W * F_ooPicBoxesLevels.Max) + 1
            F_ooPicBoxesLevels[it].Visible = True 
            ResizePanelLevels()
          Endif 
          F_oLastPicBoxObject = F_ooPicBoxesLevels[it]
          If Object.IsValid(F_oLastPicBoxObject) = True Then F_oLastPicBoxObject.Picture = Img.Picture 
          ' CheckLastPicBoxObject() 'Show-Wait-Show ???
          SumPaintClockLevels()
        Endif 
      Endif  
    Endif 
    
    If F_iSelectButton0Levels1Gallery2Muster3 = 3 And F_oLastPicBoxMuster And Img Then 
      If IsInteger(sToolTip) = True Then it = CInteger(sToolTip) - 1
      
      ' Img = F_ooPicBoxesMuster[it].Picture.Image
      '***********************************************
      Img = ImageEditReturn(Img, sLastTag) 'as Image
      '***********************************************
      If Img Then 
        F_ooPicBoxesMuster[it].Picture = Img.Picture
        F_oLastPicBoxMuster = F_ooPicBoxesMuster[it]
        If F_oLastPicBoxMuster Then F_oLastPicBoxMuster.Picture = Img.Picture 
        ' CheckLastPicBoxObject() 'Show-Wait-Show
      Endif
    Endif
    
    If bCopy = True Then  
      ' Clipboard.Clear() 'no longer?
      Clipboard.Copy(Img) 'as Variant
      imgCopy = Clipboard.Paste("image/png")
      ' If Clipboard.Type <> Clipboard.Image Then 
      If Not imgCopy Then 
        ' Clipboard.Clear() 'no longer? 
        ' Wait 0.5
        Clipboard.Copy(Img) 'as Variant
        Wait 0.5 'time for clipboard
        imgCopy = Clipboard.Paste("image/png")
        If Not imgCopy Then imgCopy = M01Functions.ClipboardImage() 'as Image
      Endif
      
      ' If Img Then Wait 1 'time for clipboard
      ' If Clipboard.Type = Clipboard.Image Then 
      ' Img = M01Functions.ClipboardImage() 'as Image
      ' If Clipboard.Formats.Exist("image") = True Then 
      
      ' sText = imgCopy.Format 'as String "RGBA", "ARGB", "BGRA", And so on. component: gb.image
      ' Print sText
      If imgCopy Then 
        PicBoxPaste.Picture = imgCopy.Picture 'Control picture
      Else 
        PicBoxPaste.Picture = Null
      Endif 
    Endif 
    If PanelGallery.Visible = True And Object.IsValid(F_oLastPicBoxObject) = True Then 
      F_oLastPicBoxObject.Picture = Img.Picture 
    Endif 
  Endif 'Img
  
  ''No Picture:
  If Not Img Then 
    LabelMessageText(F_sLabelMessageTextEmptyHTML)
  Else  
    ''Check:
    If PanelGallery.Visible = True And Object.IsValid(F_oLastPicBoxObject) = True Then
      If isMoveableParts(F_oLastPicBoxObject) = True Then 
        ' F_oLastPicBoxObject.Picture = picOriginal
        LabelMessageText("<b>" & ("Nr") & "." & F_oLastPicBoxObject.ToolTip & "</b>" & Space(1) & "<font color=blue>" & ("Bewegliches Teil") & "</font>")
      Else 
        LabelMessageCheck(F_oLastPicBoxObject)
        ' LabelMessageText("<b>" & ("Nr") & "." & F_oLastPicBoxObject.ToolTip & "</b>" & Space(1) & F_oLastPicBoxObject.Tag)
      Endif 
    Endif 
    ''Check:
    If PanelMuster.Visible = True And F_oLastPicBoxMuster Then
      LabelMessageCheck(F_oLastPicBoxMuster)
      ' LabelMessageText("<b>" & ("Nr") & "." & F_oLastPicBoxMuster.ToolTip & "</b>" & Space(1) & F_oLastPicBoxMuster.Tag)
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function ImageEditReturn(Optional Img As Image, Optional sLastTag As String = "") As Image 
  
  Dim U, U75 As Float 
  Dim imgTemp As Image 
  
  If Img Then 
    
    Select Case sLastTag
        
      Case "mirrorleftright", MenuMirrorLeftRight.Tag 'vertical ◁|▶
        Img = Img.Mirror(True, False) '(Horizontal As Boolean, Vertical As Boolean) 
        
      Case "mirrortopbottom", MenuMirrorTopBottom.Tag 'horizontal △——▼
        Img = Img.Mirror(False, True)
        
      Case "rotateleft", MenuRotateLeft.Tag '◀○
        Img = Img.RotateLeft()
        
      Case "rotateright", MenuRotateRight.Tag '○▶
        Img = Img.RotateRight()
        
      Case "grayscale", MenuGrayscale.Tag '□■
        Img = Img.Desaturate()
        
      Case "scaleminus", MenuScaleMinus.Tag ''■ –▶ ▪ ("Inhalt ->verkleinern<-") & Space(1) & "(Scale Minus)"
        imgTemp = New Image(Img.W, Img.H, Color.Transparent)
        Paint.Begin(imgTemp)
        Paint.AntiAlias = True
        ' ImageHalfCheck(Img.W * 0.9 / 2)
        Img = Img.Stretch(ImageHalfCheck(Img.W * 0.9), ImageHalfCheck(Img.H * 0.9))
        Paint.DrawImage(Img, (imgTemp.W / 2) - (Img.W / 2), (imgTemp.H / 2) - (Img.H / 2)) '' > center <
        Paint.End
        Img = imgTemp.Copy()
        
      Case "scaleplus", MenuScalePlus.Tag ''▪ –▶ ■ ("Inhalt <-vergrößern->") & Space(1) & "(Scale Plus)"
        imgTemp = New Image(Img.W, Img.H, Color.Transparent)
        Paint.Begin(imgTemp)
        Paint.AntiAlias = True
        Img = Img.Stretch(ImageHalfCheck(Img.W * 1.1), ImageHalfCheck(Img.H * 1.1))
        Paint.DrawImage(Img, (imgTemp.W / 2) - (Img.W / 2), (imgTemp.H / 2) - (Img.H / 2)) '' > center <
        Paint.End
        Img = imgTemp.Copy()
        
      Case "moveleft", "moveright", "moveup", "movedown" '◀ ▶ ▲ ▼
        U = Img.W / 10
        U75 = ImageHalfCheck(U * 0.75)
        imgTemp = New Image(Img.W, Img.H, Color.Transparent)
        
        Select Case sLastTag
          Case "moveleft"
            Paint.Begin(imgTemp)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, -U75, 0)
            ' Paint.Fill()
            Paint.End
          Case "moveright"
            Paint.Begin(imgTemp)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, U75, 0)
            ' Paint.Fill()
            Paint.End
          Case "moveup"
            Paint.Begin(imgTemp)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, 0, -U75)
            ' Paint.Fill()
            Paint.End    
          Case "movedown"
            Paint.Begin(imgTemp)
            Paint.AntiAlias = True
            Paint.DrawImage(Img, 0, U75)
            ' Paint.Fill()
            Paint.End
        End Select
        Img = imgTemp.Copy()
        
        ' Case "fontsizeminus", "fontsizestandard", "fontsizeplus"
        ' 
        '   ' imgTemp = New Image(Img.W, Img.H, Color.Transparent)
        '   Settings[F_sForm &/ "F_fFontSizePlus"] = F_fFontSizePlus
        '   F_fFontSizePlus = CheckLabelFontSize() 'as Float
        ' If PanelMuster.Visible = True Then SideG("gallery")
        ' sTag = ReadLevelsTag()
        ' CreateLevelsGallery() ''Refresh
        ' LoadLevelsNewNull()
        ' LoadLevels(sTag)
        ' ResizePanelLevels()
        ' SumPaintClockLevels()
        ' Img = imgTemp.Copy()
    End Select
  Endif
  
  Return Img 'Background Picture
  
Catch 
  FMain.ErrorText
  
End

Public Function ImageHalfCheck(Optional iSize As Integer = 0) As Integer
  
  iSize = (iSize / 2) * 2 
  If iSize Mod 2 <> 0 Then iSize = iSize + 1 
  
  Return iSize 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ScrollViewEnsureVisibleG(Optional sTag As String = "")
  
  Dim iColor As Integer
  Dim iFound As Integer = -1
  Dim oObj As Object
  
  If F_iESCpressed > 0 Then Return 'end here
  If PanelColorPicker.Visible = True Or PanelColorSave1.Visible = True Then Return 
  
  If F_bChangeON = True Then
    If Not sTag Then 
      If PanelGallery.Visible = True Then 
        iFound = F_ssPicBoxGalleryTags.Find(PicBoxSelectLevelONoff.Tag)
        If iFound = -1 Then 
          If F_ooPicBoxesGallery And Object.IsValid(F_oLastPicBoxObject) = True Then iFound = F_ooPicBoxesGallery.Find(F_oLastPicBoxObject)
        Endif 
      Else If PanelMuster.Visible = True Then 
        If F_ooPicBoxesMuster And Object.IsValid(F_oLastPicBoxMuster) = True Then iFound = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster)
        If iFound = -1 Then 
          If F_ssPicBoxMusterTags And F_sLevelsTags Then iFound = F_ssPicBoxMusterTags.Find("*" & Replace(F_sLevelsTags, gb.NewLine, "*") & "*", gb.Like) '-1 not found 
        Endif 
      Endif 
    Endif 
    
    If PanelGallery.Visible = True Then 
      If iFound = -1 And sTag Then 
        If IsInteger(sTag) = True Then iFound = CInteger(sTag)
      Endif 
      
      If iFound > -1 Then 
        ' If PanelGallery.Visible = False Then SideG("gallery")
        If F_ooPicBoxesGallery And iFound < F_ooPicBoxesGallery.Count Then oObj = F_ooPicBoxesGallery[iFound]
      Endif 
      
    Else If PanelMuster.Visible = True Then 
      
      If F_ooPicBoxesMuster Then 
        If sTag Then 
          If IsInteger(sTag) = True Then 
            iFound = CInteger(sTag)
          Else 
            iFound = F_ssPicBoxMusterTags.Find("*" & Replace(sTag, gb.NewLine, "*") & "*", gb.Like) '-1 not found
          Endif 
        Endif 
        
        If iFound = -1 And Object.IsValid(F_oLastPicBoxMuster) = True Then iFound = F_ooPicBoxesMuster.Find(F_oLastPicBoxMuster)
      Endif 
      
      If iFound > -1 Then 
        If F_ooPicBoxesMuster Then 
          If iFound < F_ooPicBoxesMuster.Count Then 
            oObj = F_ooPicBoxesMuster[iFound]
          Endif 
        Endif 
      Endif 
    Endif 
    
    If Object.IsValid(oObj) = True Then 
      iColor = oObj.Background
      If PanelGallery.Visible = True Then ScrollViewGallery.EnsureVisible(oObj.Left, oObj.Top, oObj.W, oObj.H)
      If PanelMuster.Visible = True Then ScrollViewMuster.EnsureVisible(oObj.Left, oObj.Top, oObj.W, oObj.H)
      '''Wait and show for user:
      If F_iOnly1x > 0 Then
        ' LabelCounterGallery.Text &= Space(1) & ("Muster") & "=" & Str(iFound + 1) 
        If Object.IsValid(oObj) = True Then oObj.Background = Color.Blue
        Wait 0.5
        If Object.IsValid(oObj) = True Then oObj.Background = Color.Default
        Wait 0.5
        If Object.IsValid(oObj) = True Then oObj.Background = Color.Blue
        Wait 0.5
        If Object.IsValid(oObj) = True Then oObj.Background = iColor 'Reset
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxSelectLevelONoff_Enter()
  
  PicBoxSelectLevelONoff.Background = F_iSelectGreenAlpha150
  If Not PicBoxSelectLevelONoff.Tag Then 
    LabelMessageText(F_sLabelMessageTextEmptyHTML)
  Else 
    LabelMessageText(PicBoxSelectLevelONoff.Tag)  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxSelectLevelONoff_Leave()
  
  PicBoxSelectLevelONoff.Background = Color.Default
  
End

Public Sub PicBoxSelectLevelONoff_MouseDown()
  'Note: PicBoxSelectLevelONoff.Tag = F_oLastPicBoxObject.Tag
  
  If Mouse.Left Then 
    If PanelGallery.Visible = True Then 
      If Object.IsValid(F_oLastPicBoxObject) = False Then
        LabelMessageText(F_sLabelMessageTextEmptyHTML)
      Else 
        RefreshSelectColorGroupLevelsGallery(F_oLastPicBoxObject)
        SumPaintClockLevels()
      Endif 
    Endif 
    
    If PanelMuster.Visible = True Then MusterFindLevel()
  Endif 
  
  If Mouse.Middle Then 
    If PanelMuster.Visible = True Then MusterFindLevel()
  Endif
  
  If Mouse.Right Then 
    If Object.IsValid(F_oLastPicBoxObject) = False Then 
      LabelMessageText(F_sLabelMessageTextEmptyHTML)
    Else 
      PicBoxSelectLevelONoff.Background = Color.Blue
      F_oLastPicBoxObject = PicBoxSelectLevelONoff
      CheckMenu1()
      MenuEdit.Popup()
      PicBoxSelectLevelONoff.Background = Color.Default
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterFindLevel()
  
  Dim it, iNr As Integer
  Dim sFind As String
  
  ''level=number=left=selected=path= '0=1=2=3=4=
  
  If PanelGallery.Visible = True Then 
    If F_ooPicBoxesGallery Then 
      If Object.IsValid(F_oLastPicBoxObject) = True Then 'Clock-Part, only one level
        iNr = CInteger(F_oLastPicBoxObject.ToolTip)
      Endif
      
      If iNr > -1 Then 
        sFind = "level=" & Str(iNr) & "="
        For it = 0 To F_ooPicBoxesGallery.Max
          If String.InStr(F_ooPicBoxesGallery[it].Tag, sFind) > 0 Then 
            F_ooPicBoxesGallery[it].Background = F_iColorSelect
            Print F_ooPicBoxesGallery[it].Tag
          Else 
            F_ooPicBoxesGallery[it].Background = Color.Default 
          Endif 
        Next
        GalleryCounter()  'as String  "0/0"
      Endif
    Endif
  Else If PanelMuster.Visible = True Then
  
    If F_ooPicBoxesMuster Then 
      If Object.IsValid(F_oLastPicBoxObject) = True Then 'Clock-Part, only one level
        iNr = CInteger(F_oLastPicBoxObject.ToolTip)
      Endif
      
      If iNr > -1 Then 
        sFind = "level=" & Str(iNr) & "="
        For it = 0 To F_ooPicBoxesMuster.Max
          If String.InStr(F_ooPicBoxesMuster[it].Tag, sFind) > 0 Then 
            F_ooPicBoxesMuster[it].Background = F_iColorSelect
            Print F_ooPicBoxesMuster[it].Tag
          Else 
            F_ooPicBoxesMuster[it].Background = Color.Default 
          Endif 
        Next
        MusterCounter() 'as String  "0/0"
      Endif
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form3TextSelectTags()
  
  Dim sText, sTag, sInfo, sLevels As String 
  Dim picCurrent As Picture
  Dim it, iCount, iNr, iAllMuster As Integer
  
  ''Gallery:
  If Object.IsValid(F_oLastPicBoxObject) = True Then 
    sTag = F_oLastPicBoxObject.Tag
    picCurrent = F_oLastPicBoxObject.Picture
    If Not sTag Then sTag = ("Keine")
    If F_bEditChangeON = True Then sText &= ("#EditChange-Mode") & ": ■" & ("aktiviert, eingeschaltet") & gb.NewLine Else sText &= ("#EditChange-Mode") & ": □" & ("deaktiviert, ausgeschaltet") & gb.NewLine
    If F_bColorChangeON = True Then sText &= ("#ColorChange-Mode") & ": ■" & ("aktiviert, eingeschaltet") & gb.NewLine Else sText &= ("#ColorChange-Mode") & ": □" & ("deaktiviert, ausgeschaltet") & gb.NewLine
    sText &= gb.NewLine
    sText &= ("Einzelteil Baukasten") & ":" & gb.NewLine & 
    F_oLastPicBoxObject.ToolTip & gb.NewLine & sTag & gb.NewLine & gb.NewLine 'is Text, no Path
  Endif 
  If F_ooPicBoxesLevels Then 
    sTag = ReadLevelsTag(True) 'ReadGalleryTags(False) 'as String, (False)—▶Selection
    If Not sTag Then sTag = ("Keine")
    For it = 0 To F_ooPicBoxesLevels.Max
      If F_ooPicBoxesLevels[it].Visible = True Then  
        If F_ooPicBoxesLevels[it].Background = F_iColorSelect Then 
          sText &= Str(it + 1) & "=" & F_ooPicBoxesLevels[it].Tag & gb.NewLine
          sLevels &= "■"
          iCount = iCount + 1
        Else 
          sLevels &= "□"
        Endif
      Endif 
    Next
    sText &= gb.NewLine
    If Object.IsValid(F_oLastPicBoxMuster) = True Then iNr = CInteger(F_oLastPicBoxMuster.ToolTip) Else iNr = 0
    If F_ooPicBoxesMuster Then iAllMuster = F_ooPicBoxesMuster.Count Else iAllMuster = 0
    sText &= ("Auswahl Ebenen") & ": " & sLevels & " = " & iCount & Space(1) & ("Bauteile") & gb.NewLine
    sText &= ("Aktuelles Muster") & ": " & iNr & Space(1) & ("von") & Space(1) & iAllMuster & gb.NewLine & gb.NewLine 
    sText &= sTag & gb.NewLine & gb.NewLine
    
  Endif 
  
  ''Muster:
  If F_ooPicBoxesMuster Then 
    sTag = ReadMusterTags(False)
    If Not sTag Then sInfo = ("Keine") Else sInfo = LabelCounterMuster.Text
    sText &= ("Markierte Muster") & ": " & gb.NewLine & sInfo & gb.NewLine 
    sText &= sTag & gb.NewLine & gb.NewLine
  Endif 
  
  If sText Then  
    If String.InStr(sText, "level=") > 0 Then sText = CheckFileTitleClockMuster(sText) 
    If picCurrent Then Form3Text.PicBoxPictureToText.Picture = picCurrent 'Public True?
    Form3Text.Tag = sText
    Form3Text.Window.Show()
    ' Form3Text.Window.Visible = True 'Wayland error?
  Else 
    LabelMessageText("<font color=red><b>" & ("Ein Bild markieren (Mittel-Klick)") & "</b></font>")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PrintFileIcons()
  
  Dim sDirCache, sDirSub, sDir, sFile, sPath, sMessage As String 
  Dim it, iLine, iPics As Integer
  Dim Img As Image
  Dim ooPicBoxes As Object[]
  
  ' If F_iESCpressed > 0 Then Return 'end here
  
  sDirCache = M01Functions.CheckDirectoryCache()
  sDirSub = Settings[F_sForm &/ "F_sDirPrintCache", Null]
  
  ''Check:
  If IsDir(sDirSub) = False Then 
    M01Functions.CheckDirAppName()
    sDirSub = sDirCache &/ Application.Name & "-printcache"
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
  Endif 
  
  ''Delete files in Cache
  If IsDir(sDirSub) = True Then 
    For Each sFile In Dir(sDirSub, "*", gb.File)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      
      Try Kill sDirSub &/ sFile
    Next 
  Endif 
  
  ''Pictures:
  If PanelGallery.Visible = True Then 
    ooPicBoxes = F_ooPicBoxesGallery'.Copy()
  Else If PanelMuster.Visible = True Then 
    ooPicBoxes = F_ooPicBoxesMuster'.Copy()
  Endif 
  
  ''Save Pictures:
  If ooPicBoxes And IsDir(sDirSub) = True Then 
    iPics = ooPicBoxes.Count
    iPics = String.Len(Str(iPics)) 'as Integer
    For it = 0 To ooPicBoxes.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_iESCpressed > 0 Then 
        If MessageQuestionBreak() > 0 Then Break
      Endif
      
      If ooPicBoxes[it].Background = F_iColorSelect And ooPicBoxes[it].Picture Then 
        Img = ooPicBoxes[it].Picture.Image 
        sFile = Format(ooPicBoxes[it].ToolTip, "clock" & String(iPics, "0")) & ".png"
        If String.InStr(sFile, Space(1)) > 0 Then sFile = Replace(sFile, Space(1), "_")
        sPath = sDirSub &/ sFile 
        ' Print sPath
        Img.Save(sPath)
      Endif 
    Next 
    '******************************************
    ''HTML > Browser
    M01Functions.PrintFile(sDirSub, Me.Window.Title, Settings[FMain.Name &/ "F_iIconSize", 64])
    '******************************************
  Else 
    If Not ooPicBoxes Then sMessage = "<h3><font color=red>" & ("Bilder fehlen") & "</font></h3>"
    If IsDir(sDirSub) = False Then sMessage &= "<h3><font color=red>" & ("Ordner fehlt") & "</font></h3>"
    sMessage &= sDirSub
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory
        If IsDir(sDirSub) = True Then sDir = sDirSub Else sDir = File.Dir(sDirSub)
        M01Functions.FileManagerOpen(sDir)
      Case 2
        '... 
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub SettingsColorsUserReadSave(Optional sReadSave As String = "read")
  
  Dim it As Integer
  
  If F_ooPicBoxesColorsB Then '□ □ □
    Select Case String.LCase(String.Left(sReadSave, 1))
        
      Case "r" ''Read ■ ■ ■ ——▶ □ □ □
        If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
        If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
        
        ''Refresh:
        F_sColorChangeLineUser = "colorchange="
        For it = 0 To F_ooPicBoxesColorsB.Max
          F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
          F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
        Next  
        Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
        
      Case "s" ''Save □ □ □ ◀—— ■ ■ ■
        If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = New Integer[]
        If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
        
        F_sColorChangeLineUser = "colorchange="
        For it = 0 To F_ooPicBoxesColorsB.Max
          F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
          F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
        Next 
        Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
        
    End Select 
    M05.ColorClockGetSettings() 'read
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorsUserToBoxes(Optional iiColors As Integer[] = Null)
  
  Dim it As Integer
  
  If F_ooPicBoxesColorsB Then '□ □ □
    ' If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = New Integer[]
    If Not iiColors Then iiColors = F_iiIconClockColorsB
    If Not iiColors Then iiColors = F_iiIconClockColorsA
    
    If iiColors Then 
      If iiColors.Max <> F_ooPicBoxesColorsB.Max Then iiColors.Resize(F_ooPicBoxesColorsB.Count)
      For it = 0 To iiColors.Max 
        ' If it < F_iiIconClockColorsB.Count Then 
        If it < F_iiIconClockColorsB.Count Then F_iiIconClockColorsB[it] = iiColors[it] ''◀——  iiColors
        F_ooPicBoxesColorsB[it].Background = iiColors[it] ''◀——  F_iiIconClockColorsB
        ' Endif 
      Next 
    Endif 
    ' If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
    
    ' For it = 0 To F_ooPicBoxesColorsB.Max ''◀——  F_iiIconClockColorsB
    '   F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
    ' Next 
  Endif 
  Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
  ' F_ooColorChangeLevels = F_iiIconClockColorsB
  ' CheckButtonEdit()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Click() '—▶ Menu _Click!
  
  If Object.Type(Last) = "Menu" Then ListMenuGroupFunctions(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_MouseDown() 
  
  If Object.Type(Last) = "TextLabel" Then ListMenuGroupFunctions(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Enter() 
  
  If Object.Type(Last) = "Label" Then Last.Background = F_iColorSelect
  If Object.Type(Last) = "TextLabel" Or Object.Type(Last) = "Label" Then LabelMessageText(Last.ToolTip)
      
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Leave() 
  
  If Object.Type(Last) = "Label" Then Last.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuUndoRedo_Show()
  
  MenuUndo1.Enabled = True 
  MenuRedo1.Enabled = True 
  MenuUndoMin1.Enabled = True 
  MenuRedoMax1.Enabled = True 
  
  If PanelMuster.Visible = True Then  'Muster
    MenuUndo2.Enabled = True  
    MenuRedo2.Enabled = True 
    MenuUndoMin2.Enabled = True 
    MenuRedoMax2.Enabled = True  
  Else 
    MenuUndo2.Enabled = False  
    MenuRedo2.Enabled = False 
    MenuUndoMin2.Enabled = False 
    MenuRedoMax2.Enabled = False  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroupFunctions(Optional sLastTag As String = "") 
  
  F_iESCpressed = 0 
  
  Select Case String.LCase(sLastTag)
      
    Case "counterlabel1"
      MenuUndoRedo.Popup()
      
    Case "undo1"
      ButtonGroupSelect("undo1")
      
    Case "redo1"
      ButtonGroupSelect("redo1")
      
    Case "undomin1"
      F_iUndoRedoLevelPointer = 0 
      ButtonGroupSelect("undo1")
      
    Case "redomax1"
      F_iUndoRedoLevelPointer = F_ssUndoRedoLevels.Max
      ButtonGroupSelect("redo1")
      
      ' Gallery ▲
      '---------------------------------------------------
      ' Muster  ▼
      
    Case "counterlabel2"
      MenuUndoRedo.Popup()
      
    Case "undo2"
      ButtonGroupSelect("undo2")
      
    Case "redo2"
      ButtonGroupSelect("redo2")  
      
    Case "undomin2"
      F_iUndoRedoMusterPointer = 0
      ButtonGroupSelect("undo2")
      
    Case "redomax2"
      F_iUndoRedoMusterPointer = F_ssUndoRedoMuster.Max
      ButtonGroupSelect("redo2")
      
  End Select
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub PicBoxColorSelectedBorder_Enter()
  
  LabelMessageText(PicBoxColorSelectedBorder.Tooltip, Color.Red)
  
Catch
  FMain.ErrorText
  
End

' Public Sub ButtonColorPotNumber_Enter()
'   
'   LabelMessageText(ButtonColorPotNumber.Tooltip, Color.Red)
'   
' Catch
'   FMain.ErrorText
'   
' End
' 
' Public Sub ButtonColorPotNumber_MouseDown()
'   
'   Dim it As Integer
'   Dim hCursor As Cursor
'   Dim hPic As Picture
'   
'   If ButtonColorPotNumber.Mouse <> Mouse.Custom Then 
'     hPic = PicTemplateColorPotCross.Picture.Image.Stretch(64, 64).Picture
'     hCursor = New Cursor(hPic, hPic.W, hPic.H) 'Hotspot right-bottom (rechts-unten)
'     For it = 0 To F_ooPicBoxesColorsB.Max
'       F_ooPicBoxesColorsB[it].Cursor = hCursor
'       F_ooPicBoxesColorsB[it].Mouse = Mouse.Custom
'     Next 
'     ButtonColorPotNumber.Cursor = hCursor
'     ButtonColorPotNumber.Mouse = Mouse.Custom
'     ' PanelColorChooser.Visible = True 
'     ColorChooser1.SelectedColor = PicBoxColorSelectedBorder.Background
'   Else 
'     For it = 0 To F_ooPicBoxesColorsB.Max
'       F_ooPicBoxesColorsB[it].Mouse = Mouse.Pointing
'     Next 
'     ButtonColorPotNumber.Mouse = Mouse.Pointing
'   Endif 
'   
' Catch
'   FMain.ErrorText
'   
' End

Public Sub LabelColorSelected_MouseDown()
  
  PanelColorChooser.Visible = Not PanelColorChooser.Visible
  If PanelColorChooser.Visible Then ColorChooser2.SelectedColor = Color.SetAlpha(LabelColorSelected.Background, 0)
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxColorSelectedBorder_MouseDown()
  
  PanelColorChooser.Visible = Not PanelColorChooser.Visible
  If PanelColorChooser.Visible Then ColorChooser1.SelectedColor = PicBoxColorSelectedBorder.Background
  
Catch
  FMain.ErrorText
  
End

Public Function InfoColorPaletteMessage() As String 
  
  Dim iiIconClockColorsA, iiIconClockColorsB As Integer[]
  Dim it, iDiff As Integer
  Dim sMessage, sColors, sSquare As String
  
   ' "standard", "standardcolors", "reset" '.....................................................
  iiIconClockColorsA = Settings[FMain.Name &/ "F_iiIconClockColorsA", F_iiIconClockColorsA]
  iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
    
  If iiIconClockColorsA And iiIconClockColorsB Then 
    If iiIconClockColorsA.Max <> F_ooPicBoxesColorsB.Max Then iiIconClockColorsA.Resize(F_ooPicBoxesColorsB.Count)
    
    sMessage = "<h3><font color=gray>" & "■ " & ("Standard Farben") & "</font></h3>"
    sColors = ""
    '■□□□□□□□□□□ Standard
    For it = 0 To iiIconClockColorsA.Max
      If iiIconClockColorsA[it] = Color.Background Then 
        sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
      Else 
        sColors &= "<font color=#" & Hex(iiIconClockColorsA[it], 6) & ">" & "■" & "</font>"  
      Endif 
    Next   
    sMessage &= "<font size=5>" & sColors & "</font>"

    sColors = ""
    '●□□□□□□□□□□ Current
    For it = 0 To F_ooPicBoxesColorsB.Max
      If iiIconClockColorsA[it] = F_ooPicBoxesColorsB[it].Background Then 
        sSquare = "■"
        If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
      Else 
        iDiff = iDiff + 1
        sSquare = "●" 'Changed
        If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
      Endif 
      sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & sSquare & "</font>"
    Next  
    sMessage &= "<br>"
    sMessage &= "<font size=5>" & sColors & "</font>"
    sMessage &= "<h3>" & "● " & ("Aktuelle Farben") & "</h3>"
    sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & F_ooPicBoxesColorsB.Count & Space(1) & ("Farben") & Space(1) & "</font></h3>"
   
  Endif 
   
  Return sMessage
    
Catch
  FMain.ErrorText
  
End

Public Function InfoButtonPictureMessage(Optional picButton As Picture, Optional sFileBaseName As String = "1.png") As String 
  
  Dim sPathCache1, sMessage As String 
  
  If sFileBaseName <> "1.png" Then sFileBaseName = File.SetExt(sFileBaseName, "png")
  sPathCache1 = M01Functions.TempDirFile(sFileBaseName) ' Temp() & ".png"
  
  If Exist(sPathCache1) = True And picButton Then
    picButton.Save(sPathCache1)
  Endif 

  sMessage &= "<img src=" & Quote("file://" & sPathCache1) & " width=50 height=50 >" 

  Return sMessage
  
Catch 
  FMain.ErrorText
  
End

Public Function InfoPropertiesMessage() As String 
  
  Dim sPathCache1, sPathCache2, sPathCache3, sMessage, sText1, sText2, sText3 As String 
  
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
  sPathCache2 = M01Functions.TempDirFile("2.png") ' Temp() & ".png"
  sPathCache3 = M01Functions.TempDirFile("3.png") ' Temp() & ".png"
  
  If Exist(sPathCache1) = True Then
    PicBoxLevelsEditNull2.Picture.Save(sPathCache1)
    PicBoxLevelsEditNullColor2.Picture.Save(sPathCache2)
    PicBoxWhiteBorder.Picture.Save(sPathCache3)
  Endif 
  
  If F_bEditChangeON = True Then 
    sText1 &= "<br>" & ("edit=") & Space(1) & ("eingeschaltet") & "<br>"
  Else 
    sText1 &= "<br>" & ("edit=") & Space(1) & "<font color=DarkGray>" & ("ausgeschaltet") & "</font>" & "<br>"
  Endif 
  
  If F_bColorChangeON = True Then 
    sText2 &= "<br>" & ("colorchange=") & Space(1) & ("eingeschaltet") & "<br>"
  Else 
    sText2 &= "<br>" & ("colorchange=") & Space(1) & "<font color=DarkGray>" & ("ausgeschaltet") & "</font>" & "<br>"
  Endif 
  
  If F_bWhiteBorderON = True Then 
    sText3 &= "<br>" & ("Teile weiß umrandet") & ":" & Space(1) & ("eingeschaltet") & "<br>"
  Else 
    sText3 &= "<br>" & ("Teile weiß umrandet") & ":" & Space(1) & "<font color=DarkGray>" & ("ausgeschaltet") & "</font>" & "<br>"
  Endif 
  
  ' sMessage &= "<br>"
  sMessage &= "<h2>" & "<img src=" & Quote("file://" & sPathCache1) & " width=50 height=50 >" & Space(1) & sText1 & "</h2>"
  sMessage &= "<h2>" & "<img src=" & Quote("file://" & sPathCache2) & " width=50 height=50 >" & 
  Space(1) & sText2 & "</h2>"
  sMessage &= "<h2>" & "<img src=" & Quote("file://" & sPathCache3) & " width=50 height=50 >" & 
  Space(1) & sText3 & "</h2>"
  
  Return sMessage
  
Catch 
  FMain.ErrorText
  
End

Public Sub WhiteBorderMessageONoff()

  Dim sLevelsBefore As String
  
  sLevelsBefore = ReadLevelsTag()
  
  If PanelGallery.Visible = True Then 
    DefaultNewLevelsGallery()
    LoadLevelsNewNull()
    LoadLevels(sLevelsBefore)
    ResizePanelLevels()
    SumPaintClockLevels()         
  Endif 
  
  If PanelMuster.Visible = True Then MusterColorRefreshSelection()     
    
Catch 
  FMain.ErrorText
End

Public Sub MusterReloadAll()
  
  Dim sText, sText1, sMusterAll, sMessage As String 
  
  sText = InfoColorPaletteMessage() ' as String 
  sText1 = InfoPropertiesMessage() 'as String
  
  sMessage = "<h2>" & ("Alle Muster erneuern mit Einstellungen (Refresh)") & "</h2>"
  sMessage &= sText & "<br>" & sText1
  
  Select Case Message.Question(sMessage, ("Alle Muster neu berechnen"), ("Nein"), ("Abbrechen"))
    Case 1
      sMusterAll = ReadMusterTags() 'All
      MusterNullNew()
      LoadMuster(sMusterAll)
      ResizePanelMuster()
      F_bMusterSideChanged = True
    Case 2, 3
      'Cancel
  End Select

Catch 
  FMain.ErrorText
  
End

Public Sub CheckMusterSideFill()
  
  Dim sPath, sText As String 
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If Not F_ooPicBoxesMuster Then
    LabelMessageText("<font color=red><b>" & ("Lade Muster-Liste") & "..." & "</b></font>")
    Me.Window.Title = Application.Name & " - " & ("Lade Muster-Liste") & "..."
    If Not F_dateNow Then F_dateNow = Now  
    
    sPath = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt] 'Standard-File
    
    ''From File:
    ''****************************************************
    If Exist(sPath) = True Then sText = File.Load(sPath)
    ''****************************************************
    
    ''Load:
    LoadMuster(sText)
    ' Print "PanelMuster.Visible " & PanelMuster.Visible 
    If TextBoxPath.Text <> sPath Then 
      TextBoxPath.Selectall()
      TextBoxPath.Insert(sPath)
      LabelInfoPathG(sPath)
    Endif 
    
    If Not F_ooPicBoxesMuster Then 
      LabelMessageText("<font color=red><b>" & ("Die Muster-Liste ist (noch) leer.") & "</b></font>")
      PicBoxPenguin.Visible = True 
      PanelGallery.Visible = False
      PanelMuster.Visible = True 
      PicBoxMusterChange.Background = Color.Default
      PicBoxMusterSide.Background = F_iColorSelect
    Else 
      If F_iESCpressed = 0 Then 
        LabelMessageText("<font color=darkgreen><b>" & ("Die Muster-Liste wurde berechnet und ist fertig") & "</b></font>")
      Endif 
    Endif
    F_bMusterSideChanged = False 'Reset 
    If String.InStr(Me.Window.Title, "...") > 0 Then MusterCounter() 'as String  "0/0"
  Endif  
  If Not PanelMuster.Visible = True Then
    Wait 1 
    SideG("muster") 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuOpenRecentG(Optional sPath As String = "")
  
  Dim it, iFound As Integer
  Dim hMenu As Menu
  Dim sDirFile, sInfo As String 
  
  If F_iESCpressed > 0 Then Return 'end here
  If Not F_ssMenuOpenRecent Then F_ssMenuOpenRecent = New String[]
  
  If Exist(sPath) = True Then 
    iFound = F_ssMenuOpenRecent.Find(sPath) 
    If iFound > -1 Then F_ssMenuOpenRecent.Remove(iFound, 1)
    F_ssMenuOpenRecent.Add(sPath, 0) 'add top▲
    Settings[F_sForm &/ "F_ssMenuOpenRecent"] = F_ssMenuOpenRecent
  Endif 
  
  MenuOpenRecent.Children.Clear()
  
  ''Recent:
  If F_ssMenuOpenRecent Then 
    For it = 0 To F_ssMenuOpenRecent.Max
      sDirFile = F_ssMenuOpenRecent[it]
      If Exist(sDirFile) = True Then 
        sInfo = ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size)  
      Else 
        sInfo = ""
      Endif 
      hMenu = New Menu(MenuOpenRecent) As "GroupOpenRecent"
      hMenu.Name = MenuOpenRecent.Name & it 
      hMenu.Enabled = True 
      hMenu.Text = F_ssMenuOpenRecent[it] & " = " & sInfo
      hMenu.Tag = F_ssMenuOpenRecent[it] ' /Dir/File.txt
      hMenu.Visible = True 
      hMenu.Picture = PicTemplateOpenRecent.Picture
      hMenu.Enabled = Exist(sDirFile)  'True or False
      If it > 20 Then Break
    Next 
  Endif 
  
  ''Empty
  If Not F_ssMenuOpenRecent Then
    hMenu = New Menu(MenuOpenRecent) As "GroupOpenRecent"
    hMenu.Name = MenuOpenRecent.Name & (it)
    hMenu.Enabled = False  
    hMenu.Text = F_sEmptyText
    hMenu.Tag = ""
    hMenu.Visible = True 
  Endif 
  
  ''Line --------------------------
  hMenu = New Menu(MenuOpenRecent) As "GroupOpenRecent"
  hMenu.Name = MenuOpenRecent.Name & (it + 1)
  hMenu.Enabled = True 
  hMenu.Text = ""
  hMenu.Tag = ""
  hMenu.Visible = True 
  
  ''Remove list (Liste leeren)
  hMenu = New Menu(MenuOpenRecent) As "GroupOpenRecent"
  hMenu.Name = MenuOpenRecent.Name & (it + 2)
  If F_ssMenuOpenRecent Then 
    hMenu.Enabled = True 
  Else 
    hMenu.Enabled = False 
  Endif   
  hMenu.Text = ("Öffnen-Liste leeren")
  hMenu.Tag = "removeopenrecent"
  hMenu.Visible = True 
  hMenu.Picture = PicTemplateCut.Picture 
  
  ''[ Cancel ]
  hMenu = New Menu(MenuOpenRecent) As "GroupOpenRecent"
  hMenu.Name = MenuOpenRecent.Name & (it + 3)
  hMenu.Enabled = True 
  hMenu.Text = MenuCancel1.Text
  hMenu.Tag = "cancel"
  hMenu.Visible = True 
  hMenu.Picture = MenuCancel1.Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupOpenRecent_Click()
  
  Dim sMessage, sDirFile As String 
  Dim it, iAll As Integer
  
  If Last.Tag = "removeopenrecent" Then 
    If F_ssMenuOpenRecent Then 
      For it = 0 To F_ssMenuOpenRecent.Max
        sMessage &= Str(it + 1) & ") " & F_ssMenuOpenRecent[it] & "<br>"
        If it > 5 Then 
          sMessage &= "..." & "<br>" 
          Break
        Endif 
      Next
      iAll = F_ssMenuOpenRecent.Count
    Endif
    sMessage &= "<h3><font color=red>" & ("Liste leeren") & "?" & "</font></h3>"
    sMessage &= "<h4><font color=gray>" & ("Hinweis: Die Original-Dateien bleiben unberührt erhalten.") & "</font></h4>"
    
    Select Case Message.Question(sMessage, ("Liste leeren"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Remove list
        F_ssMenuOpenRecent = Null
        Settings[F_sForm &/ "F_ssMenuOpenRecent"] = F_ssMenuOpenRecent
      Case 2 'Directory
        M01Functions.FileManagerOpen(Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock])
      Case 3 'Cancel
        ''...
    End Select 
    
  Else If Last.Tag = "cancel" Then 
    ''...
  Else  ''Open
    sDirFile = Last.Tag
    F_sRecentOpenMusterLastPath = sDirFile
    If M01Functions.isPicForPictureBox(sDirFile) = True Then 
      OpenDialogPicture(sDirFile)
    Else If M01Functions.isTerminweckerClockMusterFile(sDirFile) = True Then 
      LoadMusterFileText(sDirFile)
    Endif 
  Endif
  ' Last.Close
  ProgressBar1.Visible = False 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuSaveRecentG(Optional sPath As String = "")
  
  Dim it, iFound As Integer
  Dim hMenu As Menu
  Dim sDirFile, sInfo As String 
  
  If F_iESCpressed > 0 Then Return 'end here
  
  If Exist(sPath) = True Then 
    If Not F_ssMenuSaveRecent Then F_ssMenuSaveRecent = New String[]
    iFound = F_ssMenuSaveRecent.Find(sPath) 
    If iFound > -1 Then F_ssMenuSaveRecent.Remove(iFound, 1)
    F_ssMenuSaveRecent.Add(sPath, 0) 'add top▲
    Settings[F_sForm &/ "F_ssMenuSaveRecent"] = F_ssMenuSaveRecent
  Endif 
  
  MenuSaveRecent.Children.Clear()
  
  ''Recent:
  If F_ssMenuSaveRecent Then 
    For it = 0 To F_ssMenuSaveRecent.Max
      sDirFile = F_ssMenuSaveRecent[it]
      If Exist(sDirFile) = True Then 
        sInfo = ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size)  
      Else 
        sInfo = ""
      Endif 
      hMenu = New Menu(MenuSaveRecent) As "GroupSaveRecent"
      hMenu.Name = MenuSaveRecent.Name & it 
      hMenu.Enabled = True 
      hMenu.Text = F_ssMenuSaveRecent[it] & " = " & sInfo
      hMenu.Tag = F_ssMenuSaveRecent[it] ' /Dir/File.txt
      hMenu.Visible = True 
      hMenu.Picture = PicTemplateOpenRecent.Picture
      hMenu.Enabled = Exist(sDirFile)  'True or False
      If it > 20 Then Break
    Next 
  Endif 
  
  ''Empty
  If Not F_ssMenuSaveRecent Then
    hMenu = New Menu(MenuSaveRecent) As "GroupSaveRecent"
    hMenu.Name = MenuSaveRecent.Name & (it)
    hMenu.Enabled = False  
    hMenu.Text = F_sEmptyText
    hMenu.Tag = ""
    hMenu.Visible = True 
  Endif 
  
  ''Line --------------------------
  hMenu = New Menu(MenuSaveRecent) As "GroupSaveRecent"
  hMenu.Name = MenuSaveRecent.Name & (it + 1)
  hMenu.Enabled = True 
  hMenu.Text = ""
  hMenu.Tag = ""
  hMenu.Visible = True 
  
  ''Remove list (Liste leeren)
  hMenu = New Menu(MenuSaveRecent) As "GroupSaveRecent"
  hMenu.Name = MenuSaveRecent.Name & (it + 2)
  If F_ssMenuSaveRecent Then 
    hMenu.Enabled = True 
  Else 
    hMenu.Enabled = False 
  Endif   
  hMenu.Text = ("Öffnen-Liste leeren")
  hMenu.Tag = "removesaverecent"
  hMenu.Visible = True 
  hMenu.Picture = PicTemplateCut.Picture 
  
  ''[ Cancel ]
  hMenu = New Menu(MenuSaveRecent) As "GroupSaveRecent"
  hMenu.Name = MenuSaveRecent.Name & (it + 3)
  hMenu.Enabled = True 
  hMenu.Text = MenuCancel1.Text
  hMenu.Tag = "cancel"
  hMenu.Visible = True 
  hMenu.Picture = MenuCancel1.Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupSaveRecent_Click()
  
  Dim sMessage, sDirFile As String 
  Dim it, iAll As Integer
  
  If Last.Tag = "removesaverecent" Then 
    If F_ssMenuSaveRecent Then 
      For it = 0 To F_ssMenuSaveRecent.Max
        sMessage &= Str(it + 1) & "=" & F_ssMenuSaveRecent[it] & "<br>"
        If it > 5 Then 
          sMessage &= "..." & "<br>" 
          Break
        Endif 
      Next
      iAll = F_ssMenuSaveRecent.Count
    Endif
    sMessage &= "<h3><font color=red>" & ("Liste leeren") & "?" & "</font></h3>"
    sMessage &= "<h4><font color=gray>" & ("Hinweis: Die Original-Dateien bleiben unberührt erhalten.") & "</font></h4>"
    
    Select Case Message.Question(sMessage, ("Liste leeren"), ("Ordner..."), ("Abbrechen"))
      Case 1 'Remove list
        F_ssMenuSaveRecent = Null
        Settings[F_sForm &/ "F_ssMenuSaveRecent"] = F_ssMenuSaveRecent
      Case 2 'Directory
        M01Functions.FileManagerOpen(Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock])
      Case 3 'Cancel
        ''...
    End Select 
    
  Else If Last.Tag = "cancel" Then 
    ''...
  Else  ''Open
    sDirFile = Last.Tag
    F_sRecentOpenMusterLastPath = sDirFile
    If M01Functions.isPicForPictureBox(sDirFile) = True Then
      OpenDialogPicture(sDirFile)
    Else If String.InStr(File.Name(sDirFile), ".color.txt") > 0 Then 
      ColorOpenSaveStandardG("open")
    Else If M01Functions.isTerminweckerClockMusterFile(sDirFile) = True Then '".muster.txt"
      LoadMusterFileText(sDirFile)
    Endif 
  Endif
  ' Last.Close
  ProgressBar1.Visible = False 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckLabelFontSize() As Float
  
  Dim U, fSize As Float
  
  U = F_iIconSize / 10
  fSize = U * 5   
  
  If F_fFontSizePlus = 0 Then F_fFontSizePlus = Settings[F_sForm &/ "F_fFontSizePlus", F_fFontSizePlus]
  
  If F_fFontSizePlus > fSize Then 
    LabelFontSize.Foreground = Color.Red
  Else If F_fFontSizePlus < -fSize Then 
    LabelFontSize.Foreground = Color.Red
  Else  '= 0
    LabelFontSize.Foreground = Color.Default 
  Endif 
  ' FMain.F_fFontSizePlus = F_fFontSizePlus
  LabelFontSize.Text = Round(F_fFontSizePlus, -1)
  
  Return F_fFontSizePlus
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Dim sToolTip, sSelect1, sSelect2 As String 
  
  If F_bChangeON = True Then 
    If Object.Type(Last) = "Button" Then 
      ' Last.Border = True 
      If Last.Tag = ButtonSave.Tag Then ScrollViewLevels.Background = F_iColorSelect
      If Last.Tag = ButtonMusterSave.Tag Then ScrollViewMuster.Background = F_iColorSelect
      If Last.Tag = ButtonMenuEditCancel.Tag Then PanelMenuEdit.Background = F_iColorSelect
      If PanelMenuColor.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
      If Last.Tag = ArrowR.Tag Then 
        ArrowR.Background = F_iColorGreenAlpha150
        ArrowR.Border = True
      Endif 
    Endif 
    
    If Object.Type(Last) = "PictureBox" Then 
      If PanelMuster.Visible = True Then PicBoxMusterSide.Background = F_iColorSelect Else PicBoxMusterSide.Background = Color.Default
      If PanelColorPicker.Visible = True Or PanelColorSave1.Visible = True Then PicBoxColors.Background = F_iColorSelect Else PicBoxColors.Background = Color.Default
    Endif
  
      If Last.Background <> F_iColorSelect Then Last.Background = F_iSelectGreenAlpha150
      If Last.Tag = PicBoxGalleryReset.Tag Then
        If PanelGallery.Visible = True Then 
          sSelect1 = "● "
          sSelect2 = "○ "
          PanelGallery.Background = F_iSelectGreenAlpha150
        Else 
          sSelect1 = "○ "
          sSelect2 = "● "
          PanelMuster.Background = F_iSelectGreenAlpha150
        Endif
        PicBoxGalleryReset.Tooltip = sSelect1 & ("Neu berechnen (Galerie Uhren-Teile)") & gb.NewLine & sSelect2 & ("Neu berechnen (Muster)")
      Endif
      
      If Me.F_bWhiteBorderON = True Then 
        PicBoxWhiteBorder.Picture = PicTemplateWhiteBorderON.Picture 
        PicBoxWhiteBorder.Background = Color.Default 
      Else 
        PicBoxWhiteBorder.Picture = PicTemplateWhiteBorderOff.Picture
        PicBoxWhiteBorder.Background = F_iColorSelect 
      Endif 

    
    ''Show focus:
    Select Case String.LCase(Last.Tag)
      Case "fileinfo"
        LabelInfoPathG(TextBoxPath.Text)
        LabelInfo.Visible = True 
      Case "info"
        LabelInfo.Visible = False
      Case LabelFontSize.Tag 
        LabelFontSize.Background = F_iSelectGreenAlpha150
        PicFontMinus.Background = F_iSelectGreenAlpha150
        PicFontPlus.Background = F_iSelectGreenAlpha150
      Case LabelTimePause.Tag
        Last.Background = F_iSelectGreenAlpha150
      Case LabelInfo.Tag
        LabelInfo.Visible = False
      Case ButtonSchongang.Tag
        PicBoxPenguin.Background = F_iSelectGreenAlpha150
        ButtonSchongang.Border = True 
      Case ButtonFileInfo.Tag
        PanelPath.Background = F_iSelectGreenAlpha150
      Case PicBoxUndo.Tag, PicBoxRedo.Tag
        ScrollViewLevels.Background = Color.Yellow
        LabelUndoRedoCounter.Background = Color.Yellow
      Case ButtonSave.Tag
        PanelPath.Background = F_iSelectGreenAlpha150
      Case ButtonBrowser.Tag 
        PicBoxClock.Background = F_iSelectGreenAlpha150
      Case PicBoxReorder.Tag
        ScrollViewLevels.Background = F_iSelectGreenAlpha150
      Case LabelMessage.Tag 
        If ScrollViewLevels.ScrollW > ScrollViewLevels.W Then LabelMessage.Visible = False
      Case LabelUndoRedoCounter.Tag
        Last.Background = F_iSelectGreenAlpha150 '◀—undo/redo—▷
      Case PicBoxUndoMuster.Tag, PicBoxRedoMuster.Tag, ButtonMusterReload.Tag, ButtonMusterCancel.Tag
        PanelMuster.Background = F_iSelectGreenAlpha150
      Case PicBoxLevelsAll.Tag, PicBoxRefreshSum.Tag
        ScrollViewLevels.Background = F_iSelectGreenAlpha150
        ' Case ButtonColorsUserClear.Tag
        '   Last.Border = True
        '   Last.Background = F_iSelectGreenAlpha150
      ' Case ButtonColorApply.Tag
      '   ScrollViewLevels.Background = F_iSelectGreenAlpha150
      '   ScrollViewGallery.Background = F_iSelectGreenAlpha150
      Case PicBoxMusterChange.Tag 
        If PanelMuster.Visible = True Then PanelMuster.Background = F_iSelectGreenAlpha150
        ' Case PicBoxSelectedQuestion.Tag 
        '   If PicBoxSelectLevelONoff.Tag Like "*level=*" Then PicBoxSelectedQuestion.Tooltip = ("Zeige Muster Nr.") & Space(1) & PicBoxSelectLevelONoff.Tooltip Else PicBoxSelectedQuestion.Tooltip = ("Zeige Bauteil Nr.") & Space(1) & PicBoxSelectLevelONoff.Tooltip
      ' Case TextLabelColorInfo.Tag 
        ' TextLabelColorInfo.Visible = False 
      Case PicBoxLevelsEditNull.Tag, PicBoxLevelsEditNull2.Tag 
        If F_bEditChangeON = True Then PicBoxLevelsEditNull.Background = F_iColorSelect Else PicBoxLevelsEditNull.Background = F_iSelectGreenAlpha150
        PicBoxLevelsEditNull2.Background = F_iSelectGreenAlpha150
        If PanelMuster.Visible = True Then PanelMuster.Background = F_iSelectGreenAlpha150
        ScrollViewLevels.Background = Color.SetAlpha(Color.Gray, 200)
        
      Case PicBoxLevelsEditNullColor.Tag, PicBoxLevelsEditNullColor2.Tag
        If F_bColorChangeON = True Then PicBoxLevelsEditNullColor.Background = F_iColorSelect Else PicBoxLevelsEditNullColor.Background = F_iSelectGreenAlpha150
        PicBoxLevelsEditNullColor2.Background = F_iSelectGreenAlpha150
        If PanelMuster.Visible = True Then PanelMuster.Background = F_iSelectGreenAlpha150
        
      Case "colorcancel", ButtonColorCancel.Tag
        Last.Background = F_iSelectGreenAlpha150
        Last.Border = True 
    End Select
    
    ''Functions: □ ■ ○ ● ◁ ▶
    Select Case Last.Name 
      Case PicBoxMirrorLeftRight.Name, PicBoxMirrorTopBottom.Name, PicBoxRotateLeft.Name, PicBoxRotateRight.Name, PicBoxLevelsQuestionShowGalleryPart.Name, PicBoxGrayscale.Name, PicBoxScaleMinus.Name, PicBoxScalePlus.Name, PicBoxMoveLeft.Name, PicBoxMoveRight.Name, PicBoxMoveUp.Name, PicBoxMoveDown.Name
        If Last.Name = PicBoxLevelsQuestionShowGalleryPart.Name Then 
          If PicBoxSelectLevelONoff.Tag Like "*level=*" Then 
            If IsInteger(PicBoxSelectLevelONoff.ToolTip) = True Then 
              sToolTip = ("Zeige Muster") & ": " & PicBoxSelectLevelONoff.ToolTip
            Else 
              sToolTip = ("Zeige Muster") & ": " & ("Auswahl fehlt")
            Endif 
          Else 
            If IsInteger(PicBoxSelectLevelONoff.ToolTip) = True Then 
              sToolTip = ("Zeige Bauteil") & ": " & PicBoxSelectLevelONoff.ToolTip
            Else 
              sToolTip = ("Zeige Bauteil") & ": " & ("Auswahl fehlt")
            Endif 
          Endif 
          LabelMessageText(sToolTip)
        Else 
          If Object.IsValid(F_oLastPicBoxObject) = True Then 
            If isMoveableParts(F_oLastPicBoxObject) = True Then 
              LabelMessageText(sToolTip & "<b>" & ("Nr") & "." & F_oLastPicBoxObject.ToolTip & "</b>" & Space(1) & "<font color=blue>" & ("Bewegliches Teil") & "</font>")
            Else 
              LabelMessageCheck(F_oLastPicBoxObject)
              ' LabelMessageText(sToolTip & "<b>" & ("Nr") & "." & F_oLastPicBoxObject.ToolTip & "</b>" & Space(1) & F_oLastPicBoxObject.Tag)
            Endif 
          Else 
            LabelMessageText(F_sLabelMessageTextEmptyHTML)
          Endif
        Endif 
      Case Else 
        LabelMessageText(Last.ToolTip)
    End Select 
    
    If Object.Type(Last) = "Button" Then 
      Last.Border = True 
      Last.Background = F_iSelectGreenAlpha150
    Endif 
    If Object.Type(Last) = "TextLabel" Or Object.Type(Last) = "Label" Then LabelMessageText(Last.ToolTip)
  Endif 
  
  LabelZoom2.Background = Color.Default 'Reset
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If F_bChangeON = True Then
    If Object.Type(Last) = "Button" Then 
      If InStr(Last.Tag, "cancel") = 0 Then Last.Border = True
      If Last.Tag = ButtonSave.Tag Then ScrollViewLevels.Background = Color.Default
      If Last.Tag = ButtonMenuEditCancel.Tag Then ButtonMenuEditCancel.Background = Color.Default
      If PanelGallery.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
      ArrowR.Background = Color.Default
      ArrowR.Border = False 
    Endif 
    PanelMenuEdit.Background = Color.Default
    ScrollViewMuster.Background = Color.Default
    PanelGallery.Background = Color.Default
    PanelMuster.Background = Color.Default
    
    If Object.Type(Last) = "PictureBox" Then 
      If PanelMuster.Visible = True Then PicBoxMusterSide.Background = F_iColorSelect Else PicBoxMusterSide.Background = Color.Default
      If PanelColorPicker.Visible = True Or PanelColorSave1.Visible = True Then PicBoxColors.Background = F_iColorSelect Else PicBoxColors.Background = Color.Default
      If Last.Background <> F_iColorSelect Then Last.Background = Color.Default
      
      If Me.F_bWhiteBorderON = True Then 
        PicBoxWhiteBorder.Picture = PicTemplateWhiteBorderON.Picture 
        PicBoxWhiteBorder.Background = Color.Default
      Else 
        PicBoxWhiteBorder.Picture = PicTemplateWhiteBorderOff.Picture
        PicBoxWhiteBorder.Background = F_iColorSelect
      Endif 
    Endif 
    
    ''Clear focus:
    Select Case String.LCase(Last.Tag)
      Case "fileinfo"
        LabelInfo.Visible = False 
      Case "info"
        LabelInfo.Visible = False
      Case LabelFontSize.Tag 
        LabelFontSize.Background = Color.Default
        PicFontMinus.Background = Color.Default
        PicFontPlus.Background = Color.Default
      Case LabelTimePause.Tag
        Last.Background = Color.Default
      Case ButtonSchongang.Tag
        PicBoxPenguin.Background = Color.Default
        ButtonSchongang.Border = False 
      Case ButtonFileInfo.Tag
        PanelPath.Background = Color.Default
      Case PicBoxUndo.Tag, PicBoxRedo.Tag
        ScrollViewLevels.Background = Color.Default
        LabelUndoRedoCounter.Background = Color.Default
      Case ButtonSave.Tag
        PanelPath.Background = Color.Default
      Case ButtonBrowser.Tag 
        PicBoxClock.Background = Color.Default
        ButtonBrowser.Border = False 
      Case PicBoxReorder.Tag
        ScrollViewLevels.Background = Color.Default
      Case LabelUndoRedoCounter.Tag
        Last.Background = Color.Default
      Case PicBoxUndoMuster.Tag, PicBoxRedoMuster.Tag, ButtonMusterReload.Tag, ButtonMusterCancel.Tag
        PanelMuster.Background = Color.Default
      Case PicBoxLevelsAll.Tag, PicBoxRefreshSum.Tag
        ScrollViewLevels.Background = Color.Default
      ' Case ButtonColorsUserClear.Tag
        ' Last.Border = True
        ' Last.Background = Color.Default
      Case ButtonFindMusterColor.Tag
        Last.Border = False
        Last.Background = Color.Default
        
      ' Case ButtonColorApply.Tag
        ' ScrollViewLevels.Background = Color.Default
        ' ScrollViewGallery.Background = Color.Default
      Case PicBoxMusterChange.Tag 
        PanelMuster.Background = Color.Default
        
      Case PicBoxColorSelectFG.Tag
        PicBoxColorSelectFG.Background = ColorChooser1.SelectedColor
        
     Case "colorcancel", ButtonColorCancel.Tag
        Last.Background = Color.Default
        Last.Border = True 
      
     Case PicBoxLevelsEditNull.Tag, PicBoxLevelsEditNull2.Tag 
        ' If F_bEditChangeON = True Then PicBoxLevelsEditNull.Background = F_iColorSelect Else PicBoxLevelsEditNull.Background = Color.Default
        ' PicBoxLevelsEditNull2.Background = Color.Default
        ScrollViewLevels.Background = Color.Default
        
      Case PicBoxLevelsEditNullColor.Tag, PicBoxLevelsEditNullColor2.Tag
        ' If F_bColorChangeON = True Then PicBoxLevelsEditNullColor.Background = F_iColorSelect Else PicBoxLevelsEditNullColor.Background = Color.Default
        ' PicBoxLevelsEditNullColor2.Background = Color.Default
        
      Case Else 
        Last.Background = Color.Default
        If Object.Type(Last) = "Button" Then Last.Border = False 
    End Select
    
    If F_bSelectionTopON = True Then 
      ButtonMusterSelectionTop.Background = F_iColorSelect 
      ButtonMusterSelectionTop.Border = True 
    Else 
      ButtonMusterSelectionTop.Background = Color.Default
      ButtonMusterSelectionTop.Border = False 
    Endif 
    
    If F_bEditChangeON = True Then 
      PicBoxLevelsEditNull.Background = F_iColorSelect 
    Else 
      PicBoxLevelsEditNull.Background = Color.Default
    Endif 
    PicBoxLevelsEditNull2.Background = PicBoxLevelsEditNull.Background
    
    If F_bColorChangeON = True Then 
      PicBoxLevelsEditNullColor.Background = F_iColorSelect 
    Else 
      PicBoxLevelsEditNullColor.Background = Color.Default
    Endif 
    PicBoxLevelsEditNullColor2.Background = PicBoxLevelsEditNullColor.Background
    
    LabelMessageText("")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown() 'PictureBox
  
  Dim sLMR As String 
  
  If Mouse.Left Then sLMR = "L"
  If Mouse.Middle Then sLMR = "M"
  If Mouse.Right Then sLMR = "R"
  
  If Last.Tag = PicBoxMusterSide.Tag Then ButtonGroupSelect(Last.Tag, sLMR)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp() 'PictureBox
  
  Dim sLMR As String 
  
  If Mouse.Left Then sLMR = "L"
  If Mouse.Middle Then sLMR = "M"
  If Mouse.Right Then sLMR = "R"
  
  If Object.Type(Last) = "PictureBox" Then 
    If Last.Tag = PicBoxMusterSide.Tag Then
      ''...  nothing, null, zero, nichts
    Else 
      ButtonGroupSelect(Last.Tag, sLMR)
    Endif 
  Else If Object.Type(Last) = "Label" Then 
    ButtonGroupSelect(Last.Tag, sLMR)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  Dim sLMR As String = "L" 'no Mouse. Event
  
  If Object.Type(Last) <> "PictureBox" Then 
    If Last.Tag = PicBoxMusterSide.Tag Then
      ''...  nothing, null, zero, nichts
    Else 
      If Last.Tag = PicBoxClock.Tag Then F_oLastPicBoxObject = Last
      ButtonGroupSelect(Last.Tag, sLMR)
    Endif 
  Endif 
  
  ' Print "MouseClick " & Last.Tag 
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "L")
  
  Dim sPath, sText, sTag, sLevelsBefore, sMusterBefore As String 
  Dim iFound As Integer
  Dim it As Integer
  
  ''[ESC]?
  F_iESCpressed = 0 'Reset
  F_bESCpressedON = False 'Reset
  IconError.Visible = False 
  F_bChangeON = True 'Reset
  ' F_bColorPickerAreaON = False
  sLevelsBefore = ReadLevelsTag()
  
  If String.InStr(sLastTag, "muster") > 0 Then
    ' If Not F_ooPicBoxesMuster Then 
    '   SideG("muster")
    ' ' CheckMusterSideFill()
    ' Endif 
    ' If Not F_ssUndoRedoMuster Then F_ssUndoRedoMuster = New String[]
    If Not F_ssUndoRedoMuster Then UndoRedoMusterSave()
    If F_ooPicBoxesMuster Then sMusterBefore = ReadMusterTags() 'All
    ' If PicBoxMusterSide.Tag <> sLastTag Then SideG("muster")
    Print PicBoxMusterSide.Tag; sLastTag
  Else 
    If Not F_ssUndoRedoLevels Then UndoRedoLevelSave(sLevelsBefore) 
  Endif 
  
  ' TimerPickerColor.Stop()
  sMouseLMR = String.LCase(String.Left(sMouseLMR, 1)) 'l,m or r
  sLastTag = String.LCase(sLastTag)
  
  Select Case sLastTag
    Case "colormemory", PicBoxMenuColorPicker.Tag
      F_bColorPickerAreaON = Not F_bColorPickerAreaON
      ColorPickerCursorAllReset()
      ' If F_bColorPickerAreaON = True Then TimerColorPicker.Start()
      ' If PanelMemoryColors.Visible = False Then 
      '   SideG("colormemory")
      '   ' F_bColorPickerAreaON = True
      ' Else If PanelGallery.Visible = True Then 
      '   SideG("gallery")
      ' Else 
      '   SideG("muster")
      ' Endif 
    Case "color", PicBoxColors.Tag
      If PanelColor.Visible = False Then 
        SideG(PicBoxColors.Tag)
      Else 
        ' If PanelGallery.Visible = True Then 
        '   SideG("gallery")
        ' Else If PanelMuster.Visible = True Then 
        '   SideG("muster")
        ' Else 
          PanelColor.Visible = False
        ' Endif 
      Endif 
    Case "colorcancel", ButtonColorCancel.Tag
      PanelColor.Visible = False
      
    ' Case ButtonMenuEditCancel.Tag
    '   PanelMenuEdit.Visible = False
    '   Form_Resize()
    
    Case PicFontMinus.Tag 'A- Aminus 'rework, not finished
      FontsizeG(sLastTag)
  
    Case PicFontPlus.Tag 'A+ Aplus
      FontsizeG(sLastTag)
      '   
    Case LabelFontSize.Tag '0 Aplus Standard
      FontsizeG(sLastTag)
 
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "browser"
      PicBoxClock.Background = Color.Blue
      ButtonBrowserTrueG(True)
      Wait 0.5
      PicBoxClock.Background = Color.Default
      
    Case "copy1", MenuCopy1.Tag 'copy picture in Pixel WxH
      ImageEdit(sLastTag)
      
    Case "copy2", MenuCopy2.Tag
      ImageEdit(sLastTag)
      
    Case "copy3", MenuCopy3.Tag
      ImageEdit(sLastTag)
      
    Case "save1", MenuSave1.Tag
      ImageEdit(sLastTag)
      
    Case "mirrorleftright", MenuMirrorLeftRight.Tag
      ImageEdit(sLastTag)
      '         
    Case "mirrortopbottom", MenuMirrorTopBottom.Tag
      ImageEdit(sLastTag)
      
    Case "rotateleft", MenuRotateLeft.Tag
      ImageEdit(sLastTag)
      
    Case "rotateright", MenuRotateRight.Tag
      ImageEdit(sLastTag)
      
    Case "grayscale", MenuGrayscale.Tag
      ImageEdit(sLastTag)
      
    Case "scaleminus", MenuScaleMinus.Tag
      ImageEdit(sLastTag)
      
    Case "scaleplus", MenuScalePlus.Tag
      ImageEdit(sLastTag)
      
    Case "moveleft", "moveright", "moveup", "movedown"
      ImageEdit(sLastTag)
      
    Case MenuSize0.Tag, MenuSize1.Tag, MenuSize2.Tag, MenuSize3.Tag, MenuSize4.Tag, MenuSize5.Tag 'Example: 128
      IconSizeMenu(sLastTag)
      
    Case "cutgallerypic"
      CutLevelGalleryMuster()
      
    Case "colorpicker", PicBoxPickerColor.Tag, PicBoxMenuColorPicker.Tag
      If F_iColor0Picker1Transparent2 <> 1 Then 
        F_iColor0Picker1Transparent2 = 1
        SideG("colorpicker")
        ScreenshotPhotoNew()
      Else 
        F_iColor0Picker1Transparent2 = 0
        SideG("color")
      Endif 
      TimerColorPicker.Enabled = PanelColorPicker.Visible 
      If PanelColorPicker.Visible = True Then 
        PicBoxPickerColor.Background = F_iColorSelect
        PicBoxPickerTransparent.Background = Color.Default 
        PicBoxScreenshot.Background = F_iSelectGreenAlpha150
        Wait 0.5 'show effect for User
        PicBoxScreenshot.Background = Color.Transparent
      Else 
        PicBoxPickerColor.Background = Color.Default 
      Endif 
      
    Case "colorpickertransparent", PicBoxPickerTransparent.Tag
      If F_iColor0Picker1Transparent2 <> 2 Then 
        F_iColor0Picker1Transparent2 = 2
        SideG("colorpicker")
        ScreenshotPhotoNew()
      Else 
        F_iColor0Picker1Transparent2 = 0
        SideG("color")
      Endif 
      ' TimerColorPicker.Enabled = PicBoxScreenshot.Visible 
      TimerColorPicker.Enabled = PicturePhoto.Visible
      If PanelColorPicker.Visible = True Then 
        PicBoxPickerColor.Background = Color.Default 
        PicBoxPickerTransparent.Background = F_iColorSelect
        ' PicBoxScreenshot.Background = Color.SetAlpha(Color.Gray, 200)
        ' Wait 0.5 'show effect for User
        ' PicBoxScreenshot.Background = Color.Transparent
        PicturePhoto.Background = Color.SetAlpha(Color.Gray, 200)
        Wait 0.5 'show effect for User
        PicturePhoto.Background = Color.Transparent
      Else 
        PicBoxPickerTransparent.Background = Color.Default 
      Endif 
      
    Case "colorpoint", MenuColorPoint.Tag
      Form21Colors.Show
      Form21Colors.Visible = True 
      Form21Colors.F_sForm21ColorsText = ("Einen Farbpunkt auswählen") 
      Form21Colors.Tag = Me.Name
      
      ' Case "colorcancel"
      '   F_iColor0Picker1Transparent2 = 0
      '   SideG("gallery")
      
    Case "colorchoosercancel"
      F_iColor0Picker1Transparent2 = 0
      PanelColorChooser.Visible = False
      TimerClock.Stop()
      
    Case "copyimageextern"
      PicBoxSelectLevelONoff.Background = Color.Blue 
      OpenExtern("png") 'File in Temp with Ext-Format 
      Wait 0.5 'show effect for user
      PicBoxSelectLevelONoff.Background = Color.Default 
      
    Case "copyimage"
      CopyToClipboard(PictureSelect())
      
    Case "copyclockimage"
      If PicBoxClock.Picture Then CopyToClipboard(PicBoxClock.Picture) 'as Picture
      
    Case "copyclockextern"
      OpenExtern("png") 'File in Temp with Ext-Format 
      
    Case "mustercorrecttags"
      CheckMusterCorrectTags()
      
    Case "datetime", LabelTimePause.Tag
      If PanelDateTime.Visible = True Then 
        SideG() ' "gallery"
      Else 
        SideG(sLastTag) 
      Endif 
      
    Case "clockmusterdemo"
      ClockMusterDemoG()
      
    Case "createrandomizeclockmuster10x"
      CreateRandomizeClockMuster10x()
      If F_ooPicBoxesMuster Then F_oLastPicBoxMuster = F_ooPicBoxesMuster.Last
      
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "directory", ButtonDir.Tag
      ButtonDirG()
      
    Case "dirtemp", MenuDirTemp.Tag
      M01Functions.TempDirectoryOpen() 'as String sDir
      
    Case "datecancel"
      SideG("gallery")
      
    Case "editstandard" '0 Reset
      ResetStandardEdit()
      
    Case "fileinfo", ButtonFileInfo.Tag
      FileInfoG()
      
    Case "picboxpath"
      F_sPathClockBackground_png = Settings[FMain.Name &/ "F_sPathClockBackground_png", FMain.F_sPathClockBackground_png]
      FileInfoG(F_sPathClockBackground_png)
    
    Case "galleryreset", PicBoxGalleryReset.Tag, PicBoxRefreshSum2.Tag, "colorapply"
       TimerPanelColorsChange.Start()
       
    Case "info", PicBoxInfo.Tag
      M06InfoText.InfoText()
      
    Case "iconsize"
      CheckMenu1()
      MenuIconSize.Popup(LabelIconSizeWxH.ScreenX + LabelIconSizeWxH.W, LabelIconSizeWxH.Top + LabelIconSizeWxH.H)
      
    Case "loadlevelsnewnull", PicBoxLevelsNullNew.Tag
      ' ParkingChange()
      LoadLevelsNewNull()
      SumPaintClockLevels()
      SynchronizeLevelsToGallery()
      LabelInfo.Visible = False
      
    Case "levelsall", PicBoxLevelsAll.Tag
      LevelsAllSelect() '.Green or .Default
      
    Case "levelminus", PicBoxLevelMinus.Tag
      If Object.IsValid(F_oLastPicBoxObject) = True Then 
        MoveLevelMinusPlus("-")
        SumPaintClockLevels()
      Else 
        LabelMessageText("<font color=red><b>" & ("Ein Bild markieren (Mittel-Klick)") & "</b></font>")
      Endif 
      
    Case "levelplus", PicBoxLevelPlus.Tag
      If Object.IsValid(F_oLastPicBoxObject) = True Then 
        MoveLevelMinusPlus("+")
        SumPaintClockLevels()
      Else 
        LabelMessageText("<font color=red><b>" & ("Ein Bild markieren (Mittel-Klick)") & "</b></font>")
      Endif
      
    Case "menu", PicBoxEditStandard.Tag 
      ' CheckMenu1()
      ' MenuEdit.Popup(PicBoxMenu.ScreenX + PicBoxMenu.W, PicBoxMenu.ScreenY)
      SideG(PicBoxMusterChange.Tag)
      If PanelColorChooser.Visible = False Then 
        PanelColorChooser.Visible = True 
      Else 
        PanelColorChooser.Visible = False 
      Endif
      
    Case "menueditcancel"
      SideG("gallery")
      
    Case "colorchooser"
      PanelColorChooser.Visible = Not PanelColorChooser.Visible
      
    Case "musterdir", ButtonMusterDir.Tag
      ButtonMusterDirG()
      
    Case "morebuttons", ButtonMore.Tag
      F_bMoreButtons = Not F_bMoreButtons
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      MoreButtons(F_bMoreButtons)
      Form_Resize()
      
    Case "galleryside", "gallery"
      SideG("gallery")
      
    Case "musterside", "muster", "galleryormuster", ArrowR.Tag, PicBoxMusterSide.Tag
    ', ButtonMusterCancel.Tag, PicBoxMusterSide.Tag
      If PanelMuster.Visible = False Then 
        ' SideG("muster")
        If Not F_ooPicBoxesMuster Then CheckMusterSideFill()'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        If PanelMuster.Visible = False Then SideG("muster")
      Else 
        SideG("gallery")  
      Endif 
      
    Case "musteradd", PicBoxMusterAdd.Tag
      If sMouseLMR = "l" Then 
        CheckExistMuster(sLevelsBefore) 
      Endif  
      If sMouseLMR = "r" Then 
        MusterChange() 
      Endif 
      
    Case "musteroldyearoutside", MenuMusterOldyearOutside.Tag
      CheckMusterDoubleNewToOldyear() 
      
    Case "musteroldyearinside", MenuMusterOldyearInside.Tag
      CheckMusterDoubleOldyeartoNew() 
      
    Case "musterselectiontop" '■□ ■□
      F_bSelectionTopON = Not F_bSelectionTopON
      If Not F_ooPicBoxesMuster Then CheckMusterSideFill()'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      ' ResizePanelMusterSelectionTop()
      ResizePanelMuster()
      If F_bSelectionTopON = True Then MusterSelectionTopInfo()
      
    Case "musterchange"
      MusterChange() 
      
    Case "findmusterdouble", ButtonFindMusterDouble.Tag
      MusterSideCompareDouble()
      
    Case "findmusteredit", ButtonFindMusterEdit.Tag
      MusterSideCompareEdit()

    Case "findmustercolor", ButtonFindMusterColor.Tag
      MusterSideCompareColor()
      
    Case "findcurrentmuster", ButtonFindCurrentMuster.Tag
      '... see end ▼
      If PanelMuster.Visible = True Then 
        If Object.IsValid(F_oLastPicBoxMuster) = False And F_ssPicBoxMusterTags And F_ooPicBoxesMuster Then 
          it = F_ssPicBoxMusterTags.Find(PicBoxClock.Tag) 
          If it > -1 Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[it]
        Endif 
      Endif 
      
      ' Case "musterrefresh"
      '   MusterColorRefreshSelection()
      
    Case "musterreloadall"
      MusterReloadAll()
      
    Case "musteropen", ButtonMusterOpen.Tag
      LoadMusterFileText()
      
    Case "findcurrentmuster", ButtonFindCurrentMuster.Tag 
      FindCurrentMuster()
      
    Case "musteropenbackup"
      sPath = OpenDirBackupG()
      LoadMusterFileText(sPath, "openbackup")
      
    Case "mustersavedirect", ButtonMusterSaveDirect.Tag
      SaveAllMusterDirectTxt()
      
    Case "mustersave", ButtonMusterSave.Tag
      SaveSelectionMusterTxt()
      
    Case "musterunselectall", ButtonMusterUnSelectAll.Tag
      MusterUnselectAll()
      MusterCounter() 'as String  "0/0"
      
    Case "musterselectall", ButtonMusterSelectAll.Tag
      MusterSelectAll()
      MusterCounter() 'as String  "0/0"
      
    Case "mustercut", ButtonMusterCut.Tag
      MusterCut()
      
    Case "mustersavepics", ButtonMusterSavePics.Tag
      If PanelMuster.Visible = False Then SideG("muster")
      SaveSelectMusterPictures()
      
    Case "opendialog", PicBoxOpenDialog.Tag
      OpenDialogPicture()
      
    Case "panelcolorchooser"
      If PanelColorChooser.Visible = False Then 
        PanelColorChooser.Visible = True 
      Else 
        PanelColorChooser.Visible = False 
      Endif
      
    Case "picboxclock", PicBoxClock.Tag 
      If sMouseLMR = "l" Then 
        '... see end ▼
        If PanelMuster.Visible = True Then 
          If Object.IsValid(F_oLastPicBoxMuster) = False And F_ssPicBoxMusterTags And F_ooPicBoxesMuster Then 
            it = F_ssPicBoxMusterTags.Find(PicBoxClock.Tag) 
            If it > -1 Then F_oLastPicBoxMuster = F_ooPicBoxesMuster[it]
          Endif 
        Endif 
      Else If sMouseLMR = "m" Then 
        PicBoxClock.Background = Color.Blue
        ButtonBrowserTrueG(False) 'Cache
        Wait 0.5
        PicBoxClock.Background = Color.Default
      Else If sMouseLMR = "r" Then  
        Form3TextSelectTags()
      Endif 
      
    Case "picoriginal", MenuPicOriginal.Tag
      ReloadPicOriginal()
      
    Case "picschongang"
      If sMouseLMR = "l" Then 
        ButtonSchongangSwitchG()
      Endif 
      If sMouseLMR = "r" Then 
        F_oLastPicBoxObject = PicBoxPenguin
        CheckMenu1()
        MenuEdit.Popup()
      Endif
      
    Case "photo", PicBoxPhoto.Tag ', "camera"
      ButtonFotoG()
      
    Case "printfile"
      PrintFileIcons()  ' PrintFile() ''open extern, Example: Browser
      
    Case "refreshsum", PicBoxRefreshSum.Tag
      ScrollViewLevels.Background = LabelTemplateClockColor.Background
      SumPaintClockLevels()
      SynchronizeLevelsToGallery()
      Wait 0.3
      ScrollViewLevels.Background = Color.Default
      
    Case "findmustercolor", MenuFindMusterColor.Tag
      FindMusterColor()
      
    ' Case "colorsuserclear", ButtonColorsUserClear.Tag 
    '   F_iiIconClockColorsB = F_iiIconClockColorsA.Copy()
    '   ColorsUserToBoxes(F_iiIconClockColorsB)
      
    Case "copyclockpartpictureextern"
      sPath = M01Functions.TempDirFile("clockpart.png")
      If PanelGallery.Visible = True Then 
        If Object.IsValid(F_oLastPicBoxObject) = True And Object.Type(F_oLastPicBoxObject) = "PictureBox" Then F_oLastPicBoxObject.Picture.Save(sPath)
      Else If PanelMuster.Visible = True Then 
        If Object.IsValid(F_oLastPicBoxMuster) = True And Object.Type(F_oLastPicBoxMuster) = "PictureBox" Then F_oLastPicBoxMuster.Picture.Save(sPath)
      Endif 
      If Exist(sPath) = True Then Desktop.Open(sPath)
      
    Case "copyclockextern"
      sPath = M01Functions.TempDirFile("clockpart.png")
      If PanelGallery.Visible = True Then 
        If Object.IsValid(F_oLastPicBoxObject) = True And Object.Type(F_oLastPicBoxObject) = "PictureBox" Then F_oLastPicBoxObject.Picture.Save(sPath)
      Else If PanelMuster.Visible = True Then 
        If Object.IsValid(F_oLastPicBoxMuster) = True And Object.Type(F_oLastPicBoxMuster) = "PictureBox" Then F_oLastPicBoxMuster.Picture.Save(sPath)
      Endif 
      If Exist(sPath) = True Then M01Functions.ExternStart("gimp", sPath) 'mit Datei 
      
    Case "copyclockpictureextern"
      sPath = M01Functions.TempDirFile("clock.png")
      If PicBoxClock.Picture Then PicBoxClock.Picture.Save(sPath)
      If Exist(sPath) = True Then Desktop.Open(sPath)
      
    Case "reset", ButtonReset.Tag ' |◀— Back to start
      Select Case Message.Question("<h3>" & ("Leeren und neu anfangen in Seite...") & "</h3>", ("Baukasten"), ("Muster") & Space(1) & "(" & ("Alle Muster auslagern") & "..." & ")", ("Abbrechen"))
        Case 1 'building set
          ' ParkingChange()
          DefaultNewLevelsGallery()
          Me.F_iiIconClockColorsB = M05.ColorPaletteStandardii()'as Integer[]
          Settings[F_sForm &/ "F_iiIconClockColorsB"] = Me.F_iiIconClockColorsB
          ' FMain.F_iiIconClockColorsB = Me.F_iiIconClockColorsB.Copy()
          CreatePanelMemoryColors() 'takes Colors —▶ behind Create Gallery
          CheckFontColor()
          M05.ColorClockGetSettings()
          LoadLevelsNewNull()
          
        Case 2 'Muster
          CheckMusterDoubleNewToOldyear() 
          SideG("muster")
          
        Case 3 'Cancel
          '...
      End Select  
      DateTimeSetting(F_dateNow)
      
    Case "reorder", PicBoxReorder.Tag 'clear up, reduce, —▶compress◀—
      sText = ReadLevelsTag(False) 'Clear, only SelectColor
      LoadLevelsNewNull()
      LoadLevels(sText)
      ResizePanelLevels()
      SumPaintClockLevels()
      
    Case "levelseditnull", PicBoxLevelsEditNull.Tag
      If sMouseLMR = "l" Then 
        F_bEditChangeON = Not F_bEditChangeON
        LevelsNullEditsOnOff()
        SumPaintClockLevels()
      Endif 
      If sMouseLMR = "r" Then 
        Form3TextSelectTags()
      Endif
      
    Case "levelseditnull2", PicBoxLevelsEditNull2.Tag
      If sMouseLMR = "l" Then
        F_bEditChangeON = Not F_bEditChangeON
        MusterReloadAll()
      Endif 
      If sMouseLMR = "r" Then 
        Form3TextSelectTags()
      Endif
      
    Case "levelseditnullcolor", PicBoxLevelsEditNullColor.Tag
      If sMouseLMR = "l" Then 
        F_bColorChangeON = Not F_bColorChangeON
        LevelsNullColorChangeOnOff()
        SumPaintClockLevels()
      Endif 
      If sMouseLMR = "r" Then 
        Form3TextSelectTags()
      Endif
      
    Case "levelseditnullcolor2", PicBoxLevelsEditNullColor2.Tag
      If sMouseLMR = "l" Then
        F_bColorChangeON = Not F_bColorChangeON
        MusterReloadAll()
      Endif 
      If sMouseLMR = "r" Then 
        Form3TextSelectTags()
      Endif
      
    Case "selectedquestion", PicBoxLevelsQuestionShowGalleryPart.Tag
      MusterFindLevel()
      
    Case "save", ButtonSave.Tag
      SaveG()
      
    Case "open", ButtonOpen.Tag 
      OpenG()
      
    Case "openrecent"
      MenuOpenRecentG()
      
    Case "saverecent"
      MenuSaveRecentG()  
      
    Case "recentopenpath"
      LoadMusterFileText(F_sRecentOpenMusterLastPath, "open")
      
    Case "recentsavepath"
      LoadMusterFileText(F_sRecentOpenMusterLastPath, "open")
      
    Case "selecttags", MenuSelectTags.Tag
      LabelCounterGallery.Text = GalleryCounter() 'as String  "0/0"
      Form3TextSelectTags()
      
    Case "timepause", PicBoxPause.Tag
      TimerClock.Enabled = Not TimerClock.Enabled
      If TimerClock.Enabled = True Then
        FMain.F_iClockMap0Stop1Count2Digital3Design4 = 4
        DateTimeSetting(Now)
        SumPaintClockLevels()
      Endif 
      CheckTimerClockPausePicture()
      
    Case "undo1", MenuUndo.Tag
      If sMouseLMR = "r" Then F_iUndoRedoLevelPointer = 0
      sText = UndoRedoLevelRead("-") 'as String 
      LoadLevelsNewNull()
      LoadLevels(sText) 'Reset
      ResizePanelLevels()
      SumPaintClockLevels()
      
    Case "redo1", MenuRedo.Tag
      If sMouseLMR = "r" And F_ssUndoRedoLevels Then F_iUndoRedoLevelPointer = F_ssUndoRedoLevels.Max
      sText = UndoRedoLevelRead("+") 'as String
      LoadLevelsNewNull()
      LoadLevels(sText) 'Reset
      ResizePanelLevels()
      SumPaintClockLevels()  
      
    Case "undo2"
      If PanelMuster.Visible = True Then 
        If sMouseLMR = "l" Then F_iUndoRedoMusterPointer = F_iUndoRedoMusterPointer - 1
        If sMouseLMR = "r" Then F_iUndoRedoMusterPointer = 0  'min.
        sText = UndoRedoMusterRead(F_iUndoRedoMusterPointer)
        MusterNullNew()
        LoadMuster(sText)
        sTag = UndoRedoMusterSelection("read") '0/0
        ResizePanelMuster()
      Endif 
      
    Case "redo2"
      If PanelMuster.Visible = True Then 
        If sMouseLMR = "l" Then F_iUndoRedoMusterPointer = F_iUndoRedoMusterPointer + 1
        If sMouseLMR = "r" And F_ssUndoRedoMuster Then F_iUndoRedoMusterPointer = F_ssUndoRedoMuster.Max
        sText = UndoRedoMusterRead(F_iUndoRedoMusterPointer)
        MusterNullNew()
        LoadMuster(sText)
        ResizePanelMuster()
        sTag = UndoRedoMusterSelection("read")'0/0
      Endif 
      
    Case "whiteborder", PicBoxWhiteBorder.Tag
      Form14UhrDesign.F_bWhiteBorderON = Not Form14UhrDesign.F_bWhiteBorderON
      Me.F_bWhiteBorderON = Form14UhrDesign.F_bWhiteBorderON
      Settings[F_sForm &/ "F_bWhiteBorderON"] = F_bWhiteBorderON 
      WhiteBorderMessageONoff()  
      
    Case MenuGallerySort.Tag
      F_bGallerySortON = Not F_bGallerySortON
      Settings[F_sForm &/ "F_bGallerySortON"] = F_bGallerySortON
      ResizePanelGallery()
      
    Case "resetstandardside"
      ResetStandardSideG()
      
    Case "opencolors"
      ColorOpenSaveStandardG(sLastTag)
      
    Case "savecolors"
      ColorOpenSaveStandardG(sLastTag)
      
    Case "standardcolors" 'Reset
      ColorOpenSaveStandardG(sLastTag)

    Case "zoomlabel"
      If sMouseLMR = "l" Then ZoomMinusPlus("s") 'Standard Reset
      If sMouseLMR = "r" Then ZoomMinusPlus("s") 'Standard Reset
      
    Case "zoom"
      ZoomMinusPlus("s") 'Standard Reset
      
    Case "zoomminus", PicBoxZoomMinus.Tag '-1x
      If sMouseLMR = "l" Then 
        ZoomMinusPlus("-")
      Else 
        ZoomMinusPlus("s") 'Standard Reset
      Endif 
      
    Case "zoomplus", PicBoxZoomPlus.Tag  '+1x
      If sMouseLMR = "l" Then 
        ZoomMinusPlus("+")
      Else 
        ZoomMinusPlus("s") 'Standard Reset
      Endif 
      
      ' Case "close"
      '   Me.Window.Close()
      
  End Select
  
  ''Save for undo◀—▶redo
  F_sLevelsTags = ReadLevelsTag()
  
  If String.InStr(sLastTag, "undo") > 0 Or String.InStr(sLastTag, "redo") > 0 Then 
    ''...
  Else   
    If String.InStr(sLastTag, "muster") > 0 Then 
      F_sMusterTags = ReadMusterTags(True) 'All
      If sMusterBefore <> F_sMusterTags Then UndoRedoMusterSave(F_sMusterTags) 
      If sLevelsBefore <> F_sLevelsTags Then UndoRedoLevelSave()
    Else 
      If sLevelsBefore <> F_sLevelsTags Then UndoRedoLevelSave() '> Sum...
    Endif 
  Endif
  
  If FMain.F_sErrorInfos Then 
    IconError.Visible = True 
    IconError.Raise() '▲Top-Level▲
  Endif
  
  If sLastTag = "close" Then 
    Me.Window.Close()
  Else 
    ProgressBar1.Pulse = False
    ProgressBar1.Visible = False 'ProgressBarONoff(False)
    If PanelGallery.Visible = True Then 
      ScrollViewEnsureVisibleG()
    Else 
      If F_ooPicBoxesMuster And F_ssPicBoxMusterTags Then 
        iFound = F_ssPicBoxMusterTags.Find("*" & sLevelsBefore & "*", gb.Like)
        If iFound > -1 Then 
          ScrollViewEnsureVisibleG(iFound)
        Else 
          ScrollViewEnsureVisibleG()
        Endif 
      Endif
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  ProgressBar1.Visible = False
  
End '..............................................................


Public Sub ColorPickerCursorAllReset()
  
  Dim oObj As Object
  
  For Each oObj In ScrollViewLevels.Children
    oObj.Cursor = New Cursor(PicTemplateMove.Picture, PicTemplateMove.Picture.W / 2, PicTemplateMove.Picture.H / 2) ' hotspot x,y, center, middle ◀–▶
    oObj.Mouse = Mouse.Custom  
  Next
  For Each oObj In ScrollViewGallery.Children
    oObj.Mouse = Cursor.Pointing
  Next
  For Each oObj In ScrollViewMuster.Children
    oObj.Mouse = Cursor.Pointing
  Next
  
  Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoColorsAdd(Optional iiColorsNew As Integer[] = Null)
  
  If iiColorsNew Then 
    If Not F_ooPicBoxesColorsB Then CreatePanelMemoryColors()
    
    If Not F_ooUndoRedoColors Then F_ooUndoRedoColors = New Object[]
    If iiColorsNew Then F_ooUndoRedoColors.Add(iiColorsNew) 
    
    Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColorsNew
    ListBackupCounter2.Text = F_ooUndoRedoColors.Max & Space(1) & "/" & Space(1) & F_ooUndoRedoColors.Max
    ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Farben-Reihe")
    F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
    Print "UndoRedoColorsAdd"
    ResizeColorBoxes()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoColorsPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim iiColors As Integer[]
  Dim sInfo As String
  
  If Not F_ooUndoRedoColors Then F_ooUndoRedoColors = New Object[]
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer - 1
      sInfo = ("Rückgängig")
      
    Case "r", "redo"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer + 1
      sInfo = ("Wiederherstellung")
      
    Case "m", "max"
      F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
      sInfo = ("max.")
      
    Case "s", "select"
      F_iUndoRedoColorsPointer = F_iUndoRedoColorsPointer
      sInfo = ("Auswahl")
      
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoColorsPointer < 0 Then F_iUndoRedoColorsPointer = 0
  If F_iUndoRedoColorsPointer > F_ooUndoRedoColors.Max Then F_iUndoRedoColorsPointer = F_ooUndoRedoColors.Max
  
  If F_iUndoRedoColorsPointer > -1 Then 
    iiColors = F_ooUndoRedoColors[F_iUndoRedoColorsPointer] 'Object Image
  Else 
    iiColors = Null
  Endif 
  ''Array [0,..., n-1]
  ''User 1,2,3,... n
  ListBackupCounter2.Text = Str(F_iUndoRedoColorsPointer + 1) & Space(1) & "/" & Space(1) & Str(F_ooUndoRedoColors.Max + 1)
  ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Farben-Reihe")

  If F_iUndoRedoColorsPointer > -1 Then 
    LabelInfo2.Text = ("Farbe") & ": " & sInfo
    F_iiIconClockColorsB = iiColors 'without .Copy()
    Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
  Endif 
  
  SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  ResizeColorBoxes()
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxHTML_MouseDown()

  ButtonGroupSelect("textareatext")
  
Catch 
  FMain.ErrorText
End

' Public Sub SettingsColorsUserReadSave(Optional sReadSave As String = "read")
'   
'   Dim it As Integer
'   
'   If F_ooPicBoxesColorsB Then '□ □ □
'     Select Case String.LCase(String.Left(sReadSave, 1))
'         
'       Case "r" ''Read ■ ■ ■ ——▶ □ □ □
'         If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
'         If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
'         
'         ''Refresh:
'         F_sColorChangeLineUser = "colorchange="
'         For it = 0 To F_ooPicBoxesColorsB.Max
'           F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
'           F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
'         Next  
'         Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
'         
'       Case "s" ''Save □ □ □ ◀—— ■ ■ ■
'         If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = New Integer[]
'         If F_iiIconClockColorsB.Max <> F_ooPicBoxesColorsB.Max Then F_iiIconClockColorsB.Resize(F_ooPicBoxesColorsB.Count)
'         
'         F_sColorChangeLineUser = "colorchange="
'         For it = 0 To F_ooPicBoxesColorsB.Max
'           F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
'           F_sColorChangeLineUser &= F_iiIconClockColorsB[it] & "="
'         Next 
'         Settings[F_sForm &/ "F_iiIconClockColorsB"] = F_iiIconClockColorsB
'         
'     End Select 
'     ' M05.ColorClockGetSettings() 'read
'   Endif 
'   
' Catch 
'   FMain.ErrorText
'   
' End

Public Sub ResizeColorBoxes()
  
  Dim it, iH, iW As Integer
  Dim fW, fH As Float
  Dim Img As Image
  
  If F_bChangeON = False Then Return 'hier abbrechen, zurück geben
  
  'Alternative: F_ooPicBoxesColorsA[it] = PanelColorBoxesA.Children[it]
  ' If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = Settings[F_sForm &/ "F_iiIconClockColorsA", Null]
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  
  F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsB]
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = M05.ColorPaletteStandardii() 'as Integer[]

  ' If Not F_ooPicBoxesColorsB Then CreateColorBoxes() 'Loop?
  ' F_iiIconClockColorsA = F_iiIconClockColorsB.Copy()
  
  If Not F_ooPicBoxesColorsA Or Not F_ooPicBoxesColorsBgrid Then CreatePanelMemoryColors()
  
  ''Colors A: Default □□□□□□□□□□
  If F_ooPicBoxesColorsA Then 
    iW = ScrollViewMemoryColors.W / F_ooPicBoxesColorsA.Count
    iH = ScrollViewMemoryColors.H / 2
    For it = 0 To F_ooPicBoxesColorsA.Max
      F_ooPicBoxesColorsA[it].Move(iW * it, 0, iW - 4, iH * 0.65)
      If it < F_iiIconClockColorsA.Count Then F_ooPicBoxesColorsA[it].Background = F_iiIconClockColorsA[it]
    Next
  Endif 
  
  ''Colors B: User □□□□□□□□□□
  If F_ooPicBoxesColorsB Then 'Boxes
    iW = ScrollViewMemoryColors.W / F_ooPicBoxesColorsB.Count
    iH = ScrollViewMemoryColors.H / 2
    fW = iW - 4
    fH = iH * 1.25
    
    For it = 0 To F_ooPicBoxesColorsB.Max
      If it < F_iiIconClockColorsB.Count Then F_ooPicBoxesColorsB[it].Background = F_iiIconClockColorsB[it]
      F_ooPicBoxesColorsB[it].Font.Bold = False 
      F_ooPicBoxesColorsB[it].Font.Size = LabelInfo2.Font.Size
      ' F_ooPicBoxesColorsB[it].Font.Size = ButtonColorPotNumber.Font.Size
      F_ooPicBoxesColorsB[it].Move(iW * it, iH * 0.75, fW, fH)
      F_ooPicBoxesColorsB[it].Raise()'▲
      If M01Functions.ColorInfoRGB(F_ooPicBoxesColorsB[it].Background, "L") < 150 And M01Functions.ColorInfoRGB(F_ooPicBoxesColorsB[it].Background, "A") < 150 Then F_ooPicBoxesColorsB[it].Foreground = Color.White Else F_ooPicBoxesColorsB[it].Foreground = Color.Black
    Next
    
    Img = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200), fW, fH) 'as Image
    For it = 0 To F_ooPicBoxesColorsBgrid.Max
      F_ooPicBoxesColorsBgrid[it].Move(iW * it, iH * 0.75, fW, fH)
      F_ooPicBoxesColorsBgrid[it].Lower()'▼
      F_ooPicBoxesColorsBgrid[it].Visible = True
      If Img Then F_ooPicBoxesColorsBgrid[it].Picture = Img.Picture
      ' F_ooPicBoxesColorsBgrid[it].Background = Color.Blue
    Next
    
    Img = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200), PicBoxColorSelectBGGrid.W, PicBoxColorSelectBGGrid.H) 'as Image
    If Img Then PicBoxColorSelectBGGrid.Picture = Img.Picture
    
    ''Selected:
    If F_ooPicBoxesColorsB Then 
      If F_iColorBoxesPointer > -1 And F_iColorBoxesPointer < F_ooPicBoxesColorsB.Count Then F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Bold = True 
      F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = 22
    ' F_ooPicBoxesColorsB[F_iColorBoxesPointer].Font.Size = ButtonColorPotNumber.Font.Size
    Endif 
    
  Endif
  ColorFindSelected()
  ' CheckFontColor() 
  F_bPanelColorsChanged = PanelMemoryColors.Visible 
  Print "ResizeColorBoxes"
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesA_Enter()
  
  F_iColorPicker = Last.Background
  ''ColorPicker 'Change ●
  Last.Cursor = New Cursor(PicBoxPickerColor.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 'as Picture, x, y
  Last.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesA_MouseDown()
  
  F_iColorPicker = Last.Background
  ColorChooser2.SelectedColor = F_iColorPicker
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesB_Enter()

  Dim iW, iH As Integer
  
  iW = 50
  iH = iW
  
  F_iColorPicker = Last.Background
  ''ColorPicker 'Change ●
  Last.Cursor = New Cursor(PicBoxColorMemoryBottom.Picture.Image.Stretch(iW, iH).Picture, iW, iH) 'as Picture, x, y
  Last.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupColorBoxesB_MouseDown()

  Dim sMessage As String 
  Dim it, iColor, iTrans, iColorRGB As Integer
  Dim iiColors As Integer[]
  
  iColor = ColorChooser2.SelectedColor
  iTrans = Color.GetAlpha(iColor) '0 = Color, 255 = full transparent
  iColorRGB = Color.SetAlpha(iColor, 0)
  sMessage = "<h1>" & "<font color=#" & Str(Hex(Last.Background, 6)) & ">" & "■ " & "</font>" & "#" & Str(Hex(Last.Background, 6)) & Space(1) & ("Alt") & "</h1>"
  sMessage &= "<h1>" & "<font color=#" & Str(Hex(iColorRGB, 6)) & ">" & "■ " & "</font>" & TextBoxHexaHTML.Text & Space(1) & ("Neu") & "</h1>"
  If iTrans > 0 Then sMessage &= "<font size=5 color=DarkGray><b>" & Str(iTrans) & "</b>" & Space(1) & ("von") & Space(1) & "255" & Space(1) & ("Alpha=Glas=transparenter Anteil") & "</font><br>"
  sMessage &= "<h3><font color=DarkGray>" & TextBoxColorName.Text & "</font></h3>"
  
  sMessage &= "<h1>" & ("Neue Farbe merken?") & "</h1>"
  Select Case Message.Question(sMessage, ("Merken"), ("Abbrechen"))
      
    Case 1 
      Last.Background = iColor
      If M01Functions.ColorInfoRGB(iColor, "L") < 150 And M01Functions.ColorInfoRGB(iColor, "A") < 150 Then Last.Foreground = Color.White Else Last.Foreground = Color.Black
      it = CInteger(Last.Tag)
      F_iColorBoxesPointer = it
      Settings[F_sForm &/ "F_iColorBoxesPointer"] = F_iColorBoxesPointer
      iiColors = F_iiIconClockColorsB.Copy()
      ' If it < F_iiIconClockColorsA.Count Then F_iiIconClockColorsA[it] = iColor 
      If it < F_iiIconClockColorsB.Count Then iiColors[it] = iColor 
      ' Settings[F_sForm &/ "F_iiIconClockColorsA"] = F_iiIconClockColorsA
      Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
      UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
            
    Case 2 'Cancel
      '...
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfo2G(Optional hTextInfo As String = Null) '<HTML>
  
  If hTextInfo Then 
    LabelCopyExample.Text = hTextInfo
    ' LabelInfoSearch.Visible = True 
  Else 
    LabelCopyExample.Text = LabelCopyExample.Tooltip
    ' LabelInfoSearch.Visible = False 
  Endif 
  
Catch 
  FMain.ErrorText
  
End
Public Sub SearchText(Optional sUpDown As String = "+")
  
  Dim sFindText As String 
  
  TextAreaSearch.SelectAll()
  
  sFindText = TextAreaSearch.Selection.Text
  
  If PanelWebTextCode.Visible = True Then 
    ''Web:
    If WebView1.Visible = True Then 
      If sUpDown = "+" Then '> plus down ▼
        'WebView.FindText(...) needs component: gb.qt4.webkit   and see: gb.gui.webview
        'Function FindText ( [ Text As String, Backward As Boolean, CaseSensitive As Boolean, Wrap As Boolean ] ) As Boolean
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, False, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Else '"-" '< minus up ▲
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          If WebView1.FindText(sFindText, True, True, False) = True Then  
            If LabelBgSearch.Background = F_iColorSelectRed150 Then 
              LabelBgSearch.Background = Color.White
            Else 
              LabelBgSearch.Background = F_iColorSelectRed150
            Endif
            LabelBgSearch.Text = ("Ende Suche")
          Else
            LabelBgSearch.Background = F_iColorSelectGreen150
            LabelBgSearch.Text = ("Gefunden")
          Endif
        Endif 
      Endif 
      If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
        LabelInfo2G(WebView1.SelectedText)
      Endif 
    Else If TextAreaCode.Visible = True Then 
      ''Code:
      F_iSearchPosCode = TextAreaTempPos(TextAreaCode, F_iSearchPosCode, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Position") & ": " & F_iSearchPosCode
    Else If TextAreaText.Visible = True Then 
      ''Text:
      F_iSearchPosText = TextAreaTempPos(TextAreaText, F_iSearchPosText, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Position") & ": " & F_iSearchPosText
    Else If ColumnView2.Visible = True Then 
      ''ColumnView:
      F_iSearchPosColumnView = ColumnViewFind(F_iSearchPosColumnView, sUpDown) 'as Integer
      LabelCopyExample.Text = ("Zeile") & ": " & F_iSearchPosColumnView
    Endif 
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Function TextAreaTempPos(Optional hTextArea As TextArea, Optional iLastPos As Integer, Optional sUpDown As String = "+") As Integer
  
  Dim iPos As Integer
  Dim sFindText As String 
  
  sFindText = TextAreaSearch.Text
  
  If hTextArea Then 
    If iLastPos < 0 Then iLastPos = 0
    If sUpDown = "+" Then '> plus down ▼
      iPos = String.InStr(hTextArea.Text, sFindText, iLastPos) 'as Integer  0=not found in String.InStr()
      If iPos > 0 Then 
        ButtonSearch.Background = F_iColorSelectGreen150
      Else 
        ButtonSearch.Background = F_iColorSelectRed150
      Endif 
      ButtonSearchBack.Background = Color.Default
      iLastPos = iPos + 1
    Else '"-" '< minus up ▲
      If iLastPos < String.Len(sFindText) Then iLastPos = String.Len(hTextArea.Text) - 1
      If iLastPos < 1 Then iLastPos = 1
      iPos = String.RInStr(hTextArea.Text, sFindText, iLastPos) 
      If iPos > 0 Then 
        ButtonSearchBack.Background = F_iColorSelectGreen150
      Else 
        ButtonSearchBack.Background = F_iColorSelectRed150
      Endif 
      ButtonSearch.Background = Color.Default
      iLastPos = iPos - 1 
    Endif
    
    If iPos < 1 Then 'not found 
      If LabelBgSearch.Background = F_iColorSelectRed150 Then 
        LabelBgSearch.Background = Color.White
      Else 
        LabelBgSearch.Background = F_iColorSelectRed150
      Endif
      iLastPos = 0
      LabelBgSearch.Text = ("Ende Suche")
    Else 
      LabelBgSearch.Background = F_iColorSelectGreen150 
      If iPos - 1 < 1 Then iPos = 1
      hTextArea.Select(iPos - 1, String.Len(sFindText)) 'begin min. with 1
      LabelBgSearch.Text = ("Gefunden") 
    Endif
    hTextArea.EnsureVisible()
  Endif 
  
  Return iLastPos
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewFind(Optional iLastPos As Integer, Optional UpDown As String = "+") As Integer
  
  Dim M, it, iFound, iLine As Integer
  Dim sK1, sText, sFindText, sTopBottom As String 
  
  If ColumnView2.Visible = True Then 
    If ColumnView2.Count > 0 And ColumnView2.Columns.Count > F_iColumns13Undo Then 
      If iLastPos < 0 Then iLastPos = 0
      sFindText = TextAreaSearch.Text
      sFindText = String.LCase(Replace(sFindText, gb.NewLine, "", gb.String))
      M = ColumnView2.MoveCurrent()
      If ColumnView2.Mode <> Select.Single Then ColumnView2.Mode = Select.Single
      TextAreaSearch.Foreground = Color.DarkRed
      For it = 0 To ColumnView2.Count - 1 
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sTopBottom = "" 'Reset
        If UpDown = "+" Then 
          M = ColumnView2.MoveBelow() '▼
          If M = -1 Then 
            M = ColumnView2.MoveFirst() 'M=0=False>Exist. M=-1=True>Missing
            sTopBottom = "top"
          Endif 
        Else 
          M = ColumnView2.MoveAbove() '▲
          If M = -1 Then 
            M = ColumnView2.MoveLast()  
            sTopBottom = "bottom"
          Endif 
        Endif 
        If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
          sK1 = ColumnView2.Item.Key
          sText = String.LCase(ColumnView2[sK1][F_iColumns13Undo]) 
          iLastPos = String.InStr(sText, sFindText)  '0 not found
          If iLastPos > 0 Then 
            If IsInteger(ColumnView2[sK1][0]) = True Then iFound = CInteger(ColumnView2[sK1][0])
            Break
          Endif 
        Endif 
      Next
      If iLastPos > 0 Then
        ColumnView2[sK1].Selected = True 
        ColumnView2[sK1].EnsureVisible
        TextAreaSearch.Foreground = Color.DarkGreen
      Endif 

      If F_iSearchPosColumnView >= iFound Then 
        LabelBgSearch.Text = ("Ende Suche")
        LabelBgSearch.Background = F_iColorSelectRed150
        iFound = 0
      Else 
        LabelBgSearch.Text = ("Gefunden")
        LabelBgSearch.Background = F_iColorSelectGreen150
      Endif
    Endif 
  Endif 

  Return iFound
  
Catch
  FMain.ErrorText
  
End

Public Sub CreatePanelMemoryColors()
  
  Dim hLabel As Label
  Dim hPicBox As PictureBox
  Dim it, iW, iH, iColorsCount As Integer
  Dim iiColors As Integer[]
  
  iColorsCount = F_iColorsCount '= 10 '0,1,2... n-1    '0...10=11
  iiColors = New Integer[] 
  iiColors.Resize(iColorsCount)
  iiColors.Fill(Color.White, 0, -1) 'all -1
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = Settings[F_sForm &/ "F_iiIconClockColorsA", Null]
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = iiColors.Copy()
  
  If F_iiIconClockColorsA Then 
    If F_iiIconClockColorsA.Count < iColorsCount Then F_iiIconClockColorsA.Resize(iColorsCount)
    
    ''Colors A: Default □□□□□□□□□□
    ScrollViewMemoryColors.Children.Clear()
    F_ooPicBoxesColorsA = New Object[]
    F_ooPicBoxesColorsB = New Object[]
    F_ooPicBoxesColorsBgrid = New Object[]
    
    iW = PanelMemoryColors.H - 2
    iH = iW / 2
    
    For it = 0 To iColorsCount - 1
      hPicBox = New PictureBox(ScrollViewMemoryColors) As "GroupColorBoxesA"
      If it < F_iiIconClockColorsA.Count Then  
        hPicBox.Background = F_iiIconClockColorsA[it]
        ' F_sColorChangeLineStandard &= F_iiIconClockColorsA[it] & "="
      Endif 
      hPicBox.Tooltip = Str(it + 1) & Space(1) & ("Standard-Farbe übernehmen") 
      hPicBox.Tag = it '=Position
      hPicBox.Move(iW * it, 0, iW, iH)
      hPicBox.Cursor = New Cursor(PicBoxPickerColor.Picture, 0, 0) 
      hPicBox.Mouse = Mouse.Custom
      ' hPicBox.Mouse = Mouse.Pointing
      hPicBox.Visible = True 
      hPicBox.Border = Border.None
      
      F_ooPicBoxesColorsA.Add(hPicBox)
      
      hLabel = New Label(ScrollViewMemoryColors) As "GroupColorBoxesB"
      hLabel.Tooltip = Str(it + 1) & Space(1) & ("Farbe speichern") 
      hLabel.Tag = it '=Position
      hLabel.Move(iW * it, iH, iW, iH)
      hLabel.Cursor = New Cursor(PicTemplateColorPotCross.Picture, PicBoxColorMemoryBottom.Picture.W * 0.75, PicBoxColorMemoryBottom.Picture.H * 0.75) 
      hLabel.Mouse = Mouse.Custom
      hLabel.Alignment = Align.Center
      ' hLabel.Mouse = Mouse.Pointing
      hLabel.Visible = True 
      hLabel.Font.Bold = False
      hLabel.Text = Str(it + 1) '"+M" 
      hLabel.Border = Border.None
      
      ' If M01Functions.ColorInfoRGB(hLabel.Background, "L") < 150 Then hLabel.Foreground = Color.White Else hLabel.Foreground = Color.Black
      
      F_ooPicBoxesColorsB.Add(hLabel)
      
      ''Transparent-Grid in Background
      hPicBox = New PictureBox(ScrollViewMemoryColors) 
      hPicBox.Move(iW * it, iH, iW, iH)
      hPicBox.Tag = it '=Position
      hPicBox.Visible = True 
      
      F_ooPicBoxesColorsBgrid.Add(hPicBox) 
      
    Next
    
    ''Single, 1x:
    hPicBox = New PictureBox(ScrollViewMemoryColors) 
    hPicBox.Background = Color.Green 'find
    hPicBox.Tag = -1 'Position Nr.
    hPicBox.Move(-iW, 0, iW, iH)
    hPicBox.Mouse = Mouse.Default 
    hPicBox.Visible = False  
    hPicBox.Border = Border.None
    hPicBox.Name = "PicBoxSelect"
    F_oPicBoxColorFind = hPicBox
    
    ''Single, 1x:
    hPicBox = New PictureBox(ScrollViewMemoryColors) 
    hPicBox.Background = Color.Black 'last
    hPicBox.Tag = -1 'Position Nr.
    hPicBox.Move(-iW, 0, iW, iH)
    hPicBox.Mouse = Mouse.Default 
    hPicBox.Visible = False  
    hPicBox.Border = Border.None
    hPicBox.Name = "PicBoxSelect"
    F_oPicBoxColorLast = hPicBox
  Endif 
  ResizeColorBoxes()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorOpenSaveStandardG(Optional sOpenSaveStandard As String = "standard")
  
  Dim sPathLast, sDir, sFile, sDirFile, sLine, sLines, sSquare, sColors, sMessage As String 
  Dim ssColor As String[]
  Dim iColor, iDiff, it, iExist As Integer
  Dim iiColors As Integer[]
  
  If Not F_iiIconClockColorsA Then F_iiIconClockColorsA = M05.ColorPaletteStandardii() 'as Integer[]
  If Not F_iiIconClockColorsB Then F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
  iiColors = New Integer[]
  sPathLast = Settings[FMain.Name &/ "F_sPathPickerColorsMemory_txt", FMain.F_sPathPickerColorsMemory_txt]
  
  Select Case String.LCase(sOpenSaveStandard) 
      
    Case "open", "opencolors" '.....................................................
      iiColors = F_iiIconClockColorsA.Copy()
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      If sDirFile Then sFile = File.Name(sDirFile) 
      If Exist(sDir) = False Then sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = FileDialogPathReturn(sPathLast, "open", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Load:
      If Exist(sDirFile) = True Then 
        sLines = File.Load(sDirFile)
        If Not iiColors Then iiColors = New Integer[]
        If iiColors.Max <> F_ooPicBoxesColorsB.Max Then iiColors.Resize(F_ooPicBoxesColorsB.Count)
        it = -1
        For Each sLine In Split(sLines & gb.NewLine, gb.NewLine)
          If String.LCase(sLine) Like "*" & "color=" & "*" Then 
            ssColor = Split(sLine & "=", "=")
            If ssColor Then
              ssColor[1] = Trim(UnQuote(ssColor[1]))
              If IsInteger(ssColor[1]) = True Then 
                it = it + 1
                iColor = CInteger(ssColor[1]) 
                If it < iiColors.Count Then iiColors[it] = iColor Else Break
              Endif 
            Endif 
          Endif 
        Next 
        iExist = it
        If iiColors.Max > -1 Then 
          sColors = ""
          sMessage &= "<h3>" & "■ " & ("Aktuelle Farben") & "</h3>"
          For it = 0 To F_iiIconClockColorsB.Max
            If F_iiIconClockColorsB[it] = Color.Background Then 
              sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
            Else 
              sColors &= "<font color=#" & Hex(F_iiIconClockColorsB[it], 6) & ">" & "■" & "</font>"  
            Endif 
          Next   
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<br><br>"
          sMessage &= "<h3>" & "● " & ("Farben aus der Datei") & "</h3>"
          sColors = Null
          For it = 0 To iiColors.Max
            If iiColors[it] = F_iiIconClockColorsB[it] Then 
              sSquare = "■"
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
            Else 
              iDiff = iDiff + 1
              sSquare = "●" 'Changed
              If iiColors[it] = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
            Endif 
            sColors &= "<font color=#" & Hex(iiColors[it], 6) & ">" & sSquare & "</font>"
          Next  
          sMessage &= "<font size=5>" & sColors & "</font>"
          sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & iiColors.Count & Space(1) & ("Farben") & Space(1) & "</font></h3>"
          sMessage &= "<font color=gray>" & sDirFile & "</font>" & "<br>"
          If Exist(sDirFile) = True Then sMessage &= "<font color=darkgreen><b>" & Space(1) & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
          If Stat(sDirFile).Size = 0 Then sMessage &= "<font color=red size=5>" & ("Leer") & "</font>"
          If Stat(sDirFile).Size > 0 And iExist = -1 Then sMessage &= "<font color=red size=5>" & ("Keine Farben erkannt") & "</font>"
                    
          Select Case Message.Question(sMessage, "● " & ("Öffnen"), ("Ordner..."), ("Abbrechen"))
            Case 1  '"● "
              ''...Open
            Case 2 'Directory
              If Exist(sDirFile) = True Then M01Functions.FileManagerOpen(sDirFile) Else M01Functions.FileManagerOpen(sDir)
              Goto JumpEnd
            Case 3 'Cancel
              Goto JumpEnd
          End Select
          F_iiIconClockColorsB = iiColors.Copy()
          Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
          UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
        Else 
          sMessage = ""
          sColors = ""
          If F_iiIconClockColorsB Then
            sColors &= String(F_iiIconClockColorsB.Count, "□") & "<br>"
          Endif 
          If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
          sMessage &= sDirFile 
          sMessage &= "<h3><font color=red>" & ("Keine Farb-Palette?") & "</font></h3>"
          
          Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
            Case 1
              sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
              M01Functions.FileManagerOpen(sDir)
            Case 2
              ''...
          End Select
        Endif 
      Endif 
      
    Case "save", "savecolors" '.....................................................
      F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
      
      ' sMessage = "<h3><font color=gray>" & "■ " & ("Standard Farben") & "</font></h3>"
      sMessage = "<h3>" & "● " & ("Aktuelle Farben") & Space(1) & ("speichern") & "</h3>"
      sColors = ""
      For it = 0 To F_iiIconClockColorsB.Max 
        If F_iiIconClockColorsB[it] = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>" Else sSquare = "■"
        sColors &= "<font color=#" & Hex(F_iiIconClockColorsB[it], 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & F_iiIconClockColorsB.Count & Space(1) & ("Farben") & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Speichern") & "...", ("Ordner..."), ("Abbrechen"))
        Case 1  '"● "
          ''...Save
          
        Case 2 'Directory
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
          Goto JumpEnd
          
        Case 3 'Cancel
          Goto JumpEnd
      End Select
      
      sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
      sFile = File.Name(sDirFile)
      sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
      If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = M01Functions.FileDialogPathReturn(sPathLast, "save", sDirFile)  'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Goto JumpEnd
      
      ''Save:
      If sDirFile Then 
        If F_ooPicBoxesColorsB Then 
          sLines = "#" & Application.Name & Space(1) & Application.Version & ("Color-Palette") & gb.NewLine
          For it = 0 To F_ooPicBoxesColorsB.Max
            sLines &= "color=" & Quote(Str(F_ooPicBoxesColorsB[it].Background)) & gb.NewLine
          Next 
          '*****************************************************
          sDirFile = M01Functions.FileTextPlus(sDirFile, sLines, True) 'TRUE=overwrite (überschreiben)
          '*****************************************************
        Endif 
      Endif 
      
      ''Check:
      If sDirFile And Exist(sDirFile) = False Then
        sMessage = ""
        sColors = ""
        If F_iiIconClockColorsA Then
          sColors &= String(F_iiIconClockColorsA.Count, "□") & "<br>"
        Endif 
        If sColors Then sMessage &= "<font size=5>" & sColors & "</font>" & "<br>"
        sMessage &= sDirFile 
        sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            M01Functions.FileManagerOpen(sDir)
          Case 2
            ''...
        End Select
      Endif 
      
    Case "standard", "standardcolors", "reset" '.....................................................
      iiColors = Settings[FMain.Name &/ "F_iiIconClockColorsA", F_iiIconClockColorsA]
      F_iiIconClockColorsB = Settings[F_sForm &/ "F_iiIconClockColorsB", F_iiIconClockColorsA]
      If iiColors.Max <> F_ooPicBoxesColorsB.Max Then iiColors.Resize(F_ooPicBoxesColorsB.Count)
      
      sMessage = "<h3><font color=gray>" & "■ " & ("Standard Farben") & "</font></h3>"
      sColors = ""
      For it = 0 To iiColors.Max
        If iiColors[it] = Color.Background Then 
          sColors &= "<font color=#" & Hex(Color.Black, 6) & ">" & "□" & "</font>"
        Else 
          sColors &= "<font color=#" & Hex(iiColors[it], 6) & ">" & "■" & "</font>"  
        Endif 
      Next   
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<br><br>"
      sMessage &= "<h3>" & "● " & ("Aktuelle Farben") & "</h3>"
      sColors = ""
      For it = 0 To F_ooPicBoxesColorsB.Max
        If iiColors[it] = F_ooPicBoxesColorsB[it].Background Then 
          sSquare = "■"
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "□" & "</font>"
        Else 
          iDiff = iDiff + 1
          sSquare = "●" 'Changed
          If F_ooPicBoxesColorsB[it].Background = Color.Background Then sSquare = "<font color=black>" & "○" & "</font>"
        Endif 
        sColors &= "<font color=#" & Hex(F_ooPicBoxesColorsB[it].Background, 6) & ">" & sSquare & "</font>"
      Next  
      sMessage &= "<font size=5>" & sColors & "</font>"
      sMessage &= "<h3><font color=gray>" & ("Änderung") & ": " & iDiff & Space(1) & ("von") & Space(1) & F_ooPicBoxesColorsB.Count & Space(1) & ("Farben") & Space(1) & "</font></h3>"
      
      Select Message.Question(sMessage, "■ " & ("Standard Farben (Reset)") & Space(1) & ("Clear"), ("Ordner..."), ("Abbrechen"))
        Case 1 'Reset Colors
          If iDiff > 0 Then 
            F_iiIconClockColorsB = iiColors.Copy()
            Settings[F_sForm &/ "F_iiIconClockColorsB"] = iiColors.Copy()
            UndoRedoColorsAdd(iiColors) 'ResizeColorBoxes()
            LabelInfo2.Text = ("Farbe") & ": " & ("Standard (Reset)")
          Endif

        Case 2 
          sDirFile = Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt]
          If Exist(sDirFile) = False Then 
            sDir = Settings[FMain.Name &/ "F_sDirColors", FMain.F_sDirColors]
            sDirFile = sDir
          Endif 
          M01Functions.FileManagerOpen(sDirFile)
        Case 3 'Cancel
          '...
      End Select 
      
  End Select 

    
JumpEnd:
  
Catch 
  FMain.ErrorText()
  
End

' Public Sub ColorChooser1_Change()
'   
'   ColorSelected()
'   
' Catch 
'   FMain.ErrorText
'   
' End

Public Sub ColorSelected()
  
  Dim sText, sLine, sColorName, sAlpha As String
  Dim iFound, iColor, iR, iG, iB, iColorRGB, iAlpha As Integer
  Dim ssSpli As String[]
  Dim hColorInfo As ColorInfo
  
  iColor = ColorChooser2.SelectedColor
  iColorRGB = Color.SetAlpha(iColor, 0)
  
  hColorInfo = Color[iColor]
  iR = hColorInfo.Red
  iG = hColorInfo.Green
  iB = hColorInfo.Blue
  iAlpha = hColorInfo.Alpha 'Transparent

  ' sColorName = Quote(("Ein Name für die Farbe"))
  sColorName = Quote(("Kein Name"))
  
  If Not F_ssColorNames Then LoadColorNames()
  
  If F_ssColorNames Then 
    iFound = F_ssColorNames.Find("*=#" & Str(Hex(iColorRGB, 6)) & "=*", gb.Like) '-1 not found 
    If iFound > -1 Then 
      sLine = F_ssColorNames[iFound]
      ssSpli = Split(sLine & String(F_iColumns14Count, "="), "=")
      sColorName = ssSpli[0] 
    Endif 
  Endif 
  
  sText = "RGB" & "(" & iR & "," & iG & "," & iB & "," & iAlpha & ")" & gb.NewLine
  sText &= ("(Rot, Grün, Blau, Transparenz)") & Space(1) & ("Werte 0 bis 255") & gb.NewLine
  sText &= "<font color=" & Quote("#" & Str(Hex(iColorRGB, 6))) & ">...</font>" & gb.NewLine
  sText &= "<draw:color draw:name=" & sColorName & " draw:color=" & Chr(34) & "#" & Str(Hex(iColor, 6)) & Chr(34) & "/>" 'Chr() siehe ASCII-Tabelle 
  
  TextBoxHTML.SelectAll()
  TextBoxHTML.Insert(sText)
  TextBoxHTML.Background = Color.Default
  TextBoxHTML.Pos = 1
  
  TextBoxColorName.SelectAll()
  TextBoxColorName.Insert(sColorName)
  TextBoxColorName.Background = iColor
  
  TextBoxDezi.SelectAll()
  TextBoxDezi.Insert(iColor) '0123456789
  TextBoxDezi.Background = Color.Default
  
  TextBoxHexa.SelectAll()
  TextBoxHexa.Insert("&H" & Str(Hex(iColor, 8)) & "&")   '&H40678DB2& transparent blue
  TextBoxHexa.Background = Color.Default
  
  TextBoxHexaHTML.SelectAll()
  TextBoxHexaHTML.Insert("#" & Str(Hex(iColorRGB, 6))) '#678DB2
  TextBoxHexaHTML.Background = iColorRGB '=.Value =.SelectedColor
  
  F_iColorPicker = iColor
  LabelInfo2.Background = F_iColorPicker
  PicBoxColorApply.Background = F_iColorPicker
  PicBoxColorApplyTop.Background = F_iColorPicker
  PicBoxColorSelectFG.Background = F_iColorPicker
  CheckFontForeground()
  TextBoxColorName.ForeGround = LabelInfo2.Foreground
  TextBoxHexaHTML.ForeGround = LabelInfo2.Foreground
  PicBoxColorMemoryBottom.Picture = PicTemplateColorPotCross2.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture
  PicBoxPlus.Picture = PicTemplateColorPlus.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture
  'Only color, without Transparent (Alpha). Example: Hex(Color.White, 6) = > "FFFFFF"   not forget &H...&
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  
  If iAlpha > 0 Then sAlpha = " +" & Str(iAlpha) & Space(1) & ("Alpha=Glas=transparenter Anteil") 
  
  If iFound > -1 Then 
    LabelInfo2.Text = ("Info") & ": " & sColorName & sAlpha
  Else 
    LabelInfo2.Text = ("Info") & ": " & Str(Hex(iColor, 8)) & sAlpha
  Endif 
  
  LabelInfo2.Tooltip = LabelInfo2.Text
  ' If ColorChooser2.Visible = False Then SideG2(1)
  ColorFindSelected()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColorFindSelected()
  
  Dim it As Integer = -1
  
  If F_oPicBoxColorFind Then 
    
    If F_iiIconClockColorsB Then it = F_iiIconClockColorsB.Find(ColorChooser2.SelectedColor) '-1 not found
    
    If it > -1 Then 
      If F_ooPicBoxesColorsA And F_ooPicBoxesColorsB Then 
        F_oPicBoxColorFind.Move(F_ooPicBoxesColorsB[it].Left, F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H, F_ooPicBoxesColorsB[it].W, F_ooPicBoxesColorsB[it].Top - (F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H))
      Else 
        it = -1
      Endif 
    Endif
    If it = -1 Then F_oPicBoxColorFind.Visible = False Else F_oPicBoxColorFind.Visible = True
  Endif 
  
  
  If F_oPicBoxColorLast Then
    If F_iColorBoxesPointer > -1 Then it = F_iColorBoxesPointer Else it = -1
    If F_ooPicBoxesColorsA And F_ooPicBoxesColorsB And it > -1 Then 
      F_oPicBoxColorLast.Move(F_ooPicBoxesColorsB[it].Left, F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H, F_ooPicBoxesColorsB[it].W, F_ooPicBoxesColorsB[it].Top - (F_ooPicBoxesColorsA[it].Top + F_ooPicBoxesColorsA[it].H))
    Else 
      it = -1
    Endif 
    If it = -1 Then F_oPicBoxColorLast.Visible = False Else F_oPicBoxColorLast.Visible = True
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LoadColorNames() 
  
  Dim sPath, sText As String 
  
  If Not F_ssColorNames Then 
    sPath = "text/colornames.txt"
    If Exist(sPath) = True Then 
      sText = File.Load(sPath)
      F_ssColorNames = Split(sText & gb.NewLine, gb.NewLine) 'Abc
      F_ssColorNames.Sort()
    Endif 
  Endif 
  
  ''For programmer:
  '.............................
  ' CreateColorNamesHexRGBDezimalSave() '1x if not exist
  ' CreateColorNamesTableHTMLsave() '1x if not exist 
  ' CreateColorNamesTableHTMLColumnView2Save() '1x in file
  ' CreateColorNamesTableHTMLSortsave() '1x in file
  '.............................
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesHexRGBDezimalSave() '1x in file
  
  Dim sDirFile, sDir, sLine, sText As String 
  Dim sColorName, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli As String[]
  Dim iR, iG, iB, iRGB As Integer
  Dim hColorInfo As ColorInfo
  
  If F_ssColorNames Then 
    sText = "#Color-Names html Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & gb.NewLine
    sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
    sDirFile = sDir &/ "colornames.txt"
    For Each sLine In F_ssColorNames
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpli = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpli[0]
        sHex = ssSpli[1]
        ''Example: "#8000"
        Print sHex
        
        If sHex Begins "#" Then 
          sHex = Replace(sHex, "#", "")
          iRGB = CInt(Val("&H" & sHex)) 'ssSpli[2]
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha '0
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          ''Example: "Green=008000=0,128,0=32768="
          sLine = sColorName & "=" & String.UCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    File.Save(sDirFile, sText)
    Print sText
    Desktop.Open(sDirFile)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLsave() '1x in file
  
  Dim sDirFile, sDirFileHTML, sStyle, sDir, sLine, sText, sHTML, sInfo As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli, ssSpliLine As String[]
  Dim iR, iG, iB, iRGB, iCounter As Integer
  Dim hColorInfo As ColorInfo
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDirFile = sDir &/ "colornames.txt"
  sDirFileHTML = File.SetExt(sDirFile, "htm")
  
  If Exist(sDirFile) = True Then 
    sText = File.Load(sDirFile)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    
    sInfo = ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "gray = grey, aqua = cyan, fuchsia = magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote("2024 color-table: design-cad.de (Freeware)") & ">" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '" text / css ""
    ' sStyle &= "strong  {width: 90%; color: limegreen;}" & gb.NewLine 
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; font-weight: normal;}" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; text-decoration: none;}" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    sHTML &= "<h1>" & ("Farb-Tabelle mit Namen") & "</h1>" & gb.NewLine
    sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
    sHTML &= "<tr>" & gb.NewLine
    sHTML &= "<td colspan=1 align=right valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=2 align=left valign=top>" & "<b>" & ("Farbe") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=3 align=left valign=top>" & "<b>" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=4 align=left valign=top>" & "<b>" & ("Name") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=5 align=left valign=top>" & "<b>" & ("RGB(0,0,0)") & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=6 align=right valign=top>" & "<b>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=7 align=right valign=top>" & "<b>" & ("Luminance") & "</b>" & "<br>" & ("Helligkeit") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=8 align=right valign=top>" & "<b>" & ("Saturation") & "</b>" & "<br>" & ("Sättigung") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=9 align=right valign=top>" & "<b>" & ("HUE") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "</tr>" & gb.NewLine
    
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpliLine[0]
        sHex = ssSpliLine[2]  ''Example: "F0F8FF"
        sHex = Replace(sHex, "#", "")
        sHex = Replace(sHex, "&H", "")
        sHex = Replace(sHex, "&", "")
        sHex = "#" & sHex
        ' sRGB = ssSpliLine[2]
        sDezi = ssSpliLine[4]
        
        If IsInteger(sDezi) = True Then 
          iRGB = CInteger(sDezi)
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha 
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          If hColorInfo.Luminance < 150 Then 
            sColorNameFG = "<font color=white>" & sColorName & "</font>" 
          Else 
            sColorNameFG = "<font color=black>" & sColorName & "</font>"
          Endif 
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          iCounter = iCounter + 1
          ''Example: "Green=008000=0,128,0=32768="
          sHTML &= "<tr>" & gb.NewLine
          sHTML &= "<td colspan=1 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
          sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
          sHTML &= "<td colspan=3 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
          sHTML &= "<td colspan=4 align=left valign=top>" & sColorName & "</td>" & gb.NewLine
          sHTML &= "<td colspan=5 align=left valign=top>" & sRGB & "</td>" & gb.NewLine
          sHTML &= "<td colspan=6 align=right valign=top>" & sDezi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=7 align=right valign=top>" & sLumi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=8 align=right valign=top>" & sSatu & "</td>" & gb.NewLine
          sHTML &= "<td colspan=9 align=right valign=top>" & sHue & "</td>" & gb.NewLine
          sHTML &= "</tr>" & gb.NewLine
          sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    sHTML &= "</table>" & gb.NewLine
    sHTML &= "<br>" & gb.NewLine
    sHTML &= sInfo
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    ''Save:
    File.Save(sDirFileHTML, sHTML)
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    File.Save(sDirFileHTML & ".txt", sText)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    
    ''Show:
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLSortsave() '1x in file
  
  Dim sDirFile, sDirFileHTML, sStyle, sDir, sLine, sText, sHTML, sInfo As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue As String
  Dim ssSpli, ssSpliLine As String[]
  Dim iR, iG, iB, iRGB, iCounter As Integer
  Dim hColorInfo As ColorInfo
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sDirFile = sDir &/ "colornames.txt"
  sDirFileHTML = File.SetExt(sDirFile, "htm")
  
  If Exist(sDirFile) = True Then 
    sText = File.Load(sDirFile)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    
    sInfo = ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "gray = grey, aqua = cyan, fuchsia = magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote("2024 color-table: design-cad.de (Freeware)") & ">" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '" text / css ""
    ' sStyle &= "strong  {width: 90%; color: limegreen;}" & gb.NewLine 
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; font-weight: normal;}" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; text-decoration: none;}" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen; text-decoration: underline;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    sHTML &= "<h1>" & ("Farb-Tabelle mit Namen") & "</h1>" & gb.NewLine
    sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
    sHTML &= "<tr>" & gb.NewLine
    sHTML &= "<td colspan=1 align=right valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=2 align=left valign=top>" & "<b>" & ("Farbe") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=3 align=left valign=top>" & "<b>" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=4 align=left valign=top>" & "<b>" & ("Name") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=5 align=left valign=top>" & "<b>" & ("RGB(0,0,0)") & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=6 align=right valign=top>" & "<b>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
    sHTML &= "<td colspan=7 align=right valign=top>" & "<b>" & ("Luminance") & "</b>" & "<br>" & ("Helligkeit") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=8 align=right valign=top>" & "<b>" & ("Saturation") & "</b>" & "<br>" & ("Sättigung") & "</td>" & gb.NewLine
    sHTML &= "<td colspan=9 align=right valign=top>" & "<b>" & ("HUE") & "</b>" & "<br>" & ("360°") & "</td>" & gb.NewLine
    sHTML &= "</tr>" & gb.NewLine
    
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If sLine = "" Or sLine Begins "#" Then
        '...
      Else 
        ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
        sColorName = ssSpliLine[0]
        sHex = ssSpliLine[2]  ''Example: "F0F8FF"
        sHex = Replace(sHex, "#", "")
        sHex = Replace(sHex, "&H", "")
        sHex = Replace(sHex, "&", "")
        sHex = "#" & sHex
        ' sRGB = ssSpliLine[2]
        sDezi = ssSpliLine[4]
        
        If IsInteger(sDezi) = True Then 
          iRGB = CInteger(sDezi)
          hColorInfo = Color[iRGB]
          iR = hColorInfo.Red
          iG = hColorInfo.Green
          iB = hColorInfo.Blue
          ' iA = hColorInfo.Alpha 
          sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
          sDezi = Str(hColorInfo.Color)
          sLumi = hColorInfo.Luminance
          If hColorInfo.Luminance < 150 Then 
            sColorNameFG = "<font color=white>" & sColorName & "</font>" 
          Else 
            sColorNameFG = "<font color=black>" & sColorName & "</font>"
          Endif 
          sSatu = hColorInfo.Saturation
          sHue = hColorInfo.Hue
          iCounter = iCounter + 1
          ''Example: "Green=008000=0,128,0=32768="
          sHTML &= "<tr>" & gb.NewLine
          sHTML &= "<td colspan=1 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
          sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
          sHTML &= "<td colspan=3 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
          sHTML &= "<td colspan=4 align=left valign=top>" & sColorName & "</td>" & gb.NewLine
          sHTML &= "<td colspan=5 align=left valign=top>" & sRGB & "</td>" & gb.NewLine
          sHTML &= "<td colspan=6 align=right valign=top>" & sDezi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=7 align=right valign=top>" & sLumi & "</td>" & gb.NewLine
          sHTML &= "<td colspan=8 align=right valign=top>" & sSatu & "</td>" & gb.NewLine
          sHTML &= "<td colspan=9 align=right valign=top>" & sHue & "</td>" & gb.NewLine
          sHTML &= "</tr>" & gb.NewLine
          sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & sRGB & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & gb.NewLine 
          sText &= sLine
        Endif 
      Endif 
    Next
    sHTML &= "</table>" & gb.NewLine
    sHTML &= "<br>" & gb.NewLine
    sHTML &= sInfo
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    ''Save:
    File.Save(sDirFileHTML, sHTML)
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    File.Save(sDirFileHTML & ".txt", sText)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    
    ''Show:
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColorGroup_Click()
  
  F_sBackgroundColorOrPath = M01Functions.CheckFormBackgroundColorValue(Last.Tag) 'as String  
  FormBackgroundColor()
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  CheckFormBackgroundColor()
  
Catch 
  FMain.ErrorText
  
End

' Public Sub CheckFontForeground()
'   '■=■ > □=■
'   ''Example: Black-Foreground-Font in Black-Background = no visible —▶ more difference in Color
'   
'   If M01Functions.ColorInfoRGB(F_iColorPicker, "L") < 150 And M01Functions.ColorInfoRGB(F_iColorPicker, "A") < 150 Then LabelInfo.Foreground = Color.White Else LabelInfo.Foreground = Color.Black
'   
'   If F_iColorPicker = Color.Default Or F_iColorPicker = Color.Transparent Then LabelInfo.Foreground = Color.Black
'   ' LabelZoom.Foreground = LabelInfo.Foreground
'   
' Catch 
'   FMain.ErrorText 
'   
' End

Public Sub CheckFormBackgroundColor()
  
  PicBoxColorApplyTop.Picture = PicTemplateCheckoff.Picture
  PicBoxWoodTop.Picture = PicTemplateCheckoff.Picture
  PicBoxMetalTop.Picture = PicTemplateCheckoff.Picture
  
  Select Case F_sBackgroundColorOrPath
    Case Like "*wood*"
      PicBoxWoodTop.Picture = PicTemplateCheckON.Picture
    Case Like "*holz*"
      PicBoxWoodTop.Picture = PicTemplateCheckON.Picture
      
    Case Like "*metal*"
      PicBoxMetalTop.Picture = PicTemplateCheckON.Picture
    Case Like "*alu*"
      PicBoxMetalTop.Picture = PicTemplateCheckON.Picture
      
    Case CInteger(PicBackground.Background)
      PicBoxColorApplyTop.Picture = PicTemplateCheckON.Picture
      PicBoxColorApplyTop.Background = PicBackground.Background
    Case Else 
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ApplyIconColorG()
  Dim sLevelsBefore As String
  
  If PanelGallery.Visible = True Then 
    sLevelsBefore = ReadLevelsTag()
    DefaultNewLevelsGallery()
    LoadLevelsNewNull()
    LoadLevels(sLevelsBefore) 'SettingsColorsUserReadSave("save")
    ResizePanelLevels()
    SumPaintClockLevels()
  Else If PanelMuster.Visible = True Then 
    MusterColorRefreshSelection()
  Endif 
  F_bPanelColorsChanged = False 'Reset
  PanelColor.Visible = False 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
End

Public Sub ApplyG()
  
  Dim iColor As Integer
  
  If PicBackground.Picture Then 
    If Not F_sBackgroundColorOrPath Then F_sBackgroundColorOrPath = "wood"
    Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
  Else 
    iColor = ColorChooser2.SelectedColor
    F_sBackgroundColorOrPath = iColor
    PicBoxColorApplyTop.Background = iColor
    Settings[FMain.Name &/ "FormBackgroundColor"] = iColor   'Path or Color  
    Settings[FMain.Name &/ "ColorButton1.Value"] = iColor
  Endif 
  
  M01Functions.FormsBackgroundColorAll()
  ' F_sBackgroundColorOrPathEnter = F_sBackgroundColorOrPath
  F_iBackgroundColorEnter = PicBackground.Background
  ButtonApply.Picture = PicTemplateCheckON.Picture
  Wait 0.5 'show effect
  ButtonApply.Background = Color.Default 
  ButtonApply.Picture = PicTemplateApply.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomHasFocus(Optional bMouseForward As Boolean = True)
  
  ' If PicturePhoto.HasFocus = True Then 
  If F_fZoomFactor < 1.2 Then 
    If bMouseForward = False Then 
      F_fZoomFactor = F_fZoomFactor - 0.1
    Else
      F_fZoomFactor = F_fZoomFactor + 0.1
    Endif
  Else 
    If bMouseForward = False Then 
      F_fZoomFactor = F_fZoomFactor - 0.5
    Else
      F_fZoomFactor = F_fZoomFactor + 0.5
    Endif  
  Endif 
  If F_fZoomFactor < 0.2 Then F_fZoomFactor = 0.2  'Min.
  Me.Title = Application.Name & " - " & ("Zoom") & ": " & Round(F_fZoomFactor, -1) 'Example: 1.2
  ' Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicturePhoto_Enter()
  ' F_bColorPickerAreaON = True 
  F_oColorPickerLastObj = PicturePhoto 'as PictureBox
  PicBoxZoomCross.Picture = PicTemplateZoomCross.Picture
  PicBoxZoomCross.Visible = True 
  PicturePhoto.Visible = True 
  PicturePhoto.Background = Color.Transparent
  LabelInfo2.Text = ("Einen Farbpunkt auswählen")
  ' If F_sForm21ColorsText Then LabelInfo2.Text &= gb.NewLine & F_sForm21ColorsText
  
Catch
  FMain.ErrorText
  
End 

Public Sub PicturePhoto_Leave()
  ' If F_imgZoomLupe Then PicBoxZoomCross.Picture = F_imgZoomLupe.Picture
  
  PicBoxZoomCross.Visible = False 
  ' PicturePhoto.Visible = False  
  
  PicturePhoto.Background = F_iColorGreenAlpha150
  LabelInfo2.Text = ("Farbpunkt aus Foto")
  ' TimerZoomLupe.Stop()
  ' F_bColorPickerAreaON = False 
  F_oColorPickerLastObj = Null
  
Catch
  FMain.ErrorText
  
End

Public Sub PicturePhoto_MouseDown()
  
  Dim Img As Image
  
  If Mouse.Left Then 
    If PicturePhoto.Picture Then
      Img = PicturePhoto.Picture.Image.Stretch(PicturePhoto.W, PicturePhoto.H) 
      F_iColorPicker = Img[Mouse.X, Mouse.Y]
      F_imgScreen = Img.Copy()
      ColorChooser2.SelectedColor = F_iColorPicker
      SideG2(1)
    Endif 
    F_pointPickerXY = Point(Mouse.X, Mouse.Y) 
  Endif 
  ' If Mouse.Right Then Menu1.Popup() 'PhotoColorPickerG() 'siehe Eigenschaften
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView2Resize()
  
  If ColumnView2.Columns.Count < F_iColumns14Count Then  
    ColumnView2.Columns.Count = F_iColumns14Count     'Columns:|0|1|2|3|...|max|
  Endif 
  ColumnView2.Header = True                            'Title, Row index=0
  ColumnView2.Mode = Select.Single
  ColumnView2.AutoResize = True                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView2.Sorted = True 
  ' ColumnView2.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView2.Resizable = True            'Header <|> <|> Resize with Mouse
  ColumnView2.Columns[0].Alignment = Align.Right                                          '|  123|
  ' ColumnView2.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView2.Columns[1].Alignment = Align.Left                                           '|123  |
  ColumnView2.Columns[2].Alignment = Align.Left                                           '|123  |
  ColumnView2.Columns[3].Alignment = Align.Left                                         
  ColumnView2.Columns[4].Alignment = Align.Left                                         
  
  ''Name, name, Hex, RGB, Dezi, Lumi, Satu, HUE
  ColumnView2.Columns[0].Title = "▲▽" & ("Zeile")
  ColumnView2.Columns[1].Title = ("Farb-Name" & String(20, Space(1)))     'SpringGreen
  ColumnView2.Columns[2].Title = ""   'Name lcase
  ColumnView2.Columns[3].Title = ("#Hexadezimal")    '
  ColumnView2.Columns[4].Title = ("RGB(0,0,0)")    '
  ColumnView2.Columns[5].Title = ("Dezimal")       '
  ColumnView2.Columns[6].Title = ("□Helligkeit")       '
  ColumnView2.Columns[7].Title = ("■Sättigung")     
  ColumnView2.Columns[8].Title = ("HUE°")  
  ColumnView2.Columns[9].Title = ("○Rot")    
  ColumnView2.Columns[10].Title = ("○Grün")       '
  ColumnView2.Columns[11].Title = ("○Blau")       '
  ' ColumnView2.Columns[F_iColumn12Sort].Title = ("Sort") 
  ColumnView2.Columns[13].Title = ""    'Undo Line
  
  ' For it = 0 To ColumnView2.Columns.Max     '>9 or >13
  '   ' ColumnView2.Columns[it].Title = ""         'ColumnsUndo
  '   ColumnView2.Columns[it].Alignment = Align.Right   
  ' Next 
  '.AutoResize width = longest filename
  ' ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[F_iColumnUndo].Left 
  
  ' ColumnViewAscending()
  ColumnView2.AutoResize = False 
  ColumnView2.Columns[2].Width = 0  'Name lcase
  ColumnView2.Columns[13].Width = 0
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnView4Resize()
  Dim it As Integer
  
  If ColumnView4.Columns.Count < F_iColumns14Count Then  
    ColumnView4.Columns.Count = F_iColumns14Count     'Columns:|0|1|2|3|...|max|
  Endif 
  ColumnView4.Header = True                            'Title, Row index=0
  ColumnView4.Mode = Select.Single
  ColumnView4.AutoResize = True                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView4.Sorted = True 
  ' ColumnView4.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView4.Resizable = True            'Header <|> <|> Resize with Mouse
  ' ColumnView4.Columns[0].Alignment = Align.Right                                          '|  123|
  ' ColumnView4.Columns[2].Alignment = Align.Center                                         '| abc |
  ' ColumnView4.Columns[1].Alignment = Align.Left                                           '|123  |
  ' ColumnView4.Columns[2].Alignment = Align.Left                                           '|123  |
  ' ColumnView4.Columns[3].Alignment = Align.Left                                         
  ' ColumnView4.Columns[4].Alignment = Align.Left                                         
  ' iCompareLevel0_Edit1_Color2_Muster3
  ''NrBox0|Tag1|Level2|Edit3|Color4|5|6|7|8|9|10|11|Sort12|13|14|
  ColumnView4.Columns[0].Title = "▲▽" & ("NrBox")
  ColumnView4.Columns[1].Title = ("tag1")    
  ColumnView4.Columns[2].Title = ("level2")
  ColumnView4.Columns[3].Title = ("edit3")    '
  ColumnView4.Columns[4].Title = ("color4")    '
  ColumnView4.Columns[5].Title = ("double5")       '
  ColumnView4.Columns[6].Title = ("")       '
  ColumnView4.Columns[7].Title = ("")     
  ColumnView4.Columns[8].Title = ("")  
  ColumnView4.Columns[9].Title = ("")    
  ColumnView4.Columns[10].Title = ("")       '
  ColumnView4.Columns[11].Title = ("")       '
  ColumnView4.Columns[F_iColumn12Sort].Title = ("sort12") 
  ColumnView4.Columns[13].Title = ""    'Undo Line
  
  For it = 0 To ColumnView4.Columns.Max     '>9 or >13
    ' ColumnView4.Columns[it].Title = ""         'ColumnsUndo
    ColumnView4.Columns[it].Alignment = Align.Left 'Align.Right   
  Next 
  '.AutoResize width = longest filename
  ' ColumnView4.Columns[5].Width = ColumnView4.ClientWidth - ColumnView4.Columns[F_iColumnUndo].Left 
  
  ' ColumnViewAscending()
  ColumnView4.AutoResize = False 
  ' ColumnView4.Columns[2].Width = 0  'Name lcase
  ColumnView4.Columns[13].Width = 0
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Function ColorRGBtoHUEinfo(Optional iColorDezi As Integer = 0) As String 
  
  Dim hColorInfo As ColorInfo
  Dim sText As String 
  hColorInfo = color[iColorDezi]
  sText = "Color.RGB(" & hColorInfo.Red & ", " & hColorInfo.Green & ", " & hColorInfo.Blue & ", " & hColorInfo.Alpha & ")" & gb.NewLine & ("RGBA(Red, Green, Blue, Alpha)") & Space(5) & ("0 bis 255") & gb.NewLine & ("RGBA(Rot, Grün, Blau, Transparenz (Durchsichtigkeit))") & gb.NewLine & gb.NewLine
  sText &= "Color.HSV(" & hColorInfo.Hue & ", " & hColorInfo.Saturation & ", " & hColorInfo.Luminance & ")" & gb.NewLine & "HSV(HUE, Saturation, Luminance)" & Space(5) & "360°" & gb.NewLine & "HSV(Farbwert, Sättigung, Luminance Helligkeit)" & gb.NewLine

  Return sText
  
  Catch 
  FMain.ErrorText
  
End

Public Sub PhotoColorPickerLatest(Optional sLoadSaveReset As String = "load")
  
  Dim sDir, sFile, sDirFile As String 
  Dim picPhoto As Picture
  
  sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  sFile = "photocolorpickerlatest.png"
  sDirFile = sDir &/ sFile
  
  Select Case sLoadSaveReset
    Case "save"
      If IsDir(sDir) = True And PicturePhoto.Picture Then 
        PicturePhoto.Picture.Save(sDirFile)
      Endif
      
    Case "load"
      If Exist(sDirFile) = True Then 
        picPhoto = Picture.Load(sDirFile)
        If picPhoto Then 
          PicturePhoto.Picture = picPhoto.Copy()
          F_picScreen = PicturePhoto.Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
          UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
        Endif 
      Endif
      SideG2(2)  'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "reset"
      F_iLastSide = 1
      SideG2(2)  'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      If Not F_picPhotoLastUndo Then 
        F_sBackgroundColorOrPathUndo = F_sBackgroundColorOrPath
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
        F_picPhotoLastUndo = PicturePhoto.Picture
        F_sColorValueUndo1 = TextBoxHTML.Text
        F_sColorValueUndo2 = TextBoxHexa.Text
        F_sColorValueUndo3 = TextBoxDezi.Text
        PicturePhoto.Picture = Null
        PicBoxZoomLupe.Picture = Null
        If Exist(sDirFile) = True Then Kill sDirFile
        TextBoxHTML.Clear
        TextBoxHexa.Clear
        TextBoxDezi.Clear
        TextBoxColorName.Clear
        TextBoxHexaHTML.Clear
        TextBoxColorName.Background = Color.Default 
        TextBoxColorName.Foreground = Color.Default
        TextBoxHexaHTML.Background = Color.Default 
        TextBoxHexaHTML.Foreground = Color.Default
        F_imgScreen = M01Functions.ScreenshotImageDemo(PicBackground.ScreenX, PicBackground.ScreenY, PicBackground.W, PicBackground.H)
        If F_imgScreen Then 
          PicturePhoto.Picture = F_imgScreen.Picture
          F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          F_picScreen = F_imgScreen.Picture
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
        Endif
        LabelInfo2.Text = "-1x" & Space(1) & ("Reset") & "=Null"
      Else 
        F_sBackgroundColorOrPath = F_sBackgroundColorOrPathUndo
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
        F_imgScreen = F_picPhotoLastUndo.Image
        If F_imgScreen Then 
          PicturePhoto.Picture = F_imgScreen.Picture
          F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
          F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
          F_picScreen = F_imgScreen.Picture
          PicturePhoto.Picture = F_picScreen
          PicBoxZoomLupe.Picture = F_picScreen
        Endif
        ' F_picScreen = F_picPhotoLastUndo
        ' If F_picScreen Then F_imgScreen = F_picScreen.Image
        TextBoxHTML.SelectAll()
        TextBoxHTML.Insert(F_sColorValueUndo1)
        TextBoxHexa.SelectAll()
        TextBoxHexa.Insert(F_sColorValueUndo2)
        TextBoxDezi.SelectAll()
        TextBoxDezi.Insert(F_sColorValueUndo3)
        ColorSelected()
        F_picPhotoLastUndo = Null
        LabelInfo2.Text = "+1x" & Space(1) & ("Wiederherstellung")
      Endif 
      LabelInfo2.Tooltip = ("Info-Zeile")
      FormBackgroundColor()
      If F_sBackgroundColorOrPath <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      TimerZoomLupe.Start()
  End Select
  
Catch 
  FMain.ErrorText
  
End 

Public Sub ColumnView2_Click()
  
  If ColumnView2.Current Then 
    LabelInfo2.Text = ("Auswahl") & ": " & ColumnView2.Current[1]
    LabelInfo2.Tooltip = LabelInfo2.Text
    PasteTextBoxColor(ColumnView2.Current[1])
    ' TextBoxHTML.SelectAll()
    ' TextBoxHTML.Insert(ColumnView2.Current[1])
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_MouseUp() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    If WebView1.SelectedText Then 
      LabelInfo2.Text = ("Auswahl") & ": " & WebView1.SelectedText 
      LabelInfo2.Tooltip = ("Auswahl") & ": " & String.Left(WebView1.SelectedText, 200) 
      LabelCopyExample.Text = LabelInfo2.Text
      If WebView1.SelectedText Then 
        PasteTextBoxColor(WebView1.SelectedText)
        ' TextBoxHTML.SelectAll()
        ' TextBoxHTML.Insert(WebView1.SelectedText)
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebViewURL(Optional sFile As String = "colornamessort.htm")
  
  Dim sDirFile, sDir, sFaviconPNG As String 
  
  sDir = "text"
  If Exist(sDir &/ sFile) = False Then sFile = "colornamessort.htm"
  sDirFile = sDir &/ sFile 
  sDirFile = M01Functions.FileRootToTemp(sDirFile)
  If Exist(sDirFile) = True Then 
    WebView1.Url = "file://" & sDirFile
    sFaviconPNG = "text" &/ "favicon.png"
    sFaviconPNG = M01Functions.FileRootToTemp(sFaviconPNG)
    Wait 0.3
  Else 
    WebView1.Url = F_sURLblankempty
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateColorNamesTableHTMLColumnView2Save() '1x in file
  
  Dim sPathFaviconPNG, sPathProgram, sDirFile, sDirFileHTML, sDir, sFile, sFileHTML, sLine, sTitle, sText, sText2, sTextTXT, sTextCSV As String 
  Dim sColorName, sColorNameFG, sHex, sRGB, sDezi, sLumi, sSatu, sHue, sRGBfont As String
  Dim ssSpli, ssSpliLine, ssBG As String[]
  Dim iR, iG, iB, iRGB, iCounter, iTable As Integer
  Dim hColorInfo As ColorInfo
  Dim sStyle, sHTML, sInfo As String
  
  sRGBfont = "<font color=red>" & "0" & "</font>,<font color=green>" & "0" & "</font>,<font color=blue>" & "0" & "</font>"
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] 'Example: /home/<user>/terminwecker/...
  sFile = "colornames.txt"
  sDirFile = sDir &/ sFile
  
  If Exist(sDirFile) = True Then Kill sDirFile
  sPathProgram = "text" &/ sFile 'Path relativ
  Copy sPathProgram To sDirFile
  sPathFaviconPNG = sDir &/ "favicon.png"
  sPathProgram = "text" &/ "favicon.png"
  If Exist(sPathFaviconPNG) = True Then Kill sPathFaviconPNG
  Copy sPathProgram To sPathFaviconPNG
  
  sDirFileHTML = sDir &/ File.BaseName(sDirFile) & "sort" & ".htm"
  sFileHTML = File.Name(sDirFileHTML)
  
  ''Tabellenprogramm autom. Spalte mit gb.Tab, Kommata ",", ";" Voreinstellung?
  sTitle = "#" & "Farb-Name|abc|#Hexadezimal|RGB(0+0+0)|Dezimal|□Helligkeit|■Sättigung|HUE360°|○Rot|○Grün|○Blau-Anteil|" & gb.NewLine
  
  If IsDir(sDir) = True Then    
    sInfo = ("(Color names, Source reference)") & ", " & ("Farb-Namen") & ", " & "Quelle: 2024 selfhtml.org, w3.org, wikipedia.org" & "<br>" & gb.NewLine
    sInfo &= "*gray = *grey, Aqua = Cyan, Fuchsia = Magenta" & Space(1) & ("(2 = doppelt)") & "<br>" & gb.NewLine
    sInfo &= ("Color table created by: 2024 design-cad.de (Freeware)") & Space(1) & Application.Name & String.Left(Application.Version, 1) & "<br>" & gb.NewLine
    
    sHTML = "<!DOCTYPE html>" & gb.NewLine
    sHTML &= "<html lang=de> " & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<meta charset=UTF-8>" & gb.NewLine
    sHTML &= "<meta name=copyright content=" & Quote(("Color table created by: 2024 design-cad.de (Freeware)") & Space(1) & Application.Name & String.Left(Application.Version, 1)) & ">" & gb.NewLine
    sHTML &= "<meta name=author content=design-cad.de>" & gb.NewLine
    sHTML &= "<meta name=Keywords lang=de content=" & Quote("Farb-Namen, Farben, Tabelle, HTML") & ">" & gb.NewLine
    sHTML &= "<link rel=icon href=favicon.png type=image/png>" & gb.NewLine
    sHTML &= "<head>" & gb.NewLine
    sHTML &= "<title>Color-Names</title>" & gb.NewLine
    
    sStyle = "<STYLE TYPE=" & Quote("text/css") & ">" & gb.NewLine   '"text/css"
    sStyle &= "body, td {font-family: sans-serif; color: #656565; font-size: 20px; }" & gb.NewLine 
    sStyle &= "b {font-family: sans-serif; color: #656565; font-size=30px;}" & gb.NewLine 
    sStyle &= "A:link {font-family: sans-serif; color: grey;}" & gb.NewLine 
    sStyle &= "A:visited {font-family: sans-serif; color: darkblue;}" & gb.NewLine 
    sStyle &= "A:active {font-family: sans-serif; color: gray; }" & gb.NewLine 
    sStyle &= "A:hover {font-family: sans-serif; color: limegreen;}" & gb.NewLine 
    sStyle &= "</STYLE>" & gb.NewLine 
    
    sHTML &= sStyle 
    sHTML &= "</head>" & gb.NewLine
    sHTML &= "<body>" & gb.NewLine
    
    ''............................................................
    ''Title:
    ' sHTML &= "<table>" & gb.NewLine
    For iTable = 0 To 10
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      If iTable = 1 Then Continue 'with iTable=2
      iCounter = 0 'Reset
      sText = Null
      
      ''++++++++++++++++++++++++++++++++++++++++++++++++++++++
      sText = ColumnView2SortReturnText(iTable + 1)
      ' Print sText
      ''++++++++++++++++++++++++++++++++++++++++++++++++++++++
      
      ssSpli = Split(sText & gb.NewLine, gb.NewLine)
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      ''Title:
      sHTML &= gb.NewLine
      sHTML &= "<!-- Next table.............................................. -->" & gb.NewLine
      sHTML &= "<a name=jump" & Str(iTable) & "></a>" & gb.NewLine
      If iTable = 0 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Namen") & " Abc" & "</a> <img src=favicon.png width=30 height=30 alt=Logo></h1>" & gb.NewLine
      If iTable = 1 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach namen") & " abc" & "</a></h1>" & gb.NewLine
      If iTable = 2 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Hexadezimal") & " #" & "</a></h1>" & gb.NewLine
      If iTable = 3 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach RGB") & " (R,G,B)" & "</a></h1>" & gb.NewLine
      If iTable = 4 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Dezimal-Zahl") & " 0123" & "</a></h1>" & gb.NewLine
      If iTable = 5 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Helligkeit") & " □" & "</a></h1>" & gb.NewLine
      If iTable = 6 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Sättigung") & " ■" & "</a></h1>" & gb.NewLine
      If iTable = 7 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach HUE") & " 360°" & "</a></h1>" & gb.NewLine
      If iTable = 8 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Rot-Anteil") & " RGB(<font Color=Red>●</font>" & " ○ ○" & ")</a></h1>" & gb.NewLine
      If iTable = 9 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Grün-Anteil") & " RGB(○ <font Color=Green>●</font>" & " ○" & ")</a></h1>" & gb.NewLine
      If iTable = 10 Then sHTML &= "<h1><a href=#jump0>" & ("Farb-Tabelle nach Blau-Anteil") & " RGB(○ ○ <font Color=Blue>●</font>" & ")</a></h1>" & gb.NewLine
      
      ''Title line
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      sHTML &= "<table cellspacing=4% border=0 align=left bgcolor=white width=100%>" & gb.NewLine
      sHTML &= "<tr>" & gb.NewLine
      sHTML &= "<td colspan=0 align=left valign=top>" & "<b>" & ("Zeile") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=1 align=left valign=top>" & "<b><a href=#jump0>" & ("Name") & "</a></b>" & "</td>" & gb.NewLine
      ' sHTML &= "<td colspan=1 align=left valign=top>" & "<b><a href=#jump1>" & ("name") & "</a></b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=2 align=left valign=top>" & "<b><a href=#jump2>" & "#" & ("Hexadezimal") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=3 align=left valign=top>" & "<b><a href=#jump3>" & "RGB(" & sRGBfont & ")" & "</b>" & "<br>" & ("Rot, Grün, Blau") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=4 align=right valign=top>" & "<b><a href=#jump4>" & ("Dezimal") & "</b>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=5 align=right valign=top>" & "<b><a href=#jump5>" & ("Luminance") & "</b>" & "<br>" & "□ " & ("Helligkeit") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=6 align=right valign=top>" & "<b><a href=#jump6>" & ("Saturation") & "</b>" & "<br>" & "■ " & ("Sättigung") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=7 align=right valign=top>" & "<b><a href=#jump7>" & ("HUE") & "</b>" & "<br>" & ("360°") & "</td>" & gb.NewLine
      sHTML &= "<td colspan=8 align=right valign=top>" & "<b><a href=#jump8>" & ("Rot") & "</b>" & "<br>" & "<font color=red>●</font>" & "</td>" & gb.NewLine
      sHTML &= "<td colspan=9 align=right valign=top>" & "<b><a href=#jump9>" & ("Grün") & "</b>" "<br>" & "<font color=green>●</font>" & "</td>" & gb.NewLine 
      sHTML &= "<td colspan=10 align=right valign=top>" & "<b><a href=#jump10>" & ("Blau") & "</b>" "<br>" & "<font color=blue>●</font>" & "</td>" & gb.NewLine
      sHTML &= "</tr>" & gb.NewLine
      
      ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
      ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      For Each sLine In ssSpli
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If sLine = "" Or sLine Begins "#" Then
          '...
        Else 
          ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
          sColorName = ssSpliLine[0]
          sHex = ssSpliLine[2]  ''Example: "F0F8FF"
          sHex = Replace(sHex, "#", "")
          sHex = Replace(sHex, "&H", "")
          sHex = Replace(sHex, "&", "")
          
          ssBG = New String[] 
          ssBG.Resize(F_iColumn12Sort)
          If iTable > 2 Then ssBG[iTable] = Space(1) & "bgcolor=#" & "F1F1F1"
          
          sHex = "#" & sHex
          ' sRGB = ssSpliLine[2]
          
          ''..................................
          sDezi = ssSpliLine[4]
          ''..................................
          
          If IsInteger(sDezi) = True Then 
            iRGB = CInteger(sDezi)
            hColorInfo = Color[iRGB]
            iR = hColorInfo.Red
            iG = hColorInfo.Green
            iB = hColorInfo.Blue
            ' iA = hColorInfo.Alpha 
            sRGB = Str(iR) & "," & Str(iG) & "," & Str(iB) 
            sDezi = Str(hColorInfo.Color)
            sLumi = hColorInfo.Luminance
            If hColorInfo.Luminance < 150 Then 
              sColorNameFG = "<font color=white>" & sColorName & "</font>" 
            Else 
              sColorNameFG = "<font color=black>" & sColorName & "</font>"
            Endif 
            sSatu = hColorInfo.Saturation
            sHue = hColorInfo.Hue 
            iCounter = iCounter + 1
            ''Example: "Green=008000=0,128,0=32768="
            sHTML &= "<tr>" & gb.NewLine
            sHTML &= "<td colspan=0 align=right valign=top>" & Str(iCounter) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=1 align=left valign=top bgcolor=" & sHex & ">" & sColorNameFG & "</td>" & gb.NewLine
            sHTML &= "<td colspan=2 align=left valign=top bgcolor=" & sHex & ">" & sHex & "</td>" & gb.NewLine
            sHTML &= "<td colspan=3 align=left valign=top" & ssBG[3] & ">" & sRGB & "</td>" & gb.NewLine
            sHTML &= "<td colspan=4 align=right valign=top" & ssBG[4] & ">" & sDezi & "</td>" & gb.NewLine
            sHTML &= "<td colspan=5 align=right valign=top" & ssBG[5] & ">" & sLumi & "</td>" & gb.NewLine
            sHTML &= "<td colspan=6 align=right valign=top" & ssBG[6] & ">" & sSatu & "</td>" & gb.NewLine
            sHTML &= "<td colspan=7 align=right valign=top" & ssBG[7] & ">" & sHue & "</td>" & gb.NewLine
            sHTML &= "<td colspan=8 align=right valign=top" & ssBG[8] & ">" & Str(iR) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=9 align=right valign=top" & ssBG[9] & ">" & Str(iG) & "</td>" & gb.NewLine
            sHTML &= "<td colspan=10 align=right valign=top" & ssBG[10] & ">" & Str(iB) & "</td>" & gb.NewLine
            sHTML &= "</tr>" & gb.NewLine
            
            sLine = sColorName & "=" & String.LCase(sColorName) & "=" & sHex & "=" & Quote(sRGB) & "=" & sDezi & "=" & sLumi & "=" & sSatu & "=" & sHue & "=" & Str(iR) & "=" & Str(iG) & "=" & Str(iB) & "=" & gb.NewLine 
            If iTable = 0 Then sText2 &= sLine
          Endif 
        Endif 
      Next
      sHTML &= "</table>" & gb.NewLine
      sHTML &= "<br>" & gb.NewLine
      sHTML &= sInfo
    Next 'iTable
    
    ''............................................................
    
    sHTML &= "</body>" & gb.NewLine
    sHTML &= "</html>" & gb.NewLine
    
    If F_bESCpressedON = True Then Return 
    
    ''Save:
    sText2 = sTitle & sText2
    sTextTXT = sText2
    File.Save(sDirFile, sTextTXT)
    
    sTextCSV = Replace(sText2, "|", gb.Tab)
    sTextCSV = Replace(sTextCSV, "=", gb.Tab) & gb.NewLine 
    sTextCSV &= gb.NewLine 
    sTextCSV &= Replace("Name0|name1|Hexadezimal2|RGB(0+0+0)3|Dezimal4|Luminance5|Saturation6|HUE7|Red8|Green9|Blue10|", "|", gb.Tab) & gb.NewLine 
    sTextCSV &= Replace("Farb-Name|abc|Hexadezimal|RGB(0+0+0)|Dezimal|Helligkeit|Sättigung|HUE|Rot|Grün|Blau-Anteil|", "|", gb.Tab) & gb.NewLine 
    sTextCSV &= gb.NewLine
    sTextCSV &= Replace("#" & sInfo, "<br>", gb.NewLine)
    sTextCSV = Replace(sTextCSV, gb.NewLine, gb.CrLf) ' Chr$(13) & Chr$(10) = "\r\n"  ->windows + linux (read)
    
    ''File Format  *.csv
    File.Save(File.SetExt(sDirFile, "csv"), sTextCSV) 'Office Calc Table"
    
    ''sDirFile:
    ''Example line: "AliceBlue=F0F8FF=240,248,255=15792383="
    
    ''File Format *.htm
    File.Save(sDirFileHTML, sHTML)
    ''Example line: "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    
    ''Show:
    ''Yellow=yellow=#FFFF00=255,255,0=16776960=226=255=60=255=255=0==
    ' Print sText
    Desktop.Open(sDirFileHTML)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotoImageAdd(Optional Img As Image = Null)
  
  If Img Then 
    If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
    F_ooUndoRedoPhoto.Add(Img) '(Img, 1)
    ListBackupCounter1.Text = F_ooUndoRedoPhoto.Count & Space(1) & ("von") & Space(1) & F_ooUndoRedoPhoto.Count
    ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
    F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotosPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim Img As Image
  
  If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer - 1
      
    Case "r", "redo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer + 1
      
    Case "m", "max"
      F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      
    Case "s", "select"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoPhotosPointer < 0 Then F_iUndoRedoPhotosPointer = -1
  If F_iUndoRedoPhotosPointer > F_ooUndoRedoPhoto.Max Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  
  If F_iUndoRedoPhotosPointer > -1 Then 
    Img = F_ooUndoRedoPhoto[F_iUndoRedoPhotosPointer] 'Object Image
    PicturePhoto.Picture = Img.Picture
  Else 
    PicturePhoto.Picture = Null
  Endif 
  
  ' If PicturePhoto.Picture Then 
  '   ImageViewPhoto.Update(Img) 
  ' Else 
  '   ImageViewPhoto.Update(PicTemplateQuestion256.Picture.Image.Stretch(Screen.W, Screen.H))
  ' Endif 
  
  PicBoxZoomLupe.Picture = PicturePhoto.Picture
  
  ListBackupCounter1.Text = Str(F_iUndoRedoPhotosPointer + 1) & Space(1) & ("von") & Space(1) & Str(F_ooUndoRedoPhoto.Max + 1)
  ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
  SideG2(2)
  If Not PicturePhoto.Picture Then LabelInfo2.Text = ("Fehlt: Bildschirm-Foto") Else LabelInfo2.Text = ("Info") 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PasteTextBoxColor(Optional sFind As String = Null)
  
  Dim iColor, iRed, iGreen, iBlue, iAlpha, iFound As Integer
  Dim ssSpliLine As String[]
  Dim sLine, sDezi, sValue As String
  Dim hColorInfo As ColorInfo
  Dim sAlpha As String
  
  'sGrad = "°" 'sGrad = chr(176) 'ASCCI only 0 > 128
  
  If Not sFind Then 
    If Clipboard.Type = Clipboard.Text Then 
      sFind = Clipboard.Paste("text/plain")
      ' Wait 0.3
      If Not sFind Then 
        sFind = Clipboard.Paste()
        ' Wait 1
      Endif 
    Endif 
  Endif 
  
  If Not F_ssColorNames Then LoadColorNames()
  
  iFound = -1
  If F_ssColorNames Then 
    sFind = UnQuote(sFind)
    sValue = "*=" & sFind & "=*"
    iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
    If iFound > -1 Then Goto JumpSelect
    
    ''RGB(0,0,0)
    If String.InStr(sFind, ",") > 0 Then ssSpliLine = Split(sFind & String(3, ","), ",")
    If String.InStr(sFind, Space(1)) > 0 Then ssSpliLine = Split(sFind & String(3, Space(1)), Space(1))
    If ssSpliLine Then 
      If IsInteger(ssSpliLine[0]) = True Then iRed = CInteger(ssSpliLine[0])
      If IsInteger(ssSpliLine[1]) = True Then iGreen = CInteger(ssSpliLine[1])
      If IsInteger(ssSpliLine[2]) = True Then iBlue = CInteger(ssSpliLine[2])
      If IsInteger(ssSpliLine[3]) = True Then iAlpha = CInteger(ssSpliLine[3])
      iColor = Color.RGB(iRed, iGreen, iBlue, iAlpha)
      sValue = "*" & Str(iColor) & "*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    sFind = Replace(sFind, Space(1), "")
       
    ''&H00F0F8FF&, #F0F8FF, F0F8FF
    If IsHexa(sFind) Or String.InStr(sFind, "&") > 0 Or String.InStr(sFind, "#") > 0 Then 
      sValue = Replace(sFind, "&H00", "")
      sValue = Replace(sValue, "&H", "")
      sValue = Replace(sValue, "&", "")
      sValue = Replace(sValue, "#", "")
      If IsInteger(sValue) = False And IsHexa(sValue) Then 
        ''Hexa: 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
        iColor = CInteger(Val("&H" & sValue))
        sValue = "*" & Str("&H" & sValue) & "*"
        iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
        If iFound > -1 Then Goto JumpSelect
      Endif 
    Endif
    
    ''0123456789
    If IsDigit(Str(sFind)) Then 
      sValue = sFind
      If IsInteger(sValue) = True Then iColor = CInteger(sValue)
      sValue = "*=" & Str(iColor) & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''Abc...
    If IsAscii(Str(sFind)) And IsInteger(sFind) = False Then 
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsHexa(sValue) Then 
        iColor = CInteger(Val("&H" & sValue))
        ' sValue = String.Right(sValue, 6)
        sValue = "*=" & Str(iColor) & "=*"
        iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
        If iFound > -1 Then Goto JumpSelect
      Endif 
    Endif
    
    ''0123456789
    If IsInteger(sFind) Then 
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsInteger(sValue) Then iColor = CInteger(sValue)
      sValue = "*=" & sValue & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''ABCabc..
    If IsLetter(sFind) Then 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
      If String.Len(sFind) > 6 Then sValue = String.Right(sFind, 8) Else sValue = sFind
      If IsHexa(sValue) Then iColor = CInteger(Val("&H" & sValue))
      sValue = "*" & sValue & "=*"
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
    
    ''Hexa: 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
    If IsHexa(sFind) Then  'not IsHexa(...)=True
      sValue = "*=" & sFind & "=*" 
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
      sValue = Replace(sFind, "&H", "")
      sValue = Replace(sValue, "&", "")
      If IsInteger(sValue) = True Then 
        iColor = CInteger(sValue)
      Else
        If IsHexa(sValue) Then iColor = CInteger(Val("&H" & sValue))
      Endif 
      ' If String.Len(sValue) > 6 Then sValue = String.Right(sValue, 6) ''#00FF00
      sValue = "*=" & iColor & "=*" 
      iFound = F_ssColorNames.Find(sValue, gb.Like) '-1 not found 
      If iFound > -1 Then Goto JumpSelect
    Endif
  Endif 
  
JumpSelect:
  If iFound > -1 Then 
    sLine = F_ssColorNames[iFound] 
    ''Example line: "AliceBlue=aliceblue=F0F8FF=240,248,255=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
    If sLine Then 
      sLine = Replace(sLine, Space(1), "")
      ssSpliLine = Split(sLine & String(F_iColumns14Count, "="), "=")
      ' sColorName = ssSpliLine[0]
      ' sColorNameLower = ssSpliLine[1]
      ' sHex = ssSpliLine[2]
      ' sRGB = ssSpliLine[3]
      sDezi = ssSpliLine[4]
      If IsInteger(sDezi) = True Then 
        iColor = CInteger(sDezi)
        ColorChooser2.SelectedColor = iColor
      Endif 
    Endif 
  Else If IsInteger(Str(iColor)) = True Then 
    ColorChooser2.SelectedColor = iColor
  Else 
    TextBoxHTML.SelectAll()
    TextBoxHTML.Insert(("Kein Farb-Format erkannt") & ": " & gb.NewLine)
    TextBoxDezi.SelectAll()
    TextBoxDezi.Insert("0")
    TextBoxHexa.SelectAll()
    TextBoxHexa.Insert("&H")
    TextBoxHexaHTML.SelectAll()
    TextBoxHexaHTML.Insert("#")
    ' ColorChooser2.SelectedColor = iColor
  Endif  
  
  hColorInfo = Color[ColorChooser2.SelectedColor]
  iAlpha = hColorInfo.Alpha 'Transparent
  If iAlpha > 0 Then sAlpha = " +" & Str(iAlpha) & Space(1) & ("Alpha=Glas=transparenter Anteil") 
  
  LabelInfo2.Text = ("Auswahl") & ": " & String.Left(sFind, 20) & sAlpha
  LabelInfo2.Tooltip = ("Auswahl") & ": " & String.Left(sFind, 200) & sAlpha
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnView2SortReturnText(Optional iSort As Integer = 0) As String
  
  Dim sKey, sText As String 
  Dim M As Integer = -1
  Dim it, it2, iLine, iNumber As Integer
  
  If ColumnView2.Columns.Max < F_iColumns14Count Then '|0|1|2|3|4|5|6|7|8|9|10|11|12|13| 
    ColumnView2.Clear
    ReadG2()
    ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
  Endif 
  If iSort < 0 Then iSort = 0 
  If iSort > ColumnView2.Columns.Max Then iSort = ColumnView2.Columns.Max
  
  If ColumnView2.Columns.Count >= F_iColumns14Count Then 
    ColumnView2.Sorted = False            ' sortieren
    ' ColumnView2.Columns.Ascending = True ' A —▶ Z
    For Each sKey In ColumnView2.Keys
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView2[sKey][F_iColumn12Sort] = ColumnView2[sKey][iSort]
      If IsInteger(ColumnView2[sKey][F_iColumn12Sort]) = True Then 
        iNumber = ColumnView2[sKey][F_iColumn12Sort]
        ColumnView2[sKey][F_iColumn12Sort] = Format(iNumber, String(11, "0"))
      Else If IsHexa(Replace(ColumnView2[sKey][F_iColumn12Sort], "#", "")) Then  'without = TRUE!
        ColumnView2[sKey][F_iColumn12Sort] = Replace(ColumnView2[sKey][F_iColumn12Sort], "#", "")
      Endif 
    Next
    ColumnView2.Sorted = True
    ' ColumnView2.Columns.Sort = 0
    ' ColumnView2.Columns.Sort = ColumnView2.Columns.Max '12
    ''...........................................
    ColumnView2.Columns.Sort = F_iColumn12Sort 'Sortiert nach Spalte   0|1|2|3|4|5|6|7|8|9|10|11|12|...
    ''...........................................
    
    sText = Null
    M = ColumnView2.MoveFirst()
    ' For Each sKey In ColumnView2.Keys
    For it = 1 To ColumnView2.Count - 1
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If it = 0 Then 
        M = ColumnView2.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
      Else 
        M = ColumnView2.MoveBelow() '▼down
      Endif 
      If M = 0 Then 
        sKey = ColumnView2.Item.Key 'Gambas3: "Returns the item pointed by the internal cursor, or NULL if the internal cursor is not available."
        ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
        For it2 = 1 To ColumnView2.Columns.Max
          sText &= ColumnView2[sKey][it2] & "="
        Next  
        sText &= gb.NewLine
      Endif  
    Next 
    Print sText 
    ' File.Save(sDirFile, sText)
  Endif 
  
  Return sText 
  
Catch
  FMain.ErrorText
  
End

Public Sub SearchPasteG()

  Dim sText As String
  
  If Clipboard.Type = Clipboard.Text Then sText = Clipboard.Paste("text") ' "text/plain"
  If Not sText Then 
    LabelCopyExample.Text = "[Zwischenablage]" & ": " & ("Leer")
    sText = TextBoxColorName.Text 
  Else 
    LabelCopyExample.Text = "[Zwischenablage]" & ": " & ("Eingefügt")
  Endif
  TextAreaSearch.SelectAll()
  TextAreaSearch.Insert(sText)
  LabelBgSearch.Background = Color.White
  LabelBgSearch.Text = ""
  
  Catch 
  FMain.ErrorText
  
End

Public Sub WebView1_Select() 
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    LabelInfo2G(WebView1.SelectedText)
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(WebView1.SelectedText)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub AplusG()
  
  If ColumnView2.Font.Size < 16 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
    WebView1.Zoom = 1 ' 1=100%
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
    WebView1.Zoom = 1.5 ' 1=100%
  Endif 
  
  ''Text-Height:
  
  LabelInfo2.Font.Size = ColumnView2.Font.Size
  TextBoxHTML.Font.Size = ColumnView2.Font.Size
  TextAreaText.Font.Size = ColumnView2.Font.Size
  TextAreaCode.Font.Size = ColumnView2.Font.Size
  LabelCopyImageInfo.Font.Size = ColumnView2.Font.Size
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup2_Click()

  Select Case Last.Tag
    Case "webback"
      WebView1.Back() ''◀—
      LabelCopyExample.Text = ("-1x Rückwärts")
    Case "webforward"
      WebView1.Forward() ''—▶
      LabelCopyExample.Text = ("+1x Vorwärts")
    Case "webcode"
      SideG2(7) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      LabelCopyExample.Text = ("Quell-Text")
    Case "webcopyall"
      Clipboard.Clear
      Clipboard.Copy(WebView1.Document.HTML)
      If Clipboard.Type = Clipboard.Text Then 
        LabelCopyExample.Text = ("Kopie in der [Zwischenablage]") & ": " & String.Left(Clipboard.Paste("text/plain"), 300) 
      Else 
        LabelCopyExample.Text = ("Kopie in der [Zwischenablage]") & ": " & ("Fehlt") & Space(1) & ("(noch)")
      Endif 
    Case "webreload"
      WebView1.Reload()
      LabelCopyExample.Text = ("1x Neu geladen (Reload)")
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup2_Click()
  
  If Object.Type(Last) <> "PictureBox" Then ButtonGroup2Select(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup2_Enter()
  
  Select Case Last.Tag
    Case ArrowR.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True 
      PanelColor.Background = F_iColorGreenAlpha220
    Case PicBoxMemoryColors.Tag
      Last.Background = F_iColorGreenAlpha150
      PanelMemoryColors.Background = F_iColorGreenAlpha220
    Case ButtonCancelMemoryColors.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True 
    Case PicBoxResetstart.Tag 
      Last.Background = F_iColorGreenAlpha150
      PanelColorBackground.Background = F_iColorGreenAlpha150
    Case PicBoxColorsUndo.Tag, PicBoxColorsRedo.Tag
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxOpenColors.Tag 
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxSaveColors.Tag 
      Last.Background = F_iColorGreenAlpha150
      ScrollViewMemoryColors.Background = F_iColorGreenAlpha150
    Case PicBoxPlus.Tag, PicBoxWebColorNamesSort.Tag, PicBoxColumnviewColorNamesFind.Tag, PicBoxColorChooser.Tag
      Last.Background = F_iColorGreenAlpha150
      PanelColor.Background = F_iColorGreenAlpha220
    Case ButtonSearch.Tag, ButtonSearchBack.Tag, ButtonCancelWebTextCode.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True
    Case WindowT5plus.Tag
      Last.Background = F_iColorGreenAlpha150
      Last.Border = True
    Case Else 
      Last.Background = F_iColorGreenAlpha150
  End Select

Catch 
  FMain.ErrorText
  
End 

Public Sub ButtonGroup2_Leave()
  
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
  PicBoxColorApplyTop.Background = PicBackground.Background
  
  Select Case Last.Tag
    Case ArrowR.Tag
      Last.Background = Color.Default 
      Last.Border = False 
      PanelColor.Background = Color.Default
    Case ButtonCancelMemoryColors.Tag
      Last.Background = Color.Default
      Last.Border = True 
    Case PicBoxResetstart.Tag 
      Last.Background = Color.Default 
      PanelColorBackground.Background = Color.Default
    Case PicBoxColorsRedo.Tag, PicBoxColorsRedo.Tag 
      Last.Background = Color.Default 
    Case PicBoxOpenColors.Tag 
      Last.Background = Color.Default 
    Case PicBoxOpenColors.Tag 
      Last.Background = Color.Default
    Case PicBoxSaveColors.Tag 
      Last.Background = Color.Default
    Case PicBoxPlus.Tag, PicBoxWebColorNamesSort.Tag, PicBoxColumnviewColorNamesFind.Tag, PicBoxColorChooser.Tag
      Last.Background = Color.Default
      PanelColor.Background = Color.Default
    Case ButtonSearch.Tag, ButtonSearchBack.Tag, ButtonCancelWebTextCode.Tag
      Last.Background = Color.Default
      Last.Border = True
    Case WindowT5plus.Tag
      If F_iLastSide = 6 Then Last.Background = Color.Green Else Last.Background = Color.Default
      Last.Border = True
    Case Else 
      Last.Background = Color.Default 
  End Select
  
  If PicturePhoto.Visible = True Then   'PicBoxScreenshot
    PicBoxPickerColor.Background = Color.Green
  Else 
    PicBoxPickerColor.Background = Color.Default 
  Endif 
  If PanelMemoryColors.Visible = True Then 
    PicBoxMemoryColors.Background = Color.Green 
  Else 
    PicBoxMemoryColors.Background = Color.Default 
  Endif 
  PanelMemoryColors.Background = Color.Default 
  ScrollViewMemoryColors.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup2_MouseDown()
  
End

Public Sub ButtonGroup2_MouseUp()
  
  If Object.Type(Last) = "PictureBox" Or Object.Type(Last) = "Label" Then ButtonGroup2Select(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup2_MouseWheel()
  
  If Last.Tag = LabelZoom2.Tag Or Last.Tag = PicBoxPickerColor.Tag Then 
    ZoomHasFocus(Mouse.Forward)   '.Forward as Boolean True/False
    ZoomLupeG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup2Select(Optional sLastTag As String, Optional sMouseLMR As String = "left")
  
  'Reset
  F_bESCpressedON = False
  IconError.Visible = False ''Reset
  sMouseLMR = String.Left(sMouseLMR, 1)
  sLastTag = String.LCase(sLastTag)
  TimerZoomLupe.Stop()
  ' PanelColor.Visible = True 
  
  Select Case sLastTag
    ' Case "color", "colormemory"
    '   If PanelGallery.Visible = True Or PanelMuster.Visible = True Then 
    '     SideG("colormemory")
    '   Else 
    '     SideG("gallery")
    '   Endif 
    Case "memorycolors", ButtonCancelMemoryColors.Tag
      PanelColor.Visible = False
      If CheckColorsChangeMessage() = False Then 
        If PanelGallery.Visible = True Then 
          SideG("gallery")
        Else 
          SideG("muster")  
        Endif 
      Else 
        'only cancel Message
      Endif 
      
    Case "menucolorcancel", ButtonCancel.Tag
      If CheckColorsChangeMessage() = False Then 
        If PanelGallery.Visible = True Then 
          SideG("gallery")
        Else 
          SideG("muster")  
        Endif 
      Else 
        'only cancel Message
      Endif 
      
    Case "aplus" 'A+, A-
      If ColumnView2.Font.Size < 16 Then 
        ColumnView2.Font.Size = 16 
      Else 
        ColumnView2.Font.Size = 12
      Endif 
      Settings[F_sForm &/ "ColumnView2.Font.Size"] = ColumnView2.Font.Size
      AplusG()
      
    Case "undophoto"
      If sMouseLMR = "r" Then F_iUndoRedoPhotosPointer = -1
      UndoRedoPhotosPointer("undo")
    Case "redophoto"
      If sMouseLMR = "r" And F_ooUndoRedoPhoto Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      UndoRedoPhotosPointer("redo")
    Case "undoredomax"
      UndoRedoPhotosPointer("max")
      
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "labelzoom"
      F_fZoomFactor = 10
      ' LabelZoomTextG()
      ZoomLupeG()
      TimerZoomLupe.Start()
    
    Case "photo"
      SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' F_fZoomFactor = 4
      PhotoG()
      
    Case "sidephoto"
      SidePhotoG()
      
    Case "colorchooser"
      ' If ColorChooser2.Visible = False Then 
        SideG2(1)
      ' Else 
      '   SideG2(F_iLastSideBefore) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' Endif
      
    Case "colorpicker"
      F_imgScreen = Null
      PhotoColorPickerG()
      
    Case "copyimage"
      CopyButtonG() 
      
      ' Case "copyimagezoom"
      '   CopyButtonG("zoom") 
      
    Case PicBoxWebColorNamesSort.Tag 'HTML Webview1
      ' If PanelWebTextCode.Visible = False Then 
        SideG2(4) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' Else 
      '   SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' Endif 
      
    Case PicBoxColumnviewColorNamesFind.Tag
      ' If ColumnView2.Visible = False Then 
        SideG2(3) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
        'Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        'Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
      ' Else 
      '   SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ' Endif
      
    Case ButtonCancelWebTextCode.Tag
        SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7  
      
    Case "cancelcopyimage"
      PanelCopyImage.Visible = False 
      
    Case PicBoxColorMemoryTop.Tag
      If ScrollViewMemoryColors.ScrollX = 0 Then ScrollViewMemoryColors.ScrollX = ScrollViewMemoryColors.ScrollW Else ScrollViewMemoryColors.ScrollX = 0
      PicBoxColorMemoryTop.Picture = PicBoxColorMemoryTop.Picture.Image.Mirror(True, False).Picture '(Horizontal, -Vertikal-)
      
    Case "dirfile" 
      M01Functions.FileManagerOpen(FilePathForm()) 'Path or "" Null
      
    Case "apps" 'Apps
      M01Functions.SystemStandardApplications() 'System Info
      
    Case "trashopen"
      M01Functions.ExternTrash()
      
    Case "photoform"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "menu"
      MenuDatei2.Popup()
      
    Case "savepicture"
      SideG2(2)
      SaveG2()
      
    Case "clipboardimagepaste", mnuClipboardImagePaste.Tag 
      SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      ClipboardImagePaste()
      
    Case "pastepictureopen", mnuPastePictureOpen.Tag
      PastePictureOpen()
      
    Case PicBoxPlus.Tag, "plus" '+
      Settings[F_sForm &/ "F_iLastColor"] = ColorChooser2.SelectedColor
      SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "wood"
      F_sBackgroundColorOrPath = sLastTag
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo2.Text = PicBoxWoodTop.Tooltip
      
    Case "metal"
      F_sBackgroundColorOrPath = sLastTag
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo2.Text = PicBoxMetalTop.Tooltip
      
    Case "colorapply" 'Apply + Return to Form
      F_sBackgroundColorOrPath = ColorChooser2.SelectedColor
      Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
      FormBackgroundColor()
      If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
      CheckFormBackgroundColor()
      LabelInfo2.Text = PicBoxColorApplyTop.Tooltip
      
    ' Case "reset" '0 Reset Color
    '   F_sBackgroundColorOrPath = "wood"
    '   Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath 'Path or Color
    '   FormBackgroundColor()
    '   If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then ButtonApply.Background = Color.SoftRed
    '   CheckFormBackgroundColor()
      
    Case "resetstart", PicBoxResetstart.Tag
      PhotoColorPickerLatest("reset")
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "apply"
      Select Case Message.Question("<h2><font color=darkgreen>" & ("Hintergrund übernehmen?") & "</font>" & "</h2>", ("Nein"), ("Neuer Fenster-Hintergrund"), ("Abbrechen")) 
        Case 1
          ' ColorChooser1.SelectedColor = PicBoxPickerColor2.Background ' F_iColorPicker
          ' ApplyIconColorG()
          
          ButtonApply.Visible = False
        Case 2
          ApplyG()
          CheckFormBackgroundColor()
          ButtonApply.Visible = False
        Case 3
          ''Cancel
      End Select
      
    Case "hidecolorchooser"
      If ColorChooser2.Visible = True Then 
        SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
        If Not PicturePhoto.Picture Then PicturePhoto.Picture = PicBoxPhoto2.Picture
      Else 
        SideG2(1) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      Endif 
      
    Case PicBoxMemoryColors.Tag 'On-Off
      F_bMemoryColorsPanelON = Not F_bMemoryColorsPanelON
      Settings[F_sForm &/ "F_bMemoryColorsPanelON"] = F_bMemoryColorsPanelON
      Form_Resize()
      ' If F_bMemoryColorsPanelON = False And F_bPanelColorsChanged = True Then TimerPanelColorsChange.Start()
      ' ApplyIconColorG()
      TimerPanelColorsChange.Start()
      
    Case PicBoxResetMemoryColors.Tag 
      ColorOpenSaveStandardG("reset")
      
    Case PicBoxOpenColors.Tag 
      ColorOpenSaveStandardG("open")
      
    Case PicBoxSaveColors.Tag 
      ColorOpenSaveStandardG("save")
    
    Case PicBoxColorsUndo.Tag
      UndoRedoColorsPointer("undo")
    
    Case PicBoxColorsRedo.Tag
      UndoRedoColorsPointer("redo")
      
    Case "textareatext", "text5resize"
      If F_iLastSide <> 6 Then SideG2(6) Else SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
      
    Case "textareacode"
      If F_iLastSide <> 7 Then SideG2(7) Else SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7

    Case PicBoxSearchPaste.Tag
      SearchPasteG()
      
    Case "searchdown"
      SearchText("+")
      
    Case "searchup"
      SearchText("-")
    
    ' Case "refreshsum", PicBoxRefreshSum2.Tag
    '   ScrollViewLevels.Background = LabelTemplateClockColor.Background
    '   SumPaintClockLevels()
    '   SynchronizeLevelsToGallery()
    '   Wait 0.3
    '   ScrollViewLevels.Background = Color.Default
  
    Case "galleryreset", PicBoxGalleryReset.Tag, PicBoxRefreshSum2.Tag, "colorapply"
       TimerPanelColorsChange.Start()
  
    Case "cancelcolumnview4", ButtonCancelColumnView4.Tag
      PanelColumnView4.Visible = False 
      Form_Resize()
    Case "close", "cancelform", ButtonCancel.Tag  '×
      Me.Close
      
  End Select 
  
  If ColorChooser2.Visible = True Then ArrowR.Picture = PicTemplateArrowR.Picture Else ArrowR.Picture = PicTemplateArrowL.Picture
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End 

Public Sub PhotoScreen() 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  
  Dim imgScreen As Image
  Dim picScreen As Picture
  
  TimerZoomLupe.Stop()
  Me.Window.Visible = False 
  
  Wait 0.3
  '**********************************************
  ' picScreen = Desktop.Screenshot() 'as Picture!
  picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  If picScreen Then imgScreen = picScreen.Image
  '**********************************************
  
  ''Missing? Alternative:
  If M01Functions.ScreenshotImageExist(imgScreen) = False Then 
    imgScreen = M01Functions.ScreenshotImageAlternative()
    If Not imgScreen Then imgScreen = M01Functions.ScreenshotImageDemo(PicBackground.ScreenX, PicBackground.ScreenY, PicBackground.W, PicBackground.H)
    ' ZoomArea()
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  If imgScreen Then 
    F_picScreen = imgScreen.Picture
    ' F_imgScreen = imgScreen.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicturePhoto.Picture = F_picScreen
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
  Endif 
  Me.Window.Visible = True 
  F_imgScreen = Null 'Reset
  TimerZoomLupe.Start()
  
Catch 
  FMain.ErrorText
  Me.Window.Visible = True 
  
End 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Public Sub TimerZoomLupe_Timer()
  '.Delay = 100 ?     1000=1sec.
  
  ''Pick Color:
  ' If PicturePhoto.Visible = True Then   'PicBoxScreenshot
  If PicturePhoto.Visible = True Then 
    PicBoxPickerColor.Background = Color.Green 
    PicBoxZoomLupe.Visible = True 
    ZoomArea()
  Else 
    ' TimerZoomLupe.Stop()
    PicBoxPickerColor.Background = Color.Default
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyButtonG(Optional sFullOrZoom As String = "full")
  
  Dim Img As Image
  
  Select Case sFullOrZoom
    Case "full"
      If PicturePhoto.Picture Then Img = PicturePhoto.Picture.Image
    Case "zoom"
      ' If PicBoxZoomLupe.Picture Then Img = PicBoxZoomLupe.Picture.Image.Copy(Mouse.ScreenX - F_iX1 - (PanelColorZoom.W / 2), F_iY1 - Mouse.ScreenY - (PanelColorZoom.H / 2), PanelColorZoom.W, PanelColorZoom.H)
      ' PicturePhoto.Picture = Img.Picture 
      If PicturePhoto.Picture Then Img = PicturePhoto.Picture.Image
  End Select
  
  If Img Then 
    Clipboard.Clear() 'no longer?
    ' '??? libpng error: Read Error
    Wait 0.5
    Clipboard.Copy(Img) 'Copy In Clipboard(Zwischenablage)
  Endif 
  
  Img = Null
  Img = M01Functions.ClipboardImage() 'as Image
  ' If M01Functions.ClipboardImageExist() = False Then Img = ""
  
  If Img Then 
    ' If Clipboard.Type = Clipboard.Image Then
    ' PicBoxCopyImage.Picture = Img.Picture
    ImageView1.Update(Img)  
    ImageView1.ZoomFit()
    ' ImageView1.Zoom = 1
    If sFullOrZoom = "full" Then
      LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & Img.W & " x " & Img.H & " px"
      ' PicBoxCopyImage.Stretch = True 
    Else 
      LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & Img.W & " x " & Img.H & " px"
      ' LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild vorhanden") & gb.NewLine & ("Zoom") & Space(1) & F_fZoomFactor & "x, " & Img.W & " x " & Img.H & " px"
      ' PicBoxCopyImage.Stretch = False 
    Endif 
    LabelCopyImageInfo.Foreground = Color.Blue
  Else
    PicBoxCopyImage.Picture = Null 'Picture[""] 'sichtbar leeren
    LabelCopyImageInfo.Text = ("[Zwischenablage] = Bild fehlt")
    LabelCopyImageInfo.Foreground = Color.Red
  Endif
  PanelCopyImage.Visible = True 
  PanelCopyImage.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFontForeground()
  '■=■ > □=■
  ''Example: Black-Foreground-Font in Black-Background = no visible —▶ more difference in Color
  
  If M01Functions.ColorInfoRGB(F_iColorPicker, "L") < 150 And M01Functions.ColorInfoRGB(F_iColorPicker, "A") < 150 Then LabelInfo2.Foreground = Color.White Else LabelInfo2.Foreground = Color.Black
  
  If F_iColorPicker = Color.Default Or F_iColorPicker = Color.Transparent Then LabelInfo2.Foreground = Color.Black
  ' LabelZoom.Foreground = LabelInfo2.Foreground
  
Catch 
  FMain.ErrorText 
  
End

Public Sub ZoomArea()
  
  If Not F_picScreen Then
    If PicturePhoto.Picture Then 
      F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
      F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
      PicBoxZoomLupe.Picture = F_picScreen
    Endif 
  Endif 
  
  If F_picScreen Then    
    ' If Not F_imgScreen Then 
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    If String.LCase(Desktop.Platform) = "wayland" Then 
      F_fX1 = Mouse.ScreenX - PanelBorder.Left 
      F_fY1 = Mouse.ScreenY - PanelBorder.Top ' Desktop.Y '= Screens[0].AvailableY = 0
    Else 'If String.LCase(Desktop.Platform) = "x11" Then 
      F_fX1 = Mouse.ScreenX - PanelBorder.ScreenX
      F_fY1 = Mouse.ScreenY - PanelBorder.ScreenY ' Desktop.Y '= Screens[0].AvailableY = 0
    Endif 
    
    ''Pick Color Pixel-Point:
    F_iColorPicker = F_imgScreen[F_fX1, F_fY1] 'as Integer
    
    ZoomLupeG()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ZoomLupeG()
  
  PicBoxZoomLupe.Move((-F_fX1 * F_fZoomFactor) + (PanelColorZoom.W / 2), (-F_fY1 * F_fZoomFactor) + (PanelColorZoom.H / 2), PicturePhoto.W * F_fZoomFactor, PicturePhoto.H * F_fZoomFactor)
  F_rectZoom = Rect(PicBoxZoomLupe.Left, PicBoxZoomLupe.Top, PicBoxZoomLupe.W, PicBoxZoomLupe.H)
  ZoomImage()

Catch
  FMain.ErrorText
  
End

Public Sub ZoomImage()
  
  If Not PicturePhoto.Picture Then 
    LabelInfo2.Text = ("Fehlt: Bildschirm-Foto")
  Else  
    ''Refresh ColorPicker:
    ' If PicturePhoto.Visible = True Then 
    CursorFill()
    
    ''Show Color:
    LabelInfo2.Background = F_iColorPicker
    CheckFontForeground()
    
    LabelZoomTextG()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelZoomTextG()
  
  LabelZoom2.Text = ("Zoom") & Space(1) & Round(F_fZoomFactor, -1) & "x" & Space(1) & ("im Foto") & gb.NewLine & ("Maus-Rad - +")' Example Round —▶ 1.2
  LabelZoom2.Tooltip = LabelZoom2.Text & gb.NewLine & ("Klick=Reset: Zoom") & Space(1) & Str(F_fZoomFactor) & "x"
  
Catch
  FMain.ErrorText
  
End

Public Sub CursorFill()
  
  ''ColorPicker 'Change ●
  PicturePhoto.Cursor = New Cursor(PicBoxPickerColor.Picture.Image.Replace(Color.Black, F_iColorPicker).Picture, 0, 0) 'as Picture, x, y
  PicturePhoto.Mouse = Mouse.Custom '.Custom = -1, .Cross = 9
  
Catch
  FMain.ErrorText
  
End

Public Sub FormClose2()
  
  SettingsReadSave("save")                                                                'save
  CheckSaveG2()
  PhotoColorPickerLatest("save")
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckSaveG2() As Boolean
  
  Dim sMessage, sColorSquare As String  
  
  ' Path1 = "images/bg_aluminium1.png"
  ' Path2 = "images/bg_holz2.png"
  
  If F_sBackgroundColorOrPathEnter <> F_sBackgroundColorOrPath Then 
    If Not PicBackground.Picture Then sColorSquare = "<font size=7 color=#" & Hex(PicBackground.Background, 6) & ">" & "■" & "</font>" 
    sMessage = "<h2><font color=red>" & ("Speichern?") & "</font></h2>"
    sMessage &= "<h3>" & sColorSquare & Space(1) & "<font color=blue>" & ("Hintergrund") & ": " & ("Auswahl anwenden") & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("Speichern"), ("Nein"), ("Abbrechen"))
      Case 1 'Save
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPath   'Path or Color  
        Settings[FMain.Name &/ "ColorButton1.Value"] = PicBackground.Background
        
      Case 2, 3 'Reset, Cancel
        Settings[FMain.Name &/ "FormBackgroundColor"] = F_sBackgroundColorOrPathUndo   'Path or Color  
        Settings[FMain.Name &/ "ColorButton1.Value"] = F_iBackgroundColorEnter
        
    End Select
    
    M01Functions.FormsBackgroundColorAll()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxZoomLupe_MouseWheel()
  
  ZoomHasFocus(Mouse.Forward)   '.Forward as Boolean True/False
  
  ZoomLupeG()
  
Catch 
  FMain.ErrorText  
  
End

Public Sub PicBoxZoomLupe_MouseDown()
  
  Dim Img As Image
  
  If Mouse.Left Then 
    If PicBoxZoomLupe.Picture Then 
      Img = PicBoxZoomLupe.Picture.Image.Stretch(PicBoxZoomLupe.W, PicBoxZoomLupe.H)
      F_iColorPicker = Img[Mouse.X, Mouse.Y]
      ColorChooser2.SelectedColor = F_iColorPicker
      LabelInfo2.Background = F_iColorPicker
      CheckFontForeground()
      SideG2(1)
    Endif
  Endif 
  
  If Mouse.Right And PicBoxZoomLupe.Picture Then 
    ' Img = PicBoxZoomLupe.Picture.Image.Stretch(PicBoxZoomLupe.W, PicBoxZoomLupe.H)
    ' PicBoxCopyImage.Picture = Img.Picture '.Copy(Mouse.ScreenX - (PanelColorZoom.W / 2), Mouse.ScreenY - (PanelColorZoom.H / 2)).Picture
    CopyButtonG("zoom")
  Endif 
  
Catch 
  FMain.ErrorText  
  
End

Public Sub PhotoG()
  
  PhotoScreen()
  SideG2(2)
  TimerZoomLupe.Start()
  LabelInfo2.Text = ("Pipette: Einen Farbpunkt auswählen")
  ' PicturePhoto.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoColorPickerG()
  
  PanelCopyImage.Visible = False 
  ' PicturePhoto.Visible = True 
  PanelWebTextCode.Visible = False 
  ColumnView2.Visible = False
  ColorChooser2.Visible = False 
  
  If PicturePhoto.Visible = False Then 
    PicturePhoto.Visible = True
    If Not PicturePhoto.Picture Then PhotoScreen()
    TimerZoomLupe.Start()
    LabelInfo2.Text = ("Pipette: Einen Farbpunkt auswählen")
  Else 
    PicturePhoto.Visible = False
    ' TimerZoomLupe.Stop()
    ColorChooser2.Visible = True  
    ColorChooser2.SelectedColor = F_iColorPicker
    LabelInfo2.Text = ("Farbwahl nacharbeiten")
  Endif 
  ' If F_sForm21ColorsText Then LabelInfo2.Text &= gb.NewLine & F_sForm21ColorsText
  
Catch 
  FMain.ErrorText
  
End

Public Sub SidePhotoG(Optional sPhoto As String = "")
  
  PanelCopyImage.Visible = False
  PanelWebTextCode.Visible = False
  ColumnView2.Visible = False 
  ColorChooser2.Visible = False 
  
  If sPhoto = "photo" Or PicturePhoto.Visible = False Then 
    PicturePhoto.Visible = True
    PicturePhoto.Raise()
    TimerZoomLupe.Start()
  Else 
    PicturePhoto.Visible = False
    ColorChooser2.Visible = True 
    ' TimerZoomLupe.Stop()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClipboardImagePaste()
  
  Dim Img As Image
  Dim sPathScreenshot, sMessage As String
  
  'If Clipboard.Type = Clipboard.Image Then 'check, '0=empty, 1=Text, 2=Image, Clipboard.Text for some text, Clipboard.Image for an image.
  
  If Not Img Then Img = M01Functions.ClipboardImage()  'as Image
  sPathScreenshot = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", ""]
  If IsDir(File.Dir(sPathScreenshot)) = False Then M01Functions.CheckDirAppName(File.Dir(sPathScreenshot), False)
  If Not Img And Exist(sPathScreenshot) = True Then Img = Image.Load(F_sPathScreenphotoPNG)
  
  If Img Then 
    PicturePhoto.Picture = Img.Picture
  Else 
    Img = M01Functions.ScreenshotImageDemo()
    If Img Then PicturePhoto.Picture = Img.Picture
    LabelInfo2.Text = ("Fehlt: Bild aus der [Zwischenablage]")
    sMessage = "<h3><font color=red>" & ("Ohne Bild") & "</font></h3>"
    sMessage &= "<h3><font color=gray>" & ("Die [Zwischenablage] ist (noch) leer.") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif
  If PicturePhoto.Picture Then 
    F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub PastePictureOpen()
  
  Dim sPathFoto, sFilter1, sFilterText1 As String 
  Dim sPath, sDir As String
  Dim Img As Image
  
  'Beispiel--------------------------
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  'Dialog.Filter = ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .Save(JPG-Datei, Qualität 1 bis 100)
  
  sPathFoto = Settings[FMain.Name &/ "sPathFoto", sPathFoto]
  If Exist(sPathFoto) = True Then 
    sFilter1 = "*" & String.Left(File.BaseName(sPathFoto), 10) & "*." & File.Ext(sPathFoto)
    sFilterText1 = ("letzte Speicherung")
  Endif 
  If Exist(sPathFoto) = False Then 
    sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
    sPathFoto = sDir &/ ("BildDatei.png")
    sFilter1 = "*.png;*.jpg;"
    sFilterText1 = ("Bilder")
  Endif
  sPath = M01Functions.FileDialogOpen(sPathFoto, [sFilter1, sFilterText1, "*.jpeg;*.jpg;*.png;*.bmp;*.xpm;*.svg;", ("Bilder")], ("Einfügen aus Bild-Datei..."))
  If Exist(sPath) = True Then 'Null is Canceled
    PicturePhoto.Picture = Picture.Load(sPath)
    ' PhotoCutArea()
  Else 
    Img = M01Functions.ScreenshotImageDemo()
    If Img Then PicturePhoto.Picture = Img.Picture
    LabelInfo2.Text = ("Fehlt: Bild aus der Datei")
  Endif
  If PicturePhoto.Picture Then 
    F_picScreen = PicturePhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
    F_imgScreen = F_picScreen.Image.Stretch(PicturePhoto.W, PicturePhoto.H)
    PicBoxZoomLupe.Picture = F_picScreen
    UndoRedoPhotoImageAdd(PicturePhoto.Picture.Image)
    SideG2(2) 'iColor1_Photo2_ColumnV3_Web4_CopyImage5_Text6_Code7
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG2()
  
  Dim sPathBefore, sDirFile, sDir, sFile, sJPGQuality, sMessage As String
  Dim ssFilter As String[]
  
  F_sSaveFormat = Settings[Form15Foto.Name &/ "F_sSaveFormat", "png"]
  F_iSaveQualityJPG = Settings[Form15Foto.Name &/ "F_iSaveQualityJPG", F_iSaveQualityJPG]
  If F_sSaveFormat = "jpg" Then sJPGQuality = Space(1) & ("Komprimierung=") & F_iSaveQualityJPG & "%"
  
  ''Directory:
  sDir = Desktop.GetDirectory("PICTURES") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  If IsDir(sDir) = False Then 
    If IsDir(FMain.F_sDirAppName) = False Then FMain.F_sDirAppName = M01Functions.CheckDirAppName() 'as String
    sDir = FMain.F_sDirAppName
  Endif 
  
  ''New Name:
  sFile = ("BildschirmFoto") & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & "." & F_sSaveFormat
  sDirFile = sDir &/ sFile '"Bildschirmfoto~.tmp.png"
  sPathBefore = Settings[FMain.Name &/ "sPathFoto", sDirFile]
  
  'Dialog DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  ssFilter = New String[]
  
  ssFilter.Add("*" & "." & F_sSaveFormat) '"" Null > Error
  ssFilter.Add(("Neue Speicherung") & Space(1) & ("mit Name+Uhrzeit") & sJPGQuality) 'Text
  
  ssFilter.Add("*" & File.Name(sPathBefore)) 'Filter
  ssFilter.Add(("letzte Speicherung")) 'Text
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Heute") & Space(1) & Format(Now, "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Day, -1), "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Gestern") & Space(1) & Format(DateAdd(Date, gb.Day, -1), "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Monat") & Space(1) & Format(Now, "mmmm"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(Now, "yyyy"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Year, -1), "yyyy-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(DateAdd(Date, gb.Year, -1), "yyyy"))
  
  ssFilter.Add("*.jpg;*.jpeg")
  ssFilter.Add(("Format JPG") & sJPGQuality)
  
  ssFilter.Add("*.gif")
  ssFilter.Add(("Format GIF"))
  
  ssFilter.Add("*.bmp")
  ssFilter.Add(("Format BMP"))
  
  ssFilter.Add("*.xpm")
  ssFilter.Add(("Format XPM"))
  
  ssFilter.Add("*.png") 'Filter
  ssFilter.Add(("Format PNG")) 'Text
  'Dialog.Filter = ["*.png", ("Format PNG"), "*.jpeg", "Format JPG", "*.bmp", "Bitmap BMP", "*.gif", "Format GIF", "*.xpm", "Format XPM", "All files(*.*)"]
  Dialog.Filter = ssFilter '(*), All files wird autom. angehängt
  Dialog.Path = sDir &/ File.BaseName(sFile)
  Dialog.Title = (("Bild speichern..."))
  Dialog.AutoExt = True ''needs component: gb.form.dialog ' Datei.xyz xyz-Ext, extension automatically
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  'nicht abgebrochen,  speichern siehe unten  .Picture.Save
  sDirFile = Dialog.Path
  
  'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  
  If PicturePhoto.Picture Then 
    If LCase(File.Ext(sDirFile)) = "jpg" Then
      PicturePhoto.Picture.Save(sDirFile, F_iSaveQualityJPG) 'only jpg
    Else
      PicturePhoto.Picture.Save(sDirFile)
    Endif
    If Exist(sDirFile) = False Then
      Message.Info(("Fehler. Datei nicht gespeichert"), ("Abbrechen"))
    Else
      Settings[FMain.Name &/ "sPathFoto"] = sDirFile '/sDir/File.xyz
      
      sMessage = "<h3><font color=darkgreen>" & ("Gespeichert") & ":" & "</font></h3>"
      sMessage &= "<font color=gray>" & sDirFile & "</font><br>"
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) 
      
      Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
        Case 1
          M01Functions.FileManagerOpen(sDirFile)
        Case 2
          ''...
      End Select  
      
      LabelInfo2.Text = sDirFile 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub CButtons_Enter()
  
  Last.Background = Color.Green
  
  Select Case Last.Tag 
    Case "copy1"
      TextBoxColorName.Background = F_iColorGreenAlpha150
    Case "copy2"
      TextBoxHexaHTML.Background = F_iColorGreenAlpha150
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CButtons_Leave()
  
  Last.Background = Color.Default 
  
  Select Case Last.Tag 
    Case "copy1"
      TextBoxColorName.Background = LabelInfo2.Background 
      TextBoxColorName.ForeGround = LabelInfo2.ForeGround
    Case "copy2"
      TextBoxHexaHTML.Background = Color.SetAlpha(LabelInfo2.Background, 0)
      ' TextBoxHexaHTML.ForeGround = LabelInfo2.ForeGround
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CButtons_Click()
  
  Dim iColor As Integer
  
  iColor = Color.SetAlpha(ColorChooser2.SelectedColor, 150)
  
  Select Case Last.Tag 
    Case "insert"
      ' If TextBoxHTML.Text And TextBoxHTML.Text Begins "<" Then 
      PasteTextBoxColor()
      ' Else 
      '   PasteTextBoxColor(TextBoxHTML.Text)
      ' Endif 
      
    Case "copy1"
      CopyText(TextBoxColorName.Text)
      TextBoxColorName.Background = iColor
      
    Case "copy2"
      CopyText(TextBoxHexaHTML.Text)
      TextBoxHexaHTML.Background = iColor
      
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() 'Top▲ 
  
End 

Public Sub CopyText(Optional sText As String = "")
  
  If sText Then 
    Clipboard.Clear
    Clipboard.Copy(sText)                                                                 'Copy x----
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxHexa_KeyPress()
  
  If Key.Code = Key.Return Then PasteTextboxColor(TextBoxHexa.Text)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxDezi_KeyPress()
  
  Dim iColor As Integer
  Dim sHex As String
  
  If Key.Code = Key.Return Then 
    If IsInteger(TextBoxDezi.Text) Then 
      iColor = CInteger(TextBoxDezi.Text)
      sHex = "#" & Hex(iColor, 6)
      PasteTextboxColor(sHex)
    Else 
      PasteTextboxColor(TextBoxDezi.Text)
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterSideCompareColor()
  
  Dim it, iLine, iCounter, iAll As Integer
  Dim sMessage, sLine, sValue, sLevelsTags, sLevelsTags2, sLineColor As String 

  ''with line "colorchange=...."?
  sLevelsTags = ReadLevelsTag() 'as String
  If Not sLevelsTags And F_ooPicBoxesMuster Then sLevelsTags = F_ooPicBoxesMuster[F_ooPicBoxesMuster.Max].Tag
  
  For Each sLine In Split(sLevelsTags & gb.NewLine, gb.NewLine)
    iLine = iLine + 1
    ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
      
    If sLine Then 
      If sLine Like "*color*=*" Then 
        sLineColor = sLine 
        Break 
      Endif
    Endif
  Next
  
  If F_bESCpressedON = True Then Return 'Exit, end here
    
  ''Standard?
  If Not sLineColor Then sLineColor = CheckColorChangeLine() 'as String 
  
  If F_ooPicBoxesMuster Then 
    iAll = F_ooPicBoxesMuster.Count
    ''Find, compare:
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
        
      sLevelsTags2 = F_ooPicBoxesMuster[it].Tag
      
      If sLevelsTags2 Not Like "*color*=*" Then sLevelsTags2 = Replace(sLevelsTags2, "level=end", sLineColor & gb.NewLine & "level=end") 
        
      sValue = "*" & sLineColor & "*"
      If sLevelsTags2 Like sValue Then 
        F_ooPicBoxesMuster[it].Background = F_iColorSelect
        iCounter = iCounter + 1 
      Else 
        F_ooPicBoxesMuster[it].Background = Color.Default
      Endif 
    Next   
  Endif 
  MusterCounter()
 
  ' If iCounter > 0 Then 
    sMessage = InfoButtonPictureMessage(ButtonFindMusterColor.Picture) 'as String
    sMessage &= "<h2>" & ("Muster") & "</h2>"
    sMessage &= "<h2>" & "<font size=7>" & iCounter & Space(1) & "</font>" & ("von") & Space(1) & iAll & Space(1) & ("mit gleicher Farb-Palette") & "</h2>"
    sMessage &= "<br>"
    sMessage &= InfoColorPaletteMessage()
    
    Message.Info(sMessage, ("Abbrechen"))
  ' Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterSideCompareEdit()
  
  Dim it, iLine, iCounter, iAll, iFound As Integer
  Dim sMessage, sValue, sLevelsTags2, sLineEdit As String 
  Dim ssSpli As String[]
  
  If F_ooPicBoxesMuster Then 
    iAll = F_ooPicBoxesMuster.Count
    ''Find, compare:
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
        
      sLevelsTags2 = F_ooPicBoxesMuster[it].Tag
        
      sValue = "*" & "edit=" & "*"
      If sLevelsTags2 Like sValue Then 
        F_ooPicBoxesMuster[it].Background = F_iColorSelect
        iCounter = iCounter + 1 
        If Not sLineEdit Then 
          ssSpli = Split(sLevelsTags2 & gb.NewLine, gb.NewLine)
          iFound = ssSpli.Find("*edit=*", gb.Like) '-1 not found 
          If iFound > -1 Then sLineEdit = ssSpli[iFound]
        Endif
      Else 
        F_ooPicBoxesMuster[it].Background = Color.Default
      Endif 
    Next   
  Endif 
  MusterCounter()
 
  ' If iCounter > 0 Then 
    If Not sLineEdit Then sLineEdit = ("Nicht vorhanden")
    sMessage = "<h2><font color=gray>" & ButtonFindMusterEdit.Text & "</font></h2>"
    sMessage &= "<h2>" & ("Muster") & "</h2>"
    sMessage &= "<h2>" & "<font size=7>" & iCounter & Space(1) & "</font>" & ("von") & Space(1) & iAll & Space(1) & ("mit Zeile") & Space(1) & "edit=..." & "</h2>"
    sMessage &= "<br>"
    sMessage &= ("Beispiel") & ":" & "<br>"
    sMessage &= "<font color=gray>" & sLineEdit & "</font>"

    Message.Info(sMessage, ("Abbrechen"))
  ' Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MusterSideCompareDouble()
  
  Dim it, iLine, iCounter, iAll, iFound As Integer
  Dim sMessage, sLine As String 
  Dim iiDoubleFirst, iiDoubleSecond, iiDoubleUnselect As Integer[]
  Dim ssSpli, ssShortLines As String[]
  
  If F_ooPicBoxesMuster Then 
    F_ssPicBoxMusterTags = New String[]
    
    ''List array:
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      F_ssPicBoxMusterTags.Add(F_ooPicBoxesMuster[it].Tag)
    Next 
    If F_bESCpressedON = True Then Goto JumpEnd
    
    iAll = F_ooPicBoxesMuster.Count
    iiDoubleFirst = New Integer[]
    iiDoubleSecond = New Integer[]
    iiDoubleUnselect = New Integer[]
    ssShortLines = New String[F_ssPicBoxMusterTags.Count]
    
    ''Standard?
    ' sLineColor = CheckColorChangeLine() 'as String 
    
    ''Reduce lines:
    For it = 0 To F_ssPicBoxMusterTags.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      For Each sLine In Split(F_ssPicBoxMusterTags[it] & gb.NewLine, gb.NewLine)
        ssSpli = Split(sLine & String(2, "="), "=")
        If String.InStr(sLine, "=") > 0 Then 
          If String.InStr(sLine, "level=begin") = 0 And String.InStr(sLine, "level=end") = 0 And String.InStr(sLine, "edit=") = 0 And String.InStr(sLine, "color") = 0 Then
            ssShortLines[it] &= "*" & ssSpli[0] & "=" & ssSpli[1] & "=" & "*" & gb.NewLine
          Endif 
        Endif
      Next 
    Next 

    If F_bESCpressedON = True Then Goto JumpEnd
    
    iCounter = 0 'Reset
    ''Select double:
    For it = 0 To F_ooPicBoxesMuster.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      iFound = F_ssPicBoxMusterTags.Find(ssShortLines[it], gb.Like)
      If iFound > -1 And iFound <> it Then
        If iiDoubleFirst.Find(it) = -1 Then 
          iiDoubleFirst.Add(it)
          F_ooPicBoxesMuster[it].Background = F_iColorSelect
          iCounter = iCounter + 1
          ssShortLines[it] = ""
        Endif 
      Else 
        F_ooPicBoxesMuster[it].Background = Color.Default
        iiDoubleUnselect.Add(it)
        iFound = F_ssPicBoxMusterTags.Find(ssShortLines[it], gb.Like, iFound + 1)
        If iFound > -1 And iiDoubleUnselect.Find(iFound) = -1 Then
          iiDoubleUnselect.Add(it)
          F_ooPicBoxesMuster[it].Background = F_iColorGray
        Else 
          F_ooPicBoxesMuster[it].Background = Color.Default 'Reset
        Endif 
      Endif  

    Next 
    If F_bESCpressedON = True Then Goto JumpEnd
    
    ' F_iiMusterSort = New Integer[]
    ' F_iiMusterSort.Insert(iiDoubleFirst)
    ' F_iiMusterSort.Insert(iiDoubleUnselect)
    
    MusterCounter()
    
  ' If iCounter > 0 Then 
    sMessage = InfoButtonPictureMessage(ButtonFindMusterDouble.Picture) 'as String
    sMessage &= "<h2>" & ("Muster") & "</h2>"
    sMessage &= "<h2>" & "<font size=7>" & iCounter & Space(1) & "</font>" & ("von") & Space(1) & iAll & Space(1) & ("sind doppelt oder ähnlich") & "</h2>"

    Message.Info(sMessage, ("Abbrechen"))
  ' Endif 
  Endif 
  
  JumpEnd:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView4Readyyyyy(Optional iSortLevel2_Edit3_Color4_Muster5 As Integer = 2)
  
  Dim M, iKey, iMax, iKeyDouble, iColumn, iFound, iLen, iLinesMax, iLevel, iEdit, iColor, iMuster As Integer
  Dim iCount, iPicW, iPicH, iLeft, iTop, iColumns, iCloseW, it, it2, iLine As Integer
  Dim sLine, sValue, sKey, sLevelsTags, sLevelsTags2, sColorChange As String 
  Dim iiMusterSort, iiLevels, iiEdits, iiColors, iiMuster, iiDouble, iiSelect, iiUnselection As Integer[]
  Dim Img, imgEmpty As Image
  Dim ssLevelsTags2, ssExist As String[]
  Dim ooPicBoxesMuster As Object[]
  
  ColumnView4.Clear()
  ColumnView4Resize()
  
  iLen = String.Len(Str(F_ooPicBoxesMuster.Count)) + 1 'Example: 001, 002, 003, ...
  iLinesMax = Split(F_ssPicBoxMusterTags.Join(gb.NewLine) & gb.NewLine, gb.NewLine).Max
  imgEmpty = New Image(32, 32, Color.Transparent)
  iColumn = iSortLevel2_Edit3_Color4_Muster5 
  sColorChange = CheckColorChangeLine() 'as String 
  ' sLevelsTags = ReadLevelsTag() 'as String
  ' For it = 0 To F_ooPicBoxesMuster.Max
    ' sTag = F_ooPicBoxesMuster[it].Tag 
    ' iiLevels = New Integer[]
    F_ssPicBoxMusterTags = New String[]
    For it = 0 To F_ooPicBoxesMuster.Max
      F_ssPicBoxMusterTags.Add(F_ooPicBoxesMuster[it].Tag)
    Next

    ''Create count lines
    For it = 0 To F_ooPicBoxesMuster.Max
      iiDouble = New Integer[F_ooPicBoxesMuster.Count] 
      If F_ooPicBoxesMuster[it].Picture Then Img = F_ooPicBoxesMuster[it].Picture.Image.Stretch(32, 32) Else Img = Null
      ' iCompareLevel0_Edit1_Color2_Muster3
      ''NrBox0|Tag1|Level2|Edit3|Color4|5|6|7|8|9|10|11|Sort12|13|14|
      sKey = F_ooPicBoxesMuster[it].ToolTip
      ColumnView4.Add(sKey, "")  '|1|2|3|... Number
      If Img Then 
        ColumnView4[sKey].Picture = Img.Picture
      Else 
        ColumnView4[sKey].Picture = imgEmpty.Picture
      Endif 
      ColumnView4[sKey][0] = sKey
      ColumnView4[sKey][1] = F_ooPicBoxesMuster[it].Tag
      ColumnView4[sKey][F_iColumn12Sort] = Format(it, String(iLen, "0")) '001
      ' ColumnView4[sKey][5] = iFound 
      ' iiLevels.Add(-1)

      iLevel = 0 'Reset
      iEdit = 0
      iColor = 0
      iMuster = 0
      iMax = -1
      sLevelsTags = F_ooPicBoxesMuster[it].Tag
      ' If sLevelsTags Not Like "*color*=*" Then sLevelsTags = Replace(sLevelsTags, "level=end", sColorChange & gb.NewLine & "level=end") '
      For it2 = 0 To F_ooPicBoxesMuster.Max
        ' If it <> it2 Then 
          sLevelsTags2 = F_ooPicBoxesMuster[it2].Tag
          ' If sLevelsTags2 Not Like "*color*=*" Then sLevelsTags2 = Replace(sLevelsTags2, "level=end", sColorChange & gb.NewLine & "level=end")
          ' If sLevelsTags == sLevelsTags2 Then Print "doppelt", it, it2
          ssLevelsTags2 = Split(sLevelsTags2 & gb.NewLine, gb.NewLine)
          For Each sLine In ssLevelsTags2 'Split(sLevelsTags2 & gb.NewLine, gb.NewLine)
            If sLine Then 
              ' sLine = Replace(sLine, "=", "*")
              
              sValue = "*" & Replace(sLine, "=", "*") & "*"
              If sLevelsTags Like sValue Then iFound = it Else iFound = -1
              ' iFound = F_ssPicBoxMusterTags.Find(sValue, gb.Like) '-1 not found
              If iFound > -1 Then   
                ' sKey2 = F_ooPicBoxesMuster[iFound].ToolTip
                If sLine Like "*level=*" Then 
                  iLevel = iLevel + 1 
                Else If sLine Like "*edit=*" Then  
                  iEdit = iEdit + 1 
                Else If sLine Like "*color*=*" Then 
                  iColor = iColor + 1 
                Endif 
                ' If ColumnView4[sKey][6] Not Like "*=" & iFound & "=*" Then 
                ' ColumnView4[sKey][6] = ColumnView4[sKey][6] & "=" & iFound & "="
                ' Endif 
                'double5
              Endif 
            Endif 
          Next 
        ' Endif 
        If iLevel + iEdit + iColor > iMax Then 
          iMax = iLevel + iEdit + iColor
          iKeyDouble = it2
        Endif 
        ' iiDouble[it2] = iLevel + iEdit + iColor
              If Not ColumnView4[sKey][6] Then iKey = 0 Else iKey = CInteger(Str(ColumnView4[sKey][6]))
      If iKey < iMax Then
        ColumnView4[sKey][6] = iMax
        ColumnView4[sKey][7] = it2 'double5
      Endif
      Next
      iMuster = iLevel + iEdit + iColor
      ColumnView4[sKey][2] = iLevel
      ColumnView4[sKey][3] = iEdit
      ColumnView4[sKey][4] = iColor
      ColumnView4[sKey][5] = iMax 'double5
      ' iiDouble.Sort(gb.Descent)'0,1,2,3... (gb.Descent Example: 9,8,7...)

      
      iKeyDouble = 0
    Next
    
    ''exact double
    
    ' For it = 0 To F_ssPicBoxMusterTags.Max
    '   sLevelsTags = F_ssPicBoxMusterTags[it]
    '   iFound = -1
    '   For it2 = 0 To F_ssPicBoxMusterTags.Max
    '   ' iFound = F_ssPicBoxMusterTags.Find("*" & sLevelsTags & "*", gb.Like, iFound + 1)
    '   'Gambas3: "LIKE only deals with ASCII strings. If you need to match UTF-8 strings, use the gb.pcre component."
    '   If F_ssPicBoxMusterTags[it2] Like "*" & sLevelsTags & "*" Then iFound = it2 Else iFound = -1
    '   ' If iFound = -1 Then Break 
    '   
    '   If iFound > -1 Then 
    '     sKey = F_ooPicBoxesMuster[iFound].ToolTip
    '     If Not ColumnView4[sKey][5] Then ColumnView4[sKey][5] = iFound 
    '   Endif 
    '   Next 
    ' Next 

    ' For Each sLine In Split(F_ssPicBoxMusterTags.Join(gb.NewLine) & gb.NewLine, gb.NewLine)
    '   iPos = 0 'Reset
    '   iLevel = 0
    '   iEdit = 0
    '   iColor = 0
    '   iFound = -1 
    '   If Not sLine Or sLine Begins "level=begin" Or sLine Begins "level=end" Then 
    '     ''...
    '   Else 
    '     For it2 = 0 To iLinesMax
    '       iFound = F_ssPicBoxMusterTags.Find("*" & sLine & "*", gb.Like, iFound + 1)
    '       ' If F_ooPicBoxesMuster[it2].Tag Like "*" & sLine & "*" Then 
    '       If iFound = -1 Then 
    '         ''...
    '       Else 
    '       
    '       sKey = F_ooPicBoxesMuster[iFound].ToolTip
    '       it = iFound
    '       ' iPos = iFound
    ' 
    '       If sLine And F_ooPicBoxesMuster[it].Tag Like "*" & sLine & "*" Then
    '         If sLine Like "*level=*" Then 
    '           iLevel = iLevel + 1
    '           ColumnView4[sKey][2] = ColumnView4[sKey][2] & "=" & it2
    '         Else If sLine Like "*edit=*" Then  
    '           iEdit = iEdit + 1
    '           ColumnView4[sKey][3] = ColumnView4[sKey][3] & "=" & it
    '         Else If sLine Like "*color*=*" Then  
    '           iColor = iColor + 1
    '           ColumnView4[sKey][4] = ColumnView4[sKey][4] & "=" & it
    '         Else 'If sLine Like "*muster*=*" Then  
    '           ' iColor = iColor + 1
    '           ColumnView4[sKey][5] = ColumnView4[sKey][5] & "=" & it
    '         Endif 
    '       Endif 
    '       Endif
    '     Next 
    '   Endif
    ' Next
    
    ColumnView4.Sorted = True 'Important (wichtig)
    ColumnView4.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    ' iSortLevel2_Edit3_Color4_Muster5
    iColumn = iSortLevel2_Edit3_Color4_Muster5 
    ColumnView4.Columns.Sort = 1'iColumn
    
    ''Sort:
    iiMusterSort = New Integer[]
    iiLevels = New Integer[] '|0|0|0|...
    iiEdits = New Integer[]
    iiColors = New Integer[]
    iiMuster = New Integer[]
    ssExist = New String[]
    iiSelect = New Integer[]
    iiUnSelection = New Integer[]
    
    ' sText = Null
    it = -1 'Reset
    M = ColumnView4.MoveFirst()
    For Each sKey In ColumnView4.Keys
    ' For it = 1 To ColumnView4.Count - 1
      it = it + 1
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If it = 0 Then 
        M = ColumnView4.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
      Else 
        M = ColumnView4.MoveBelow() '▼down
      Endif 
      If M = 0 Then 
        sKey = ColumnView4.Item.Key 'Gambas3: "Returns the item pointed by the internal cursor, or NULL if the internal cursor is not available."
        ' iKey = CInteger(Str(ColumnView4[sKey][0])) '- 1
        iKey = CInteger(Str(ColumnView4[sKey][F_iColumn12Sort]))
        If iKey > -1 And iKey < F_ooPicBoxesMuster.Count Then  
          If ssExist.Find(Str(F_ooPicBoxesMuster[iKey].Picture.Image.Data)) = -1 Then
            ssExist.Add(Str(F_ooPicBoxesMuster[iKey].Picture.Image.Data))
            ' F_ooPicBoxesMuster[iKey].Background = F_iColorSelect
            iiSelect.Add(iKey)
            ' Else 
            ' ' F_ooPicBoxesMuster[iKey].Background = Color.Default   
            ' iiUnselection.Add(iKey)
          Endif 
          iiMusterSort.Add(iKey)
        Endif 
        
        ' iiMusterSort.Add(iKey)
        ' Select Case iColumn
        '   Case 2
        '     If ColumnView4[sKey][iColumn] Then iiLevels.Add(iKey)
        '     Print ColumnView4[sKey][iColumn], iKey
        '   Case 3
        '     If ColumnView4[sKey][iColumn] Then iiEdits.Add(iKey)
        '   Case 4
        '     If ColumnView4[sKey][iColumn] Then iiColors.Add(iKey)
        '   Case 5
        '     If ColumnView4[sKey][iColumn] Then iiMuster.Add(iKey)
        ' End Select
        
      Endif  
    Next 
    ' iiMusterSort = iiSelect.Copy() 
    ' iiMusterSort.Insert(iiUnselection) 'Gambas3: "By default, the array is inserted at the end."
    ooPicBoxesMuster = New Object[]
    
    iPicW = F_iZoomGallery
    iPicH = iPicW '1:1 WxH
    iColumns = (ScrollViewMuster.W - Desktop.Y) / iPicW  'not .ClientWidth, different empty or full
    If F_ooButtonMuster.Max > -1 Then iCloseW = F_ooButtonMuster[0].W Else iCloseW = 25
    iLeft = -1 'Begin with 0
    ProgressBar1.Pulse = False
    iCount = F_ooPicBoxesMuster.Count
    If iCount < 2 Then iCount = 1 'Not Division by zero 
      
    For Each it In iiMusterSort
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
        If it > -1 And it < F_ooPicBoxesMuster.Count Then 
          'Positions PictureBoxes
          iLeft = iLeft + 1
          If iLeft > iColumns - 1 Then 
            iLeft = 0
            iTop = iTop + 1
          Endif 
          If Object.Type(F_ooPicBoxesMuster[it]) = "PictureBox" Then 
            F_ooPicBoxesMuster[it].Move(iPicW * iLeft, iPicH * iTop, iPicW, iPicH) 
            F_ooPicBoxesMuster[it].Visible = True
          Endif 
          If Object.Type(F_ooButtonMuster[it]) = "Button" Then 
            F_ooButtonMuster[it].Move((iPicW * iLeft) + iPicW - iCloseW, iPicH * iTop, iCloseW, iCloseW) 
            F_ooButtonMuster[it].Visible = True
            F_ooButtonMuster[it].Raise()
          Endif 
          If iiSelect.Find(it) > -1 Then 
            F_ooPicBoxesMuster[it].Background = F_iColorSelect
            ooPicBoxesMuster.Add(F_ooPicBoxesMuster[it], it)
          Else 
            F_ooPicBoxesMuster[it].Background = Color.Default
          Endif 
        Endif 
    
    Next 
    F_ooPicBoxesMuster = ooPicBoxesMuster.Copy()
    
    ' F_iiMusterSort = iiMusterSort.Copy()
    
    ' ResizePanelMuster()
    
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG2()
  
  Dim sKey, sPath, sText, sLine, sRGB, sR, sG, sB, sLineUndo As String 
  Dim ssSpli, ssColumns, ssRGB As String[]
  Dim it, iNr, iColor As Integer
  
  ColumnView2.Clear()
  ColumnView2Resize()
  
  sPath = "text" &/ "colornames.txt"   ''Load from program directory
  ColumnView2.Columns.Sort = 1'F_iColumn12Sort
  ColumnView2.Sorted = True 
  
  If Exist(sPath) = False Then ColumnView2.Columns[1].Title = ("Fehlt") & ": " & sPath
  
  If Exist(sPath) = True Then 
    sText = File.Load(sPath)
    ssSpli = Split(sText & gb.NewLine, gb.NewLine)
    'Example Line: 1= "AliceBlue=aliceblue=#F0F8FF=240,248,255=15792383=246=15=208="
    For Each sLine In ssSpli
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If String.InStr(sLine, "=") > 0 Then 
        iNr = iNr + 1
        ssColumns = Split(Str(iNr) & "=" & sLine & String(F_iColumns14Count, "="), "=")
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
        sKey = Str(ColumnView2.Count + 1)
        ColumnView2.Add(sKey, "")
        
        sLineUndo = ""
        For it = 0 To F_iColumns14Count - 1 
          ColumnView2[sKey][it] = UnQuote(ssColumns[it])
          sLineUndo &= ColumnView2[sKey][it] & gb.Tab
        Next
        ColumnView2[sKey][F_iColumns13Undo] = sLineUndo
        sRGB = ColumnView2[sKey][4]
        ssRGB = Split(sRGB & String(2, ","), ",")
        sR = ssRGB[0]
        sG = ssRGB[1]
        sB = ssRGB[2]
        ColumnView2[sKey][9] = sR
        ColumnView2[sKey][10] = sG
        ColumnView2[sKey][11] = sB
        iColor = CInteger(ColumnView2[sKey][5]) 
        ColumnView2[sKey].Background = iColor
        If M01Functions.ColorInfoRGB(iColor, "L") < 150 Then ColumnView2[sKey].Foreground = Color.White Else ColumnView2[sKey].Foreground = Color.Black
      Endif 
    Next
    For it = 4 To ColumnView2.Columns.Max   
      ColumnView2.Columns[it].Alignment = Align.Right   
    Next 
    ' ColumnView2Resize()
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0) 'unused?
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If iSortColumnNr < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True 'Important (wichtig)
      ' If ColumnView2.Sorted = False Then ColumnView2.Sorted = True 'faster
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView2.Columns.Sort <> iSortColumnNr Then ColumnView2.Columns.Sort = iSortColumnNr 
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection.Last  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function ColumnView1SortReturnText(Optional iSort As Integer = 0) As String
  
  Dim sKey, sText As String 
  Dim M As Integer = -1
  Dim it, it2, iLine, iNumber As Integer
  
  If ColumnView2.Columns.Max < F_iColumns14Count Then '|0|1|2|3|4|5|6|7|8|9|10|11|12|13| 
    ColumnView2.Clear
    ReadG2()
    ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
    ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
  Endif 
  If iSort < 0 Then iSort = 0 
  If iSort > ColumnView2.Columns.Max Then iSort = ColumnView2.Columns.Max
  
  If ColumnView2.Columns.Count >= F_iColumns14Count Then 
    ColumnView2.Sorted = False            ' sortieren
    ' ColumnView2.Columns.Ascending = True ' A —▶ Z
    For Each sKey In ColumnView2.Keys
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView2[sKey][F_iColumn12Sort] = ColumnView2[sKey][iSort]
      If IsInteger(ColumnView2[sKey][F_iColumn12Sort]) = True Then 
        iNumber = ColumnView2[sKey][F_iColumn12Sort]
        ColumnView2[sKey][F_iColumn12Sort] = Format(iNumber, String(11, "0"))
      Else If IsHexa(Replace(ColumnView2[sKey][F_iColumn12Sort], "#", "")) Then  'without = TRUE!
        ColumnView2[sKey][F_iColumn12Sort] = Replace(ColumnView2[sKey][F_iColumn12Sort], "#", "")
      Endif 
    Next
    ColumnView2.Sorted = True
    ' ColumnView2.Columns.Sort = 0
    ' ColumnView2.Columns.Sort = ColumnView2.Columns.Max '12
    ''...........................................
    ColumnView2.Columns.Sort = F_iColumn12Sort 'Sortiert nach Spalte   0|1|2|3|4|5|6|7|8|9|10|11|12|...
    ''...........................................
    
    sText = Null
    M = ColumnView2.MoveFirst()
    ' For Each sKey In ColumnView2.Keys
    For it = 1 To ColumnView2.Count - 1
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If it = 0 Then 
        M = ColumnView2.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
      Else 
        M = ColumnView2.MoveBelow() '▼down
      Endif 
      If M = 0 Then 
        sKey = ColumnView2.Item.Key 'Gambas3: "Returns the item pointed by the internal cursor, or NULL if the internal cursor is not available."
        ''Example line: 1= "AliceBlue=aliceblue=F0F8FF=RGB(240, 248, 255)=15792383=246=15=208="
        ''Nr|Name0|name1|Hexa2|RGB3|Dezi4|Lumi5|Satu6|HUE7|R8|G9|B10|
        For it2 = 1 To ColumnView2.Columns.Max
          sText &= ColumnView2[sKey][it2] & "="
        Next  
        sText &= gb.NewLine
      Endif  
    Next 
    Print sText 
    ' File.Save(sDirFile, sText)
  Endif 
  
  Return sText 
  
Catch
  FMain.ErrorText
  
End

Public Sub TimerPanelColorsChange_Timer()
  '.Delay = 2000 '2 sec.
  TimerPanelColorsChange.Enabled = False
  ApplyIconColorG()
  
  PanelColor.Visible = False 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch
  FMain.ErrorText
  
End '..................................................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form16Diagramm.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form16Diagramm.class
156 KB
' Gambas class file

'F_ = Form
Public F_bbTimeWindows As Boolean[]
Public F_bChangeON As Boolean
Public F_bColumnsMore As Boolean
Public F_bCorrectListON As Boolean
Public F_bESCpressedON As Boolean
Public F_bLabelDiagramTitleON As Boolean = True 'Default
Public F_bMovingON As Boolean
Public F_bPaintDiagramAllON As Boolean
Public F_bPicDiagramLongerON As Boolean 
Public F_dateNow As Date 
Public F_i22 As Integer = 22 'Example: 22 'Pixel Icon WxH —▶ColumnView
Public F_iBottomBorder As Integer '_▼_
Public F_iColorForegroundBlue As Integer = Color.DarkBlue
Public F_iColorRed As Integer = Color.Red
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iCurrentErrorLine As Integer
Public F_iDiagrammHintergrundfarbe As Integer
Public F_iMusterTermine1Names2Projects3 As Integer = 3 '!!! ******************************************
Public F_iOldLines As Integer
Public F_iOnly1x As Integer
Public F_iSelectGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150) 
Public F_iSelectGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220) 
Public F_iSelectRedAlpha220 As Integer = Color.SetAlpha(Color.Red, 220) 
Public F_iTime24BorderLeft As Integer  '<
Public F_iTime24BorderRight As Integer '>
Public F_iTopBorder As Integer
Public F_iUnknownCounter As Integer
Public F_iX1 As Integer
Public F_iX2 As Integer
Public F_iY1 As Integer
Public F_iY2 As Integer
Public F_longFilesRead As Long '>Files
Public F_ooColumnViewImages As Object[]
Public F_ooColumnViewValues As Object
Public F_sCVinfoSelectLineFirst As String = ("Vorher eine Zeile markieren")
Public F_sDiagramTitle As String
Public F_sForm As String = Me.Name 
Public F_sLinesCopy As String 
Public F_ssCVImgNames As String[]
Public F_ssKeysCopy As String[]                   'ColumnView1.Selection  'internally, instead of Clipboard.Copy()
Public F_sTitleBasicText As String
Public F_sUnknownLinesText As String

Public Struct F_iColumnViewValues 'Example in Sub: Dim hColumn as New F_iColumnViewValues
  i00YYYYMMDD As Integer 
  i01HHMMA As Integer 
  i02WD As Integer 
  i03Q As Integer 
  i04CW As Integer 
  i05Notice As Integer 
  i06HHMMB As Integer 
  i07WD As Integer 
  i08Seconds As Integer 
  i09HHMMSS As Integer 
  i10Undo As Integer 
  i11Select As Integer 
  i12Sort As Integer 
  i13Nr As Integer 
  i14ColumnsCount As Integer 
End Struct 

Public Function FilePathForm() As String 
  
  ' Return Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]  '... "terminwecker.txt"
  ' Return Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt]'..."projects_names.txt"
  Return Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] '..."projects_all.txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt")
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathProjectActual() As String 
  
  Dim sDir, sFile, sDirFile As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  ' sDir = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  sFile = "project_" & Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName] & ".txt"
  sDirFile = sDir &/ sFile
  If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] 
  
  Return sDirFile 'Path
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Form16Diagramm.Window.Title = Application.Name & " - " & ("Diagramm") 
  If Not Form16Diagramm.Window.Icon Then Form16Diagramm.Window.Icon = FMain.Window.Icon
  Menu1.Visible = False
  F_sTitleBasicText = Form16Diagramm.Window.Title
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  If System.Error > 0 Then Form16Diagramm.Window.Close()
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True
  ' SelectHide0Date1Clock2Timer3(0)
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then ColumnViewInfo(("Abbruch mit [ESC]")) Else ColumnViewInfo()
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form16Diagramm.Window.Maximized = False Then
    Form16Diagramm.Window.Maximized = True
  Else
    Form16Diagramm.Window.Maximized = False
    Form16Diagramm.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewInfo(Optional CVText As String = "")
  
  If CVText = "" Then  
    If ColumnView1.Visible = True Then 
      If ColumnView1.Count = 0 Then 
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView1.Selection.Count = 0 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView1.Selection.Count) & Space(1) & ("Edit")
      Endif 
      ' Else If ColumnView2.Visible = True Then 
      '   CVText = Str(ColumnView2.Selection.Count) & Space(1) & ("Edit")
    Endif 
  Endif 
  
  LabelInfo.Alignment = Align.Center
  LabelInfo.Font.Bold = True
  LabelInfo.Text = CVText
  LabelInfo.Tooltip = CVText
  LabelInfo.Visible = True
  LabelInfo.Raise
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  ColumnView1.Columns[5].Title = CVText
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    FormStart()
    Side(2) 'Diagr1_Liste2_Einst3
    
    Try PicBoxDiagram.Picture = DiagramEmpty().Picture 'as Image
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim hColumn As F_iColumnViewValues
  Dim sPath As String 
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  F_iColumnNr = 13                                  'Termine 6, in Projects 13
  F_iColumnUndo = 10                                'Termine 7, in Projects 10
  F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
  F_iColumnSort = 12                                'Termine 9, in Projects 12
  
  ''Column-Count 1,2,3...n
  F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
  F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  
  ''Area Diagram inside
  '********************************************
  F_iTime24BorderLeft = 50 'linker Rand ◀
  F_iTime24BorderRight = 50 'rechter Rand ▶
  F_iTopBorder = 20 'oberer Rand▲
  F_iBottomBorder = 40 'unterer Rand ▼
  '********************************************
  
  ' Public Struct F_iColumnViewValues 'Example in Sub: Dim hColumn as New F_iColumnViewValues
  hColumn = New F_iColumnViewValues 'see Form head▲ 
  With hColumn
    .i00YYYYMMDD = 0 'as Integer
    .i01HHMMA = 1
    .i02WD = 2
    .i03Q = 3
    .i04CW = 4
    .i05Notice = 5
    .i06HHMMB = 6
    .i07WD = 7
    .i08Seconds = 8
    .i09HHMMSS = 9
    .i10Undo = 10
    .i11Select = 11
    .i12Sort = 12
    .i13Nr = 13
    .i14ColumnsCount = 14
  End With 
  F_ooColumnViewValues = New Object[]
  F_ooColumnViewValues.Add(hColumn)
  ColumnViewImagesRead()
  
  SettingsDiagram(False) 'SpeichernTrue_LesenFalse
  
  F_bChangeON = False
  ButtonEspeichern.Background = Color.Default
  'Datei = "/home/USER/terminwecker/projects/projekt_F_sProjectOnlyName.txt"
  sPath = FilePathProjectActual() 'FilePathForm() 
  TextBoxPath.SelectAll()
  TextBoxPath.Insert(sPath)
  LabelInfoPathG(sPath)
  
  FormBackgroundColor()
  WindowStretchCursor()
  If ButtonC1.Picture Then 'Colors Weekdays
    ' ButtonC1.Picture = ButtonC1.Picture
    ButtonC2.Picture = ButtonC1.Picture '<x
    ButtonC3.Picture = ButtonC1.Picture
    ButtonC4.Picture = ButtonC1.Picture
    ButtonC5.Picture = ButtonC1.Picture
    ButtonC6.Picture = ButtonC1.Picture
    ButtonC7.Picture = ButtonC1.Picture
  Endif 
  If F_bPicDiagramLongerON = True Then 
    ArrowR.Picture = PicTemplateArrowL.Picture
  Else 
    ArrowR.Picture = PicTemplateArrowR.Picture  
  Endif
  GroupTimeWindowsCheckG()
  F_bLabelDiagramTitleON = Settings[F_sForm &/ "F_bLabelDiagramTitleON", F_bLabelDiagramTitleON]
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupTimeWindowsCheckG()
  
  F_bbTimeWindows = Settings[F_sForm &/ "F_bbTimeWindows", F_bbTimeWindows]
  If Not F_bbTimeWindows Then F_bbTimeWindows = New Boolean[3]
  
  If F_bbTimeWindows[0] = True Then TimeWindow1.Picture = PicTemplateConnectON.Picture Else TimeWindow1.Picture = PicTemplateConnectOff.Picture 
  If F_bbTimeWindows[1] = True Then TimeWindow2.Picture = PicTemplateConnectON.Picture Else TimeWindow2.Picture = PicTemplateConnectOff.Picture 
  If F_bbTimeWindows[2] = True Then TimeWindow3.Picture = PicTemplateConnectON.Picture Else TimeWindow3.Picture = PicTemplateConnectOff.Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupTimeWindows_MouseDown()
  
  Dim it As Integer
  
  If Not F_bbTimeWindows Then F_bbTimeWindows = New Boolean[3]
  
  Select Case Last.Tag 
    Case TimeWindow1.Tag
      it = 0
    Case TimeWindow2.Tag 
      it = 1
    Case TimeWindow3.Tag 
      it = 2
  End Select  
  F_bbTimeWindows[it] = Not F_bbTimeWindows[it]
  Settings[F_sForm &/ "F_bbTimeWindows"] = F_bbTimeWindows.Copy()
  GroupTimeWindowsCheckG()
  
  If F_bbTimeWindows[0] = True Or F_bbTimeWindows[1] = True Or F_bbTimeWindows[2] = True Then  
    ToggleFrame.Value = True 
  Else 
    ToggleFrame.Value = False  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form16Diagramm.Left]
      iY = Settings[F_sForm &/ "Top", Form16Diagramm.Top]
      iW = Settings[F_sForm &/ "Width", Form16Diagramm.W]
      iH = Settings[F_sForm &/ "Height", Form16Diagramm.H]
      Form16Diagramm.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form16Diagramm.Left
      Settings[F_sForm &/ "Top"] = Form16Diagramm.Top
      Settings[F_sForm &/ "Width"] = Form16Diagramm.Width
      Settings[F_sForm &/ "Height"] = Form16Diagramm.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
  
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH, iPH, iPH2, iDis As Integer
  Dim fPart As Float
  
  If Form16Diagramm.Width < 200 Then Form16Diagramm.Width = 200
  If Form16Diagramm.Height < 200 Then Form16Diagramm.Height = 200
  
  '************************
  iPH = 50 'Pixel
  iPH2 = 30 'iPH / 2
  iDis = 0
  '************************
  
  PicBackground.Move(0, 0, Form16Diagramm.ClientW, Form16Diagramm.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Randbreite
  iBH = PicBackground.Height / 100 * 3
  
  IconError.Move(Form16Diagramm.ClientW - 32, 0, 32, 32)
  
  ''List:
  ColumnView1.Move(iBW, iBH, Form16Diagramm.Clientw - (2 * iBW), Form16Diagramm.ClientH - (2 * iBH) - (3 * iPH))
  
  ''Diagram:
  ScrollViewDiagram.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  LabelDiagramTitle.Move(ScrollViewDiagram.Left, 0, ScrollViewDiagram.W, iBH)
  PicBoxDiagram.Move(0, 0, ScrollViewDiagram.W, ScrollViewDiagram.H)
  
  ''Settings Side:
  ScrollView1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, Form16Diagramm.ClientH - (2 * iBH))
  PanelCV3.Move(ColorButton1.Left, 0, PanelKR1.Left - ColorButton1.Left, ScrollView1.H)
  ColumnView3.Move(0, 0, PanelCV3.W, PanelCV3.H - iPH)
  ButtonCancelcv3.Move(0, ColumnView3.Top + ColumnView3.H, ColumnView3.W, iPH)
  
  ''Panel Menu:
  PanelMenu.Move(iBW, ColumnView1.Top + ColumnView1.H, ColumnView1.W, iPH * 3)
  fPart = PanelMenu.W / 13
  
  ''Panel Info:
  PanelInfo.Move(0, 0, PanelMenu.W, iPH2)
  LabelInfoMenu.Move(0, 0, (fPart * 5) - (iPH2 * 6), iPH2)
  ListColumnCorrect.Move(LabelInfoMenu.Left + LabelInfoMenu.W, 0, fPart, iPH2)
  ListGotoErrorLineDown.Move(ListColumnCorrect.Left + ListColumnCorrect.W, 0, fPart * 0.5, iPH2)
  ListGotoErrorLineUp.Move(ListGotoErrorLineDown.Left + ListGotoErrorLineDown.W, 0, fPart * 0.5, iPH2)
  ToggleFrame.Move(ListGotoErrorLineUp.Left + ListGotoErrorLineUp.W, 0, fPart * 1.5, iPH2)
  ToggleColumnDiagram.Move(ToggleFrame.Left + ToggleFrame.W, 0, fPart, iPH2)
  ToggleDiagramLine.Move(ToggleColumnDiagram.Left + ToggleColumnDiagram.W, 0, fPart, iPH2)
  ToggleWeekSumMiddle.Move(ToggleDiagramLine.Left + ToggleDiagramLine.W, 0, fPart, iPH2)
  ToggleProWeekHours.Move(ToggleWeekSumMiddle.Left + ToggleWeekSumMiddle.W, 0, fPart, iPH2)
  ListLineActual.Move(iDis + ToggleProWeekHours.Left + ToggleProWeekHours.W, 0, fPart * 0.5, iPH2) '▶··
  ListMark.Move(iDis + ListLineActual.Left + ListLineActual.W, 0, fPart * 0.5, iPH2) 'Flag
  ListRefresh.Move(iDis + ListMark.Left + ListMark.W, 0, fPart * 0.5, iPH2) 
  ListDiagramRefresh.Move(iDis + ListRefresh.Left + ListRefresh.W, 0, fPart * 0.5, iPH2) 
  
  ''Panel Image:
  PanelImage.Move(0, PanelInfo.Top + PanelInfo.H, PanelMenu.W, iPH)
  ButtonMenu.Move(0, 0, fPart * 1, iPH)
  ButtonNew.Move(ButtonMenu.Left + ButtonMenu.W, 0, fPart * 0.5, iPH)
  ButtonList.Move(ButtonNew.Left + ButtonNew.W, 0, fPart * 2.5, iPH)
  ButtonSelection.Move(ButtonList.Left + ButtonList.W, 0, fPart * 1.5, iPH)
  ButtonDiagram.Move(ButtonSelection.Left + ButtonSelection.W, 0, fPart * 3.5, iPH)
  ButtonPicProgram.Move(ButtonDiagram.Left + ButtonDiagram.W, 0, fPart * 1.5, iPH)
  ButtonCopyImage.Move(ButtonPicProgram.Left + ButtonPicProgram.W, 0, fPart * 1.5, iPH)
  PicBoxDiagramCopy.Move(ButtonCopyImage.Left + ButtonCopyImage.W, 0, fPart * 1.5, iPH)
  
  ''Panel Path:
  PanelPath.Move(0, PanelImage.Top + PanelImage.H, PanelMenu.W, iPH2)
  ButtonFileInfo.Move(0, 0, iPH2, iPH2)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (iPH2 * 4), iPH2)
  ButtonPathAdd.Move(TextBoxPath.Left + TextBoxPath.W, 0, iPH2 * 3, iPH2)
  LabelInfo.Move(TextBoxPath.Left, 0, TextBoxPath.W, iPH2)
  ProgressBar1.Move(0, 0, PanelPath.W, PanelPath.H)
  
  ''Panel Save:
  PanelSave.Move(0, PanelPath.Top + PanelPath.H, PanelMenu.W, PanelMenu.H - (PanelPath.Top + PanelPath.H))
  ButtonChartExtern.Move(0, 0, PanelSave.H, PanelSave.H)
  ButtonProjectAll.Move(ButtonChartExtern.Left + ButtonChartExtern.W, 0, fPart * 2, PanelSave.H)
  ButtonProjectCurrent.Move(ButtonProjectAll.Left + ButtonProjectAll.W, 0, fPart * 2, PanelSave.H)
  ButtonOpen.Move(ButtonProjectCurrent.Left + ButtonProjectCurrent.W, 0, fPart * 2, PanelSave.H)
  ButtonSave.Move(ButtonOpen.Left + ButtonOpen.W, 0, fPart * 3, PanelSave.H)
  ButtonSettingsSide.Move(ButtonSave.Left + ButtonSave.W, 0, fPart * 1, PanelSave.H)
  ButtonFormClose.Move(ButtonSettingsSide.Left + ButtonSettingsSide.W, 0, PanelSave.W - (ButtonSettingsSide.Left + ButtonSettingsSide.W), PanelSave.H)
  
  fPart = PanelSave.H
  If F_bMovingON = False Then WindowStretch.Move(Form16Diagramm.ClientW - iBW - fPart, Form16Diagramm.ClientH - iBH - fPart, fPart, fPart)
  
  ArrowR.Move(Form16Diagramm.ClientW - iBW, ScrollViewDiagram.Top, iBW, ScrollViewDiagram.H) ''>>
  ArrowR2.Move(Form16Diagramm.ClientW - iBW, ScrollViewDiagram.Top, iBW, ScrollViewDiagram.H) ''>>
  
  RaiseOrder()
  
  ''List resize:
  If F_iOnly1x > 0 And F_bMovingON = False Then ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  
  TextBoxPath.Lower()
  LabelInfo.Raise()
  ProgressBar1.Raise()
  LabelDiagramTitle.Raise() 'Diagram-Title
  ArrowR.Raise() '>>
  ArrowR2.Raise() '>>
  
  IconError.Raise()
  WindowStretch.Raise() 'Level ▲Top▲
  
Catch 
  FMain.ErrorText
  
End

Public Sub DiagramExampleDemo()
  
  Dim sPath As String
  
  sPath = M01Functions.DemoDiagramFile() 'as String 
  TextBoxPath.SelectAll()
  TextBoxPath.Insert(sPath)
  ReadG(sPath, False) 'True=Dialogfenster
  PaintDiagramAll()
  LabelInfoMenu.Text = mnuBeispieldatei.Text
  LabelInfoPathG(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Function DiagramEmpty() As Image
  
  Dim it, it2, iScalaH As Integer
  Dim Img As Image
  Dim fY, fRadius, fScaleUnitHH, fScaleUnitMM As Float
  Dim iDiagramRect As Rect '(x,y,w,h)
  Dim bAntiAliasON As Boolean
  
  bAntiAliasON = True
  
  ''—▶  >>    'Reset
  PicBoxDiagram.Move(0, 0, ScrollViewDiagram.ClientW, ScrollViewDiagram.ClientH)  '(-Scrollbar)
  PicBoxDiagram.Picture = Null
  PicBoxDiagram.Stretch = True
  
  ''Paint-Area:
  Img = New Image(PicBoxDiagram.W, PicBoxDiagram.H, F_iDiagrammHintergrundfarbe)
  
  iScalaH = PicBoxDiagram.H - F_iTopBorder - F_iBottomBorder 
  fScaleUnitHH = iScalaH / 24
  fScaleUnitMM = fScaleUnitHH / 60
  fRadius = fScaleUnitHH * 0.1
  
  iDiagramRect = New Rect(F_iTime24BorderLeft, F_iTopBorder, PicBoxDiagram.W - (F_iTime24BorderLeft + F_iTime24BorderRight), iScalaH)
  'Number Days DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  
  Paint.Begin(Img) 
  Paint.AntiAlias = bAntiAliasON      
  Paint.LineCap = Paint.LineCapRound 'as Integer=1
  ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
  Paint.LineJoin = Paint.LineJoinRound 'as Integer
  ''00 h ___________________________________________________________________ 00:00''
  ''Lines:
  For it = 0 To 23 ' Uhrzeit-Linien 00:00 - 24:00 . x,y links oben anfangen
    If F_bESCpressedON = True Then Break
    fY = iDiagramRect.Top + (fScaleUnitHH * it) '▼__▼
    ''_Lines_:
    Paint.MoveTo(iDiagramRect.Left, fY)
    Paint.LineTo(iDiagramRect.Left + iDiagramRect.W, fY) '_____ 01:00h
    Paint.Brush = Paint.Color(Color.LightGray)
    Paint.Stroke()
  Next 
  ''Text 00:00
  For it = 0 To 23 ' Uhrzeit-Linien 00:00 - 24:00 . x,y links oben anfangen
    If F_bESCpressedON = True Then Break
    fY = iDiagramRect.Top + (fScaleUnitHH * it) '▼__▼
    ''00:00 Clock-Text:
    it2 = 23 - it 'umgekehrte Zählung  24:00— 23:00— 22:00—... 01:00— 00:00—
    If it2 < 24 Then 
      Paint.Font.Size = fScaleUnitHH * 0.5
      Paint.Text(Format(it2, "00") & " h", 0, fY, iDiagramRect.Left, fScaleUnitHH, Align.Center)  'Left: 00:00|◀
      Paint.Text(Format(it2, "00") & ":00", iDiagramRect.Left + iDiagramRect.W, fY, F_iTime24BorderRight, fScaleUnitHH, Align.Center) 'Right: ▶|00:00
      Paint.Brush = Paint.Color(Color.Blue)
      Paint.Fill()
    Endif 
  Next 
  ''00 h ___________________________________________________________________ 00:00''
  
  ''□ Border, Area:
  Paint.Rectangle(iDiagramRect.Left, iDiagramRect.Top, iDiagramRect.W, iDiagramRect.H, fRadius)
  Paint.LineWidth = fScaleUnitHH * 0.1
  Paint.Brush = Paint.Color(Color.Blue)
  Paint.Stroke()
  Paint.End 
  
  LabelDiagramTitle.Text = ("Leer. Neue Seite")
  LabelDiagramTitle.Foreground = Color.Red
  LabelDiagramTitle.Font.Bold = True 
  LabelDiagramTitle.Visible = True 
  LabelDiagramTitle.Raise() 'Top level▲
  
  Return Img
  
Catch 
  FMain.ErrorText
  
End

Public Sub DiagramPaint()
  
  Dim it, iKey, it2, iCount, iPos, iBeforeX, iBeforeY As Integer
  Dim iDays7Min, iWeekDays7Sum, iWeekSumAll, iWeekDaysUntil7Counter, iSecondsAll As Integer
  Dim iScalaH, iHeight1, iHeight2, iPosL, iPosL2, iTextH, iPicDiagramW As Integer
  Dim iPicDiagramH, iBottomTextY, iLegendTopLineY As Integer
  Dim iZeit1HH, iZeit1MM As Integer
  Dim iHHNNSecond1, iHHNNSecond2, iDaySeconds, iWeekLast As Integer
  Dim iSS, iHH, iNN As Integer 'iYYYY, iMM, iDD, iHH, iNN, iSS
  Dim iDay, iDays, iColorWD, iColor1 As Integer 'Year, Month (M), Day, Hour, Minute (N), Second
  Dim iTimeWindow, iScrollBarH, iDay24hSeconds, iDaySumSeconds As Integer
  Dim iiColors7D As New Integer[7] 'Week 0-6
  Dim iiDayAllSeconds, iiWeekDays As New Integer[]
  Dim fColumnW, fScaleUnitHH, fScaleUnitMM, fColumnFixWidth50, fScaleUnitSecond, fRadius As Float
  Dim sValue, sYYYYMMDD, sDDDD, sKey As String 
  Dim sHHNN1, sHHNN2 As String 
  Dim sDatum, sWeekDay, sTxt1, sTxt2, sTimeWindowText As String
  Dim ssDatesMinMax, ssDatesAndWeekdays, ssSpli, ssKeys, ssKeysError As New String[]
  Dim bAntiAliasON As Boolean
  Dim iDiagramRect As Rect 'Rectangle as Integer (x,y,w,h)
  Dim hColumn As F_iColumnViewValues 'see Form head▲ 
  Dim Img, ImgTemp As Image
  Dim PicEmpty, PicQuestionRed As Picture
  Dim dateMin, dateMax, dateDatum, dateZeit As Date
  Dim dateAll As Date[]
  
  ''Check Correct?
  ' If F_bCorrectListON = True Then ColumnViewCorrectLines()
  
  bAntiAliasON = True
  F_sDiagramTitle = "" 
  sTimeWindowText = ("0 Zeit-Fenster, siehe Einstellungen")
  
  'Reset
  PicBoxDiagram.Picture = Null
  PicBoxDiagram.Stretch = True
  
  ImgTemp = New Image(22, 22, Color.Transparent)
  PicEmpty = ImgTemp.Picture 
  PicQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(22, 22).Picture
  
  '' Paint Pic Question: "?"
  ' Paint.Begin(ImgTemp)
  ' Paint.AntiAlias = bAntiAliasON 
  ' Paint.LineCap = Paint.LineCapRound 'as Integer=1
  ' ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
  ' Paint.LineJoin = Paint.LineJoinRound 'as Integer
  ' Paint.Font.Size = ImgTemp.H * 0.75 
  ' Paint.Text("?", 0, 0, ImgTemp.W, ImgTemp.H, Align.Center)
  ' Paint.Brush = Paint.Color(Color.White)
  ' Paint.LineWidth = 4
  ' Paint.Stroke(True)
  ' Paint.Brush = Paint.Color(Color.Red) 'Rot: falsche oder doppelte Werte können addierend größer als 24 Std. werden?
  ' Paint.LineWidth = 0.5
  ' Paint.Stroke(True)
  ' Paint.Fill()
  ' Paint.End 
  ' PicQuestionRed = ImgTemp.Picture
  ' PicQuestionRed.Save(FilePathForm() & ".png")
  ' PicQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(22, 22).Picture
  
  hColumn = F_ooColumnViewValues[0]
  
  ''Colors Weekdays SuSa:
  iiColors7D[0] = ColorButton1.Value 'Farbe ändern über Button Background
  iiColors7D[1] = ColorButton2.Value
  iiColors7D[2] = ColorButton3.Value
  iiColors7D[3] = ColorButton4.Value
  iiColors7D[4] = ColorButton5.Value
  iiColors7D[5] = ColorButton6.Value
  iiColors7D[6] = ColorButton7.Value
  F_bESCpressedON = False
  PicBoxDiagram.ToolTip = ""
  ProgressBarONoff(True)
  ' ssWeekDays7SuSa = M01Functions.Weekdays0to6LocalLanguage() 'as String["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] '0-6
  
  fColumnFixWidth50 = 50 'as Float
  
  ''Legend, lettering (Legende, Beschriftung) Daten vorbereiten vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  ''Min-Max Days:
  If F_bPaintDiagramAllON = True Then 
    ssKeys = ColumnView1.Keys.Copy()   
  Else 
    ssKeys = ColumnView1.Selection.Copy()
  Endif 
  
  ssDatesMinMax = New String[]
  ssDatesMinMax.Sort() '> .FindSorted() 'Faster
  iDays7Min = 7 ' min. 1 Week = 7 Days
  ''Days:
  For Each sKey In ssKeys ''Keys "1", "2",...
    If ColumnView1[sKey].Text And ColumnView1[sKey].Text Like "*????-??-??*" Then 'only yyyy-mm-dd 1x
      If ssDatesMinMax.Find(ColumnView1[sKey].Text) = -1 Then ssDatesMinMax.Add(ColumnView1[sKey].Text) ''"0000-00-00" 
    Endif 
  Next 
  
  ''First - Last Day:
  If ssDatesMinMax.Max > -1 Then 
    ' ssDatesAndWeekdays.Sort() ''"0000-00-00 Su Key" 
    ssSpli = Split(ssDatesMinMax.First & gb.NewLine, gb.NewLine)
    dateMin = M01Functions.DateCheckyyyymmddhhnn(ssSpli[0], "00:00") 'as Date
    ssSpli = Split(ssDatesMinMax.Last & gb.NewLine, gb.NewLine)
    dateMax = M01Functions.DateCheckyyyymmddhhnn(ssSpli[0], "00:00") 'as Date
    iDays = DateDiff(dateMin, dateMax, gb.Day)
    If iDays < iDays7Min Then 
      dateMax = DateAdd(dateMin, gb.Day, iDays7Min)
      iDays = DateDiff(dateMin, dateMax, gb.Day)
    Endif 
  Else 
    dateMin = Now
    dateMax = DateAdd(dateMin, gb.Day, iDays7Min)
    iDays = DateDiff(dateMin, dateMax, gb.Day) 'as Integer DateDiff(old, new, Time-Area)' 0-Tag mitzählen
  Endif 
  
  ''...Legend, lettering (Legende, Beschriftung) Daten vorbereiten vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  ''Title:     Day Min -to- Day Max = Days
  ' If Not dateMin Then DateMin = Date
  ' If Not dateMax Then dateMax = DateAdd(dateMin, gb.Day, iDays7Min) 'Now
  ' iDays = DateDiff(dateMin, dateMax, gb.day) 'as Integer DateDiff(old, new, Time-Area)' 0-Tag mitzählen
  
  F_sDiagramTitle = Format(dateMin, "ddd dd.mm.yyyy") & " - " & Format(dateMax, "ddd dd.mm.yyyy") & " = " & Str(iDays) & Space(1) & ("Tage") 
  
  ssDatesAndWeekdays = New String[]
  ssDatesAndWeekdays.Sort() '> .FindSorted() 'Faster
  iiWeekDays = New Integer[]
  dateAll = New Date[]
  dateAll.Sort()
  For iDay = 0 To iDays  'min. 7 Days (1 Week)
    dateDatum = DateAdd(dateMin, gb.Day, iDay)
    sYYYYMMDD = Format(dateDatum, "yyyy-mm-dd")
    sDDDD = Format(dateDatum, "dddd") 'Example: "Sunday", ...So Mo Di Mi Do Fr Sa... > take S or Su or Sun
    ''0000-00-00 Sunday 0 000
    ssDatesAndWeekdays.Add(sYYYYMMDD & gb.NewLine & Str(WeekDay(dateDatum)) & gb.NewLine & sDDDD & gb.NewLine & "000") 
    iiWeekDays.Add(WeekDay(dateDatum)) 'Example: 0 (gb.Sunday)
    dateAll.Add(dateDatum)
  Next
  iiDayAllSeconds = New Integer[]
  iiDayAllSeconds.Resize(ssDatesAndWeekdays.Count) ' Not sort! (nicht sortieren, iPos aus ssDatesAndWeekdays)
  
  ''Diagram Width ◀——▶:
  If iDays < iDays7Min Then  '|Diagramm-Breite  >|
    If F_bPicDiagramLongerON = False Then 
      iPicDiagramW = ScrollViewDiagram.ClientW
    Else
      iPicDiagramW = ScrollViewDiagram.ClientW - (F_iTime24BorderLeft + F_iTime24BorderRight) 'left+right
    Endif 
  Else 
    If F_bPicDiagramLongerON = False Then 
      iPicDiagramW = ScrollViewDiagram.ClientW
    Else 
      iPicDiagramW = (fColumnFixWidth50 * iDays) + (F_iTime24BorderLeft + F_iTime24BorderRight) 
    Endif 
  Endif
  
  If iPicDiagramW < ScrollViewDiagram.ClientW Then iScrollBarH = 0 Else iScrollBarH = 22
  'Desktop.Y 'Gambas3: "It is an equivalent of Screens[0].AvailableY."
  
  ''...Legend, lettering (Legende, Beschriftung) Daten vorbereiten vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  ''Height ▼▲
  If F_bPicDiagramLongerON = False Then 
    iPicDiagramH = ScrollViewDiagram.ClientH 
  Else 
    iPicDiagramH = ScrollViewDiagram.ClientH - iScrollBarH '>Scrollbar
  Endif 
  
  ''—▶  >>    'Reset
  PicBoxDiagram.Move(0, 0, iPicDiagramW, iPicDiagramH) '.Move or .Resize
  PicBoxDiagram.Picture = Null
  PicBoxDiagram.Stretch = True
  
  ''Paint-Area:
  Img = New Image(PicBoxDiagram.W, PicBoxDiagram.H, F_iDiagrammHintergrundfarbe)
  
  iScalaH = PicBoxDiagram.H - F_iTopBorder - F_iBottomBorder 
  fScaleUnitHH = iScalaH / 24
  fScaleUnitMM = fScaleUnitHH / 60
  fRadius = fScaleUnitHH * 0.1
  iDay24hSeconds = 86400  '24h, 1 Tag  '1Day=24h=1440m=86400s
  fScaleUnitSecond = iScalaH / iDay24hSeconds
  
  iDiagramRect = New Rect(F_iTime24BorderLeft, F_iTopBorder, PicBoxDiagram.W - (F_iTime24BorderLeft + F_iTime24BorderRight), iScalaH)
  
  ''Diagram Border Time scale ▲▼ 00 h ______ 00:00
  ''...Legend, lettering (Legende, Beschriftung) Daten vorbereiten vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  Paint.Begin(Img) 
  Paint.AntiAlias = bAntiAliasON      
  Paint.LineCap = Paint.LineCapRound 'as Integer=1
  ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
  Paint.LineJoin = Paint.LineJoinRound 'as Integer
  ''00 h ___________________________________________________________________ 00:00''
  ''Lines:
  For it = 0 To 23 ' Uhrzeit-Linien 00:00 - 24:00 . x,y links oben anfangen
    If F_bESCpressedON = True Then Break
    iLegendTopLineY = iDiagramRect.Top + (fScaleUnitHH * it) '▼__▼
    ''_Lines_:
    Paint.MoveTo(iDiagramRect.Left, iLegendTopLineY)
    Paint.LineTo(iDiagramRect.Left + iDiagramRect.W, iLegendTopLineY) '_____ 01:00h
    Paint.Brush = Paint.Color(Color.LightGray)
    Paint.Stroke()
  Next 
  ''Text 00:00
  For it = 0 To 23 ' Uhrzeit-Linien 00:00 - 24:00 . x,y links oben anfangen
    If F_bESCpressedON = True Then Break
    iLegendTopLineY = iDiagramRect.Top + (fScaleUnitHH * it) '▼__▼
    ''00:00 Clock-Text:
    it2 = 23 - it 'umgekehrte Zählung  24:00— 23:00— 22:00—... 01:00— 00:00—
    If it2 < 24 Then 
      Paint.Font.Size = fScaleUnitHH * 0.5
      Paint.Text(Format(it2, "00") & " h", 0, iLegendTopLineY, iDiagramRect.Left, fScaleUnitHH, Align.Center)  'Left: 00:00|◀
      Paint.Text(Format(it2, "00") & ":00", iDiagramRect.Left + iDiagramRect.W, iLegendTopLineY + (fScaleUnitHH * 0.25), F_iTime24BorderRight, fScaleUnitHH, Align.Center) 'Right: ▶|00:00
      Paint.Brush = Paint.Color(Color.LightGray)
      Paint.Fill()
    Endif 
  Next 
  ''00 h ___________________________________________________________________ 00:00''
  
  '' |||||||||' LineWidth (Stiftbreite)
  ' If iDays = 0 Then iDays = 7
  If iDays > 0 Then fColumnW = iDiagramRect.W / (iDays + 1) Else fColumnW = fColumnFixWidth50 
  
  ''□ Border, Area:
  Paint.Rectangle(iDiagramRect.Left, iDiagramRect.Top, iDiagramRect.W, iDiagramRect.H, fRadius)
  Paint.LineWidth = fScaleUnitHH * 0.1
  Paint.Brush = Paint.Color(Color.Blue)
  Paint.Stroke()
  Paint.End
  
  iBottomTextY = iDiagramRect.Top + iDiagramRect.H + (F_iBottomBorder * 0.8)
  
  ''Chart (Diagramm)
  '..._S_M_D_M_D_F_S_... weekdays bottom (Wochen-Tag-Raster unten)   'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  ''Sorted. Date-Line from list (Sortiert. Datum-Zeilen in Liste)
  Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
  Paint.AntiAlias = bAntiAliasON    
  Paint.LineCap = Paint.LineCapRound 'as Integer=1
  ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
  Paint.LineJoin = Paint.LineJoinRound 'as Integer
  
  ''see>: ssKeys = ColumnView1.Selection.Copy() Or ssKeys = ColumnView1.Keys.Copy() 'All
  For Each sKey In ssKeys 'Example: "3". Only Keys, not Lines with Columns
    
    If F_bESCpressedON = True Then Break
    iCount = iCount + 1
    If iCount Mod 500 = 0 Then ProgressBarONoff(True)
    
    ''Take 0000-00-00
    sDatum = ColumnView1[sKey][0] '0000-00-00
    
    ''Add (+addieren+)
    ''One Day, one Line (Ein Tag, eine Zeile)
    If sDatum Then iPos = ssDatesAndWeekdays.Find("*" & sDatum & "*", gb.Like) Else iPos = -1 '0000-00-00  '-1 not found  
    If iPos > -1 Then 
      sWeekDay = Format(dateAll[iPos], "dddd")
      iColorWD = iiColors7D[iiWeekDays[iPos]] 
      '::::::::::::::::::::::::::::::::::::::::::::::::::::::::
      sHHNN1 = ColumnView1[sKey][hColumn.i01HHMMA] 'Example A: "12:34"
      sHHNN2 = ColumnView1[sKey][hColumn.i06HHMMB] 'Example B: "12:35"  '::::::::::::::::::::::::::::::::::::::::::::::::::::::::
      If String.InStr(sHHNN2, ":") = 0 Then 'Search Clock B (zweite Uhrzeit suchen)
        For it2 = 2 To ColumnView1.Columns.Max
          sHHNN2 = ColumnView1[sKey][it2] 'Uhr
          If String.InStr(sHHNN2, ":") > 0 Then Break
        Next
      Endif
      If sHHNN2 = "24:00" Then sHHNN2 = "23:59"      '24:00 = 00:00
      
      ssSpli = Split(sHHNN1 & ":", ":")
      If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0]) Else iHH = 0
      If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1]) Else iNN = 0
      iHHNNSecond1 = (iHH * 60 * 60) + (iNN * 60)
      
      ssSpli = Split(sHHNN2 & ":", ":")
      If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0]) Else iHH = 0
      If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1]) Else iNN = 0 
      iHHNNSecond2 = (iHH * 60 * 60) + (iNN * 60)
      
      ''Day Sum:
      If IsInteger(ColumnView1[sKey][hColumn.i08Seconds]) = True Then 'Example: 12345   
        'Time-Difference in Seconds (Dauer in Sekunden)
        Try iDaySumSeconds = CInteger(ColumnView1[sKey][hColumn.i08Seconds]) 'Sekunden as Integer
      Else 'Alternative:
        
        Try iDaySumSeconds = iHHNNSecond2 - iHHNNSecond1
      Endif
      If iPos < iiDayAllSeconds.Count Then 
        iiDayAllSeconds[iPos] = iiDayAllSeconds[iPos] + iDaySumSeconds
        iWeekSumAll = iWeekSumAll + iDaySumSeconds
        iSecondsAll = iSecondsAll + iDaySumSeconds
      Endif 
      
      ''Column Chart _|||¡¡|¡|_ (Balken-Diagramm)
      iPosL = F_iTime24BorderLeft + (fColumnW * iPos) 
      iLegendTopLineY = iDiagramRect.Top + iDiagramRect.H 
      iHeight1 = iLegendTopLineY - (fScaleUnitSecond * iHHNNSecond1)
      iHeight2 = iLegendTopLineY - (fScaleUnitSecond * iHHNNSecond2)
      
      Paint.Rectangle(iPosL, iHeight1, fColumnW, iHeight2 - iHeight1, 0)
      Paint.Brush = Paint.Color(iColorWD)
      Paint.Fill(True)
      Paint.LineWidth = 1 ' Stiftbreite
      Paint.Stroke()
      
      ''Legend bottom ▼__▼
      Paint.Rectangle(iPosL, iBottomTextY - 6, fColumnW, 6, 0) ' ■□■□■□■□■□■□■□■□
      Paint.LineWidth = fColumnW ' Stiftbreite
      Paint.Brush = Paint.Color(iColorWD) 
      Paint.Fill(True)
      Paint.LineWidth = 1 ' Stiftbreite
      Paint.Stroke()
      
      If ToggleDiagramLine.Value = True Then 
        ''Month □□□■■■□□□
        If Month(dateAll[iPos]) Mod 2 = 0 Then 
          Paint.Brush = Paint.Color(Color.RGB(200, 200, 200)) 
        Else 
          Paint.Brush = Paint.Color(Color.RGB(240, 240, 240))
        Endif
        Paint.Rectangle(iPosL, iDiagramRect.Top + iDiagramRect.H + (fColumnW * 0.25), fColumnW, fColumnW * 0.25, 0)
        Paint.Fill()
        
        If Day(dateAll[iPos]) = 1 Then 
          Paint.Rectangle(iPosL, 0, 4, iPicDiagramH, 0)
          Paint.Brush = Paint.Color(Color.RGB(150, 150, 150)) 
          Paint.Fill()
        Endif 
        
        ''Text Date
        Paint.Font.Size = fColumnW * 0.2
        Paint.Text(Format(dateAll[iPos], "dd.mm" & gb.NewLine & "yyyy"), iPosL, iDiagramRect.Top + iDiagramRect.H - fColumnW, fColumnW, fColumnW, Align.Center)
        Paint.Brush = Paint.Color(Color.DarkBlue) 
        Paint.LineWidth = 1
        Paint.Fill()  
        
        ''KW, CalendarWeek (KalenderWoche)
        dateZeit = dateAll[iPos]
        If iWeekLast <> Week(dateZeit) Then 
          iWeekLast = Week(dateZeit)
          Paint.Font.Size = iDiagramRect.Top * 0.5
          Paint.Text(iWeekLast & ("KW"), iPosL, 0, fColumnW * 3, iDiagramRect.Top, Align.Left)
          Paint.Brush = Paint.Color(Color.Gray) 'doppelte Werte können addierend größer als 24 Std. werden
          Paint.LineWidth = 1
          Paint.Stroke(True)
          Paint.Fill()  
        Endif 
      Endif       
      
      ''Text-Size 
      Paint.Font.Size = fColumnW * 0.5 
      If Paint.Font.Size > iDiagramRect.Left * 0.5 Then Paint.Font.Size = iDiagramRect.Left * 0.5
      If fColumnW > fColumnFixWidth50 Then
        sWeekDay = String.Left(sWeekDay, 2) 'So Mo Di Mi Do Fr Sa  
      Else 
        sWeekDay = String.Left(sWeekDay, 1) 'S M D M D F S
      Endif
      'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
      Try Paint.Text(sWeekDay, iPosL, iDiagramRect.Top + iDiagramRect.H, fColumnW, F_iBottomBorder * 0.8, Align.Center)
      Paint.Brush = Paint.Color(Color.White)
      Paint.LineWidth = 6
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(iColorWD)
      Paint.LineWidth = 1
      Paint.Stroke(True)
      Paint.Fill()
      
      ''?, Red Point, Sum-Error?
      If iiDayAllSeconds[iPos] < 0 Or iiDayAllSeconds[iPos] > iDay24hSeconds Then 
        'größer als 24h, 1 Tag      '1Day=24h=1440m=86400s
        ssKeysError.Add(sKey) 'Example: "16"
        Paint.Font.Size = fColumnW * 0.5 
        Paint.Text("?", iPosL, iDiagramRect.Top + iDiagramRect.H, fColumnW, F_iBottomBorder, Align.Bottom)
        Paint.Brush = Paint.Color(Color.White)
        Paint.LineWidth = 4
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.Red) 'doppelte Werte können addierend größer als 24 Std. werden
        Paint.LineWidth = 0.5
        Paint.Stroke(True)
        Paint.Fill()
        '"?" as Text, as Picture > PicQuestionRed
      Endif 
    Endif 'iPos
  Next 'sKey'-----------------------------------------
  Paint.End
  
  ''_|||¡¡|¡|_ Column Diagram duration ▼_bottom_▼ (Dauer als Balkendiagramm) BBBBBBBBBBBBBBBBBBBBBB 
  If ToggleColumnDiagram.Value = True Then       'iDaySumSeconds Durchschnitt   00:00 bis 08:00 = 8 Std.  
    Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
    Paint.AntiAlias = bAntiAliasON      
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    Paint.Rectangle(iDiagramRect.Left, iDiagramRect.Top, iDiagramRect.W, iDiagramRect.H, fRadius)
    Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 50)) 'Paint over Glass
    Paint.Fill()
    If ssDatesAndWeekdays.Count <> iiDayAllSeconds.Count Then iiDayAllSeconds.Resize(ssDatesAndWeekdays.Count)
    For iDay = 0 To ssDatesAndWeekdays.Max
      If F_bESCpressedON = True Then Break
      iDaySeconds = iiDayAllSeconds[iDay] * fScaleUnitSecond
      If iDaySeconds > 0 Then 
        iPosL = iDiagramRect.Left + (fColumnW * iDay) 
        iColorWD = iiColors7D[iiWeekDays[iDay]] 
        iLegendTopLineY = iDiagramRect.Top + iDiagramRect.H
        iHeight1 = iLegendTopLineY 
        iHeight2 = iLegendTopLineY - iDaySeconds 
        If iHeight2 < iDiagramRect.Top Then iHeight2 = iDiagramRect.Top
        ''Column Chart _|||¡¡|¡|_
        Paint.Rectangle(iPosL, iHeight1, fColumnW, iHeight2 - iHeight1, 0) 'fRadius
        Paint.Brush = Paint.Color(iColorWD)
        Paint.Fill(True)
        Paint.LineWidth = 1 ' Stiftbreite
        Paint.Stroke()
      Endif 'iDaySeconds
    Next
    Paint.End
  Endif 
  'Dauer als Balkendiagramm, bottom BBBBBBBBBBBBBBBBBBBBBB
  
  ''...Extra
  ''⊂⊃ Time-Window 1, 2, 3: Ξ□Ξ ----------------------- Main-Time Border
  If ToggleFrame.Value = True Then
    Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
    Paint.AntiAlias = bAntiAliasON  
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    F_bbTimeWindows = Settings[F_sForm &/ "F_bbTimeWindows", F_bbTimeWindows]
    If Not F_bbTimeWindows Then F_bbTimeWindows = New Boolean[3]
    
    'Borders (Rahmen) 33333333333333333333333333333333333
    For iTimeWindow = 0 To 2 '3x
      If F_bESCpressedON = True Then Break
      If iTimeWindow = 0 And F_bbTimeWindows[0] = True Then 
        sHHNN1 = TextK1.Text 'Example: "07:00"
        sHHNN2 = TextK2.Text 'Example: "16:00"
      Else If iTimeWindow = 1 And F_bbTimeWindows[1] = True Then  
        sHHNN1 = TextK3.Text 
        sHHNN2 = TextK4.Text
      Else If iTimeWindow = 2 And F_bbTimeWindows[2] = True Then  
        sHHNN1 = TextK5.Text
        sHHNN2 = TextK6.Text 
      Endif 
      If F_bbTimeWindows[iTimeWindow] = True Then 
        If sHHNN1 <> "00:00" And sHHNN2 <> "00:00" Then
          ssSpli = Split(sHHNN1 & ":", ":")
          If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0]) Else iHH = 0
          If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1]) Else iNN = 0
          iHeight1 = iScalaH - (fScaleUnitHH * iHH) - (fScaleUnitMM * iNN)
          
          ssSpli = Split(sHHNN2 & ":", ":")
          If IsInteger(ssSpli[0]) = True Then iHH = CInteger(ssSpli[0]) Else iHH = 0
          If IsInteger(ssSpli[1]) = True Then iNN = CInteger(ssSpli[1]) Else iNN = 0
          iHeight2 = iScalaH - (fScaleUnitHH * iHH) - (fScaleUnitMM * iNN)
          
          Paint.Brush = Paint.Color(F_iSelectGreenAlpha220)
          Paint.Rectangle(iDiagramRect.Left, iHeight1, iDiagramRect.W, iHeight2 - iHeight1, 0)
          Paint.Fill(True)
          Paint.Brush = Paint.Color(Color.Red) '□ Border 
          Paint.LineWidth = 2 ' Stiftbreite
          Paint.Stroke()
        Endif
        sTimeWindowText = "" 'min. 1 Exist, no info
      Endif 
    Next 
    Paint.End 
  Endif
  '⊂⊃ Kernzeitrahmen------------------------ Main-Time Border
  
  ''...Extra
  ''° Line _/\ ● Point   'Duration (Dauer) DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 
  If ToggleDiagramLine.Value = True Then       'iDaySumSeconds Durchschnitt   00:00 bis 08:00 = 8 Std.  
    Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
    Paint.AntiAlias = bAntiAliasON
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    iBeforeX = F_iTime24BorderLeft
    iBeforeY = iDiagramRect.Top + iDiagramRect.H 
    For iKey = 0 To iiDayAllSeconds.Max
      If F_bESCpressedON = True Then Break
      iPosL = F_iTime24BorderLeft + (fColumnW * iKey) + (fColumnW / 2) 'Mitte Strichbreite
      dateZeit = M01Functions.Seconds24hDate(iiDayAllSeconds[iKey]) 'as Date 01.01.2018 00:00:00
      iZeit1HH = Hour(dateZeit)
      iZeit1MM = Minute(dateZeit)
      If iiDayAllSeconds[iKey] > iDay24hSeconds Then 'größer als 24h, 1 Tag  '1Day=24h=1440m=86400s
        iColor1 = Color.Red 'doppelte Werte können addierend größer als 24 Std. werden
      Else
        iColor1 = Color.Blue
      Endif
      Try iHeight1 = (iDiagramRect.Top + iDiagramRect.H) - (fScaleUnitHH * iZeit1HH) - (fScaleUnitMM * iZeit1MM)
      
      ''Point ●
      Paint.Arc(iPosL, iHeight1, 5)
      Paint.Brush = Paint.Color(Color.White)
      Paint.LineWidth = 4 ' Stiftbreite
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(iColor1)
      Paint.Fill()
      
      ''Line _/\
      Paint.MoveTo(iBeforeX, iBeforeY)
      Paint.LineTo(iPosL, iHeight1)
      Paint.LineWidth = 6
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
      Paint.LineWidth = 3
      Paint.Brush = Paint.Color(Color.DarkBlue)
      Paint.Stroke()
      
      ''Next Position:
      iBeforeX = iPosL
      iBeforeY = iHeight1
    Next
    Paint.End 
    
    Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
    Paint.AntiAlias = bAntiAliasON
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    iBeforeX = F_iTime24BorderLeft
    iBeforeY = iDiagramRect.Top + iDiagramRect.H 
    
    For iKey = 0 To iiDayAllSeconds.Max  '=ssDatesAndWeekdays.Max
      If F_bESCpressedON = True Then Break
      iPosL = F_iTime24BorderLeft + (fColumnW * iKey) + (fColumnW / 2) 'Mitte Strichbreite
      dateZeit = M01Functions.Seconds24hDate(iiDayAllSeconds[iKey]) 'as Date 01.01.2018 00:00:00
      iZeit1HH = Hour(dateZeit)
      iZeit1MM = Minute(dateZeit)
      If iiDayAllSeconds[iKey] > iDay24hSeconds Then 'größer als 24h, 1 Tag  '1Day=24h=1440m=86400s
        iColor1 = Color.Red 'doppelte Werte können addierend größer als 24 Std. werden
      Else
        iColor1 = Color.Blue
      Endif
      Try iHeight1 = (iDiagramRect.Top + iDiagramRect.H) - (fScaleUnitHH * iZeit1HH) - (fScaleUnitMM * iZeit1MM)
      
      ' ''Point ●
      ' Paint.Arc(iPosL, iHeight1, 5)
      ' Paint.Brush = Paint.Color(Color.White)
      ' Paint.LineWidth = 4 ' Stiftbreite
      ' Paint.Stroke(True)
      ' Paint.Brush = Paint.Color(iColor1)
      ' Paint.Fill()
      ' 
      ' ''Line _/\
      ' Paint.MoveTo(iBeforeX, iBeforeY)
      ' Paint.LineTo(iPosL, iHeight1)
      ' Paint.LineWidth = 6
      ' Paint.Brush = Paint.Color(Color.White)
      ' Paint.Stroke(True)
      ' Paint.LineWidth = 3
      ' Paint.Brush = Paint.Color(Color.DarkBlue)
      ' Paint.Stroke()
      
      ''Text:
      sValue = Format(dateZeit, "hh:nn")
      iTextH = Paint.Font.TextHeight(sValue)
      Paint.Font.Size = LabelDiagramTitle.Font.Size
      If sValue <> "00:00" Then Paint.Text(sValue, iPosL - (fColumnW / 2), iHeight1 - iTextH, fColumnW, iTextH, Align.Center)
      Paint.LineWidth = 3
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.DarkBlue)
      Paint.Fill()
      
      ''Next Position:
      iBeforeX = iPosL
      iBeforeY = iHeight1
    Next
    Paint.End 
  Endif 
  'Dauer DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  
  ''...Extra
  ''Week ■■■■ = ∅
  '∅ Weekday (Wochendurchschnitt) WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
  If ToggleWeekSumMiddle.Value = True Or ToggleProWeekHours.Value = True Then 
    Paint.Begin(Img) 'Image (Img) als Zeichnungsfläche, Grundlage zum Zeichnen und Malen
    Paint.AntiAlias = bAntiAliasON      
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    Paint.Font.Size = LabelDiagramTitle.Font.Size
    iLegendTopLineY = iDiagramRect.Top + iDiagramRect.H
    iWeekDays7Sum = 0
    iWeekDaysUntil7Counter = 0
    
    For iDay = 0 To iiWeekDays.Max
      If F_bESCpressedON = True Then Break 
      
      iCount = iCount + 1
      If iCount Mod 500 = 0 Then ProgressBarONoff(True)
      
      iWeekDaysUntil7Counter = iWeekDaysUntil7Counter + 1
      
      If iiWeekDays[iDay] = gb.Sunday Or iDay = iiWeekDays.Max Then 
        ''Begin:
        If iiWeekDays[iDay] = gb.Sunday And iDay < 7 Then 
          iWeekDaysUntil7Counter = iDay - iiWeekDays[iDay] 
          iPosL = F_iTime24BorderLeft + (fColumnW * 1)
        Else 'Other:
          iPosL = F_iTime24BorderLeft + (fColumnW * iDay)  
        Endif 
        ''End:
        If iDay = iiWeekDays.Max Then 
          iWeekDaysUntil7Counter = iiWeekDays[iDay] + 1
          iPosL = F_iTime24BorderLeft + (fColumnW * (iDay + 1))
          iWeekDays7Sum = iWeekDays7Sum + iiDayAllSeconds[iDay]
        Endif      
        
        iPosL2 = iPosL - (fColumnW * iWeekDaysUntil7Counter)
        If iWeekDaysUntil7Counter = 0 Then iWeekDaysUntil7Counter = 1 'Error if Division by zero
        iHeight1 = iLegendTopLineY - (fScaleUnitSecond * (iWeekDays7Sum / iWeekDaysUntil7Counter))
        
        ''| Week | Week |...
        Paint.LineWidth = 2
        Paint.MoveTo(iPosL, iLegendTopLineY)
        Paint.LineTo(iPosL, iDiagramRect.Top)
        Paint.Brush = Paint.Color(Color.Yellow)
        Paint.Stroke()
        
        ''Week ■■■■ Line
        Paint.LineWidth = 10 ' Stiftbreite
        Paint.MoveTo(iPosL, iHeight1)
        Paint.LineTo(iPosL2, iHeight1)
        Paint.Brush = Paint.Color(Color.Blue)
        Paint.Stroke()
        
        '' W=
        Paint.Font.Size = fColumnW 
        If Paint.Font.Size > 15 Then Paint.Font.Size = 15
        If ToggleProWeekHours.Value = True Then
          ' dateZeit = M01Functions.Seconds24hDate(iWeekDays7Sum) 'as Date 01.01.2018 00:00:00
          iSS = iWeekDays7Sum 
          dateZeit = DateAdd(Date, gb.Second, iSS)'60×60×24×7=604800
          iNN = DateDiff(Date, dateZeit, gb.Minute)
          iHH = CInteger(iNN / 60) '1,23 > 1
          iNN = iNN Mod 60  '1,23 > 23
          Paint.Text("W=" & Format(iHH, "0") & ":" & Format(dateZeit, "nn") & Space(1) & "=" & iWeekDaysUntil7Counter & ("T"), iPosL2, iHeight1 - (Paint.Font.Size * 2), fColumnW * iWeekDaysUntil7Counter, Paint.Font.Size * 1, Align.Top)
        Endif 
        
        '' T∅
        If ToggleWeekSumMiddle.Value = True Then
          dateZeit = M01Functions.Seconds24hDate(iWeekDays7Sum / iWeekDaysUntil7Counter) 'as Date 01.01.2018 00:00:00
          Paint.Text(("1T") & "∅" & Format(dateZeit, "hh:nn"), iPosL2, iHeight1 - (Paint.Font.Size * 2), fColumnW * iWeekDaysUntil7Counter, Paint.Font.Size * 3, Align.Bottom)
        Endif 
        
        Paint.Brush = Paint.Color(Color.White)
        Paint.LineWidth = Paint.Font.Size / 3
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.Blue) 'doppelte Werte können addierend größer als 24 Std. werden
        ' Paint.LineWidth = 0.5
        ' Paint.Stroke(True)
        Paint.Fill()
        
        iWeekDays7Sum = 0 'Reset
        iWeekDaysUntil7Counter = 0
      Endif 
      
      iWeekDays7Sum = iWeekDays7Sum + iiDayAllSeconds[iDay]
      
    Next 'iiWeekDays'-----------------------------------------
    Paint.End
  Endif   'Not forget: For...Next Loop. Jump not out with Goto (Nicht mit Goto aus der Schleife springen) 
  
  ''Sum (Summe)
  sTxt1 = Str("ø") & Space(1) & ("Tag") & "=" 
  sTxt1 &= M01Functions.SecondsHHHNNSS(iSecondsAll / iDays) '1 Day
  sTxt2 = Str("ø") & Space(1) & ("7-Tage-Woche") & "=" 
  sTxt2 &= M01Functions.SecondsHHHNNSS((iSecondsAll / iDays) * iDays7Min) '7 Days = 1 Week
  'Note: no Division by Zero (Division mit Null = Error)
  F_sDiagramTitle = F_sDiagramTitle & gb.NewLine & sTxt1 & gb.NewLine & sTxt2
  ' LabelDiagramTitle.H = LabelDiagramTitle.Font.TextHeight(F_sDiagramTitle)
  
  ''Title:
  If F_bLabelDiagramTitleON = True Then 
    LabelDiagramTitle.Foreground = Color.DarkGreen
    LabelDiagramTitle.Font.Bold = True 
    If Not F_sDiagramTitle Then LabelDiagramTitle.Text = ("Titel") & Space(1) & ("leer") Else LabelDiagramTitle.Text = ("Titel")
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    Paint.Font.Name = "Ubuntu"
    ' Paint.Font.Bold = LabelDiagramTitle.Font.Bold
    Paint.Font.Size = LabelDiagramTitle.Font.Size
    Paint.Text(F_sDiagramTitle, iDiagramRect.Left, iDiagramRect.Top, Paint.Font.TextWidth(F_sDiagramTitle), Paint.Font.TextHeight(F_sDiagramTitle), Align.Center)
    Paint.LineWidth = 1
    Paint.Brush = Paint.Color(Color.Black)
    ' Paint.Stroke(True)
    Paint.Fill()
    Paint.End
  Else 
    LabelDiagramTitle.Text = ("Titel")
    LabelDiagramTitle.Foreground = Color.Red
    LabelDiagramTitle.Font.Bold = False
  Endif 
  
  ''Acutal Today (Heute):
  If ssDatesAndWeekdays Then 
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON
    Paint.LineCap = Paint.LineCapRound 'as Integer=1
    ' Paint.LineCap = Paint.LineCapButt 'as Integer=0
    Paint.LineJoin = Paint.LineJoinRound 'as Integer
    
    sDatum = Format(Date, "yyyy-mm-dd") 'yyyy-mm-dd ("0000-00-00")
    iPos = ssDatesAndWeekdays.Find("*" & sDatum & "*", gb.Like) '0000-00-00  '-1=nicht gefunden  0,1,2,3...n-1
    If iPos > -1 Then 
      iPosL = F_iTime24BorderLeft + (fColumnW * iPos) 
      Paint.Rectangle(iPosL + 1, iDiagramRect.Top + 1, fColumnW - 2, iDiagramRect.H - 2, fRadius)
      Paint.Brush = Paint.Color(F_iSelectGreenAlpha220)
      Paint.Fill(True)
      Paint.LineWidth = 2 ' Stiftbreitey
      Paint.Stroke()
      
      ''Triangle Today △ (Heute, aktuelle Zeitstufe)
      Paint.Brush = Paint.Color(Color.DarkGreen) 
      Paint.MoveTo(iPosL + 1, iHeight2)
      Paint.LineTo(iPosL + 1 + (fColumnW / 2), iHeight2 - (fColumnW * 0.5))
      Paint.LineTo(iPosL + 1 + fColumnW - 2, iHeight2)
      Paint.ClosePath()
      Paint.LineWidth = 2 ' Stiftbreite
      Paint.Stroke()
      
      ''Text:
      Paint.Font.Size = iDiagramRect.Top * 0.5 
      Paint.Text(("Heute"), iPosL, 0, fColumnW, iDiagramRect.Top, Align.Center)
      Paint.Brush = Paint.Color(Color.White)
      Paint.LineWidth = 4
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.DarkGreen) 
      Paint.LineWidth = 0.5
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    Paint.End
  Endif 
  
  ''Diagram as Picture:
  PicBoxDiagram.Picture = Img.Picture.Copy()
  
  If ssKeysError.Count > 0 Then  'as New String[] in Head?
    PicBoxDiagram.ToolTip = "? " & ("Rot. Fehler oder zuviele Daten in der Liste?") 
    ListColumnCorrect.Text = ssKeysError.Count
    ''Error-Lines:
    For Each sKey In ssKeysError
      ColumnView1[sKey].Picture = PicQuestionRed
      ColumnView1[sKey].Background = F_iSelectRedAlpha220
    Next 
    ListColumnCorrect.Tooltip = ("?-Fehler Zeiten") & ": " & Str(ssKeysError.Count)
    ListColumnCorrect.Visible = True 
  Else 
    PicBoxDiagram.ToolTip = ""
    ListColumnCorrect.Text = 0
    ListColumnCorrect.Visible = True 
  Endif 
  If sTimeWindowText Then PicBoxDiagram.ToolTip = PicBoxDiagram.ToolTip & gb.NewLine & sTimeWindowText
  
  ' ''Check Correct?
  ' If ToggleColumnCorrecting.Value Then ColumnViewCorrectLines()
  
  ProgressBarONoff(False)
  
Catch 'Fehler einfangen
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise
  ProgressBarONoff(False)
  
End

Public Sub SettingsDiagram(Optional SpeichernTrue_LesenFalse As Boolean = False)
  
  If SpeichernTrue_LesenFalse = True Then 'Speichern
    If TextK1.Foreground = Color.red Then TextK1.Text = "07:00"
    If TextK2.Foreground = Color.red Then TextK2.Text = "16:00"
    If TextK3.Foreground = Color.red Then TextK3.Text = "00:00"
    If TextK4.Foreground = Color.red Then TextK4.Text = "00:00"
    If TextK5.Foreground = Color.red Then TextK5.Text = "00:00"
    If TextK6.Foreground = Color.red Then TextK6.Text = "00:00"
    Settings[F_sForm &/ "FarbeDiagrWTag1"] = ColorButton1.Value
    Settings[F_sForm &/ "FarbeDiagrWTag2"] = ColorButton2.Value
    Settings[F_sForm &/ "FarbeDiagrWTag3"] = ColorButton3.Value
    Settings[F_sForm &/ "FarbeDiagrWTag4"] = ColorButton4.Value
    Settings[F_sForm &/ "FarbeDiagrWTag5"] = ColorButton5.Value
    Settings[F_sForm &/ "FarbeDiagrWTag6"] = ColorButton6.Value
    Settings[F_sForm &/ "FarbeDiagrWTag7"] = ColorButton7.Value
    Settings[F_sForm &/ "DiagrammHintergrundfarbe"] = ColorButton8.Value
    Settings[F_sForm &/ "KernrahmenZeit1a"] = TextK1.Text
    Settings[F_sForm &/ "KernrahmenZeit1b"] = TextK2.Text
    Settings[F_sForm &/ "KernrahmenZeit2a"] = TextK3.Text
    Settings[F_sForm &/ "KernrahmenZeit2b"] = TextK4.Text
    Settings[F_sForm &/ "KernrahmenZeit3a"] = TextK5.Text
    Settings[F_sForm &/ "KernrahmenZeit3b"] = TextK6.Text
    Settings[F_sForm &/ "ToggleColumnDiagram"] = ToggleColumnDiagram.Value
    Settings[F_sForm &/ "ToggleWochenstunden"] = ToggleProWeekHours.Value
    Settings[F_sForm &/ "ToggleWocheDurchschnitt"] = ToggleWeekSumMiddle.Value
    Settings[F_sForm &/ "ToggleChartLine"] = ToggleDiagramLine.Value
    Settings[F_sForm &/ "ToggleFrame"] = ToggleFrame.Value
    Settings[F_sForm &/ "F_bCorrectListON"] = F_bCorrectListON
  Else 'Lesen
    ColorButton1.Value = Settings[F_sForm &/ "FarbeDiagrWTag1", ColorButton1.Value]
    ColorButton2.Value = Settings[F_sForm &/ "FarbeDiagrWTag2", ColorButton2.Value]
    ColorButton3.Value = Settings[F_sForm &/ "FarbeDiagrWTag3", ColorButton3.Value]
    ColorButton4.Value = Settings[F_sForm &/ "FarbeDiagrWTag4", ColorButton4.Value]
    ColorButton5.Value = Settings[F_sForm &/ "FarbeDiagrWTag5", ColorButton5.Value]
    ColorButton6.Value = Settings[F_sForm &/ "FarbeDiagrWTag6", ColorButton6.Value]
    ColorButton7.Value = Settings[F_sForm &/ "FarbeDiagrWTag7", ColorButton7.Value]
    ColorButton8.Value = Settings[F_sForm &/ "DiagrammHintergrundfarbe", ColorButton8.Value]
    TextK1.Text = Settings[F_sForm &/ "KernrahmenZeit1a", "07:00"]
    TextK2.Text = Settings[F_sForm &/ "KernrahmenZeit1b", "16:00"]
    TextK3.Text = Settings[F_sForm &/ "KernrahmenZeit2a", "00:00"]
    TextK4.Text = Settings[F_sForm &/ "KernrahmenZeit2b", "00:00"]
    TextK5.Text = Settings[F_sForm &/ "KernrahmenZeit3a", "00:00"]
    TextK6.Text = Settings[F_sForm &/ "KernrahmenZeit3b", "00:00"]
    '0 = Sunday and 6 = Saturday
    ButtonC1.Text = Format(DateAdd(Now, gb.Day, 0 - WeekDay(Now)), "ddd") 'So
    ButtonC2.Text = Format(DateAdd(Now, gb.Day, 1 - WeekDay(Now)), "ddd") 'Mo
    ButtonC3.Text = Format(DateAdd(Now, gb.Day, 2 - WeekDay(Now)), "ddd") 'Di
    ButtonC4.Text = Format(DateAdd(Now, gb.Day, 3 - WeekDay(Now)), "ddd") 'Mi
    ButtonC5.Text = Format(DateAdd(Now, gb.Day, 4 - WeekDay(Now)), "ddd") 'Do
    ButtonC6.Text = Format(DateAdd(Now, gb.Day, 5 - WeekDay(Now)), "ddd") 'Fr
    ButtonC7.Text = Format(DateAdd(Now, gb.Day, 6 - WeekDay(Now)), "ddd") 'Sa
    ToggleColumnDiagram.Value = Settings[F_sForm &/ "ToggleColumnDiagram", False] 
    ToggleProWeekHours.Value = Settings[F_sForm &/ "ToggleWochenstunden", False]
    ToggleWeekSumMiddle.Value = Settings[F_sForm &/ "ToggleWocheDurchschnitt", False]
    ToggleDiagramLine.Value = Settings[F_sForm &/ "ToggleChartLine", False]
    ToggleFrame.Value = Settings[F_sForm &/ "ToggleFrame", False]
    F_bCorrectListON = Settings[F_sForm &/ "F_bCorrectListON", False]
  Endif
  
  'Variable neu einlesen
  F_iDiagrammHintergrundfarbe = ColorButton8.Value
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines(Optional bCorrectON As Boolean = False)
  
  Dim it, iFound, iLine, iColumn, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 As String 
  Dim B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13 As String 
  Dim sK1, sLineBefore, sKeyLast As String
  Dim hDateT0, hDate0, hDate1, hDate2, hDate3, hDate4, hDateAdd, hDateSum, hDateTime1, hDateTime2 As Date
  Dim iSecond, iHH, iMM, iSecond24h, iDiff As Integer
  Dim sTime1, sTime2 As String
  Dim sValue, sLine, sLines, sTitle As String
  Dim bReadUnknownLineON As Boolean
  Dim ssWeekdays, ssTime, ssCheckDateSecondSum, ssKeys, ssKeysError, ssColumns, ssSpli As String[]  
  Dim iiCheckDateSecondSum As Integer[]
  Dim PicRefresh, PicOK, PicQuestion, PicQuestionRed, PicLineActual, PicEmpty, PicNull, PicAdd As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicRefresh = ColumnViewImages("PicRefresh").Picture
  PicOK = ColumnViewImages("PicOK").Picture
  PicQuestion = ColumnViewImages("PicQuestion").Picture
  PicEmpty = ColumnViewImages("PicEmpty").Picture
  PicLineActual = ColumnViewImages("PicLineActual").Picture
  PicQuestionRed = ColumnViewImages("PicQuestionRed").Picture
  PicAdd = ColumnViewImages("PicAdd").Picture
  PicNull = PicTemplateClockNull.Picture.Image.Stretch(F_i22, F_i22).Picture
  
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  
  If ColumnView1.Count > 0 Then
    F_sUnknownLinesText = "" 'Reset
    F_iOldLines = ColumnView1.Count
    ' Timer4Now.Enabled = False
    ssKeys = ColumnView1.Keys.Copy()
    If Not ssKeys Then ssKeys = New String[]
    
    If ColumnView1.Keys.Max > -1 Then 
      ' ssKeys = ColumnView1.Keys.Copy()
      ssCheckDateSecondSum = New String[]
      iiCheckDateSecondSum = New Integer[]
      ssKeysError = New String[]
      iSecond24h = 60 * 60 * 24 'max. seconds in 24h = 1 day
      
      For Each sK1 In ssKeys
        iLine = iLine + 1
        ' Print iLine & " " & ssKeys.Count
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        bReadUnknownLineON = False 'Reset
        sLineBefore = ""
        ''Before correcting: Original
        For iColumn = 0 To ColumnView1.Columns.Max
          If iColumn = F_iColumnUndo Then 
            sLineBefore &= "" & hTab 
          Else If iColumn < ColumnView1.Columns.Max Then 
            sLineBefore &= ColumnView1[sK1][iColumn] & hTab 
          Else 
            sLineBefore &= ColumnView1[sK1][iColumn] & gb.NewLine 
          Endif 
        Next
        ColumnView1[sK1].Background = Color.Default 'Reset
        
        T0 = Trim(ColumnView1[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView1[sK1][1]) '00:00
        T2 = Trim(ColumnView1[sK1][2]) 'Mo
        T3 = Trim(ColumnView1[sK1][3]) 'Q
        T4 = Trim(ColumnView1[sK1][4]) 'KW
        T5 = Trim(ColumnView1[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView1[sK1][6]) '00:00
          T7 = Trim(ColumnView1[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView1[sK1][8]) 'Sek.
          T9 = Trim(ColumnView1[sK1][9]) '00:00:00
          T9 = Replace(T9, gb.Cr, "") 'Windows-Return "\r"
          T10 = Trim(ColumnView1[sK1][10]) 'ColumnsUndo
          T11 = Trim(ColumnView1[sK1][11]) 'Icon, Edit
          T12 = Trim(ColumnView1[sK1][12]) 'Sortieren
          T13 = Trim(ColumnView1[sK1][13]) 'Nr
          T13 = Replace(T13, gb.Cr, "") 'Windows-Return "\r"
        Endif 
        
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8  'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T1 Like "??:??" Then
          sValue = Str(T1)
          T1 = M01Functions.TimeCheckHHMM(sValue) 
        Else If T1 Like "*??:??*" Then
          sValue = Str(T1)
          T1 = M01Functions.TimeCheckHHMM(sValue)
        Else 'find time in columns
          sValue = ""
          For iColumn = 0 To 5 'search time column "00:00"
            If ColumnView1[sK1][iColumn] Like "*??:??*" Then
              sValue = Str(ColumnView1[sK1][iColumn])
              Break
            Endif
          Next
          T1 = M01Functions.TimeCheckHHMM(sValue)
        Endif
        
        If T6 Like "??:??" Then
          sValue = Str(T6)
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Else If T6 Like "*??:??*" Then
          sValue = Str(T6)
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Else 'find time in columns
          sValue = ""
          For iColumn = 5 To 9 'search time column "00:00"
            If ColumnView1[sK1][iColumn] Like "*??:??*" Then
              sValue = Str(ColumnView1[sK1][iColumn])
              Break
            Endif
          Next
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Endif 
        
        If T0 Like "*????-??-??*" Then 
          hDateT0 = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        Else 'kein Datum oder Timer?
          hDateT0 = Null
          bReadUnknownLineON = True
        Endif 
        If hDateT0 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDateT0, "yyyy-mm-dd")
          T2 = Format(hDateT0, "ddd")
          T3 = M01Functions.DateQuarterG(hDateT0) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDateT0), "00") & ("KW") '00...52
        Endif 
        
        sTime1 = T1 '"hh:nn"
        sTime2 = T6 '"hh:nn"
        hDate1 = Null
        hDate2 = Null
        If hDateT0 Then hDate0 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), 0, 0, 0) 
        
        If sTime1 Like "??:??" Then 
          ssTime = Split(sTime1 & ":", ":")
          If ssTime Then 
            iHH = CInteger(ssTime[0])
            iMM = CInteger(ssTime[1])
          Endif 
          If hDateT0 Then hDate1 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), iHH, iMM, 0)
        Endif 
        
        If sTime2 Like "??:??" Then 
          ssTime = Split(sTime2 & ":", ":")
          If ssTime Then 
            iHH = CInteger(ssTime[0])
            iMM = CInteger(ssTime[1])
          Endif 
          If hDateT0 Then hDate2 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), iHH, iMM, 0)
        Endif 
        
        If hDate1 And hDate2 Then 
          hDateTime1 = hDate1
          hDateTime2 = hDate2
          iDiff = DateDiff(hDate1, hDate2, gb.Second) 
          If iDiff > -1 And iDiff < iSecond24h And T2 = T7 Then ' So<>Mo 
            T1 = Format(hDate1, "hh:nn") 'Old, First
            T2 = Format(hDate1, "ddd")
            T6 = Format(hDate2, "hh:nn") 'New, Last
            T7 = Format(hDate2, "ddd")
            iSecond = DateDiff(hDate1, hDate2, gb.Second) 
            T8 = Str(iSecond)
            hDateSum = Date(Year(hDate1), Month(hDate1), Day(hDate1), 0, 0, 0)
            T9 = Format(DateAdd(hDateSum, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            T10 = "" 'Selected True=-1  'ColumnsUndo
            T11 = "PicOK" 'Icon, Edit
            T12 = T0 & T1 'Sortieren
            B0 = ""
          Else
            hDate2 = Date(Year(hDate1), Month(hDate1), Day(hDate1), 23, 59, 59)  '—▶24:00
            T1 = Format(hDate1, "hh:nn") 'Old, First
            T2 = Format(hDate1, "ddd")
            T6 = Format(hDate2, "hh:nn")'"23:59"
            T7 = Format(hDate2, "ddd")
            iSecond = DateDiff(hDate1, hDate2, gb.Second) 
            T8 = Str(iSecond)
            hDateSum = Date(Year(hDate1), Month(hDate1), Day(hDate1), 0, 0, 0)
            T9 = Format(DateAdd(hDateSum, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            T10 = -1 'Selected True=-1  'ColumnsUndo
            T11 = "PicQuestion" 'Icon, Edit
            T12 = T0 & T1 'Sortieren
            
            ''—▶ next Day? ++++++++++++++++++++++++++++++++++++++++++++++++++
            hDateAdd = DateAdd(hDate1, gb.Day, 1) 'Errorxxxx
            hDate3 = Date(Year(hDateAdd), Month(hDateAdd), Day(hDateAdd), 0, 0, 0)   '00:00—▶
            hDate4 = Date(Year(hDateAdd), Month(hDateAdd), Day(hDateAdd), Hour(hDateTime2), Minute(hDateTime2), Second(hDateTime2)) 
            iSecond = DateDiff(hDate3, hDate4, gb.Second) 
            B0 = Format(hDate3, "yyyy-mm-dd")
            B1 = "00:00"
            B2 = Format(hDate3, "ddd")
            B3 = Str(M01Functions.DateQuarterG(hDate3)) & ("Q")
            B4 = Format(M01Functions.DateCalenderWeek(hDate3), "00") & ("KW") '00...52
            B5 = T5 'Project-Name
            B6 = Format(hDate4, "hh:nn")
            B7 = Format(hDate4, "ddd")
            B8 = Str(iSecond)
            B9 = Format(DateAdd(hDate3, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            B10 = -1  'Selected True=-1  'ColumnsUndo
            B11 = "PicAdd" 'Icon, Edit
            B12 = B0 & B1  'Sortieren
            B13 = T13 ' Nr
          Endif
          
          'Compare (mit korrigierter Zeile vergleichen)
          If ColumnView1[sK1][F_iColumnSelect] = "PicLineActual" Then 
            ColumnView1[sK1].Picture = PicLineActual 
            ColumnView1[sK1][F_iColumnSelect] = "PicLineActual"
            ColumnView1[sK1].Background = F_iSelectGreenAlpha220
            ColumnView1[sK1].Foreground = Color.Gray
          Else If bReadUnknownLineON = True Then  
            ColumnView1[sK1].Picture = PicQuestionRed 
            ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
            ColumnView1[sK1].Background = F_iSelectRedAlpha220
            ColumnView1[sK1].Foreground = Color.Gray
            ColumnView1[sK1].Selected = True
            If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
          Endif
          
          If T8 = 0 Then
            ''...
          Else If T0 Then 
            If T0 Like "????-??-??" Then 
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 
              ''Control Sum max. 24h
              iFound = ssCheckDateSecondSum.Find(T0)  '-1 not Found
              If iFound = -1 Then 
                ssCheckDateSecondSum.Add(T0)  ''no sort!
                iiCheckDateSecondSum.Add(iSecond)
                iFound = ssCheckDateSecondSum.Max
              Else 
                iiCheckDateSecondSum[iFound] = iiCheckDateSecondSum[iFound] + iSecond
              Endif 
            Endif 
            If iiCheckDateSecondSum[iFound] > iSecond24h Then
              ColumnView1[sK1].Picture = PicQuestionRed 
              ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
              ColumnView1[sK1].Background = F_iSelectRedAlpha220
              ColumnView1[sK1].Foreground = Color.Gray
            Else  
              sLines &= T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hTab & T6 & hTab & T7 & hTab & T8 & hTab & T9 & hTab & T10 & hTab & T11 & hTab & T12 & hTab & T13 & gb.NewLine 
              ' F_sUnknownLinesText &= sLines & gb.NewLine
            Endif 
          Endif 
          
          If B0 Then 
            If B0 Like "????-??-??" Then 
              If hDate3 And hDate4 Then iSecond = DateDiff(hDate3, hDate4, gb.Second) 
              iFound = ssCheckDateSecondSum.Find(B0)  '-1 not Found
              If iFound = -1 Then 
                ssCheckDateSecondSum.Add(B0)  ''no sort!
                iiCheckDateSecondSum.Add(iSecond)
                iFound = ssCheckDateSecondSum.Max
              Else 
                iiCheckDateSecondSum[iFound] = iiCheckDateSecondSum[iFound] + iSecond
              Endif 
            Endif 
            If iiCheckDateSecondSum[iFound] > iSecond24h Then 
              ColumnView1[sK1].Picture = PicQuestionRed 
              ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
              ColumnView1[sK1].Background = F_iSelectRedAlpha220
              ColumnView1[sK1].Foreground = Color.Gray
            Else 
              sLines &= B0 & hTab & B1 & hTab & B2 & hTab & B3 & hTab & B4 & hTab & B5 & hTab & B6 & hTab & B7 & hTab & B8 & hTab & B9 & hTab & B10 & hTab & B11 & hTab & B12 & hTab & B13 & gb.NewLine 
            Endif
          Endif 
        Endif 
      Next 
      
      If bCorrectON = True Then 
        ColumnView1.Clear()
        ssKeysError = New String[]
        If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
        ssSpli = Split(sLines & gb.NewLine, gb.NewLine)
        For Each sLine In ssSpli
          If sLine Then 
            ssColumns = Split(sLine & String(ColumnView1.Columns.Count, gb.Tab), gb.Tab)
            sK1 = ColumnView1.Count + 1
            ColumnView1.Add(sK1, "")
            ' ColumnView1[sK1].Picture = ColumnViewImages(ssColumns[F_iColumnSelect]).Picture
            For it = 0 To ColumnView1.Columns.Max
              If it = F_iColumnUndo Then 
                ColumnView1[sK1][it] = ""
              Else 
                ColumnView1[sK1][it] = ssColumns[it] 
              Endif 
            Next
            
            If ColumnView1[sK1][F_iColumnUndo] = "" Then 
              ColumnView1[sK1].Selected = False 
            Else 
              ColumnView1[sK1].Selected = True
            Endif
            
            Select Case ColumnView1[sK1][F_iColumnSelect]
              Case "PicLineActual" 
                ColumnView1[sK1].Picture = PicLineActual 
                ColumnView1[sK1].Background = F_iSelectGreenAlpha220
                ColumnView1[sK1].Foreground = Color.Gray
              Case "PicQuestionRed"
                ColumnView1[sK1].Picture = PicQuestionRed 
                ColumnView1[sK1].Background = F_iSelectRedAlpha220
                ColumnView1[sK1].Foreground = Color.Gray
                If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
                sKeyLast = sK1
                ' F_sUnknownLinesText &= sLine & gb.NewLine 'Error?xxxx
              Case "PicAdd" 
                ColumnView1[sK1].Picture = PicAdd
                ColumnView1[sK1].Background = F_iSelectGreenAlpha220
                ColumnView1[sK1].Foreground = Color.DarkBlue
                If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
                sKeyLast = sK1
                ' F_sUnknownLinesText &= sLine & gb.NewLine
              Case Else
                ColumnView1[sK1].Picture = PicOK 
                ColumnView1[sK1].Background = Color.Default 
            End Select
            
          Endif
        Next
      Endif
      F_sLinesCopy = F_sUnknownLinesText
      ButtonAddLineActualG()
      If ssKeysError.Count > 0 Then iUnknown = ssKeysError.Count Else iUnknown = 0
      
      ' PicBoxDiagram.ToolTip = "? " & ("Rot. Fehler oder zuviele Daten in der Liste?") 
      ListColumnCorrect.Text = iUnknown
      ''Error-Lines:
      ListColumnCorrect.Tooltip = ("?-Fehler Zeiten") & ": " & iUnknown
      ListColumnCorrect.Visible = True 
      
      F_iUnknownCounter = iUnknown
      mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
      If iUnknown > 0 Then sValue = ("Unbekannte=") & iUnknown & "?" Else sValue = ""
      sTitle = ("Geändert") & Space(1) & iUnknown & Space(1) & ("von") & Space(1) & ColumnView1.Count
      ColumnView1.Columns[5].Title = sTitle
      F_sUnknownLinesText = sTitle & gb.NewLine & F_sUnknownLinesText
      ' M01Functions.ProjectLine(Date, "07:00", ("Beispiel"), "12:00") & hReturn & F_sUnknownLinesText
      ' If ssKeysError.Count > 0 Then sK1 = ssKeysError.Last
      ' If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
      Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & Space(5) & Str((ColumnView1.Count) & Space(1) & sValue)
      LabelInfo.Text = sTitle
      LabelInfo.Visible = True 
      ColumnViewSort(F_iColumnSort)
      If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
    Endif 'ColumnView1.Selection.Max 
  Endif 'ColumnView1.Count
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  '◀▷'[......■■...]  False: [■■■□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'zurück zum Anfang
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 'Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicDiagramDrawG()
  
  If ScrollViewDiagram.Visible = False Then Side(1)
  
  If isListData() = False Then 
    PicBoxDiagram.Picture = DiagramEmpty().Picture 'as Image
  Else
    'Wait 0.3 'Aufbau
    DiagramPaint() 
    ' LabelDiagramTitle.Text = F_sDiagramTitle
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxDiagram_MouseUp()
  
  If Mouse.Right = True Then Menu1.Popup
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup(PicBackground.ScreenX, PicBackground.ScreenY)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewImagesRead()  'Note: Work with Images = faster. Convert to Picture at End.
  
  Dim ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgLineActual, ImgQuestionRed As Image
  Dim iSize As Integer
  
  ''End-Names:
  F_ssCVImgNames = ["PicAdd", "PicCut", "PicDouble", "PicDown", "PicEmpty", "PicFind", "PicHome", "PicMarkGreen", "PicOFF", "PicOK", "PicON", "PicQuestion", "PicRefresh", "PicSave", "PicUp", "PicWarning", "PicLineActual", "PicQuestionRed"]
  
  iSize = F_i22 'Pixel 
  ImgAdd = ListAdd.Picture.Image.Stretch(iSize, iSize)
  ImgCut = ListCut.Picture.Image.Stretch(iSize, iSize)
  ImgDouble = PicTemplateDouble.Picture.Image.Stretch(iSize, iSize)
  ImgDown = ListDown.Picture.Image.Stretch(iSize, iSize)
  ImgEmpty = New Image(iSize, iSize, Color.Transparent) 'Image is faster than Picture
  ImgFind = ListSearch.Picture.Image.Stretch(iSize, iSize) 
  ImgHome = PicTemplateLEDgreen.Picture.Image.Stretch(iSize, iSize) 
  ImgMarkGreen = ListMark.Picture.Image.Stretch(iSize, iSize) 'Flag
  ImgOff = PicTemplateConnectOff.Picture.Image.Stretch(iSize, iSize)
  ImgOK = PicTemplateApply.Picture.Image.Stretch(iSize, iSize) 
  ImgON = PicTemplateConnectON.Picture.Image.Stretch(iSize, iSize)
  ImgQuestion = PicTemplateQuestionRound.Picture.Image.Stretch(iSize, iSize)
  ImgRefresh = PicTemplateReChange.Picture.Image.Stretch(iSize, iSize)
  ImgSave = ButtonSave.Picture.Image.Stretch(iSize, iSize)
  ImgUp = ListUp.Picture.Image.Stretch(iSize, iSize)
  ImgWarning = IconError.Picture.Image.Stretch(iSize, iSize)
  ImgLineActual = PicTemplateAddLineActual.Picture.Image.Stretch(iSize, iSize)
  ImgQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(iSize, iSize)
  
  ''Images:
  F_ooColumnViewImages = [ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgLineActual, ImgQuestionRed]
  
  ''Example:
  'PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewImages(Optional sName As String = "PicEmpty") As Image
  
  Dim iFound As Integer
  
  If String.InStr(sName, "-") > 0 Then sName = Replace(sName, "-", "") '"-" for selected Line
  If F_ssCVImgNames And F_ooColumnViewImages Then iFound = F_ssCVImgNames.Find(sName) '-1 not found
  If iFound = -1 Then iFound = F_ssCVImgNames.Find("PicEmpty")
  
  Return F_ooColumnViewImages[iFound]
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG(Optional sDirFile As String = "", Optional bDialog As Boolean = False) ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File 'Stream
  Dim it, iUnknownCounter, iEmptyOrDouble, iLine, iLines As Integer
  Dim sKey, sLine, sLinePart, sText, sUnknown, sMessage, sDemo As String
  Dim ssExist, ssKeysAdd, ssKeysWarning As String[]
  Dim PicNew, PicEmpty, PicAdd, PicWarning As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  Error.Clear()
  
  ' PicEmpty = Img.Picture 'New Picture(22, 22, True) 'True=Transparent
  ' PicAdd = ListAdd.Picture.Image.Stretch(22, 22).Picture
  ' PicWarning = IconError.Picture.Image.Stretch(22, 22).Picture
  PicEmpty = ColumnViewImages("PicEmpty").Picture
  PicAdd = ColumnViewImages("PicAdd").Picture
  PicWarning = ColumnViewImages("PicWarning").Picture
  
  ''Reset:
  F_bESCpressedON = False
  IconError.Visible = False
  F_sUnknownLinesText = "" 
  
  ''Dialog:
  If bDialog = True Then 'Add+
    sDirFile = FileDialogPathReturn(sDirFile, "open", Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt]) 'no Path = cancel
    If Exist(sDirFile) = False Then Goto JumpEnd    'Cancel (Abgebrochen)
  Else 
    ColumnView1.Clear() 'delete all lines, but not title (header)
    F_longFilesRead = 0
  Endif
  
  ''File-Name or Standard or Demo:
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = False Then
    ''Empty, Demo-File
    sDemo = M01Functions.DemoFileTermineOrProjects(FilePathForm()) 'Terminwecker or Projects
    If Exist(sDemo) = True Then Try Move sDemo To sDirFile 
  Endif
  If sDirFile <> TextBoxPath.Text Then 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
  Endif 
  FilePathCheck()
  
  ''Check Columns:
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  F_iOldLines = ColumnView1.Count
  If F_iOldLines = 0 Then PicNew = PicEmpty Else PicNew = PicAdd
  ' ColumnView1.Header = True 
  ColumnView1.Visible = False
  ColumnView1.Sorted = False     'Enter-List (Liste nach Eingang aus Datei)
  
  ProgressBarONoff(True)
  Form16Diagramm.Window.Title = Application.Name & " - " & ("Datei lesen...")
  
  ''Check first lines. File-Format:
  ' If M01Functions.isTerminweckerFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  If M01Functions.isProjectFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  
  ''Backup:
  ' If Not F_ooCVBackups Then ColumnViewBackup()
  
  'Read and add Column Lines (Zeilen (rows) erzeugen)
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  If Exist(sDirFile) = True Then
    F_longFilesRead = F_longFilesRead + Stat(sDirFile).Size
    ssExist = New String[]
    ssKeysAdd = New String[]
    ssKeysWarning = New String[]
    
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    ssExist.Sort() '>Projects A-z
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If sLine And String.Left(sLine, 1) <> "#" And ssExist.ExistSorted(sLine) = False Then '.Find()? If sorted, then faster with .FindSorted() Factor ~10x    Integer, Boolean
        ssExist.Add(sLine) 
      Else 
        iEmptyOrDouble = iEmptyOrDouble + 1
      Endif 
      
      iLines = iLines + 1
      If iLines Mod 100 = 0 Then 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          sMessage = sDirFile & "<br>"
          If Stat(sDirFile).Size > 2000000 Then '2MiB
            sMessage &= M01Functions.FileSizeText(sDirFile) & "<br>"
            sMessage &= "<font color=red><b>" & ("Große Datei = Mehr Zeit") & "</b></font><br><br>"
            sMessage &= ("Zeile") & ": " & iLines & "<br>"
            sMessage &= ("Tipp: Menü > Datei > Auslagern...") 
          Endif 
          Select Case Message.Question(sMessage, ("weiter einlesen") & "...", ("Abbrechen"))
            Case 1 'no cancel
              F_bESCpressedON = False
            Case 2 'cancel
              Break
          End Select
        Endif 
        ProgressBarONoff(True) 
      Endif 
    Next 
    
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
    Error.Clear
  Endif 
  
  'Check "\r" Return,  Typ Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
  If Exist(sDirFile) = True And String.InStr(sLine, gb.Cr) > 0 Then 
    sText = File.Load(sDirFile)
    If sText Then 
      ssExist = New String[]
      sText = Replace(sText, gb.Cr, gb.NewLine)
      ssExist = Split(sText & gb.NewLine, gb.NewLine) 
    Endif 
  Endif 
  
  If Not Error Then 
    For iLine = 0 To ssExist.Max '.........................................
      ''[ESC]?
      If F_bESCpressedON = True Then 
        Select Case Message.Question(sDirFile & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
          Case 1
            F_bESCpressedON = False
          Case 2
            Break
        End Select
      Endif 
      
      sLine = ssExist[iLine] 'one line
      
      If String.Len(sLine) > 10 Then 'min.
        ' sLine = Replace(sLine, gb.Cr, String.Chr(182)) ' Replace Return "¶" (ersetzen)
        sKey = Str(ColumnView1.Count + 1)
        
        ColumnView1.Add(sKey, "")
        
        it = 0
        For Each sLinePart In Split(sLine & String(F_iColumnsCount, hTab), hTab) ' Stringarray
          If it = 0 Then 
            ColumnView1[sKey][it] = Trim(sLinePart) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          Else If it < F_iColumnsReadMax + 1 Then 
            ColumnView1[sKey][it] = sLinePart
          Endif 
          If it = F_iColumnsReadMax Then Break
          it = it + 1
        Next
        
        If it = F_iColumnsReadMax Then
          ColumnView1[sKey][F_iColumnUndo] = sLine 'Original Line (Originalzeile)
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = sKey
          ssKeysAdd.Add(sKey) 'only Key
        Else  'too many or not enough Separators '(zu viele oder zu wenige sSeparator) '|0|1|2|3|4|5|> |
          ColumnView1[sKey][F_iColumnUndo] = sLine 
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = 0
          iUnknownCounter = iUnknownCounter + 1
          If iUnknownCounter < 5 Then F_sUnknownLinesText &= sLine & gb.NewLine 'ssUnknown.Add(sLine)
          ssKeysWarning.Add(sKey) 'only Key
        Endif 'F_iColumnsReadMax
      Endif 
      
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    Next '.................................................
    
    If F_bESCpressedON = False Then 
      For Each sKey In ssKeysAdd
        If F_bESCpressedON = True Then Break 
        ColumnView1[sKey].Picture = PicNew 'Empty or Add +
      Next 
      For Each sKey In ssKeysWarning
        If F_bESCpressedON = True Then Break 
        ColumnView1[sKey].Picture = PicWarning '!
      Next
    Endif  
  Endif 
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  
  F_iUnknownCounter = iUnknownCounter
  mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
  If iUnknownCounter > 0 Then 
    F_sUnknownLinesText = Str(iEmptyOrDouble) & Space(1) & ("von") & Space(1) & Str(ssExist.Count) & Space(1) & ("Zeilen leer oder doppelt") & gb.NewLine 
    F_sUnknownLinesText &= Str(iUnknownCounter) & Space(1) & ("?-Zeilen") & ". " & ("Beispiel") & ": " & gb.NewLine 
    sUnknown = M01Functions.CheckTextTerminwecker(F_sUnknownLinesText)
    F_sUnknownLinesText &= sUnknown
  Endif 
  F_iUnknownCounter = iUnknownCounter
  ButtonSave.Background = Color.Default
  ColumnView1.UnselectAll() '>AddAppend
  ''Activate or Deactivate:
  ' ColumnViewAddAppend() ''with ColumnViewSort() 'with .EnsureVisible()
  ' ColumnViewBackup()
  ' ProjectLineSelection() '>Form5Projekte
  TextBoxPath.SelectAll()
  TextBoxPath.Insert(sDirFile) '>Form18Diagramm
  ' ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  ' F_bListChanged = False
  If bDialog = False Then ButtonAddLineActualG()
  
JumpEnd:
  ColumnView1Resize() 'with Title-Info
  ColumnView1.Visible = True
  ProgressBarONoff(False)
  WindowTitle()
  
Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
  IconError.Raise '▲top level▲  (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
  IconError.Visible = True
  TextBoxPath.Foreground = F_iColorRed
  If Exist(sDirFile) = True Then Close #hFile
  ColumnView1.Visible = True
  
End ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Public Sub SaveG() 'unused
  
End

Public Sub ColumnViewMarkGreen()
  
  Dim sK1 As String
  Dim PicEmpty As Picture
  Dim PicMarkGreen As Picture
  
  ''ColumnView1:
  If ColumnView1.Visible = True Then 
    PicMarkGreen = PicTemplateListMark.Picture.Image.Stretch(22, 22).Picture 
    PicEmpty = New Picture(22, 22, True)
    
    If ColumnView1.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnView1.Selection.Last           'ColumnViewCurrentKey() 'as String
      If ColumnView1[sK1].Background <> Color.Default Then 
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView1[sK1].Background = F_iSelectGreenAlpha150
        ColumnView1[sK1].Foreground = F_iColorForegroundBlue
        ColumnView1[sK1].Picture = PicMarkGreen
        ColumnView1[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonAddLineActualG() 'Akutelle Projektzeile
  
  Dim sLine, sKey, sFoundKey As String
  Dim ssLineParts As New String[]
  Dim it As Integer 
  Dim PicLineActual As Picture
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicLineActual = PicTemplateAddLineActual.Picture.Image.Stretch(22, 22).Picture 
  
  If ColumnView1.Count > 0 Then 
    ''Last line?
    If ColumnView1[ColumnView1.Keys.Last][F_iColumnSelect] = "PicLineActual" Then 
      sFoundKey = ColumnView1.Keys.Last
    Else  'search in all
      For Each sKey In ColumnView1.Keys
        ' For it = ColumnView1.Keys.Max To 0 Step -1
        If ColumnView1[sKey][F_iColumnSelect] = "PicLineActual" Then 
          sFoundKey = sKey
          ColumnView1[sKey][F_iColumnSort] = Format(Now, "yyyy-mm-ddhh:nn")
          Break 
        Endif 
      Next 
    Endif 
  Endif 
  
  ''Refresh:
  If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
  FMain.F_dateProjectStart = Settings[FMain.Name &/ "F_dateProjectStart", FMain.F_dateProjectStart]
  
  If FMain.F_dateProjectStart Then 
    FMain.F_sProjectLineActual = M01Functions.ProjectLineRefresh(FMain.F_dateProjectStart, Now, FMain.F_sProjectOnlyName) 'as String
  Else If sFoundKey Then 
    hDate = M01Functions.DateCheckyyyymmddhhnn(ColumnView1[sFoundKey][0], ColumnView1[sFoundKey][1]) 'as Date
    FMain.F_sProjectLineActual = M01Functions.ProjectLineRefresh(hDate, Now, FMain.F_sProjectOnlyName) 'as String
  Else 
    FMain.F_sProjectLineActual = M01Functions.ProjectLineRefresh(Now, Now, FMain.F_sProjectOnlyName) 'as String
  Endif 
  
  sLine = FMain.F_sProjectLineActual 
  sLine = Replace(sLine, gb.Cr, "") 'no Carrige Return = Chr(13)   'Windows-Dateienden gb.CrLf
  
  ' If Not sFoundKey Then 'not found, add new
  If ColumnView1.Exist(sFoundKey) = False Then 
    sKey = ColumnView1.Count + 1
    ColumnView1.Add(sKey, "") 
  Else 
    sKey = sFoundKey
  Endif 
  
  ''Only 1x, one Line
  ssLineParts = Split(sLine & String(F_iColumnsCount, hTab), hTab) ' Stringarray
  
  ''Columns
  For it = 0 To ColumnView1.Columns.Max
    If String.InStr(ssLineParts[it], ":") > 0 Then 
      ssLineParts[it] = Trim(Replace(ssLineParts[it], gb.NewLine, ""))
    Endif
    ColumnView1[sKey][it] = ssLineParts[it]
  Next
  If ColumnView1.Columns.Max < F_iColumnsCount Then
    ColumnView1[sKey][F_iColumnUndo] = sLine 'Original Line (Originalzeile)
    ColumnView1[sKey][F_iColumnNr] = sKey
    ColumnView1[sKey][F_iColumnSort] = sKey
    ColumnView1[sKey][F_iColumnSelect] = "PicLineActual"
    ColumnView1[sKey].Background = F_iSelectGreenAlpha150
    ColumnView1[sKey].Foreground = F_iColorForegroundBlue
    ColumnView1[sKey].Picture = PicLineActual 
    ColumnView1[sKey].EnsureVisible
  Endif 'Columns
  ColumnView1.Columns.Sort = 0
  If ColumnView1.Exist(sFoundKey) = True Then ColumnView1[sFoundKey].EnsureVisible
  ColumnViewInfo("▶··· " & "Offene Projekt-Zeile aktualisiert" & ": " & Format(Now, "hh:nn:ss"))
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilenG()
  
  Form3Text.Tag = F_sUnknownLinesText
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  ColumnViewInfo(("Fehl-Zeilen im Lesefenster"))
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnSortSettingCentral()
  
  ColumnView1.Mode = Select.Multiple
  ColumnView1.Sorted = True 
  ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ColumnView1.Columns.Sort = F_iColumnSort 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewRefresh() 
  
  Dim sK1 As String 
  Dim M As Integer
  Dim PicAdd, PicEmpty As Picture
  
  PicEmpty = New Picture(22, 22, True) 'True=Transparent 
  PicAdd = ListAdd.Picture.Image.Stretch(22, 22).Picture
  
  ColumnSortSettingCentral()
  ColumnView1.Sorted = False
  
  For Each sK1 In ColumnView1.Keys 
    If ColumnView1[sK1][5] <> ""    
      ColumnView1[sK1].Picture = PicEmpty
      ColumnView1[sK1].Background = Color.Default
      ColumnView1[sK1].Foreground = Color.Default
    Else 
      ColumnView1.Remove(sK1) 'cut, delete, empty
    Endif 
  Next 
  sK1 = ColumnView1.Count + 1
  
  ''Plus+
  ColumnView1.Add(sK1, "", PicAdd)
  ColumnView1[sK1][1] = ""
  ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
  ColumnView1[sK1][F_iColumnNr] = sK1 
  
  For Each sK1 In ColumnView1.Keys 
    ColumnView1[sK1].Selected = False
    ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
  Next 
  ColumnViewSort(F_iColumnSort)
  M = ColumnView1.MoveLast()
  If M = -1 Then sK1 = ColumnView1.Item.Key
  If ColumnView1.Exist(sK1) = True Then 
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  ColumnViewInfo("Aufgeräumt")
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  Dim sInfo As String
  Dim sSizeAll As String 
  
  sSizeAll = Space(1) & "=" & Space(1) & File.FormatSize(F_longFilesRead, False) 'as String  
  
  If ColumnView1.Count = 0 Then sInfo = Space(2) & ("Leer. Datei öffnen oder +Einfügen") Else sInfo = ("Projekt-Name") & Space(2) & ("Zeilen") & ": " & ColumnView1.Count & sSizeAll
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False 'F_bColumnsMore                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  ColumnView1.Columns[9].Alignment = Align.Left
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ColumnView1.Columns[1].Title = ("Uhr")     '00:00 Begin
  ColumnView1.Columns[2].Title = Space(1)    'Su Weekday (Wochentag) 
  ColumnView1.Columns[3].Title = Space(1)    '0Q Quater (Quartal)
  ColumnView1.Columns[4].Title = Space(1)    '0CW CalenderWeek (KalenderWoche)
  ColumnView1.Columns[5].Title = sInfo       'Notice (Notiz)
  
  ColumnView1.Columns[6].Title = ("Uhr")     '00:00 End
  ColumnView1.Columns[7].Title = ""          'Su Weekday (Wochentag)
  ColumnView1.Columns[8].Title = ("Sek.")    'Seconds 123 (Sekunden)
  ColumnView1.Columns[9].Title = ("Dauer")   '00:00:00 Duration
  ColumnView1.Columns[10].Title = ""         'ColumnsUndo
  ColumnView1.Columns[11].Title = ""         'Select01
  ColumnView1.Columns[12].Title = ""         'Sort (Sortieren)
  ColumnView1.Columns[13].Title = ""         'Nr. Enter Number (Eingangs-Nummer)
  
  ColumnView1.Columns[0].Width = 200
  ColumnView1.Columns[1].Width = 80
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 80
  ColumnView1.Columns[5].Width = 0           'Notice
  
  ColumnView1.Columns[6].Width = 70
  ColumnView1.Columns[7].Width = 0 
  ColumnView1.Columns[8].Width = 0
  ColumnView1.Columns[9].Width = 100         '00:00:00 Duration
  ColumnView1.Columns[10].Width = 0          'ColumnsUndo
  ColumnView1.Columns[11].Width = 0          'Select01 "0" or "-1"
  ColumnView1.Columns[12].Width = 0          'Sort
  ColumnView1.Columns[13].Width = 0          'Nr.
  '.AutoResize width = longest filename
  
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[13].Left 
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  ' If ColumnView2.Visible = True Then ColumnView2Resize() 
  
  If F_bColumnsMore = True Then 
    ArrowR2.Picture = PicTemplateArrowL.Picture
  Else 
    ArrowR2.Picture = PicTemplateArrowR.Picture  
  Endif
  ColumnViewAscending()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnsMore(Optional bONoff As Boolean = False)
  
  Dim it As Integer
  
  If ColumnView1.Visible = False Then Side(2)
  F_bColumnsMore = bONoff
  
  If bONoff = False Then
    ColumnView1Resize()
  Else 'mehr
    ColumnView1Resize()
    ColumnView1.Columns[0].Width = 200 'Datum
    ColumnView1.Columns[1].Width = 100 'Uhr
    ColumnView1.Columns[2].Width = 50 'Wochentag
    ColumnView1.Columns[3].Width = 50 'Q
    ColumnView1.Columns[4].Width = 70   'KW
    ColumnView1.Columns[5].Width = 300 'Notiz
    ColumnView1.Columns[6].Width = 100 'Uhr
    ColumnView1.Columns[7].Width = 50 'Wochentag
    ColumnView1.Columns[8].Width = 100 'Sekunden
    ColumnView1.Columns[9].Width = 100 'Dauer
    For it = 10 To ColumnView1.Columns.Max
      ColumnView1.Columns[it].Width = 0  '10 Zeile tag
    Next 
    ColumnView1.Columns[8].Alignment = Align.Right
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewSort(Optional Csort As Integer = 0)
  
  Dim sKey As String 
  Dim M As Integer
  
  If Csort < ColumnView1.Columns.Count Then 
    If ColumnView1.Sorted = False Then ColumnView1.Sorted = True
    ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
    ColumnView1.Columns.Sort = Csort
    If ColumnView1.Selection.Max > -1 Then
      sKey = ColumnView1.Selection[ColumnView1.Selection.Max]  'only Key, Example: sKey = "9"
    Else 
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False, Missing
    Endif
    If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewSortPics()
  
  Dim sKey As String 
  Dim M As Integer
  
  If ColumnView1.Visible = False Then Side(2)
  If F_iColumnSelect < ColumnView1.Columns.Count Then 
    ColumnView1.Sorted = True
    ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
    ColumnView1.Columns.Sort = F_iColumnSelect
    If ColumnView1.Selection.Max > -1 Then
      ' sKey = ColumnView1.Selection[ColumnView1.Selection.Max]  'only Key, Example: Last sKey = "9"
      sKey = ColumnView1.Selection.Last
    Else 
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
    Endif
    If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewDouble() '= ● ●
  
  Dim sKey, sLine As String
  Dim it, iLine, iFound, iFoundLines As Integer
  Dim PicDouble, PicHome As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView1.Visible = False Then Side(2)
  If ColumnView1.Visible = True Then
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView1.Columns.Count > F_iColumnSort Then
      PicDouble = PicTemplateDouble.Picture.Image.Stretch(22, 22).Picture
      PicHome = PicTemplateLEDgreen.Picture.Image.Stretch(22, 22).Picture
      ColumnView1.Mode = Select.Multiple 
      ColumnView1.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView1[sKey].Picture = PicDouble
          ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView1[sKey][F_iColumnSort] = ColumnView1.Count + iLine
          ColumnView1[sKey].Selected = True
          ColumnView1[sKey].EnsureVisible
        Else
          ColumnView1[sKey].Picture = PicHome
          ColumnView1[sKey][F_iColumnSelect] = "PicHome"
          ColumnView1[sKey][F_iColumnSort] = iLine
          ColumnView1[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewGotoErrorLines(Optional sUpDown As String = "down") '▼
  
  Dim sK1, sK2, sInfo, sMessage As String 
  Dim PicQuestion As Picture
  
  If ColumnView1.Visible = False Then Side(2)
  
  If ColumnView1.Count > 0 Then 
    For Each sK1 In ColumnView1.Keys
      If ColumnView1[sK1].Background = F_iSelectRedAlpha220 Then  
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
      Else 
        ColumnView1[sK1].Selected = False 
      Endif
    Next
  Endif
  
  Select Case sUpDown
    Case "up"
      F_iCurrentErrorLine = F_iCurrentErrorLine - 1
    Case "down"
      F_iCurrentErrorLine = F_iCurrentErrorLine + 1
  End Select
  
  If ColumnView1.Count > 0 Then 
    If F_bColumnsMore = False Then 
      F_bColumnsMore = True 
      ColumnsMore(F_bColumnsMore)
    Endif 
    PicQuestion = ColumnViewImages("PicQuestion").Picture 
    ' PicQuestion = ToggleColumnCorrecting.Picture.Image.Stretch(22, 22).Picture
    ' ColumnSortSettingCentral()
    ColumnView1.Columns.Sort = 0
    ColumnView1.Sorted = True 
    For Each sK1 In ColumnView1.Keys
      If ColumnView1[sK1].Background = F_iSelectRedAlpha220 Then  
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
      Else 
        ColumnView1[sK1].Selected = False 
      Endif
    Next
    If ColumnView1.Selection.Max = -1 Then 
      For Each sK1 In ColumnView1.Keys
        If ColumnView1[sK1].Background <> Color.Default Then  
          ColumnView1[sK1].Selected = True 
          ' ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
        Else 
          ColumnView1[sK1].Selected = False 
        Endif
      Next
    Endif 
    
    F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
    ' F_ssKeysCopy = ColumnView1.Keys.Copy()
    If Not F_ssKeysCopy Then F_ssKeysCopy = New String[]
    If F_iCurrentErrorLine < 0 Then F_iCurrentErrorLine = F_ssKeysCopy.Max
    If F_iCurrentErrorLine > F_ssKeysCopy.Max Then F_iCurrentErrorLine = 0
    If F_ssKeysCopy.Max = -1 Then 
      sInfo = ("Fehler-Zeilen") & ": " & ("Keine")
      ColumnViewInfo(sInfo)
      sMessage = "<h3><font color=gray>" & ("Fehler-Zeilen") & ": " & "</font></h3>" 
      sMessage &= "<h3><font color=darkgreen>" & ("Keine") & "</font></h3>" 
      sMessage &= ("In der Liste wurden keine Fehler-Zeilen erkannt oder sie wurden schon korrigiert.")
      Message.Info(sMessage, ("Abbrechen"))
    Else
      sK2 = F_ssKeysCopy[F_iCurrentErrorLine]
      If ColumnView1.Exist(sK2) = True Then 
        For Each sK1 In ColumnView1.Keys
          ColumnView1[sK1].Picture = ColumnViewImages(ColumnView1[sK1][F_iColumnSelect]).Picture 'Reset
        Next 
        ColumnView1[sK2].EnsureVisible
        ColumnView1[sK2].Picture = PicQuestion
      Endif  
      ColumnViewInfo(("?-Zeilen") & ": " & ColumnView1[sK2][1] & ">" & ColumnView1[sK2][6] & Space(1) & ColumnView1[sK2][2] & ">" & ColumnView1[sK2][7])
    Endif
  Else 
    ListGotoErrorLineDown.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub ToggleFrameG()
  
  Dim bbTimeWindows As Boolean[]
  Dim bON As Boolean
  Dim iFound As Integer
  
  ' Settings[F_sForm &/ "ToggleFrame", False] = Not ToggleFrame.Value
  If Not F_bbTimeWindows Then F_bbTimeWindows = New Boolean[3]
  
  ''min. 1x:
  If ToggleFrame.Value = True Then 
    bbTimeWindows = F_bbTimeWindows
    bbTimeWindows = Settings[F_sForm &/ "F_bbTimeWindows", bbTimeWindows]
    For Each bON In bbTimeWindows
      If bON = True Then iFound = iFound + 1
    Next
    If iFound = 0 Then 
      bbTimeWindows[0] = True
      Settings[F_sForm &/ "F_bbTimeWindows"] = bbTimeWindows
    Endif 
  Endif 
  PicDiagramDrawG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCopyDiagramPicture() 'Kopie
  
  Dim Img As Image
  Dim ssSpli As String[]
  
  ''Side Diagram:
  If ScrollViewDiagram.Visible = False Then 
    Side(1) 'Diagram
    Wait 0.5
  Endif 
  
  ''Empty?
  If PicBoxDiagram.Picture = Null Then 
    'Message.Info(("Ein Diagramm-Bild fehlt (noch)"))
    PicBoxDiagram.Picture = DiagramPhoto() 'as Picture
  Endif  
  
  ''Copy —▶ Clipboard:
  If PicBoxDiagram.Picture Then   
    ButtonCopyImage.Background = Color.Green
    ' Clipboard.Clear() 'no longer?
    Clipboard.Copy(PicBoxDiagram.Picture.Image) 'Copy in Clipboard (Zwischenablage)
    Wait 0.1
    If Clipboard.Type = Clipboard.Image Then Img = Clipboard.Paste()
  Endif  
  
  ''Check:
  If Not Img Then Img = M01Functions.ClipboardImage() 'as Image
  If Img Then 
    PicBoxDiagramCopy.Picture = Img.Picture
    LabelInfoMenu.Text = ("Diagramm-Bild in > [Zwischenablage]")
    ButtonCopyImage.Background = Color.Default
    PicBoxDiagramCopy.Tooltip = ("Kontroll-Bild Kopie in > [Zwischenablage]") & gb.NewLine
  Else
    PicBoxDiagramCopy.Picture = PicTemplateQuestionRound.Picture 'Picture[""] 'sichtbar leeren
    LabelInfoMenu.Text = ("Diagramm-Bild (noch) nicht in der [Zwischenablage]")
    ButtonCopyImage.Background = Color.Red
    PicBoxDiagramCopy.Tooltip = ""
  Endif
  ssSpli = Clipboard.Formats ' as String[] '.Join (verbindet einzelne [Arrays])
  If ssSpli Then PicBoxDiagramCopy.Tooltip = PicBoxDiagramCopy.Tooltip & ("[Zwischenablage]") & ": " & gb.NewLine & ssSpli.Join(gb.NewLine)
  
Catch 
  FMain.ErrorText
  
End

Public Function DiagramPhoto() As Picture
  
  Dim imgScreen As Image
  Dim picScreen As Picture
  
  ' Try imgScreen = Desktop.Screenshot(ScrollViewDiagram.ScreenX, ScrollViewDiagram.ScreenY, ScrollViewDiagram.W, ScrollViewDiagram.H).Image 'as Picture
  picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
  If picScreen Then imgScreen = picScreen.Image.Copy(ScrollViewDiagram.ScreenX, ScrollViewDiagram.ScreenY, ScrollViewDiagram.W, ScrollViewDiagram.H)
  
  If M01Functions.ScreenshotImageExist(imgScreen) = False Then 
    imgScreen = M01Functions.ScreenshotImageAlternative()
    If imgScreen Then imgScreen = imgScreen.Copy(PicBoxDiagram.ScreenX, PicBoxDiagram.ScreenY, PicBoxDiagram.W, PicBoxDiagram.H)
  Else 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Endif 
  
  Return imgScreen.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveDiagramPicture()
  
  Dim sPath, sDir, sFile, sInfo As String
  ' Dim bMini As Boolean
  Dim ssFilter As New String[]
  
  ' bMini = Form0NurUhr.Minimized
  ' Form16Diagramm.SetFocus
  Wait 0.3
  If Not PicBoxDiagram.Picture Then 
    'Message.Info(("Ein Diagramm-Bild fehlt (noch)"))
    PicBoxDiagram.Picture = DiagramPhoto()
  Endif 
  sPath = Settings[FMain.Name &/ "sPathFoto", sPath]
  sDir = File.Dir(sPath)
  
  If Exist(sDir) = False Then sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  
  sFile = ("DiagrammFoto") & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & ".png" 
  sPath = sDir &/ sFile
  
  ssFilter.Add(File.BaseName(sPath)) 'Filter
  ssFilter.Add(("letzte Speicherung")) 'Filter-Text
  
  ssFilter.Add("*.png") 'Filter
  ssFilter.Add(("PNG-Bild") & Space(1) & "(Portable Network Graphics)" & Space(1) & ("verlustfreie Datenkompression")) 'Filter-Text
  
  ssFilter.Add(("DiagrammFoto") & "*.png") 'Filter
  ssFilter.Add(("PNG-Bild")) 'Filter-Text
  
  ssFilter.Add("*" & Format(Date, "yyyy-mm-dd") & "*.png") 'Filter
  ssFilter.Add(("PNG Heute") & Space(1) & Format(Date, "yyyy-mm-dd")) 'Filter-Text
  
  ssFilter.Add("*" & Format(Date, "yyyy-mm") & "*.png") 'Filter
  ssFilter.Add(("PNG Monat") & Space(1) & Format(Date, "yyyy-mm")) 'Filter-Text
  
  ssFilter.Add("*" & Format(DateAdd(Date, gb.Month, -1), "yyyy-mm") & "*.png") 'Filter
  ssFilter.Add(("PNG Monat") & Space(1) & Format(DateAdd(Date, gb.Month, -1), "yyyy-mm")) 'Filter-Text
  
  ssFilter.Add("*" & Format(Date, "yyyy") & "*.png") 'Filter
  ssFilter.Add(("PNG Jahr") & Space(1) & Format(Date, "yyyy")) 'Filter-Text
  
  ssFilter.Add("*" & Format(DateAdd(Date, gb.Year, -1), "yyyy") & "*.png") 'Filter
  ssFilter.Add(("PNG Jahr") & Space(1) & Format(DateAdd(Date, gb.Year, -1), "yyyy")) 'Filter-Text
  
  ssFilter.Add("*.png;*.jpg;*jpeg;*.bmp;*.xpm") 'Filter
  ssFilter.Add(("Bild-Formate")) 'Filter-Text
  '(*), All files (Alle Dateien, wird autom. angehängt)
  
  'Dialog.Filter = ["*.png", ("Format PNG"), "*.jpeg", "Format JPG", "*.bmp", "Bitmap BMP", "*.gif", "Format GIF", "*.xpm", "Format XPM", "All files(*.*)"]
  Dialog.Filter = ssFilter
  Dialog.AutoExt = True 'braucht Komponente: gb.form.dialog
  Dialog.Path = sPath
  Dialog.Title = (("Bild speichern..."))
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Datei-Name zurück
    '= False, nicht abgebrochen
    sPath = Dialog.Path '/sDir/File.png
    Try PicBoxDiagram.Picture.Save(sPath) 'Supported formats are JPEG, PNG, BMP, GIF and XPM. 
    If Exist(sPath) = False Then
      sInfo = ("Fehler. Datei nicht gespeichert")
      LabelInfoMenu.Text = sInfo
      Message.Info(sInfo)
      ButtonSave.Background = Color.Red
    Else
      Settings[FMain.Name &/ "sPathFoto"] = sPath
      ButtonSave.Background = Color.Green
      LabelInfoMenu.Text = File.Name(sPath)
    Endif
  Endif
  ' Form0NurUhr.Minimized = bMini
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSavePicture()
  
  Side(1)
  SaveDiagramPicture()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuBildordneroeffnen_Click()
  
  Dim sDir As String
  
  sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  sDir = Settings[FMain.Name &/ "sPathFoto", sDir]
  If Exist(sDir) = False Then sDir = FMain.F_sDirAppName '&/ sFile
  If System.Exist("nautilus") = True Then 
    M01Functions.FileManagerOpen(sDir)
  Else 
    Desktop.Open(sDir)
  Endif 
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form16Diagramm.Window.Maximized = Not Form16Diagramm.Window.Maximized 
  If Form16Diagramm.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form16Diagramm.Window.FullScreen = True Or Form16Diagramm.Window.Maximized = True Then 
      F_bMovingON = False
      Form16Diagramm.Window.FullScreen = False
      Form16Diagramm.Window.Maximized = False
      If Form16Diagramm.Left + Form16Diagramm.W > Screen.AvailableWidth Then Form16Diagramm.Move(Form16Diagramm.Left, Form16Diagramm.Top, Screen.AvailableWidth - Form16Diagramm.Left, Screen.AvailableHeight - Form16Diagramm.Top)
    Else
      F_bMovingON = True
      Form16Diagramm.Window.FullScreen = False
      Form16Diagramm.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form16Diagramm.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form16Diagramm.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form16Diagramm.ClientW - WindowStretch.W, Form16Diagramm.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form16Diagramm.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form16Diagramm.W = Mouse.ScreenX - F_iX1
    Form16Diagramm.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form16Diagramm.ClientW - WindowStretch.W, Form16Diagramm.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form16Diagramm.ClientW - WindowStretch.W, Form16Diagramm.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form16Diagramm.Window.Maximized = Not Form16Diagramm.Window.Maximized 
    If Form16Diagramm.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form16Diagramm.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeKRZeit_KeyPress()
  
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then    
    'erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeKRZeit_MouseUp()
  
  If PanelCV3.Visible = False Then
    ClockTimeList0to24h(Last.Text)
    ColumnView3.tag = Last.Tag
    PanelCV3.Visible = True
    PanelCV3.Raise
    ButtonCancelcv3.Visible = True
    ButtonCancelcv3.Raise
  Else
    PanelCV3.Visible = False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeKRZeit_Change()
  
  If Last.Text Like "??:??" Then
    Last.Foreground = Color.Default
  Else
    Last.Foreground = Color.Red 'Fehler oder noch unvollständig
  Endif
  ButtonEspeichern.Background = Color.Red
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeNFarbe_Click()
  
  Select Case Last.tag
    Case 1 
      ColorButton1.Value = ButtonC1.Background
    Case 2 
      ColorButton2.Value = ButtonC2.Background
    Case 3 
      ColorButton3.Value = ButtonC3.Background
    Case 4 
      ColorButton4.Value = ButtonC4.Background
    Case 5 
      ColorButton5.Value = ButtonC5.Background
    Case 6 
      ColorButton6.Value = ButtonC6.Background
    Case 7 
      ColorButton7.Value = ButtonC7.Background
    Case 8
      ColorButton8.Value = ButtonC8.Background
  End Select
  ButtonEspeichern.Background = Color.Red
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeNFarbe_Enter()
  
  Last.Border = True 
  
End

Public Sub GruppeNFarbe_Leave()
  
  Last.Border = False 
  
End

Public Sub ButtonStandardG()
  
  Dim sMessage As String 
  
  sMessage = "<h3>" & ("Alle Diagramm-Einstellungen") & ":" & "</h3>"
  sMessage &= "<h3><font color=red>" & "○" & Space(1) & ("Löschen (Neu-Zustand)") & "</font></h3>"
  Select Case Message.Question(sMessage, "○" & Space(1) & ("Löschen"), ("Abbrechen"))
    Case 1 'Clear
      Settings.Clear(F_sForm) ' löscht die Settings unter dem Titel. Ohne Titel alles. 
      DiagramDefault()
      FormStart()
      ButtonEspeichern.Background = Color.Green
      ButtonSettingsSide.Background = Color.Green
      ButtonEspeichern.Border = True 
      ButtonSettingsSide.Border = True 
    Case 2 'Cancel
      '...
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DiagramDefault()
  
  TextK1.Text = "07:00"
  TextK2.Text = "16:00"
  TextK3.Text = "00:00"
  TextK4.Text = "00:00"
  TextK5.Text = "00:00"
  TextK6.Text = "00:00"
  ColorButton1.Value = Color.Yellow
  ColorButton2.Value = Color.Blue
  ColorButton3.Value = Color.Red
  ColorButton4.Value = Color.Green
  ColorButton5.Value = Color.Pink
  ColorButton6.Value = Color.DarkCyan
  ColorButton7.Value = Color.Cyan
  ColorButton8.Value = Color.White
  
  ButtonC1.Background = ColorButton1.Value 
  ButtonC2.Background = ColorButton2.Value
  ButtonC3.Background = ColorButton3.Value
  ButtonC4.Background = ColorButton4.Value
  ButtonC5.Background = ColorButton5.Value
  ButtonC6.Background = ColorButton6.Value
  ButtonC7.Background = ColorButton7.Value
  ButtonC8.Background = ColorButton8.Value
  
  F_bbTimeWindows = New Boolean[3]
  ToggleProWeekHours.Value = False
  ToggleWeekSumMiddle.Value = False
  ToggleColumnDiagram.Value = False
  ToggleDiagramLine.Value = False
  ToggleFrame.Value = False
  F_bLabelDiagramTitleON = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub PaintDiagramAll(Optional bAll As Boolean = True)
  
  Side(1) 
  F_bPaintDiagramAllON = bAll
  PicDiagramDrawG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonListG()
  
  Select Case ColumnView1.Visible
    Case False 
      Side(2) 'Diagram 1, List 2, Settings 3
      ColumnViewInfo(("Zeilen auswählen > Diagramm-Auswahl"))
    Case True 
      Side(1)
      If isListData() = False Then Try PicBoxDiagram.Picture = DiagramEmpty().Picture 'as Image
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function isListData() As Boolean
  
  Dim ssSpli As String[]
  
  If ColumnView1.Count = 0 Then 
    F_sDiagramTitle = ("Leer. Eine Datei öffnen.")
    LabelInfoMenu.Text = F_sDiagramTitle
    LabelDiagramTitle.Text = F_sDiagramTitle
    ' ColumnView1.Header = True
    ' ColumnView1.Columns[0].Title = "▲▽" & Space(2) & F_sDiagramTitle
    ColumnView1Resize()
    Return False 
  Else 
    ssSpli = Split(F_sDiagramTitle & gb.NewLine, gb.NewLine)
    LabelDiagramTitle.Text = ssSpli[0]
    Return True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonNewG()
  
  Dim sPath, sMessage As String
  
  sMessage = ("Ohne Datei") & "<br><br>"
  sMessage &= ("Liste leeren und neu anfangen") & "<br><br>"
  
  Select Case Message.Question(sMessage, ("Neu"), ("Ordner..."), ("Abbrechen"))
    Case 1 'Open
      ColumnView1.Clear()
      Side(2) 'Diagr1_Liste2_Einst3
      Try PicBoxDiagram.Picture = DiagramEmpty().Picture 'as Image
      ColumnView1Resize()
      MenuDiagramExtraWG()
      TextBoxPath.SelectAll()
      TextBoxPath.Insert("Ohne Datei")
      
    Case 2 'Directory
      sPath = FilePathForm()
      TextBoxPath.SelectAll()
      TextBoxPath.Insert(sPath)
      M01Functions.FileManagerOpen(sPath)
      
    Case 3 'Cancel 
      '...
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonPictureDirectory()
  
  mnuBildordneroeffnen_Click()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonPictureProgramExtern()
  
  Dim sPath, sDirTempFile, sFile, sMessage As String
  Dim hPic As Picture
  
  hPic = PicBoxDiagram.Picture
  
  If ScrollViewDiagram.Visible = False Then Side(1) 'Diagram
  If Not hPic Then
    Wait 0.5
    hPic = DiagramPhoto() 'as Picture
  Endif 
  
  If hPic Then 
    sFile = "temp_" & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss-uu") & "_" & ("BildschirmFoto") & "-" & Application.Name & "." & "png"
    sFile = ("temp_") & Replace(sFile, "temp_", "") 'not double
    sDirTempFile = M01Functions.ProgramDirCache(sFile)  '("temp_diagramfoto.png")
    If IsDir(File.Dir(sDirTempFile)) = True Then hPic.Save(sDirTempFile)
    sPath = sDirTempFile
  Endif 
  
  If Exist(sPath) = False Then LabelInfoMenu.Text = ("Datei nicht gefunden") & "."
  
  sMessage = "<h2><font color=darkgreen>" & ("Diagramm-Foto") & "</font></h2>" 
  sMessage &= sPath & "<br>" & "<br>"
  sMessage &= ("Hinweis: Datei-Namen und Ordner ändern") & "<br>"
  If Exist(sPath) = False Then sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
  sMessage &= "<h3>" & "● " & ("Bild-Datei mit einem Bild-Programm starten?") & "</h3>" 
  
  Select Case Message.Question(sMessage, "● " & ("Bild-Programm..."), ("Ordner..."), ("Abbrechen"))
    Case 1 'Open
      Desktop.Open(sPath)
    Case 2 'Directory
      ' sPath = Settings[FMain.Name &/ "sPathFoto", sPath]
      If Exist(sPath) = False Then sPath = Desktop.GetDirectory("PICTURES")
      M01Functions.FileManagerOpen(sPath)
    Case 3 'Cancel 
      '...
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSettingsCancel()
  
  If ScrollViewDiagram.Visible = False Then Side(1)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCancelcv3G()
  
  PanelCV3.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h(Optional Zeittext As String = "")
  
  Dim it, it2, Zaehler As Integer
  Dim sValue As String
  
  ColumnView3.Clear()
  ColumnView3.Sorted = False 'nicht sortieren!
  ColumnView3.Columns.Count = 1 'Spalten (Columns) erzeugen
  ColumnView3.Columns[0].Width = ColumnView3.ClientW 
  For it = 0 To 23 'Stunden SS:
    For it2 = 0 To 59 'Minuten :MM
      sValue = Format(it, "00") & ":" & Format(it2, "00")
      Zaehler = Zaehler + 1
      ColumnView3.Add(Zaehler, sValue)
      If it2 Mod 10 = 0 Then ''00:00, 00:15, 00:30, ...
        ColumnView3[Zaehler].Foreground = Color.Default 
      Else 
        ColumnView3[Zaehler].Foreground = Color.LightGray  
      Endif 
      If it2 Mod 30 = 0 Then ''00:00, 00:30, 01:00, ... 
        ColumnView3[Zaehler].Background = Color.LightGray 
      Endif 
      If Zeittext = ColumnView3[Zaehler].Text Then
        ColumnView3[Zaehler].Selected = True
        ColumnView3[Zaehler].EnsureVisible
      Endif
    Next
  Next
  sValue = "00:00"
  Zaehler = Zaehler + 1
  ColumnView3.Add(Zaehler, sValue)
  ColumnView3.SetFocus
  ColumnView3_GotFocus
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_GotFocus()
  
  If ColumnView3.Columns.Max > 0 Then ColumnView3.Columns[0].Width = ColumnView3.Width
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_Click()
  
  Dim Text As String
  
  Text = ColumnView3[ColumnView3.Current.key][0]
  
  Select Case ColumnView3.Tag
    Case 1 
      TextK1.Text = Text
    Case 2
      TextK2.Text = Text
    Case 3 
      TextK3.Text = Text
    Case 4 
      TextK4.Text = Text
    Case 5 
      TextK5.Text = Text
    Case 6
      TextK6.Text = Text
  End Select
  PanelCV3.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSettingsDiagram()
  
  SettingsDiagram(True) 'SpeichernTrue_LesenFalse
  FormStart()
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeFarbeWT_Change()
  
  ButtonEspeichern.Background = Color.Red
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSettingsG()
  
  If ScrollView1.Visible = False Then Side(3)
  ScrollView1.Raise
  PanelMenu.Visible = False 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Side(Optional Diagr1_Liste2_Einst3 As Integer = 1)
  
  ScrollViewDiagram.Visible = False
  PicBoxDiagram.Visible = True
  ColumnView1.Visible = False
  ScrollView1.Visible = False 
  ScrollViewDiagram.Background = F_iDiagrammHintergrundfarbe
  LabelDiagramTitle.Visible = False
  
  Select Case Diagr1_Liste2_Einst3
    Case 1 'Diagram:
      ScrollViewDiagram.Visible = True
      ScrollViewDiagram.Raise
      PanelMenu.Visible = True 
      ' LabelDiagramTitle.Text = F_sDiagramTitle
      LabelDiagramTitle.Visible = True 
      LabelDiagramTitle.Raise
    Case 2 'List:
      ColumnView1.Visible = True
      ColumnView1.Raise
      PanelMenu.Visible = True 
      If ColumnView1.Count = 0 Then ColumnView1Resize()
      LabelDiagramTitle.Visible = True 
    Case 3 'Settings:
      ScrollView1.Visible = True
      ScrollView1.Raise
      PanelMenu.Visible = False  
  End Select
  
  ArrowR.Visible = ScrollViewDiagram.Visible
  
  FilePathCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FilePathCheck()
  
  Dim sPath, sInfo As String 
  
  sPath = TextBoxPath.Text 'FilePathForm()
  If Exist(sPath) = False Then sInfo = ("Nicht gefunden") & ": "  
  TextBoxPath.ToolTip = sInfo & sPath 
  If Exist(sPath) = False Then
    TextBoxPath.Foreground = F_iColorRed
  Else
    TextBoxPath.Foreground = Color.Gray
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()

  LabelInfoMenu.Text = ("Heute") & Space(1) & Format(Now, "yyyy-mm-dd hh:nn:ss ddd")
  
Catch 
  FMain.ErrorText
End

Public Sub Timer2KeyPress_Timer()
  
  Dim sPath As String 
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in Sub
  sPath = TextBoxPath.Text 
  sPath = Replace(sPath, gb.NewLine, "")
  ReadG(sPath, False) 'not in _KeyPress > Error
  Side(2)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonFilePathG()
  
  Dim sPath As String
  
  sPath = TextBoxPath.Text
  If Exist(sPath) = False Then
    Message.Info(sPath & gb.NewLine & gb.NewLine & ("Datei nicht gefunden") & ".")
  Else
    M01Functions.FileManagerOpen(sPath)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonTableExternCSV()
  
  Dim sPath, sPathCSV, sMessage As String
  
  sPath = TextBoxPath.Text
  
  If Exist(sPath) = False Then
    ColumnViewInfo(("Datei nicht gefunden") & ".")
  Else 
    sPathCSV = File.SetExt(sPath, "csv")

    sMessage &= "<h2><font color=darkgreen>" & "○ " & ("Öffnen im externen Tabellen-Programm?") & "</font></h2>" 
    sMessage &= sPathCSV & "<br>"
    sMessage &= ("Trennzeichen") & ": " & "<font color=blue><b>" & ("TABulatoren") & "</b></font>"
    
    Select Case Message.Question(sMessage, "○ " & ("Öffnen..."), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open
        M01Functions.ProjectSumCSV(sPath)
      Case 2 'Directory
        If Exist(sPathCSV) = True Then 
          M01Functions.FileManagerOpen(sPathCSV)
        Else 
          M01Functions.FileManagerOpen(sPath)
        Endif 
      Case 3 'Cancel 
        '...
    End Select 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonPathAddG()
  
  Dim sPath As String 
  
  sPath = TextBoxPath.Text
  LabelDiagramTitle.Text = ("Titel")
  If Settings[FMain.Name &/ "ProjectTest"] = sPath Then 
    DiagramExampleDemo()
    ColumnViewInfo(mnuBeispieldatei.Text)
  Else
    'If Exist(sPath) = False Then sPath = User.Home &/ Application.Name &/ ("projects") &/ File.Name(sPath)
    If Exist(sPath) = False Then sPath = FilePathProjectActual()
    ReadG(sPath, False) 'True=Dialogfenster
    ' If ScrollViewDiagram.Visible = True Then 
    PaintDiagramAll()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_MouseUp()
  
  If Mouse.Left Then WindowTitle()
  If Mouse.Right Then Menu1.Popup 'or > Eigenschaften PopupMenu = mnMaus
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowTitle()
  
  Dim sSpace, sProjectName As String 
  ' 
  sSpace = Space(1)
  sProjectName = Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]
  Form16Diagramm.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView1.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & "), " & ("Aktiv") & ": " & ("Projekt") & Space(1) & String.Left(sProjectName, 30)
  
  If ColumnView1.Visible = True Then ColumnView1SelectionLinesTimeSum()
  ColumnViewAscending()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  ' If ColumnView2.Columns.Ascending = True Then  
  '   ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ' Else 
  '   ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  ' Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1SelectionLinesTimeSum()
  
  Dim sKey, sText As String 
  Dim iColumn, iSumSeconds, iDays As Integer
  Dim sTimeSum, sTimeMiddle, sDay As String 
  Dim hColumn As F_iColumnViewValues
  
  If ColumnView1.Selection.Max > -1 Then 
    If F_ooColumnViewValues Then 
      hColumn = F_ooColumnViewValues[0]
      iColumn = hColumn.i08Seconds
    Else 
      iColumn = 8'—▶Seconds 1234
    Endif 
    If ColumnView1.Columns.Count > iColumn Then 
      For Each sKey In ColumnView1.Selection
        If IsInteger(ColumnView1[sKey][iColumn]) = True Then iSumSeconds = iSumSeconds + CInteger(ColumnView1[sKey][iColumn])
        If sDay <> ColumnView1[sKey][0] Then 'Day changed
          iDays = iDays + 1
          sDay = ColumnView1[sKey][0]
        Endif 
      Next 
      sTimeSum = M01Functions.SecondsHHHNNSS(iSumSeconds) 'as String  Example: "123:59:59"
      If iDays < 1 Then iDays = 1 'Error if Division by zero
      sTimeMiddle = M01Functions.SecondsHHHNNSS(iSumSeconds / iDays)
      sText = ("Summe") & "=" & sTimeSum & ", "
      sText &= ToggleWeekSumMiddle.Text & "=" & sTimeMiddle & ", " 
      sText &= ("Tage") & "=" & iDays
      LabelInfoMenu.Text = sText 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileEditorG()
  
  Dim sPath, sMessage As String
  
  sPath = TextBoxPath.Text
  
  If Exist(sPath) = False Then
    LabelInfoMenu.Text = ("Datei nicht gefunden") & "."
  Else 
    sMessage = sPath & "<br>"
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Öffnen im externen Texteditor-Programm?") & "</font></h3>" 
    
    Select Case Message.Question(sMessage, "● " & ("Öffnen..."), ("Ordner..."), ("Abbrechen"))
      Case 1 'Open
        M01Functions.ExternStart("gedit", sPath)
      Case 2 'Directory
        M01Functions.FileManagerOpen(sPath)
      Case 3 'Cancel 
        '...
    End Select 
  Endif 
  ButtonListG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Menu1_Show()
  
  Dim sPath As String
  
  sPath = TextBoxPath.Text
  If Exist(sPath) = True Then
    mnuDateibearbeiten.Text = ("Öffnen extern...  Textprogramm") & Space(3) & File.Name(sPath)
  Else
    mnuDateibearbeiten.Text = ("Öffnen extern...  Textprogramm") & Space(3) & ("?")
  Endif
  mnuFehlzeilen.Text = "=" & F_iUnknownCounter & Space(1) & ("?-Zeilen sehen") 
  mnuZeilenkorrigieren.Checked = F_bCorrectListON
  MenuDiagramExtraW.Checked = F_bPicDiagramLongerON
  mnuSpaltenMehr.Checked = F_bColumnsMore
  mnuSpaltenWeniger.Checked = Not F_bColumnsMore
  
Catch 
  FMain.ErrorText
  
End

Public Sub GruppeFarbeWT_Enter()
  
  Last.Border = True 
  
End

Public Sub GruppeFarbeWT_Leave()
  
  Last.Border = False 
  
End

Public Sub ProgressBar1_MouseDown()
  
  ProgressBar1.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormReset()
  
  F_bESCpressedON = False
  IconError.Visible = False
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  TextBoxPath.Visible = True
  ProgressBar1.Visible = False
  LabelInfoMenu.Text = ""
  LabelInfo.Text = Form16Diagramm.Window.Title  'Active in ColumnViewInfo("...")
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG(Optional sPath As String = "")
  
  Form19FileInfo.Tag = sPath
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End 

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathProjectActual()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuDiagramExtraWG()
  
  MenuDiagramExtraW.Checked = F_bPicDiagramLongerON
  DiagramPaint() 
  If F_bPicDiagramLongerON = True Then 
    ArrowR.Picture = PicTemplateArrowL.Picture
    ScrollViewDiagram.ScrollX = ScrollViewDiagram.ScrollW '▶|
  Else 
    ArrowR.Picture = PicTemplateArrowR.Picture  
    ' ScrollViewDiagram.ScrollX = 0 '|◀
  Endif
  ' LabelDiagramTitle.Text = F_sDiagramTitle
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxDiagram_Enter()
  
  LabelInfoMenu.Text = PicBoxDiagram.ToolTip
  
End

Public Sub PicBoxDiagram_MouseDown()
  
  LabelDiagramTitle.Visible = True
  
End

Public Sub PicBoxDiagram_MouseWheel()
  
  If Mouse.Forward Then ScrollViewDiagram.ScrollX = ScrollViewDiagram.ScrollX + 100 Else ScrollViewDiagram.ScrollX = ScrollViewDiagram.ScrollX - 100
  
End

Public Sub PanelKRGroup_Enter()
  
  Last.Background = F_iSelectGreenAlpha150
  
End

Public Sub PanelKRGroup_Leave()
  
  Last.Background = Color.Default
  
End

Public Sub mnuPapierkorbG()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  ColumnViewInfo(mnuPapierkorb.Tex)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCopy()
  
  If ColumnView1.Selection.Max > -1 Then
    F_ssKeysCopy = ColumnView1.Selection    'only Keys, Example: "3", "1", "2",... without .Sort()
    ColumnViewInfo(("Einfügen der Kopie, nach markierter Zeile."))
    ColumnView1ClipboardCopy()
  Else 
    ' ListCopy.Background = Color.Red
    ColumnViewInfo(("ausgewählte Zeilen") & ": 0")  'No Selection
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1ClipboardCopy()
  
  Dim it, it2 As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  If F_ssKeysCopy Then 
    For it = 0 To F_ssKeysCopy.Max
      sKey = F_ssKeysCopy[it]
      For it2 = 0 To ColumnView1.Columns.Max
        sLine = ColumnView1[sKey][it2]
        If it2 < F_iColumnsReadMax + 1 Then 
          sText = sText & sLine & hTab
        Else 
          sText = sText & sLine & hReturn
          Break
        Endif 
      Next 
    Next
    If sText Then 
      Clipboard.Clear()
      Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
      'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
      F_sLinesCopy = sText 
    Endif 
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCut()
  
  Dim it2 As Integer
  Dim PicCut As Picture
  Dim sK1 As String 
  
  ''ColumnView1:
  If ColumnView1.Visible = True Then 
    If ColumnView1.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      ' PicCut = mnuZeileEntfernen1.Picture.Image.Stretch(22, 22).Picture
      PicCut = ColumnViewImages("PicCut").Picture
      For Each sK1 In ColumnView1.Selection
        ColumnView1[sK1].Picture = PicCut
        ColumnView1[sK1][F_iColumnSelect] = "PicCut"
        For it2 = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView1[sK1][it2] = Null 
        Next
      Next
    Else 
      ' ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Else ''ColumnView2:
    
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnviewCheckErrorDaySum()

  Dim sKey, sKeyLast, sErrorLines, sCorrectLines, sText, sMessage As String 
  Dim picQuestionRed, PicOK, PicCut As Picture
  Dim iLine, it, iErrorLines, iCorrectLines As Integer
  Dim bCutErrorLines, bCutCorrectLines As Boolean
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If ColumnView1.Current Then 
    picQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(22, 22).Picture
    PicOK = ColumnViewImages("PicOK").Picture
    PicCut = ColumnViewImages("PicCut").Picture
    
    For Each sKey In ColumnView1.Keys
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form16Diagramm.Window.Title) = True Then Break
      Endif 
      
      If ColumnView1[sKey].Background = F_iSelectRedAlpha220 Then 
        iErrorLines = iErrorLines + 1
      Endif 
      If ColumnView1[sKey].Background = F_iSelectGreenAlpha220 Then 
        iCorrectLines = iCorrectLines + 1
      Endif 
    Next
    ProgressBarONoff(False)
    
    sMessage &= "<h4><font color=gray>" & ("Beispiel Fehler in Dauer") & ": " & ("Weniger als 0 Sekunden oder mehr als 1 Tag") & Space(1) & "(60s×60s×24h=86400s)" & "</font></h4>"
    sMessage &= "<h3><font color=red>" & "○ " & ("Fehler-Zeilen") & ": " & iErrorLines & "</font></h3>"
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Korrigierte Zeilen") & ": " & iCorrectLines & "</font></h3>"
    
    Select Case Message.Question(sMessage, "○ " & ("Ausschneiden"), "● " & ("Ausschneiden"), ("Abbrechen"))
      Case 1 'Cut
        bCutErrorLines = True 
      Case 2 'Directory
        bCutCorrectLines = True 
      Case 3 'Cancel
        ''...
    End Select
    
    If bCutErrorLines = True Then 
      For Each sKey In ColumnView1.Keys
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
        Endif 
        If ColumnView1[sKey].Background = F_iSelectRedAlpha220 Then 
          sKeyLast = sKey
          For it = 0 To F_iColumnsReadMax
            If it < F_iColumnsReadMax Then 
              sErrorLines &= ColumnView1[sKey][it] & hTab
            Else 
              sErrorLines &= ColumnView1[sKey][it] & hReturn  
            Endif 
            ColumnView1[sKey][it] = Null
          Next
          ColumnView1[sKey].Picture = PicCut
        Endif 
      Next 
      If sErrorLines Then 
        Clipboard.Clear()
        Clipboard.Copy(sErrorLines)
        
        F_iUnknownCounter = iErrorLines
        F_sUnknownLinesText = sErrorLines 
        MenuErrorLinesCut.Text = ("?-Fehler-Zeilen") & ": " & iErrorLines
        ListColumnCorrect.Text = iErrorLines
        If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
        sText = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String 
        F_sLinesCopy = sErrorLines
        mnuFehlzeilenG()
        Message.Info(sText, ("Abbrechen"))
      Endif 
    Endif 
    
    If bCutCorrectLines = True Then 
      For Each sKey In ColumnView1.Keys
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
        Endif 
        If ColumnView1[sKey].Background = F_iSelectGreenAlpha220 Then 
          sKeyLast = sKey
          For it = 0 To F_iColumnsReadMax
            If it < F_iColumnsReadMax Then 
              sCorrectLines &= ColumnView1[sKey][it] & hTab
            Else 
              sCorrectLines &= ColumnView1[sKey][it] & hReturn  
            Endif 
            ColumnView1[sKey][it] = Null
          Next
          ColumnView1[sKey].Picture = PicCut
        Endif 
      Next 
      If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
      If sCorrectLines Then 
        Clipboard.Clear()
        Clipboard.Copy(sCorrectLines)
        If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
        sText = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String 
        F_sUnknownLinesText = sCorrectLines 
        F_sLinesCopy = sCorrectLines
        mnuFehlzeilenG()
        Message.Info(sText, ("Abbrechen"))
      Endif 
    Endif   
  Endif
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText

End

Public Sub ColumnViewClipboardCopy()
  
  Dim it, it2 As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''ColumnView1:
  If ColumnView1.Visible = True Then 
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        sKey = F_ssKeysCopy[it]
        For it2 = 0 To ColumnView1.Columns.Max
          sLine = ColumnView1[sKey][it2]
          If it2 < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Else ''ColumnView2:
    '...
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewPaste() 
  
  Dim it2 As Integer
  Dim sK0, sK1, sKeySort As String 
  Dim M As Integer = -1 'True -1, False 0 (meaning here True!)
  Dim PicAdd As Picture
  Dim ssKeys As New String[]
  Dim sLine, sPart As String 
  
  ''ColumnView1:
  If ColumnView1.Visible = True Then 
    If ColumnView1.Selection.Max > -1 Then 
      ' PicAdd = ListAdd.Picture.Image.Stretch(22, 22).Picture
      PicAdd = ColumnViewImages("PicAdd").Picture
      sK0 = ColumnView1.Selection[ColumnView1.Selection.Max] 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView1.Sorted = False
    Endif 
    
    ' If F_ssKeysCopy Then 
    If F_sLinesCopy Then 
      If ColumnView1.Exist(sK0) = False Then 
        M = ColumnView1.MoveLast()
        If M = 0 Then ColumnView1.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView1.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView1.UnselectAll()
      ColumnView1.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy, gb.NewLine) 
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView1.Count + 1 
          ColumnView1.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
          it2 = 0
          For Each sPart In Split(sLine & gb.Tab, gb.Tab)
            If it2 < ColumnView1.Columns.Max Then 
              ColumnView1[sK1][it2] = sPart
            Else 
              Break
            Endif 
            it2 = it2 + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView1[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView1[sK1].Selected = True
        Next
        If ColumnView1.Selection.Max > -1 Then sK1 = ColumnView1.Selection.Last
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ' ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    '...
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddMin1xCount()
  
  Dim sK1 As String 
  Dim PicAdd As Picture
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Count < 2 Then '1 > only Header (Title)
    sK1 = ColumnView1.Count + 1
    ' PicAdd = ListAdd.Picture.Image.Stretch(22, 22).Picture 
    PicAdd = ColumnViewImages("PicAdd").Picture
    ColumnView1.Add(sK1, "", PicAdd)
    ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
    ColumnView1[sK1][1] = ""
    ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
    ColumnView1[sK1][F_iColumnNr] = sK1 
    ColumnView1[sK1].Selected = True
    ' ColumnView1[sK1].Picture = PicAdd
    ColumnView1[sK1].EnsureVisible()  
    ColumnViewInfo(("Min. 1 Zeile"))
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ClipboardCheck()
  
  Dim Img As Image
  
  Img = M01Functions.ClipboardImage()
  If Img Then 
    If F_bPicDiagramLongerON = True Then Img = DiagramPhoto().Image
    PicBoxDiagramCopy.Picture = Img.Picture 
  Else 
    PicBoxDiagramCopy.Picture = PicTemplateQuestionRound.Picture   
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  ArrowR2.Visible = ColumnView1.Visible
  ArrowR.Visible = ScrollViewDiagram.Visible
  
  If Object.Type(Last) = "Button" Or Object.Type(Last) = "ToggleButton" Then 
    Last.Border = True 
    If Last.Background <> Color.Green Then Last.Background = F_iSelectGreenAlpha150
  Endif 
  If Object.Type(Last) = "PictureBox" Then 
    Last.Background = Color.Green 
  Endif 
  
  If Last.Tag = "add" Or Last.Tag = "open" Then TextBoxPath.Background = F_iSelectGreenAlpha150
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True
      LabelInfoPathG(TextBoxPath.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "add"
      ButtonPathAdd.Background = F_iSelectGreenAlpha150
    Case "diagramtitle"
      LabelDiagramTitle.Background = F_iSelectGreenAlpha150
    Case "lineactual"
      ListLineActual.Tooltip = ("Aktuelle Projekt-Zeile erneuern (Refresh)") & Space(1) & Format(Time, "hh:nn:ss")
  End Select
  
  Timer1.Stop
  LabelInfoMenu.Text = Last.Tooltip
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  ArrowR2.Visible = ColumnView1.Visible
  ArrowR.Visible = ScrollViewDiagram.Visible
  
  If Object.Type(Last) = "Button" Or Object.Type(Last) = "ToggleButton" Then  
    Last.Border = False 
    If Last.Background <> Color.Green Then Last.Background = Color.Default 
  Endif 
  If Object.Type(Last) = "PictureBox" Then 
    Last.Background = Color.Default 
  Endif 
  ListColumnCorrect.Border = F_bCorrectListON
  If F_bCorrectListON = True Then ListColumnCorrect.Background = Color.Green Else ListColumnCorrect.Background = Color.Default
  
  If Last.Tag = "add" Or Last.Tag = "open" Then TextBoxPath.Background = Color.Transparent
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "add"
      ButtonPathAdd.Background = Color.Default
    Case "diagramtitle"
      LabelDiagramTitle.Background = Color.Default
  End Select
  
  Timer1.Start
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp() 'PictureBox
  
  ' If Object.Type(Last) = "PictureBox" Then ButtonGroupSelect(Last.Tag)
  ' If Last.Name = LabelDiagramTitle.Name Then ButtonGroupSelect(Last.Tag)
  ' ButtonGroupSelect(Last.Tag)
  Select Case Object.Type(Last) 
    Case "Menu"
      '...
    Case "ToggleButton"
      '...
    Case Else 
      ButtonGroupSelect(Last.Tag)
  End Select
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click() 'Click with Buttons or Menue
  
  Select Case Object.Type(Last) 
    Case "Menu"
      ButtonGroupSelect(Last.Tag)
    Case "ToggleButton"
      ButtonGroupSelect(Last.Tag)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "Left")
  
  Dim sPath As String 
  
  FormReset()
  
  ColumnViewAddMin1xCount()
  sMouseLMR = String.Lower(String.Left(sMouseLMR, 1)) 'Example: "L" '> Left, Middle, Right
  
  ''abc...z:
  Select Case String.LCase(sLastTag)
    Case "add", "reloadlist" '+++++++++++>
      ButtonPathAddG()
    Case "correctlines"
      F_bCorrectListON = Not F_bCorrectListON
      ButtonAddLineActualG() '▶•• 1x
      ' F_bCorrectListON = True
      ColumnViewCorrectLines(F_bCorrectListON)
      F_bColumnsMore = True
      If ScrollViewDiagram.Visible = True Then 
        ColumnsMore(F_bColumnsMore)
        PaintDiagramAll()
      Else 
        ColumnsMore(F_bColumnsMore)
      Endif 
    Case "correct"
      ButtonAddLineActualG() '▶•• 1x
      ' F_bCorrectListON = True
      ColumnViewCorrectLines(True)
      F_bColumnsMore = True
      If ScrollViewDiagram.Visible = True Then 
        ColumnsMore(F_bColumnsMore)
        PaintDiagramAll()
      Else 
        ColumnsMore(F_bColumnsMore)
      Endif 
    Case "errorlinescut"
      If ColumnView1.Visible = False Then Side(2) 'List
      ColumnviewCheckErrorDaySum()
    Case "correctlinescut"
      If ColumnView1.Visible = False Then Side(2) 'List
      ColumnviewCheckErrorDaySum()
    Case "cancelcv3" 
      ButtonCancelcv3G()
    Case "cancelsettings"
      ButtonSettingsCancel()
    Case "chartexample" 'Chart = Diagram
      DiagramExampleDemo()
    Case "chartextern"
      ButtonTableExternCSV()
    Case "chartline"
      PicDiagramDrawG()
    Case "chartmedium"
      PaintDiagramAll() 
    Case "close"
      Form16Diagramm.Window.Close
    Case "columnsminus"
      If ColumnView1.Visible = False Then Side(2) 'List
      F_bColumnsMore = False
      ColumnsMore(F_bColumnsMore)
    Case "columnsplus"
      If ColumnView1.Visible = False Then Side(2) 'List
      F_bColumnsMore = True
      ColumnsMore(F_bColumnsMore)
    Case "copy"
      If ColumnView1.Visible = False Then Side(2) 'List
      ColumnViewCopy()
    Case "cut"
      If ColumnView1.Visible = False Then Side(2) 'List
      ColumnViewCut()
    Case "diagram"
      PaintDiagramAll()
    Case "diagramrefresh"
      ' PaintDiagramAll()  
      If ScrollViewDiagram.Visible = False Then Side(1)
      ScrollViewDiagram.ScrollX = ScrollViewDiagram.ScrollW
      F_bPicDiagramLongerON = True 
      MenuDiagramExtraWG()
    Case "diagramcopy"
      ClipboardCheck()
    Case "diagramtitle"
      F_bLabelDiagramTitleON = Not F_bLabelDiagramTitleON
      Settings[FMain.Name &/ "F_bLabelDiagramTitleON"] = F_bLabelDiagramTitleON
      DiagramPaint()
      ScrollViewDiagram.ScrollX = 0
    Case "diagramw"
      F_bPicDiagramLongerON = Not F_bPicDiagramLongerON
      If ScrollViewDiagram.Visible = False Then Side(1) 
      MenuDiagramExtraWG()
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "editproject"
      Form18Projektbearbeiten.Window.Show
      Form18Projektbearbeiten.Visible = True
    Case "fileinfo"
      FileInfoG(TextBoxPath.Text)
    Case "filepath"
      ButtonFilePathG()
    Case "frame"
      ToggleFrameG()
    Case "lineactual"
      If ColumnView1.Visible = False Then Side(2)
      ButtonAddLineActualG()
    Case "list"
      ButtonListG()
    Case "markgreen"
      If ColumnView1.visible = False Then Side(2)
      ColumnViewMarkGreen()
    Case "menu"
      Menu1.Popup()
    Case "menucancel"
      'be sure that: 
      Try Menu1.Close() 'Gambas3: "Close an opened popup menu."
    Case "new"
      ButtonNewG()
    Case "projectall"
      sPath = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt]
      ReadG(sPath, False) 'True=Dialogfenster
      ButtonPathAddG()
    Case "projectcurrent"
      sPath = Settings[FMain.Name &/ "F_sPathProject_txt", FMain.F_sPathProject_txt]
      ReadG(sPath, False) 'True=Dialogfenster
      ButtonPathAddG()
    Case "open"
      sPath = FilePathForm()
      ReadG(sPath, True) 'True=Dialogfenster
      ButtonPathAddG()
      ' PaintDiagramAll()
    Case "openpic"
      ButtonPictureProgramExtern()
    Case "paste"
      ColumnViewPaste() 
    Case "photocopy"
      ButtonCopyDiagramPicture()
    Case "picpath" 
      ButtonPictureDirectory()
    Case "refresh", "clean" ', "reload"  'new Numbers 1,2,3...
      Side(2) 'Diagr1_Liste2_Einst3
      ColumnViewRefresh()
      ColumnView1Resize()
    Case "save"
      ' SaveG()
    Case "saveas"
      ButtonSavePicture()
    Case "savesettings"
      ButtonSettingsDiagram()
    Case "selectall"
      If ColumnView1.Selection.Max < 1 Then 
        ColumnView1.Mode = Select.Multiple
        ColumnView1.SelectAll()
      Else 
        ColumnView1.UnselectAll()  
      Endif  'SelectAll<>UnselectAll
    Case "selection"
      ' ButtonSelectionPaint()
      PaintDiagramAll(False)
    Case "settings"
      ButtonSettingsG()
    Case "standardsettings"
      ButtonStandardG()
    Case "texteditor"
      M01Functions.FileToForm3Text(TextBoxPath.Text)
    Case "textextern"
      FileEditorG()
    Case "trash"
      mnuPapierkorbG()
    Case "unknowlinestext"
      mnuFehlzeilenG()
    Case "unselectall"
      ColumnView1.UnselectAll()  
    Case "weekhours"
      PaintDiagramAll() 
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "sortpics"
      ColumnViewSortPics()
    Case "double"
      ColumnViewDouble()
    Case "gotoerrorlinedown"
      ColumnViewGotoErrorLines("down")
    Case "gotoerrorlineup"
      ColumnViewGotoErrorLines("up")
    Case "morecolumns"
      F_bColumnsMore = Not F_bColumnsMore
      ColumnsMore(F_bColumnsMore)
    Case "cancelform"
      Form16Diagramm.Window.Close
  End Select 
  WindowTitle()
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  
End '............................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form13Export.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form13Export.class
99,7 KB
' Gambas class file

Public F_bESCpressedON As Boolean
Public F_bMovingON As Boolean
Public F_iColorGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorGreen220 As Integer = Color.SetAlpha(Color.Green, 220)
Public F_iColorRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iOnly1x As Integer
Public F_iSpecialCharacters As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_ooASCIIKeybord As Object[]
Public F_sASCII As String
Public F_sForm As String = Me.Name 
Public F_sHasFocusName As String 
Public F_sLinesCopy As String 
Public F_sMyABC As String
Public F_sQuestionUnknown As String = "??" '"�"
Public F_ssKeysCopy As String[]                   'ColumnView1.Selection  'internally, instead of Clipboard.Copy()
Public F_ssMyABC As String[]
Public F_sTitleBasicText As String

Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iMusterTermine1Names2Projects3 As Integer = 1 '!!! ******************************************
Public F_longFilesRead As Long '>Files
Public F_sColumnLineLast As String  

Public Function FilePathForm() As String 
  
  Return Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt] 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_Change()
  
  If Exist(TextBoxPath.Text) = True Then TextBoxPath.Background = Color.Transparent Else TextBoxPath.Background = F_iColorRed150
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Form13Export.Window.Title = Application.Name & " - " & ("Zeichensatz umwandeln") 'Exportieren
  If Not Form13Export.Window.Icon Then Form13Export.Window.Icon = FMain.Window.Icon
  Menu1.Visible = False 'Web
  Menu2.Visible = False 'ColumnView2
  F_sTitleBasicText = Form13Export.Window.Title 
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  
  ' Catch 
  '   FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then Form13Export.Window.Title = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") Else Form13Export.Window.Title = F_sTitleBasicText
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form13Export.Window.Maximized = False Then
    Form13Export.Window.Maximized = True
  Else
    Form13Export.Window.Maximized = False
    Form13Export.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Activate() 
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    Formstart()
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckiMusterTermine1Names2Projects3()
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1, 2 'Termine, Project-Names
      F_iColumnNr = 6                                  'Termine 6, in Projects 13
      F_iColumnUndo = 7                                'Termine 7, in Projects 10
      F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 9                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
      
    Case 3 'Projects
      F_iColumnNr = 13                                  'Termine 6, in Projects 13
      F_iColumnUndo = 10                                'Termine 7, in Projects 10
      F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 12                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Formstart()
  
  Dim sText As String
  
  CheckiMusterTermine1Names2Projects3()
  
  FormBackgroundColor()
  WindowStretchCursor()
  ' ColumnView1Resize()
  
  If Not FMain.F_sTab Then FMain.F_sTab = gb.Tab
  If Not FMain.F_sReturnCrLF Then FMain.F_sReturnCrLF = gb.NewLine
  
  F_sMyABC = "ä=ae;ö=oe;ü=ue;¶=" & gb.NewLine & ";ß=ss;Ä=Ae;Ö=Oe;Ü=Ue;€=Euro;²=2;³=3;½=1/2;¼=1/4"
  sText = Settings[FMain.Name &/ "F_sMyABC", F_sMyABC]
  
  TextAreaReplace.SelectAll()
  TextAreaReplace.Insert(sText)
  TextAreaReplace.Pos = String.Len(TextAreaReplace.Text)
  TextAreaReplace.SetFocus
  TextBoxPath.Text = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Settings[FMain.Name &/ "F_sMyABC"] = TextAreaReplace.Text
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form13Export.Left]
      iY = Settings[F_sForm &/ "Top", Form13Export.Top]
      iW = Settings[F_sForm &/ "Width", Form13Export.W]
      iH = Settings[F_sForm &/ "Height", Form13Export.H]
      Form13Export.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form13Export.Left
      Settings[F_sForm &/ "Top"] = Form13Export.Top
      Settings[F_sForm &/ "Width"] = Form13Export.Width
      Settings[F_sForm &/ "Height"] = Form13Export.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPH, iPH2 As Integer
  Dim fPart As Float
  
  ''Min.:
  If Form13Export.Width < 200 Then Form13Export.Width = 200
  If Form13Export.Height < 200 Then Form13Export.Height = 200
  
  iW = (Form13Export.ClientWidth / 100) * 3
  iH = (Form13Export.ClientHeight / 100) * 3
  iPH = 40
  iPH2 = iPH / 2
  IconError.Move(Form13Export.ClientW - iPH, 0, iPH, iPH)
  
  PicBackground.Move(0, 0, Form13Export.ClientWidth, Form13Export.ClientHeight) 'Hintergrund Aluminium, Holz oder Farbe
  
  ''Panel Path:
  PanelPath.Move(iW, iH, PicBackground.W - (iW * 2), iPH)
  PicBoxMenu.Move(0, 0, iPH, PanelPath.H)
  ButtonFileInfo.Move(PicBoxMenu.Left + PicBoxMenu.W, 0, iPH, PanelPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelPath.H)
  LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelPath.W - (iPH * 5), PanelPath.H)
  ButtonPathAdd.Move(LabelInfo.Left + LabelInfo.W, 0, PanelPath.W - (LabelInfo.Left + LabelInfo.W), PanelPath.H)
  
  PanelBorder.Move(iW, PanelPath.Top + PanelPath.H, Form13Export.ClientW - (iW * 2), Form13Export.ClientH - iH - (PanelPath.Top + PanelPath.H))
  Panel1.Move(0, 0, PanelBorder.W, PanelBorder.H / 3)
  Panel2.Move(0, Panel1.Top + Panel1.H, PanelBorder.W, PanelBorder.H / 3)
  Panel3.Move(0, Panel2.Top + Panel2.H, PanelBorder.W, PanelBorder.H / 3)
  
  ''1.Open:
  TextAreaOpen.Move(0, 0, Panel1.W, Panel1.H - iPH)
  LabelBG1.Move(TextAreaOpen.Left, TextAreaOpen.Top, TextAreaOpen.W, TextAreaOpen.H)
  ButtonOpen.Move(0, TextAreaOpen.Top + TextAreaOpen.H, Panel1.W - (iPH * 7), iPH)
  ButtonFilterASCII.Move(ButtonOpen.Left + ButtonOpen.W, ButtonOpen.Top, iPH * 3, iPH) '[i]
  ButtonInfo.Move(ButtonFilterASCII.Left + ButtonFilterASCII.W, ButtonOpen.Top, iPH * 4, iPH) 'Format-Info
  ColumnView1.Move(0, 0, TextAreaOpen.W, TextAreaOpen.H)
  ProgressBar1.Move(0, Panel1.H - iPH, TextAreaOpen.W, iPH)
  
  ''2.Replace:
  TextAreaReplace.Move(0, 0, Panel2.W, Panel2.H - (iPH * 2))
  LabelBG2.Move(TextAreaReplace.Left, TextAreaReplace.Top, TextAreaReplace.W, TextAreaReplace.H)
  LabelInfo2.Move(0, TextAreaReplace.Top + TextAreaReplace.H, ButtonFilterASCII.Left, iPH)
  ButtonLoadMyKeys.Move(ButtonFilterASCII.Left, LabelInfo2.Top, iPH * 3, iPH)
  ButtonSaveMyKeys.Move(ButtonLoadMyKeys.Left + ButtonLoadMyKeys.W, ButtonLoadMyKeys.Top, iPH * 4, iPH)
  ButtonReplace.Move(0, LabelInfo2.Top + LabelInfo2.H, Panel2.W - (iPH * 7), iPH)
  ButtonUTF8.Move(ButtonReplace.Left + ButtonReplace.W, ButtonReplace.Top, iPH * 3, iPH)
  ButtonKeyboard.Move(ButtonUTF8.Left + ButtonUTF8.W, ButtonReplace.Top, iPH * 4, iPH)  
  
  PanelColumnLine.Move(Panel2.Left, Panel2.Top, Panel2.W, Panel2.H)
  TextAreaColumnLine1.Move(0, 0, PanelColumnLine.W, PanelColumnLine.H / 2)
  TextAreaColumnLine2.Move(0, TextAreaColumnLine1.Top + TextAreaColumnLine1.H, PanelColumnLine.W, PanelColumnLine.H - (TextAreaColumnLine1.Top + TextAreaColumnLine1.H))
  ButtonSearchUp.Move(0, PanelColumnLine.H - iPH, iPH, iPH)
  ButtonSearchDown.Move(ButtonSearchUp.Left + ButtonSearchUp.W, ButtonSearchUp.Top, iPH, iPH)
  ButtonColumnLineCancel.Move(ButtonSearchDown.Left + ButtonSearchDown.W, ButtonSearchDown.Top, PanelColumnLine.W - (ButtonSearchDown.Left + ButtonSearchDown.W), iPH)
  
  ''3.Save:
  TextAreaResult.Move(0, 0, Panel3.W, Panel3.H - iPH)
  LabelBG3.Move(TextAreaResult.Left, TextAreaResult.Top, TextAreaResult.W, TextAreaResult.H)
  ButtonSave.Move(0, TextAreaResult.Top + TextAreaResult.H, Panel2.W - (iPH * 7), iPH)
  ButtonCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, Panel3.W - (ButtonSave.Left + ButtonSave.W), iPH)
  ColumnView2.Move(0, 0, TextAreaResult.W, TextAreaResult.H)
  
  ButtonBorderCancel1.Move(Form13Export.ClientW - iW, PanelBorder.Top + Panel1.Top, iW, TextAreaOpen.H)
  ButtonBorderCancel2.Move(Form13Export.ClientW - iW, PanelBorder.Top + Panel2.Top, iW, TextAreaReplace.H)
  ButtonBorderCancel3.Move(Form13Export.ClientW - iW, PanelBorder.Top + Panel3.Top, iW, TextAreaResult.H)
  
  ''PanelUTF8
  fPart = PanelBorder.W / 10
  PanelUTF8.Move(PanelBorder.Left, PanelBorder.Top + Panel2.Top + LabelInfo2.Top, Panel3.W, PanelBorder.H - (Panel2.Top + LabelInfo2.Top))
  ScrollViewKeyboard.Move(0, 0, PanelUTF8.W, PanelUTF8.H - (iPH * 2))
  WebView1.Move(ScrollViewKeyboard.Left, ScrollViewKeyboard.Top, ScrollViewKeyboard.W, ScrollViewKeyboard.H)
  TextAreaQuelltext.Move(ScrollViewKeyboard.Left, ScrollViewKeyboard.Top, ScrollViewKeyboard.W, ScrollViewKeyboard.H)
  
  LabelUTF8Search.Move(0, ScrollViewKeyboard.Top + ScrollViewKeyboard.H, fPart * 2, iPH)
  LabelUTF8Code.Move(LabelUTF8Search.Left + LabelUTF8Search.W, LabelUTF8Search.Top, fPart * 2, iPH)
  LabelUTF8Found.Move(LabelUTF8Code.Left + LabelUTF8Code.W, LabelUTF8Search.Top, fPart * 2, iPH)
  LabelCodeInfo.Move(LabelUTF8Found.Left + LabelUTF8Found.W, LabelUTF8Found.Top, WebView1.W - (LabelUTF8Found.Left + LabelUTF8Found.W), LabelUTF8Found.H)
  
  TextBoxSearch.Move(0, LabelUTF8Search.Top + LabelUTF8Search.H, LabelUTF8Search.W, iPH)
  TextBoxCode.Move(TextBoxSearch.Left + TextBoxSearch.W, TextBoxSearch.Top, LabelUTF8Code.W, TextBoxSearch.H)
  TextBoxFound.Move(TextBoxCode.Left + TextBoxCode.W, TextBoxSearch.Top, LabelUTF8Found.W, TextBoxSearch.H)
  ButtonUTF8Apply.Move(TextBoxFound.Left + TextBoxFound.W, TextBoxSearch.Top, fPart * 2, TextBoxSearch.H)
  ButtonUTF8Cancel.Move(ButtonUTF8Apply.Left + ButtonUTF8Apply.W, ButtonUTF8Apply.Top, WebView1.W - (ButtonUTF8Apply.Left + ButtonUTF8Apply.W), ButtonUTF8Apply.H)
  TextBoxSearch.Font.Size = TextBoxSearch.H / 2
  TextBoxCode.Font.Size = TextBoxSearch.Font.Size
  TextBoxFound.Font.Size = TextBoxSearch.Font.Size
  
  If F_bMovingON = False Then WindowStretch.Move(Form13Export.ClientW - ButtonCancel.H - iW, Form13Export.ClientH - ButtonCancel.H - iH, ButtonCancel.H, ButtonCancel.H) 'quadratisch
  
  ' If ColumnView1.Visible = True Then 
  ColumnView1Resize()
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True 'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub PaintKeyboard()
  
  Dim Img As Image 
  Dim U As Float
  Dim sKey, sPrintKey, sTag, sToolTip, sUnvisible As String
  Dim hPicBox As PictureBox
  Dim it, iCode, iLeft, iTop, iColor As Integer
  
  F_ooASCIIKeybord = New Object[]
  ScrollViewKeyboard.Children.Clear 'delete all PictureBoxes as Keyboard
  
  U = ScrollViewKeyboard.H / 4 'Pixel
  ScrollViewKeyboard.ScrollBar = Scroll.Both
  ScrollViewKeyboard.Background = Color.DarkGray 
  'Asc(gb.Tab))=chr(9), Asc(gb.NewLine))=chr(10), Asc(Space(1)))=chr(32) empty (Leertaste)
  sUnvisible = ("Ein unsichtbares Zeichen. Nur hier dargestellt mit sichtbarem Ersatzzeichen.")
  iLeft = -U
  For it = 9 To 380 'Note: ASCII, not UTF-8 with String.Len()
    If F_bESCpressedON = True Then 
      Select Case Message.Question(("Zeichen-Liste") & "<br>", ("weiter einlesen") & "...", ("Abbrechen"))
        Case 1
          F_bESCpressedON = False
        Case 2
          Break
      End Select
    Endif 
    iCode = it 
    sKey = String.Chr$(iCode)
    sPrintKey = sKey
    sTag = sKey
    
    If iCode = 32 Then 'ASCII begin with Key empty (Leertaste)'Asc(Space(1)))=chr(32) empty (Leertaste)
      sPrintKey = "■"
      sTag = sKey & "=" & Space(1) & Chr(32) 'empty
      sToolTip = sPrintKey & Space(1) & ("Lange Leertaste, Leerzeichen, Space") & gb.NewLine & sUnvisible
      iColor = Color.Blue
    Else If iCode = 10 Then 'Asc(gb.NewLine))=chr(10)
      sPrintKey = "¶"
      sTag = sKey & "=" & gb.NewLine
      sToolTip = sPrintKey & Space(1) & ("Zeilenumbruch, Return, neue Zeile, Wagenrücklauf chr(13) + Carriage Return chr(10)") & gb.NewLine & sUnvisible
      iColor = Color.Blue
    Else If iCode = 9 Then 'Asc(gb.Tab)) = Chr(9)
      sPrintKey = "⇄"
      sTag = sKey & "=" & gb.Tab
      sToolTip = sPrintKey & Space(1) & ("Tabulator") & gb.NewLine & sUnvisible
      iColor = Color.Blue
    Else 
      sTag = sKey & "=" & "??"
      sToolTip = sKey
      iColor = Color.DarkGray
    Endif 
    
    If sPrintKey Then 
      Img = New Image(U, U, Color.Background)
      Paint.Begin(Img)
      Paint.Font.Name = "Ubuntu"
      ' Paint.Font.Name = "Waree"
      Paint.Font.Bold = True
      Paint.Font.Size = U / 3
      Paint.RichText(sPrintKey, 0, 0, U, U, Align.Center)
      Paint.LineWidth = 2
      Paint.Brush = Paint.Color(iColor)
      Paint.Fill()
      Paint.End
      
      hPicBox = New PictureBox(ScrollViewKeyboard) As "GroupKeyword"
      hPicBox.Border = True 
      hPicBox.Visible = True 
      hPicBox.Picture = Img.Picture 
      hPicBox.Padding = 4
      hPicBox.Tag = sTag
      hPicBox.ToolTip = sToolTip
      hPicBox.Mouse = Mouse.Pointing 'hand
      If iLeft + U > ScrollViewKeyboard.Width Then 
        iLeft = 0
        iTop = iTop + U
      Else 
        iLeft = iLeft + U
      Endif 
      hPicBox.Move(iLeft, iTop, U, U)
      hPicBox.Raise()
      
      F_ooASCIIKeybord.Add(hPicBox)
    Endif
  Next 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Sub GroupKeyword_Enter()
  
  Last.Background = Color.Green 
  
End

Public Sub GroupKeyword_Leave()
  
  Last.Background = Color.Default 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupKeyword_MouseDown()
  
  Dim ssSpli As String[]
  Dim sCharacter As String
  
  ssSpli = Split(Last.Tag & "=", "=")
  If ssSpli Then 
    sCharacter = ssSpli[0]
    WebTextCheck(sCharacter)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  LabelBG1.Lower()
  LabelBG2.Lower()
  LabelBG3.Lower()
  TextAreaQuelltext.Lower()

  WindowStretch.Raise() 'Level ▲Top▲
  IconError.Raise()
  PicBoxMenu.Raise()
    
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
 
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub ReadG() 
  'Aus der Datei wird zeilenweise gelesen
  
  Dim sDirFile, sText, sKey As String
  Dim iColumn, iLine As Integer
  Dim hFile As File
  Dim sColumn, sLine As String
  Dim bColumns As Boolean
  Dim picTransparent As Picture
  Dim hTab, hReturn As String  
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  picTransparent = New Picture(22, 22, True)
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  If Exist(sDirFile) = False Then sDirFile = User.Home
  
  sDirFile = FileDialogPathReturn(sDirFile, "open", Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt])
  
  If Exist(sDirFile) = True Then
    TextBoxPath.Foreground = Color.Default  
    Form13Export.Window.Title = Application.Name & " - " & File.Name(sDirFile) & Space(2) & ("einlesen...") & Space(2) & File.FormatSize(Stat(sDirFile).Size, False) 'FormatSize needs component gb.util
    Settings[FMain.Name &/ "LastExportFile"] = sDirFile
    
    TextBoxPath.Text = sDirFile
    F_longFilesRead = Stat(sDirFile).Size
    ''Check first lines. File-Format:
    F_iMusterTermine1Names2Projects3 = 3 
    If File.Name(sDirFile) Like "*project*.txt" Then 
      bColumns = M01Functions.isProjectFile(sDirFile, False)  '(Path, MessageQuestionFalse) as Boolean  
      If bColumns = True Then F_iMusterTermine1Names2Projects3 = 3 
    Else 
      bColumns = M01Functions.isTerminweckerFile(sDirFile, False)  '(Path, MessageQuestionFalse) as Boolean   
      If bColumns = True Then F_iMusterTermine1Names2Projects3 = 1
    Endif 
    
    If bColumns = True Then 
      ColumnView1.Clear()
      ColumnView2.Clear()
      ColumnView1Resize()
      ColumnView1.Visible = True 
      TextAreaOpen.Visible = False 
      PanelUTF8.Visible = False
    Else 
      ColumnView1.Visible = False  
      TextAreaOpen.Visible = True 
    Endif 
    ColumnView1Resize()
    ColumnView1.Columns[5].Title = Form13Export.Window.Title
    
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    
    For Each sLine In hFile.Lines  ''all Lines in File
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
      Endif
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If String.Left(sLine, 1) <> "#" And String.InStr(sLine, hTab) > 0 Then 
        If bColumns = True Then 
          iColumn = 0 
          sKey = Str(ColumnView1.Count + 1)
          ColumnView1.Add(sKey, "")
          ColumnView1[sKey].Picture = picTransparent
          F_sColumnLineLast = sKey
          For Each sColumn In Split(sLine & gb.Tab, gb.Tab)
            ColumnView1[sKey][iColumn] = sColumn
            iColumn = iColumn + 1
            If iColumn > ColumnView1.Columns.Count Then Break
          Next 
        Else 
          sText &= sLine & hReturn 
        Endif 
      Endif 
    Next 
    
    Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() '' ########################################
  Endif 
  If ColumnView1.Exist(F_sColumnLineLast) = True Then 
    sKey = F_sColumnLineLast
    ColumnView1[sKey].Selected = True
    ColumnView1[sKey].EnsureVisible()
  Endif
  If bColumns = True Then 
    ColumnView1Resize()
    ColumnView1.Visible = True 
    TextAreaOpen.Visible = False 
  Else 
    ColumnView1.Visible = False  
    TextAreaOpen.Visible = True 
    If sText Then 
      TextAreaOpen.SelectAll()
      TextAreaOpen.Insert(sText)
    Endif 
  Endif 
  ColumnView2.Visible = ColumnView1.Visible 
  TextAreaResult.Visible = TextAreaOpen.Visible 
  
JumpEnd:
  ProgressBarONoff(False)
  Form13Export.Window.Title = F_sTitleBasicText
  
Catch
  FMain.ErrorText
  If Exist(sDirFile) = True Then hFile.Close()
  
End 

Public Sub ColumnView1Resize()
  
  Dim it As Integer
  Dim sInfo As String
  Dim sSizeAll As String 
  
  CheckiMusterTermine1Names2Projects3()
  
  sSizeAll = Space(1) & "=" & Space(1) & File.FormatSize(F_longFilesRead, False) 'as String   
  
  If ColumnView1.Count < 2 Then 
    sInfo = Space(2) & ("Leer. Datei öffnen oder +Einfügen") 
  Else 
    If F_iMusterTermine1Names2Projects3 > 1 Then sInfo = Space(3) & ("Projekt-Name") 
    sInfo = ("Notiz") & sInfo & Space(2) & ("Zeilen") & ": " & ColumnView1.Count & sSizeAll
  Endif 
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ColumnView1.Columns[1].Title = ("Uhr")     '00:00 Begin
  ColumnView1.Columns[2].Title = Space(1)    'Su Weekday (Wochentag) 
  ColumnView1.Columns[3].Title = Space(1)    '0Q Quater (Quartal)
  ColumnView1.Columns[4].Title = Space(1)    '0CW CalenderWeek (KalenderWoche)
  ColumnView1.Columns[5].Title = sInfo       'Notice (Notiz)
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Title = ""          'Nr
    ColumnView1.Columns[7].Title = ""          'Undo
    ColumnView1.Columns[8].Title = ""          'Select01
    ColumnView1.Columns[9].Title = ""          'Sort
  Else 
    ColumnView1.Columns[6].Title = ("Uhr")     '00:00 End
    ColumnView1.Columns[7].Title = ""          'Su Weekday (Wochentag)
    ColumnView1.Columns[8].Title = ""          'Seconds 123 (Sekunden)
    ColumnView1.Columns[9].Title = ("Dauer")   '00:00:00 Duration  
  Endif 
  
  ColumnView1.Columns[0].Width = 200
  ColumnView1.Columns[1].Width = 80
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 80
  ColumnView1.Columns[5].Width = 0           'Notice
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Width = 0
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 0  
  Else 
    ColumnView1.Columns[6].Width = 50          '00:00 End
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 100         '00:00:00 Duration  
  Endif 
  
  For it = 10 To ColumnView1.Columns.Max     '>9 or >13
    ColumnView1.Columns[it].Title = ""         'ColumnsUndo
    ColumnView1.Columns[it].Width = 0          'ColumnsUndo
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[F_iColumnUndo].Left 
  
  ColumnView2Resize() 
  ColumnViewAscending()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13     F_iColumnsCount=14
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End


Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  If ColumnView2.Columns.Ascending = True Then  
    ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  
Catch 
  FMain.ErrorText
    
End

Public Sub ColumnView2Resize()                                                            'ColumnView2 = ColumnView1
  
  Dim sInfo As String
  Dim it As Integer
  
  sInfo = Str(ColumnView2.Count) & Space(1) & ("Zeilen")
  ColumnView2.Columns.Count = ColumnView1.Columns.Count                                   'Columns:|0|1|2|3|...|max|
  ColumnView2.Header = ColumnView1.Header                                                 'Title, Row index=0
  ColumnView2.Mode = ColumnView1.Mode
  ColumnView2.AutoResize = ColumnView1.AutoResize 'last column in last row  |abc| => |abcdef>>| 
  ColumnView2.Sorted = ColumnView1.Sorted
  ColumnView2.Resizable = ColumnView1.Resizable                                           'Header <|> <|> Resize with Mouse
  ColumnView2.Columns.Ascending = ColumnView1.Columns.Ascending     '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ColumnView2.Columns[0].Alignment = ColumnView1.Columns[0].Alignment                     '|  123|
  ColumnView2.Columns[2].Alignment = ColumnView1.Columns[2].Alignment                     '| abc |
  ColumnView2.Columns[6].Alignment = ColumnView1.Columns[6].Alignment                     '|  123|
  
  For it = 0 To ColumnView1.Columns.Max
    ColumnView2.Columns[it].Title = ColumnView1.Columns[it].Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
  Next
  ColumnView2.Columns[5].Width = 0
  ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[F_iColumnUndo].Left
  ColumnView2.Columns[5].Title = sInfo
  '.AutoResize width = longest text in Column in last row
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ReplaceG() 'ö=oe, Replace (Ersetzen)
  
  Dim sKey, sKeyFirst, sText, sPart, sUnknow, sCharacter, sMessage As String
  Dim ssSpli, ssReplace, ssExist As String[]
  Dim iLen, iFound, iLine, iColumn, iProjectLine As Integer
  Dim picTransparent As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  picTransparent = New Picture(22, 22, True)
  Form13Export.Window.Title = Application.Name & " - " & ("ersetzen...")
  
  ''Open:
  TextAreaOpen.SelectAll()
  sText = TextAreaOpen.Text
  TextAreaResult.SelectAll()
  TextAreaResult.Insert(TextAreaOpen.Selection.Text)
  
  iLen = String.Len(sText) ' ProgressMax is 1
  
  sUnknow = TextAreaReplace.Text 
  If sUnknow Not Like "*=*" Then 
    sMessage = ("Ersatz-Zeichen fehlen") & "<h3>" & ("Beispiel") & ": " & "ö=oe" & "</h3>"
    Message.Info(sMessage)
  Else 
    If TextAreaOpen.Visible = True Then 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
      ColumnView2.Visible = False
      TextAreaResult.Visible = True
      ssExist = New String[]
      
      ''TextAreaReplace, Result:
      ssSpli = Split(sUnknow & ";", ";") 'Example: "ü=ue;ä=ae;ß=ss;ö=oe;Ü=Ue;Ä=Ae;Ö=oe;¶=  ;€=Euro;²=2;³=3;½=1/2;"
      For Each sPart In ssSpli
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
        Endif 
        
        If String.InStr(sPart, "=") > 0 Then
          ssReplace = Split(sPart & "=", "=")
          If ssReplace Then 
            sCharacter = ssReplace[0]
            If ssExist.Find(sCharacter, gb.String) = -1 Then 
              If sText Like "*" & sCharacter & "*" Then 
                ssExist.Add(sCharacter) 
                Try sText = Replace(sText, ssReplace[0], ssReplace[1]) 'Example: Convert "ö=oe" 
              Endif 
            Endif 
          Endif 
        Endif
      Next
      Panel2.Visible = True
      PanelColumnLine.Visible = False 
      TextAreaResult.SelectAll()
      TextAreaResult.Insert(sText)
      F_iSpecialCharacters = ssExist.Count 'ö, Counter
    Endif 
    
    If ColumnView1.Visible = True Then  'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      ColumnView2.Visible = True
      TextAreaResult.Visible = False
      ColumnView2.Clear() 'Reset
      ColumnView1Resize()
      iProjectLine = 1
      ssExist = New String[]
      
      ''Copy:
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
        Endif 
        
        ColumnView2.Add(sKey, "")
        ColumnView1[sKey].Picture = picTransparent
        For iColumn = 0 To ColumnView1.Columns.Max
          ColumnView2[sKey][iColumn] = ColumnView1[sKey][iColumn]
        Next 
      Next 
      
      ''Replace:
      ssSpli = Split(sUnknow & ";", ";") 'Example: "ü=ue;ä=ae;ß=ss;ö=oe;Ü=Ue;Ä=Ae;Ö=oe;¶=  ;€=Euro;²=2;³=3;½=1/2;"
      For Each sPart In ssSpli
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
        Endif 
        
        If String.InStr(sPart, "=") > 0 Then
          ssReplace = Split(sPart & "=", "=")
          If ssReplace Then 
            sCharacter = ssReplace[0]
            If ssExist.Find(sCharacter, gb.String) = -1 And sCharacter <> "¶" And sCharacter <> gb.NewLine Then 
              ssExist.Add(sCharacter) 
              For Each sKey In ColumnView2.Keys
                iLine = iLine + 1
                If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
                ''[ESC]?
                If F_bESCpressedON = True Then 
                  If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
                Endif 
                
                If ColumnView2[sKey][5] Like "*" & sCharacter & "*" Then 
                  ColumnView2[sKey][5] = Replace(ColumnView2[sKey][5], ssReplace[0], ssReplace[1]) 'Example: Convert "ö=oe"
                  ColumnView2[sKey].Background = F_iColorGreen220
                  iFound = iFound + 1
                  If Not sKeyFirst Then sKeyFirst = sKey
                Endif 
              Next 
            Endif 
          Endif 
        Endif
      Next
      sKey = sKeyFirst
      F_sColumnLineLast = sKey
      If ColumnView2.Exist(sKey) = True Then 
        ColumnViewLine(sKey)
        ColumnView2.Columns[5].Title = ("Zeichen gefunden") & ": " & Str(iFound) 
      Endif 
      Panel2.Visible = False
      PanelColumnLine.Visible = True 
    Endif 
  Endif 
  
  ProgressBarONoff(False)
  Form13Export.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  ProgressBar1.Visible = False
  
End

Public Sub ColumnViewDownUp(Optional sDownUp As String = "+") '▼△
  
  Dim iKey As Integer 
  Dim sKey As String 
  
  ''ColumnView1:
  If ColumnView1.Visible = True Then 
    If ColumnView1.Exist(F_sColumnLineLast) = False And ColumnView1.Selection.Max > -1 Then F_sColumnLineLast = ColumnView1.Selection.Last 
    If IsInteger(F_sColumnLineLast) = True Then iKey = CInteger(F_sColumnLineLast)
    
    If sDownUp = "+" And iKey > 0 Then  
      sKey = Str(iKey + 1)
      If ColumnView1.Exist(sKey) = False Then sKey = ColumnView1[1].Key 'after Header=[0] > [1]
    Else If sDownUp = "-" And iKey > 0 Then ''"-"
      sKey = Str(iKey - 1)
      If ColumnView1.Exist(sKey) = False Then sKey = ColumnView1[ColumnView1.Count].Key
    Endif 
    
    If ColumnView1.Exist(sKey) = True Then 
      F_sColumnLineLast = sKey
      ColumnViewLine(sKey)
    Else   
      If sDownUp = "+" Then 
        ButtonSearchDown.Background = Color.Red 
      Else ''"-"
        ButtonSearchUp.Background = Color.Red 
      Endif 
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    Select Case Message.Question(sMessage, ("weiter") & "...", ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG() ' Speichern
  
  Dim iColumn, iLine As Integer
  Dim sDir, sFile, sDirFile, sBackup, sText, sKey, sLine, sLines, sInfo, sInfo1, sInfo2, sMessage As String
  Dim sFilter1, sFilterText1, sFilter2, sFilterText2, sFilter3, sFilterText3, sFilter4, sFilterText4, sFilter5, sFilterText5 As String
  Dim iSave1SaveAs2Cancel3 As Integer
  Dim picOK As Picture 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  picOK = PicTemplateApply.Picture.Image.Stretch(22, 22).Picture
  
  ''Text?
  If String.Len(TextAreaResult.Text) = 0 Then 
    sMessage = ("Noch ohne Text. Siehe Schalter") & ": " & ButtonReplace.Text
    Message.Info(sMessage) 
  Else 
    'TRY 'Bei Fehler nächste Zeile
    sDirFile = TextBoxPath.Text 
    If TextAreaResult.Visible = True Then 
      sInfo = String.Len(TextAreaResult.Selection.Text) & Space(1) & ("Zeichen mit") & Space(1)
      sText = M01Functions.CheckTextTerminwecker(TextAreaResult.Selection.Text) 'as String, Null or Infotext
      If sText Then sText = ("Keine erkennbare Text-Struktur für") & Space(1) & Application.Name
    Endif 
    sInfo1 = "○ "
    If ColumnView2.Visible = True Then 
      sInfo = ColumnView1.Keys.Count & Space(1) & ("Zeilen") & ", "
      If M01Functions.isTerminweckerFile(sDirFile) = False Then  'as Boolean
        sInfo1 = "? "
        sText = ("Keine erkennbare Text-Struktur für") & Space(1) & Application.Name
      Endif 
    Endif
    sMessage = "<h3><font color=gray>" & ("Speichern in die aktuelle Datei?") & "</font></h3>"
    sMessage &= "<h3>" & "○ " & "<font color=darkgreen>" & File.Dir(sDirFile) &/ "</font><font color=red>" & File.Name(sDirFile) & "</font>" & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font></h3>" 
    sMessage &= "<font color=gray>" & Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] &/ "..." & "</font>" & "<br>"
    If Not sText Then
      sMessage &= "<h2><font color=red>" & sInfo1 & ("Inhalt speichern, überschreiben?") & "</font></h2>"
    Endif 
    sMessage &= "<h3><font color=darkgray>" & Quote(String.Left(TextAreaReplace.Text, 300)) & "</font></h3>"
    sMessage &= "<h3><font color=darkgray>" & sInfo & F_iSpecialCharacters & Space(1) & ("Arten Sonder-Zeichen ersetzen") & "</font></h3>"
    sMessage &= "<h3><font color=darkgray>" & ("Text-Inhalt") & ":" & "</font></h3>"
    sMessage &= "<font color=gray>" & Quote(String.Left(TextAreaResult.Selection.Text & gb.Newline & "...", 300)) & "</font><br>"
    If sText Then 
      sInfo2 = "● "
      sMessage &= "<h2><font color=red>" & sText & "</font></h2>"
      sMessage &= "<h3>" & sInfo2 & "<font color=darkgreen>" & ("Speichern als... neue Datei") & "</font></h3>"
    Endif

    Select Case Message.Question(sMessage, sInfo1 & ("Speichern") & "...", sInfo2 & ("Speichern als..."), ("Abbrechen"))
      Case 1 
        iSave1SaveAs2Cancel3 = 1
      Case 2
        iSave1SaveAs2Cancel3 = 2
      Case 3
        iSave1SaveAs2Cancel3 = 3
        Goto JumpEnd
    End Select
      
    If iSave1SaveAs2Cancel3 = 2 Then 
      sFilter1 = "*.txt"
      sFilterText1 = ("Nur-Text")
      sFilter2 = ("*geburtstag*.txt")
      sFilterText2 = ("Geburtstage *Jedes Jahr")
      sFilter3 = "*" & Format(Now, "yyyy-mm-dd") & "*.txt"
      sFilterText3 = ("Heute")
      sFilter4 = "*termin*" & Format(Now, "yyyy-mm-") & "*.txt"
      sFilterText4 = ("Monat ") & Format(Now, "mmmm yyyy")
      sFilter5 = "*termin*" & Format(Now, "yyyy-") & "*.txt"
      sFilterText5 = ("Jahr ") & Format(Now, "yyyy")
      
      Dialog.Filter = [sFilter1, sFilterText1, sFilter2, sFilterText2, sFilter3, sFilterText3, sFilter4, sFilterText4, sFilter5, sFilterText5] ' autom. + all files *.* 
      
      If Exist(TextBoxPath.Text) = True Then 
        sDirFile = TextBoxPath.Text
      Else 
        ''Alternative:
        sDirFile = Settings[FMain.Name &/ "LastExportFile", ""]
        If Exist(sDirFile) = True Then sDir = File.Dir(sDirFile)
        If Exist(sDir) = False Then 
          sDir = Desktop.GetDirectory("DOCUMENTS")                                         '"DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
          If Exist(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
        Endif 
        sFile = "export_" & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & Application.Name & ".txt"
        sDirFile = sDir &/ sFile
      Endif 
    Endif
    
    'DialogDDDDDDDDDDDDDDDDDDDDDDDD
    'Dialog.Filter = ["*.txt", "Nur-Text"]
    ' Dialog.Path = sDirFile
    ' Dialog.AutoExt = True ''needs component: gb.form.dialog
    ' Dialog.Title = ("Speichern unter...")
    ' If Dialog.SaveFile() Then Return 'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    'DialogDDDDDDDDDDDDDDDDDDDDDDDD
    
    'no canceled:
    ' sDirFile = Dialog.Path
    sDirFile = FileDialogPathReturn(sDirFile, "save", Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt])
    If Not sDirFile Then Return  
    
    Form13Export.Window.Title = Application.Name & " - " & File.Name(sDirFile) & Space(2) & ("speichern...")
    ProgressBarONoff(True)
    Wait 0.5
    
    ''Save:
    If TextAreaResult.Visible = True Then  
      sDirFile = M01Functions.FileTextPlus(sDirFile, TextAreaResult.Text, True) 'TRUE=overwrite (überschreiben)
    Else If ColumnView2.Visible = True Then 
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
        Endif 
        
        sLine = "" 'Reset
        For iColumn = 0 To F_iColumnsReadMax '5 or 9
          If iColumn < F_iColumnsReadMax Then  
            sLine &= ColumnView2[sKey][iColumn] & hTab
          Else 
            sLine &= ColumnView2[sKey][iColumn] & hReturn  
            ColumnView2[sKey].Picture = picOK
            Break
          Endif 
        Next 
        sLines &= sLine 
      Next 
      If F_bESCpressedON = False Then 
        sDirFile = M01Functions.FileTextPlus(sDirFile, sLines, True) 'TRUE=overwrite (überschreiben)
      Endif   
    Endif 

    Form13Export.Window.Title = F_sTitleBasicText
    ProgressBarONoff(False)
    
    ''Check:
    If Exist(sDirFile) = True Then 
      Settings[FMain.Name &/ "LastExportFile"] = sDirFile
      sBackup = FMain.F_sLastCopyBackup
      If Exist(sBackup) = False Then 
        sInfo = "<font color=red>" & ("Ohne") & "</font>" & "<br>" 
      Else 
        sInfo = "<font color=gray>" & sBackup & "</font>" & "<br>" 
      Endif 
      sMessage = "<h3><font color=darkgreen>" & ("Gespeichert") & ": " & "</font></h3>"
      sMessage &= sDirFile & "<br>" 
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font><br>" 
      sMessage &= "<br>"
      sMessage &= "● " & ("Hauptseite > Menü > Datei > Backup...") & "<br>" 
      sMessage &= "○ " & ("Sicherungskopie/Backup") & ": " & "<br>" 
      sMessage &= sInfo
      Select Case Message.Question(sMessage, "● " & ("Backup... Wiederherstellung"), "○ " & ("Ordner..."), ("Abbrechen"))
        Case 1
          FMain.mnuTerminweckerBackupG()
        Case 2
          If Exist(sBackup) = True Then M01Functions.FileManagerOpen(sBackup) Else M01Functions.FileManagerOpen(sDirFile)
        Case 3
          ''...
      End Select
    Else 
      Message.Info(sDirFile & gb.NewLine & gb.NewLine & ("Datei nicht gefunden") & "." & ("Abbruch") & ".") 
    Endif 
  Endif 'Text?
  
  JumpEnd:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'Beispielaufruf: 
  'ohne Value         ProgressBarONoff(TRUE)
  'oder direkt mit    ProgressBar1.Value = Zaehler / ColumnView1.Count
  'oder direkt mit    ProgressBar1.Value = 0.99 / ColumnView1.Count * it
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'zurück zum Anfang
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 'Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoG()
  
  Dim sMessage, sExample, sASCII, sNotVisible, sHTMLspace, sHTMLfont, sHTMLendfont, sHTMLbreak As String 
  
  sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html
  sHTMLbreak = "<br>"
  sHTMLfont = "<font color=gray><b>"
  sHTMLendfont = "</b></font>"
  sNotVisible = "<font color=red>" & Space(1) & ("unsichtbar") & ": " & "</font>"
  F_sASCII = Quote(ASCIIString()) 'as String 
  sASCII = F_sASCII
  If Not sASCII Then sASCII = ("Keine")
  
  ''Charset or character set (Zeichensatz):
  sMessage = ("Allgemeiner Mindestzeichensatz") & "<font color=blue>" & sHTMLspace & ("ASCII") & "</font>" & ":" & sHTMLbreak
  
  sMessage &= sHTMLbreak
  sMessage &= "<font size=3 color=blue><b>" & sASCII & "</b></font>" & sHTMLbreak
  sExample = "ö=oe"
  sMessage &= sHTMLbreak & sExample & sHTMLbreak & sHTMLfont & ("Original") & " = " & "<font color=blue>" & ("Ersatz") & "</font>" & sHTMLendfont & sHTMLbreak
  sExample = "Ã€=ä"
  sMessage &= sHTMLbreak & sExample & sHTMLbreak & sHTMLfont & ("Umlaute und Sonderzeichen, Umgekehrung") & sHTMLendfont & sHTMLbreak
  sExample = "�=" & sNotVisible
  sMessage &= sHTMLbreak & sExample & sHTMLbreak & sHTMLfont & ("Sonderzeichen für nicht erkannte Zeichen") & sHTMLendfont & sHTMLbreak
  sExample = "_=" & sNotVisible
  sMessage &= sHTMLbreak & sExample & sHTMLbreak & sHTMLfont & ("Zeichen wie Leertaste") & sHTMLendfont & sHTMLbreak
  sExample = "¶=" & sNotVisible
  sMessage &= sHTMLbreak & sExample & sHTMLbreak & sHTMLfont & ("Zeichen wie Zeilenumbruch (neue Zeile, Return)") & sHTMLendfont & sHTMLbreak
  sMessage &= sHTMLbreak 
  
  sMessage &= "<font color=darkgreen><b>" & ("Beispiele") & ": " & "</b></font>" & sHTMLbreak 
  sMessage &= F_sMyABC
  
  Select Case Message.Question(sMessage, ("Beispiele 'Einfügen'"), ("Abbrechen"))
      
    Case 1 'Paste:
      TextAreaReplace.SelectAll() 'Über Selektion später Undo möglich
      TextAreaReplace.Insert(F_sMyABC)
      TextAreaReplace.SelectAll() 
      
    Case 2 'Cancel:
      '...
      
  End Select
  
  ''______________________________________________________________________________________________________________________''
  ''ASCII = "\n  !\"#$%&'()*+,-./0123456789:;<=>?\n  @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\n  `abcdefghijklmnopqrstuvwxyz{|}~"
  ' Quelle 2020: "https://de.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange"
  ' "\n" = gb.NewLine 
  ' ASCII = Quote(ASCII) = Quote("...")
  ' Unicode oder ISO 10646 mit allen Zeichen aller Schriftkulturen, ständig aktualisiert. Gambas3 benutzt intern ASCII. Sortierung einheitlich [A>z]. 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBar1_MouseDown()
  
  ProgressBar1.Visible = False
  
End

Public Sub TextBoxPath_KeyPress()

  If Key.Code = Key.Return Then ButtonGroupSelect("add")
  
Catch 
  FMain.ErrorText

End

Public Sub TextAreaOpen_Enter()
  
  ButtonOpen.Font.Bold = True 
  
End

Public Sub TextAreaOpen_Leave()
  
  ButtonOpen.Font.Bold = False 
  
End

Public Sub TextAreaReplace_Enter()
  
  ButtonReplace.Font.Bold = True 
  
End

Public Sub TextAreaReplace_Leave()
  
  ButtonReplace.Font.Bold = False 
  
End

Public Sub TextAreaResult_Enter()
  
  ButtonSave.Font.Bold = True 
  
End

Public Sub TextAreaResult_Leave()
  
  ButtonSave.Font.Bold = False 
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End


Public Sub WindowStretch_DblClick()
  
  Form13Export.Window.Maximized = Not Form13Export.Window.Maximized 
  If Form13Export.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form13Export.Window.FullScreen = True Or Form13Export.Window.Maximized = True Then 
      F_bMovingON = False
      Form13Export.Window.FullScreen = False
      Form13Export.Window.Maximized = False
      If Form13Export.Left + Form13Export.W > Screen.AvailableWidth Then Form13Export.Move(Form13Export.Left, Form13Export.Top, Screen.AvailableWidth - Form13Export.Left, Screen.AvailableHeight - Form13Export.Top)
    Else
      F_bMovingON = True
      Form13Export.Window.FullScreen = False
      Form13Export.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form13Export.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form13Export.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form13Export.ClientW - WindowStretch.W, Form13Export.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form13Export.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form13Export.W = Mouse.ScreenX - F_iX1
    Form13Export.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form13Export.ClientW - WindowStretch.W, Form13Export.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form13Export.ClientW - WindowStretch.W, Form13Export.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form13Export.Window.Maximized = Not Form13Export.Window.Maximized 
    If Form13Export.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form13Export.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu2.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Function FilterASCII() As String
  
  Dim iPos, iLine, iCounter As Integer
  Dim sKey, sCharacter, sText, sHTML, sTitle As String
  Dim ssExist As String[]
  
  Form13Export.Window.Title = Application.Name & " - " & ("filtern...")
  ProgressBarONoff(True)
  ssExist = New String[]
  
  If TextAreaOpen.Visible = True Then 
    For iPos = 1 To String.Len(TextAreaOpen.Text) 'Position begins with 1, not 0
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
      Endif
      
      sCharacter = String.Mid(TextAreaOpen.Text, iPos, 1) 'String.Mid() in UTF-8. characters, not in bytes
      If IsAscii(sCharacter) = False Then 
        If ssExist.Find(sCharacter, gb.String) = -1 Then 'not double '-1 not found
          ssExist.Add(sCharacter)
          iCounter = iCounter + 1
          sText &= sCharacter & "=" & "??;"
          
          sHTML &= "<table cellpadding=3><tbody><tr valign=top>" 
          sHTML &= "<td width=30% color=black name=ubuntu bgcolor=yellow>" 
          sHTML &= sCharacter 
          sHTML &= "</td>"
          sHTML &= "<td width=30% bgcolor=white>" 
          sHTML &= "="
          sHTML &= "</td>"
          sHTML &= "<td width=30% bgcolor=yellow>" 
          sHTML &= "??;" 
          sHTML &= "</td>"
          sHTML &= "</tr></tbody></table>"
        Endif 
      Endif 
    Next 
    
  Else If ColumnView1.Visible = True Then 
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
      Endif
      
      For iPos = 1 To String.Len(ColumnView1[sKey][5]) 'Position begins with 1, not 0
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form13Export.Window.Title) = True Then Break
        Endif
        
        sCharacter = String.Mid(ColumnView1[sKey][5], iPos, 1) 'one character, not bytes. String.Len("Ö") = 1, String.Len("Ö")= 2 !
        If IsAscii(sCharacter) = False Then 
          If ssExist.Find(sCharacter, gb.String) = -1 Then 'not double
            ssExist.Add(sCharacter)
            iCounter = iCounter + 1
            sText &= sCharacter & "=" & "??;"
            
            sHTML &= "<table cellpadding=3><tbody><tr valign=top>" 
            sHTML &= "<td width=30% color=black name=ubuntu bgcolor=yellow>" 
            sHTML &= sCharacter 
            sHTML &= "</td>"
            sHTML &= "<td width=30% bgcolor=white>" 
            sHTML &= "="
            sHTML &= "</td>"
            sHTML &= "<td width=30% bgcolor=yellow>" 
            sHTML &= "??;" 
            sHTML &= "</td>"
            sHTML &= "</tr></tbody></table>"
          Endif 
        Endif 
      Next 
    Next 
  Endif  
  PanelColumnLine.Visible = False
  Panel2.Visible = True 
  TextAreaReplace.SelectAll() 'Über Selektion später Undo möglich
  TextAreaReplace.Insert(sText)
  LabelBG2.Background = PanelUTF8.Background
  sTitle = ("Filter") & ": " & Str(iCounter) & Space(1) & ("Zeichen gefunden") & "<br>" 
  If sText Then sTitle &= "<font color=gray>" & "1 Zeichen markieren:" & "</font><br>" 
  sHTML = sTitle & sHTML
  sHTML = "<font size=5>" & sHTML & "</font>"
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    WebView1.HTML = M01Functions.FileBasisHTML(sHTML)
  Endif 
  
  ProgressBarONoff(False)
  Form13Export.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveLoadMyKeysAbc(Optional sSaveLoad As String = "load")
  
  Dim sDir, sPath, sText, sMessage As String 
  Dim iLen As Integer
  Dim ssSpli As String[]
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] 
  If IsDir(sDir) = True Then sPath = sDir &/ Application.Name & "-MyKeysAbc.txt"
  
  Select Case sSaveLoad
      
    Case "s", "save"
      
      sMessage = sPath & "<br>"
      sMessage &= "<font color=gray>" & Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] &/ "..." & "</font>" & "<br>"
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font><br>" 
      sText = TextAreaReplace.Text
      If sText Then 
        ssSpli = Split(sText & "=", "=")
        iLen = ssSpli.Max - 1
        If iLen > 400 Then 
          sMessage &= "<font color=gray>" 
          sMessage &= String.Left(sText, 300) & "<br>" & "..." & "<br>" & String.Right(sText, 100) 
          sMessage &= "</font>" 
          sMessage &= "<h2><font color=red>" & ("Inhalt überschreiben?") & "</font></h2>"
        Else 
          sMessage &= "<font color=gray>" 
          sMessage &= sText
          sMessage &= "</font>" 
        Endif 
      Endif 
      sMessage &= "<h2><font color=blue>" & Str(iLen) & Space(1) & ("Zeichen") & "</font></h2>"
      
      Select Case Message.Question(sMessage, ("Speichern"), ("Ordner..."), ("Abbrechen"))
        Case 1
          ' File.Save(sPath, TextAreaReplace.Text)
          sPath = M01Functions.FileTextPlus(sPath, TextAreaReplace.Text, True) ' TRUE=overwrite (überschreiben)
          If Exist(sPath) = True Then TextAreaReplace.SelectAll()
        Case 2
          M01Functions.FileManagerOpen(sPath)
        Case 3
          ''...
      End Select 
      
    Case "l", "load"
      
      If Exist(sPath) = False Then 
        sMessage = sPath & "<br>" 
        sMessage &= "<h2><font color=red>" & ("Datei nicht gefunden") & "</font></h2>"
        sMessage &= "<h3><font color=gray>" & ("Tipp: Der Schalter 'Zeichen' erstellt eine neue Datei") & "</font></h3>"
        sMessage &= "<font color=gray>" & Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] &/ "..." & "</font>" & "<br>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1 
            M01Functions.FileManagerOpen(sDir) 
          Case 2
            ''...
        End Select
        
      Else 
        If Exist(sPath) = True Then sText = File.Load(sPath)
        sMessage = sPath & "<br>"
        sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font><br>" 
        If sText Then 
          ssSpli = Split(sText & "=", "=")
          iLen = ssSpli.Max - 1
          sMessage &= "<font color=gray>"
          If iLen > 400 Then sMessage &= String.Left(sText, 300) & "<br>" & "..." & "<br>" & String.Right(sText, 100) Else sMessage &= sText
          sMessage &= "</font>"
        Else 
          sMessage &= ("Leer")
        Endif 
        sMessage &= "<h2><font color=darkgreen>" & Str(iLen) & Space(1) & ("Zeichen") & "</font></h2>"
        
        Select Case Message.Question(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
          Case 1
            ' sText = File.Load(sPath)
            TextAreaReplace.SelectAll()
            TextAreaReplace.Insert(sText)
            TextAreaReplace.SelectAll()
          Case 2
            M01Functions.FileManagerOpen(sPath)
          Case 3
            ''...
        End Select 
      Endif 
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxSearch_Change()
  
  Dim sText As String 
  Dim iCode As Integer
  
  sText = TextBoxSearch.Text
  iCode = String.Code(sText) 
  
  TextBoxFound.SelectAll()
  TextBoxFound.Insert(String.Chr(iCode) & "=??;")
  
  TextBoxCode.SelectAll()
  TextBoxCode.Insert(iCode)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxCode_KeyPress()
  
  Dim iCode As Integer
  
  If Key.Code = Key.Return Then 
    If IsInteger(TextBoxCode.Text) = True Then 
      iCode = CInteger(TextBoxCode.Text)
      If String.Code(iCode) > -1 Then '-1 is returned if the UTF-8 string is invalid.
        WebTextCheck(String.Chr(iCode))
      Endif 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UTF8All() 'ö=oe, Replace (Ersetzen)
  
  Dim it As Integer
  Dim sHTML, sHTMLbody As String
  Dim sCharacter, sNotVisible, sHTMLspace, sHTMLfont, sHTMLendfont, sHTMLbreak As String 
  
  sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html
  sHTMLbreak = "<br>"
  sHTMLfont = "<font color=red><b>" ' bgcolor=lightblue
  sHTMLendfont = "</b></font></td>"
  sNotVisible = "<font color=red>" & Space(1) & ("unsichtbar") & ": " & "</font>"
  
  sHTMLbody = "<!DOCTYPE html>" & gb.NewLine 'html5 neu
  sHTMLbody &= "<html lang=de>" & gb.NewLine 'LANGuage DEutsch German
  sHTMLbody &= "<head>" & gb.NewLine
  sHTMLbody &= "<meta http-equiv=Language content=de>" & gb.NewLine
  sHTMLbody &= "<meta http-equiv=Content-Type content=" & Chr(34) & "text/html;CHARSET=utf-8" & Chr(34) & ">" & gb.NewLine
  sHTMLbody &= "<meta name=software content=" & Application.Name & ">" & gb.NewLine 
  sHTMLbody &= "<meta name=publisher content=design-cad.de>" & gb.NewLine 'or name=author
  sHTMLbody &= "<title>" & Application.Name & "</title>" & gb.NewLine
  sHTMLbody &= "</head>" & gb.NewLine
  
  sHTMLbody &= "<body><font color=black size=6 face=" & Chr(34) & "ubuntu" & Chr(34) & "> " & gb.NewLine 'Note: Abc0123... List Ubuntu
  ''UTF8 = ASCII(32-128)
  sHTML = "<font color=gray>" & "1 Zeichen markieren:" & "</font>" & sHTMLbreak & gb.NewLine
  
  For it = 32 To 380 
    sCharacter = String.Chr(it) 'one character, not bytes. String.Len("Ö") = 1, String.Len("Ö")= 2 !
    If IsAscii(sCharacter) = False Then
      sHTML &= sHTMLfont & sCharacter & sHTMLendfont
    Else 
      sHTML &= sCharacter
    Endif 
    If it Mod 50 = 0 Then sHtml &= "<br>"
  Next 
  sCharacter = String.Chr(65533) 'Sonderzeichen, Ersatzzeichen 
  sHTML &= sHTMLfont & sCharacter & sHTMLendfont
  
  sHTMLbody &= sHTML & gb.NewLine
  sHTMLbody &= "</font></body></html>" & gb.NewLine
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    WebView1.HTML = sHTMLbody
  Endif 
  
Catch 
  FMain.ErrorText
  ProgressBar1.Visible = False
  
End

Public Sub WebView1_Select() 
  
  Dim sCharacter As String
  
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    If WebView1.SelectedText Then 
      sCharacter = WebView1.SelectedText
      sCharacter = String.Left(sCharacter, 1)
      WebTextCheck(sCharacter)
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WebTextCheck(Optional sKey As String = "")
  
  Dim sText, sCharacter As String
  
  If sKey Then 
    sText = String.Left(sKey, 1)
    sCharacter = sText 
    
    TextBoxSearch.SelectAll()
    TextBoxSearch.Insert(sCharacter)
    
    LabelCodeInfo.Text = ""
    
    If sCharacter = gb.NewLine Then 
      sCharacter = "¶"
      LabelCodeInfo.Text = sCharacter & Space(1) & "Unsichtbar: Neue Zeile"
    Endif 
    If sCharacter = gb.Tab Then 
      sCharacter = "⇄"
      LabelCodeInfo.Text = sCharacter & Space(1) & "Unsichtbar: Tabulator"
    Endif 
    If sCharacter = Space(1) Then 
      sCharacter = "■"
      LabelCodeInfo.Text = sCharacter & Space(1) & "Unsichtbar: Leertaste"
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaOpen_MouseDown()
  
  LabelBG1.Background = Color.White 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaOpen_MouseUp()
  
  Dim sCharacter As String
  
  If PanelUTF8.Visible = True Then 
    sCharacter = TextAreaOpen.Selection.Text
    sCharacter = String.Left(sCharacter, 1)
    WebTextCheck(sCharacter)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaReplace_MouseDown()
  
  LabelBG2.Background = Color.White 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaReplace_MouseUp()
  
  Dim sCharacter As String
  
  sCharacter = String.Left(TextAreaReplace.Selection.Text, 1)
  WebTextCheck(sCharacter)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaResult_MouseDown()
  
  LabelBG3.Background = Color.White 
  
Catch 
  FMain.ErrorText
  
End

Public Function ASCIIString() As String 
  'first Position = Space, Empty (Leertaste) decimal=32 
  
  Return " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  
  ' F_sASCII = "\n     !\"#$%&'()*+,-./0123456789:;<", ">?\n    @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\n    `abcdefghijklmnopqrstuvwxyz{|}~"
  
  ' Print Conv("Beispiel Text würde daß über ändern mit § und €", Desktop.Charset, "ISO 8859-15") ''Mitteleuropaeisch: "ISO 8859-2"
  ' Print "Desktop-Zeichensatz = "; Desktop.Charset
  ' Print "System-Zeichensatz  = "; System.Charset
  ' Print Conv(TextAreaOpen.Text, "UTF-8", "ISO 8859-2") 
  
  ' Gambas3:
  ' gb.NewLine  Newline character. Equivalent to Chr$(10).
  ' gb.Cr  Carriage return character. Equivalent to Chr$(13). The line terminator on old Macintoshs.
  ' gb.Lf  Linefeed character. Equivalent to Chr$(10). The line terminator on Linux and co.
  ' gb.CrLf  Carriage return followed by linefeed. The line terminator on Windows and network protocols such as HTTP.
  ' gb.Tab  Tab character. Equivalent to Chr$(9).
  '
  '' "\\" Rueckwaertsschraegstrich (Backslash) '*1
  '' "\n" Zeilenumbruch (New Line), gb.NewLine 
  '' "\t" Tabulatorzeichen, z.B.tabellarisch ordnen 
  '' "\b" Backspace, löscht das vorhergehende Zeichen
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaOpenSearch(Optional sSearchDownUp As String = "-")
  
  Dim iMax, iPos, iCursorPos As Integer
  Dim sCharacter As String 
  
  iMax = String.Len(TextAreaOpen.Text)
  iCursorPos = TextAreaOpen.Pos
  If PanelUTF8.Visible = False Then ButtonGroupSelect(ButtonUTF8.Tag)
  
  Select Case sSearchDownUp
      
    Case "-" '◀—
      TextAreaOpen.SetFocus
      iCursorPos = iCursorPos - 1
      If iCursorPos < 2 Then iCursorPos = iMax + 1
      ' If iCursorPos > iMax Then iCursorPos = 1
      For iPos = iCursorPos To 1 Step -1
        sCharacter = String.Mid(TextAreaOpen.Text, iPos, 1)
        If IsAscii(sCharacter) = False Then 
          TextAreaOpen.Select(iPos - 1, 1)
          TextBoxSearch.SelectAll()
          TextBoxSearch.Insert(sCharacter)
          Break 
        Endif 
      Next 
      
    Case "+" '—▶
      TextAreaOpen.SetFocus
      iCursorPos = iCursorPos + 1
      ' If iCursorPos < 2 Then iCursorPos = iMax
      If iCursorPos > iMax Then iCursorPos = 1
      For iPos = iCursorPos To iMax + 1
        sCharacter = String.Mid(TextAreaOpen.Text, iPos, 1)
        If IsAscii(sCharacter) = False Then 
          TextAreaOpen.Select(iPos - 1, 1)
          TextBoxSearch.SelectAll()
          TextBoxSearch.Insert(sCharacter)
          Break 
        Endif 
      Next  
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_Select()

  Dim iColumn As Integer
  Dim sKey, sLine As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If ColumnView1.Selection.Max > -1 Then 
    F_sColumnLineLast = ColumnView1.Selection.First'ColumnView1.Current.Key
    sKey = ColumnView1.Selection.First
    ColumnView2.Columns[5].Title = ("Zeile") & ": " & F_sColumnLineLast
    If PanelColumnLine.Visible = True Then 
      If ColumnView1.Keys.Max > -1 Then 
        sLine = "" 'Reset
        For iColumn = 0 To F_iColumnsReadMax '5 or 9
          If iColumn < F_iColumnsReadMax Then  
            sLine &= ColumnView1[sKey][iColumn] & hTab
          Else 
            sLine &= ColumnView1[sKey][iColumn] & hReturn  
            Break
          Endif 
        Next 
        TextAreaColumnLine1.SelectAll()
        TextAreaColumnLine1.Insert(sLine)
        TextAreaColumnLine1.Line = 0
      Endif 
      
      If ColumnView2.Keys.Max > -1 Then 
        sLine = "" 'Reset
        For iColumn = 0 To F_iColumnsReadMax '5 or 9
          If iColumn < F_iColumnsReadMax Then  
            sLine &= ColumnView2[sKey][iColumn] & hTab
          Else 
            sLine &= ColumnView2[sKey][iColumn] & hReturn  
          Endif 
        Next 
        TextAreaColumnLine2.SelectAll()
        TextAreaColumnLine2.Insert(sLine)
        TextAreaColumnLine2.Line = 0
        ColumnView2.UnSelectAll()
        ColumnView2[F_sColumnLineLast].Selected = True 
        ColumnView2[F_sColumnLineLast].EnsureVisible
      Endif 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_Select()
  
  Dim iColumn As Integer
  Dim sKey, sLine As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If ColumnView2.Selection.Max > -1 Then 
    F_sColumnLineLast = ColumnView2.Selection.First 'ColumnView2.Current.Key
    sKey = ColumnView2.Selection.First
    ColumnView2.Columns[5].Title = ("Zeile") & ": " & F_sColumnLineLast
    If PanelColumnLine.Visible = True Then 
      If ColumnView1.Keys.Max > -1 Then 
        sLine = "" 'Reset
        For iColumn = 0 To F_iColumnsReadMax '5 or 9
          If iColumn < F_iColumnsReadMax Then  
            sLine &= ColumnView1[sKey][iColumn] & hTab
          Else 
            sLine &= ColumnView1[sKey][iColumn] & hReturn  
          Endif 
        Next 
        TextAreaColumnLine1.SelectAll()
        TextAreaColumnLine1.Insert(sLine)
        TextAreaColumnLine1.Line = 0
        ColumnView1.UnSelectAll()
        ColumnView1[F_sColumnLineLast].Selected = True 
        ColumnView1[F_sColumnLineLast].EnsureVisible
      Endif 
      
      If ColumnView2.Keys.Max > -1 Then 
        sLine = "" 'Reset
        For iColumn = 0 To F_iColumnsReadMax '5 or 9
          If iColumn < F_iColumnsReadMax Then  
            sLine &= ColumnView2[sKey][iColumn] & hTab
          Else 
            sLine &= ColumnView2[sKey][iColumn] & hReturn  
          Endif 
        Next 
        TextAreaColumnLine2.SelectAll()
        TextAreaColumnLine2.Insert(sLine)
        TextAreaColumnLine2.Line = 0
      Endif 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewLine(Optional sKey As String = "")
  
  Dim sLine1, sLine2 As String
  Dim iColumn As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If ColumnView1.Exist(sKey) = True Then 
    ColumnView2.Columns[5].Text = ("Zeile") & ": " & sKey
    
    If ColumnView2.Exist(sKey) = True Then
      ColumnView1.UnSelectAll()
      ColumnView2.UnSelectAll()
      ColumnView1[sKey].Selected = True
      ColumnView2[sKey].Selected = True
      ColumnView1[sKey].EnsureVisible()
      ColumnView2[sKey].EnsureVisible()
      ColumnView1.MoveTo(sKey)
      ColumnView2.MoveTo(sKey)
      sLine1 = ""
      sLIne2 = ""
      For iColumn = 0 To F_iColumnsReadMax 'ColumnView1.Columns.Max
        sLine1 &= ColumnView1[sKey][iColumn] & hTab
        sLine2 &= ColumnView2[sKey][iColumn] & hTab
      Next 
      sLine1 &= hReturn
      sLine2 &= hReturn
      TextAreaColumnLine1.SelectAll()
      TextAreaColumnLine1.Insert(sLine1)
      TextAreaColumnLine2.SelectAll()
      TextAreaColumnLine2.Insert(sLine2)
      TextAreaColumnLine1.Pos = 1
      TextAreaColumnLine1.EnsureVisible()
      TextAreaColumnLine2.Pos = 1
      TextAreaColumnLine2.EnsureVisible()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Click()

  ' ListMenuGroupFunctions(Last.Tag)
  ButtonGroupSelect(Last.Tag)
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewClipboardCopy() 'intern
  
  Dim it, iColumn, iLine As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''ColumnView1:
  If ColumnView1.HasFocus = True Then 
    F_ssKeysCopy = ColumnView1.Selection.Copy()
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView1.Columns.Max
          sLine = ColumnView1[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Else If ColumnView2.HasFocus = True Then ''ColumnView2:
    F_ssKeysCopy = ColumnView2.Selection.Copy()
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView2.Columns.Max
          sLine = ColumnView2[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines()
  
  Dim iLine, iDay, iColumn, iCorrectedLines, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim sK1, sTimerDays, sLine As String
  Dim hDate0, hDate1, hDate2 As Date
  Dim iSecond, iHH, iMM As Integer
  Dim sTime1, sTime2 As String
  Dim sValue As String
  Dim ssWeekdays, ssTime As String[]  
  Dim PicRefresh, PicOK, PicQuestion As Picture
  
  PicRefresh = PicTemplateReChange.Picture.Image.Stretch(22, 22).Picture 'ColumnViewImages("PicRefresh").Picture 
  PicOK = PicTemplateApply.Picture.Image.Stretch(22, 22).Picture  'ColumnViewImages("PicOK").Picture 
  PicQuestion = PicTemplateQuestionRound.Picture.Image.Stretch(22, 22).Picture 'ColumnViewImages("PicQuestion").Picture 
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  
  If ColumnView1.Count > 0 Then
    If ColumnView1.Selection.Max > -1 Then 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = ""
        For iColumn = 0 To F_iColumnsReadMax
          sLine = sLine & ColumnView1[sK1][iColumn]
        Next
        
        T0 = Trim(ColumnView1[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView1[sK1][1]) '00:00
        T2 = Trim(ColumnView1[sK1][2]) 'Mo
        T3 = Trim(ColumnView1[sK1][3]) 'Q
        T4 = Trim(ColumnView1[sK1][4]) 'KW
        T5 = Trim(ColumnView1[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView1[sK1][6]) '00:00
          T7 = Trim(ColumnView1[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView1[sK1][8]) 'Sek.
          T9 = Trim(ColumnView1[sK1][9]) '00:00:00
        Endif 
        'T10 = Trim(ColumnView1[sK1][10]) 'ColumnsUndo
        'T11 = Trim(ColumnView1[sK1][11]) 'Icon, Edit
        'T12 = Trim(ColumnView1[sK1][12]) 'Sortieren
        'T13 = Trim(ColumnView1[sK1][13]) 'Nr
        
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T0 <> "" Then
          If T1 Like "??:??" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue) 
          Else If T1 Like "*??:??*" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Else
            sValue = ""
            For iColumn = 0 To ColumnView1.Columns.Max
              If ColumnView1[sK1][iColumn] Like "*??:??*" Then
                sValue = Str(ColumnView1[sK1][iColumn])
                Break
              Endif
            Next
            If sValue = "" Then sValue = "00:00"
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            If T6 Like "??:??" Then
              '...Leerlauf
            Else If T6 Like "*??:??*" Then
              sValue = Str(T6)
              Try T6 = M01Functions.TimeCheckHHMM(sValue)
            Endif 
          Endif 
        Endif
        
        sValue = T0
        hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If hDate1 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDate1, "yyyy-mm-dd")
          T2 = Format(hDate1, "ddd")
          T3 = M01Functions.DateQuarterG(hDate1) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
        Else 'kein Datum oder Timer?  TTTTTTTTTTTTTTTTTTTTTTTT
          If M01Functions.isZahl(T0) = True Then 'unbekannte Zahl?
            sLine = ""
          Else
            For iDay = 0 To 6 ' 7-Tage
              If String.LCase(T0) Like "*" & String.LCase(ssWeekdays[iDay]) & "*" Then sTimerDays = sTimerDays & ssWeekdays[iDay] 'Teile von SoMoDiMiDoFrSa
            Next
            If sTimerDays <> "" Then
              T0 = sTimerDays
              If T1 = "" Then T1 = "00:00"
              T3 = "-Q"
              T4 = "-KW"
            Else
              sLine = ""
            Endif
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            sTime1 = T1
            sTime2 = T6
            If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
              hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
              ssTime = Split(sTime1 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              ssTime = Split(sTime2 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
              T8 = Str(iSecond)
              If iSecond < 0 Then iSecond = 0
              T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
              ' Endif 
            Endif 
            T7 = T2 'Mo > Mo
          Endif 
        Endif
        
        'Compare (mit korrigierter Zeile vergleichen)
        If sLine = "" Then
          ColumnView1[sK1].Picture = PicQuestion '?  Fragezeichen
          ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
          iUnknown = iUnknown + 1
        Else If Not Trim(sLine) = Trim(T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9) Then
          ColumnView1[sK1].Picture = PicRefresh 'verändert
          ColumnView1[sK1][F_iColumnSelect] = "PicRefresh"
          iCorrectedLines = iCorrectedLines + 1
        Else
          ColumnView1[sK1].Picture = PicOK 'OK
          ColumnView1[sK1][F_iColumnSelect] = "PicOK"
        Endif
        
        'Back (Korrigierte Zeilen zurückschreiben)
        ColumnView1[sK1][0] = T0
        ColumnView1[sK1][1] = T1
        ColumnView1[sK1][2] = T2
        ColumnView1[sK1][3] = T3
        ColumnView1[sK1][4] = T4
        ColumnView1[sK1][5] = T5
        If F_iMusterTermine1Names2Projects3 = 3 Then
          ColumnView1[sK1][6] = T6
          ColumnView1[sK1][7] = T7
          ColumnView1[sK1][8] = T8
          ColumnView1[sK1][9] = T9
        Endif 
      Next
      sValue = ""
      If iUnknown > 0 Then sValue = Space(1) & ("Unbekannte=") & iUnknown & "?"
      ColumnView1.Columns[5].Title = ("Formate korrigiert=") & iCorrectedLines & sValue
      If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
      If iCorrectedLines > 0 Then 
        ButtonSave.Background = Color.Red
      Endif
      Form13Export.Title = F_sTitleBasicText & Space(5) & Str((ColumnView1.Count) & sValue)
      LabelInfo.Text = ColumnView1.Columns[5].Title
      LabelInfo.Visible = True 
    Endif 'ColumnView1.Selection.Max 
  Endif 'ColumnView1.Count
  
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines2()
  
  Dim iLine, iDay, iColumn, iCorrectedLines, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim sK1, sTimerDays, sLine As String
  Dim hDate0, hDate1, hDate2 As Date
  Dim iSecond, iHH, iMM As Integer
  Dim sTime1, sTime2 As String
  Dim sValue As String
  Dim ssWeekdays, ssTime As String[]  
  Dim PicRefresh, PicOK, PicQuestion As Picture
  
  PicRefresh = PicTemplateReChange.Picture.Image.Stretch(22, 22).Picture 'ColumnViewImages("PicRefresh").Picture 
  PicOK = PicTemplateApply.Picture.Image.Stretch(22, 22).Picture  'ColumnViewImages("PicOK").Picture 
  PicQuestion = PicTemplateQuestionRound.Picture.Image.Stretch(22, 22).Picture 'ColumnViewImages("PicQuestion").Picture 
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView2.Columns.Count <> F_iColumnsCount Then ColumnView2Resize()
  
  If ColumnView2.Count > 0 Then
    If ColumnView2.Selection.Max > -1 Then 
      For Each sK1 In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = ""
        For iColumn = 0 To F_iColumnsReadMax
          sLine = sLine & ColumnView2[sK1][iColumn]
        Next
        
        T0 = Trim(ColumnView2[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView2[sK1][1]) '00:00
        T2 = Trim(ColumnView2[sK1][2]) 'Mo
        T3 = Trim(ColumnView2[sK1][3]) 'Q
        T4 = Trim(ColumnView2[sK1][4]) 'KW
        T5 = Trim(ColumnView2[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView2[sK1][6]) '00:00
          T7 = Trim(ColumnView2[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView2[sK1][8]) 'Sek.
          T9 = Trim(ColumnView2[sK1][9]) '00:00:00
        Endif 
        'T10 = Trim(ColumnView2[sK1][10]) 'ColumnsUndo
        'T11 = Trim(ColumnView2[sK1][11]) 'Icon, Edit
        'T12 = Trim(ColumnView2[sK1][12]) 'Sortieren
        'T13 = Trim(ColumnView2[sK1][13]) 'Nr
        
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T0 <> "" Then
          If T1 Like "??:??" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue) 
          Else If T1 Like "*??:??*" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Else
            sValue = ""
            For iColumn = 0 To ColumnView2.Columns.Max
              If ColumnView2[sK1][iColumn] Like "*??:??*" Then
                sValue = Str(ColumnView2[sK1][iColumn])
                Break
              Endif
            Next
            If sValue = "" Then sValue = "00:00"
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            If T6 Like "??:??" Then
              '...Leerlauf
            Else If T6 Like "*??:??*" Then
              sValue = Str(T6)
              Try T6 = M01Functions.TimeCheckHHMM(sValue)
            Endif 
          Endif 
        Endif
        
        sValue = T0
        hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If hDate1 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDate1, "yyyy-mm-dd")
          T2 = Format(hDate1, "ddd")
          T3 = M01Functions.DateQuarterG(hDate1) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
        Else 'kein Datum oder Timer?  TTTTTTTTTTTTTTTTTTTTTTTT
          If M01Functions.isZahl(T0) = True Then 'unbekannte Zahl?
            sLine = ""
          Else
            For iDay = 0 To 6 ' 7-Tage
              If String.LCase(T0) Like "*" & String.LCase(ssWeekdays[iDay]) & "*" Then sTimerDays = sTimerDays & ssWeekdays[iDay] 'Teile von SoMoDiMiDoFrSa
            Next
            If sTimerDays <> "" Then
              T0 = sTimerDays
              If T1 = "" Then T1 = "00:00"
              T3 = "-Q"
              T4 = "-KW"
            Else
              sLine = ""
            Endif
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            sTime1 = T1
            sTime2 = T6
            If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
              hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
              ssTime = Split(sTime1 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              ssTime = Split(sTime2 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
              T8 = Str(iSecond)
              If iSecond < 0 Then iSecond = 0
              T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
              ' Endif 
            Endif 
            T7 = T2 'Mo > Mo
          Endif 
        Endif
        
        'Compare (mit korrigierter Zeile vergleichen)
        If sLine = "" Then
          ColumnView2[sK1].Picture = PicQuestion '?  Fragezeichen
          ColumnView2[sK1][F_iColumnSelect] = "PicQuestion"
          iUnknown = iUnknown + 1
        Else If Not Trim(sLine) = Trim(T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9) Then
          ColumnView2[sK1].Picture = PicRefresh 'verändert
          ColumnView2[sK1][F_iColumnSelect] = "PicRefresh"
          iCorrectedLines = iCorrectedLines + 1
        Else
          ColumnView2[sK1].Picture = PicOK 'OK
          ColumnView2[sK1][F_iColumnSelect] = "PicOK"
        Endif
        
        'Back (Korrigierte Zeilen zurückschreiben)
        ColumnView2[sK1][0] = T0
        ColumnView2[sK1][1] = T1
        ColumnView2[sK1][2] = T2
        ColumnView2[sK1][3] = T3
        ColumnView2[sK1][4] = T4
        ColumnView2[sK1][5] = T5
        If F_iMusterTermine1Names2Projects3 = 3 Then
          ColumnView2[sK1][6] = T6
          ColumnView2[sK1][7] = T7
          ColumnView2[sK1][8] = T8
          ColumnView2[sK1][9] = T9
        Endif 
      Next
      sValue = ""
      If iUnknown > 0 Then sValue = Space(1) & ("Unbekannte=") & iUnknown & "?"
      ColumnView2.Columns[5].Title = ("Formate korrigiert=") & iCorrectedLines & sValue
      If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1].EnsureVisible
      If iCorrectedLines > 0 Then 
        ButtonSave.Background = Color.Red
      Endif
      Form13Export.Title = F_sTitleBasicText & Space(5) & Str((ColumnView2.Count) & sValue)
    Endif 'ColumnView2.Selection.Max 
  Endif 'ColumnView2.Count
  
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub RingStrokeFill()

  If TextAreaOpen.Visible = True Then 
    ButtonBorderCancel1.Picture = PicTemplateRingStroke.Picture
  Else 
    ButtonBorderCancel1.Picture = PicTemplateRingFill.Picture
  Endif 
  
  If Panel2.Visible = True Then 
    ButtonBorderCancel2.Picture = PicTemplateRingStroke.Picture
  Else 
    ButtonBorderCancel2.Picture = PicTemplateRingFill.Picture
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
  If TextAreaResult.Visible = True Then 
    ButtonBorderCancel3.Picture = PicTemplateRingStroke.Picture
  Else 
    ButtonBorderCancel3.Picture = PicTemplateRingFill.Picture
  Endif 
  
  Catch 
  FMain.ErrorText
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = True 
    Last.Background = F_iColorGreen150
  Endif 

  Select Case Last.Tag
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
    Case ButtonSaveMyKeys.Tag, ButtonLoadMyKeys.Tag, ButtonUTF8Apply.Tag
      LabelBG2.Background = F_iColorGreen150
    Case PicBoxMenu.Tag
      Last.Background = F_iColorGreen150
    Case "pathbg"
      Last.Background = Color.White
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = False 
    Last.Background = Color.Default
  Endif 
  
  Select Case Last.Tag
    Case "fileinfo"
      LabelInfo.Visible = False 
      
    Case ButtonSaveMyKeys.Tag, ButtonLoadMyKeys.Tag, ButtonUTF8Apply.Tag
      LabelBG2.Background = PanelUTF8.Background
    
    Case PicBoxMenu.Tag
      Last.Background = Color.Default
      
    Case "pathbg"
      Last.Background = Color.Transparent
  End Select
  
  If PanelUTF8.Visible = True And WebView1.Visible = True Then 
    ButtonUTF8.Border = True 
    ButtonUTF8.Background = Color.Green  
  Endif 
  If PanelUTF8.Visible = True And ScrollViewKeyboard.Visible = True Then 
    ButtonKeyboard.Border = True 
    ButtonKeyboard.Background = Color.Green  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp()

  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLasttag As String = "")
  
  Dim sText As String 
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form13Export.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  
  Select Case String.LCase(sLasttag)
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
       
    Case "open", "add"
      ReadG()
      If ColumnView1.Keys.Max > -1 Then ReplaceG()
      
    Case "info"
      sText = M06InfoText.CharsetABCInfo() 'as String 
      
    Case "fileinfo"
      FileInfoG()
      
    Case "labelinfo"
      LabelInfoG()
      
    Case "filterascii" 'ASCII(32-128) Filter....
      If PanelUTF8.Visible = False Then 
        ScrollViewKeyboard.Visible = False 
        TextAreaQuelltext.Visible = False 
        WebView1.Visible = True 
        WebView1.Raise()
        PanelUTF8.Visible = True 
        PanelUTF8.Raise()
      Endif 
      FilterASCII()
      
    Case "utf8" '"ascii" ASCII (32-128) = utf8 (32-128)
      If PanelUTF8.Visible = False Then 
        ScrollViewKeyboard.Visible = False 
        TextAreaQuelltext.Visible = False 
        WebView1.Visible = True 
        WebView1.Raise()
        PanelUTF8.Visible = True 
        PanelUTF8.Raise()
        UTF8All()
      Else
        PanelUTF8.Visible = False  
      Endif 
      
    Case "utf8search", LabelUTF8Search.Tag 
      TextBoxSearch.SelectAll()
      TextBoxSearch.Insert("ö")
      TextBoxSearch.SetFocus()
      
    Case "utf8code", LabelUTF8Code.Tag 
      TextBoxCode.SelectAll()
      TextBoxCode.Insert("246") '"ö"=246
      TextBoxCode.SetFocus()
      
    Case "utf8found", LabelUTF8Found.Tag 
      TextBoxFound.SelectAll()
      TextBoxFound.Insert("ö=oe;") '"ö"=246
      TextBoxFound.SetFocus()
      
    Case "utf8cancel", ButtonUTF8Cancel.Tag
      PanelUTF8.Visible = False 
      ButtonUTF8.Border = False 
      
    Case "utf8apply", ButtonUTF8Apply.Tag  '+
      If String.InStr(TextAreaReplace.Text, TextBoxFound.Text) = 0 Then 
        TextAreaReplace.Pos = String.Len(TextAreaReplace.Text)
        If String.Right(TextAreaReplace.Text, 1) <> ";" Then sText = ";" & TextBoxFound.Text Else sText = TextBoxFound.Text
        TextAreaReplace.Insert(sText)
      Else 
        TextAreaReplace.Select(String.InStr(TextAreaReplace.Text, TextBoxFound.Text) - 1, String.Len(TextBoxFound.Text))
      Endif 
      
    Case "savemykeys", ButtonSaveMyKeys.Tag 
      SaveLoadMyKeysAbc("save")
      
    Case "loadmykeys", ButtonLoadMyKeys.Tag 
      SaveLoadMyKeysAbc("load")
      
    Case "utf8keyboard", ButtonKeyboard.Tag
      If PanelUTF8.Visible = True Then 
        PanelUTF8.Visible = False 
        ScrollViewKeyboard.Visible = False 
      Else 
        TextAreaQuelltext.Visible = False 
        ScrollViewKeyboard.Visible = True 
        ScrollViewKeyboard.Raise()
        PaintKeyboard()
        PanelUTF8.Visible = True 
        TextAreaReplace.SetFocus 'show current Cursor-Position
      Endif 
      ButtonKeyboard.Border = False
      
    Case "searchdown"
      If ColumnView1.Visible = True Then 
        ColumnViewDownUp("+")
      Else 
        TextAreaOpenSearch("+")  
      Endif 
      
    Case "searchup"
      If ColumnView1.Visible = True Then 
        ColumnViewDownUp("-")
      Else 
        TextAreaOpenSearch("-")  
      Endif 
      
    Case "columnlinecancel"
      PanelColumnLine.Visible = False 
      Panel2.Visible = True 
      
    Case "bordercancel1"
      If TextAreaOpen.Visible = True Then 
        TextAreaOpen.Visible = False 
        ColumnView1.Visible = True 
        PanelUTF8.Visible = False 
      Else 
        ColumnView1.Visible = False
        TextAreaOpen.Visible = True 
        PanelUTF8.Visible = False 
      Endif 
      
    Case "bordercancel2"
      If Panel2.Visible = True Then 
        Panel2.Visible = False 
        PanelColumnLine.Visible = True 
        PanelUTF8.Visible = False 
      Else 
        PanelColumnLine.Visible = False
        Panel2.Visible = True 
        PanelUTF8.Visible = False 
      Endif 
      
    Case "bordercancel3"
      If TextAreaResult.Visible = True Then 
        TextAreaResult.Visible = False 
        ColumnView2.Visible = True 
        PanelUTF8.Visible = False 
      Else 
        ColumnView2.Visible = False
        TextAreaResult.Visible = True 
        PanelUTF8.Visible = False
      Endif 
      
    Case "replace", ButtonReplace.Tag
      ReplaceG()
      
    Case "menu"
      Menu2.Popup()
      
    Case "selectall"
      If ColumnView1.HasFocus = True Then 
        ColumnView1.SelectAll()
      Else If ColumnView2.HasFocus = True Then 
        ColumnView2.SelectAll()
      Else 
        If TextAreaOpen.HasFocus = True Then 
          TextAreaOpen.SelectAll()
        Endif
        If TextAreaReplace.HasFocus = True Then 
          TextAreaReplace.SelectAll()
        Endif
        If TextAreaResult.HasFocus = True Then 
          TextAreaResult.SelectAll()
        Endif
        
        If TextAreaColumnLine1.HasFocus = True Then 
          TextAreaColumnLine1.SelectAll()
        Endif
        If TextAreaColumnLine2.HasFocus = True Then 
          TextAreaColumnLine2.SelectAll()
        Endif
      Endif
      
    Case "unselectall"
      If ColumnView1.HasFocus = True Then 
        ColumnView1.UnSelectAll()
      Else If ColumnView2.HasFocus = True Then 
        ColumnView2.UnSelectAll()
      Else 
        If TextAreaOpen.HasFocus = True Then 
          TextAreaOpen.UnSelectAll()
        Endif
        If TextAreaReplace.HasFocus = True Then 
          TextAreaReplace.UnSelectAll()
        Endif
        If TextAreaResult.HasFocus = True Then 
          TextAreaResult.UnSelectAll()
        Endif
        
        If TextAreaColumnLine1.HasFocus = True Then 
          TextAreaColumnLine1.UnSelectAll()
        Endif
        If TextAreaColumnLine2.HasFocus = True Then 
          TextAreaColumnLine2.UnSelectAll()
        Endif
      Endif
    
    Case "copyselection"
      If ColumnView1.HasFocus = True Then 
        ColumnViewClipboardCopy()
      Else If ColumnView2.HasFocus = True Then 
        ColumnViewClipboardCopy()
      Else If TextAreaOpen.HasFocus = True Then 
        TextAreaOpen.Copy()
      Else If TextAreaReplace.HasFocus = True Then 
        TextAreaReplace.Copy()
      Else If TextAreaResult.HasFocus = True Then 
        TextAreaResult.Copy()
      Else If TextAreaColumnLine1.HasFocus = True Then 
        TextAreaColumnLine1.Copy()
      Else If TextAreaColumnLine2.HasFocus = True Then 
        TextAreaColumnLine2.Copy()
      Else 
        Message.Info("Keine Auswahl. In ein ausgewähltes Feld klicken.")
      Endif
      
    Case "copyall"
      If ColumnView1.HasFocus = True Then 
        ColumnView1.SelectAll()
        ColumnViewClipboardCopy()
      Else If ColumnView2.HasFocus = True Then 
        ColumnView2.SelectAll()
        ColumnViewClipboardCopy()
      Else If TextAreaOpen.HasFocus = True Then 
        TextAreaOpen.SelectAll()
        TextAreaOpen.Copy()
      Else If TextAreaReplace.HasFocus = True Then 
        TextAreaReplace.SelectAll()
        TextAreaReplace.Copy()
      Else If TextAreaResult.HasFocus = True Then 
        TextAreaResult.SelectAll()
        TextAreaResult.Copy()
      Else If TextAreaColumnLine1.HasFocus = True Then 
        TextAreaColumnLine1.SelectAll()
        TextAreaColumnLine1.Copy()
      Else If TextAreaColumnLine2.HasFocus = True Then 
        TextAreaColumnLine2.SelectAll()
        TextAreaColumnLine2.Copy()
      Else 
        Message.Info("Keine Auswahl. In ein ausgewähltes Feld klicken.")
      Endif
      
    Case "correct"
      If ColumnView1.HasFocus = True Then ColumnViewCorrectLines()
      If ColumnView2.HasFocus = True Then ColumnViewCorrectLines2()
      
    Case MenuCopyAllWeb.Tag
      If WebView1.HasFocus = True Then 
        If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
          Clipboard.Clear
          Clipboard.Copy(WebView1.Text) 'without html
        Endif 
      Endif 
      If TextAreaQuelltext.HasFocus = True Then 
        TextAreaQuelltext.SelectAll()
        TextAreaQuelltext.Copy()
      Endif    
    
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "save", ButtonSave.Tag
      ReplaceG()
      If ColumnView2.Visible = True Then ColumnView2.SelectAll()
      If TextAreaResult.Visible = True Then TextAreaResult.SelectAll()
      SaveG()
      
    Case MenuHTML.Tag 'Web
      If PanelUTF8.Visible = True Then 
        ScrollViewKeyboard.Visible = False  
        TextAreaQuelltext.Visible = False 
        WebView1.Visible = True 
        WebView1.Raise()
        UTF8All()
      Endif 
      
    Case MenuQuelltext.Tag
      If PanelUTF8.Visible = True Then 
        ScrollViewKeyboard.Visible = False  
        WebView1.Visible = False
        TextAreaQuelltext.Visible = True 
        TextAreaQuelltext.Raise()
        TextAreaQuelltext.SelectAll()
        TextAreaQuelltext.Insert(WebView1.HTML)
      Endif 
    Case MenuCopyAllWeb.Tag
      ColumnViewClipboardCopy()
      
    Case "close", "cancelform", ButtonCancel.Tag
      Form13Export.Window.Close
  End Select
  
  RingStrokeFill()
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False

Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  PanelBorder.Visible = True 
  
End '................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M05.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M05.module
192 KB
' Gambas module file

'Note: Simplify structure (Projekt ist gewachsen, Struktur vereinfachen)

Public Sub ColorClockGetSettings(Optional bFMain As Boolean = False)
  
  Dim iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorYellow, iColorTransBlack, iColorMenuGray, iColorNatur, iColorTransWater, n As Integer
  
  ''Check Color-Palette:
  If Form14UhrDesign.F_iiIconClockColorsB Then FMain.F_iiIconClockColorsB = Form14UhrDesign.F_iiIconClockColorsB.Copy()
  If Not Form14UhrDesign.F_iiIconClockColorsB Then
    Form14UhrDesign.F_iiIconClockColorsB = Settings[Form14UhrDesign.Name &/ "F_iiIconClockColorsB", Null]
    If Not Form14UhrDesign.F_iiIconClockColorsB Then Form14UhrDesign.F_iiIconClockColorsB = M05.ColorPaletteStandardii()'as Integer[]
  Endif 
  
  If Form14UhrDesign.F_iiIconClockColorsB Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    n = Form14UhrDesign.F_iColorsCount
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    If 9 < n Then iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    If 10 < n Then iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    
    Form14UhrDesign.F_iColor = iColorGreen    '0
    Form14UhrDesign.F_iColorBlue = iColorBlue '1
    Form14UhrDesign.F_iColorRed = iColorRed   '2
    Form14UhrDesign.F_iColorGray = iColorGray '3
    Form14UhrDesign.F_iColorDarkGray = iColorDarkGray '4
    Form14UhrDesign.F_iColorWhite = iColorWhite       '5
    Form14UhrDesign.F_iColorYellow = iColorYellow     '6
    Form14UhrDesign.F_iColorTransBlack = iColorTransBlack '7
    Form14UhrDesign.F_iColorNature = iColorNatur          '8
    Form14UhrDesign.F_iColorWaterTrans = iColorTransWater '9
    Form14UhrDesign.F_iColorCut = Color.Background        '10
  Endif 
  
  ''FMain —▶ △Declarations△
  If bFMain = True Then 'if "Save..."
    FMain.F_iColor = iColorGreen '0
    FMain.F_iColorBlue = iColorBlue
    FMain.F_iColorRed = iColorRed
    FMain.F_iColorGray = iColorGray
    FMain.F_iColorDarkGray = iColorDarkGray
    FMain.F_iColorWhite = iColorWhite
    FMain.F_iColorYellow = iColorYellow
    FMain.F_iColorNature = iColorNatur
    FMain.F_iColorTransBlack = iColorTransBlack
    FMain.F_iColorWaterTrans = iColorTransWater
    FMain.F_iColorCut = Color.Background '10
  Endif 
  
  ' If Not Form14UhrDesign.F_iColor And Not Form14UhrDesign.F_iColorWaterTrans Then 
  '   Form14UhrDesign.F_iColor = iColorGreen
  '   Form14UhrDesign.F_iColorBlue = iColorBlue
  '   Form14UhrDesign.F_iColorRed = iColorRed
  '   Form14UhrDesign.F_iColorGray = iColorGray
  '   Form14UhrDesign.F_iColorDarkGray = iColorDarkGray
  '   Form14UhrDesign.F_iColorWhite = iColorWhite
  '   Form14UhrDesign.F_iColorYellow = iColorYellow
  '   Form14UhrDesign.F_iColorTransBlack = iColorTransBlack
  '   Form14UhrDesign.F_iColorNature = iColorNatur
  '   Form14UhrDesign.F_iColorWaterTrans = iColorTransWater
  '   Form14UhrDesign.F_iColorCut = iColorMenuGray
  ' Endif 
  
  ''EndType:
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  ' iLineEndType = Paint.LineCapRound 'as Integer=1
  ' F_iColor = Color.Green
  ' F_iColorBlue = Color.Lighter(Color.Blue) '&H6472B0F4& 'Spezial-Blue 
  ' F_iColorCut = Color.Background 'or Color.DarkYellow ?
  ' F_iColorDarkGray = Color.DarkGray
  ' F_iColorGray = Color.Lighter(Color.Gray)
  ' F_iColorGreen = Color.Lighter(Color.Green)
  ' F_iColorMagenta = Color.Magenta
  ' F_iColorNature = Color.RGB(255, 200, 0) 'or yellow foot = &H00FFC800& (Post-Package)
  ' F_iColorOrange = Color.Orange
  ' F_iColorPackage = Color.Lighter(&HFFC800&) 'Post-Package
  ' F_iColorPink = Color.Pink
  ' F_iColorRed = Color.Lighter(Color.Red) 'primary colors > RGB (Red, Green, Blue)
  ' F_iColorViolet = Color.Violet
  ' F_iColorWaterTrans = Color.SetAlpha(Color.DarkGray, 150)
  ' F_iColorYellow = Color.Yellow
  ' F_iColorWhite = Color.White
  ' F_iColorGrayMiddle = Color.Gray
  ' F_iColorDarkBlue = Color.DarkBlue
  ' F_iColorBlack = Color.Black
  '***************************
Catch 
  FMain.ErrorText
  
End

Public Function ColorPaletteStandardii() As Integer[]
  
  Dim iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorTransBlack, iColorYellow, iColorMenuGray, iColorNatur, iColorTransWater As Integer
  Dim iiColors As Integer[]
  
  iColorGreen = Color.Green 'FMain.F_iColor
  iColorBlue = Color.Lighter(Color.Blue) 'FMain.F_iColorBlue
  iColorRed = Color.Lighter(Color.Red) 'FMain.F_iColorRed
  iColorGray = Color.Lighter(Color.Gray) 'FMain.F_iColorGray
  iColorDarkGray = Color.DarkGray 'FMain.F_iColorDarkGray
  iColorWhite = Color.White 'FMain.F_iColorWhite
  iColorYellow = Color.Yellow
  iColorNatur = Color.RGB(255, 200, 0) 'or yellow foot = &H00FFC800& (Post-Package)
  iColorTransWater = Color.SetAlpha(Color.DarkGray, 150)
  iColorTransBlack = Color.Black 'FMain.F_iColorTransBlack
  iColorMenuGray = Color.Background 'FMain.F_iColorCut
  
  ' iiColors = New Integer[]
  ' iiColors.Add(iColorGreen) '0
  ' iiColors.Add(iColorBlue) '1
  ' iiColors.Add(iColorRed) '2
  ' iiColors.Add(iColorGray) '3
  ' iiColors.Add(iColorDarkGray) '4
  ' iiColors.Add(iColorWhite) '5
  ' iiColors.Add(iColorYellow) '6
  ' iiColors.Add(iColorNatur) '7
  ' iiColors.Add(iColorTransWater) '8
  ' iiColors.Add(iColorTransBlack) '9
  ' iiColors.Add(iColorMenuGray) '10
  
  iiColors = [iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorYellow, iColorNatur, iColorTransWater, iColorTransBlack, iColorMenuGray]
  If iiColors.Count <> Form14UhrDesign.F_iColorsCount Then iiColors.Resize(Form14UhrDesign.F_iColorsCount)

  Settings[FMain.Name &/ "F_iiIconClockColorsA"] = iiColors.Copy()
  ' Settings[FMain.Name &/ "F_iiIconClockColorsB"] = iiColors.Copy()
  ' If Not FMain.F_iiIconClockColorsB = iiColors.Copy() 
  
  FMain.F_bWhiteBorderON = Settings[FMain.Name &/ "F_bWhiteBorderON", True]
  
  Return iiColors
  
Catch 
  FMain.ErrorText
  
End

Public Function CreateIconClock() As Picture
  
  Dim Img, Img2, Img3, imgTemp As Image
  Dim iIconSize, iLineEndType, iHours, iStep, iColorGreen, iColorBlue, iColorRed, iColorGray, iColorDarkGray, iColorWhite, iColorYellow, iColorTransBlack, iColorMenuGray, iColorNatur, iColorTransWater, iColorCut, iColorChange1, iColorChange2, it2, it3, it5, iNumber As Integer
  Dim U, R, itF, L, W, H As Float 
  Dim fRadius4_75, fRadius4_5, fRadius4_25, fRadius4_0, fRadius3_75, fRadius3_5 As Float
  Dim Text, T, sName As String = ""
  Dim bChange As Boolean
  Dim dateTime As Date
  Dim a, b, c, Radius, alpha, fSizeMin As Float
  Dim MX1, MY1, MX2, MY2 As Float
  Dim bIconThemeAllAddON As Boolean = False
  Dim bAntiAliasON, bWhiteBorderON As Boolean
  Dim n As Integer
  
  ''activate or deactivate with Comment-line '
  '***********************
  If Form14UhrDesign.F_bESCpressedON = True Then Return
  
  bWhiteBorderON = FMain.F_bWhiteBorderON 
  bAntiAliasON = True 'FMain.F_bAntiAliasON
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  
  ''Icon-Size: 
  If FMain.F_iIconSize Then 
    iIconSize = FMain.F_iIconSize 
  Else 'Default
    iIconSize = Settings[FMain.Name &/ "F_iIconSize", 128] 'Pixel
  Endif 
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  imgTemp = New Image(iIconSize, iIconSize, Color.Transparent)
  
  Text = "C" 'Clock
  U = Img.W / 10                                                                          '1 Unit
  R = U * 0.5 'FMain.F_fRadiusRect
  fRadius4_75 = 4.75 'Consistent dimension (einheitlich konsistentes Maß für Aufbauten)
  fRadius4_5 = 4.5
  fRadius4_25 = 4.25
  fRadius4_0 = 4.0
  fRadius3_75 = 3.75
  fRadius3_5 = 3.5
  
  ''Check Color-Palette:
  M05.ColorClockGetSettings()
  n = Form14UhrDesign.F_iColorsCount
  
  If FMain.F_iiIconClockColorsB Then 
    If FMain.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then FMain.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
  
    ''Colors User:
    iColorGreen = FMain.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = FMain.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = FMain.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = FMain.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = FMain.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = FMain.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = FMain.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    iColorNatur = FMain.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = FMain.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    If 9 < n Then iColorTransBlack = FMain.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    If 10 < n Then iColorMenuGray = FMain.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    iColorCut = Color.Background
  Endif 
  If Form14UhrDesign.Visible = True Then 
    If Form14UhrDesign.F_iiIconClockColorsB.Count <> Form14UhrDesign.F_iColorsCount Then Form14UhrDesign.F_iiIconClockColorsB.Resize(Form14UhrDesign.F_iColorsCount)
    ''Colors User:
    iColorGreen = Form14UhrDesign.F_iiIconClockColorsB[0] 'FMain.F_iColor 'Green
    iColorBlue = Form14UhrDesign.F_iiIconClockColorsB[1] 'FMain.F_iColorBlue
    iColorRed = Form14UhrDesign.F_iiIconClockColorsB[2] 'FMain.F_iColorRed
    iColorGray = Form14UhrDesign.F_iiIconClockColorsB[3] 'FMain.F_iColorGray
    iColorDarkGray = Form14UhrDesign.F_iiIconClockColorsB[4] 'FMain.F_iColorDarkGray
    iColorWhite = Form14UhrDesign.F_iiIconClockColorsB[5] 'FMain.F_iColorWhite
    iColorYellow = Form14UhrDesign.F_iiIconClockColorsB[6] 'FMain.F_iColorYellow
    iColorNatur = Form14UhrDesign.F_iiIconClockColorsB[7] 'FMain.F_iColorNature or yellow foot = &H00FFC800& (Post-Package)
    iColorTransWater = Form14UhrDesign.F_iiIconClockColorsB[8] 'FMain.F_iColorTransBlack
    If 9 < n Then iColorTransBlack = Form14UhrDesign.F_iiIconClockColorsB[9] 'FMain.F_iColorWaterTrans
    If 10 < n Then iColorMenuGray = Form14UhrDesign.F_iiIconClockColorsB[10] 'FMain.F_iColorCut
    iColorCut = Color.Background
  Endif
  
  ''FMain —▶ △Declarations△
  ' If Not FMain.F_iColor And Not FMain.F_iColorWaterTrans Then 
  '   FMain.F_iColor = iColorGreen
  '   FMain.F_iColorBlue = iColorBlue
  '   FMain.F_iColorRed = iColorRed
  '   FMain.F_iColorGray = iColorGray
  '   FMain.F_iColorDarkGray = iColorDarkGray
  '   FMain.F_iColorWhite = iColorWhite
  '   FMain.F_iColorYellow = iColorYellow
  '   FMain.F_iColorNature = iColorNatur
  '   FMain.F_iColorTransBlack = iColorTransBlack
  '   FMain.F_iColorWaterTrans = iColorTransWater
  '   FMain.F_iColorCut = iColorMenuGray
  ' Endif 
  ' If Not Form14UhrDesign.F_iColor And Not Form14UhrDesign.F_iColorWaterTrans Then 
  '   Form14UhrDesign.F_iColor = iColorGreen
  '   Form14UhrDesign.F_iColorBlue = iColorBlue
  '   Form14UhrDesign.F_iColorRed = iColorRed
  '   Form14UhrDesign.F_iColorGray = iColorGray
  '   Form14UhrDesign.F_iColorDarkGray = iColorDarkGray
  '   Form14UhrDesign.F_iColorWhite = iColorWhite
  '   Form14UhrDesign.F_iColorYellow = iColorYellow
  '   Form14UhrDesign.F_iColorTransBlack = iColorTransBlack
  '   Form14UhrDesign.F_iColorNature = iColorNatur
  '   Form14UhrDesign.F_iColorWaterTrans = iColorTransWater
  '   Form14UhrDesign.F_iColorCut = iColorMenuGray
  ' Endif 
  
  ''EndType:
  'iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1
  ' F_iColor = Color.Green
  ' F_iColorBlue = Color.Lighter(Color.Blue) '&H6472B0F4& 'Spezial-Blue 
  ' F_iColorCut = Color.Background 'or Color.DarkYellow ?
  ' F_iColorDarkGray = Color.DarkGray
  ' F_iColorGray = Color.Lighter(Color.Gray)
  ' F_iColorGreen = Color.Lighter(Color.Green)
  ' F_iColorMagenta = Color.Magenta
  ' F_iColorNature = Color.RGB(255, 200, 0) 'or yellow foot = &H00FFC800& (Post-Package)
  ' F_iColorOrange = Color.Orange
  ' F_iColorPackage = Color.Lighter(&HFFC800&) 'Post-Package
  ' F_iColorPink = Color.Pink
  ' F_iColorRed = Color.Lighter(Color.Red) 'primary colors > RGB (Red, Green, Blue)
  ' F_iColorViolet = Color.Violet
  ' F_iColorWaterTrans = Color.SetAlpha(Color.DarkGray, 150)
  ' F_iColorYellow = Color.Yellow
  ' F_iColorWhite = Color.White
  ' F_iColorGrayMiddle = Color.Gray
  ' F_iColorDarkBlue = Color.DarkBlue
  ' F_iColorBlack = Color.Black
  '***************************
  ''h-m-s
  For it3 = 0 To 76
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Select Case it3
      Case 0
        T = "-timehh-hour"
      Case 1
        T = "-timehh-hour-small-gray"
      Case 2
        T = "-timehh-hour-triangle" '▶
      Case 3
        T = "-timehh-hour-drawarrow" '—○▸
      Case 4
        T = "-timehh-hour-verysmall" '——
      Case 5
        T = "-timehh-hour-circle" '—○▸
      Case 6
        T = "-timehh-hour-doublecircle" '—○▸
      Case 7
        T = "-timehh-hour-doublecircle-big" '—○▸
      Case 8
        T = "-timehh-hour-longarrow-fill" '—○▸
      Case 9
        T = "-timehh-hour-longarrow-stroke" '—○▸
      Case 10
        T = "-timehh-hour-graylongarrow" '—○▸
      Case 11
        T = "-timehh-hour-greenlongarrow" '—○▸
      Case 12
        T = "-timehh-hour-redlongarrow" '—○▸
      Case 13
        T = "-timehh-hour-biglittlecircle" '—○▸
      Case 14
        T = "-timehh-hour-square"  '■■■  
      Case 15
        T = "-timehh-hour-sun"
      Case 16
        T = "-timehh-hour-arrow-big" '▪▪▪▶
      Case 17
        T = "-timehh-hour-arrow-stroke" '▪▪▪▶
      Case 18
        T = "-timehh-hour-arrow-fill" '▪▪▪▶
      Case 19
        T = "-timehh-hour-greattriangle-stroke" '▷
      Case 20
        T = "-timemm-minute-square"  '◼◼◼◼◼
      Case 21
        T = "-timemm-minute-circlesminutes"
      Case 22
        T = "-timemm-minute-small"
      Case 23
        T = "-timemm-minute-verysmall" '———
      Case 24
        T = "-timemm-minute-green"
      Case 25
        T = "-timemm-minute-quaterplus-verysmall-green" '————
      Case 26
        T = "-timemm-minute-middle-green" '———— 1/4 ○
      Case 27
        T = "-timess-second-short" ' —
      Case 28
        T = "-timess-second-short-whiteborder" ' —
      Case 29
        T = "-timess-second-long" '———
      Case 30
        T = "-timess-second-long-whiteborder" '———
      Case 31
        T = "-timess-second-circle-stroke"  '●——
      Case 32
        T = "-timess-second-circle-stroke-whiteborder"  '●——
      Case 33
        T = "-timess-second-point-small"  '●
      Case 34
        T = "-timess-second-point-big" '●
      Case 35
        T = "-timess-second-point-near" '•
      Case 36
        T = "-timess-second-square"  '▪▪▪▪▪▪▪
      Case 37
        T = "-timess-second-outsidering"
      Case 38
        T = "-timess-second-technicalwheel"
      Case 39
        T = "-timess-second-verysmall" '————
      Case 40
        T = "-timess-second-verysmall-ring" '—○———
      Case 41
        T = "-timehh-hour-orbit"  '——○——  
      Case 42
        T = "-timemm-minute-orbit"  '——○——  
      Case 43
        T = "-timess-second-orbit"  '——○——  
      Case 44
        T = "-timecenterpoint-small"  '○—— 
      Case 45
        T = "-timecenterpoint-big"  '●
      Case 46
        T = "-timecenterpoint-stroke"  '●—— 
      Case 47
        T = "-timecenterpoint-fill-white"  '●—— 
      Case 48
        T = "-timecenterpoint-fill-white-little"  '●—— 
      Case 49
        T = "-timecenterpoint-fill-red"   '●—— 
      Case 50
        T = "-timecenterpoint-middle"  '●—— 
      Case 51
        T = "-timecenterpoint-more"  '●——   
      Case 52
        T = "-timecenterpoint-more-white"  '●——   
      Case 53
        T = "-timecenterpoint-more-blue"  '●——   
      Case 54
        T = "-timedatepoint-point"  '●
      Case 55
        T = "-timedatepoint-line"  '●
      Case 56
        T = "-timedatepoint-triangledown"  '▼●
      Case 57
        T = "-timedatepoint-triangleup"  '▲●
      Case 58
        T = "-timephythagoras" 
      Case 59
        T = "-timedigital-fontname-freesans"
      Case 60
        T = "-timedigital-red-fontname-sawasdee" 'simple modern
      Case 61
        T = "-timedigital-fontname-ubuntu-condensed-bottom" '"Ubuntu Condensed"    font —▶smaller◀—
      Case 62
        T = "-timedigital-darkgray-fontname-ubuntu-thin-middle" '"Ubuntu Thin"    small stroke———
      Case 63
        T = "-timelcd-big-skyblue-middle"
      Case 64
        T = "-timelcd-big"
      Case 65
        T = "-timelcd-big-white-sizemax"
      Case 66
        T = "-timelcd-square-blue-little" '■■■
      Case 67
        T = "-timelcd-square-big-blue-onlylight" '■■■
      Case 68
        T = "-timesunupdown-stroke-sunpoint-linebig"  '——— ○
      Case 69
        T = "-timesunupdown-stroke-doublering-up-down"  '——— ○
      Case 70
        T = "-timesunupdown-fill-sunpoint"  '■○
      Case 71
        T = "-timesunupdown-sunpoint"  '○
      Case 72
        T = "-timesunupdown-stroke-big"  
      Case 73
        ' T = "-timesunupdown-fill-little"  
        T = "-timesunupdown-horizontal"  
      Case 74
        T = "-timesunupdown-nightday" '●○
      Case 75
        T = "-timegearwheel"
      Case 76
        T = "-timegearwheel-sun"
        
    End Select
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                 'Paint.LineJoinRound 'as Integer
    
    If String.InStr(T, "-timegearwheel") > 0 Then 
      If String.InStr(T, "-sun") > 0 Then 
        Img = M07Paint.ClockGearWheel(Now, T) 'as Image
      Else 
        Img = M07Paint.ClockGearWheel(Now, T) 'as Image
      Endif 
    Endif 
    
    If String.InStr(T, "-timedatepoint") > 0 Then 
      If String.InStr(T, "-point") > 0 Then 
        'date point ●
        Paint.Arc(U * 5, U * 1, U * 0.25)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-line") > 0 Then 
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1) 
        Paint.Arc(U * 5, U * 1, U * 0.25)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-triangledown") > 0 Then 'Triangle ▼
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 5.5, U * 1.5) 
        Paint.LineTo(U * 4.5, U * 1.5)
        Paint.LineTo(U * 5, U * 1)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else 'If String.InStr(T, "-triangleup") > 0 Then 'Triangle ▲
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 5.5, U * 0.5) 
        Paint.LineTo(U * 4.5, U * 0.5)
        Paint.LineTo(U * 5, U * 1)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
      Endif
    Endif 'timedatepoint
    
    If String.InStr(T, "-timesunupdown") > 0 Then 
      datetime = Form14UhrDesign.F_dateNow
      If Not datetime Then datetime = Now
      Try Img = M07Paint.ClockSunUpDown(datetime, T) '.Copy() 'as Image
    Endif 
    
    If String.InStr(T, "-timehh") > 0 Then 
      If String.InStr(T, "-orbit") > 0 Then 
        L = U * 2
        'hour point —○— hh
        Paint.Arc(U * 5, U * 5, L) 'Pie —line ———
        
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGray, 200))
        Paint.Stroke()
        
        Paint.Arc(U * 5, U * 5 - L, U * 0.5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorYellow)
        Paint.Stroke(True)
        Paint.Fill()
        
        Paint.Arc(U * 5, U * 5, L, Rad(-120), Rad(60), False)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.25
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        ' Paint.Fill()
      Else If String.InStr(T, "-sun") > 0 Then 
        ''line, clock-hand ——
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 3.5)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Fill()
        
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 2 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorYellow)
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 30
        For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.1 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.15 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2)
        Next 'it
        Paint.Arc(a, b, U * 0.5) 'center
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-triangle") > 0 Then         '▲   
        Paint.MoveTo(U * 5, U * 2.5)
        Paint.LineTo(U * 5.5, U * 3)
        Paint.LineTo(U * 4.5, U * 3)
        Paint.LineTo(U * 5, U * 2.5)
        
      Else If String.InStr(T, "-greattriangle") > 0 Then         '▪▶
        Paint.Rectangle(U * 4.5, U * 4.25, U * 1, U * 1.5, R / 2)
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 6, U * 3.25)
        Paint.LineTo(U * 4, U * 3.25)
        Paint.LineTo(U * 5, U * 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
        
      Else If String.InStr(T, "-arrow-big") > 0 Then         '▲
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 4)
        Paint.MoveTo(U * 5, U * 2.75)
        Paint.LineTo(U * 5.5, U * 3.5)
        Paint.LineTo(U * 4.5, U * 3.5)
        Paint.LineTo(U * 5, U * 2.75)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.White)
        Paint.Operator = Paint.OperatorClear
        Paint.Fill()
        
        Paint.MoveTo(U * 5, U * 2.75)
        Paint.LineTo(U * 5.5, U * 3.5)
        Paint.LineTo(U * 4.5, U * 3.5)
        Paint.LineTo(U * 5, U * 2.75)
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Operator = Paint.OperatorClear
        Paint.Stroke(True)
        Paint.Operator = Paint.OperatorClear
        Paint.Fill()
        
      Else If String.InStr(T, "-arrow-fill") > 0 Then
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 3.5)
        Paint.MoveTo(U * 5, U * 2.75)
        Paint.LineTo(U * 5.5, U * 3.5)
        Paint.LineTo(U * 4.5, U * 3.5)
        Paint.LineTo(U * 5, U * 2.75)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-arrow-stroke") > 0 Then
        Paint.Rectangle(U * 4.5, U * 3, U * 1, U * 2.5, R)
        Paint.MoveTo(U * 5, U * 2.5)
        Paint.LineTo(U * 6, U * 3.5)
        Paint.LineTo(U * 4, U * 3.5)
        Paint.LineTo(U * 5, U * 2.5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
        
      Else If String.InStr(T, "-circle") > 0 Then      '—○▸
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 1.5)
        Paint.LineTo(U * 5.5, U * 2)
        Paint.LineTo(U * 4.5, U * 2)
        Paint.LineTo(U * 5, U * 1.5)
        
        Paint.Arc(U * 5, U * 3.25, U * 0.85) '○
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 4.25)
        
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 5, U * 2.25)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 1.5)
        Paint.LineTo(U * 5.5, U * 2)
        Paint.LineTo(U * 4.5, U * 2)
        Paint.LineTo(U * 5, U * 1.5)
        
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Fill()
        
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 5, U * 2.25)
        
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        
      Else If String.InStr(T, "-doublecircle") > 0 Then      '○—○–
        Paint.Arc(U * 5, U * 5, U * 0.25) '○
        ' Paint.Arc(U * 5, U * 5, U * 0.75) '○
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 3.75)
        Paint.Arc(U * 5, U * 3, U * 0.75) '○
        Paint.MoveTo(U * 5, U * 1.5)
        Paint.LineTo(U * 5, U * 2.25)
        
        If String.InStr(T, "-big") > 0 Then
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(iColorBlue)
          Paint.Stroke()
        Else 'small
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 0.75
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.35
          Paint.Brush = Paint.Color(iColorBlue)
          Paint.Stroke()
        Endif 
        
      Else If String.InStr(T, "-biglittlecircle") > 0 Then      '—○·
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 4.25)
        Paint.Arc(U * 5, U * 3.25, U * 0.85) '○
        Paint.Arc(U * 5, U * 2, U * 0.35) '○
        Paint.MoveTo(U * 5, U * 1.25)
        Paint.LineTo(U * 5, U * 1.5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        
      Else If String.InStr(T, "-longarrow") > 0 Then      '—▶ —▷
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 6, U * 3.5)
        Paint.LineTo(U * 4, U * 3.5)
        Paint.LineTo(U * 5, U * 1)
        
        If String.InStr(T, "-stroke") > 0 Then
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 0.75
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.25
          Paint.Brush = Paint.Color(iColorRed)
          Paint.Stroke()
        Else '"-fill"
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(iColorRed)
          Paint.Stroke(True)
          Paint.Fill()
        Endif 
        
      Else If String.InStr(T, "-graylongarrow") > 0 Then      '—▶
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 6, U * 4)
        Paint.LineTo(U * 4, U * 4)
        Paint.LineTo(U * 5, U * 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorDarkGray)
        Paint.Stroke()
        ' Paint.Fill()
        
      Else If String.InStr(T, "-bluelongarrow") > 0 Then      '—▶
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 6, U * 4)
        Paint.LineTo(U * 4, U * 4)
        Paint.LineTo(U * 5, U * 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
        
      Else If String.InStr(T, "-redlongarrow") > 0 Then      '—▶
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 6, U * 3.5)
        Paint.LineTo(U * 4, U * 3.5)
        Paint.LineTo(U * 5, U * 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-greenlongarrow") > 0 Then      '—▶
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 6, U * 3.5)
        Paint.LineTo(U * 5, U * 5)
        Paint.LineTo(U * 4, U * 3.5)
        Paint.LineTo(U * 5, U * 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-drawarrow") > 0 Then      '—○▸
        Paint.Arc(U * 5, U * 1.75, U * 1.75, Rad(-250), Rad(-40), True)
        Paint.Arc(U * 5, U * 5, U * 0.5) '○
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 5, U * 4.5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Fill()  
        
      Else If String.InStr(T, "-small") > 0 Then '——
        Paint.Arc(U * 5, U * 3.25, U * 0.5) '○
        Paint.MoveTo(U * 5, U * 5) '◼◼◼
        Paint.LineTo(U * 5, U * 2.25)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Fill()
        
        Paint.Arc(U * 5, U * 3.25, U * 0.5) '○
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Fill()
        
      Else If String.InStr(T, "-verysmall") > 0 Then '——
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 3)
        Paint.LineWidth = U * 0.05
        Paint.Brush = Paint.Color(iColorTransBlack)
        Paint.Stroke()
        
      Else If String.InStr(T, "-square") > 0 Then 
        ' Paint.LineCap = Paint.LineCapButt '▪—▪
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 2.5)  
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorDarkGray)
        Paint.Stroke()
        Paint.LineCap = iLineEndType 'Reset
        
      Else                                      ''Hour, Line, Pointer --
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 3)
      Endif 
      
      If String.InStr(T, "-stroke") > 0 Then '——
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
      Else 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 2
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1.4
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Fill()
      Endif 
    Endif 'hour timehh
    
    If String.InStr(T, "-timemm") > 0 Then 
      If String.InStr(T, "-orbit") > 0 Then 
        L = U * 3.25
        'minute point —○— mm
        Paint.Arc(U * 5, U * 5, L)
        
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGray, 200))
        Paint.Stroke()
        
        Paint.Arc(U * 5, U * 5 - L, U * 0.5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
        Paint.Arc(U * 5, U * 5, L, Rad(-110), Rad(40), False)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.25
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        ' Paint.Fill()
        
      Else If String.InStr(T, "-square") > 0 Then 
        ' Paint.LineCap = Paint.LineCapButt '▪—▪
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1.75)  
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorDarkGray)
        Paint.Stroke()
        Paint.LineCap = iLineEndType 'Reset
        
      Else If String.InStr(T, "-quaterplus-verysmall") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3.5, Rad(-90), Rad(90), True)
        
        Paint.LineWidth = U * 0.01
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGreen, 230))
        Paint.Fill()
        ''Minute, Line, Pointer ----
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1.75)
        Paint.LineWidth = U * 0.5
        
      Else If String.InStr(T, "-circlesminutes") > 0 Then
        'Triangle ▶
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 5.25, U * 1.5)
        Paint.LineTo(U * 4.75, U * 1.5)
        Paint.LineTo(U * 5, U * 1)
        iStep = 1
        For itF = 2.25 To 5.25 Step iStep
          Paint.Arc(U * 5, U * itF, U * 0.25)
        Next 'it
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1.5)
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else 
        ''Minute, Line, Pointer ----
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1.5)
        
        If String.InStr(T, "-middle") > 0 Then 
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 0.75
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.35
        Else If String.InStr(T, "-small") > 0 Then 
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.4
        Else If String.InStr(T, "-verysmall") > 0 Then '——
          Paint.LineWidth = U * 0.05
          Paint.Brush = Paint.Color(iColorDarkGray)
          Paint.Stroke() 
        Else 
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1.3
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.7  
        Endif 
      Endif
      
      If String.InStr(T, "-green") > 0 Then 
        Paint.Brush = Paint.Color(iColorGreen)
      Else 
        Paint.Brush = Paint.Color(iColorBlue)
      Endif
      Paint.Stroke(True)
      Paint.Fill()
    Endif 'Minute timemm
    
    If String.InStr(T, "-timess-second") > 0 Then '——
      If String.InStr(T, "-technicalwheel") > 0 Then 
        Paint.LineWidth = U * 0.25
        iStep = 30
        For itF = iStep To 360 Step iStep
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(U * 5, U * 5, U * 0.75, Rad(itF), Rad(iStep))
          Else
            Paint.Arc(U * 5, U * 5, (U * 0.75) + Paint.LineWidth, Rad(itF), Rad(iStep))
          End If
        Next 'it
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke 
        
        'Second –○——————
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Arc(U * 5, U * 5, U * 0.5) 'Zeiger Sekunde Loch o
        Paint.Stroke 'Strich zeichnen
        Paint.MoveTo(U * 5, U * 6.5)
        Paint.LineTo(U * 5, U * 1)
        Paint.Stroke 'Strich zeichnen
        
      Else If String.InStr(T, "-verysmall") > 0 Then '——
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1)
        If String.InStr(T, "-ring") > 0 Then Paint.Arc(U * 5, U * 5, U * 0.5)
        Paint.LineWidth = U * 0.05
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
        
      Else If String.InStr(T, "-square") > 0 Then 
        ' Paint.LineCap = Paint.LineCapButt '▪—▪
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 1)  
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.25
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorDarkGray)
        Paint.Stroke()
        Paint.LineCap = iLineEndType 'Reset
        
      Else If String.InStr(T, "-orbit") > 0 Then 
        L = U * 4.5
        'second point —○—  ss
        Paint.Arc(U * 5, U * 5, L)
        
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(Color.SetAlpha(iColorGray, 200))
        Paint.Stroke()
        
        Paint.Arc(U * 5, U * 5 - L, U * 0.15)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-outsidering") > 0 Then 
        iStep = 30
        For itF = iStep / 2 To 360 Step iStep
          bChange = Not bChange
          If bChange = True Then 
            Paint.Arc(U * 5, U * 5, U * fRadius4_5, Rad(itF), Rad(iStep), False)
          Else 
            Paint.Arc(U * 5, U * 5, U * fRadius4_75, Rad(itF), Rad(iStep), False)
          Endif 
        Next
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
        ' Paint.Fill() 
        '–○———
        L = U * 0.8
        Paint.Brush = Paint.Color(iColorRed)
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 5, U * 5 - L)
        Paint.MoveTo(U * 5, U * 5 + L)
        Paint.LineTo(U * 5, U * 5 + L + (U * 0.5))
        Paint.LineWidth = U * 0.15
        Paint.Stroke()
        Paint.Arc(U * 5, U * 5, L)
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
        Paint.Arc(U * 5, U * 5, L * 0.5)
        Paint.Fill() 
        
      Else If String.InStr(T, "-point") > 0 Then '●•
        ''Center, Circle
        If String.InStr(T, "-big") > 0 Then 
          Paint.Arc(U * 5, U * 1, U * 0.25)
        Else If String.InStr(T, "-near") > 0 Then 
          Paint.Arc(U * 5, U * 2, U * 0.25)
        Else 
          Paint.Arc(U * 5, U * 1.5, U * 0.15) 
        Endif 
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill() 
      Endif 
      
      If String.InStr(T, "-point") = 0 Then  
        If String.InStr(T, "-short") > 0 Then '–
          ''Second, Line, Pointer ------
          Paint.MoveTo(U * 5, U * 3)
          Paint.LineTo(U * 5, U * 1)
          Paint.LineWidth = U * 0.15
        Else If String.InStr(T, "-long") > 0 Then '————
          ''Second, Line, Pointer ------
          Paint.MoveTo(U * 5, U * 6.5)
          Paint.LineTo(U * 5, U * 1)
          Paint.LineWidth = U * 0.15
        Else If String.InStr(T, "-circle") > 0 Then '–○———
          If String.InStr(T, "-stroke") > 0 Then L = U * 0.5 Else L = U * 1
          Paint.MoveTo(U * 5, U * 1)
          Paint.LineTo(U * 5, U * 5 - L)
          Paint.MoveTo(U * 5, U * 5 + L)
          Paint.LineTo(U * 5, U * 5 + L + (U * 0.5))
          Paint.Arc(U * 5, U * 5, L)
          Paint.LineWidth = U * 0.35
        Else If String.InStr(T, "-ring") > 0 Then 
          ''...
        Else If String.InStr(T, "-big") > 0 Then '———— "-big"
          ''Second, Line, Pointer ------
          Paint.MoveTo(U * 5, U * 6)
          Paint.LineTo(U * 5, U * 1)
          Paint.LineWidth = U * 0.35
        Endif 
        
        If String.InStr(T, "-whiteborder") > 0 Then 
          If bWhiteBorderON = True Then
            Paint.LineWidth = Paint.LineWidth * 1.5
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
            Paint.LineWidth = Paint.LineWidth / 2 'Reset
          Endif
        Endif 
        
        Paint.Brush = Paint.Color(iColorRed)
        If String.InStr(T, "-stroke") > 0 Then 
          Paint.LineWidth = U * 0.15
          Paint.Stroke()
        Else 
          Paint.Stroke(True)
          Paint.Brush = Paint.Color(Color.White)
          Paint.Fill()
        Endif 
      Endif 
    Endif 'Second timess
    
    If String.InStr(T, "-timecenterpoint") > 0 Then '●
      ''Center, Circle
      If String.InStr(T, "-small") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 0.15)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
      Else If String.InStr(T, "-big") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 0.25)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
      Else If String.InStr(T, "-stroke") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 0.75)
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
      Else If String.InStr(T, "-fill") > 0 Then
        Paint.Arc(U * 5, U * 5, U * 0.5)
        
        If bWhiteBorderON = True Then
          If String.InStr(T, "-little") > 0 Then Paint.LineWidth = U * 0.6 Else Paint.LineWidth = U * 0.8
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.Brush = Paint.Color(Color.White)
        If String.InStr(T, "-little") > 0 Then Paint.LineWidth = U * 0.4 Else Paint.LineWidth = U * 0.6
        Paint.Stroke(True)
        If String.InStr(T, "-white") > 0 Then 
          Paint.Brush = Paint.Color(Color.White)
        Else 
          Paint.Brush = Paint.Color(iColorRed)
        Endif
        Paint.Fill()
      Else If String.InStr(T, "-middle") > 0 Then 
        ''Center, Circle
        Paint.Arc(U * 5, U * 5, U * 0.25)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.8
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
      Else  'other
        Paint.Arc(U * 5, U * 5, U * 0.15)
        Paint.LineWidth = U * 0.3
        If String.InStr(T, "-white") > 0 Then 
          Paint.Brush = Paint.Color(iColorWhite) 
        Else If String.InStr(T, "-blue") > 0 Then 
          Paint.Brush = Paint.Color(iColorBlue) 
        Else 
          Paint.Brush = Paint.Color(iColorRed)
        Endif 
        Paint.Stroke(True)
        Paint.Fill()
      Endif
    Endif 
    
    ''Text
    If String.InStr(T, "-timedigital") > 0 Then 'Symbol-Icon, calculated about —▶Drawtime() in Timer
      Try Img = M07Paint.ClockDigital(Now, T) '.Copy()  'as Image '1x actual, current time
    Endif
    
    If String.InStr(T, "-timelcd") > 0 Then 'Symbol-Icon, calculated about —▶Drawtime() in Timer
      Try Img = M07Paint.ClockLCD(Now, T) 'as Image '1x actual, current time
    Endif 
    
    If String.InStr(T, "-timephythagoras") > 0 Then 'Symbol-Icon, calculated about —▶Drawtime() in Timer
      T = T & "-hour-minute-second-centerpoint"
      Try Img = M07Paint.ClockPhythagoras(Now, T) 'as Image '1x actual, current time
    Endif 
    
    If String.InStr(T, "-nightday") > 0 Then 
      datetime = Form14UhrDesign.F_dateNow
      If Not datetime Then datetime = Now
      Try Img = M07Paint.ClockSunUpDown(datetime, T) '.Copy() 'as Image
    Endif 
    Paint.End
    
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "clock" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break   
  Next 'it3
  ''h-m-s
  
  ''1111111111111111111111111111111111111111111111111111111111111111
  For it3 = 0 To 33
    iStep = 15
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Select Case it3
      Case 0
        T = "-zone-stroke-timesummer"
      Case 1
        T = "-zone-fill-timesummer"
      Case 2
        T = "-background-inside-white"
      Case 3
        T = "-background-inside-stroke"
      Case 4
        T = "-borderhours12x-ring"
      Case 5
        T = "-watchstrap-rectangle-small" ''▪○▪
      Case 6
        T = "-watchstrap-rectangle-big" 
      Case 7
        T = "-watchstrap-rectangle" 
      Case 8
        T = "-watchstrap-clock" ''|◃
      Case 9
        T = "-watchstrap-rectangle-horizontal-blue" ''■■■■
      Case 10
        T = "-watchstrap-rectangle-horizontal" ''□□□□
      Case 11
        T = "-adjustingwheel-button" ''|◃
      Case 12
        T = "-stephours4x-big"
      Case 13
        T = "-stephours12x"  
      Case 14
        T = "-ringstep"  
        iStep = 15
      Case 15
        T = "-ringstep-big"  
        iStep = 15
      Case 16
        T = "-ringoutsidestep"  
        iStep = 15
      Case 17
        T = "-ringstep"  
        iStep = 30
      Case 18
        T = "-ringstep-big"  
        iStep = 30
      Case 19
        T = "-ringoutsidestep"  
        iStep = 30
      Case 20
        T = "-circle-background-large-white"
      Case 21
        T = "-circle-background-great-white"
      Case 22
        T = "-circle-background-middle-white"
      Case 23
        T = "-circle-background-little-white"
      Case 24
        T = "-circle-background-middle-blue"
      Case 25
        T = "-circle-outside-ring"  
      Case 26
        T = "-circle-middle-ring"  
      Case 27
        T = "-circle-inside-ring" 
      Case 28
        T = "-circle-background-white"
      Case 29
        T = "-circle-ring-small" 
      Case 30
        T = "-circle-ring-big"
      Case 31
        T = "-circle-clock" ''|◃
      Case 32
        T = "-circle12x-stroke-ring-numbers" '····
      Case 33
        T = "-circle12x-blue-ring-numbers" ''····
    End Select
    
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    
    If String.InStr(T, "-ringstep") > 0 Then 
      ' iStep = 15
      L = 3
      For itF = -(iStep / 2) To 360 Step iStep
        bChange = Not bChange
        If bChange = True Then 
          Paint.Arc(U * 5, U * 5, U * fRadius4_5, Rad(itF), Rad(iStep), False)
        Else 
          Paint.Arc(U * 5, U * 5, U * fRadius4_75, Rad(itF - L), Rad(iStep + L + L), False)
        Endif 
      Next
      If String.InStr(T, "-big") > 0 Then 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
      Else
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke()
      Endif 
    Endif 
    
    If String.InStr(T, "-ringoutsidestep") > 0 Then 
      ' iStep = 30
      L = 3
      For itF = -(iStep / 2) To 360 Step iStep
        bChange = Not bChange
        If bChange = True Then 
          '...
        Else 
          Paint.Arc(U * 5, U * 5, U * fRadius4_75, Rad(itF), Rad(iStep), False)
        Endif 
      Next
      Paint.Arc(U * 5, U * 5, U * 4.5)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-borderhours12x") > 0 Then 
      iStep = 30
      For itF = iStep To 360 Step iStep  'clockwise right —▶ Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        Paint.Arc(U * 5, U * 5, U * fRadius4_5, Rad(itF), Rad(iStep), False)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        bChange = Not bChange
        If bChange = True Then 
          Paint.Brush = Paint.Color(iColorBlue)
        Else 
          Paint.Brush = Paint.Color(iColorGray)  
        Endif 
        Paint.Stroke()
      Next
    Endif
    
    If String.InStr(T, "-watchstrap-rectangle") > 0 Then '▪○▪
      If String.InStr(T, "-horizontal") > 0 Then '▪○▪
        Paint.Rectangle(U * 0, U * 2, U * 10, U * 6, R / 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorWhite)
        Paint.Fill()
        
      Else If String.InStr(T, "-big") > 0 Then '▪○▪
        Paint.Rectangle(U * 2, U * 0, U * 6, U * 10, R / 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(iColorDarkGray)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Fill()
      Else If String.InStr(T, "-small") > 0 Then '▪○▪
        Paint.Rectangle(U * 3, U * 0, U * 4, U * 10, R / 2)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Fill()
      Else
        Paint.Rectangle(U * 2, U * 0, U * 6, U * 10, R / 2)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Fill()
      Endif 
    Endif 
    
    If String.InStr(T, "-circle-clock") > 0 Then '▪○▪
      ''Clock Circle Background
      Paint.Arc(U * 5, U * 5, U * fRadius4_0)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1.4
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif 
    
    If String.InStr(T, "-watchstrap-clock") > 0 Then '▪○▪
      Paint.Rectangle(U * 2, U * 0, U * 6, U * 10, R / 2)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Clock Circle Background
      Paint.Arc(U * 5, U * 5, U * fRadius4_0)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1.4
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
      
      Paint.Arc(U * 5, U * 5, U * 4.85, Rad(-10), Rad(20), False)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
      
      Paint.Arc(U * 5, U * 5, U * 5.15, Rad(-310), Rad(80), False) 'shadow
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-background-inside") > 0 Then
      Paint.Arc(U * 5, U * 5, U * fRadius3_5)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      If String.InStr(T, "-white") > 0 Then  
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
        Paint.Fill() 
      Endif 
      If String.InStr(T, "-stroke") > 0 Then 
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke()
      Endif 
    Endif
    
    If String.InStr(T, "-circle-inside") > 0 Then 
      Paint.Arc(U * 5, U * 5, U * fRadius3_5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-circle-middle") > 0 Then 
      Paint.Arc(U * 5, U * 5, U * fRadius4_0)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-circle-outside") > 0 Then 
      Paint.Arc(U * 5, U * 5, U * fRadius4_25)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-circle-background") > 0 Then 
      ''Clock Circle Background
      If String.InStr(T, "-large") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 4)
      Else If String.InStr(T, "-great") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3.75)
      Else If String.InStr(T, "-middle") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3.5)
      Else If String.InStr(T, "-little") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3)
      Else 
        Paint.Arc(U * 5, U * 5, U * 2.5)
      Endif 
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      If String.InStr(T, "-white") > 0 Then 
        Paint.Brush = Paint.Color(iColorWhite)
      Else If String.InStr(T, "-blue") > 0 Then 
        Paint.Brush = Paint.Color(iColorBlue)
      Else 
        Paint.Brush = Paint.Color(iColorGreen)  
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If String.InStr(T, "-circle-ring") > 0 Then 
      ''Clock Circle Background
      Paint.Arc(U * 5, U * 5, U * fRadius4_0)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      If String.InStr(T, "-big") > 0 Then '■■■■
        Paint.LineWidth = U * 1.8
      Else '"-small" '———
        Paint.LineWidth = U * 0.6
      Endif 
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke()
    Endif 
    
    If String.InStr(T, "-adjustingwheel") > 0 Then    
      Paint.Arc(U * 5, U * 5, U * 4.85, Rad(-10), Rad(20), False)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-circle12x") > 0 Then 'x12h 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 30
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        ' Radius = c * 0.5 '>Line length
        ' MX1 = a + (Radius * Cos(alpha))
        ' MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.25)                                                      'Punkt, Point(X2,Y2)
        ' Paint.MoveTo(MX1, MY1)
        ' Paint.LineTo(MX2, MY2)
      Next
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.15
      If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGray)
      If String.InStr(T, "-stroke") > 0 Then 
        Paint.Stroke()
      Else 
        Paint.Stroke(True)
        Paint.Fill()
      Endif 
    Endif
    
    If String.InStr(T, "-stephours12x") > 0 Then 'x12h 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 30
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.5 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-stephours4x") > 0 Then 'x4h 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 4x
      iStep = 90
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.5 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-zone") > 0 Then
      ''Hour moved, time zone, segment
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(0), Rad(-30), True)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorRed)
      If String.InStr(T, "-stroke") > 0 Then 
        Paint.Stroke()
      Else '"-fll"
        Paint.Stroke(True)
        Paint.Fill()
      Endif 
    Endif
    
    Paint.End
    
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "clock-1" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
    
  Next 'it3
  
  ''2222222222222222222222222222222222222222222222222222222222222222222222222222222222222
  T = ""
  Text = "Z"
  ' For it4 = 0 To 0 ''= 1
  For it3 = 0 To 13
    T = ""
    'If it4 = 1 Then T = "-pure"
    
    Select Case it3
      Case 0
        T = T & "-points-green-background"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 1
        T = T & "-points-blue"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorGreen
        Text = ""
        iHours = 4
      Case 2
        T = T & "-points-red"
        iColorChange1 = iColorRed
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 4
      Case 3
        T = T & "-lines-darkgray"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 4
        T = T & "-lines-background"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 5                  ''type ▼..........................
        T = T & "-single"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 4
      Case 6
        T = T & "-bold"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 4
      Case 7
        T = T & "-station"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 8
        T = T & "-bold"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 9
        T = T & "-lines-long"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorDarkGray
        Text = ""
        iHours = 12
      Case 10
        T = T & "-square" '■
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 12
      Case 11
        T = T & "-square" '■
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
        Text = ""
        iHours = 4
      Case 12
        T = T & "-zone-timesummer"
        iColorChange1 = iColorGray
        iColorChange2 = iColorBlue
        Text = "Z"
        iHours = 0
      Case 13
        T = T & "-texttime"
        iColorChange1 = iColorGray
        iColorChange2 = iColorBlue
        Text = "T"
        iHours = 0
    End Select
    If iHours > 0 Then T = "-stephours" & Str(iHours) & "x" & T
    
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    'Paint.Translate(U , U)
    'Paint.Scale(-0.8, 0.8)
    'Paint.Rotate(Rad(-90))
    
    If String.InStr(T, "-background") > 0 Then ''Background
      ''Clock Circle Background
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-single") > 0 Then
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 4x      Rad(0) = 03:00
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.65 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.75
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-lines") > 0 Then
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        If String.InStr(T, "-long") > 0 Then 
          Radius = c * 0.4 '>Line length
        Else
          Radius = c * 0.55 '>Line length
        Endif
        
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.65 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      If String.InStr(T, "-long") > 0 Then 
        Paint.LineWidth = U * 0.05
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
      Else
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
      Endif
    Endif
    
    If String.InStr(T, "-points") > 0 Then
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        ' Radius = c * 0.6 '>Line length
        ' MX1 = a + (Radius * Cos(alpha))
        ' MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.2)                                                      'Punkt, Point(X2,Y2)
        'Paint.MoveTo(MX1, MY1)
        'Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.6
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-station") > 0 Then
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.55 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.65 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        'Paint.Arc(MX2, MY2, U * 0.2)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.2
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-bold") > 0 Then
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.55 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.65 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        'Paint.Arc(MX2, MY2, U * 0.2)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.Stroke()
    Endif
    
    If String.InStr(T, "-square") > 0 Then
      Paint.LineCap = Paint.LineCapButt 'as Integer=0
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 12x
      iStep = 360 / iHours
      For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.52 '5 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.65 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        'Paint.Arc(MX2, MY2, U * 0.2)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.Stroke()
      
      ''Reset:
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    Endif
    
    If String.InStr(T, "-zone") > 0 Then ''Time Zone
      ''Hour moved, time zone, segment
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(0), Rad(-30), True)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.4
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorRed)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    ''Text
    If Text Then
      If String.InStr(T, "-zone") > 0 Or String.InStr(T, "-texttime") > 0 Then ''Time Zone
        'Paint.Font.Name = "Ubuntu"
        Paint.Font.Name = "Waree"
        Paint.Font.Bold = True
        Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 3
        Paint.RichText(Text, 0, U * 3, U * 10, U * 10, Align.Center)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.6
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.2
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
      Endif
    Endif
    Paint.End
    
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "clock-2" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
  Next 'it3
  ' Next 'it4
  
  ''33333333333333333333333333333333333333333333333333333333333333333333333333333333
  T = ""
  Text = "Z" 'Time, Zone, Clock
  Img = New Image(iIconSize, iIconSize, Color.Transparent)
  Paint.Begin(Img)
  Paint.AntiAlias = bAntiAliasON                                                               '...----...
  Paint.LineCap = iLineEndType
  Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
  
  ''Clock Circle Background
  Paint.Arc(U * 5, U * 5, U * fRadius4_5)
  If bWhiteBorderON = True Then
    Paint.LineWidth = U * 1
    Paint.Brush = Paint.Color(Color.White)
    Paint.Stroke(True)
  Endif
  Paint.LineWidth = U * 0.4
  Paint.Brush = Paint.Color(iColorGreen)
  Paint.Stroke(True)
  Paint.Brush = Paint.Color(Color.White)
  Paint.Fill()
  
  ''Lines, Pointer, Parts - | -
  a = U * 5 'Middle, Center, start-point
  b = U * 5
  c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
  ''Hours 4x      Rad(0) = 03:00
  iStep = 90
  For itF = iStep To 360 Step iStep  '4xHours 03:00, 06:00, 09:00, 12:00
    alpha = Rad(itF)
    Radius = c * 0.6 '>Line length
    MX1 = a + (Radius * Cos(alpha))
    MY1 = b + (Radius * Sin(alpha))
    Radius = c * 0.7 '>Line length
    MX2 = a + (Radius * Cos(alpha))
    MY2 = b + (Radius * Sin(alpha))
    ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
    Paint.MoveTo(MX1, MY1)
    Paint.LineTo(MX2, MY2)
  Next
  If bWhiteBorderON = True Then
    Paint.LineWidth = U * 1.2
    Paint.Brush = Paint.Color(Color.White)
    Paint.Stroke(True)
  Endif
  Paint.LineWidth = U * 0.8
  Paint.Brush = Paint.Color(iColorGray)
  Paint.Stroke()
  'Paint.Brush = Paint.Color(Color.White)
  'Paint.Fill()
  
  ''Hours 12x
  iStep = 30
  For itF = iStep To 360 Step iStep  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
    alpha = Rad(itF)
    Radius = c * 0.6 '>Line length
    MX1 = a + (Radius * Cos(alpha))
    MY1 = b + (Radius * Sin(alpha))
    Radius = c * 0.7 '>Line length
    MX2 = a + (Radius * Cos(alpha))
    MY2 = b + (Radius * Sin(alpha))
    ''Paint.Arc(MX2, MY2, U * 0.2)                                                      'Punkt, Point(X2,Y2)
    Paint.MoveTo(MX1, MY1)
    Paint.LineTo(MX2, MY2)
  Next
  If bWhiteBorderON = True Then
    Paint.LineWidth = U * 1
    Paint.Brush = Paint.Color(Color.White)
    Paint.Stroke(True)
  Endif
  Paint.LineWidth = U * 0.4
  Paint.Brush = Paint.Color(iColorGray)
  Paint.Stroke()
  'Paint.Brush = Paint.Color(Color.White)
  'Paint.Fill()
  
  Paint.End
  
  'Save in Program-Directory. Note: Not in Root-Path.
  it5 = it5 + 1
  Form14UhrDesign.F_sLastIconName = "clock-3-phythagoras" & String.LCase(T) & "-" & Str(it5)
  Form14UhrDesign.F_imgLastIconImage = Img
  If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
  ' If Form14UhrDesign.F_bESCpressedON = True Then Break
  
  ''5555555555555555555555555555555555555555555555555555555555555555555555555555
  T = "" ''Station clock, clock dial blank, clock face, clock background
  Text = "0" 'Time, Zone, clock, stop watch, button, click
  For it3 = 0 To 40
    Select Case it3
      Case 0
        T = "-numbers-first0-text-small-font2"  ''0, 3, 6, 9 hours
      Case 1
        T = "-numbers-first0-text-greater-font3"  ''0, 3, 6, 9
      Case 2
        T = "-numbers-first12-text-small-font2"  ''12, 3, 6, 9
      Case 3
        T = "-numbers-first24-text-small-font3"  ''24, 15, 18, 21
      Case 4
        T = "-numbers-text-small"  ''0, 3, 6, 9
      Case 5
        T = "-numbers-text-nowhite"  ''0, 3, 6, 9
      Case 6
        T = "-numbers-text-bold"  ''0, 3, 6, 9
      Case 7
        T = "-numbers-text-font3"  ''0, 3, 6, 9 
      Case 8
        T = "-numbers-text-compass-snow"  ''S, W, N, O
      Case 9
        T = "-numbers-text-compass-nswo"  ''N, S, W, O
      Case 10
        T = "-numbers-text-colorcompass-snow-bold"  ''S, W, N, O
      Case 11
        T = "-numbers-text-colorcompass-nswo-bold"  ''N, S, W, O
      Case 12
        T = "-stopwatch-big-cutbackground" '' with 2 button
      Case 13
        T = "-stopwatch-cutbackground" '' with 2 button
      Case 14
        T = "-stopwatch-small-cutbackground"
      Case 15
        T = "-buttonstopwatch" '' middle button
      Case 16
        T = "-buttonstopwatch-redbig" '' middle button
      Case 17
        T = "-bigbackground-stopwatch-big-minutes-buttonstopwatch" '' with 3 button
      Case 18
        T = "-bigbackground-stopwatch" 
      Case 19
        T = "-sun12hours"
      Case 20
        T = "-sun12hours-small"  
      Case 21
        T = "-onlyhours"
      Case 22
        T = "-onlyhours-radiussmaller"
      Case 23
        T = "-bigbackground-minutes" 
      Case 24
        T = "-onlyminutes"
      Case 25
        T = "-onlyminutes-radiussmaller"
      Case 26
        T = "-minutes-radiussmaller" ''——▶
      Case 27
        T = "-minutes" '' |,,,,|
      Case 28
        T = "-foot-big"
      Case 29
        T = "-foot-middle"
      Case 30
        T = "-foot-little-blue"
      Case 31
        T = "-foot-little-gray"
      Case 32
        T = "-foot-station-blue"
      Case 33
        T = "-foot-station"
      Case 34
        T = "-foot-line-blue"  '_|_
      Case 35
        T = "-foot-line"  '_|_
      Case 36
        T = "-foot-triangle-blue"  '▲
      Case 37
        T = "-foot-triangle"  '▲
      Case 38
        T = "-foot-halfcircle-blue" 
      Case 39
        T = "-foot-halfcircle"  '▲
      Case 40
        T = "-foot-leftright"
        
    End Select
    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    'Paint.Translate(U , U)
    'Paint.Scale(-0.8, 0.8)
    'Paint.Rotate(Rad(-90))
    
    If String.InStr(T, "-stopwatch") > 0 Then 'Clock ears left and right ∩▪∩
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 2x
      ' iStep = 360 / iHours
      For itF = 0 To 1 'Step -90  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        If itF = 0 Then iStep = -45
        If itF = 1 Then iStep = -135
        alpha = Rad(iStep)
        Radius = c * 0.45 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.7 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
        
        If String.InStr(T, "-small") > 0 Then '▪
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 0.5
        Else If String.InStr(T, "-big") > 0 Then '■
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 3
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 2.5
        Else '"-middle"'◼
          If bWhiteBorderON = True Then
            Paint.LineWidth = U * 1.5
            Paint.Brush = Paint.Color(Color.White)
            Paint.Stroke(True)
          Endif
          Paint.LineWidth = U * 1
        Endif 
        
        If itF = 0 Then Paint.Brush = Paint.Color(iColorBlue)
        If itF = 1 Then Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
      Next
    Endif
    
    If String.InStr(T, "-cutbackground") > 0 Then ''●
      ''Clock Circle Background Border ''○
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      
      Paint.LineWidth = U * 0.3
      Paint.Operator = Paint.OperatorClear
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-bigbackground") > 0 Then ''●
      ''Clock Circle Background Border ''○
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.75
      Paint.Brush = Paint.Color(iColorGreen)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(Color.White)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-minutes") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      Paint.LineCap = Paint.LineCapButt '■ ■ ■ ■ ■
      Paint.LineJoin = Paint.LineJoinMiter    
      
      ''Minutes:
      If String.InStr(T, "-radiussmaller") > 0 Then 
        L = 0.5 '>Line length ○ ◀——▶ ■ 
      Else
        L = 0.55 '>Line length ○ ◀——▶ ■
      Endif 
      iStep = 6
      For itF = iStep To 360 Step iStep 'Minute 03:01, 03:02, 03:03, ...,03:00
        alpha = Rad(itF)
        Radius = c * L '>Line length ●—▶ start inside
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * (L + 0.05)  '>Line length ○——● outside
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next 'itF
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.LineWidth = U * 0.075
      Paint.Stroke()
      
      ''Hours:
      If String.InStr(T, "-radiussmaller") > 0 Then 
        Radius = U * fRadius3_5 '>Line length ○ ◀——▶ ■ 
      Else
        Radius = U * fRadius4_0 '>Line length ○ ◀——▶ ■
      Endif 
      L = U * 0.15 '>Line length ■
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      Paint.LineWidth = U * 0.3
      iStep = 6
      For itF = iStep To 360 Step iStep  'Minutes 03:01, 03:02, 03:03, 03:04, ...
        ''Minutes 4x12 –
        ' Paint.Arc(a, b, Radius + Paint.LineWidth, Rad(itF - (L / 2)), Rad(L))
        ''Hours 12x ◼
        If CInteger(itF) Mod 30 = 0 Then '1-2-3-4...
          Paint.Arc(a, b, Radius, Rad(itF - (L / 2)), Rad(L)) 'Rad in Float 1,234...Tortenausschnitt, Rad(Grad)  0-360Grad
          Paint.Arc(a, b, Radius - Paint.LineWidth, Rad(itF - (L / 2)), Rad(L))
        End If
        ''Hours 4x ■■
        If CInteger(itF) Mod 90 = 0 Then ' 0-3-6-9
          Paint.Arc(a, b, Radius - (Paint.LineWidth * 2), Rad(itF - (L / 2)), Rad(L))
        End If
      Next 'itF
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.Stroke(True)
      Paint.Fill()
      ''Reset:
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    Endif 
    
    If String.InStr(T, "-onlyminutes") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      If String.InStr(T, "-radiussmaller") > 0 Then 
        ' Radius = U * 3.5 '>Line length ○ ◀——▶ ■ 
        L = 0.5
      Else
        ' Radius = U * 3.75 '>Line length ○ ◀——▶ ■
        L = 0.55
      Endif 
      Paint.LineWidth = U * 0.3
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.LineCap = Paint.LineCapButt '■ ■ ■ ■ ■
      Paint.LineJoin = Paint.LineJoinMiter                                                       'Paint.LineJoinRound 'as Integer=1
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      iStep = 6
      For itF = iStep To 360 Step iStep  'Minutes 03:01, 03:02, 03:03, ...
        'Minutes 4x12
        ' L = U * 0.15 '>Line length ■
        ' Paint.Arc(a, b, Radius + Paint.LineWidth, Rad(itF - (L / 2)), Rad(L))
        ' Paint.Stroke()
        alpha = Rad(itF)
        Radius = c * L '>Line length ●—▶ start inside
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * (L + 0.05)  '>Line length ○——● outside
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
        Paint.LineWidth = U * 0.1
        Paint.Stroke()
      Next 'itF
      ''Reset:
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    Endif 
    
    If String.InStr(T, "-onlyhours") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      If String.InStr(T, "-radiussmaller") > 0 Then 
        Radius = U * fRadius3_5 '>Line length ○ ◀——▶ ■ 
      Else
        Radius = U * fRadius3_75 '>Line length ○ ◀——▶ ■
      Endif 
      L = U * 0.15 '>Line length ■
      Paint.LineWidth = U * 0.3
      Paint.Brush = Paint.Color(iColorDarkGray)
      Paint.LineCap = Paint.LineCapButt '■ ■ ■ ■ ■
      Paint.LineJoin = Paint.LineJoinMiter                                                       'Paint.LineJoinRound 'as Integer=1
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      iStep = 6
      For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
        ''Hours 12x
        If CInteger(itF) Mod 30 = 0 Then '1-2-3-4...
          Paint.Arc(a, b, Radius, Rad(itF - (L / 2)), Rad(L)) 'Rad in Float 1,234...Tortenausschnitt, Rad(Grad)  0-360Grad
          Paint.Stroke()
          Paint.Arc(a, b, Radius - Paint.LineWidth, Rad(itF - (L / 2)), Rad(L))
          Paint.Stroke()
        End If
        ''Hours 4x
        If CInteger(itF) Mod 90 = 0 Then ' 0-3-6-9
          Paint.Arc(a, b, Radius - (Paint.LineWidth * 2), Rad(itF - (L / 2)), Rad(L))
          Paint.Stroke()
        End If
      Next 'it
      ''Reset:
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    Endif 
    
    If String.InStr(T, "-sun12hours") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      
      If String.InStr(T, "-small") > 0 Then 
        Paint.LineWidth = U * 0.15
      Else
        Paint.LineWidth = U * 0.5
      Endif 
      
      Paint.Brush = Paint.Color(iColorYellow)
      ' Paint.LineCap = Paint.LineCapButt '■ ■ ■ ■ ■
      ' Paint.LineJoin = Paint.LineJoinMiter                                                       'Paint.LineJoinRound 'as Integer=1
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      iStep = 30
      For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
        alpha = Rad(itF)
        Radius = c * 0.2 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.5 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        Paint.MoveTo(MX1, MY1)
        Paint.LineTo(MX2, MY2)
      Next 'it
      If String.InStr(T, "-small") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 1.5)
      Else
        Paint.Arc(U * 5, U * 5, U * 3)
      Endif 
      
      Paint.Stroke(True)
      Paint.Fill()
      ''Reset:
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    Endif 
    
    If String.InStr(T, "-buttonstopwatch") > 0 Then ''with button top
      If String.InStr(T, "-redbig") > 0 Then ''with button top
        Paint.Arc(U * 5, U * 5, U * fRadius4_75, Rad(-110), Rad(40), False)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke()
      Else '"-normal" 
        Paint.Arc(U * 5, U * 5, U * fRadius4_75, Rad(-110), Rad(40), False)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.75
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke()
      Endif 
    Endif 
    
    If String.InStr(T, "-foot") > 0 Then ''Clock foot, footing, socle, base
      If String.InStr(T, "-big") > 0 Then
        Paint.Ellipse(U * 0.25, U * 8.5, U * 9.5, U * 3)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-middle") > 0 Then
        Paint.Ellipse(U * 0.75, U * 9, U * 8.5, U * 2)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-little") > 0 Then 
        Paint.Ellipse(U * 1, U * 9.5, U * 8, U * 1)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-station") > 0 Then  '■●
        Paint.Arc(U * 5, U * 5, U * 4.5, Rad(-180), Rad(180), False)
        Paint.Rectangle(U * 0.5, U * 5, U * 9, U * 4.5, 0)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-line") > 0 Then  ' _|_
        ' Paint.Rectangle(U * 0.5, U * 9.5, U * 9, U * 0.5, R)
        Paint.MoveTo(U * 0.5, U * 9.5)
        Paint.LineTo(U * 9.5, U * 9.5)
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 5, U * 9.5)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGray)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-triangle") > 0 Then  ' ▲
        Paint.MoveTo(U * 5, U * 5)
        Paint.LineTo(U * 9.5, U * 9.5)
        Paint.LineTo(U * 0.5, U * 9.5)
        Paint.LineTo(U * 5, U * 5)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-halfcircle") > 0 Then  ' ▲
        Paint.Arc(U * 5, U * 9.5, U * 4.5, Rad(-180), Rad(180), True)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        If String.InStr(T, "-blue") > 0 Then Paint.Brush = Paint.Color(iColorBlue) Else Paint.Brush = Paint.Color(iColorGreen)
        Paint.Stroke(True)
        Paint.Fill()
        
      Else If String.InStr(T, "-leftright") > 0 Then 
        ''Foots
        Paint.Ellipse(U * 0.5, U * 9, U * 3, U * 1.5, Rad(-180), Rad(180), True)
        Paint.Ellipse(U * 6.5, U * 9, U * 3, U * 1.5, Rad(-180), Rad(180), True)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorRed)
        Paint.Stroke(True)
        Paint.Fill()
      Else 
        Paint.MoveTo(U * 0.5, U * 9.5)
        Paint.LineTo(U * 9.5, U * 9.5)
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorBlue)
        Paint.Stroke(True)
        Paint.Fill()
      Endif 
    Endif
    
    ''Text, "-numbers"
    If Text And String.InStr(T, "-text") > 0 Then
      Radius = U * 2.75
      If String.InStr(T, "-font2") > 0 Then 
        ' Paint.Font.Name = "Ubuntu"
        ' Paint.Font.Name = "Waree"
        ' Paint.Font.Name = "Ubuntu Condensed" ' —▶0◀—
        ' Paint.Font.Name = "Ubuntu Thin" 'new, very small
        ' Paint.Font.Name = "FreeSans"
        'Paint.Font.Name = "FreeSerif"
        'Paint.Font.Name = "FreeMono"
        'Paint.Font.Name = "Monospace"
        sName = "FreeSans"
        iColorChange1 = iColorDarkGray
      Else If String.InStr(T, "-font3") > 0 Then
        sName = "Ubuntu Thin"
        iColorChange1 = iColorBlue
      Else  
        sName = "Sawasdee"
        iColorChange1 = iColorDarkGray
      Endif 
      If String.InStr(T, "-greater") > 0 Then Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 1.5 Else Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 1
      If Fonts.Exist(sName) = False Then Paint.Font.Name = "Ubuntu Condensed" 'alternative
      
      Paint.Font.Bold = False
      If String.InStr(T, "-first24") > 0 Then 
        W = Paint.Font.TextWidth("00") / 2
        H = Paint.Font.TextHeight("00") / 2
        Paint.Text("24", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
        Paint.Text("18", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
        Paint.Text("21", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
        Paint.Text("15", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
      Else If String.InStr(T, "-first12") > 0 Then 
        W = Paint.Font.TextWidth("00") / 2
        H = Paint.Font.TextHeight("00") / 2
        Paint.Text("12", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
        W = Paint.Font.TextWidth("0") / 2
        H = Paint.Font.TextHeight("0") / 2
        Paint.Text("6", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
        Paint.Text("9", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
        Paint.Text("3", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
      Else If String.InStr(T, "-compass") > 0 Then  
        W = Paint.Font.TextWidth("N") / 2
        H = Paint.Font.TextHeight("N") / 2
        If String.InStr(T, "-snow") > 0 Then 
          Paint.Text("S", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
          Paint.Text("N", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
          Paint.Text("O", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
          Paint.Text("W", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
        Else '"-nswo"
          Paint.Text("N", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
          Paint.Text("S", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
          Paint.Text("W", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
          Paint.Text("O", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
        Endif 
      Else If String.InStr(T, "-colorcompass") > 0 Then  
        W = Paint.Font.TextWidth("N") / 2
        H = Paint.Font.TextHeight("N") / 2
        If String.InStr(T, "-snow") > 0 Then 
          Paint.Text("S", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorRed)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("N", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorGreen)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("O", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorYellow)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("W", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorBlue)
          Paint.Stroke(True)
          Paint.Fill()
        Else '"-nswo"
          Paint.Text("N", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorRed)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("S", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorGreen)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("W", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorGreen)
          Paint.Stroke(True)
          Paint.Fill()
          Paint.Text("O", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
          If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
          Paint.Brush = Paint.Color(iColorGreen)
          Paint.Stroke(True)
          Paint.Fill()
        Endif 
      Else 'If String.InStr(T, "-first0") > 0 Then  
        W = Paint.Font.TextWidth("0") / 2
        H = Paint.Font.TextHeight("0") / 2
        Paint.Text("0", U * 5 - W, U * 5 - Radius - H, Align.Center) ' |
        Paint.Text("6", U * 5 - W, U * 5 + Radius - H, Align.Center) ' |
        Paint.Text("9", U * 5 - Radius - W, U * 5 - H, Align.Center) ' __
        Paint.Text("3", U * 5 + Radius - W, U * 5 - H, Align.Center) ' __
      Endif 
      
      If String.InStr(T, "-nowhite") > 0 Then 
        '...
      Else 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
      Endif  
      If String.InStr(T, "-bold") > 0 Then Paint.LineWidth = U * 0.15 Else Paint.LineWidth = U * 0.01
      ' Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    Paint.End
    
    'Img.Save(FMain.F_sDirDefault &/  "clockphythagoras" & String.LCase(T) & String.LCase(Text) & "_" & Str(Form14UhrDesign.F_iIconSize) & ".png") 'Save in Program-Directory. Note: Not in Root-Path.
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "clock-5" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
  Next 'it3
  
  ''66666666666666666666666666666666666666666666666666666666666666666666
  T = "" ''Station clock, clock dial blank, clock face, clock background
  Text = "0" 'Time, Zone, clock, stop watch, button, click
  For it3 = 0 To 22
    iColorChange1 = Color.Transparent 'Default
    Select Case it3
      Case 0
        T = "-zone"
        iColorChange2 = iColorGreen
      Case 1
        T = "-zone"
        iColorChange2 = iColorRed
      Case 2
        T = "-zone"
        iColorChange2 = iColorGray
      Case 3
        T = "-ring-small"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorGreen
      Case 4
        T = "-ring-big"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorGreen
      Case 5
        T = "-background-ring"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorGreen
      Case 6
        T = "-ring"
        iColorChange1 = iColorGreen
      Case 7
        T = "-ring"
        iColorChange1 = iColorDarkGray
      Case 8
        T = "-background-white"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite
      Case 9
        T = "-background-button"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite
      Case 10
        T = "-background-halfzone" ''1/2
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorGreen
      Case 11
        T = "-halfzone-timenightsky" ''1/2
        iColorChange2 = iColorBlue
      Case 12
        T = "-halfzone" ''1/2
        iColorChange2 = iColorRed
      Case 13
        T = "-halfzone" ''1/2
        iColorChange2 = iColorWhite
      Case 14
        T = "-background-quarterzone" ''1/4
        iColorChange1 = iColorBlue
        iColorChange2 = iColorRed
      Case 15
        T = "-quarterzone" ''1/4
        iColorChange2 = iColorGreen
      Case 16
        T = "-quarterzone" ''1/4
        iColorChange2 = iColorRed
      Case 17
        T = "-quarterzone" ''1/4
        iColorChange2 = iColorYellow
      Case 18
        T = "-fillmask-stencil-cut" 
        iColorChange1 = iColorWhite
      Case 19
        T = "-bottom-stroke" 
        iColorChange2 = iColorGreen  
      Case 20
        T = "-square-4x-numbers" 
        iColorChange2 = iColorBlue  
        iStep = 360 / 4
        L = U * 0.25
      Case 21
        T = "-square-12x-numbers" 
        iColorChange2 = iColorGray
        iStep = 360 / 12
        L = U * 0.25
      Case 22
        T = "-square-12x-numbers" 
        iColorChange2 = iColorGray
        iStep = 360 / 12
        L = U * 0.15
    End Select

    Img = New Image(iIconSize, iIconSize, Color.Transparent)
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    'Paint.Translate(U , U)
    'Paint.Scale(-0.8, 0.8)
    'Paint.Rotate(Rad(-90))
    
    If String.InStr(T, "-fillmask") > 0 Then 
      Paint.FillRect(U * 0, U * 0, U * 10, U * 10, iColorChange1)
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(Color.White)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-background") > 0 Then 
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(Color.White)
      If String.InStr(T, "-border") > 0 Then 
        Paint.Stroke(True)
        Paint.Brush = Paint.Color(iColorChange1)
      Endif 
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-square") > 0 Then ''■
      Paint.LineCap = Paint.LineCapButt ' 
      'Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ' L = 30 'one hour
      ''Hours 1x      Rad(0) = 03:00
      ' L = U * 0.25
      ' iStep = 90
      For itF = iStep To 360 Step iStep  '4xHours 03:00, 06:00, 09:00, 12:00
        alpha = Rad(itF)
        ' Radius = c * 0.2 '>Line length
        ' MX1 = a + (Radius * Cos(alpha))
        ' MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.5 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
        ' Paint.MoveTo(MX1, MY1)
        ' Paint.LineTo(MX2, MY2)
        Paint.Rectangle(MX2 - L, MY2 - L, L * 2, L * 2, 0)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
      Paint.LineCap = iLineEndType 'Reset
    Endif
    
    If String.InStr(T, "-button") > 0 Then ''■
      Paint.Rectangle(U * 0.5, U * 0.5, U * 9, U * 9, R * 2)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      
      Paint.Arc(U * 5, U * 5, U * fRadius4_0) ''○
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Operator = Paint.OperatorClear
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-ring") > 0 Then 'colors
      Paint.Arc(U * 5, U * 5, U * fRadius4_5)
      
      If String.InStr(T, "-small") > 0 Then 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.25
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        ' Paint.Fill()
      Else If String.InStr(T, "-big") > 0 Then 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
      Else '"-middle"
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 0.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
      Endif  
    Endif 
    
    If String.InStr(T, "-zone") > 0 Then 'colors
      
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(-90 - 180), Rad(180), True)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-halfzone") > 0 Then
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(-180), Rad(180), True)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-timenightsky") > 0 Then
      Paint.Arc(U * 5, U * 5, U * 1, Rad(-180), Rad(180), True)
      Paint.Arc(U * 2.5, U * 4.5, U * 0.1)
      Paint.Arc(U * 6, U * 2.5, U * 0.25)
      Paint.Arc(U * 7.5, U * 4, U * 0.1)
      
      '+
      Paint.MoveTo(U * 5.5, U * 2.5)
      Paint.LineTo(U * 6.5, U * 2.5)
      Paint.MoveTo(U * 6, U * 2)
      Paint.LineTo(U * 6, U * 3)
      
      Paint.LineWidth = U * 0.15
      Paint.Brush = Paint.Color(iColorYellow)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-bottom-stroke") > 0 Then
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(-180), Rad(-180), True)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke()
      ' Paint.Fill()
    Endif
    
    If String.InStr(T, "-quarterzone") > 0 Then
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(-180), Rad(90), True)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    If String.InStr(T, "-quarterredzone") > 0 Then
      Paint.Arc(U * 5, U * 5, U * fRadius3_5, Rad(-90), Rad(90), True)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
    Endif
    
    Paint.End
    
    'Img.Save(FMain.F_sDirDefault &/  "clockphythagoras" & String.LCase(T) & String.LCase(Text) & "_" & Str(Form14UhrDesign.F_iIconSize) & ".png") 'Save in Program-Directory. Note: Not in Root-Path.
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "clock-6" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
  Next 'it3
  
  ''8888888888888888888888888888888888888888888888888888888888888888
  T = "" ''Station clock, clock dial blank, clock face, clock background
  Text = "0" 'Time, Zone, clock, stop watch, button, click
  For it3 = 0 To 45
    Select Case it3
      Case 0
        T = "-flower"
        iColorChange1 = iColorGreen
        iSTep = 30
      Case 1
        T = "-flower-stroke"
        iColorChange1 = iColorGreen
        iSTep = 30
      Case 2
        T = "-flower-4x"
        iColorChange1 = iColorGreen
        iSTep = 90
      Case 3
        T = "-flower-4x-stroke"
        iColorChange1 = iColorGreen
        iSTep = 90
      Case 4
        T = "-wheelflower"
        iColorChange1 = iColorGray   
        iSTep = 30
      Case 5
        T = "-earth-globe-y"
        iColorChange1 = iColorGray
      Case 6
        T = "-earth-points-y"
        iColorChange1 = iColorGreen 
      Case 7
        T = "-gearwheel" '∧∧∧∧
        iColorChange1 = iColorGray
      Case 8
        T = "-technicalwheel-05wheel" '∧∧∧∧
        iColorChange1 = iColorGray  
        L = 1.25
      Case 9
        T = "-technicalwheel-05wheel" '∧∧∧∧
        iColorChange1 = iColorGray
        L = 1.0
      Case 10
        T = "-technicalwheel-05wheel" '∧∧∧∧
        iColorChange1 = iColorGray
        L = 0.75
      Case 11
        T = "-technicalwheel-05wheel"
        iColorChange1 = iColorGray
        L = 0.5
      Case 12
        T = "-technicalwheel-ring1"
        iColorChange1 = iColorGray
      Case 13
        T = "-technicalwheel-ring2"
        iColorChange1 = iColorGray
      Case 14
        T = "-technicalwheel-ring3"
        iColorChange1 = iColorGray
      Case 15
        T = "-technicalwheel-bike"
        iColorChange1 = iColorGray
      Case 16
        T = "-technicalwheel-round"
        iColorChange1 = iColorGray
      Case 17
        T = "-technicalwheel-big"
        iColorChange1 = iColorGray
      Case 18
        T = "-technicalwheel-insidecircle"
        iColorChange1 = iColorGray
      Case 19
        T = "-technicalwheel-insidecircle-stroke"
        iColorChange1 = iColorGray
      Case 20
        T = "-technicalwheel-insidewheel"
        iColorChange1 = iColorGray
      Case 21
        T = "-technicalwheel-insidestrokes-circleinside"
        iColorChange1 = iColorGray 
        iSTep = 30
      Case 22
        T = "-technicalwheel-insidestrokes-circleoutside"
        iColorChange1 = iColorGray  
        iSTep = 30
      Case 23
        T = "-technicalwheel-insidestrokes-circles"
        iColorChange1 = iColorGray 
        iSTep = 30
      Case 24
        T = "-technicalwheel-insidestrokes"
        iColorChange1 = iColorGray   
        iSTep = 30
      Case 25
        T = "-technicalwheel-insidestrokes"
        iColorChange1 = iColorGray   
        iSTep = 90
      Case 26
        T = "-technicalwheel-insidecross"
        iColorChange1 = iColorGray   
      Case 27
        T = "-technicalwheel-03wheel"
        iColorChange1 = iColorGray   
      Case 28
        T = "-technicalwheel-01wheel"
        iColorChange1 = iColorGray   
      Case 29
        T = "-technicalwheel-04wheel"
        iColorChange1 = iColorGray   
      Case 30
        T = "-technicalwheel-onlycross"
        iColorChange1 = iColorGray   
      Case 31
        T = "-technicalwheel-ring4"
        iColorChange1 = iColorGray  
      Case 32
        T = "-timeclocknumbers-01"
      Case 33
        T = "-timeclocknumbers-02"
      Case 34
        T = "-timeclocknumbers-03"
      Case 35
        T = "-timeclocknumbers-04"
      Case 36
        T = "-timeclocknumbers-05"  
      Case 37
        T = "-timeclocknumbers-06"  
      Case 38
        T = "-timeclocknumbers-07"  
      Case 39
        T = "-timeclocknumbers-08"  
      Case 40
        T = "-timeclocknumbers-09"  
      Case 41
        T = "-timeclocknumbers-10"  
      Case 42
        T = "-timeclocknumbers-11"  
      Case 43
        T = "-timeclocknumbers-12"  
      Case 44
        T = "-timeclocknumbers-13"  
      Case 45
        T = "-technicalwheel-3xwheel"
    End Select
    
    If String.InStr(T, "-gearwheel") > 0 Then 
      ''Gearwheel ▲
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      Paint.Arc(U * 5, U * 2.15, U * 0.75, Rad(-175), Rad(170), False)
      
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke()
      ' Paint.Fill()
      Paint.End
      
      ''Gearwheel ▼
      Img3 = New Image(iIconSize, iIconSize, Color.Transparent)
      Paint.Begin(Img3)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      Paint.Arc(U * 5, U * 2, U * 0.75, Rad(-200), Rad(-140), False)
      
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke()
      ' Paint.Fill()
      Paint.End
      
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      Paint.Begin(Img)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      iStep = 1
      For itF = iStep To 12 Step iStep ' 12 Striche Stunden
        bChange = Not bChange
        If bChange = True Then 
          imgTemp = Img3.Rotate(-itF * Pi(2 / 12)) '.Copy()
        Else 
          imgTemp = Img2.Rotate(-itF * Pi(2 / 12))  
        Endif 
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2))
      Next
      Paint.End
      L = 0.5 'Size factor
      imgTemp = Img.Stretch(iIconSize * L, iIconSize * L).Copy() 'reset size
      
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      Paint.Begin(Img)
      Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2))
      Paint.End
    Endif
    
    If String.InStr(T, "-technicalwheel") > 0 Then 
      If String.InStr(T, "-big") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.5
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(U * 5, U * 5, U * fRadius3_75, Rad(itF), Rad(iStep))
          Else
            Paint.Arc(U * 5, U * 5, (U * fRadius3_75) + (Paint.LineWidth / 2), Rad(itF), Rad(iStep))
          End If
        Next 'it
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke(True)
        Paint.Fill()
        Paint.End
        
      Else If String.InStr(T, "-01wheel") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.5
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        ''background fill
        Paint.Arc(a, b, U * 4.25)
        Paint.Brush = Paint.Color(iColorChange1)
        ' Paint.Stroke()
        Paint.Fill()
        
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.6 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Paint.Arc(MX1, MY1, U * 0.35)
          ' Paint.Brush = Paint.Color(Color.Transparent)
          Paint.Operator = Paint.OperatorClear
          Paint.Fill()
        Next 'it
        ''cut inside
        Paint.Arc(a, b, U * 3)
        ' Paint.Brush = Paint.Color(iColorChange1)
        Paint.Operator = Paint.OperatorClear
        ' Paint.Stroke()
        Paint.Fill()
        Paint.End
        
      Else If String.InStr(T, "-ring1") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.5
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.5 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2)
          
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(U * 5, U * 5, U * 3.5, Rad(itF), Rad(iStep))
          Else
            Paint.Arc(U * 5, U * 5, (U * fRadius3_75) + Paint.LineWidth, Rad(itF), Rad(iStep))
          End If
        Next 'it
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke 
        Paint.End
      Else If String.InStr(T, "-ring2") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.5
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(U * 5, U * 5, U * fRadius3_75, Rad(itF), Rad(iStep))
          End If
        Next 'it
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke 
        Paint.LineWidth = U * 0.25
        Paint.Arc(U * 5, U * 5, U * fRadius3_5)
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke 
        Paint.End
      Else If String.InStr(T, "-ring3") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.25
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 30
        For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.5 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
          ' Paint.MoveTo(MX1, MY1)
          ' Paint.LineTo(MX2, MY2)
          
          ' bChange = Not bChange
          ' If bChange = True Then
          '   Paint.Arc(U * 5, U * 5, U * 3.5, Rad(itF), Rad(iStep))
          ' Else
          '   Paint.Arc(U * 5, U * 5, (U * fRadius3_75) + Paint.LineWidth, Rad(itF), Rad(iStep))
          ' End If
        Next 'it
        Paint.Arc(U * 5, U * 5, U * 3.5)
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke 
        Paint.End
      Else If String.InStr(T, "-bike") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorChange1)
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.5 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2)
          
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(U * 5, U * 5, c * 0.5, Rad(itF), Rad(iStep))
          Else
            Paint.Arc(U * 5, U * 5, c * 0.6, Rad(itF), Rad(iStep))
          End If
        Next 'it
        Paint.Arc(a, b, U * 2) 'center
        Paint.Stroke()
        ' Paint.Fill()
        Paint.End  
      Else If String.InStr(T, "-round") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        Paint.LineWidth = U * 0.25
        Paint.Brush = Paint.Color(iColorChange1)
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 15
        For itF = -(iStep * 2) To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.59 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          ''Paint.Arc(MX2, MY2, U * 0.4)                                                      'Punkt, Point(X2,Y2)
          ' Paint.MoveTo(MX1, MY1)
          ' Paint.LineTo(MX2, MY2) ''———
          bChange = Not bChange
          If bChange = True Then
            Paint.Arc(MX2, MY2, c * 0.1, Rad(itF - 90), Rad(180), False) ''
          Else
            Paint.Arc(MX1, MY1, c * 0.05, Rad(itF - 90), Rad(-180), False)
          End If
        Next 'it
        Paint.Arc(a, b, U * 2) 'center
        Paint.Stroke()
        ' Paint.Fill()
        Paint.End  
        
      Else If String.InStr(T, "-05wheel") > 0 Then 
        
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ' L = 1.0 'see select case ...
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.5
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        Paint.Arc(a, b, (U * 4) * L)
        Paint.Brush = Paint.Color(iColorChange1)
        ' Paint.Stroke()
        Paint.Fill()
        bChange = True 'Reset
        iStep = 15
        For itF = iStep To 360 Step iStep
          alpha = Rad(itF)
          Radius = (c * 0.6) * L '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          bChange = Not bChange
          If bChange = True Then 
            ''...
          Else 
            Paint.Arc(MX1, MY1, (U * 0.75) * L)
            Paint.Brush = Paint.Color(Color.Transparent)
            Paint.Operator = Paint.OperatorClear
            Paint.Fill()
          Endif      
        Next 'it
        Paint.Fill()
        
        ''cut inside
        Paint.Arc(a, b, (U * 2.75) * L)
        ' Paint.Brush = Paint.Color(iColorChange1)
        Paint.Operator = Paint.OperatorClear
        ' Paint.Stroke()
        Paint.Fill()
        Paint.End
      Else If String.InStr(T, "-insidestrokes") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        ' iStep = 30
        ' For itF = -(iStep / 2) To 360 Step iStep
        For itF = iStep To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.4 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.55 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          ''Paint.Arc(MX2, MY2, U * 0.4)         
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2)
        Next 'it
        
        ''circle
        If String.InStr(T, "-circleinside") > 0 Then 
          Paint.Arc(U * 5, U * 5, U * 2.5)
        Else If String.InStr(T, "-circleoutside") > 0 Then 
          Paint.Arc(U * 5, U * 5, U * 4)
        Else If String.InStr(T, "-circles") > 0 Then 
          Paint.Arc(U * 5, U * 5, U * 2.5)
          Paint.Arc(U * 5, U * 5, U * 4)
        Else 
          '...
        Endif 
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        ' Paint.Brush = Paint.Color(Color.White)
        ' Paint.Fill()
        Paint.End 
      Else If String.InStr(T, "-03wheel") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        ''circle
        Paint.Arc(U * 5, U * 5, U * 3.75)
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        ' Paint.Stroke(True)
        Paint.Fill()
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        iStep = 15
        For itF = -(iStep / 2) To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.525 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Paint.Arc(MX1, MY1, U * 0.35)
        Next 'it
        Paint.Arc(U * 5, U * 5, U * 2.75)
        Paint.Operator = Paint.OperatorClear
        Paint.Fill()
        Paint.End 
        
      Else If String.InStr(T, "-04wheel") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        ''circle
        Paint.Arc(U * 5, U * 5, U * 3.5)
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        ' Paint.Stroke(True)
        Paint.Fill()
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        
        iStep = 90
        For itF = -(iStep / 2) To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.6 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Paint.Arc(MX1, MY1, U * 2.5)
        Next 'it
        Paint.Arc(U * 5, U * 5, U * 1)
        Paint.Operator = Paint.OperatorClear
        Paint.Fill()
        Paint.End 
        
      Else If String.InStr(T, "-onlycross") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        L = U * 2.25    'more=little
        Paint.MoveTo(U * 5, U * 0 + L)
        Paint.LineTo(U * 5, U * 10 - L)
        
        Paint.MoveTo(U * 0 + L, U * 5)
        Paint.LineTo(U * 10 - L, U * 5)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1.5
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        Paint.End 
        
      Else If String.InStr(T, "-ring4") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        ''circle
        Paint.Arc(U * 5, U * 5, U * 3.5)
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        Paint.End 
        
      Else If String.InStr(T, "-insidecross") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        L = U * 1
        Paint.MoveTo(U * 5, U * 2)
        Paint.LineTo(U * 5, U * 5 - L)
        Paint.MoveTo(U * 5, U * 8)
        Paint.LineTo(U * 5, U * 5 + L)
        
        Paint.MoveTo(U * 2, U * 5)
        Paint.LineTo(U * 5 - L, U * 5)
        Paint.MoveTo(U * 5 + L, U * 5)
        Paint.LineTo(U * 8, U * 5)
        
        ''circle
        Paint.Arc(U * 5, U * 5, L)
        
        If String.InStr(T, "-cirlce") > 0 Then 
          Paint.Arc(U * 5, U * 5, U * 3)
        Endif 
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        Paint.End 
      Else If String.InStr(T, "-insidewheel") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        L = U * 1
        Paint.MoveTo(U * 5, U * 1)
        Paint.LineTo(U * 5, U * 5 - L)
        Paint.MoveTo(U * 5, U * 9)
        Paint.LineTo(U * 5, U * 5 + L)
        
        Paint.MoveTo(U * 1, U * 5)
        Paint.LineTo(U * 5 - L, U * 5)
        Paint.MoveTo(U * 5 + L, U * 5)
        Paint.LineTo(U * 9, U * 5)
        
        ''circle
        Paint.Arc(U * 5, U * 5, L)
        
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        iStep = 30
        For itF = iStep To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.5 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.5)
        Next 'it
        Paint.Arc(a, b, U * 3)
        
        If bWhiteBorderON = True Then
          Paint.LineWidth = U * 1
          Paint.Brush = Paint.Color(Color.White)
          Paint.Stroke(True)
        Endif
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke()
        
        Paint.Arc(a, b, U * 3.25)
        Paint.Stroke()
        
        For itF = iStep To 360 Step iStep
          alpha = Rad(itF)
          Radius = c * 0.5 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.25)
        Next 'it
        
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Fill()
        Paint.End 
        
      Else If String.InStr(T, "-insidecircle") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        ''circle
        Paint.Arc(U * 5, U * 5, U * 2)
        
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(iColorChange1)
        If String.InStr(T, "-stroke") > 0 Then
          Paint.Stroke()
        Else 
          Paint.Stroke(True)
          Paint.Fill()
        Endif 
        Paint.End 
        
      Else If String.InStr(T, "-3xwheel") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        Img2 = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        
        ''Wheel 3x:
        imgTemp = M07Paint.ClockGearWheel() 'as Image
        Img2 = imgTemp.Stretch(U * 10, U * 10).Copy()
        Paint.DrawImage(Img2, -U * 1.85, -U * 0.5)
        Img2 = imgTemp.Stretch(U * 6.75, U * 6.75).Copy()
        Paint.DrawImage(Img2, U * 2.95, -U * 0.75)
        Img2 = imgTemp.Stretch(U * 11, U * 11).Copy()
        Paint.DrawImage(Img2, U * 0.5, U * 0.85)
        
        Paint.End 
      Endif 
    Endif 'technicalwheel
    
    If String.InStr(T, "-flower") > 0 Then 
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      ''Gearwheel ▲
      Paint.Begin(Img)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      Paint.LineWidth = U * 0.15
      ''Lines, Pointer, Parts - | -
      a = U * 5 'X▶, Middle, Center, start-point
      b = U * 5 'Y▼
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      ' iStep = 30
      If String.InStr(T, "-4x") > 0 Then 
        For itF = iStep To 360 Step iStep 
          alpha = Rad(itF)
          Radius = c * 0.35 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 1.75)     
        Next 'it
      Else 
        For itF = iStep To 360 Step iStep  
          alpha = Rad(itF)
          Radius = c * 0.45 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.75)   
          ' Paint.Arc(MX2, MY2, c * 0.1, Rad(itF - 90), Rad(180), False) ''
        Next 'it 
      Endif 
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.Brush = Paint.Color(iColorChange1)
      If String.InStr(T, "-stroke") > 0 Then 
        Paint.LineWidth = U * 0.25
        Paint.Stroke()
      Else 
        Paint.LineWidth = U * 0.5
        Paint.Stroke(True)
        ' Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
      Endif
      
      Paint.End
    Else If String.InStr(T, "-insidecircle") > 0 Then 
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      ''Gearwheel ▲
      Paint.Begin(Img)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      ''circle
      Paint.Arc(U * 5, U * 5, U * 2)
      
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      If String.InStr(T, "-stroke") > 0 Then
        Paint.Stroke()
      Else 
        Paint.Stroke(True)
        Paint.Fill()
      Endif 
      Paint.End 
    Endif
    
    If String.InStr(T, "-wheelflower") > 0 Then 
      Img = New Image(iIconSize, iIconSize, Color.Transparent)
      ''Gearwheel ▲
      Paint.Begin(Img)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      ' Paint.LineWidth = U * 0.15
      ''Lines, Pointer, Parts - | -
      a = U * 5 'X▶, Middle, Center, start-point
      b = U * 5 'Y▼
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''Hours 4x      Rad(0) = 03:00
      ''Minutes 4x, 4x, ...
      ' iStep = 30
      For itF = iStep To 360 Step iStep  
        alpha = Rad(itF)
        Radius = c * 0.45 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.75)   
        ' Paint.Arc(MX2, MY2, c * 0.1, Rad(itF - 100), Rad(200), False) ''
      Next 'it 
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.Brush = Paint.Color(iColorChange1)
      If String.InStr(T, "-stroke") > 0 Then 
        Paint.LineWidth = U * 0.25
        Paint.Stroke()
      Else 
        Paint.LineWidth = U * 0.5
        Paint.Stroke(True)
        ' Paint.Brush = Paint.Color(Color.White)
        Paint.Fill()
      Endif
      ''cut:
      Paint.Arc(U * 5, U * 5, U * 3)
      Paint.Operator = Paint.OperatorClear
      Paint.LineWidth = U * 0.5
      Paint.Fill()
      
      Paint.End
    Endif  
    
    If String.InStr(T, "-earth") > 0 Then 
      If String.InStr(T, "-globe-y") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.2
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 30
        For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.425 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
          Radius = c * 0.525 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2)
        Next 'it
        Paint.Arc(U * 5, U * 5, U * 3)
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke 
        Paint.End
      Else If String.InStr(T, "-points-y") > 0 Then 
        Img = New Image(iIconSize, iIconSize, Color.Transparent)
        ''Gearwheel ▲
        Paint.Begin(Img)
        Paint.AntiAlias = bAntiAliasON                                                               '...----...
        Paint.LineCap = iLineEndType
        Paint.LineJoin = iLineEndType   
        Paint.LineWidth = U * 0.2
        ''Lines, Pointer, Parts - | -
        a = U * 5 'X▶, Middle, Center, start-point
        b = U * 5 'Y▼
        c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
        ''Hours 4x      Rad(0) = 03:00
        ''Minutes 4x, 4x, ...
        iStep = 30
        For itF = iStep To 360 Step iStep  'Minutes [03:00, 03:01, 03:02, 03:03, 03:04, 04:00], ...
          alpha = Rad(itF)
          Radius = c * 0.6 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
        Next 'it
        ' Paint.Arc(U * 5, U * 5, U * 3)
        Paint.Brush = Paint.Color(iColorChange1)
        Paint.Stroke(True)
        Paint.Fill()
        Paint.End
      Endif 
    Endif 
    
    If String.InStr(T, "-timeclocknumbers") > 0 Then 
      If String.InStr(T, "-01") > 0 Then 
        T = T & "-freesans-small-gray-radius6-nowhite"
      Else If String.InStr(T, "-02") > 0 Then 
        T = T & "-freesans-small-blue-radius5-nowhite"
      Else If String.InStr(T, "-03") > 0 Then
        T = T & "-sawasdee-small-darkgray-radius4-nowhite"
      Else If String.InStr(T, "-04") > 0 Then  
        T = T & "-sawasdee-small-darkgray-radius3-nowhite"
      Else If String.InStr(T, "-05") > 0 Then  
        T = T & "-sawasdee-darkgray-middle-radius6-nowhite"
      Else If String.InStr(T, "-06") > 0 Then  
        T = T & "-sawasdee-middle-radius6-bold"
      Else If String.InStr(T, "-07") > 0 Then  
        T = T & "-sawasdee-blue-middle-radius8"
      Else If String.InStr(T, "-08") > 0 Then 
        T = T & "-sawasdee-green-middle-radius8-nowhite"
      Else If String.InStr(T, "-09") > 0 Then 
        T = T & "-sawasdee-darkgray-small-radius8-nowhite-numbers4x"
      Else If String.InStr(T, "-10") > 0 Then 
        T = T & "-sawasdee-darkgray-small-radius7-nowhite-numbers4x"
      Else If String.InStr(T, "-11") > 0 Then 
        T = T & "-sawasdee-darkgray-small-radius6-nowhite-numbers4x"
      Else If String.InStr(T, "-12") > 0 Then 
        T = T & "-sawasdee-darkgray-small-radius5-nowhite-numbers4x"    
      Else If String.InStr(T, "-13") > 0 Then 
        T = T & "-sawasdee-darkgray-small-radius4-nowhite-numbers4x"    
      Endif
      
      ''will be change automatically: 0-1-2-...or 12-13-14-...
      ''Example: hPicture = M07Paint.ClockNumbers(dateTime, "-freesans-small-blue-radius6").Picture
      ''sTag: Font-Name: ubuntu*condensed, ubuntu*thin, freesans, sawasdee, Font-Size: big, middle, small, Font-Color: blue, gray, darkgray, green, Font-Bold: bold, Font-Circle: radius3, radius4, radius5, radius6, radius7, radius8, numbers4x, nowhite
      datetime = Form14UhrDesign.F_dateNow
      If Not datetime Then datetime = Now
      Form14UhrDesign.F_sTagsClockNumbers = T
      Img = M07Paint.ClockNumbers(datetime, T) 'as Image
    Endif
    
    it5 = it5 + 1
    Form14UhrDesign.F_sLastIconName = "gearwheel-7" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
  Next 'it3
  
  ''222222222222222222222222222222222222222222222222222222222222222222  22222
  For it2 = 0 To 40
    Select Case it2
      Case 0
        T = "-figure00"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorBlue
      Case 1
        T = "-figure01"
        iColorChange1 = iColorYellow
        iColorChange2 = iColorBlue
      Case 2
        T = "-figure02"
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 3
        T = "-figure03-convex"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite
      Case 4
        T = "-figure04-turninghandle"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite
      Case 5
        T = "-figure05"
        iColorChange1 = iColorYellow
        iColorChange2 = iColorWhite
      Case 6
        T = "-figure06"
        iColorChange1 = iColorYellow
        iColorChange2 = iColorWhite
      Case 7
        T = "-figure07"
        iColorChange1 = iColorWhite
        iColorChange2 = iColorGray
      Case 8
        T = "-figure08-numbers"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
      Case 9
        T = "-figure09"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorBlue
      Case 10
        T = "-figure10-numbers"
        iColorChange1 = iColorGreen
        iColorChange2 = iColorDarkGray
      Case 11
        T = "-figure11-numberstransparent"
        iColorChange1 = iColorWhite
        iColorChange2 = iColorDarkGray 
      Case 12
        T = "-figure12"
        iColorChange1 = iColorWhite
        iColorChange2 = iColorDarkGray 
      Case 13
        T = "-figure13"
        iColorChange1 = iColorGray
        iColorChange2 = iColorWhite
      Case 14
        T = "-figure14"
        iColorChange1 = iColorBlue
        iColorChange2 = iColorDarkGray
      Case 15
        T = "-figure15-numbers"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorDarkGray
      Case 16
        T = "-figure16-numbers"
        iColorChange1 = iColorGray
        iColorChange2 = iColorGray
      Case 17
        T = "-figure17"
        iColorChange1 = iColorYellow
        iColorChange2 = iColorYellow
      Case 18
        T = "-figure18-numbers"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorGray
      Case 19
        T = "-figure19"
        iColorChange1 = iColorDarkGray
        iColorChange2 = iColorGray
      Case 20
        T = "-figure20"
        iColorChange1 = iColorGray
        iColorChange2 = iColorWhite
        ''****************************
        
        ''Cutter:
      Case 21
        T = "-figure21-cutter-square"  '□
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 22
        T = "-figure22-cutter-ellipse" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 23
        T = "-figure23-cutter-circle" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 24
        T = "-figure24-cutter-rectangle-vertical" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 25
        T = "-figure25-cutter-rectangle-horizontal" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite  
      Case 26
        T = "-figure26-cutter-littlecircle" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite  
        
        ''Border:
      Case 27
        T = "-figure27-ellipse-border" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 28
        T = "-figure28-circle-border" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 29
        T = "-figure29-rectangle-vertical-border" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
      Case 30
        T = "-figure30-rectangle-horizontal-border" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite  
      Case 31
        T = "-figure31-littlecircle-border" 
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite  
      Case 32
        T = "-figure32-square-border"  '□
        iColorChange1 = iColorWhite
        iColorChange2 = iColorWhite
        ''****************************
        
      Case 33
        T = "-figure33-spuare" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 34
        T = "-figure34-Rectangle" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 35
        T = "-figure35-Rectangle" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 36
        T = "-figure36-ellipse" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite 
      Case 37
        T = "-figure37-circle" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 38
        T = "-figure38-triangle" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 39
        T = "-figure39-square-big" 
        iColorChange1 = iColorBlue
        iColorChange2 = iColorWhite  
      Case 40
        T = "-figure40-stones" 
        iColorChange1 = iColorGray
        iColorChange2 = iColorWhite  
    End Select 
    
    Img = New Image(iIconSize, iIconSize, Color.Transparent)  
    Paint.Begin(Img)
    Paint.AntiAlias = bAntiAliasON                                                               '...----...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    'Paint.Translate(U * 2, U * 2)
    'Paint.Scale(0.8, 0.8)
    'Paint.Rotate(Rad(-90))
    
    If InStr(T, "-button") > 0 Then 
      Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R)
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorBlue)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    ' If InStr(T, "-squareborder") > 0 Then 
    '   ''background button
    '   Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R * 2)
    '   
    '   If FMain.F_bWhiteBorderON = True Then
    '     Paint.LineWidth = U * 2
    '     Paint.Brush = Paint.Color(Color.White)
    '     Paint.Stroke(True)
    '   Endif
    '   Paint.LineWidth = U * 1
    '   Paint.Brush = Paint.Color(iColorGreen)
    '   Paint.Stroke(True)
    '   ' Paint.Fill()
    '   
    '   ''Mask (Schablone)
    '   Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R * 2)
    '   tmpImg = tmpImg.Stretch(U * 8, U * 8)
    '   Paint.Brush = Paint.Image(tmpImg, (Img.W / 2) - (tmpImg.W / 2), (Img.H / 2) - (tmpImg.H / 2)) 'center
    '   Paint.Fill()
    ' Endif 
    
    If InStr(T, "-cutter") > 0 Then 
      ''Cut outside □
      Paint.FillRect(U * 0, U * 0, U * 10, U * 10, iColorCut)
      
      If InStr(T, "-square") > 0 Then 
        Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R * 2)
        
      Else If InStr(T, "-ellipse") > 0 Then 
        Paint.Ellipse(U * 1, U * 0, U * 8, U * 10)
        
      Else If InStr(T, "-circle") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 4.5)
        
      Else If InStr(T, "-rectangle-vertical") > 0 Then 
        Paint.Rectangle(U * 2, -U * 1, U * 6, U * 12, R * 2)
        
      Else If InStr(T, "-rectangle-horizontal") > 0 Then 
        Paint.Rectangle(-U * 1, U * 2, U * 12, U * 6, R * 2)
        
      Else If InStr(T, "-littlecircle") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3.5)
      Endif 
      Paint.LineWidth = U * 2
      Paint.Brush = Paint.Color(iColorCut)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Fill()
      Paint.Operator = Paint.OperatorOver 'Default, Reset
    Endif 
    
    If InStr(T, "-border") > 0 Then 
      If InStr(T, "-square") > 0 Then 
        Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R * 2)
        
      Else If InStr(T, "-ellipse") > 0 Then 
        Paint.Ellipse(U * 1, U * 0, U * 8, U * 10)
        
      Else If InStr(T, "-circle") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 4.5)
        
      Else If InStr(T, "-rectangle-vertical") > 0 Then 
        Paint.Rectangle(U * 2, -U * 1, U * 6, U * 12, R * 2)
        
      Else If InStr(T, "-rectangle-horizontal") > 0 Then 
        Paint.Rectangle(-U * 1, U * 2, U * 12, U * 6, R * 2)
        
      Else If InStr(T, "-littlecircle") > 0 Then 
        Paint.Arc(U * 5, U * 5, U * 3.5)
        
      Endif 
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.LineWidth = U * 2
      Paint.Stroke()
    Endif 
    
    If InStr(T, "-figure00") > 0 Then 
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 4)
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        ' Radius = c * 0.5 '>Line length
        ' MX1 = a + (Radius * Cos(alpha))
        ' MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.56 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
        'Paint.MoveTo(MX1, MY1)
        'Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.8
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 3.25)
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Cut
      For itF = L / 2 To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.56 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.75)                                                      'Punkt, Point(X2,Y2)
      Next
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure01") > 0 Then 
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 3.5)
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(Color.White)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        ' Radius = c * 0.6 '>Line length
        ' MX1 = a + (Radius * Cos(alpha))
        ' MY1 = b + (Radius * Sin(alpha))
        Radius = c * 0.4 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        ' Paint.Arc(MX1, MY1, U * 0.25)
        Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
        'Paint.MoveTo(MX1, MY1)
        'Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.8
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
      
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        ' Radius = c * 0.4 '>Line length
        ' MX2 = a + (Radius * Cos(alpha))
        ' MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX1, MY1, U * 0.25)
        ' Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
        'Paint.MoveTo(MX1, MY1)
        'Paint.LineTo(MX2, MY2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.8
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 3.25)
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Cut
      For itF = L / 2 To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.5 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
      Next
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure02") > 0 Then 
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 5)
      Paint.LineWidth = U * 0.75
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      ''●●●●
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.8)                                                      'Punkt, Point(X2,Y2)
      Next
      ' If bWhiteBorderON = True Then
      ' Paint.LineWidth = U * 0.5
      ' Paint.Brush = Paint.Color(Color.White)
      ' Paint.Stroke(True)
      ' Endif
      Paint.LineWidth = U * 0.1
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure03") > 0 Then 
      ''Circle ●
      Paint.Arc(U * 5, U * 5, U * 4.5)
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      
      ''Cut
      For itF = L / 2 To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.7 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 1)                                                      'Punkt, Point(X2,Y2)
      Next
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure04") > 0 Then 
      ''Circle 
      Paint.Arc(U * 5, U * 5, U * 4.5)
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 60
      
      ''Cut
      For itF = L / 2 To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.7 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 1)                                                      'Punkt, Point(X2,Y2)
      Next
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure05") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Ellipse(U * 4, U * 1, U * 2, U * 4)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      Paint.End
      
      L = 90
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif 
    
    If InStr(T, "-figure06") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Ellipse(U * 4.5, U * 1, U * 1, U * 3)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
      Paint.End
      
      L = 30
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next  
      
      Paint.Arc(U * 5, U * 5, U * 1) '●
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill() 
    Endif 
    
    If InStr(T, "-figure07") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Ellipse(U * 4.5, U * 1, U * 1, U * 2)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      Paint.Arc(U * 5, U * 5, U * 2) '●
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      
      L = 30
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif
    
    If InStr(T, "-figure08") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      ''●●●●
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.8)                                                      'Punkt, Point(X2,Y2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.8
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.4
      Paint.Brush = Paint.Color(iColorChange1)
      ' Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
      
      ''Font-Area:
      W = Paint.Font.TextWidth("00") / 2
      H = Paint.Font.TextHeight("00") / 2
      iNumber = 3
      fSizeMin = FMain.F_fFontSizePlus + U * 1
      
      ''Clock-Numbers:
      For itF = L To 360 Step L '0=360°=15:00h  0h (=12h=24h) = -90°, begin with 1 =-60° 
        iNumber = iNumber + 1
        If iNumber > 12 Then iNumber = 1
        alpha = Rad(itF)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 1
        fSizeMin = fSizeMin - (U * 0.01)
        If fSizeMin < 2 Then fSizeMin = 2
        Paint.Font.Size = fSizeMin
        Paint.Text(Str(iNumber), MX1 - (W / 2), MY1 - (H / 2), W, H, Align.Center) ' |
        Paint.Font.Name = "Ubuntu Condensed"
        Paint.Font.Bold = False
        ' Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 1
        Paint.LineWidth = U * 0.1
        Paint.Brush = Paint.Color(iColorChange2)
        Paint.Stroke(True)
        Paint.Fill()
      Next 
    Endif 
    
    If InStr(T, "-figure09") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      L = 30
      ''●●●●
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 1)                                                      'Punkt, Point(X2,Y2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.1
      Paint.Brush = Paint.Color(iColorChange1)
      ' Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke()
      ' Paint.Fill()
    Endif 
    
    If InStr(T, "-figure10") > 0 Then 
      ''Font-Area:
      W = Paint.Font.TextWidth("00") / 2
      H = Paint.Font.TextHeight("00") / 2
      L = 30
      iNumber = 3
      fSizeMin = FMain.F_fFontSizePlus + U * 1
      
      ''Clock-Numbers:
      For itF = L To 360 Step L '0=360°=15:00h  0h (=12h=24h) = -90°, begin with 1 =-60° 
        iNumber = iNumber + 1
        If iNumber > 12 Then iNumber = 1
        alpha = Rad(itF)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        
        If iNumber > 9 Then 
          fSizeMin = fSizeMin - (U * 0.01)
          If fSizeMin < 2 Then fSizeMin = 2
        Endif 
        Paint.Font.Size = fSizeMin
        Paint.Text(Str(iNumber), MX1 - (W / 2), MY1 - (H / 2), W, H, Align.Center) ' |
        Paint.Font.Name = "Ubuntu Condensed"
        Paint.Font.Bold = False
        ' Try Paint.Font.Size = FMain.F_fFontSizePlus + U * 1
        Paint.LineWidth = U * 0.1
        Paint.Brush = Paint.Color(iColorChange2)
        Paint.Stroke(True)
        Paint.Fill()
      Next 
      
    Endif   
    
    If InStr(T, "-figure11") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      
      ''Font-Area:
      W = Paint.Font.TextWidth("00") / 2
      H = Paint.Font.TextHeight("00") / 2
      L = 30
      iNumber = 3
      ''Clock-Numbers-Background-Circle ●
      For itF = L To 360 Step L '0=360°=15:00h  0h (=12h=24h) = -90°, begin with 1 =-60° 
        iNumber = iNumber + 1
        If iNumber > 12 Then iNumber = 1
        alpha = Rad(itF)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Paint.Arc(MX1, MY1, U * 0.75)
      Next 
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.4
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.2
      Paint.Brush = Paint.Color(iColorChange1)
      ' Paint.Operator = Paint.OperatorAdd
      Paint.Stroke(True)
      Paint.Fill() 
      
      iNumber = 3
      Paint.Font.Name = "Ubuntu Condensed"
      Paint.Font.Bold = True
      fSizeMin = FMain.F_fFontSizePlus + U * 1
      
      ''Clock-Numbers Cut ○
      For itF = L To 360 Step L '0=360°=15:00h  0h (=12h=24h) = -90°, begin with 1 =-60° 
        iNumber = iNumber + 1
        If iNumber > 12 Then iNumber = 1
        alpha = Rad(itF)   '00:00=-90°
        Radius = c * 0.6 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        
        If iNumber > 9 Then 
          fSizeMin = fSizeMin - (U * 0.01)
          If fSizeMin < 2 Then fSizeMin = 2
        Endif 
        Paint.Text(Str(iNumber), MX1 - (W / 2), MY1 - (H / 2), W, H, Align.Center) ' 
        Paint.LineWidth = U * 0.1
        Paint.Brush = Paint.Color(iColorMenuGray)
        Paint.Operator = Paint.OperatorClear 'Cut, Transparent
        Paint.Stroke(True)
        Paint.Fill()
      Next 
    Endif  
    
    If InStr(T, "-figure12") > 0 Then 
      ''Lines, Pointer, Parts - | -
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      ''concave () or convex )(
      ''Hours 12x
      
      Paint.Arc(U * 5, U * 5, U * 5)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.75
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorGray)
      Paint.Stroke(True)
      Paint.Fill()
      
      L = 30
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.6 '>Line length
        MX2 = a + (Radius * Cos(alpha))
        MY2 = b + (Radius * Sin(alpha))
        Paint.Arc(MX2, MY2, U * 0.5)                                                      'Punkt, Point(X2,Y2)
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.85
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure13") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Ellipse(U * 4.5, U * 1, U * 1, U * 2)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      Img3 = Img2.Stretch(U * 9, U * 9).Copy()
      
      L = 30
      iNumber = 3
      For itF = L To 360 Step L 
        iNumber = iNumber + 1
        If iNumber Mod 3 = 0 Then 
          imgTemp = Img2.Copy()
          imgTemp = imgTemp.Rotate(Rad(itF))
          Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
        Else 
          imgTemp = Img3.Copy()
          imgTemp = imgTemp.Rotate(Rad(itF))
          Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀ 
        Endif 
      Next   
      
      Paint.Arc(U * 5, U * 5, U * 1) '●
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorMenuGray)
      Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Fill()
    Endif
    
    If InStr(T, "-figure14") > 0 Then 
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      L = 30
      iNumber = 3
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        iNumber = iNumber + 1 
        If iNumber Mod 3 = 0 Then
          alpha = Rad(itF)
          Radius = c * 0.6 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Paint.Arc(MX1, MY1, U * 0.25) '●
        Endif 
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.25
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      ' Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke(True) '○
      Paint.Fill() '●
      
      iNumber = 3
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        iNumber = iNumber + 1 
        If iNumber Mod 3 = 0 Then
          '...
        Else 
          alpha = Rad(itF)
          Radius = c * 0.6 '>Line length
          MX1 = a + (Radius * Cos(alpha))
          MY1 = b + (Radius * Sin(alpha))
          Radius = c * 0.4 '>Line length
          MX2 = a + (Radius * Cos(alpha))
          MY2 = b + (Radius * Sin(alpha))
          Paint.MoveTo(MX1, MY1)
          Paint.LineTo(MX2, MY2) '——
        Endif 
      Next
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange2)
      ' Paint.Operator = Paint.OperatorClear 'Cut, Transparent
      Paint.Stroke()
    Endif
    
    If InStr(T, "-figure15") > 0 Then 
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      L = 30
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.52 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Paint.Arc(MX1, MY1, U * 0.08) '●
      Next
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True) '○
      Paint.Fill() '●
    Endif
    
    If InStr(T, "-figure16") > 0 Then 
      a = U * 5 'Middle, Center, start-point
      b = U * 5
      c = Sqr(a ^ 2 + b ^ 2) 'Phythagoras
      L = 30
      For itF = L To 360 Step L  'Hours  03:00: 06:00, 09:00, ..., 12:00 (=24:00)
        alpha = Rad(itF)
        Radius = c * 0.48 '>Line length
        MX1 = a + (Radius * Cos(alpha))
        MY1 = b + (Radius * Sin(alpha))
        Paint.Arc(MX1, MY1, U * 0.25) '●
      Next
      Paint.LineWidth = U * 0.1
      Paint.Brush = Paint.Color(iColorChange2)
      Paint.Stroke(True) '○
      Paint.Fill() '●
    Endif
    
    If InStr(T, "-figure17") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Ellipse(U * 4, U * 1, U * 2, U * 4)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.5
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      ' Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      L = 90
      For itF = L / 2 To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif 
    
    If InStr(T, "-figure18") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Arc(U * 5, U * 2, U * 1, Rad(-100), Rad(20), True)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      ' Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      L = 30
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif 
    
    If InStr(T, "-figure19") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.Arc(U * 5, U * 2, U * 1, Rad(-100), Rad(20), False)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 0.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.25
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      ' Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      L = 30
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif 
    
    If InStr(T, "-figure20") > 0 Then 
      Img2 = New Image(iIconSize, iIconSize, Color.Transparent)  
      Paint.Begin(Img2)
      Paint.AntiAlias = bAntiAliasON                                                               '...----...
      Paint.LineCap = iLineEndType
      Paint.LineJoin = iLineEndType   
      
      Paint.MoveTo(U * 5, U * 2)
      Paint.LineTo(U * 5, U * 1) '|
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 1.5
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 0.75
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      ' Paint.Brush = Paint.Color(iColorChange2)
      Paint.Fill()
      Paint.End
      
      L = 30
      For itF = L To 360 Step L 
        imgTemp = Img2.Copy()
        imgTemp = imgTemp.Rotate(Rad(itF))
        Paint.DrawImage(imgTemp, (Img.W / 2) - (imgTemp.W / 2), (Img.H / 2) - (imgTemp.H / 2)) '▶Center◀
      Next   
    Endif 
    
    '' -figure21 ——▶Cutter and Border
    
    If InStr(T, "-figure33") > 0 Then '▪
      Paint.Rectangle(U * 2.5, U * 2.5, U * 5, U * 5, R)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure34") > 0 Then '■
      Paint.Rectangle(U * 2.5, U * 1, U * 5, U * 8, R * 2)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure35") > 0 Then '■
      Paint.Rectangle(U * 1.5, U * 1, U * 7, U * 8, R * 2)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure36") > 0 Then '0
      Paint.Ellipse(U * 1.5, U * 1, U * 7, U * 8)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure37") > 0 Then '●
      Paint.Arc(U * 5, U * 5, U * 4)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure38") > 0 Then '▲
      Paint.MoveTo(U * 5, U * 1)
      Paint.LineTo(U * 9, U * 9)
      Paint.LineTo(U * 1, U * 9)
      Paint.ClosePath
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure39") > 0 Then '▪
      Paint.Rectangle(U * 1, U * 1, U * 8, U * 8, R)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    If InStr(T, "-figure40") > 0 Then '■ ■■
      Paint.Rectangle(U * 1, U * 1, U * 8, U * 1.5, R)
      Paint.Rectangle(U * 1, U * 4, U * 2, U * 5, R)
      Paint.Rectangle(U * 6, U * 4, U * 3, U * 5, R)
      
      If bWhiteBorderON = True Then
        Paint.LineWidth = U * 2
        Paint.Brush = Paint.Color(Color.White)
        Paint.Stroke(True)
      Endif
      Paint.LineWidth = U * 1
      Paint.Brush = Paint.Color(iColorChange1)
      Paint.Stroke(True)
      Paint.Fill()
    Endif 
    
    Paint.End
    it5 = it5 + 1
    
    Form14UhrDesign.F_sLastIconName = "clock" & String.LCase(T) & "-" & Str(it5)
    Form14UhrDesign.F_imgLastIconImage = Img
    If bIconThemeAllAddON = False Then Form14UhrDesign.IconListAdd() Else Return Img.Picture 'Return and > Ends here
    If Form14UhrDesign.F_bESCpressedON = True Then Break
  Next 'it2
  Return Img.Picture
  
Catch
  FMain.ErrorText
  
End 'CreateIconClock()



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form11Breitengrade.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form11Breitengrade.class
23,0 KB
' Gambas class file

Public F_bMovingON As Boolean
Public F_iABCObjectNr As Integer
Public F_iABCObjectNrUndo As Integer
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iColorSelectYellow150 As Integer = Color.SetAlpha(Color.Yellow, 150)
Public F_iOnly1x As Integer
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_ooABCObjects As Object[]
Public F_sExampleOsloBehind As String 
Public F_sForm As String = Me.Name 
Public F_sNordOstNotiz As String 
Public F_sNordOstNotizUndo As String

Public Function FilePathForm() As String '.txt
  
  Return Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf] 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.Esc Then Me.Close
  
  Catch 
    FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch
  FMain.ErrorText
  
End

Public Sub PaintBreitenLaengengrade()
  
  Dim U, fDis, fNr, fStep As Float 
  Dim Img As Image 
  
  Img = New Image(PicBoxBreitengrade.W, PicBoxBreitengrade.H, Color.Transparent)
  U = LabelR1.W / 10
  fDis = LabelR6.Top - (LabelR1.Top + LabelR1.H)
  
  Paint.Begin(Img)
  Paint.AntiAlias = True 
  Paint.LineCap = Paint.LineCapRound 'as Integer=1
  
  Paint.MoveTo(0, LabelR1.Top - fDis)
  Paint.LineTo(PicBoxBreitengrade.W, LabelR1.Top - fDis)  '—————
  
  Paint.MoveTo(0, LabelR6.Top - fDis)
  Paint.LineTo(PicBoxBreitengrade.W, LabelR6.Top - fDis)
  
  Paint.MoveTo(0, LabelR11.Top - fDis)
  Paint.LineTo(PicBoxBreitengrade.W, LabelR11.Top - fDis)
  
  Paint.MoveTo(0, LabelR16.Top - fDis)
  Paint.LineTo(PicBoxBreitengrade.W, LabelR16.Top - fDis)
  
  Paint.MoveTo(0, PicBoxBreitengrade.H - fDis)
  Paint.LineTo(PicBoxBreitengrade.W, PicBoxBreitengrade.H - fDis)
  
  fStep = LabelR1.H / 4
  For fNr = 0 To PicBoxBreitengrade.H Step fStep
    Paint.MoveTo(0, fNr)
    Paint.LineTo(fStep, fNr)
  Next
  
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.15
  Paint.Brush = Paint.Color(Color.Green)
  Paint.Stroke()
  
  Paint.End
  PicBoxBreitengrade.Picture = Img.Picture
  
  Img = New Image(PicBoxBreitengrade.W, PicBoxBreitengrade.H, Color.Transparent)
  Paint.Begin(Img)
  Paint.AntiAlias = True 
  Paint.LineCap = Paint.LineCapRound 'as Integer=1
  
  Paint.MoveTo(LabelR1.Left - fDis, 0)
  Paint.LineTo(LabelR1.Left - fDis, PicBoxBreitengrade.H) '||||||
  
  Paint.MoveTo(LabelR2.Left - fDis, 0)
  Paint.LineTo(LabelR2.Left - fDis, PicBoxBreitengrade.H)
  
  Paint.MoveTo(LabelR3.Left - fDis, 0)
  Paint.LineTo(LabelR3.Left - fDis, PicBoxBreitengrade.H)
  
  Paint.MoveTo(LabelR4.Left - fDis, 0)
  Paint.LineTo(LabelR4.Left - fDis, PicBoxBreitengrade.H)
  
  Paint.MoveTo(LabelR5.Left - fDis, 0)
  Paint.LineTo(LabelR5.Left - fDis, PicBoxBreitengrade.H)
  
  Paint.MoveTo(PicBoxBreitengrade.W - fDis, 0)
  Paint.LineTo(PicBoxBreitengrade.W - fDis, PicBoxBreitengrade.H)
  
  fStep = LabelR1.W / 4
  For fNr = 0 To PicBoxBreitengrade.W Step fStep
    Paint.MoveTo(fNr, 0)
    Paint.LineTo(fNr, fStep)
  Next
  
  Paint.LineWidth = U * 0.25
  Paint.Brush = Paint.Color(Color.White)
  Paint.Stroke(True)
  Paint.LineWidth = U * 0.15
  Paint.Brush = Paint.Color(Color.Blue)
  Paint.Stroke()
  
  Paint.End
  PicBoxLaengengrade.Picture = Img.Picture
  
Catch
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() '▼Level Bottom▼
  PicBoxMapEurope.Lower()
  WindowStretch.Raise() '▲Level Top▲
  ButtonSave.Raise()
  IconError.Raise()
  
  PicBoxBreitengrade.Raise()
  PicBoxLaengengrade.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelsABCObjectsAdd()

  Dim it As Integer
  
  ''A-B-C-D-E....
  F_ooABCObjects = New Object[]
  For it = 0 To PanelABC.Children.Max
    If Object.Type(PanelABC.Children[it]) = "Label" Then 
      ' PanelABC.Children[it].Padding = 3
      F_ooABCObjects.Add(PanelABC.Children[it])
    Endif
  Next
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPH, iDis As Integer
  Dim fPartW As Float
  
  If Form11Breitengrade.Width < 200 Then Form11Breitengrade.Width = 200
  If Form11Breitengrade.Height < 200 Then Form11Breitengrade.Height = 200
  
  PicBackground.Move(0, 0, Form11Breitengrade.ClientW, Form11Breitengrade.ClientH)
  iW = PicBackground.Width / 100 * 3 ' Randbreite
  iH = PicBackground.Height / 100 * 3
  iPH = TextNotiz.Font.TextHeight("Region M") * 1.25
  iDis = iPH
  
  IconError.Move(Form11Breitengrade.Window.W - 32, 0, 32, 32)
  PicBoxSunUpDown.Move(iW, iH, iPH, iPH)
  LabelOslo.Move(PicBoxSunUpDown.Left + PicBoxSunUpDown.W, PicBoxSunUpDown.Top, PicBackground.W - (PicBoxSunUpDown.Left + PicBoxSunUpDown.W) - iW, PicBoxSunUpDown.H)
  PanelABC.Move(iW, PicBoxSunUpDown.Top + PicBoxSunUpDown.H, PicBackground.W - (iW * 2), PicBackground.H - (iPH * 3.75) - (iH * 2))
  PicBoxMapEurope.Move(0, 0, PanelABC.Width, PanelABC.Height)
  
  ' ''A-B-C-D-E....
  ' If Not F_ooABCObjects Then LabelsABCObjectsAdd()
  ' If F_ooABCObjects Then 
  '   fPartW = PanelABC.W / 5
  '   fPartH = PanelABC.H / 4
  '   iLeft = -1 'begin with 0
  '   For it = 0 To F_ooABCObjects.Max
  '     If iLeft = 4 Then 
  '       iLeft = 0
  '       iTop = iTop + 1 
  '     Else 
  '       iLeft = iLeft + 1 
  '     Endif 
  '     F_ooABCObjects[it].Move(iLeft * fPartW, iTop * fPartH, fPartW, fPartH)
  '     ' PanelABC.Children[it].Padding = 3
  '   Next
  ' Endif 
  
  ''Menu:
  PanelSave.Move(PanelABC.Left, PanelABC.Top + PanelABC.H + (iPH * 0.25), PanelABC.W, iPH * 2.5)
  fPartW = PanelSave.W / 10 
  TextNord.Move(0, 0, (fPartW * 2.5) - iDis, iPH)
  Label0Plus.Move(TextNord.Left + TextNord.W, 0, iDis, iPH)
  TextOst.Move(Label0Plus.Left + Label0Plus.W, 0, (fPartW * 2.5) - iDis, iPH)
  Label1Plus.Move(TextOst.Left + TextOst.W, 0, iDis, iPH)
  TextNotiz.Move(Label1Plus.Left + Label1Plus.W, 0, PanelSave.W - (Label1Plus.Left + Label1Plus.W), iPH)
  Label1.Move(TextNord.Left, TextNord.Top + TextNord.H, TextNord.W, iPH / 2)
  Label0.Move(TextOst.Left, TextOst.Top + TextOst.H, TextOst.W, iPH / 2)
  Label2.Move(TextNotiz.Left, TextNotiz.Top + TextNotiz.H, TextNotiz.W, iPH / 2)
  ButtonSave.Move(0, Label1.Top + Label1.H, PanelSave.W * 0.65, PanelSave.H - (Label1.Top + Label1.H))
  ButtonCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, PanelSave.W - (ButtonSave.Left + ButtonSave.W), ButtonSave.H)
  
  ''Lines |||||
  PicBoxBreitengrade.Move(PicBoxMapEurope.Left, PicBoxMapEurope.Top, PicBoxMapEurope.W, PicBoxMapEurope.H) '◀——▶
  PicBoxLaengengrade.Move(PicBoxMapEurope.Left, PicBoxMapEurope.Top, PicBoxMapEurope.W, PicBoxMapEurope.H) '|||||
  
  WindowStretch.Move(Form11Breitengrade.ClientW - iPH - iW, Form11Breitengrade.ClientH - iPH - iH, iPH, iPH) 'quadratisch
  If F_bMovingON = False Then RaiseOrder()
  ResizeLabelsABC()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizeLabelsABC()

  Dim fPartW, fPartH As Float 
  Dim it, iLeft, iTop As Integer
  
  ''A-B-C-D-E....
  If Not F_ooABCObjects Then LabelsABCObjectsAdd()
  
  If F_ooABCObjects Then 
    fPartW = PanelABC.W / 5
    fPartH = PanelABC.H / 4
    iLeft = -1 'begin with 0
    For it = 0 To F_ooABCObjects.Max
      If iLeft = 4 Then 
        iLeft = 0
        iTop = iTop + 1 
      Else 
        iLeft = iLeft + 1 
      Endif 
      F_ooABCObjects[it].Move(iLeft * fPartW, iTop * fPartH, fPartW, fPartH)
      ' PanelABC.Children[it].Padding = 3
    Next
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  ' M01Functions.FileGetMimeType(Settings.Path)
  ' Me.Icon = M01Functions.FileGetMimeTypeImageIcon(Settings.Path).Picture

  If Not Form11Breitengrade.Window.Icon Then Form11Breitengrade.Window.Icon = FMain.Window.Icon
  Form11Breitengrade.Window.Title = Application.Name & " - " & ("Astro")
  Form11Breitengrade.Window.Visible = False 
  Menu1.Visible = False
  
  SettingsReadSave("read")
  FormBackgroundColor()
  LabelsABCObjectsAdd()
  'Next —▶Form_Resize()
  ''—▶Error???
  ' If Error.Text Then Message.Info(Error.Text)
  ' Desktop.Windows.Refresh 'QT5 "Aktualisiert die Liste aller Top-Level-Fenster"

Catch 
  FMain.ErrorText
  Form11Breitengrade.Window.Visible = True 
  
  ' Error (6): qt.qpa.wayland: Wayland does not support QWindow::requestActivate() 
  ' qt.qpa.wayland: Wayland unterstützt QWindow::requestActivate() nicht. Dies bedeutet, dass Ihr Fenster versucht hat, den Fokus im Compositor zu ergreifen, was in Wayland nicht zulässig ist. Erzeugen Sie keinen Fehler, wir können nichts dagegen tun.
  ' https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/288
  ' Kein Problem, Qt hat diese Funktion einfach nicht für die Wayland-Plattform implementiert. Jedes andere seltsame Verhalten in Bezug auf Docks kommt nicht von OBS, sondern von Qt selbst.
  ' https://github.com/obsproject/obs-studio/issues/6065
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText

End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    FormStart()
    Form11Breitengrade.Window.Visible = True 
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  Form11Breitengrade.Window.Visible = True 
  
End

Public Sub FormStart()
  Dim sDir, sFile, sDirFile As String
  'degree of latitude N-S
  'Not exactly Values (Grobe Werte Längengrad+Breitengrad+Ort) Atlas, Map, Globus, Internet...

  LabelR1.ToolTip = "20+65+Region A"
  LabelR2.ToolTip = "5+65+Region B"
  LabelR3.ToolTip = "10+65+Region C"
  LabelR4.ToolTip = "20+65+Region D"
  LabelR5.ToolTip = "35+65+Region E"
  LabelR6.ToolTip = "15+55+Region F"
  LabelR7.ToolTip = "0+52+Region G"
  LabelR8.ToolTip = "10+58+Region H"
  LabelR9.ToolTip = "20+55+Region I"
  LabelR10.ToolTip = "35+55+Region J"
  LabelR11.ToolTip = "5+45+Region K"
  LabelR12.ToolTip = "0+68+Region L"
  LabelR13.ToolTip = "10+50+Region M"
  LabelR14.ToolTip = "20+50+Region N"
  LabelR15.ToolTip = "25+45+Region O"
  LabelR16.ToolTip = "5+40+Region P"
  LabelR17.ToolTip = "5+45+Region Q"
  LabelR18.ToolTip = "8+42+Region R"
  LabelR19.ToolTip = "15+40+Region S"
  LabelR20.ToolTip = "25+37+Region T"
  
  sDir = "images"
  sFile = "europe_800.png"
  sDirFile = sDir &/ sFile  '"images/europe_800.png"
  If Exist(sDirFile) = True Then Try PicBoxMapEurope.Picture = Picture.Load(sDirFile) 

  F_iABCObjectNr = Settings[FMain.Name &/ "iLastEuropePositionABC", 12]  
  LabelsABCselectionReadOrSet("set")
  F_sNordOstNotiz = Settings[FMain.Name &/ "Astro/Laengengrad_Breitengrad", "10+50+Region M"]
  TextNordOstNotiz(F_sNordOstNotiz)
  
  WindowStretchCursor()
  
Catch 
  FMain.ErrorText

End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form3Text.Left]
      iY = Settings[F_sForm &/ "Top", Form3Text.Top]
      iW = Settings[F_sForm &/ "Width", Form3Text.W]
      iH = Settings[F_sForm &/ "Height", Form3Text.H]
      Form11Breitengrade.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form3Text.Left
      Settings[F_sForm &/ "Top"] = Form3Text.Top
      Settings[F_sForm &/ "Width"] = Form3Text.Width
      Settings[F_sForm &/ "Height"] = Form3Text.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSpeichernG()
  'Ergebnis = Settings[FMain.Name &/ "Astro/Laengengrad_Breitengrad", "10+50"] ' 10+50= gerundet ca. Fulda. Mitte zwischen Hamburg und München. 
  
  Settings[FMain.Name &/ "Astro/Laengengrad_Breitengrad"] = TextOst.Text & "+" & TextNord.Text & "+" & TextNotiz.Text
  Settings[FMain.Name &/ "iLastEuropePositionABC"] = F_iABCObjectNr
  FMain.F_bNeueinlesenStarten = True ' über Timer
  ButtonSave.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextOst_KeyPress()
  
  If String.InStr("0123456789", Key.Text) > 0 Or Key.Code = Key.BackSpace Or Key.Code = Key.Delete Then
    ' erlauben
    Label0.Foreground = Color.Default
    InputChanged()
  Else
    Label0.Foreground = Color.Red
    Stop Event 'Vorgang abbrechen
  Endif
  
  'If IsDigit("0123456789") = True then...
  'If IsLetter("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") = True then...
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextNord_KeyPress()
  
  If M01Functions.KeyPressCheck("0123456789", Key.Text, Key.Code) = True Then
    ' erlauben
    Label1.Foreground = Color.Default
    InputChanged()
  Else
    Label1.Foreground = Color.Red
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextNotiz_KeyPress()
  
  If Key.Code = Key.Return Then
    Stop Event 'Vorgang abbrechen
  Else
    InputChanged()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextNordOstNotiz(Optional sLabelTooltip As String = "")
  
  Dim sText, sNord, sOst, sNotiz As String
  Dim bChanged As Boolean
  
  sText = sLabelTooltip
  sNord = M01Functions.TextSplit(sText, 0, "+")
  sOst = M01Functions.TextSplit(sText, 1, "+")
  sNotiz = M01Functions.TextSplit(sText, 2, "+")
  
  If sNord <> TextNord.Text Then 
    TextNord.SelectAll
    TextNord.Insert(sNord)
    bChanged = True 
  Endif
  If sOst <> TextOst.Text Then 
    TextOst.SelectAll
    TextOst.Insert(sOst)
    bChanged = True 
  Endif
  If sNotiz <> TextNotiz.Text Then 'for undo 1x
    TextNotiz.SelectAll
    TextNotiz.Insert(sNotiz)
    bChanged = True 
  Endif
  
  If bChanged = True Then InputChanged()
  TextNotiz.Pos = String.Len(TextNotiz.Text)
  TextNotiz.SetFocus
  ButtonSave.Border = True  
  
Catch 
  FMain.ErrorText
  
End

Public Sub InputChanged()
  
  ButtonSave.Background = Color.Yellow
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelOsloG()
  
  Dim iNr As Integer
  
  iNr = LabelsABCselectionReadOrSet("read") 'as Integer
  
  If iNr <> 7 Then 
    F_iABCObjectNrUndo = iNr
    F_sNordOstNotizUndo = TextOst.Text & "+" & TextNord.Text & "+" & TextNotiz.Text
    F_iABCObjectNr = 7
    F_sNordOstNotiz = LabelOslo.Tooltip
  Else 
    F_iABCObjectNr = F_iABCObjectNrUndo
    F_sNordOstNotiz = F_sNordOstNotizUndo
    F_iABCObjectNrUndo = F_iABCObjectNr
  Endif
  
  LabelsABCselectionReadOrSet("set")  '◀—
  TextNordOstNotiz(F_sNordOstNotiz) '◀—
  
Catch 
  FMain.ErrorText
  
End

Public Function LabelsABCselectionReadOrSet(Optional sReadSet As String = "set") As Integer  
  
  Dim it As Integer
  
  ''Read areas case:
  If Not F_ooABCObjects Then 'A,B,C,...,T
    F_ooABCObjects = New Object[]
    For it = 0 To PanelABC.Children.Max
      If Object.Type(PanelABC.Children[it]) = "Label" Then F_ooABCObjects.Add(PanelABC.Children[it])
    Next
  Endif
  
  If sReadSet = "set" Then 
    ''Set selection:
    If F_ooABCObjects Then 
      For it = 0 To F_ooABCObjects.Max
        If it = F_iABCObjectNr Then 
          F_ooABCObjects[it].Background = F_iColorSelectBlue150
        Else 
          F_ooABCObjects[it].Background = Color.Default
        Endif 
      Next
    Endif 
  Else 
    ''Read selection:
    If F_ooABCObjects Then 
      For it = 0 To F_ooABCObjects.Max
        If F_ooABCObjects[it].Background = F_iColorSelectBlue150 Then 
          F_iABCObjectNr = it
          Break 
        Endif 
      Next
    Endif 
  Endif
  
  Return F_iABCObjectNr 'Example: 12 (= "M")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ABCGroup_MouseDown()
  
  Dim sLabelsText As String = "ABCDEFGHIJKLMNOPQRST"
  Dim iFound As Integer
  
  iFound = String.InStr(sLabelsText, Last.Text) 
  F_iABCObjectNr = iFound - 1
  LabelsABCselectionReadOrSet("set")
  TextNordOstNotiz(Last.ToolTip)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ABCGroup_Enter()
  
  If Last.Background <> F_iColorSelectBlue150 Then Last.Background = F_iColorSelectYellow150
  
Catch 
  FMain.ErrorText
  
End

Public Sub ABCGroup_Leave()
  
  If Last.Background <> F_iColorSelectBlue150 Then Last.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label1_Enter()
  
  PicBoxBreitengrade.Visible = True 
  Label1.Background = F_iColorSelectYellow150
  If Not PicBoxBreitengrade.Picture Then PaintBreitenLaengengrade()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label1_Leave()
  
  PicBoxBreitengrade.Visible = False
  Label1.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label0_Enter()
  
  PicBoxLaengengrade.Visible = True 
  Label0.Background = F_iColorSelectYellow150
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label0_Leave()
  
  PicBoxLaengengrade.Visible = False 
  Label0.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label2_Enter()
  
  If Object.IsValid(F_ooABCObjects[F_iABCObjectNr]) = True Then F_ooABCObjects[F_iABCObjectNr].Background = Color.Green 
  Label2.Background = F_iColorSelectYellow150
  If Not PicBoxBreitengrade.Picture Then PaintBreitenLaengengrade()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Label2_Leave()
  
  If Object.IsValid(F_ooABCObjects[F_iABCObjectNr]) = True Then F_ooABCObjects[F_iABCObjectNr].Background = F_iColorSelectBlue150
  PicBoxLaengengrade.Visible = False 
  Label2.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form11Breitengrade.Window.Maximized = Not Form11Breitengrade.Window.Maximized 
  If Form11Breitengrade.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form11Breitengrade.Window.FullScreen = True Or Form11Breitengrade.Window.Maximized = True Then 
      F_bMovingON = False
      Form11Breitengrade.Window.FullScreen = False
      Form11Breitengrade.Window.Maximized = False
      If Form11Breitengrade.Left + Form11Breitengrade.W > Screen.AvailableWidth Then Form11Breitengrade.Move(Form11Breitengrade.Left, Form11Breitengrade.Top, Screen.AvailableWidth - Form11Breitengrade.Left, Screen.AvailableHeight - Form11Breitengrade.Top)
    Else
      F_bMovingON = True
      Form11Breitengrade.Window.FullScreen = False
      Form11Breitengrade.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form11Breitengrade.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form11Breitengrade.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form11Breitengrade.ClientW - WindowStretch.W, Form11Breitengrade.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form11Breitengrade.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form11Breitengrade.W = Mouse.ScreenX - F_iX1
    Form11Breitengrade.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form11Breitengrade.ClientW - WindowStretch.W, Form11Breitengrade.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form11Breitengrade.ClientW - WindowStretch.W, Form11Breitengrade.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form11Breitengrade.Window.Maximized = Not Form11Breitengrade.Window.Maximized 
    If Form11Breitengrade.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form11Breitengrade.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True 
  If Object.Type(Last) = "Label" And Last.Tag = LabelOslo.Tag Then Last.Background = F_iColorSelectGreen150
  If Last.Tag = ButtonSave.Tag Then Last.Background = F_iColorSelectBlue150
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False 
  Last.Background = Color.Default
  If Object.Type(Last) = "PictureBox" And Last.Tag = PicBoxSunUpDown.Tag Then Last.Background = F_iColorSelectBlue150
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  Select Case String.LCase(sLastTag)
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      Form11Breitengrade.Window.Close
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "oslo"
      LabelOsloG()
    Case "save"
      ButtonSpeichernG()
    Case "resetform"
      M01Functions.ResetForm(F_sForm)  
    Case "cancel", "close"
      Form11Breitengrade.Window.Close
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '...........................

Public Sub Label1_MouseDown()

  

End



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/M06InfoText.module
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/M06InfoText.module
11,7 KB
' Gambas module file

Public Sub InfoText()
  
  Dim sText, sDir, sFile, sDirFile, sHTML As String 
  
  sText &= "<font color=red>" & "<b>" & ("[ESC]") & " = " & ("Abbrechen") & "</b>" & "<br>" & "<br>"
  
  ''Clock activate or deactivate:
  sText &= "<font color=darkred>" & "<b>" & ("Rechenleistung") & (" ∑") & "</b>" & "<br>"
  sText &= ("Schongang Ein/Aus") & ": " & ("Ohne eine berechnete 'Uhr' wird die benötigte Rechenleistung verringert, zum Beispiel für kleine oder ältere Computer.") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Clock-Levels:
  sText &= "<font color=darkgreen>" & "<b>" & ("Aufbau") & (" __—") & "</b>" & "<br>"
  sText &= ("Aufbauleiste (Summe)") & ": " & ("Die Bilder werden als Uhr-Teile von links nach rechts gestapelt (Ebene+Ebene=Summe).") & "<br>"
  sText &= ("Die letzten Bilder können vorherige Bilder überlagern und auch vollständig verdecken.") & "<br>"
  sText &= ("Die Reihenfolge kann geändert werden, auch die Aktivierung der einzelnen Bilder.") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Clock-Hands:
  sText &= "<font color=darkblue>" & "<b>" & ("Uhr-Zeiger") & (" ○–▶") & "</b>" & "<br>"
  sText &= ("Die Uhr-Zeiger für Stunde, Minute und Sekunde werden zuletzt hinzugefügt, automatisch, wenn sie aktiviert ausgewählt sind.") & "<br>"
  sText &= ("Die Zeiger sind somit immer oben, in der letzten Ebene (Schicht)") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Gearwheels:
  sText &= "<font color=gray>" & "<b>" & ("Zahnräder") & (" ‸‸‸○‸‸‸") & "</b>" & "<br>"
  sText &= ("Zahnräder (timegearwheel) werden hinter den Uhr-Zeigern hinzugefügt.") & "<br>"
  sText &= ("Die Räder drehen sich im Sekundentakt.") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Moveable Parts:
  sText &= "<font color=blue>" & "<b>" & ("Bewegliche Teile") & (" ●•  ▪●▪") & "</b>" & "<br>"
  sText &= ("Bewegliche Teile werden automatisch verändert und an die veränderte Zeit angepasst (Zeiger, Punkte, Räder, Sonnenaufgang, Nachthimmel...)") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Start, Pause/Stop:
  sText &= "<font color=red>" & "<b>" & ("Stopp und Kopie") & (" || C") & "</b>" & "<br>"
  sText &= ("Die Uhr-Zeit kann gestoppt oder individuell eingegeben werden.") & "<br>" 
  sText &= ("Beispiel: Eine Foto-Kopie mit bestimmter Uhr-Zeit.") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ''Cutter, ausstanzende Schablone:
  sText &= "<font color=gray>" & "<b>" & ("Cutter. Schneiden mit Schablone") & (" ▪○▪") & "</b>" & "<br>"
  sText &= ("Im Stapel werden die Teile unter der Schablone geschnitten, ausgestanzt (Nicht bei beweglichen Teilen).") & "<br>" 
  sText &= ("Die Teile über und nach der Schablone werden NICHT geschnitten.") & "<br>"
  sText &= "</font>" '& "<br>"
  
  ' Message.Info(sText)
  Select Case Message.Question(sText, ("Browser..."), ("Ordner..."), ("Abbrechen"))
    Case 1 
      sHTML = M01Functions.FileBasisHTML(sText)
      sFile = "info.html"
      ' sDirFile = M01Functions.TempDirFile("info.html")
      sDirFile = M01Functions.CheckDirectoryCache() &/ sFile
      If IsDir(File.Dir(sDirFile)) = True Then File.Save(sDirFile, sHTML) 
      If Exist(sDirFile) = True Then Desktop.Open(sDirFile)
    Case 2 'Directory
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      M01Functions.FileManagerOpen(sDir)
    Case 3 'Cancel
      '...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function TerminweckerLinesFormatInfo(Optional iTermin1Project3 As Integer = 1) As String 
  
  Dim sText, sSep, sReturn As String
  
  ''Text in <HTML>:
  sSep = "<font size=3 color=darkgreen><b> [TAB] </b></font>" 
  sReturn = "<font size=3 color=darkgreen><b> [↵] </b></font>"
  
  sText &= ("Zeilenaufbau: ") & "<br><br>"  'br=Break, new Line
  sText &= "<font color=gray size=3>" 
  sText &= ("Datum") & sSep & ("Uhrzeit") & sSep & ("Wochentag") & sSep & ("Quartal") & sSep & ("Kalenderwoche") & sSep 
  If iTermin1Project3 = 1 Then 
    sText &= ("Notizen") 
  Else 
    sText &= ("Projekt-Name") & sSep & "00:00" & sSep & ("Wochentag") & sSep & ("Sek.-Zahl") & sSep & ("=Dauer") 
  Endif 
  sText &= sReturn & "<br>"
  sText &= "</font><hr>" 'hr=———" horizontal rule, line
  sText &= sSep & ("=TABulator=") & "⇄=  chr(9)" & "<br>" 
  sText &= sReturn & "=" & ("Neue Zeile") & ("=Enter=Return=") & " chr(13) + chr(10)" & "</font>" & "<br>"
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Function CharsetABCInfo() As String
  
  Dim sTitle, sTextHTML, sMessage, sWord, sText, sDemoLine, sTerminLine, sExport, sNewLine, sDirFile As String
  Dim sF, sE As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]  ' Spalten-Trennung mit TAB bei Windows und Linux gleich
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sNewLine = "<br>"
  sF = "<font color=blue><b>"
  sE = "</b></font>"
  sDirFile = M01Functions.ProgramDirCache(("temp_BeispielText.txt"))
  sDirFile = Replace(sDirFile, gb.NewLine, "")
  
  ''Empty, Demo-Line
  sDemoLine = Format(Now, "yyyy-mm-dd") & hTab & "00:00" & hTab & Format(Now, "ddd") & hTab & "Q" & hTab & ("KW") & hTab & ("Notiz") & Space(1) & ("leer") & hReturn
  
  sTitle = ("Zeichensatz ohne") & " ä,ü,ö...€..." & "<font size=5 color=darkgreen>" & "?" & "</font></b><br>" & ("Systemsprache") & ": " & "<font size=5 color=darkgreen>" & System.Language & "</font>" & sNewLine & sNewLine
  
  sText &= ("Tipp: Sonderzeichen im Textprogramm" & "<br>" & "''Suchen'' und ''Ersetzen'' ö > oe ") & sNewLine & sNewLine
  ' sText &= ("Tipp: Siehe Textprogramme ''Speichern als...'' ") & sNewLine & sNewLine
  ' sText &= ("Tipp: Spalten=TABulatoren (Trennzeichen).") & sNewLine 
  sText &= ("Zeilenvorschub nur am Ende eines Termin-Eintrags (davor mit ¶ als Ersatzzeichen)") & sNewLine & sNewLine
  sText &= ("Datei öffnen, bearbeiten, ''Speichern als...'' terminwecker.txt (Format-Endung (*.txt) beachten!) und mit dem Terminwecker öffnen.") & sNewLine 
  
  sTerminLine = M06InfoText.TerminweckerLinesFormatInfo() & sNewLine 'As String
  
  sExport = Settings[FMain.Name &/ "Exportzeichen", ""] & sNewLine 'As String
  sExport = sF & sExport & sE & sNewLine
  sExport &= sDemoLine & sNewLine
  
  sTextHTML = sText 
  sWord = ("Suchen")
  sTextHTML = Replace(sTextHTML, sWord, sF & sWord & sE)
  sWord = ("Ersetzen")
  sTextHTML = Replace(sTextHTML, sWord, sF & sWord & sE)
  sWord = ("Speichern als...")
  sTextHTML = Replace(sTextHTML, sWord, sF & sWord & sE)
  
  sMessage = sTitle & sTextHTML & sTerminLine & sExport & ("Beispiel-Datei") & ": " & sNewLine & sDirFile
  
  ''Message:
  Select Case Message.Question(sMessage, ("Browser...*.html"), ("Textprogramm...*.txt"), ("Abbrechen")) '(0,1,2,3) max.3 Button
    Case 1 'Browser
      sText = M01Functions.FileBasisHTML(sTitle & sTextHTML & sExport) 
      If String.LCase(File.Ext(sDirFile)) <> "html" Then sDirFile = sDirFile & ".html"   ' sDirFile = File.SetExt(sDirFile, "html")
      If IsDir(File.Dir(sDirFile)) = True Then Try File.Save(sDirFile, sText)
      If Exist(sDirFile) = True Then M01Functions.ExternStart("firefox", sDirFile) Else Message.Info(sDirFile & sNewLine & ("Fehlt")) ' auch ohne "file://" möglich
    Case 2 'Text
      sText = Replace(sText & sExport, sNewLine, gb.NewLine)
      If IsDir(File.Dir(sDirFile)) = True Then Try File.Save(sDirFile, sText)
      If Exist(sDirFile) = True Then M01Functions.ExternStart("libreoffice", sDirFile) Else Message.Info(sDirFile & sNewLine & ("Fehlt"))
    Case 3 'Cancel
      'Leerlauf, Abbrechen
      sDirFile = ""
  End Select
  If Exist(sDirFile) = False Then sDirFile = ""
  
  Return sDirFile
  
Catch 
  FMain.ErrorText
  
End

Public Function RandomizeInfo() As String
  
  Dim sInfo As String 
  
  sInfo = "Randomize" & gb.NewLine 
  sInfo &= "Info: Mit Randomize (Pseudo-Zufallsgenerator) werden Zahlen (wie) zufällig erstellt." & gb.NewLine & gb.NewLine
  sInfo &= "Die Vorlage kann verworfen werden, oder weiter entwickelt werden. Eine mehrdimensionale Kreativität ist ein Prozess, auf der Basis vieler denkbarer Alternativen. Die Selbstkritikfähigkeit wird geübt und verfeinert. Die Kriterien sind Funktionen und Gestaltung, wie in der Architektur und Natur." & gb.NewLine & gb.NewLine
  sInfo &= "In einer kreativen Denkweise wird ein Schritt weiter gedacht und das Ergebnis wird selbstkritisch überprüft nach Stil-Richtungen, Umsetzbarkeit, Verhältnismäßigkeit und sinnvoll wünschenswerter Funktion." & gb.NewLine & gb.NewLine
  sInfo &= "Wichtige Systeme sollten mehrfach abgesichert sein, möglichst unterschiedlich, falls ein System ausfällt (Redundanz, z.B. Notfallschirm, Rettungsboote, Notstromgeneratoren). Funktionsfähige Alternativen schaffen mehr Sicherheit für Benutzer, Mitwelt und Umwelt. In dem Programm 'terminwecker' können auf der Baukasten-Basis alternative Muster gefahrlos ausprobiert werden. Wer klein anfängt, kann wachsen. Wer groß anfängt, scheitert mangels Unterbau. Ein Hausbau fängt mit dem Fundament an, nicht mit der Dachspitze. In diesem Sinne ist ausprobierende Spielzeit = Lernzeit = Lebenserfahrung = Reifegrad." & gb.NewLine & gb.NewLine
  sInfo &= "Wenn Kinder spielen, lernen sie die Welt für sich selbst neu zu entdecken. Das spielerische Lernen fördert die Entwicklung. Die Parallelwelt von 'Spielern' mit absolutem 'Zauberstab' oder kurzsichtigem 'Druckschalter' verhindert diesen Prozess der realen Reifung." & gb.NewLine & gb.NewLine
  sInfo &= "Auch in scheinbar misslungenen Entwürfen sind Anregungen und Teile enthalten, die in anderen Entwürfen weiter entwickelt werden können. Die Kreativität braucht eine 'Artenvielfalt' als 'Basis', wie die Evolution im 'Garten Erde'. Von der Schöpfung bzw. Natur kann der Mensch lernen: Wahrnehmung, Erfahrung, ausprobieren, weiter entwickeln." & gb.NewLine & gb.NewLine
  sInfo &= "In Ausbildungsberufen werden Grundlagen geschaffen, auf denen eigene Fähigkeiten wachsen können. Menschen mit zeichnenden Fährigkeiten haben eine besondere Wahrnehmung entwickelt und zeichnen, was sie zuvor bewusst wahrgenommen haben. Sie sehen mehr unterschiedliche Details und können diese entsprechend darstellen. Die Übergänge sind fließend, wie bei einem smiley :-) mit groben Pixeln und einem Gesicht mit vielen feinen Pixeln (Bildpunkten). Auch Musiker*innen sehen mehr als Punkte auf dem Notenblatt. Der Mensch 'sieht' was ihm bekannt vorkommt und zuvor erlernt hat. Ein Tunnelblick verhindert die Wahrnehmung der Zusammenhänge. Eine breitere Wahrnehmung erweitert den Wahrnehmungshorizont und erkennt eher Zusammenhänge und Grundmuster." & gb.NewLine & gb.NewLine
  sInfo &= "Eine absolut, einseitig und buchstäblich voraus gesetzte Vorgabe schafft Druck und Fehl-Entwicklungen. Ein wissenschaftlicher und kreativer Lösungsweg setzt nicht alles auf die sprichwörtlich eine Karte, absolut und alternativlos. Das Spektrum der Angebote wird erweitert durch alternative Lösungen, woraus neue evolutionäre Fortschritte entstehen." & gb.NewLine & gb.NewLine
  sInfo &= "Ein html-Quelltext Interpreter </> gibt nur wieder, was er kennt, wie beim Menschen. Unbekannte Teile werden nicht wahrgenommen und es wird nur darstellend 'gezeichnet', was in der Programm-Version bekannt ist. Vorteil: Programm läuft, wenn auch nicht vollständig, wie im Leben. Development, also Entwicklung, Entwickler. Entwicklungen annehmen und weiter entwickeln und weiter geben. Mehrwert." & gb.NewLine & gb.NewLine
  sInfo &= "Die Fehler-Meldungen sind eine Hilfe für den Programmierer und für Benutzer ein Hinweis auf technisch bedingte Fehlerquellen." & gb.NewLine
  sInfo &= "(f) 2024 www.design-cad.de (freeware)" & gb.NewLine
  
  Return sInfo
  
Catch 
  FMain.ErrorText
  
End



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form18Projektbearbeiten.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form18Projektbearbeiten.class
254 KB
' Gambas class file

'F_ = Form level
Public F_bChangeON As Boolean
Public F_bCheckBoxAbc As Boolean
Public F_bColumnsMore As Boolean
Public F_bCorrectListON As Boolean
Public F_bESCpressedON As Boolean
Public F_bKeyboardInput As Boolean
Public F_bListChanged As Boolean
Public F_bMakeBackup As Boolean
Public F_bMoreButtons As Boolean
Public F_bMovingON As Boolean
Public F_bSaved As Boolean
Public F_dateNow As Date 
Public F_i22 As Integer = 22 'Example: 22 'Pixel Icon WxH —▶ColumnView
Public F_iColorBlue As Integer
Public F_iColorForegroundBlue As Integer = Color.DarkBlue
Public F_iColorGreen As Integer
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150) ' (Color,  Alpha-Transparent)
Public F_iColorGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220) 
Public F_iColorRed As Integer
Public F_iColorRedAlpha150 As Integer = Color.SetAlpha(Color.Red, 150) 
Public F_iColorYellow As Integer
Public F_iColumnCorrectSelection1All2 As Integer
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iCurrentErrorLine As Integer
Public F_iCVUndoRedoPointer As Integer
Public F_iCVUndoRedoPointerSave As Integer
Public F_iDateTimeNoticeBackupPointer As Integer
Public F_iListChangedCounter As Integer
Public F_iMoveLineMaxH As Integer
Public F_iMoveLineMinH As Integer
Public F_iMoveLineTop As Integer
Public F_iMusterTermine1Names2Projects3 As Integer = 3 '!!! ******************************************
Public F_iOldLines As Integer
Public F_iOnly1x As Integer
Public F_iSearchPosition As Integer
Public F_iSecondsFileRead As Integer
Public F_iSelectGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220) 
Public F_iSelectRedAlpha220 As Integer = Color.SetAlpha(Color.Red, 220) 
Public F_iText5SearchPosition As Integer
Public F_iText5Seconds As Integer
Public F_iUnknownCounter As Integer
Public F_iX1 As Integer
Public F_iX2 As Integer
Public F_iY1 As Integer
Public F_iY2 As Integer
Public F_longFilesRead As Long '>Files
Public F_ooColumnViewImages As Object[]
Public F_ooCVBackups As Object[]                                                   'ColumnView1 ->Backups
Public F_ooDateTimeNoticeBackup As Object[]
Public F_sCVinfoSelectLineFirst As String = ("Vorher eine Zeile markieren oder erstellen")
Public F_sDirDefault As String = Desktop.GetDirectory("PICTURES") &/ Application.Name
Public F_sForm As String = Me.Name 
Public F_sLinesCopy As String 
Public F_sPathText5Temp_txt As String 
Public F_sProjectOnlyName As String
Public F_ssCVImgNames As String[]
Public F_ssKeysCopy As String[]          'ColumnView1.Selection.Max > -1  'internally, instead of Clipboard.Copy()
Public F_statFilePathForm As Stat
Public F_sText5StartExampleName As String
Public F_sTitleBasicText As String
Public F_sUnknownLinesText As String

Public Struct F_multiColumnViewValues 'Example in Sub: Dim hColumnView as New F_multiColumnViewValues
  bSortAscending As Integer
  bSorted As Integer
  iMode As Integer
  iScrollY As Integer
  iSortColumn As Integer
  ssKeys As String[] 
  ssLines As String[]
End Struct 

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]  '... "terminwecker.txt"
    Case 2
      sPath = Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt] '..."projects_names.txt"
    Case 3
      sPath = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] '..."projects_all.txt"
  End Select 
  
  Return sPath 
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt")
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectOnlyName() As String 
  
  F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  Return F_sProjectOnlyName
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtons(Optional bMore As Boolean = True)
  
  Dim bON As Boolean
  
  ''More:
  PanelListMenu.Visible = bMore 
  TextUndo.Visible = bMore
  TextRedo.Visible = bMore
  TextNeu.Visible = bMore
  ButtonSearch2ON.Visible = Not bMore
  ' ButtonTabelleExtern.Visible = bMore 
  ButtonOpen.Visible = False  'unused, deaktivate (Deaktiviert)
  
  ''Reset:
  bON = False
  ButtonBis.Visible = bON '{until}
  CheckBox1.Visible = bON '*EveryYear
  LabelTimer.Visible = bON 'Timer-
  LabelTitle.Visible = bON 
  LabelTitle.Raise()
  LabelTitleB.Visible = bON 
  ButtonProjectON.Visible = bON 
  ButtonSum.Visible = bON 
  ButtonName.Visible = bON 
  Text2.Visible = bON 
  Text2BG.Visible = bON 
  ButtonDauer.Visible = bON 
  ButtonTest.Visible = bON 
  ButtonPathAdd.Visible = bON
  
  Select Case F_iMusterTermine1Names2Projects3
      
    Case 1
      ''Notice:
      If Form18Projektbearbeiten.Name = Form2Bearb.Name Then 
        bON = True 
        ButtonBis.Visible = bON '{until}
        CheckBox1.Visible = bON '*EveryYear
        LabelTimer.Visible = bON 'Timer-
      Endif 
      
    Case 2
      ''Projects Names:
      If Form18Projektbearbeiten.Name = Form5Projekte.Name Then 
        bON = True 
        LabelTitle.Visible = bON 
        LabelTitle.Raise()
        LabelTitleB.Visible = bON 
        ButtonProjectON.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
    Case 3
      ''Projects edit:
      If Form18Projektbearbeiten.Name = Form18Projektbearbeiten.Name Then 
        bON = True
        ButtonSum.Visible = bON 
        ButtonName.Visible = bON 
        Text2.Visible = bON 
        Text2BG.Visible = bON 
        ButtonDauer.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH As Integer 'Border Width, Height (Rand Breite, Hoehe)
  Dim iPH, iPH2, iT0W, iT1W, iXW, iXH, iTH, iH, iW, iDis As Integer 'Panel Height
  Dim fRest As Float
  
  If Form18Projektbearbeiten.Width < 200 Then Form18Projektbearbeiten.Width = 200
  If Form18Projektbearbeiten.Height < 200 Then Form18Projektbearbeiten.Height = 200
  
  PicBackground.Move(0, 0, Form18Projektbearbeiten.ClientW, Form18Projektbearbeiten.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Randbreite
  iBH = PicBackground.Height / 100 * 3
  
  '*************************************************
  iDis = 10
  iPH = 50  'Text0.Font.TextHeight("0000-00-00") + iDis 'Distance
  iPH2 = iPH / 2
  iTH = iPH2  'TextBoxSearch5.Font.TextHeight("Path") + iDis
  iT0W = 150  'Text0.Font.TextWidth("0000-00-00") + iDis
  iT1W = 100 ' Text1.Font.TextWidth("00:00") + iDis
  F_iMoveLineMinH = iBH
  F_iMoveLineMaxH = Form2Bearb.ClientH - (iPH * 5.5) - iBH 
  '*************************************************
  
  'Adjust to MoveLine (Ausrichten an ▼-Bewegungslinie-▲)
  '-----------------------------------------------------------------------
  MoveLine.Move(iBW, MoveLine.Top, PicBackground.Width - (iBW * 2), iPH2) '.Top Begin => Form_Open
  '-----------------------------------------------------------------------
  If MoveLine.Top < F_iMoveLineMinH Or MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH
  
  IconError.Move(Form18Projektbearbeiten.ClientW - 32, 0, 32, 32)
  ProgressBar1.Move(MoveLine.Left, MoveLine.Top, MoveLine.Width, MoveLine.Height)
  
  ColumnView1.Move(iBW, iBH, MoveLine.Width, MoveLine.Top - iBH)
  
  ''Panel 0000-00-00 00:00...
  ' iXH = LabelTimer.Font.TextHeight("Timer-") + iDis
  iXH = iPH2
  PanelDatum.Move(iBW, MoveLine.Top + MoveLine.H, ColumnView1.W, iPH + iXH)
  Text0.Move(0, iPH / 3, iT0W, iPH / 3 * 2)
  Text0BG.Move(Text0.Left, Text0.Top, Text0.W, Text0.H)
  LabelTimer.Move(Text0.Left, Text0.Top + Text0.H, Text0.W * 0.65, iXH) 
  ButtonWeekDay.Move(LabelTimer.Left + LabelTimer.W, LabelTimer.Top, (LabelTimer.Left + LabelTimer.W + iDis + iT1W) - (LabelTimer.Left + LabelTimer.W), LabelTimer.H)
  Text1.Move(Text0.Left + Text0.W + iDis, Text0.Top, iT1W, Text0.H)
  Text1BG.Move(Text1.Left, Text1.Top, Text1.W, Text1.H)
  WindowT5plus.Move(PanelDatum.W - iXH, PanelDatum.H - iXH, iXH, iXH)
  ButtonSearch2ON.Move(WindowT5plus.Left, 0, WindowT5plus.W, WindowT5plus.H)
  LabelDateNow.Move(Text0.Left, 0, Text0.W, LabelDateNow.Font.TextHeight("0123"))
  LabelTimeNow.Move(Text1.Left, 0, Text1.W, LabelTimeNow.Font.TextHeight("0123"))
  ' LabelDateNow.Font.Size = LabelDateNow.Font.TextHeight("0123") * 0.65
  LabelTimeNow.Font.Size = LabelDateNow.Font.Size
  ' Text0.Font.Size = Text0.Font.TextHeight("0123") * 0.65
    
  Text1.Font.Size = Text0.Font.Size
  Text2.Font.Size = Text0.Font.Size
  ' LabelTimer.Font.Size = LabelTimer.Font.TextHeight("0123") * 0.65
  ButtonWeekDay.Font.Size = LabelTimer.Font.Size
  LabelDateNow.Font.Size = LabelTimer.Font.Size
  LabelTimeNow.Font.Size = LabelTimer.Font.Size
  
  ''Extra —▶ Project:
  PanelTitle.Move(iBW, PanelDatum.Top + PanelDatum.H, PanelDatum.W, Form18Projektbearbeiten.ClientH - (iBH * 2) - ColumnView1.H - MoveLine.H - PanelDatum.H - (iPH * 2) - iTH)
  ButtonName.Move(0, 0, Text0.Left + Text0.W, Text0.H)
  ButtonSum.Move(0, ButtonName.Top + ButtonName.H, Text1.Left - Text0.Left, PanelTitle.H - (ButtonName.Top + ButtonName.H)) 
  ButtonDauer.Move(Text1.Left, ButtonSum.Top, Text1.W, ButtonSum.H)
  Text2.Move(Text1.Left, 0, Text1.W, Text1.H)
  Text2BG.Move(Text2.Left, Text2.Top, Text2.W, Text2.H)
  ButtonTest.Move(PanelTitle.W - (iPH * 2), 0, iPH * 2, PanelTitle.H)
  ButtonProjectON.Move(0, 0, iPH, PanelTitle.H)
  LabelTitle.Move(iPH, 0, Text1.Left + Text1.W + iDis - iPH, PanelTitle.H)
  LabelTitleB.Move(LabelTitle.Left - 2, LabelTitle.Top + 2, LabelTitle.Width, LabelTitle.Height)
  LabelTitleB.Lower
  LabelTitleB.Text = LabelTitle.Text
  LabelTitleB.Font = LabelTitle.Font
  LabelTitleB.Alignment = LabelTitle.Alignment
  
  If F_iMusterTermine1Names2Projects3 = 1 Then 
    ''Termine:
    PanelText5.Move(0, 0, PanelTitle.W, PanelTitle.H)
  Else 
    ''Projects:
    PanelText5.Move(Text2.Left + Text2.W + iDis, 0, PanelTitle.W - (Text2.Left + Text2.W + iDis) - ButtonTest.W, PanelTitle.H)
  Endif 
  Text5.Move(0, 0, PanelText5.W, PanelTitle.H)
  
  ''Panel + ▶ Paste into List:
  PanelPaste.Move(iBW, PanelTitle.Top + PanelTitle.H, PanelDatum.W, iPH)
  ButtonAdd.Move(0, 0, iPH, iPH)
  ButtonInput.Move(iPH, 0, (PanelPaste.W / 2) - iPH, iPH)
  iXW = PanelPaste.W / 4
  CheckBox1.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  CheckBoxONoff.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  ButtonBis.Move(CheckBox1.Left + CheckBox1.W, 0, iXW - iPH, iPH)
  ButtonSearch5ON.Move(PanelPaste.W - iPH, 0, iPH, iPH)
  
  ''Panel Path:
  PanelPath.Move(iBW, PanelPaste.Top + PanelPaste.H, PanelDatum.W, iTH)
  ButtonFileInfo.Move(0, 0, iPH, PanelPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelPath.H)
  LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelPath.W - iTH, ButtonFileInfo.H)
  ButtonPathAdd.Move(LabelInfo.Left + LabelInfo.W, 0, PanelPath.W - (LabelInfo.Left + LabelInfo.W), iTH)
  
  ''Panel Text5 Search:
  PanelSearchText5.Move(PanelPaste.Left, PanelPaste.Top, PanelPaste.W, PanelPaste.H)
  TextBoxSearch5.Move(0, 0, PanelPath.W, PanelSearchText5.H)
  CancelSearch5.Move(PanelSearchText5.W - PanelSearchText5.H, 0, PanelSearchText5.H, PanelSearchText5.H)
  ButtonSearch5.Move(CancelSearch5.Left - (PanelSearchText5.H * 3), 0, PanelSearchText5.H * 3, PanelSearchText5.H)
  
  ''Panel Save:
  PanelSave.Move(iBW, PanelPath.Top + PanelPath.H, PanelDatum.W, iPH) 
  ButtonOpen.Move(0, 0, iPH, iPH)
  ButtonProjectForm.Move(0, 0, iPH, iPH)
  ButtonNewPlus.Move(0, 0, iPH, iPH)
  ButtonTabelleExtern.Move(ButtonNewPlus.Left + ButtonNewPlus.W, 0, iPH, iPH)
  ButtonSave.Move(ButtonTabelleExtern.Left + ButtonTabelleExtern.W, 0, ButtonInput.W, PanelSave.H)
  ButtonFormCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, PanelSave.W - (ButtonSave.Left + ButtonSave.W) - TextNeu.W, PanelSave.H)  
  ButtonCancelB.Move(PanelSave.W - PanelSave.H - TextNeu.W, ButtonSave.Top, PanelSave.H, PanelSave.H)
  
  ''Arrow Paste ▶ 0000-00-00 00:00...
  PfeilEinfuegen.Move(0, PanelDatum.Top, iBW, iPH)
  PanelSearchList.Move(PanelDatum.Left, PanelDatum.Top, PanelDatum.Width, PanelDatum.Height)
  PanelSearchResize()
  
  ''Panel Menu List:
  PanelListMenu.Move(Text1.Left + Text1.W + iDis, 0, PanelDatum.W - (Text1.Left + Text1.W + iDis), iPH * 0.7)
  If Form18Projektbearbeiten.Window.Maximized = True Then PanelListMenu.H = Text1.H
  PanelListMenuResize()
  
  ''Panel Error-Lines:
  PanelErrorLines.Move(PanelListMenu.Left, ButtonWeekDay.Top, ButtonWeekDay.H * 9, ButtonWeekDay.H)
  ListColumnCorrect.Move(0, 0, ButtonWeekDay.H * 3, ButtonWeekDay.H)
  ListGotoErrorLineDown.Move(ListColumnCorrect.Left + ListColumnCorrect.W, 0, ButtonWeekDay.H * 2, ButtonWeekDay.H)
  ListGotoErrorLineUp.Move(ListGotoErrorLineDown.Left + ListGotoErrorLineDown.W, 0, ButtonWeekDay.H * 2, ButtonWeekDay.H)
    
  ''Panel Menu Text5:
  PanelTextMenu.Move(PanelErrorLines.Left + PanelErrorLines.W, ButtonWeekDay.Top, PanelDatum.W - (PanelErrorLines.Left + PanelErrorLines.W) - iPH, ButtonWeekDay.H)
  iW = PanelTextMenu.H
  iH = PanelTextMenu.H
  fRest = PanelTextMenu.W - (iW * 11)
  TextUndo.Move(0, 0, iW, iH)
  Text5UndoCounter.Move(iW, 0, iW * 3, iH)
  TextRedo.Move(iW * 4, 0, iW, iH)
  TextNeu.Move(iW * 6, 0, iW * 3, iH)
  ButtonLineNr.Move(iW * 9, 0, PanelTextMenu.W - (iW * 13), iH)
  ButtonS.Move(PanelTextMenu.W - (iW * 4), 0, iW * 4, iH)
  
  ''Find Lines:
  ColumnView2.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Select 0000-00-00 00:00
  DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Timer: 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  ScrollViewWeekDay.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Time 00:00 > 23:59
  ColumnView3.Move(iBW, iBH, Text1.W + iDis, DateChooser1.H)
  
  ''Panel Until {bis}:
  PanelBis.Move(iBW + Text1.Left + Text1.W + iDis, PanelDatum.Top, PanelDatum.W - (Text1.Left + Text1.W + iDis), PanelDatum.Height)
  Label7Bis.Move(0, 0, Label7Bis.W, Text0.Height)
  Text0b.Move(Label7Bis.Left + Label7Bis.Width, 0, Text0.Width, Text0.Height)
  Text0bBG.Move(Text0b.Left, Text0b.Top, Text0b.W, Text0b.H)
  Label3b.Move(Text0b.Left, Text0b.Top + Text0b.Height, Text0b.Width, PanelBis.Height - Text0b.Height)
  LabelbisX.Move(0, Label3b.Top, Label3b.H, Label3b.Height)
  CancelBis.Move(PanelBis.W - iPH, 0, iPH, iPH)
  ButtonDateCancel.Move(PanelBis.Left, PanelBis.Top, PanelBis.W, PanelBis.H)
  
  ''Panel Text5 stretch:
  If PanelText5.H < F_iMoveLineMaxH Then 
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture
  Else 
    WindowT5plus.Picture = PicTemplatePageMini.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture  
  Endif
  
  ''Form stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form18Projektbearbeiten.ClientW - iBW - iPH, Form18Projektbearbeiten.ClientH - iBH - iPH, iPH, iPH)  
  
  ''List resize:
  If F_iOnly1x > 0 And F_bMovingON = False Then ColumnView1Resize()
  
  ArrowR.Move(Form18Projektbearbeiten.ClientW - iBW, ColumnView1.Top, iBW, ColumnView1.H) ''>>
  
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub PanelSearchResize()
  
  Dim iXW As Integer
  
  iXW = PanelSearchList.H * 1.1
  TextListSearch.Move(0, 0, PanelSearchList.W - (iXW * 11), PanelSearchList.H)
  If TextListSearch.W < Text0.W Then 
    TextListSearch.W = Text0.W
    iXW = (PanelSearchList.W - TextListSearch.W) / 11
  Endif 
  ButtonSearchPanel.Move(TextListSearch.Left + TextListSearch.W, 0, iXW * 2, PanelSearchList.H)
  ListFound.Move(ButtonSearchPanel.Left + ButtonSearchPanel.W, 0, iXW, PanelSearchList.H)
  ButtonSearchListOn.Move(ListFound.Left + ListFound.W, 0, iXW * 2, PanelSearchList.H)
  ButtonSearchDown.Move(ButtonSearchListOn.Left + ButtonSearchListOn.W, 0, iXW, PanelSearchList.H)
  ButtonSearchUp.Move(ButtonSearchDown.Left + ButtonSearchDown.W, 0, iXW, PanelSearchList.H)
  LabelSearchLineNr.Move(ButtonSearchUp.Left + ButtonSearchUp.W, 0, iXW * 2, PanelSearchList.H)
  SaveSelection.Move(LabelSearchLineNr.Left + LabelSearchLineNr.W, 0, iXW, PanelSearchList.H)
  ButtonSearchCancel.Move(PanelSearchList.W - iXW, 0, iXW, PanelSearchList.H)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelListMenuResize()
  
  Dim iCount, iW, iH, iDis As Integer 'Width, Height, Distance
  
  iCount = 21 ' |i|i|...|iii|
  iW = PanelListMenu.H  
  iH = PanelListMenu.H 
  iDis = PanelListMenu.W - (iW * iCount)
  iDis = iDis / iCount 
  iDis = iW + iDis
  If iDis < iW Then iDis = iW
  
  ListDown.Move(0, 0, iW, iH)
  ListUp.Move(iDis, 0, iW, iH)
  ListCut.Move(iDis * 2, 0, iW, iH)
  ListCopy.Move(iDis * 3, 0, iW, iH)
  ListPaste.Move(iDis * 4, 0, iW, iH)
  ListSelectAll.Move(iDis * 5, 0, iW, iH)
  ListAdd.Move(iDis * 6, 0, iW, iH)
  ListUndo.Move(iDis * 7, 0, iW, iH)
  ListRedo.Move(iDis * 11, 0, iW, iH)
  ListBackupCounter.Move(ListUndo.Left, 0, (ListRedo.Left + ListRedo.W) - ListUndo.Left, iH)
  ListBackupCounter.Lower
  ListSearch.Move(iDis * 12, 0, iW, iH)
  ListMark.Move(iDis * 13, 0, iW, iH)
  ListRefresh.Move(iDis * 14, 0, iW, iH)
  ListReload.Move(iDis * 15, 0, iW, iH)
  ListAplus.Move(iDis * 16, 0, iW, iH)
  ListCheckBoxAZ.Move(iDis * 17, 0, iW, iH)
  ListCheckBoxAZLabel.Move(iDis * 17 + iW, 0, iW * 2, iH)
  ListIsChanged.Move(iDis * 20, 0, iW, iH)
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  WindowStretch.Raise() 'Level ▲Top▲
  ButtonSearchCancel.Raise()
  ArrowR.Raise() '>>
  Text0BG.Raise() 'Changed auch bei Farbwechsel, deshalb extra Background für Farbhinweis (*1)
  Text1BG.Raise()
  Text2BG.Raise()
  Text0bBG.Raise()
  
  Text0.Raise()
  Text1.Raise()
  Text2.Raise()
  Text0b.Raise()
    
  LabelDateNow.Raise()
  LabelTimeNow.Raise()
  
  ''_____________________________________________________________________________''
  '(*1) Alternative in New Gambas-Version with TextBox. _Change() only Text, not Color) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True
  SelectHide0Date1Clock2Timer3(0)
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then ColumnViewInfo(("Abbruch mit [ESC]")) Else ColumnViewInfo()
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form18Projektbearbeiten.Window.Maximized = False Then
    Form18Projektbearbeiten.Window.Maximized = True
  Else
    Form18Projektbearbeiten.Window.Maximized = False
    Form18Projektbearbeiten.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Picture (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
    sValue = Replace(sValue, "bg_", "bglinie_")
    MoveLine.Picture = Picture.Load(sValue) 
    MoveLine.Stretch = True
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
    MoveLine.Background = PicBackground.Background
    MoveLine.Stretch = False
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  FMain.F_bNeueinlesenStarten = False
  IconError.Visible = False
  mnuMaus.Visible = False
  mnuMaus2.Visible = False
  If Not Form18Projektbearbeiten.Window.Icon Then Form18Projektbearbeiten.Window.Icon = FMain.Window.Icon
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1 'Termine
      Form18Projektbearbeiten.Window.Title = Application.Name & " - " & ("Bearbeiten")
    Case 2 'Project-Names
      Form18Projektbearbeiten.Window.Title = Application.Name & " - " & ("Projekte")
    Case 3 'Projects
      Form18Projektbearbeiten.Window.Title = Application.Name & " - " & ("Projekt bearbeiten")
  End Select 
  F_sTitleBasicText = Form18Projektbearbeiten.Window.Title
  MoveLine.Top = 0
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    ColumnViewCheckAplus()
    FormStart()
    If F_iMusterTermine1Names2Projects3 = 1 Then Timer1.Start() Else Timer1.Stop()
    ReadG()
    If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
    If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then Form_Resize()
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1, 2 'Termine, Project-Names
      F_iColumnNr = 6                                  'Termine 6, in Projects 13
      F_iColumnUndo = 7                                'Termine 7, in Projects 10
      F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 9                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
      
    Case 3 'Projects
      F_iColumnNr = 13                                  'Termine 6, in Projects 13
      F_iColumnUndo = 10                                'Termine 7, in Projects 10
      F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 12                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  End Select 
  
  '******************************
  F_iColorYellow = ColumnView2.Background
  F_iColorGreen = Color.Green
  F_iColorRed = Color.Red 
  F_iColorBlue = Color.Lighter(Color.Lighter(Color.Blue))
  '******************************
  
  MoreButtons(F_bMoreButtons)
  FormBackgroundColor()
  ColumnViewImagesRead()
  ButtonSave.Background = Color.Default 
  
  F_bChangeON = False
  LabelInfoPathG(FilePathForm())
  WeekDays0to6()
  F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then 
    F_sText5StartExampleName = Text5TempFileLoad() 'as String, Read file
  Else 
    Text0Insert(Format(Date, "yyyy-mm-dd"))
    Text0bInsert(Format(Date, "yyyy-mm-dd"))
    Text1Insert(Format(Time, "hh:nn"))
    Text5Insert(F_sText5StartExampleName)
  Endif 
  Text5.Pos = String.Len(Text5.Text)
  Text5.SetFocus
  ButtonWeekDay.Text = Format(Date, "dddd")
  ListColumnCorrect.Picture = ListColumnCorrect.Picture.Image.Stretch(F_i22, F_i22).Picture
  ListGotoErrorLineDown.Picture = ListGotoErrorLineDown.Picture.Image.Stretch(F_i22, F_i22).Picture
  ListGotoErrorLineUp.Picture = ListGotoErrorLineUp.Picture.Image.Stretch(F_i22, F_i22).Picture
  TextUndo.Picture = ListUndo.Picture.Image.Stretch(F_i22, F_i22).Picture
  TextRedo.Picture = ListRedo.Picture.Image.Stretch(F_i22, F_i22).Picture
  MenuSaveAsCopy.Picture = MenuSaveAsCopy.Picture.Image.Desaturate().Contrast(1).Picture
  
  TextBackgroundAll(Color.Transparent)
  F_bChangeON = True
  
  F_bListChanged = False
  F_bKeyboardInput = False
  ColorPicButtonReplace()
  WindowStretchCursor()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FilePathCheck()
  
  Dim sDirFile As String
  ' TextBoxPath.Text = FilePathForm()
  sDirFile = TextBoxPath.Text 
  
  If sDirFile = "" Then TextBoxPath.Text = ("Datei fehlt?")  
  TextBoxPath.ToolTip = ("Datei=") & Space(1) & TextBoxPath.Text
  If Exist(sDirFile) = False Then
    TextBoxPath.Foreground = F_iColorRed
    ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture
  Else
    TextBoxPath.Foreground = Color.Gray
    If F_iSecondsFileRead = 2 Then 'slowly?
      ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture 'Pixel 22, 22
    Else 
      ButtonFileInfo.Picture = mnuInfo.Picture.Image.Stretch(F_i22, F_i22).Picture
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekDays0to6()
  
  Dim ssWeekdays As New String[]
  
  ssWeekDays = M01Functions.Weekdays0to6LocalLanguage() 'new in Gambas3
  
  If ssWeekdays.Count >= 7 Then 
    ToggleButtonW1.Text = ssWeekdays[0] 'So
    ToggleButtonW2.Text = ssWeekdays[1] 'Mo
    ToggleButtonW3.Text = ssWeekdays[2] 'Di
    ToggleButtonW4.Text = ssWeekdays[3] 'Mi
    ToggleButtonW5.Text = ssWeekdays[4] 'Do
    ToggleButtonW6.Text = ssWeekdays[5] 'Fr
    ToggleButtonW7.Text = ssWeekdays[6] 'Sa
  Endif 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewSortPics()
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_iColumnSelect < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView1.Columns.Sort = F_iColumnSelect
      If ColumnView1.Selection.Max > -1 Then
        ' sKey = ColumnView1.Selection[ColumnView1.Selection.Max]  'only Key, Example: Last sKey = "9"
        sKey = ColumnView1.Selection.Last
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If F_iColumnSelect < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView2.Columns.Sort = F_iColumnSelect
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection.Last  'only Key, Example: Last sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewImagesRead()  'Note: Work with Images = faster. Convert to Picture at End.
  
  Dim ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgLineActual, ImgQuestionRed As Image
  Dim iSize As Integer
  
  ''End-Names:
  F_ssCVImgNames = ["PicAdd", "PicCut", "PicDouble", "PicDown", "PicEmpty", "PicFind", "PicHome", "PicMarkGreen", "PicOFF", "PicOK", "PicON", "PicQuestion", "PicRefresh", "PicSave", "PicUp", "PicWarning", "PicLineActual", "PicQuestionRed"]
  
  iSize = F_i22 'Pixel 
  ImgAdd = ListAdd.Picture.Image.Stretch(iSize, iSize)
  ImgCut = ListCut.Picture.Image.Stretch(iSize, iSize)
  ImgDouble = PicTemplateDouble.Picture.Image.Stretch(iSize, iSize)
  ImgDown = ListDown.Picture.Image.Stretch(iSize, iSize)
  ImgEmpty = New Image(iSize, iSize, Color.Transparent) 'Image is faster than Picture
  ImgFind = ListSearch.Picture.Image.Stretch(iSize, iSize) 
  ImgHome = PicTemplateLEDgreen.Picture.Image.Stretch(iSize, iSize) 
  ImgMarkGreen = ListMark.Picture.Image.Stretch(iSize, iSize) 'Flag
  ImgOff = PicTemplateConnectOff.Picture.Image.Stretch(iSize, iSize)
  ImgOK = PicTemplateApply.Picture.Image.Stretch(iSize, iSize) 
  ImgON = PicTemplateConnectON.Picture.Image.Stretch(iSize, iSize)
  ImgQuestion = PicTemplateQuestionRound.Picture.Image.Stretch(iSize, iSize)
  ImgRefresh = PicTemplateReChange.Picture.Image.Stretch(iSize, iSize)
  ImgSave = ButtonSave.Picture.Image.Stretch(iSize, iSize)
  ImgUp = ListUp.Picture.Image.Stretch(iSize, iSize)
  ImgWarning = IconError.Picture.Image.Stretch(iSize, iSize)
  ImgLineActual = PicTemplateAddLineActual.Picture.Image.Stretch(iSize, iSize)
  ImgQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(iSize, iSize)
    
  ''Images:
  F_ooColumnViewImages = [ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgLineActual, ImgQuestionRed]
  
  ''Example:
  'PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewImages(Optional sName As String = "PicEmpty") As Image
  
  Dim iFound As Integer
  
  If String.InStr(sName, "-") > 0 Then sName = Replace(sName, "-", "") '"-" for selected Line
  If F_ssCVImgNames And F_ooColumnViewImages Then iFound = F_ssCVImgNames.Find(sName) '-1 not found
  If iFound = -1 Then iFound = F_ssCVImgNames.Find("PicEmpty")
  
  Return F_ooColumnViewImages[iFound]
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG(Optional sDirFile As String = "", Optional bDialog As Boolean = False) ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File 'Stream
  Dim iColumn, iUnknownCounter, iEmptyOrDouble, iLine, iLines As Integer
  Dim sKey, sLine, sLinePart, sText, sUnknown, sMessage, sDemo As String
  Dim ssExist, ssRepair As String[]
  Dim PicEmpty As Picture
  Dim dateBegin, dateEnd As Date 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
  ''Reset:
  F_bESCpressedON = False
  IconError.Visible = False
  F_sUnknownLinesText = "" 
  dateBegin = Now
  Error.Clear()
  
  ''Dialog:
  If bDialog = True Then 'Add+
    sDirFile = FileDialogPathReturn(sDirFile, "open", FilePathForm()) 'no Path = cancel
    If Exist(sDirFile) = False Then Goto JumpEnd    'Cancel (Abgebrochen)
  Else 
    ColumnView1.Clear() 'delete all lines, but not title (header)
    F_longFilesRead = 0
  Endif
  
  ''File-Name or Standard or Demo:
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = False Then
    ''Empty, Demo-File
    sDemo = M01Functions.DemoFileTermineOrProjects(FilePathForm()) 'Terminwecker or Projects
    If Exist(sDemo) = True Then Try Move sDemo To sDirFile 
  Endif
  If sDirFile <> TextBoxPath.Text Then 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
  Endif 
  FilePathCheck()
  
  ''Check Columns:
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  F_iOldLines = ColumnView1.Count
  If F_iOldLines = 0 Then ColumnSortSettingCentral()
  ' If F_iOldLines = 0 Then PicNew = PicEmpty Else PicNew = PicAdd
  ' ColumnView1.Header = True 
  ColumnView1.Visible = False
  ' ColumnView1.Sorted = False     'Enter-List (Liste nach Eingang aus Datei)
  
  ProgressBarONoff(True)
  Form18Projektbearbeiten.Window.Title = Application.Name & " - " & ("Datei lesen...")
  
  ''Check first lines. File-Format:
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    If M01Functions.isTerminweckerFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Else 
    If M01Functions.isProjectFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Endif 
  
  ''Backup:
  If Not F_ooCVBackups Then ColumnViewBackup()
  
  'Read and add Column Lines (Zeilen (rows) erzeugen)
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  If Exist(sDirFile) = True Then
    F_longFilesRead = F_longFilesRead + Stat(sDirFile).Size 'as Long
    ssExist = New String[]
    ColumnView1.Sorted = False 
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    If F_iMusterTermine1Names2Projects3 > 1 Then ssExist.Sort() '>Projects
    
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If sLine And String.Left(sLine, 1) <> "#" And ssExist.ExistSorted(sLine) = False Then '.FindSorted() > faster ~10x
        ''Test Rest:
        If sLine Like "*????-??-??*??:??*????-??-??*?Q" & gb.Tab & "*" Then 
          If sLine Then ssRepair = ReadRepairG(sLine) Else ssRepair = Null 'as String[]
          If ssRepair Then ssExist.Insert(ssRepair)
        Else 
          ssExist.Add(sLine) 
        Endif 
      Else 
        iEmptyOrDouble = iEmptyOrDouble + 1
      Endif 
      
      iLines = iLines + 1
      If iLines Mod 100 = 0 Then 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          sMessage = sDirFile & "<br>"
          If Stat(sDirFile).Size > 2000000 Then '2MiB
            sMessage &= M01Functions.FileSizeText(sDirFile) & "<br>"
            sMessage &= "<font color=red><b>" & ("Große Datei = Mehr Zeit") & "</b></font><br><br>"
            sMessage &= ("Zeile") & ": " & iLines & "<br>"
            sMessage &= ("Tipp: Menü > Datei > Auslagern...") 
          Endif 
          If MessageQuestionBreak(sMessage) = True Then Break
        Endif 
        ProgressBarONoff(True) 
      Endif 
    Next 
    
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  'Check "\r" Return,  Typ Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
  If Exist(sDirFile) = True And String.InStr(sLine, gb.Cr) > 0 Then 
    sText = File.Load(sDirFile)
    If sText Then 
      ssExist = New String[]
      sText = Replace(sText, gb.Cr, gb.NewLine)
      ssExist = Split(sText & gb.NewLine, gb.NewLine) 
    Endif 
  Endif 
  
  If Not Error Then 
    For iLine = 0 To ssExist.Max '.........................................
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
      Endif 
      
      sLine = ssExist[iLine] 'one line
      
      If String.Len(sLine) > 10 Then 'min.
        
        sKey = Str(ColumnView1.Count + 1)
        ColumnView1.Add(sKey, "")
        
        iColumn = 0
        For Each sLinePart In Split(sLine & String(F_iColumnsCount, hTab), hTab) ' Stringarray
          If iColumn = 0 Then 
            ColumnView1[sKey][iColumn] = Trim(sLinePart) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          Else If iColumn < F_iColumnsReadMax + 1 Then 
            ColumnView1[sKey][iColumn] = sLinePart
          Endif 
          If iColumn = F_iColumnsReadMax Then Break
          iColumn = iColumn + 1
        Next
        
        If iColumn = F_iColumnsReadMax Then
          ColumnView1[sKey][F_iColumnUndo] = sLine 'Original Line (Originalzeile)
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][0] & ColumnView1[sKey][1]
          If F_iOldLines = 0 Then
            ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
          Else 
            ColumnView1[sKey][F_iColumnSelect] = "PicAdd"  
          Endif 
        Else  'too many or not enough Separators '(zu viele oder zu wenige sSeparator) '|0|1|2|3|4|5|> |
          ColumnView1[sKey][F_iColumnUndo] = sLine 
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][0] & ColumnView1[sKey][1]
          iUnknownCounter = iUnknownCounter + 1
          If iUnknownCounter < 5 Then F_sUnknownLinesText &= sLine & gb.NewLine 'ssUnknown.Add(sLine)
          ColumnView1[sKey][F_iColumnSelect] = "PicWarning" '!
        Endif 'F_iColumnsReadMax
      Endif 
      
    Next '................................................. 
  Endif 
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

  mnuFehlzeilen.Text = ("?-Zeilen=") & iUnknownCounter
  If iUnknownCounter > 0 Then 
    F_sUnknownLinesText = Str(iEmptyOrDouble) & Space(1) & ("von") & Space(1) & Str(ssExist.Count) & Space(1) & ("Zeilen leer oder doppelt") & gb.NewLine 
    F_sUnknownLinesText &= Str(iUnknownCounter) & Space(1) & ("?-Zeilen") & ". " & ("Beispiel") & ": " & gb.NewLine 
    sUnknown = M01Functions.CheckTextTerminwecker(F_sUnknownLinesText)
    F_sUnknownLinesText &= sUnknown
  Endif 
  ButtonSave.Background = Color.Default
  ColumnviewIcons()
  ColumnView1.UnselectAll() '>AddAppend
  ''Activate or Deactivate:
  ColumnViewAddAppend() ''with ColumnViewSort() 'with .EnsureVisible()
  ColumnViewBackup()
  If F_iMusterTermine1Names2Projects3 = 2 Then ProjectLineSelection() '>Form5Projekte
  ' TextBoxPath.SelectAll()
  ' TextBoxPath.Insert(sDirFile) '>Form18Diagramm
  ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  F_bListChanged = False
  If sDirFile = FilePathForm() Then F_statFilePathForm = Stat(sDirFile)
  
JumpEnd:
  ColumnView1Resize() 'with Title-Info
  If ColumnView1.Columns.Count > 5 Then 
    If ColumnView1.Columns[5].Title Then ColumnViewInfo(ColumnView1.Columns[5].Title)
  Endif 
  ColumnViewSort(F_iColumnSort)
  ColumnView1.Visible = True
  ProgressBarONoff(False)
  dateEnd = Now 
  F_iSecondsFileRead = DateDiff(dateEnd, dateBegin, gb.Second) 'as Integer
  WindowTitle()
  
Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
  IconError.Raise '▲top level▲  (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
  IconError.Visible = True
  TextBoxPath.Foreground = F_iColorRed
  If Exist(sDirFile) = True Then Close #hFile
  ColumnView1.Visible = True
  
End ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Public Function ReadRepairG(Optional sLine As String = "") As String[]
  Dim iColumn As Integer
  Dim sLinePart, sUnknown, sYYYYMMDD As String 
  Dim ssUnknown As String[]
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  iColumn = 0
  For Each sLinePart In Split(sLine & hTab, hTab) ' Stringarray
    ' Print sLinePart
    If sLinePart And sLinePart Like "*????-??-??*" Then 
      If iColumn < F_iColumnsReadMax Then 
        sUnknown &= sLinePart & hTab
      Else
        If Not ssUnknown Then ssUnknown = New String[]
        sYYYYMMDD = String.Right(sLinePart, 10)
        If sYYYYMMDD Like "*????-??-??*" Then 
          sUnknown &= String.Left(sLinePart, String.Len(sLinePart) - 10) 
          ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          iColumn = 0
          sUnknown = sYYYYMMDD & hTab ''Reset, Begin...
        Endif 
      Endif
    Else If iColumn > 0 Then 
      sUnknown &= sLinePart & hTab
    Endif 
    iColumn = iColumn + 1
  Next
  If Replace(sUnknown, hTab, "") Then 
    If Not ssUnknown Then ssUnknown = New String[]
    ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
  Endif  
  ' If ssUnknown Then sUnknown = ssUnknown.Join(hReturn)
  
  Return ssUnknown
  
  Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
End

Public Sub ColumnviewIcons()
  
  Dim sKey, sIcon As String 
  Dim iLine As Integer
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sIcon = ColumnView1[sKey][F_iColumnSelect]
    ColumnView1[sKey].Picture = ColumnViewImages(sIcon).Picture 
  Next
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowTitle()
  
  Dim sKey As String = "?"
  Dim sSpace, sProjectName As String 
  
  sSpace = Space(1)
  sProjectName = Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]
  
  If ColumnView2.Visible = False Then 
    Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView1.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & "), " & ("Aktiv") & ": " & ("Projekt") & Space(1) & String.Left(sProjectName, 30) 
    If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last
    ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
  Else 
    Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & "), " & ("Aktiv") & ": " & ("Projekt") & Space(1) & String.Left(sProjectName, 30) 
    If ColumnView2.Selection.Max > -1 Then sKey = ColumnView2.Selection.Last
    If String.Len(sKey) < 4 Then 
      LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
    Else 
      LabelSearchLineNr.Text = sKey 'only Key (number)  
    Endif 
    SaveSelection.Tooltip = Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Auswahl speichern in...")
  Endif 
  ColumnViewAscending()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  If ColumnView2.Columns.Ascending = True Then  
    ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  
Catch 
  FMain.ErrorText
    
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
 
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sStandard, sMessage As String 
  
  SettingsReadSave("save") 'Save window settings when application closes
  
  If F_bListChanged = False And F_bKeyboardInput = True Then
    sMessage = "<font color=gray>" & String.Left(Text5.Text, 50) & "</font>" & "<br>"
    sMessage &= "..." & "<br>"
    sMessage &= "<font color=red><b>" & ("Nicht gespeichert.") & "</b></font>" & "<br>"
    
    Select Message.Question(sMessage, ("Bearbeiten..."), ("Schliessen"), ("Abbrechen"))
      Case 1, 3 'Edit, Close
        Stop Event  ' Vorgang abbrechen
      Case 2 'Cancel
        '...
    End Select
  Endif
  
  If F_bListChanged = True Then
    sMessage = "<h1><font color=red>" & ("Veränderte Liste") & "</font></h1>" 
    sMessage &= "<font color=gray>" & FilePathForm() & "</font>" & "<br>"
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If F_sProjectOnlyName = String.LCase(Application.Name) Then 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font><font color=gray>" & Space(1) & ("(Standard)") & "</font></h3>"
      Else 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font></h3>"
      Endif 
      sMessage &= sStandard 
      sMessage &= CheckProjectOnlyName(F_sProjectOnlyName) & "<br>"
    Endif
    
    Select Message.Question(sMessage, "○ " & ("Speichern"), ("Schliessen"), ("Abbrechen"))
      Case 1 'Save:
        SaveG()
      Case 2 'Close:
        '...Leerlauf
      Case 3 'Cancel:
        Stop Event  ' Vorgang abbrechen
    End Select
  Endif
  
  F_bESCpressedON = False
  ' If F_iListChangedCounter > 0 Then FMain.F_bNeueinlesenStarten = True ' —▶ Timer
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form18Projektbearbeiten.Left]
      iY = Settings[F_sForm &/ "Top", Form18Projektbearbeiten.Top]
      iW = Settings[F_sForm &/ "Width", Form18Projektbearbeiten.W]
      iH = Settings[F_sForm &/ "Height", Form18Projektbearbeiten.H]
      Form18Projektbearbeiten.Move(iX, iY, iW, iH)
      F_bMoreButtons = Settings[F_sForm &/ "F_bMoreButtons", F_bMoreButtons]
      F_i22 = Settings[F_sForm &/ "F_i22", F_i22] 
      TextListSearch.SelectAll()
      TextListSearch.Insert(Settings[F_sForm &/ "TextListSearch.Text", TextListSearch.Text])
      
    Case "s" ''Save
      'Save window settings when application closes (Fenster-Position sichern wenn es geschlossen wird)
      Settings[F_sForm &/ "Left"] = Form18Projektbearbeiten.Left
      Settings[F_sForm &/ "Top"] = Form18Projektbearbeiten.Top
      Settings[F_sForm &/ "Width"] = Form18Projektbearbeiten.Width
      Settings[F_sForm &/ "Height"] = Form18Projektbearbeiten.Height
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      Settings[F_sForm &/ "F_i22"] = F_i22
      Settings[F_sForm &/ "TextListSearch.Text"] = TextListSearch.Text
            
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG(Optional sDirFileAsCopy As String = "")
  
  Dim sText, sMessage As String
  Dim iLine, iColumn, iDoubleLines As Integer
  Dim sPath, sDirFile As String
  Dim sInfo1, sInfo2 As String
  Dim sKey, sLine As String
  Dim PicSave, PicDouble, PicQuestion As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 

  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicSave = ColumnViewImages("PicSave").Picture 
  PicDouble = ColumnViewImages("PicDouble").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture 
  
  If sDirFileAsCopy Then 
    sDirFile = sDirFileAsCopy
  Else 
    sDirFile = FilePathForm()
  Endif
  
  If Exist(sDirFile) = True Then 
    sInfo1 = Format(Stat(sDirFile).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sDirFile).Size 
  Else 
    sInfo1 = Format(Now, "yyyy-mm-dd hh:nn:ss.uu") & "0" 
  Endif 
  sInfo2 = sInfo1 
  
  If Not F_ooCVBackups Then ColumnViewBackup()
  TextBoxPath.Foreground = Color.Default
  IconError.Visible = False
  F_bESCpressedON = False
  Form18Projektbearbeiten.Window.Title = Application.Name & " - " & File.Name(sDirFile) & Space(2) & ("speichern...")
  'Muster: SicherungsDatei = SicherungOrdner &/ "backup_" & Name & "_" & Format(Now, "yyyy-mm-dd_dddhh-nn-ss") & ".txt"
  ssExist = New String[]
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
    Endif 
    
    If ColumnView1[sKey].Text <> "" Then
      sLine = ""
      For iColumn = 0 To ColumnView1.Columns.Max
        If iColumn < F_iColumnsReadMax Then 
          sLine &= ColumnView1[sKey][iColumn] & hTab
        Else
          sLine &= ColumnView1[sKey][iColumn] '& hReturn
          ' sLine = Replace(sLine, String.Chr(65533), String.Chr(182)) '"?" unknow, "¶" Return
          Break
        Endif
      Next
      If ssExist.Find(sLine) = -1 Then ' no double (nicht doppelte Zeilen)
        ssExist.Add(sLine)
        ' sText = sText & sLine 
        ColumnView1[sKey].Picture = PicSave
        ColumnView1[sKey][F_iColumnSelect] = "PicSave"
      Else
        '..Leerlauf
        iDoubleLines = iDoubleLines + 1
        ColumnView1[sKey].Picture = PicDouble
        ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
      Endif 
      
    Else 
      ColumnView1[sKey].Picture = PicQuestion
      ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
    Endif
  Next
  If ssExist Then sText = ssExist.Join(hReturn)  '& hReturn
  
  ''Title:
  If sText Then 
    If String.InStr(sText, "#" & Application.Name) = 0 Then sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Projekt-Zeiten") & Space(1) & ("Trenner: TABulator") & gb.NewLine & sText 
  Endif
  
  If F_bESCpressedON = True Then Goto Ende
  
  ''Save:
  sPath = M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
  
  If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  ' M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, Now, True) 'TRUE (open/refresh), FALSE (close)
  
  If Exist(sPath) = True Then 
    If iDoubleLines > 0 Then ButtonLineNr.Text = ("Doppelte Zeilen") & ": " & Str(iDoubleLines)
    F_bListChanged = False
    sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size
  Else ''Alternativ:
    sMessage = sPath & hReturn 
    sMessage &= ("Datei nicht gefunden") & "!" & hReturn & hReturn 
    sMessage &= ("Liste speichern?")
    Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
      Case 1
        Dialog.Path = sDirFile
        Dialog.AutoExt = True 
        Dialog.Title = ("Liste speichern...")
        'If Dialog.SaveFile() Then Return 'Kurzform
        If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
          Return ' User pressed Cancel -
        Else 'Gibt Datei-Name zurück
          '=False, nicht abgebrochen
        Endif
        sPath = M01Functions.FileTextPlus(Dialog.Path, sText, True) ' TRUE=overwrite (überschreiben)
        If Exist(sPath) = True Then sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size 
        F_bListChanged = False
        'FMain.F_bNeueinlesenStarten = TRUE ' über Timer
      Case 2
        '... Cancel
    End Select
  Endif
  
Ende:
  ProgressBarONoff(False)
  If Exist(sPath) = True Then ''Check
    F_statFilePathForm = Stat(sPath) 'Refresh
    If sInfo1 = sInfo2 Then ' nicht gespeichert nicht verändert?
      TextBoxPath.Foreground = F_iColorRed
      IconError.Visible = True
      sMessage = sPath & "<br><br>" 
      sMessage &= "<font color=red>" & ("Nicht gespeichert?") & "</font>"
      Select Case Message.Warning(sMessage, ("Ordner..."), ("Abbrechen"))
        Case 1 'Directory
          M01Functions.FileManagerOpen(sPath)
        Case 2 'Cancel
          '...
      End Select 
    Else ''gespeichert
      ButtonSave.Background = Color.Default 
      F_iCVUndoRedoPointerSave = F_iCVUndoRedoPointer
    Endif
    TextBoxPath.Text = sPath '& Space(1) & Format(Stat(sPath).LastModified, "ddd dd.mm.yyyy hh:nn") & Space(3) & File.FormatSize(Stat(sPath).Size, True) 'Format(statInfo2.Size, "#,###") & "" & "Bytes"
    LabelInfoPathG(sPath)
  Endif 'Exist
  F_bKeyboardInput = F_bListChanged
  ColumnViewBackup()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  ' ColumnViewListChangeLED()
  If F_bListChanged = False Then ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  
End

Public Sub ColumnView1_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  If Mouse.Right Then mnuMaus.Popup 'or > Eigenschaften PopupMenu = mnuMaus
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions("cut")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewClick()
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim iT8 As Integer
  Dim sKey, sValue As String
  Dim hDate, dateTime As Date
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    sKey = ColumnViewCurrentKey()
    If ColumnView1.Exist(sKey) = True Then 
      T0 = ColumnView1[sKey][0] 'Datum
      T1 = ColumnView1[sKey][1] 'Uhr
      T2 = ColumnView1[sKey][2] 'WTag von
      T3 = ColumnView1[sKey][3] 'Q
      T4 = ColumnView1[sKey][4] 'KW
      T5 = ColumnView1[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView1[sKey][6] 'Uhr
        T7 = ColumnView1[sKey][7] 'WTag bis
        T8 = ColumnView1[sKey][8] 'Sek.
        T9 = ColumnView1[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr  
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView1.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView1.Columns.Max > 5 Then ColumnView1.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    ' sKey = ColumnViewCurrentKey()
    sKey = ColumnView2.Current.Key
    sKey = ColumnView2[sKey][F_iColumnNr]
    If ColumnView1.Exist(sKey) = True Then 
      ColumnView1[sKey].Selected = True 
      ColumnView1[sKey].EnsureVisible
    Endif 
    sKey = ColumnView2.Current.Key
    If ColumnView2.Exist(sKey) = True Then 
      T0 = ColumnView2[sKey][0] 'Datum
      T1 = ColumnView2[sKey][1] 'Uhr
      T2 = ColumnView2[sKey][2] 'WTag von
      T3 = ColumnView2[sKey][3] 'Q
      T4 = ColumnView2[sKey][4] 'KW
      T5 = ColumnView2[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView2[sKey][6] 'Uhr
        T7 = ColumnView2[sKey][7] 'WTag bis
        T8 = ColumnView2[sKey][8] 'Sek.
        T9 = ColumnView2[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr 
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr 
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView2.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView2.Columns.Max > 5 Then ColumnView2.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateTimeNoticeBackup(Optional UndoRedo As String = "+")
  
  Dim hObj As Object
  
  Select Case UndoRedo
    Case "+" ''Backup
      If Not F_ooDateTimeNoticeBackup Then F_ooDateTimeNoticeBackup = New Object[]  
      hObj = [Text0.Text, Text1.Text, Text5.Text, Text2.Text]
      F_ooDateTimeNoticeBackup.Push(hObj)
      F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
    Case "<" ''Undo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer - 1
        If F_iDateTimeNoticeBackupPointer < 0 Then F_iDateTimeNoticeBackupPointer = 0
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
    Case ">" ''Redo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer + 1
        If F_iDateTimeNoticeBackupPointer > F_ooDateTimeNoticeBackup.Max Then F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function Columnview1EnsureVisible() As String 'Key
  
  Dim sK2 As String 
  
  If ColumnView1.Visible = True Then 
    If ColumnView1.Current Then 
      sK2 = ColumnView1.Current.Key
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Else If ColumnView2.Visible = True Then 
    If ColumnView2.Current Then 
      sK2 = ColumnView2.Current.Key
      If ColumnView2.Exist(sK2) = True Then ColumnView2[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Endif 
  
  Return sK2
  
  Catch 
    FMain.ErrorText
  
End

Public Sub ButtonInputG() 'Zeileneintrag einfügen
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim T0b, T1b, T2b, T3b, T4b, T5b As String 
  Dim sLine, sText, sMessageLines As String
  Dim sValue, sMessage, sHTMLa, sHTMLb, sSpace, sUntil As String
  Dim sKey As String
  Dim iSecond, iHH, iMM As Integer
  Dim it, iLine, iDiff, iCounter, iOnly1x As Integer
  Dim hDate0, hDate1, hDate2, hDateNr As Date
  Dim sTime1, sTime2 As String 
  Dim ssTime As String[]
  Dim PicRefresh As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  F_bESCpressedON = False
  PicRefresh = ColumnViewImages("PicRefresh").Picture 
  
  sHTMLa = "<font color=darkgreen><b>"
  sHTMLb = "</b></font>"
  sSpace = "&nbsp;" 'Leerzeichen 1x
  Try sUntil = "<font color=#" & Hex(Label7Bis.Foreground, 6) & ">" & ButtonBis.Text & "</font>"
  
  If Not F_ooCVBackups Then ColumnViewBackup()
  
  Columnview1EnsureVisible()
  
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T1 = Text1.Text
    T2 = Format(hDate1, "ddd")
    T3 = Str(M01Functions.DateQuarterG(hDate1)) & ("Q")
    T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      T6 = Text2.Text
      T7 = T2
      T8 = ButtonSum.Tooltip
      T9 = ButtonDauer.Text
      
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then iSecond = 0
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Else 
    ''Timer
    T0 = Text0.Text
    T1 = Text1.Text
    T2 = T0
    T3 = ("-Q")
    T4 = ("-KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
  Endif
  
  sKey = ColumnViewCurrentKey() 'as String 
  If sKey Then
    ColumnView1[sKey][0] = T0
    ColumnView1[sKey][1] = T1
    ColumnView1[sKey][2] = T2
    ColumnView1[sKey][3] = T3
    ColumnView1[sKey][4] = T4
    ColumnView1[sKey][5] = T5
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      If Not T8 Then T8 = ButtonSum.Tooltip
      If Not T9 Then T9 = ButtonDauer.Text
      ButtonSum.Tooltip = T8
      ButtonDauer.Text = T9
      ColumnView1[sKey][6] = T6
      ColumnView1[sKey][7] = T7
      ColumnView1[sKey][8] = T8
      ColumnView1[sKey][9] = T9
    Endif 
    ColumnView1[sKey].Picture = PicRefresh
    ColumnView1[sKey][F_iColumnSelect] = "PicRefresh"
    F_bListChanged = True
    F_iListChangedCounter = F_iListChangedCounter + 1
  Endif 
  
  If PanelBis.Visible = True Then '{{{{{{{{{{{{{...}}}}}}}}}}}}}
    sValue = Text0b.Text
    If sValue Like "*????-??-??*" Then
      hDate2 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
      iDiff = DateDiff(hDate1, hDate2, gb.day)
      T5 = Replace(String.Left(T5, 3), "{", "") & String.Mid(T5, 4) 'erst vorne Klammern entfernen
      T5 = Replace(String.Left(T5, 3), "}", "") & String.Mid(T5, 4)
      Try it = String.InStr(T5, "_", -Len(T5)) ' Ende mit mehreren "_" entfernen 
      If it > 0 Then T5 = String.Left(T5, it)
      sText = ""
      iCounter = 0
      iOnly1x = 0
      For it = 0 To iDiff
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        iCounter = iCounter + 1
        hDateNr = DateAdd(hDate1, gb.Day, it) 'gb.Day=Integer, it=Integer
        T0b = Format(hDateNr, "yyyy-mm-dd")
        T1b = T1
        T2b = Format(hDateNr, "ddd")
        T3b = Str(M01Functions.DateQuarterG(hDateNr)) & ("Q")
        T4b = Format(M01Functions.DateCalenderWeek(hDateNr), "00") & ("KW") '00...52
        T5b = String.Left(T5, 30) & "_"
        If it = 0 Then T5b = T5 & "_"  'Anfang mit ganzem Text & "_"
        If it = iDiff Then T5b = "}" & T5b
        If it = 0 Then T5b = "{" & T5b  '{}
        sLine = T0b & hTab & T1b & hTab & T2b & hTab & T3b & hTab & T4b & hTab & T5b & hReturn
        sText = sText & sLine ' —▶ append (kompletter Text für Datei, > anhängen)
        If it < 4 Or it = iDiff Then '1,2,3... + last line
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Else If it = 4 Then '1x...
          sMessageLines &= "<br><b>" & "..." & "</b><br>" 
        Else If it > iDiff - 4 Then 
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Endif
      Next
      sMessageLines &= "<hr>"  'Separator line (Trennlinie) ———————— 
      If iCounter = 1 Then
        sValue = ("Zeile")
      Else
        sValue = ("Zeilen")
      Endif
      sMessage = "<h3>" & sHTMLa & Format(hDate1, "yyyy-mm-dd ddd") & sSpace & sUntil & sSpace & Format(hDate2, "yyyy-mm-dd ddd") & sHTMLb & "</h3>"  
      sMessage &= sMessageLines & "<br>" 
      sMessage &= "<h3>" & "+" & Str(iCounter) & sSpace & sValue & "." & sSpace & sHTMLa & ("+Einfügen in die Liste") & "?" & sHTMLb & "</h3>"
      
      ProgressBarONoff(False) 
      Select Case Message.Question(sMessage, ("+Einfügen"), ("Abbrechen"))
        Case 1
          PanelBis.Visible = False
          F_sLinesCopy = sText 
          ColumnViewPaste() 
          F_bListChanged = True
        Case 2 ' Cancel
          '...
      End Select
      
    Endif 
  Endif 'PanelBis {{{{{{{{{{{{{{{{{{{{{{{{{{
  
  TextBackgroundAll(Color.White)
  ButtonSave.Background = Color.Red
  ButtonInput.Background = F_iColorGreen
  ColumnViewBackup()
  ColumnViewListChangeLED()
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonInputCheck() 'calculate Line new (Zeileneintrag neu berechnen)
  
  Dim T0, T5, T8, T9 As String 
  Dim iSecond, iT8, iHH, iMM As Integer
  Dim hDate0, hDate1, hDate2 As Date
  Dim sTime1, sTime2 As String
  Dim ssTime As String[]
  Dim sValue As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Returnzeichen ¶ ersetzen
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If T0 <> Text0.Text Then Text0Insert(T0)
    If T5 <> Text5.Text Then Text5Insert(T5)
    
    If F_iMusterTermine1Names2Projects3 = 3 Then
      T8 = ButtonSum.Tooltip
      If IsInteger(T8) = True Then iT8 = CInteger(T8)
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        If iT8 > 0 Then hDate2 = DateAdd(hDate1, gb.Second, iT8) 'Seconds (genauer)—▶ 00:00:00
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then 
          iSecond = 0
          ColumnViewInfo(("Projekt-Zeit eingeben/korrigieren."))
        Else 
          ColumnViewInfo(("=neu berechnet"))
        Endif 
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Endif
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektEin_Click()
  
  ProjectONoff(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektAus_Click()
  
  ProjectONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLineSelection()
  
  Dim bFound As Boolean
  Dim sKey, sK1, sT5, sPath As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicOff = ColumnViewImages("PicOFF").Picture 
  
  If Not F_sProjectOnlyName Then F_sProjectOnlyName = ProjectOnlyName()
  
  ' ColumnView1.UnselectAll()   
  ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey][0] <> "" Then
      ColumnView1[sKey].Picture = PicOff
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF"
      sT5 = String.LCase(ColumnView1[sKey][5])
      sT5 = Replace(sT5, gb.NewLine, "") 'no new line "\n" = Chr(10)
      sT5 = Replace(sT5, gb.Cr, "") 'no Return "\r" = Chr$(13)            gb.CrLF = Chr(13) & Chr(10)
      If sT5 = F_sProjectOnlyName Then
        ColumnView1[sKey].Picture = PicON
        ColumnView1[sKey][F_iColumnSelect] = "PicON"
        ColumnView1[sKey].EnsureVisible
        ColumnView1[sKey].Selected = True
        sK1 = sKey
        bFound = True
        Text0Insert(ColumnView1[sKey][0])
        Text1Insert(ColumnView1[sKey][1])
        Text5Insert(ColumnView1[sKey][5])
        ButtonProjectON.Picture = PicTemplateConnectON.Picture
      Endif
    Endif
  Next
  ' CheckBoxONoff.Value = bFound
  ' CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
  sPath = CheckProjectOnlyName(Text5.Text) 'Dir/File.txt < (F_sProjectOnlyName) 
  If Exist(sPath) = True Then
    TextBoxPath.Text = sPath
  Else
    TextBoxPath.Text = ("Ohne Datei")
  Endif
  If ColumnView1.Exist(sK1) = False Then sK1 = ColumnView1.Keys.Last
  If ColumnView1.Exist(sK1) = True Then 
    If ColumnView1[sK1][5] = F_sProjectOnlyName And bFound = True Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture 
    Else 
      ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    Endif 
    ColumnView1[sK1].EnsureVisible
    If ColumnView1[sK1][5] = "" Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture
    Endif 
  Endif 
  
  ColumnViewInfo(("Aktivieren") & ": " & Space(1) & F_sProjectOnlyName)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectONoff(Optional bONoff As Boolean = False)
  
  Dim bFound As Boolean 
  Dim sKey, sK1, sT5 As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  If F_iMusterTermine1Names2Projects3 = 2 Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    PicON = ColumnViewImages("PicON").Picture 
    PicOff = ColumnViewImages("PicOFF").Picture 
    
    F_sProjectOnlyName = ProjectOnlyName()
    
    sK1 = ColumnViewCurrentKey()
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView1[sKey].Picture = PicOff 
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF"
    Next 
    If sK1 And bONoff = True Then
      If ColumnView1[sK1][0] <> "" Then
        ColumnView1[sK1].Picture = PicON
        ColumnView1[sK1][F_iColumnSelect] = "PicON"
        ColumnView1[sK1].EnsureVisible
        ColumnView1[sK1].Selected = True
        'Check Name:
        sT5 = ColumnView1[sK1][5]
        sT5 = Replace(sT5, "/", "_") 'no Directory
        sT5 = Replace(sT5, Space(1), "_") 'no Space
        sT5 = Replace(sT5, gb.NewLine, "") 'no Return
        ColumnView1[sK1][5] = String.LCase(sT5)
        bFound = True
        Text0Insert(ColumnView1[sK1][0])
        Text1Insert(ColumnView1[sK1][1])
        Text5Insert(ColumnView1[sK1][5])
        F_sProjectOnlyName = ColumnView1[sK1][5]
        F_bListChanged = True
        ButtonSave.Background = Color.Red
        ColumnViewBackup()
        ColumnViewListChangeLED()
        WindowTitle()
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Endif
    Endif
    CheckBoxONoff.Value = bFound
    CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
    If bFound = False Then ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
    ColumnViewInfo(("Aktiviert") & ": " & Space(1) & F_sProjectOnlyName)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLinesSaveRefresh()
  
  Dim sKey As String 
  Dim PicEmpty, PicON, PicAdd, PicSave As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicAdd = ColumnViewImages("PicAdd").Picture 
  PicSave = ColumnViewImages("PicSave").Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Picture = PicON Then F_sProjectOnlyName = ColumnView1[sKey][5]
    If ColumnView1[sKey].Picture <> PicAdd Then 
      ColumnView1[sKey].Picture = PicEmpty ' Bild entladen
      ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
    Endif 
    If ColumnView1[sKey][0] <> "" Then 
      ColumnView1[sKey].Picture = PicSave
      ColumnView1[sKey][F_iColumnSelect] = "PicSave"
    Endif 
  Next
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckProjectOnlyName(Optional sCheckProjectName As String = "") As String 
  
  Dim sDir, sTempPathTest As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  If Not sCheckProjectName Then sCheckProjectName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]) 'Einheitliche kleinschreibung
  
  ''Check
  sCheckProjectName = Replace(sCheckProjectName, "/", "_") 'no Directory
  sCheckProjectName = Replace(sCheckProjectName, Space(1), "_") 'no Space
  sCheckProjectName = Replace(sCheckProjectName, gb.NewLine, "") 'no Return
  sCheckProjectName = String.LCase(sCheckProjectName)
  
  ' sTempPathTest = M01Functions.FileTempDirFileTxt(sCheckProjectName)
  sTempPathTest = M01Functions.CheckDirectoryCache() &/ sCheckProjectName & ".txt"
  Try File.Save(sTempPathTest, "Test" & Now) 'temp-Files werden am Programm-Ende automatisch gelöscht.
  If Exist(sTempPathTest) = True Then 
    Text5Insert(sCheckProjectName)
    ButtonTest.Picture = PicTemplateBookA.Picture
    ButtonTest.Tooltip = ("Test. Als Datei-Name geeignet") & ": " & Space(1) & ("project_") & sCheckProjectName & ".txt"
    PanelText5.Background = F_iColorGreenAlpha150
  Else 
    ButtonTest.Picture = PicTemplateBookQuestion.Picture 'Picture["icon:/32/help"]
    ButtonTest.Tooltip = ("Test. Nicht als Datei-Name geeignet. Ungültige Zeichen?") & Space(1) & ("Eingabe") & ": " & ("Abc-z, 0-9")
    PanelText5.Background = F_iColorRedAlpha150
  Endif 
  ColumnViewInfo(ButtonTest.Tooltip)
  Return sDir &/ ("project_") & sCheckProjectName & ".txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewCurrentKey() As String 
  
  Dim sKey As String 
  
  If ColumnView1.Selection.Max = -1 Then ListMenuGroupFunctions("addappend")
  If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last 'only Key (number)
  ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  Return sKey
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5_MouseDown()
  
  PanelText5.Background = Color.White
  F_iText5SearchPosition = Text5.Pos
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_KeyPress()
  
  DateChooser1.Tag = "0"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_Change()
  
  Dim hDate As Date
  
  hDate = M01Functions.DateCheckyyyymmddhhnn(Text0b.Text, "00:00") 'as Date
  If hDate Then
    Label3b.Text = Format(hDate, "dddd") 'as Date
    Label3b.Foreground = Color.Default
    Text0bBG.Background = F_iColorGreenAlpha150
  Else
    Label3b.Text = "?"
    Label3b.Foreground = Color.Red
    Text0bBG.Background = F_iColorRedAlpha150
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_KeyPress()
  
  DateChooser1.Tag = "0b"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SelectHide0Date1Clock2Timer3(Optional iHide0_Date1_Clock2_Timer3_Clock4 As Integer = 0)
  
  Dim sValue As String
  Dim hDate As Date
  
  DateChooser1.Visible = False
  ColumnView1.Visible = True
  ColumnView2.Visible = False
  ColumnView3.Visible = False
  ScrollViewWeekDay.Visible = False
  ButtonDateCancel.Visible = False
  PanelSearchList.Visible = False
  
  Select Case iHide0_Date1_Clock2_Timer3_Clock4
    Case 0 'ohne
      ColumnView1.Visible = True
      If LabelTimerWT.Tag And Text0.Text <> LabelTimerWT.Tag Then Text0Insert(LabelTimerWT.Tag)
      LabelTimerWT.Tag = Null
    Case 1 'Datum
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
      If DateChooser1.Tag = "0" Then
        sValue = Text0.Text
      Else
        PanelBis.Visible = True
        sValue = Text0b.Text
        If sValue Like "????-??-??" Then
          '...Leerlauf
        Else
          sValue = Format(Date, "yyyy-mm-dd")
        Endif
      Endif
      
      If String.InStr(sValue, "-") = 0 Then
        '...Leerlauf
        hDate = Date
      Else
        If sValue Like "????-??-??" Then
          
          hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        Else
          hDate = Date
        Endif
      Endif
      DateChooser1.Mode = DateChooser1.DateOnly
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      ButtonDateCancel.Visible = True
    Case 2 ''Uhr
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView3.Left + ColumnView3.W, ColumnView1.Top, ColumnView1.Width - ColumnView3.W, ColumnView1.Height)
      DateChooser1.Mode = DateChooser1.DateTime 'TimeOnly
      If DateChooser1.Tag = "1" Then 
        If IsDate(Text1.Text) = True Then Try hDate = Time(CDate(Text1.text)) Else hDate = Time
      Else  
        If IsDate(Text2.Text) = True Then Try hDate = Time(CDate(Text2.text)) Else hDate = Time
      Endif 
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      
      ClockTimeList0to24h()
      ButtonDateCancel.Raise 
      ColumnView3.Raise 
      ColumnView3.Visible = True
      ButtonDateCancel.Visible = True
    Case 3 ''Timer
      ScrollViewWeekDay.Raise 
      ButtonDateCancel.Raise
      ScrollViewWeekDay.Visible = True
      If Text0.Text Not Like "????-??-??" Then TextBoxWT.Insert(Text0.Text)
      ButtonDateCancel.Visible = True
    Case 4 ''{Bis}
      If F_iMusterTermine1Names2Projects3 = 1 Then 
        If Text0b.Text Like "????-??-??" Then
          'Leerlauf
        Else
          Text0bInsert(Format(Date, "yyyy-mm-dd"))
        Endif
        PanelBis.Visible = True
        PanelBis.Raise
        ButtonBis.Background = Label7Bis.Background
        Text0b.Pos = String.Len(Text0b.Text)
        ' Text0b.SetFocus
      Endif 
    Case Else ''ohne
      ColumnView1.Visible = True
  End Select
  ButtonInput.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0Insert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0.Text <> sDatum Then 
    Text0.SelectAll()
    Text0.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0bInsert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0b.Text <> sDatum Then 
    Text0b.SelectAll()
    Text0b.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1Insert(Optional sTime As String = "hh:nn")
  
  If Text1.Text <> sTime Then 
    Text1.SelectAll()
    Text1.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2Insert(Optional sTime As String = "hh:nn")
  
  If Text2.Text <> sTime Then 
    Text2.SelectAll()
    Text2.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Insert(Optional sNotiz As String = ("Notiz"))

  Text5.Clear()
  Text5.SelectAll()
  Text5.Insert(sNotiz)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_Change() 'yyyy-mm-dd
  
  Dim sValue, sLine, Info As String
  Dim hDate As Date
  
  If Text0.Tag <> "" Then Goto Ende
  Text0BG.Background = Color.White
  If Text0.Text = "" Then Goto Ende
  If Text0.Text Like "????-??-??" Then                                                  ''Datum
    If Error Then Error.Clear()
    sValue = Text0.Text
    
    hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    If hDate = Null Then
      Text0BG.Background = F_iColorRedAlpha150
      ButtonWeekDay.Text = "?"
      ButtonWeekDay.Tooltip = ("Wochentag")
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Else
      ButtonWeekDay.Text = Format(hDate, "ddd") 'as Date
      ButtonWeekDay.Tooltip = Format(Date, "dddd")
      Text0BG.Background = Color.White
    Endif
  Else If String.InStr(sValue, "-") = 0 Then                                                     ''Timer
    sValue = String.LCase(Text0.Text)
    sLine = M01Functions.CheckTimerTextWeekdays0to6(sValue) 'as String, Check  Timer  SoMoDiMiDoFrSa
    If sLine <> "" Then
      Text0BG.Background = F_iColorGreenAlpha150
      Info = ("Timer") & ": " & sLine
    Else
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Endif
  Endif
  If Info Then ColumnViewInfo(Info)
Ende:
  F_bChangeON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBackgroundAll(Optional iColor As Integer = Color.Transparent)
  
  Text0BG.Background = iColor
  Text0bBG.Background = iColor
  Text1BG.Background = iColor
  Text2BG.Background = iColor
  PanelText5.Background = iColor
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Data(dateValue As Date) ' dateValue frei gewählter Variablenname  gambas3
  
  If WeekDay(dateValue) = gb.Friday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Blue, 220) '&HC3DDFF
  Else If WeekDay(dateValue) = gb.Sunday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Yellow, 200)
  Endif 
  DateChooser1.Colors[Date] = Color.Green 'heute
  'Info:
  'DateChooser1.Mode = DateChooser1.DateOnly
  'DateChooser1.Colors.Clear()
  'DateChooser1.Data.Foreground = Color.Red
  'DateChooser1.Data.Font = Font["Italic"] 
  'DateChooser1.Colors["12/31/2000"] = Color.Green ' System, engl. 
  'DateChooser1.Mode = DateChooser1.DateTime 'Kalender- und Zeit-Tabelle, Heute + aktuelle Uhr
  
Catch 
  FMain.ErrorText
  
End ' DateChooser1_Data(dateValue As Date)

Public Sub TextNeuClear()
  
  Dim sMessage As String 
  
  sMessage = "<h3><font color=blue>" & "□" & Space(1) & TextNeu.Tooltip & "?" & "</font></h3>" 
  
  Select Message.Question(sMessage, "+" & ("Neue Zeile"), "□" & Space(1) & TextNeu.Tooltip, ("Abbrechen")) '(0,1,2,3)
    Case 1 'New Line
      NewLineG()
      
    Case 2 'New Input
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd")) 'Text0.Text
      Text1Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      ' Text5.SetFocus
      TextBackgroundAll(Color.White)
      
    Case 3 'Cancel
      '...Abbrechen
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text1.Tag <> "" Then Goto Ende
  Text1BG.Background = Color.White
  If Text1.Text Like "??:??" Then 
    Text1BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text1.Text, 1, 2)
    sMM = String.Mid(Text1.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text1BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text1BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text1.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text2.Tag <> "" Then Goto Ende
  Text2BG.Background = Color.White
  If Text2.Text Like "??:??" Then 
    Text2BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text2.Text, 1, 2)
    sMM = String.Mid(Text2.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text2BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text2BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text2.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewReload()
  
  If F_bListChanged = True Then
    ColumnView2.Visible = False 
    Select Message.Question("<h3><font color=red>" & ("Veränderte Liste") & "</font></h3>", ("Speichern + Neu laden"), ("Neu laden"), ("Abbrechen"))
      Case 1 'Save + Reload (Speichern + neu laden)
        SaveG()
        ReadG()
      Case 2 'Reload (Neu laden)
        ReadG()
      Case 3 'Cancel (Abbrechen)
        '...
    End Select
  Else
    ReadG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSucheG()
  
  If PanelSearchList.Visible = False Then
    PfeilEinfuegen.Visible = False 
    PanelSearchList.Raise() 'Top ▲Level▲ (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    PanelSearchList.Visible = True
    If ButtonSearchListOn.Background <> Color.Green Then 
      ColumnView2.Visible = False
    Else
      ColumnView2.Visible = True
    Endif
    If TextListSearch.Text = "" Then TextListSearch.Text = Format(Date, "yyyy-mm-")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
    TextListSearch.SetFocus
  Else
    PanelSearchList.Visible = False
    PfeilEinfuegen.Visible = True 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CancelSearchG()
  
  PanelSearchList.Visible = False
  SelectHide0Date1Clock2Timer3(0)
  PanelDatum.Visible = True 
  PfeilEinfuegen.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchMinusPlus(Optional sMinusPlus As String = "+")
  
  Dim sSearchText, sLine, sKey As String
  Dim it, iLine As Integer
  Dim iBefore As Integer
  Dim bFound As Boolean
  
  If ColumnView2.Visible = True Then 
    SearchListG()
    If sMinusPlus = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnselectAll()
    Goto Ende
  Endif
  
  If String.InStr(TextListSearch.Text, gb.NewLine) > 0 Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, "")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
  Endif
  sSearchText = String.LCase(TextListSearch.Text)
  sSearchText = Replace(sSearchText, Space(1), "*") ' Leerzeichen ersetzen für beliebige Zeichen bei Suche
  sSearchText = "*" & sSearchText & "*"
  iBefore = F_iSearchPosition
  
  If sMinusPlus = "+" Then '+++++++++++++++++++++++++++++
    F_iSearchPosition = F_iSearchPosition + 1
    If F_iSearchPosition > ColumnView1.Count - 1 Then F_iSearchPosition = ColumnView1.Count - 1
    For it = F_iSearchPosition To ColumnView1.Count - 1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Else '-------------------------------------------------
    F_iSearchPosition = F_iSearchPosition - 1
    If F_iSearchPosition < 0 Then F_iSearchPosition = 0
    For it = F_iSearchPosition To 0 Step -1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Endif
  
  If bFound = True
    ButtonSearchDown.Background = Color.Default
    ButtonSearchUp.Background = Color.Default
  Else
    F_iSearchPosition = iBefore
    If sMinusPlus = "-" Then
      ButtonSearchDown.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
    If sMinusPlus = "+" Then
      ButtonSearchUp.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
  Endif ' bFound
Ende:
  
  If ColumnView1.Selection.Max > -1 Then sKey = (Val(ColumnView1.Current.Key) + 1) Else sKey = "?" 
  LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  LabelSearchLineNr.ToolTip = LabelSearchLineNr.Text
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelSearchLineNr_MouseDown()
  
  TextListSearch.Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextListSearch_KeyPress()
  
  If Key.Code = Key.Return Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, String.Chr(182)) '¶
    Timer3KeyPress.Start 'ButtonSearchG() not in Loop _KeyPress
    Stop Event 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSearchG()
  'SearchMinusPlus("+")
  
  ColumnViewFind("+")
  If Timer3KeyPress.Enabled = False Then SearchListG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchListG()
  
  If ButtonSearchListOn.Background <> Color.Green Then 
    ColumnView2.Visible = False
    ColumnView1.Visible = True
    ColumnView2select1() 'ColumnView2 —▶ ColumnView1
  Else 
    SearchPanelList()
    ColumnView2.Raise
    ColumnView2.Visible = True
    ColumnView1.Visible = False
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelList()
  
  Dim it, iColumn, iLine As Integer
  Dim sK1, sSearchText, sLine As String
  Dim PicFind As Picture
  
  PicFind = ColumnViewImages("PicFind").Picture 
  sSearchText = "*" & Replace(TextListSearch.Text, Space(1), "*") & "*"
  ColumnView2.Clear()
  ColumnView2.Header = True  ' Sichtbar
  'Create Columns (Spalten erzeugen):
  If ColumnView2.Columns.Count <> ColumnView1.Columns.Count Then ColumnView2.Columns.Count = ColumnView1.Columns.Count '+ 1
  For it = 0 To ColumnView1.Columns.Count - 1 'Header/Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
    ColumnView2.Columns[it].Text = ColumnView1.Columns[it].Text
    ColumnView2.Columns[it].Alignment = ColumnView1.Columns[it].Alignment
  Next
  For Each sK1 In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sLine = String.LCase(Str(ColumnView1[sK1][0] & ColumnView1[sK1][1] & ColumnView1[sK1][2] & ColumnView1[sK1][3] & ColumnView1[sK1][4] & ColumnView1[sK1][5] & ColumnView1[sK1][F_iColumnSelect]))
    If sLine Like sSearchText Then 
      ColumnView2.Add(sK1, "", PicFind)
      ColumnView2[sK1][F_iColumnSelect] = "PicFind"
      For iColumn = 0 To ColumnView1.Columns.Count - 1
        ColumnView2[sK1][iColumn] = ColumnView1[sK1][iColumn]
      Next
    Endif
  Next
  ColumnView2.Columns[5].Title = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")   '"  [Strg+Maus]")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_Click()
  
  Dim sKey As String 
  
  sKey = Val(ColumnView2.Current.Key) + 1
  LabelSearchLineNr.Text = ("Zeile") & Space(1) & Str(sKey)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2select1()                                                               'ColumnView2 —▶ ColumnView1
  
  Dim sK2 As String 
  Dim iLine As Integer
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    ColumnView1.Mode = Select.Multiple
    For Each sK2 In ColumnView2.Selection 'Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].Selected = True
    Next
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  Dim sInfo, sSizeAll As String
  Dim it As Integer
  
  sSizeAll = Space(1) & "=" & Space(1) & File.FormatSize(F_longFilesRead, False) 'as String   
  
  If ColumnView1.Count < 2 Then 
    sInfo = Space(2) & ("Leer. Datei öffnen oder +Einfügen") 
  Else 
    If F_iMusterTermine1Names2Projects3 > 1 Then sInfo = Space(3) & ("Projekt-Name") 
    sInfo = ("Notiz") & sInfo & Space(2) & ("Zeilen") & ": " & ColumnView1.Count & sSizeAll
  Endif 
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ColumnView1.Columns[1].Title = ("Uhr")     '00:00 Begin
  ColumnView1.Columns[2].Title = Space(1)    'Su Weekday (Wochentag) 
  ColumnView1.Columns[3].Title = Space(1)    '0Q Quater (Quartal)
  ColumnView1.Columns[4].Title = Space(1)    '0CW CalenderWeek (KalenderWoche)
  ColumnView1.Columns[5].Title = sInfo       'Notice (Notiz)
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Title = ""          'Nr
    ColumnView1.Columns[7].Title = ""          'Undo
    ColumnView1.Columns[8].Title = ""          'Select01
    ColumnView1.Columns[9].Title = ""          'Sort
  Else 
    ColumnView1.Columns[6].Title = ("Uhr")     '00:00 End
    ColumnView1.Columns[7].Title = ""          'Su Weekday (Wochentag)
    ColumnView1.Columns[8].Title = ""          'Seconds 123 (Sekunden)
    ColumnView1.Columns[9].Title = ("Dauer")   '00:00:00 Duration  
  Endif 
  
  ColumnView1.Columns[0].Width = 200
  ColumnView1.Columns[1].Width = 80
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 80
  ColumnView1.Columns[5].Width = 0           'Notice
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Width = 0
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 0  
  Else 
    ColumnView1.Columns[6].Width = 80          '00:00 End
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 160         '00:00:00 Duration  
  Endif 
  
  For it = 10 To ColumnView1.Columns.Max     '>9 or >13
    ColumnView1.Columns[it].Title = ""         'ColumnsUndo
    ColumnView1.Columns[it].Width = 0          'ColumnsUndo
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[F_iColumnUndo].Left 
  
  If ColumnView2.Visible = True Then ColumnView2Resize() 
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13     F_iColumnsCount=14
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  If F_bColumnsMore = True Then 
    ArrowR.Picture = PicTemplateArrowL.Picture
  Else 
    ArrowR.Picture = PicTemplateArrowR.Picture  
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnView2Resize()                                                            'ColumnView2 = ColumnView1
  
  Dim sInfo As String
  Dim it As Integer
  
  sInfo = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")
  ColumnView2.Columns.Count = ColumnView1.Columns.Count                                   'Columns:|0|1|2|3|...|max|
  ColumnView2.Header = ColumnView1.Header                                                 'Title, Row index=0
  ColumnView2.Mode = ColumnView1.Mode
  ColumnView2.AutoResize = ColumnView1.AutoResize 'last column in last row  |abc| => |abcdef>>| 
  ColumnView2.Sorted = ColumnView1.Sorted
  ColumnView2.Resizable = ColumnView1.Resizable                                           'Header <|> <|> Resize with Mouse
  ColumnView2.Columns.Ascending = ColumnView1.Columns.Ascending     '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ColumnView2.Columns[0].Alignment = ColumnView1.Columns[0].Alignment                     '|  123|
  ColumnView2.Columns[2].Alignment = ColumnView1.Columns[2].Alignment                     '| abc |
  ColumnView2.Columns[6].Alignment = ColumnView1.Columns[6].Alignment                     '|  123|
  
  For it = 0 To ColumnView1.Columns.Max
    ColumnView2.Columns[it].Title = ColumnView1.Columns[it].Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
  Next
  ColumnView2.Columns[5].Width = 0
  ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[F_iColumnUndo].Left
  ColumnView2.Columns[5].Title = sInfo
  '.AutoResize width = longest text in Column in last row
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ColumnView2_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  If Mouse.Right Then mnuMaus2.popup '> Eigenschaften PopupMenu = mnMaus2
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions(ListCut.Tag) '"cut"
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBox1G() '*every Year, Birthsdays (*jedes Jahr, Geburtstage)
  
  Select Case CheckBox1.Value
    Case True
      If String.Left(Text5.Text, 1) <> "*" Then Text5Insert("*" & Text5.Text) 'with (mit)
    Case False
      If String.Left(Text5.Text, 1) = "*" Then Text5Insert(String.Mid(Text5.Text, 2)) 'without (ohne)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5JedesJahrpruefen()
  
  If String.Left(Text5.Text, 1) = "*" Then
    CheckBox1.Value = True
  Else
    CheckBox1.Value = False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_MouseUp()
  
  DateChooser1.Tag = "0"
  If DateChooser1.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(1)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_MouseUp()
  
  DateChooser1.Tag = "0b"
  SelectHide0Date1Clock2Timer3(1)
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Change()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then
    Text0Insert(sYYYYMMDD)
  Else If DateChooser1.Tag = "0b"
    Text0bInsert(sYYYYMMDD) 'gambas3
  Else If DateChooser1.Tag = "1"
    If Text0.Text Like "????-??-??" Then 
      If Text0.Text <> sYYYYMMDD Then Text0Insert(sYYYYMMDD)
    Endif 
    Text1Insert(sHHNN)
  Else If DateChooser1.Tag = "2"
    Text2Insert(sHHNN)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Click()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then Text0Insert(sYYYYMMDD)
  If DateChooser1.Tag = "0b" Then Text0bInsert(sYYYYMMDD)
  If DateChooser1.Tag = "1" Then Text1Insert(sHHNN) '00:00 A
  If DateChooser1.Tag = "2" Then Text2Insert(sHHNN) '00:00 B
  If ColumnView3.Visible = True Then ColumnView3Select(sHHNN)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_MouseUp()
  
  DateChooser1.Tag = "1"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_MouseUp()
  
  DateChooser1.Tag = "2"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h()
  
  Dim iHH, iMM, iCounter, iSelect As Integer
  Dim sValue As String
  
  ColumnView3.Clear()
  ColumnView3.Header = False 'without Title (ohne Titel)
  ColumnView3.Sorted = False 'no sort (nicht sortieren!)
  ColumnView3.Columns.Count = 1 'Number Columns (Anzahl Spalten)
  ColumnView3.Columns[0].Width = ColumnView3.Width
  For iHH = 0 To 23 'Hours (Stunden) hh:
    For iMM = 0 To 59 'Minutes (Minuten) :nn
      sValue = Format(iHH, "00") & ":" & Format(iMM, "00")
      iCounter = ColumnView3.Count + 1
      ColumnView3.Add(iCounter, sValue)
      If iMM Mod 10 = 0 Then ''00:00, 00:15, 00:30, ...
        ColumnView3[iCounter].Foreground = Color.Default 
      Else 
        ColumnView3[iCounter].Foreground = Color.LightGray  
      Endif 
      If iMM Mod 30 = 0 Then ''00:00, 00:30, 01:00, ... 
        ColumnView3[iCounter].Background = Color.LightGray 
      Endif 
      If Text1.Text = ColumnView3[iCounter].Text Then
        iSelect = iCounter
      Endif
    Next
  Next
  sValue = "00:00"
  iCounter = ColumnView3.Count + 1
  ColumnView3.Add(iCounter, sValue)
  ColumnView3[iSelect].Selected = True
  ColumnView3[iSelect].EnsureVisible
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3Select(Optional sClock As String = "00:00")
  
  Dim sKey, sFound As String 
  
  If ColumnView3.Keys Then 
    ColumnView3.UnSelectAll()
    For Each sKey In ColumnView3.Keys
      If ColumnView3[sKey].Text = sClock Then 
        ColumnView3[sKey].Selected = True
        sFound = sKey  
        Break
      Endif 
    Next 
    If ColumnView3.Exist(sFound) = True Then 
      ColumnView3[sFound].Selected = True
      ColumnView3[sFound].EnsureVisible()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_Click()
  
  If DateChooser1.Tag = "1" Then Text1Insert(ColumnView3[ColumnView3.Current.key][0])
  If DateChooser1.Tag = "2" Then Text2Insert(ColumnView3[ColumnView3.Current.key][0])
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_MouseUp()
  
  Dim dDate, dTime As Date 
  
  If ColumnView3.Current.Text Then 
    dDate = DateChooser1.Value 'as Date
    dTime = CDate(ColumnView3.Current.Text) '00:00 (*1)
    F_dateNow = Date(Year(dDate), Month(dDate), Day(dDate), Hour(dTime), Minute(dTime), Second(dTime)) 'as Date 
    DateChooser1.Value = F_dateNow
    If DateChooser1.Tag = "1" Then Text1Insert(Format(F_dateNow, "hh:nn"))
    If DateChooser1.Tag = "2" Then Text2Insert(Format(F_dateNow, "hh:nn"))
  Endif 
  
  ''______________________________________________________________________________________________''
  '(*1) Gambas3: "CDate(): Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Hier nur bei hh:nn
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_KeyPress()
  
  DateChooser1.Tag = "1"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_KeyPress()
  
  DateChooser1.Tag = "2"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeichensatz2_Click()
  
  M06InfoText.CharsetABCInfo()
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuShow()
  
  Dim sFileOld As String
  
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1 ''Termine
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Checked = CheckBox1.Value
      mnuJedesJahr.Enabled = True  
      
      mnubirthdaysoutside.Enabled = True 
      mnubirthdaysinside.Enabled = True 
      mnuAuswahlBis.Enabled = True  
      mnuAuswahlTimer.Enabled = True  
      mnueditortermine.Text = ("Termine")
      
    Case 2 ''Project-Names
      mnuProjektEin.Enabled = True 
      mnuProjektAus.Enabled = True 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt-Namen")
      
    Case 3 ''Projects
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt")
      
  End Select 
  
  mnuProjektEin.Visible = mnuProjektEin.Enabled 
  mnuProjektAus.Visible = mnuProjektAus.Enabled 
  
  sFileOld = FilePathFormOldYears()
  sFileOld = File.Name(sFileOld)
  mnuTermineAuslagern.Text = ("Auslagern...") & Space(1) & (" >> ") & Space(1) & sFileOld & Space(1) & ("=schneller")
  mnuTermineEinlagern.Text = ("Einlagern...") & Space(1) & (" << ") & Space(1) & sFileOld 
  mnuexportselection.Text = Replace(mnuexportselection.Text, ("(Suche)"), ("(Suche ") & Format(Now, "yyyy") & "-)")
  mnuMehrSchalter.Checked = PanelListMenu.Visible
  
  mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
  mnuFehlzeilen1.Text = "=" & F_iUnknownCounter & Space(1) & ("?-Zeilen sehen") 
  mnuFehlzeilen2.Text = mnuFehlzeilen1.Text 
  mnuZeilenkorrigieren.Checked = F_bCorrectListON
  ' MenuDiagramExtraW.Checked = F_bPicDiagramLongerON
  mnuSpaltenMehr.Checked = F_bColumnsMore
  mnuSpaltenWeniger.Checked = Not F_bColumnsMore
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuBearbeiten_Show() 'Edit
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatei_Show() 'File
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahl_Show() 'Select
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilen_Show() 
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelG()
  
  If PanelSearchList.Visible = False Then
    ButtonSucheG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Click()
  
  Dim sLine As String
  
  If ToggleButtonW1.Value = True Then sLine = sLine & ToggleButtonW1.Text & gb.Sunday '0
  If ToggleButtonW2.Value = True Then sLine = sLine & ToggleButtonW2.Text & gb.Monday '1
  If ToggleButtonW3.Value = True Then sLine = sLine & ToggleButtonW3.Text & gb.Tuesday '2
  If ToggleButtonW4.Value = True Then sLine = sLine & ToggleButtonW4.Text & gb.Wednesday '3
  If ToggleButtonW5.Value = True Then sLine = sLine & ToggleButtonW5.Text & gb.Thursday '4
  If ToggleButtonW6.Value = True Then sLine = sLine & ToggleButtonW6.Text & gb.Friday '5
  If ToggleButtonW7.Value = True Then sLine = sLine & ToggleButtonW7.Text & gb.Saturday '6
  TextBoxWT.Text = sLine
  Text0Insert(sLine)
  LabelTimerWT.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Enter()
  
  Last.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Leave()
  
  Last.Border = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelTimerG()
  
  If ScrollViewWeekDay.Visible = False Then
    SelectHide0Date1Clock2Timer3(3)
  Else
    SelectHide0Date1Clock2Timer3(0)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ApplyWT_Click()
  
  Text0Insert(TextBoxWT.Text)
  LabelTimerWT.Tag = TextBoxWT.Text
  SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowT5plusG()
  
  Form3Text.Tag = Text5.Text
  FMain.F_bZeilenumbruchON = False
  Form3Text.Tooltip = "" 'Path
  Form3Text.Tag = Text5.Text
  Form3Text.Window.Show
  Form3Text.Visible = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilen1_Click()

  Dim sK1, sLine, sText As String
  Dim it, iLine As Integer
  
  ' If String.InStr(F_sUnknownLinesText, gb.NewLine) = 0 Then 
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      ' Print iLine & " " & ssKeys.Count
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = "" 'Reset
      If ColumnView1[sK1].Background <> Color.Default Then 
        For it = 0 To ColumnView1.Columns.Max
          If it = F_iColumnUndo Then 
            sLine &= ColumnView1[sK1][it] & gb.Tab
          Else If it < ColumnView1.Columns.Max Then 
            sLine &= ColumnView1[sK1][it] & gb.Tab
          Else 
            sLine &= ColumnView1[sK1][it] & gb.NewLine
          Endif
        Next
        sText &= sLine 
        ' F_sUnknownLinesText &= sLine
      Endif 
    Next
    sText = F_sUnknownLinesText & sText 
    ProgressBarONoff(False) 
  ' Endif  
  Form3Text.Tag = sText 'F_sUnknownLinesText
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub AuswahlDatumUhrTimerGroup_Click() 'Gruppe
  
  SelectHide0Date1Clock2Timer3(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtonsG()
  
  If F_bMoreButtons = True Then
    F_bMoreButtons = False
    SelectHide0Date1Clock2Timer3(0)
  Else
    F_bMoreButtons = True
  Endif
  MoreButtons(F_bMoreButtons)
  
Catch 
  FMain.ErrorText
  
End

Public Sub NewLineG()
  
  ColumnView1.UnselectAll()
  ListMenuGroupFunctions("addappend")
  Text5.Pos = String.Len(Text5.Text)
  ' Text5.SetFocus
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxWT_Change()
  
  If TextBoxWT.Text = "" Then
    ApplyWT.Background = Color.ButtonBackground
  Else
    ApplyWT.Background = Color.SelectedBackground
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewOrig()
  
  Dim it, iLine As Integer
  Dim sOrigText As String 
  Dim PicEmpty As Picture
  Dim sKey, sLine As String 
  Dim hTab As String 
  
  ''ColumnView1
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView1[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView1[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView1[sKey].Picture = PicEmpty
          ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView2[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView2[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView2[sKey].Picture = PicEmpty
          ColumnView2[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseDown()
  
  F_bMovingON = True
  F_iY1 = Mouse.Y
  MoveLine.Raise
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseMove()
  
  If F_bMovingON = True Then
    MoveLine.Top = MoveLine.Top + Mouse.Y - F_iY1 
    If MoveLine.Top < F_iMoveLineMinH Then MoveLine.Top = F_iMoveLineMinH 'Top▲ (Obergrenze)
    If MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH 'Bottom▼ (Untergrenze)
    Form_Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseUp()
  
  Dim sKey As String
  
  F_bMovingON = False
  sKey = ColumnViewCurrentKey()
  If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuMehrSchalter_Click()
  
  MoreButtonsG()
  
End

Public Sub mnuInfo_Click()
  
  Dim sMessage As String 
  
  sMessage = "(c) www.design-cad.de" & "<br><br>"
  'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub Text5_KeyPress()
  
  PanelText5.Background = Color.White
  ButtonInput.Background = Color.Default
  If F_iMusterTermine1Names2Projects3 > 1 Then 
    If InStr(Text5.Text, String.Chr(47)) > 0 Then 'stop sign "/"=chr(47) /Directory/File.xy
      ButtonTest.Picture = PicTemplateBookQuestion.Picture
      PanelText5.Background = F_iColorRedAlpha150
    Endif 
  Endif 
  F_bKeyboardInput = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSortAZ_Click()
  
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    ColumnView1.Sorted = True 
    ColumnView1.Columns.Sort = 0 'Datum sortieren
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFensterplus_Click()
  
  WindowT5plusG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuJedesJahr_Click()
  
  CheckBox1.Value = Not CheckBox1.Value
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSchliessen_Click()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExportSelectionG()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuexportselection_Click()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveSelectionG()
  
  Dim sFileBefore, sFileBehind, sDir, sPath, sDirFile, sExistFiles As String 
  Dim sK2, sLine, sText, sExistLines, sSpace, sMessage As String
  Dim iColumn, iLine As Integer
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sSpace = Space(1)
  sPath = FilePathForm()
  sDir = File.Dir(sPath)
  For Each sK2 In ColumnView2.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView2[sK2].Selected = True Then
      If ColumnView2[sK2][0] <> "" Then
        sLine = ""
        For iColumn = 0 To 5
          If iColumn < 5 Then
            sLine = sLine & ColumnView2[sK2][iColumn] & hTab
          Else
            sLine = sLine & ColumnView2[sK2][iColumn] & hReturn
            Break
          Endif
        Next
        If String.InStr(sExistLines, sLine) > 0 Then 'no double Lines (ohne doppelte Zeilen)
          '...Leerlauf
        Else
          sExistLines = sExistLines & gb.Tab & sLine & gb.Tab
          sText = sText & sLine
        Endif
      Endif
    Endif
  Next
  
  If sText = "" Then
    Message.Info(("Auswahl") & " = 0", ("Abbrechen"))
    Goto Ende
  Endif
  ColumnView2.Columns[5].Text = ("markierte Zeilen") & sSpace & ColumnView2.Selection.Count & sSpace & ("von") & sSpace & ColumnView2.Count
  sDirFile = sDir &/ "export_" & Format(Now, "yyyy") & Application.Name & ".txt" ' kleine y
  
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  Dialog.Filter = ["*.txt", ("Nur-Text")]
  Dialog.Path = sDirFile
  Dialog.AutoExt = True
  Dialog.Title = ("Datei speichern...")
  'If Dialog.SaveFile() Then Return 'Kurzform
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
    'Goto Ende
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  sDirFile = Dialog.Path
  
  If Exist(sDirFile) = True Then
    hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
    sFileBefore = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
  Endif
  sExistFiles = M01Functions.FileExistQuestionText(sDirFile)
  If sExistFiles <> "" Then sExistFiles = sExistFiles & hReturn & hReturn
  sMessage = ("(Tipp: Mit einem Textprogramm den Zeichensatz verändern)") & "<br>" & "<br>"
  sMessage &= sExistFiles & sDirFile & "<br>"
  
  Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
    Case 1 'Speichern
      'File.Save(sDirFile, sText)
      M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
      If Exist(sDirFile) = True Then
        hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
        sFileBehind = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
      Endif
      If sFileBefore = sFileBehind Then
        Message.Warning(sFileBehind & "<br>" & "<br>" & ("Nicht erfolgreich gespeichert?"))
      Endif
    Case 2 'Abbrechen
      'Leerlauf
  End Select
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  
  ''Show File-Data:
  Form3Text.Tag = sDirFile
  Form3Text.Tooltip = sDirFile
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCompare(Optional bExact As Boolean = False)
  
  Dim iLine, iFoundLines, iCheck As Integer
  Dim sExists, T0, T1, T5 As String
  Dim sKey, sLeft, sMid, sRight, sKeyFirstQuestion, sSeparator As String
  Dim PicHome, PicQuestion As Picture
  
  PicHome = ColumnViewImages("PicHome").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture
  ' PicQuestion = Picture["icon:/22/question"] 'in icon ohne Endung .png
  
  sSeparator = Settings[FMain.Name &/ "hTab", gb.Tab]
  F_bESCpressedON = False
  
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      iCheck = 0 'Reset
      
      T0 = ColumnView1[sKey][0] 'yyyy-mm-dd
      T1 = ColumnView1[sKey][1] '00:00
      T5 = String.LCase(ColumnView1[sKey][5]) 'Notiz
      ' T6 = ColumnView1[sKey][6] '00:00
      ' T8 = ColumnView1[sKey][8] 'Sek.
      ' T9 = ColumnView1[sKey][9] '00:00:00 Dauer
      
      If bExact = True Then
        If String.InStr(sExists, T0 & T1 & T5) > 0 Then iCheck = 10 'faster
        ' If sExists Like "*" & T5 & "*" Then iCheck = 10
      Else 
        sLeft = String.Left(T5, 5)                                                                'linker Teil Notizen
        If String.Len(T5) > 20 Then
          sMid = String.Mid(T5, String.Len(T5) / 2, 10)                                           'mittiger Teil Notizen
        Else
          sMid = ""
        Endif 
        sRight = String.Right(T5, 5)                                                              'rechter Teil Notizen
        If String.InStr(sExists, sLeft) > 0 Then iCheck = iCheck + 1
        If sMid <> "" Then
          If String.InStr(sExists, sMid) > 0 Then iCheck = iCheck + 1
        Endif
        If String.InStr(sExists, sRight) > 0 Then iCheck = iCheck + 1
      Endif 'bExact
      
      If iCheck > 1 Then
        ColumnView1[sKey].Picture = PicQuestion '"?"
        ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
        iFoundLines = iFoundLines + 1
        ColumnView1[sKey][F_iColumnSort] = Replace(String.Left(T5, 10), "*", "Z") & Str(iFoundLines)
      Else
        ColumnView1[sKey].Picture = PicHome 'Bild
        ColumnView1[sKey][F_iColumnSelect] = "PicHome"
        ColumnView1[sKey][F_iColumnSort] = iLine 
        sKeyFirstQuestion = sKey
      Endif
      sExists &= T0 & T1 & T5 & gb.NewLine
      ' sExists = sExists & sLine & T0 & T1 & T5 & T6 & T8 & T9 & gb.NewLine  ' 0-1-2-3...
    Next
    If bExact = True Then
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen genauer") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine
    Else 
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine 
    Endif 
    ColumnViewInfo(ColumnView1.Columns[5].Title)
    ColumnViewSort(F_iColumnSort) 
    If ColumnView1.Exist(sKeyFirstQuestion) = True Then 
      ColumnView1.UnSelectAll()
      ColumnView1[sKeyFirstQuestion].Selected = True 
      ColumnView1[sKeyFirstQuestion].EnsureVisible
    Else 
      ColumnView1[ColumnView1.Count].Selected = True 
      ColumnView1[ColumnView1.Count].EnsureVisible  
    Endif 
  Endif 
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewDouble() '= ● ●
  
  Dim sKey, sLine As String
  Dim it, iLine, iFound, iFoundLines As Integer
  Dim PicDouble, PicHome As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView1.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView1.Mode = Select.Multiple 
      ColumnView1.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView1[sKey].Picture = PicDouble
          ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView1[sKey][F_iColumnSort] = ColumnView1.Count + iLine
          ColumnView1[sKey].Selected = True
          ColumnView1[sKey].EnsureVisible
        Else
          ColumnView1[sKey].Picture = PicHome
          ColumnView1[sKey][F_iColumnSelect] = "PicHome"
          ColumnView1[sKey][F_iColumnSort] = iLine
          ColumnView1[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView2.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView2.Mode = Select.Multiple 
      ColumnView2.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView2[sKey].Picture = PicDouble
          ColumnView2[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView2[sKey][F_iColumnSort] = ColumnView2.Count + iLine
          ColumnView2[sKey].Selected = True
          ColumnView2[sKey].EnsureVisible
        Else
          ColumnView2[sKey].Picture = PicHome
          ColumnView2[sKey][F_iColumnSelect] = "PicHome"
          ColumnView2[sKey][F_iColumnSort] = iLine
          ColumnView2[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines(Optional bCorrectON As Boolean = False)
  
  Dim it, iFound, iLine, iColumn, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 As String 
  Dim B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13 As String 
  Dim sK1, sLineBefore, sKeyLast As String
  Dim hDateT0, hDate0, hDate1, hDate2, hDate3, hDate4, hDateAdd, hDateSum, hDateTime1, hDateTime2 As Date
  Dim iSecond, iHH, iMM, iSecond24h, iDiff As Integer
  Dim sTime1, sTime2 As String
  Dim sValue, sLine, sLines, sTitle As String
  Dim bReadUnknownLineON As Boolean
  Dim ssWeekdays, ssTime, ssCheckDateSecondSum, ssKeys, ssKeysError, ssColumns, ssSpli As String[]  
  Dim iiCheckDateSecondSum As Integer[]
  Dim PicRefresh, PicOK, PicQuestion, PicQuestionRed, PicLineActual, PicEmpty, PicNull, PicAdd As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]

  PicRefresh = ColumnViewImages("PicRefresh").Picture
  PicOK = ColumnViewImages("PicOK").Picture
  PicQuestion = ColumnViewImages("PicQuestion").Picture
  PicEmpty = ColumnViewImages("PicEmpty").Picture
  PicLineActual = ColumnViewImages("PicLineActual").Picture
  PicQuestionRed = ColumnViewImages("PicQuestionRed").Picture
  PicAdd = ColumnViewImages("PicAdd").Picture
  PicNull = PicTemplateClockNull.Picture.Image.Stretch(F_i22, F_i22).Picture
    
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
      
  If ColumnView1.Count > 0 Then
    F_sUnknownLinesText = "" 'Reset
    F_iOldLines = ColumnView1.Count
    ' Timer4Now.Enabled = False
    ssKeys = ColumnView1.Keys.Copy()
    If Not ssKeys Then ssKeys = New String[]
    
    If ColumnView1.Keys.Max > -1 Then 
      ' ssKeys = ColumnView1.Keys.Copy()
      ssCheckDateSecondSum = New String[]
      iiCheckDateSecondSum = New Integer[]
      ssKeysError = New String[]
      iSecond24h = 60 * 60 * 24 'max. seconds in 24h = 1 day
      
      For Each sK1 In ssKeys
        iLine = iLine + 1
        ' Print iLine & " " & ssKeys.Count
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        bReadUnknownLineON = False 'Reset
        sLineBefore = ""
        ''Before correcting: Original
        For iColumn = 0 To ColumnView1.Columns.Max
          If iColumn = F_iColumnUndo Then 
            sLineBefore &= "" & hTab 
          Else If iColumn < ColumnView1.Columns.Max Then 
            sLineBefore &= ColumnView1[sK1][iColumn] & hTab 
          Else 
            sLineBefore &= ColumnView1[sK1][iColumn] & gb.NewLine 
          Endif 
        Next
        ColumnView1[sK1].Background = Color.Default 'Reset
        
        T0 = Trim(ColumnView1[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView1[sK1][1]) '00:00
        T2 = Trim(ColumnView1[sK1][2]) 'Mo
        T3 = Trim(ColumnView1[sK1][3]) 'Q
        T4 = Trim(ColumnView1[sK1][4]) 'KW
        T5 = Trim(ColumnView1[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView1[sK1][6]) '00:00
          T7 = Trim(ColumnView1[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView1[sK1][8]) 'Sek.
          T9 = Trim(ColumnView1[sK1][9]) '00:00:00
          T9 = Replace(T9, gb.Cr, "") 'Windows-Return "\r"
          T10 = Trim(ColumnView1[sK1][10]) 'ColumnsUndo
          T11 = Trim(ColumnView1[sK1][11]) 'Icon, Edit
          T12 = Trim(ColumnView1[sK1][12]) 'Sortieren
          T13 = Trim(ColumnView1[sK1][13]) 'Nr
          T13 = Replace(T13, gb.Cr, "") 'Windows-Return "\r"
        Endif 
                 
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8  'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T1 Like "??:??" Then
          sValue = Str(T1)
          T1 = M01Functions.TimeCheckHHMM(sValue) 
        Else If T1 Like "*??:??*" Then
          sValue = Str(T1)
          T1 = M01Functions.TimeCheckHHMM(sValue)
        Else 'find time in columns
          sValue = ""
          For iColumn = 0 To 5 'search time column "00:00"
            If ColumnView1[sK1][iColumn] Like "*??:??*" Then
              sValue = Str(ColumnView1[sK1][iColumn])
              Break
            Endif
          Next
          T1 = M01Functions.TimeCheckHHMM(sValue)
        Endif
        
        If T6 Like "??:??" Then
          sValue = Str(T6)
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Else If T6 Like "*??:??*" Then
          sValue = Str(T6)
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Else 'find time in columns
          sValue = ""
          For iColumn = 5 To 9 'search time column "00:00"
            If ColumnView1[sK1][iColumn] Like "*??:??*" Then
              sValue = Str(ColumnView1[sK1][iColumn])
              Break
            Endif
          Next
          T6 = M01Functions.TimeCheckHHMM(sValue)
        Endif 
        
        If T0 Like "*????-??-??*" Then 
          hDateT0 = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        Else 'kein Datum oder Timer?
          hDateT0 = Null
          bReadUnknownLineON = True
        Endif 
        If hDateT0 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDateT0, "yyyy-mm-dd")
          T2 = Format(hDateT0, "ddd")
          T3 = M01Functions.DateQuarterG(hDateT0) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDateT0), "00") & ("KW") '00...52
        Endif 
        
        sTime1 = T1 '"hh:nn"
        sTime2 = T6 '"hh:nn"
        hDate1 = Null
        hDate2 = Null
        If hDateT0 Then hDate0 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), 0, 0, 0) 
        
        If sTime1 Like "??:??" Then 
          ssTime = Split(sTime1 & ":", ":")
          If ssTime Then 
            iHH = CInteger(ssTime[0])
            iMM = CInteger(ssTime[1])
          Endif 
          If hDateT0 Then hDate1 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), iHH, iMM, 0)
        Endif 
        
        If sTime2 Like "??:??" Then 
          ssTime = Split(sTime2 & ":", ":")
          If ssTime Then 
            iHH = CInteger(ssTime[0])
            iMM = CInteger(ssTime[1])
          Endif 
          If hDateT0 Then hDate2 = Date(Year(hDateT0), Month(hDateT0), Day(hDateT0), iHH, iMM, 0)
        Endif 
        
        If hDate1 And hDate2 Then 
          hDateTime1 = hDate1
          hDateTime2 = hDate2
          iDiff = DateDiff(hDate1, hDate2, gb.Second) 
          If iDiff > -1 And iDiff < iSecond24h And T2 = T7 Then ' So<>Mo 
            T1 = Format(hDate1, "hh:nn") 'Old, First
            T2 = Format(hDate1, "ddd")
            T6 = Format(hDate2, "hh:nn") 'New, Last
            T7 = Format(hDate2, "ddd")
            iSecond = DateDiff(hDate1, hDate2, gb.Second) 
            T8 = Str(iSecond)
            hDateSum = Date(Year(hDate1), Month(hDate1), Day(hDate1), 0, 0, 0)
            T9 = Format(DateAdd(hDateSum, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            T10 = "" 'Selected True=-1  'ColumnsUndo
            T11 = "PicOK" 'Icon, Edit
            T12 = T0 & T1 'Sortieren
            B0 = ""
          Else
            hDate2 = Date(Year(hDate1), Month(hDate1), Day(hDate1), 23, 59, 59)  '—▶24:00
            T1 = Format(hDate1, "hh:nn") 'Old, First
            T2 = Format(hDate1, "ddd")
            T6 = Format(hDate2, "hh:nn")'"23:59"
            T7 = Format(hDate2, "ddd")
            iSecond = DateDiff(hDate1, hDate2, gb.Second) 
            T8 = Str(iSecond)
            hDateSum = Date(Year(hDate1), Month(hDate1), Day(hDate1), 0, 0, 0)
            T9 = Format(DateAdd(hDateSum, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            T10 = -1 'Selected True=-1  'ColumnsUndo
            T11 = "PicQuestion" 'Icon, Edit
            T12 = T0 & T1 'Sortieren
            
            ''—▶ next Day? ++++++++++++++++++++++++++++++++++++++++++++++++++
            hDateAdd = DateAdd(hDate1, gb.Day, 1) 'Errorxxxx
            hDate3 = Date(Year(hDateAdd), Month(hDateAdd), Day(hDateAdd), 0, 0, 0)   '00:00—▶
            hDate4 = Date(Year(hDateAdd), Month(hDateAdd), Day(hDateAdd), Hour(hDateTime2), Minute(hDateTime2), Second(hDateTime2)) 
            iSecond = DateDiff(hDate3, hDate4, gb.Second) 
            B0 = Format(hDate3, "yyyy-mm-dd")
            B1 = "00:00"
            B2 = Format(hDate3, "ddd")
            B3 = Str(M01Functions.DateQuarterG(hDate3)) & ("Q")
            B4 = Format(M01Functions.DateCalenderWeek(hDate3), "00") & ("KW") '00...52
            B5 = T5 'Project-Name
            B6 = Format(hDate4, "hh:nn")
            B7 = Format(hDate4, "ddd")
            B8 = Str(iSecond)
            B9 = Format(DateAdd(hDate3, gb.Second, iSecond), "hh:nn:ss")  '00:00:00
            B10 = -1  'Selected True=-1  'ColumnsUndo
            B11 = "PicAdd" 'Icon, Edit
            B12 = B0 & B1  'Sortieren
            B13 = T13 ' Nr
          Endif

          'Compare (mit korrigierter Zeile vergleichen)
          If ColumnView1[sK1][F_iColumnSelect] = "PicLineActual" Then 
            ColumnView1[sK1].Picture = PicLineActual 
            ColumnView1[sK1][F_iColumnSelect] = "PicLineActual"
            ColumnView1[sK1].Background = F_iSelectGreenAlpha220
            ColumnView1[sK1].Foreground = Color.Gray
          Else If bReadUnknownLineON = True Then  
            ColumnView1[sK1].Picture = PicQuestionRed 
            ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
            ColumnView1[sK1].Background = F_iSelectRedAlpha220
            ColumnView1[sK1].Foreground = Color.Gray
            ColumnView1[sK1].Selected = True
            If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
          Endif

          If T8 = 0 Then
            ''...
          Else If T0 Then 
            If T0 Like "????-??-??" Then 
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 
              ''Control Sum max. 24h
              iFound = ssCheckDateSecondSum.Find(T0)  '-1 not Found
              If iFound = -1 Then 
                ssCheckDateSecondSum.Add(T0)  ''no sort!
                iiCheckDateSecondSum.Add(iSecond)
                iFound = ssCheckDateSecondSum.Max
              Else 
                iiCheckDateSecondSum[iFound] = iiCheckDateSecondSum[iFound] + iSecond
              Endif 
            Endif 
            If iiCheckDateSecondSum[iFound] > iSecond24h Then
              ColumnView1[sK1].Picture = PicQuestionRed 
              ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
              ColumnView1[sK1].Background = F_iSelectRedAlpha220
              ColumnView1[sK1].Foreground = Color.Gray
            Else  
              sLines &= T0 & hTab & T1 & hTab & T2 & hTab & T3 & hTab & T4 & hTab & T5 & hTab & T6 & hTab & T7 & hTab & T8 & hTab & T9 & hTab & T10 & hTab & T11 & hTab & T12 & hTab & T13 & gb.NewLine 
              ' F_sUnknownLinesText &= sLines & gb.NewLine
            Endif 
          Endif 
          
          If B0 Then 
            If B0 Like "????-??-??" Then 
              If hDate3 And hDate4 Then iSecond = DateDiff(hDate3, hDate4, gb.Second) 
              iFound = ssCheckDateSecondSum.Find(B0)  '-1 not Found
              If iFound = -1 Then 
                ssCheckDateSecondSum.Add(B0)  ''no sort!
                iiCheckDateSecondSum.Add(iSecond)
                iFound = ssCheckDateSecondSum.Max
              Else 
                iiCheckDateSecondSum[iFound] = iiCheckDateSecondSum[iFound] + iSecond
              Endif 
            Endif 
            If iiCheckDateSecondSum[iFound] > iSecond24h Then 
              ColumnView1[sK1].Picture = PicQuestionRed 
              ColumnView1[sK1][F_iColumnSelect] = "PicQuestionRed"
              ColumnView1[sK1].Background = F_iSelectRedAlpha220
              ColumnView1[sK1].Foreground = Color.Gray
            Else 
              sLines &= B0 & hTab & B1 & hTab & B2 & hTab & B3 & hTab & B4 & hTab & B5 & hTab & B6 & hTab & B7 & hTab & B8 & hTab & B9 & hTab & B10 & hTab & B11 & hTab & B12 & hTab & B13 & gb.NewLine 
            Endif
          Endif 
        Endif 
      Next 
      
      If bCorrectON = True Then 
        ColumnView1.Clear()
        ssKeysError = New String[]
        If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
        ssSpli = Split(sLines & gb.NewLine, gb.NewLine)
        For Each sLine In ssSpli
          If sLine Then 
            ssColumns = Split(sLine & String(ColumnView1.Columns.Count, gb.Tab), gb.Tab)
            sK1 = ColumnView1.Count + 1
            ColumnView1.Add(sK1, "")
            ' ColumnView1[sK1].Picture = ColumnViewImages(ssColumns[F_iColumnSelect]).Picture
            For it = 0 To ColumnView1.Columns.Max
              If it = F_iColumnUndo Then 
                ColumnView1[sK1][it] = ""
              Else 
                ColumnView1[sK1][it] = ssColumns[it] 
              Endif 
            Next
            
            If ColumnView1[sK1][F_iColumnUndo] = "" Then 
              ColumnView1[sK1].Selected = False 
            Else 
              ColumnView1[sK1].Selected = True
            Endif
            
            Select Case ColumnView1[sK1][F_iColumnSelect]
              Case "PicLineActual" 
                ColumnView1[sK1].Picture = PicLineActual 
                ColumnView1[sK1].Background = F_iSelectGreenAlpha220
                ColumnView1[sK1].Foreground = Color.Gray
              Case "PicQuestionRed"
                ColumnView1[sK1].Picture = PicQuestionRed 
                ColumnView1[sK1].Background = F_iSelectRedAlpha220
                ColumnView1[sK1].Foreground = Color.Gray
                If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
                sKeyLast = sK1
                ' F_sUnknownLinesText &= sLine & gb.NewLine 'Error?xxxx
             Case "PicAdd" 
                ColumnView1[sK1].Picture = PicAdd
                ColumnView1[sK1].Background = F_iSelectGreenAlpha220
                ColumnView1[sK1].Foreground = Color.DarkBlue
                If ssKeysError.Find(sK1) = -1 Then ssKeysError.Add(sK1)
                sKeyLast = sK1
                ' F_sUnknownLinesText &= sLine & gb.NewLine
              Case Else
                ColumnView1[sK1].Picture = PicOK 
                ColumnView1[sK1].Background = Color.Default 
            End Select
            
          Endif
        Next
      Endif
      F_sLinesCopy = F_sUnknownLinesText
      ' ButtonAddLineActualG()
      If ssKeysError.Count > 0 Then iUnknown = ssKeysError.Count Else iUnknown = 0
  
      ' PicBoxDiagram.ToolTip = "? " & ("Rot. Fehler oder zuviele Daten in der Liste?") 
      ListColumnCorrect.Text = iUnknown
      ''Error-Lines:
      ListColumnCorrect.Tooltip = ("?-Fehler Zeiten") & ": " & iUnknown
      ListColumnCorrect.Visible = True 
      
      F_iUnknownCounter = iUnknown
      mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
      If iUnknown > 0 Then sValue = ("Unbekannte=") & iUnknown & "?" Else sValue = ""
      sTitle = ("Geändert") & Space(1) & iUnknown & Space(1) & ("von") & Space(1) & ColumnView1.Count
      ColumnView1.Columns[5].Title = sTitle
      F_sUnknownLinesText = sTitle & gb.NewLine & F_sUnknownLinesText
      ' M01Functions.ProjectLine(Date, "07:00", ("Beispiel"), "12:00") & hReturn & F_sUnknownLinesText
      ' If ssKeysError.Count > 0 Then sK1 = ssKeysError.Last
      ' If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
      Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & Space(5) & Str((ColumnView1.Count) & Space(1) & sValue)
      LabelInfo.Text = sTitle
      LabelInfo.Visible = True 
      ColumnViewSort(F_iColumnSort)
      If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
    Endif 'ColumnView1.Selection.Max 
  Endif 'ColumnView1.Count

Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilenG()
  
  Form3Text.Tag = F_sUnknownLinesText
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  ColumnViewInfo(("Fehl-Zeilen im Lesefenster"))
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewGotoErrorLines(Optional sUpDown As String = "down") '▼
  
  Dim sK1, sK2, sInfo, sMessage As String 
  Dim PicQuestion As Picture
  
  ' If ColumnView1.Visible = False Then Side(2)

  If ColumnView1.Count > 0 Then 
    For Each sK1 In ColumnView1.Keys
      If ColumnView1[sK1].Background = F_iSelectRedAlpha220 Then  
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
      Else 
        ColumnView1[sK1].Selected = False 
      Endif
    Next
  Endif
    
  Select Case sUpDown
    Case "up"
      F_iCurrentErrorLine = F_iCurrentErrorLine - 1
    Case "down"
      F_iCurrentErrorLine = F_iCurrentErrorLine + 1
  End Select
  
  If ColumnView1.Count > 0 Then 
    If F_bColumnsMore = False Then 
      F_bColumnsMore = True 
      ColumnsMore(F_bColumnsMore)
    Endif 
    PicQuestion = ColumnViewImages("PicQuestion").Picture 
    ' PicQuestion = ToggleColumnCorrecting.Picture.Image.Stretch(22, 22).Picture
    ' ColumnSortSettingCentral()
    ColumnView1.Columns.Sort = 0
    ColumnView1.Sorted = True 
    For Each sK1 In ColumnView1.Keys
      If ColumnView1[sK1].Background = F_iSelectRedAlpha220 Then  
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
      Else 
        ColumnView1[sK1].Selected = False 
      Endif
    Next
    If ColumnView1.Selection.Max = -1 Then 
      For Each sK1 In ColumnView1.Keys
        If ColumnView1[sK1].Background <> Color.Default Then  
          ColumnView1[sK1].Selected = True 
          ' ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
        Else 
          ColumnView1[sK1].Selected = False 
        Endif
      Next
    Endif 
    
    F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
    ' F_ssKeysCopy = ColumnView1.Keys.Copy()
    If Not F_ssKeysCopy Then F_ssKeysCopy = New String[]
    If F_iCurrentErrorLine < 0 Then F_iCurrentErrorLine = F_ssKeysCopy.Max
    If F_iCurrentErrorLine > F_ssKeysCopy.Max Then F_iCurrentErrorLine = 0
    If F_ssKeysCopy.Max = -1 Then 
      sInfo = ("Fehler-Zeilen") & ": " & ("Keine")
      ColumnViewInfo(sInfo)
      sMessage = "<h3><font color=gray>" & ("Fehler-Zeilen") & ": " & "</font></h3>" 
      sMessage &= "<h3><font color=darkgreen>" & ("Keine") & "</font></h3>" 
      sMessage &= ("In der Liste wurden keine Fehler-Zeilen erkannt oder sie wurden schon korrigiert.")
      Message.Info(sMessage, ("Abbrechen"))
    Else
      sK2 = F_ssKeysCopy[F_iCurrentErrorLine]
      If ColumnView1.Exist(sK2) = True Then 
        For Each sK1 In ColumnView1.Keys
          ColumnView1[sK1].Picture = ColumnViewImages(ColumnView1[sK1][F_iColumnSelect]).Picture 'Reset
        Next 
        ColumnView1[sK2].EnsureVisible
        ColumnView1[sK2].Picture = PicQuestion
      Endif  
      ColumnViewInfo(("?-Zeilen") & ": " & ColumnView1[sK2][1] & ">" & ColumnView1[sK2][6] & Space(1) & ColumnView1[sK2][2] & ">" & ColumnView1[sK2][7])
    Endif
  Else 
    ListGotoErrorLineDown.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
   
Catch
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form18Projektbearbeiten.Window.Maximized = Not Form18Projektbearbeiten.Window.Maximized 
  If Form18Projektbearbeiten.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form18Projektbearbeiten.Window.FullScreen = True Or Form18Projektbearbeiten.Window.Maximized = True Then 
      F_bMovingON = False
      Form18Projektbearbeiten.Window.FullScreen = False
      Form18Projektbearbeiten.Window.Maximized = False
      If Form18Projektbearbeiten.Left + Form18Projektbearbeiten.W > Screen.AvailableWidth Then Form18Projektbearbeiten.Move(Form18Projektbearbeiten.Left, Form18Projektbearbeiten.Top, Screen.AvailableWidth - Form18Projektbearbeiten.Left, Screen.AvailableHeight - Form18Projektbearbeiten.Top)
    Else
      F_bMovingON = True
      Form18Projektbearbeiten.Window.FullScreen = False
      Form18Projektbearbeiten.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form18Projektbearbeiten.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form18Projektbearbeiten.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form18Projektbearbeiten.ClientW - WindowStretch.W, Form18Projektbearbeiten.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form18Projektbearbeiten.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form18Projektbearbeiten.W = Mouse.ScreenX - F_iX1
    Form18Projektbearbeiten.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form18Projektbearbeiten.ClientW - WindowStretch.W, Form18Projektbearbeiten.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form18Projektbearbeiten.ClientW - WindowStretch.W, Form18Projektbearbeiten.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form18Projektbearbeiten.Window.Maximized = Not Form18Projektbearbeiten.Window.Maximized 
    If Form18Projektbearbeiten.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form18Projektbearbeiten.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
  ' MoveLine.Cursor = New Cursor(Picture["images/size_32.png"].Image.Stretch(MoveLine.H, MoveLine.H).RotateLeft().Picture, 0, 0)
  ' MoveLine.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuErgaenzungFeiertage2_Click()
  
  Dim sValue As String 
  
  sValue = Settings[FMain.Name &/ "OsterSonntag", ""] 'EasterDay
  If sValue = "" Then M03Feiertage.HolidaysCalculate()
  Form8ZusFeiertage.Window.Show
  ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExternOpenGroup_Click()
  
  ButtonExternStartG(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonExternStartG(Optional sTag As String = "")
  
  Dim sPath, sCopy, sProgram As String
  
  sPath = FilePathForm()
  If Exist(sPath) = True Then
    Select Case String.LCase(sTag)
      Case "editor"
        sProgram = "gedit"
      Case "office"
        sProgram = "libreoffice"
      Case "browser"
        sProgram = "firefox"
      Case "csv"
        sProgram = "libreoffice"
        ' sCopy = File.SetExt(sPath, "csv")
        ' sCopy = M01Functions.ProgramDirCache(sCopy) '/Temp/File.txt
        sCopy = M01Functions.CheckDirectoryCache() &/ File.Name(sPath) & ".csv"
        If Exist(sCopy) = True Then Try Kill sCopy
        If Exist(sCopy) = False Then Copy sPath To sCopy
        If Exist(sCopy) = True Then sPath = sCopy
    End Select
    If System.Exist(sProgram) = True Then 
      M01Functions.ExternStart(sProgram, sPath) 
    Else 
      Desktop.Open(sPath)
    Endif
    ColumnViewInfo(("Siehe extern") & ": " & ": " & sPath)
  Else 
    ColumnViewInfo(("Datei nicht gefunden") & ": " & sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuHilfe_Show()
  
  Dim longFreeMedia As Long
  Dim sText As String 
  
  longFreeMedia = M01Functions.DirectoryFreeBytesLong("/") 'Alles auf Gerät "/"
  sText = ("Freier Speicher") & ": " & Format(longFreeMedia / 1024 / 1024 / 1024, "0,0") & " GB" & Space(5) & "(" & Format(longFreeMedia, "0,0") & Space(1) & "Bytes)"
  mnuFestplattenbelegung.Text = ("Festplatte") & ", " & sText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSonderzeichen_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gucharmap")
  If bExist = True Then 
    M01Functions.ExternStart("gucharmap") 'Sonderzeichen, Zeichentabelle
  Else 
    bExist = System.Exist("gnome-characters")
    ' Shell "gnome-control-center"
    M01Functions.ExternStart("gnome-characters", "")
    ' M01Functions.ExternStartAlternative("gnome", "info")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuSonderzeichen.Text, "Fehlt") = 0 Then mnuSonderzeichen.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSonderzeichen.Text)
  Endif
  '/usr/share/applications
  'gcalctool 'Taschenrechner
  'gnome-session-properties 'Startprogramme
  'gnome-control-center --overview 'Systemeinstellungen
  'gnome-control-center indicator-datetime  'Zeit und Datum
  'gnome-control-center deja-dup 'Datensicherung
  'gnome-search-tool ' Suche im PC
  'baobab 'Festplattenbelegung
  
Catch 
  FMain.ErrorText
  ''______________________________________________________________''
  'https://manpages.ubuntu.com/manpages/trusty/man1/gucharmap.1.html
  'https://manpages.ubuntu.com/manpages/trusty/man1/gnome-session-properties.1.html
  
End

Public Sub mnuSuchePC_Click()
  
  Dim sPath As String
  
  sPath = FilePathForm()
  ' M01Functions.FileManagerOpen(sPath) 'Suche im PC
  M01Functions.ExternStart("nautilus", sPath)
  ColumnViewInfo(("Siehe extern:" & Space(1) & mnuSuchePC.Text))
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFestplattenbelegung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("baobab")
  If bExist = True Then
    Shell "baobab" 'startet Programm
    ' M01Functions.ExternStart("baobab") 'Festplattenbelegung
  Else
    bExist = System.Exist("nautilus") 'Filemanager (Dateiverwaltung)
    M01Functions.ExternStart("nautilus", "")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuFestplattenbelegung.Text, "Fehlt") = 0 Then mnuFestplattenbelegung.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuFestplattenbelegung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup") 'Backup-Program
  If bExist = True Then
    Shell "deja-dup" 'start Program
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
    mnuDatensicherung2.Text = mnuDatensicherung.Text
    ColumnViewInfo(mnuDatensicherung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSystemDatumZeit_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gnome-control-center") 'System
  If bExist = True Then
    Shell "gnome-control-center datetime" 'startet Programm
    ' M01Functions.ExternStart("gnome-control-center", "info-overview") 'Zeit und Datum, Seite Betriebssysem-Info
  Endif
  If bExist = False Then bExist = System.Exist("unity-control-center")
  If bExist = True Then
    Shell "unity-control-center datetime" ' Datum und Zeit, Einstellungen im Betriebssystem
    'M01Functions.ExternStart("unity-control-center", "datetime") 'Zeit und Datum
  Endif
  If bExist = False Then
    If String.InStr(mnuSystemDatumZeit.Text, "Fehlt") = 0 Then mnuSystemDatumZeit.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSystemDatumZeit.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTaschenrechner_Click()
  
  Dim bExist As Boolean
  
  'M01Functions.ExternStart("gcalctool") 'gcalctool 'Taschenrechner
  bExist = M01Functions.ExternCalculator()
  If bExist = False Then 
    If String.InStr(mnuTaschenrechner.Text, "Fehlt") = 0 Then mnuTaschenrechner.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuTaschenrechner.Text)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuExport_Click() 'ö=oe, ...
  
  Form13Export.Window.Show
  ' Form13Export.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlExportieren_Click()
  
  SaveSelectionG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelDatumInfo()
  
  Dim sMessage, hTab, hReturn, hSpace As String
  
  hTab = String(5, "&nbsp;") ' Count empty Space (Anzahl Leerzeichen)
  hReturn = "<br>"
  hSpace = "&nbsp;" 'Empty Space (Leerzeichen 1x)
  'Terminwecker/Project-Line-Format:
  sMessage = M01Functions.TerminweckerLine(Format(Now, "yyyy-mm-dd"), Format(Now, "hh:nn"), ("Notiz"))
  sMessage = Replace(sMessage, gb.Tab, hTab)
  sMessage = "<b><font color=gray>" & sMessage & "</font></b>" & hReturn & hReturn
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'As String
  sMessage &= ("Wochentag, Quartal und Kalenderwoche werden automatisch berechnet und ergänzt.") & hReturn & hReturn
  sMessage &= ("Tipp") & ": " & hReturn 
  sMessage &= ("*Geburtstage, #Feiertage oder +Timerplus können durch ein einheitliches Zeichen") & hReturn
  sMessage &= ("unter 'Suche' zusammen angezeigt, bearbeitet, exportiert oder gelöscht werden.") & hReturn
  sMessage &= ("Begriffe einheitlich anwenden, mindestens 1x im Text, für eine spätere 'Suche'.") & hReturn 
  sMessage &= ("Beispiel") & hSpace & "<font color=darkgreen>" & ("Suche: *Jahrestreffen xy") & "</font>" & hReturn 
  
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer2KeyPress_Timer()
  
  Dim sPath As String 
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  
  sPath = TextBoxPath.Text 
  sPath = Replace(sPath, gb.NewLine, "")
  ReadG(sPath, True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer3KeyPress_Timer()
  
  Timer3KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  ButtonSearchG() 'not in _KeyPress > Error
  
Catch 
  FMain.ErrorText
  
End

Public Function Text5TempPathReturn() As String
  Dim sFile As String 
  
  F_sPathText5Temp_txt = Settings[FMain.Name &/ "F_sPathText5Temp_txt", FMain.F_sPathText5Temp_txt]
  sFile = File.BaseName(F_sPathText5Temp_txt)
        
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1
      F_sText5StartExampleName = ("Notiz")
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-termin.txt"
    Case 2
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-projectname.txt"
    Case 3
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-project.txt"
  End Select 

  Return F_sPathText5Temp_txt
  
  Catch 
  FMain.ErrorText
  
End

Public Function Text5TempFileLoad() As String 
  
  Dim sText As String 
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then
    sText = File.Load(F_sPathText5Temp_txt)
    PasteLineArrow(sText) 'Chr(182) = "¶"
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5TempFileRefresh()
  Dim T5, sText, sPath As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  
  T5 = Text5.Text
  T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
  ''Chr$(13) & Chr$(10) = "\r\n" = gb.CrLF = gb.Cr & gb.LF, gb.LF = gb.NewLine = "\n" = Chr$(10)
  T5 = Replace(T5, gb.NewLine, String.Chr(182))
  T5 = Replace(T5, hTab, Space(3))

  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      If String.Len(Text5.Text) > 0 Then 
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 2
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 3
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.ProjectLine(Text0.Text, Text1.Text, T5 & Text2.Text & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
  End Select

  Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer() '>Termine
  '.Delay=1000 =1 second
  
  If F_iMusterTermine1Names2Projects3 = 1 And F_bKeyboardInput = True Then 
    F_iText5Seconds = F_iText5Seconds + 1 
    If F_iText5Seconds > 10 Then 
      Text5TempFileRefresh()
      F_iText5Seconds = 0
      F_bKeyboardInput = False
    Endif
  Endif 
  
  If F_statFilePathForm Then 
    If Exist(F_statFilePathForm.Path) = True Then  
      If F_statFilePathForm.Time <> Stat(F_statFilePathForm.Path).Time Then ColumnViewInfo(("Info") & ": " & ("Datei extern geändert") & Space(1) & Format(F_statFilePathForm.LastModified, "hh:nn:ss"))
      F_statFilePathForm = Stat(F_statFilePathForm.Path) 'Refresh
    Endif 
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer4Now_Timer()
  
  LabelDateNow.Text = Format(Now, "yyyy-mm-dd") & Space(3) & Format(Now, "ddd")
  If Second(Time) Mod 2 Then 
    LabelTimeNow.Text = Format(Now, "hh:nn")
  Else 
    LabelTimeNow.Text = Format(Now, "hh nn")
  Endif 
  
Catch 
  FMain.ErrorText

End

Public Sub ButtonCancelB_MouseDown()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTerminweckerdateiLesen_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTermineDateiOeffnenSpeichern_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PasteLineArrow(Optional sLinePaste As String = "")
  
  Dim T0, T1, T5, T6, T8, T9 As String
  Dim sValue As String 
  Dim ssLines, ssLine As String[]
  Dim sLine, sPart As String
  Dim it, iLine, iCounter As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If String.InStr(sLinePaste, gb.Tab) > 0 Then 
    sValue = sLinePaste
  Else If Clipboard.Type = Clipboard.Text Then 'nur wenn Text in Zwischenablage ist
    sValue = Clipboard.Paste("text/plain") '()Klammer nicht vergessen!
  Endif 
  
  If sValue Then 
    If String.InStr(sValue, hTab) > 0 And sValue Like "????-??-??*??:??*" Then
      ssLines = Split(sValue & String(2, hReturn), hReturn)
      For Each sLine In ssLines
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, hTab) > 0 And sLine Like "????-??-??*??:??*" Then
          iCounter = iCounter + 1
          ssLine = Split(sLine & String(6, hTab), hTab)
          it = 0
          For Each sPart In ssLine
            If it = 0 Then T0 = sPart
            If it = 1 Then T1 = sPart
            If it = 5 Then T5 = sPart
            If it = 6 Then T6 = sPart 
            If it = 8 Then T8 = sPart
            If it = 9 Then T9 = sPart
            it = it + 1
            If it > F_iColumnsReadMax Then Break
          Next
          If iCounter > 0 Then Break 'only 1 sPart
        Endif
      Next
      Text0Insert(T0) '0000-00-00 
      Text1Insert(T1) '00:00 'A
      Text5Insert(T5) 'Project/Notice
      If F_iMusterTermine1Names2Projects3 = 3 Then 
        Text2Insert(T6) '00:00 'B
        ButtonSum.Tooltip = T8 'Seconds 12345
        ButtonDauer.Text = T9 '00:00:00 Duration
      Endif 
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineEinlagernG()
  
  ''Plus
  ReadG(FilePathFormOldYears(), True) 'True: with Dialog
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineAuslagernG()
  
  Dim iDiffDays, iOldLines, it, iLine As Integer
  Dim sKey, sKeyLast, sValue, sLine, sWithoutDoubles, sTextInside, sTextOutside, sTitleInfo, sMessage As String
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim dateA, dateB, dateDatum1, dateDatum2 As Date
  Dim sBisDatum1, sBisDatum2 As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = FilePathFormOldYears()
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  dateDatum1 = Date(Year(Date) - 6, 12, 31)
  dateDatum2 = Date(Year(Date) - 1, 12, 31)
  sBisDatum1 = ("vor") & " ◀ " & Format(dateDatum1, "yyyy") & Space(1) & ("auslagern") 'vor<<
  sBisDatum2 = ("vor") & " ◁ " & Format(dateDatum2, "yyyy") & Space(1) & ("auslagern") 
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("Vergangene Zeilen auslagern in die Datei") & ":" & "</font></h3>"
  sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
  sMessage &= ("Ausnahme:  *Geburtstage oder andere Termine (*Jedes Jahr) werden nicht verschoben.") & "<br>"
  sMessage &= ("Ausnahme:  Timer SoMoDiMiDoFrSa (Jede Woche) werden nicht verschoben.") & "<br>" 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
  Select Case Message.Question(sMessage, sBisDatum1, sBisDatum2, ("Abbrechen"))
    Case 1 'Move outside (Auslagern)
      dateA = dateDatum1
    Case 2 'Move outside (Auslagern)
      dateA = dateDatum2
    Case 3 'Cancel (Abbrechen)
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''No Birthdays "*", no Timer SoSa, Muster: 0000-00-00 00:00 WD Q CW Notice
    If String.Left(ColumnView1[sKey][5], 1) = "*" Or IsInteger(String.Left(ColumnView1[sKey][0], 1)) = False Then 'no *EveryYear (ohne *Geburtstage), no Timer SaSoMoDiMiDoFrSa
      ''...
    Else If ColumnView1[sKey][0] Like "*????-??-??" Then
      If ColumnView1[sKey][5] <> "" Then
        sValue = ColumnView1[sKey][0]
        dateB = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If dateB Then
          iDiffDays = DateDiff(dateA, dateB, gb.day)
          If iDiffDays < 0 Then
            sLine = ""
            For it = 0 To ColumnView1.Columns.Max
              If it < F_iColumnsReadMax + 1 Then 
                sLine = sLine & ColumnView1[sKey][it] & hTab
                ColumnView1[sKey][it] = ""
              Else 
                sLine = sLine & ColumnView1[sKey][it] & hReturn
                ColumnView1[sKey][it] = ""
                ColumnView1[sKey].Picture = PicCut
                ColumnView1[sKey][F_iColumnSelect] = "PicCut"
                ColumnView1[sKey].Selected = True
                sKeyLast = sKey
                Break
              Endif
            Next
            sTextInside = sTextInside & sLine
            iOldLines = iOldLines + 1
          Endif 'iDiffDays
        Endif 'dateB
      Endif 'ColumnView1[sKey][0]
    Endif 'ColumnView1[sKey][0] LIKE "*????-??-??"
  Next
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then sTextOutside = File.Load(sDirFileOldYears)
    sTextOutside = sTextOutside & sTextInside
    For Each sLine In Split(sTextOutside & gb.NewLine, gb.NewLine)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(("Auslagern")) = True Then Break
      Endif 
      
      If String.InStr(sWithoutDoubles, sLine) = 0 Then sWithoutDoubles &= sLine & hReturn
    Next 
    'File.save(sDirFileOldYears, sTextOutside)
    sPath = M01Functions.FileTextPlus(sDirFileOldYears, sWithoutDoubles, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & " - " & ("auslagern...fertig")
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iOldLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
      
      sMessage = Str(iOldLines) & Space(1) & ("Zeilen verschoben in Datei") & "<br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen"))
        Case 1 
          SaveG() 'with backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
    Message.Info(sTitleInfo, ("Abbrechen"))
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub GeburtstageAuslagernG() '*EveryYear Outside (*Jedes Jahr, auslagern)
  
  Dim iOldLines, iDoubleLines, iUnknownLines, iMoveLines, it, iLine As Integer
  Dim sKey, sKeyLast, sLine, sTextLine, sPart, sTextInside, sTextOutside, sExist, sTitleInfo, sMessage As String 
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear] '*EveryYear (*jedes Jahr, Geburtstage)
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("*Zeilen auslagern in die Datei") & ":" & "</font></h3>" '*Every Year (*Jedes Jahr)
  sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
  sMessage &= ("Nur Zeilen (*Jedes Jahr) werden verschoben.") & "<br>"
  sMessage &= ("Beispiel: *Geburtstage")
  
  Select Case Message.Question(sMessage, "*" & ("Zeilen") & Space(1) & ("auslagern"), ("Abbrechen"))
    Case 1 'Move outside —▶ birthsdays list
      '...
    Case 2 'Cancel
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''Birthdays "*" 
    If String.Left(ColumnView1[sKey][5], 1) = "*" Then 'Muster: 0000-00-00 00:00 WD Q CW *Notice
      sLine = ""
      For it = 0 To ColumnView1.Columns.Max
        If it < F_iColumnsReadMax + 1 Then
          sLine = sLine & ColumnView1[sKey][it] & hTab
          ColumnView1[sKey][it] = ""
        Else 
          Break
        Endif 
      Next
      ColumnView1[sKey].Picture = PicCut
      ColumnView1[sKey].Selected = True
      sKeyLast = sKey
      If sLine Then
        sTextInside = sTextInside & sLine & hReturn
        iOldLines = iOldLines + 1
      Endif 
    Endif  
  Next
  If F_bESCpressedON = True Then Goto Ende
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then
      sTextOutside = File.Load(sDirFileOldYears) '*EveryYear
    Endif
    sTextOutside = sTextOutside & sTextInside
    For Each sTextLine In Split(sTextOutside & hReturn, hReturn)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
      Endif 
      
      If sTextLine Then 
        it = 0
        sLine = ""
        For Each sPart In Split(sTextLine & hTab, hTab) 'Muster: 0000-00-00 00:00 WD Q CW *Notice
          If it < F_iColumnsReadMax + 1 Then sLine = sLine & sPart & hTab
          If it = F_iColumnsReadMax Then Break
          it = it + 1
        Next
        If it = F_iColumnsReadMax And sLine Then 
          sLine = sLine & hReturn
          If String.InStr(sExist, sLine) > 0 Then 
            iDoubleLines = iDoubleLines + 1
          Else 
            sExist &= sLine  'no double
            iMoveLines = iMoveLines + 1
          Endif 
        Else If sLine Then 
          iUnknownLines = iUnknownLines + 1
        Endif 
      Endif 
    Next
    If F_bESCpressedON = True Then Goto Ende
    
    'File.save(sDirFileOldYears, sExist)
    If sExist Then sPath = M01Functions.FileTextPlus(sDirFileOldYears, sExist, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iMoveLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen") & sSpace & ("Doppelt") & ": " & Str(iDoubleLines)
      
      sMessage = ("Fehlerhafte Zeilen") & ": " & sHTMLaRed & Str(iUnknownLines) & sHTMLbRed & "<br>"
      sMessage &= ("Doppelte *Zeilen") & ": " & sHTMLaRed & Str(iDoubleLines) & sHTMLbRed & "<br>"
      sMessage &= ("Zeilen verschoben in Datei") & ": " & "<font color=darkgreen><b>" & Str(iMoveLines - iDoubleLines) & Space(1) & ("von") & Space(1) & Str(iMoveLines) & "</b></font><br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen")) '(0,1,2,3)
        Case 1 'Save now
          SaveG() ' with Backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3 'No, Cancel
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
    Message.Info(sTitleInfo, ("Abbrechen"))
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahlBis_Click()
  
  ButtonUntil()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonUntil()
  'Switch central (zentrale Umstellung)
  
  If PanelBis.Visible = False Then
    SelectHide0Date1Clock2Timer3(4)
  Else
    SelectHide0Date1Clock2Timer3(0)
    PanelBis.Visible = False
    ButtonBis.Background = F_iColorGreen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlOriginal_Click()
  
  ListMenuGroupFunctions("original2")
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung2_Click()
  
  mnuDatensicherung_Click
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Search()
  
  Dim iLen As Integer
  
  F_iText5SearchPosition = String.InStr(String.LCase(Text5.Text), String.LCase(TextBoxSearch5.Text), F_iText5SearchPosition) 'as Integer
  If F_iText5SearchPosition > 0 Then 
    Text5.Pos = F_iText5SearchPosition
    iLen = String.Len(TextBoxSearch5.Text) 'as Integer   UTF-8 with String.x
    Text5.Select(F_iText5SearchPosition - 1, iLen)
    Text5.EnsureVisible
    ' Text5.SetFocus
    F_iText5SearchPosition = F_iText5SearchPosition + 1
    TextBoxSearch5.Background = F_iColorGreenAlpha150
    TextBoxSearch5.SetFocus
  Else 
    TextBoxSearch5.Background = F_iColorRedAlpha150
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Resize()
  
  If MoveLine.Top <> F_iMoveLineMinH Then 
    F_iMoveLineTop = MoveLine.Top 
    MoveLine.Top = F_iMoveLineMinH
    WindowT5plus.Picture = PicTemplatePageMini.Picture
  Else 
    MoveLine.Top = F_iMoveLineTop
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCopy()
  
  If ColumnView1.Selection.Max > -1 Then
    F_ssKeysCopy = ColumnView1.Selection.Copy()    'only Keys, Example: "3", "1", "2",... without .Sort()
    ColumnViewInfo(("Einfügen der Kopie, nach markierter Zeile."))
    ColumnViewClipboardCopy()
  Else 
    ListCopy.Background = Color.Red
    ColumnViewInfo(("ausgewählte Zeilen") & ": 0")  'No Selection
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewClipboardCopy() 'intern
  
  Dim it, iColumn, iLine As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView1.Columns.Max
          sLine = ColumnView1[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Else ''ColumnView2:
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView2.Columns.Max
          sLine = ColumnView2[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewMarkGreen()
  
  Dim sK1 As String
  Dim PicEmpty As Picture
  Dim PicMarkGreen As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView1.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView1[sK1].Background <> Color.Default Then 
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView1[sK1].Background = F_iColorGreenAlpha150
        ColumnView1[sK1].Foreground = F_iColorForegroundBlue
        ColumnView1[sK1].Picture = PicMarkGreen
        ColumnView1[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
    
  Else ''ColumnView2:
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView2.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView2[sK1].Background <> Color.Default Then 
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView2[sK1].Background = F_iColorGreenAlpha150
        ColumnView2[sK1].Foreground = F_iColorForegroundBlue
        ColumnView2[sK1].Picture = PicMarkGreen
        ColumnView2[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCut()
  
  Dim iColumn, iLine As Integer
  Dim PicCut As Picture
  Dim sK1 As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sK1].Picture = PicCut
        ColumnView1[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView1[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sK1].Picture = PicCut
        ColumnView2[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView2[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView2to1()                                                               'ColumnView2 ▶ ColumnView1
  
  Dim iColumn, iLine As Integer
  Dim sK2 As String 
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    For Each sK2 In ColumnView2.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) Then 
        For iColumn = 0 To ColumnView2.Columns.Max
          ColumnView1[sK2][iColumn] = ColumnView2[sK2][iColumn] 
        Next
        ''ColumnView1 ▶ ColumnView2
        ColumnView1[sK2].Picture = ColumnView2[sK2].Picture
        ColumnView1[sK2].Selected = ColumnView2[sK2].Selected
      Endif 
    Next
  Else 
    ListCut.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUp() '▲
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicUp As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicUp
        ColumnView1[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView1.MoveTo(sK1)
        ' M = ColumnView1.MoveBelow() '▼down
        M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort]
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicUp
        ColumnView2[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView2.MoveTo(sK1)
        ' M = ColumnView2.MoveBelow() '▼down
        M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort]
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewDown() '▼
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicDown As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicDown
        ColumnView1[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView1.MoveTo(sK1)
        M = ColumnView1.MoveBelow() '▼down
        'M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort] 'Read Column
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicDown
        ColumnView2[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView2.MoveTo(sK1)
        M = ColumnView2.MoveBelow() '▼down
        'M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort] 'Read Column
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewPaste() 
  
  Dim iColumn, iLine As Integer
  Dim sK0, sK1, sKeySort, sValue, sMessage As String 
  Dim M As Integer = -1 'True -1, False 0 (meaning here True!)
  Dim PicAdd As Picture
  Dim ssKeys As New String[]
  Dim sLine, sPart As String 
  Dim bInfo As Boolean 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView1.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView1.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView1.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then 
      If ColumnView1.Exist(sK0) = False Then 
        M = ColumnView1.MoveLast()
        If M = 0 Then ColumnView1.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView1.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView1.UnselectAll()
      ColumnView1.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView1.Count + 1 
          ColumnView1.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView1.Columns.Max Then 
              ColumnView1[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView1[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView1[sK1].Selected = True
        Next
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True
    Endif
  Else ''ColumnView2:
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView2.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView2.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView2.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then   
      If ColumnView2.Exist(sK0) = False Then 
        M = ColumnView2.MoveLast()
        If M = 0 Then ColumnView2.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView2.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView2.UnselectAll()
      ColumnView2.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView2.Count + 1 
          ColumnView2.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView2[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView2.Columns.Max Then 
              ColumnView2[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView2[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView2[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView2[sK1].Selected = True
        Next
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True 
    Endif
  Endif 
  
  If bInfo = True Then 
    If sValue Then 
      sMessage = String.Left(sValue, 300) & "..." 
      sMessage &= "<h3><font color=blue>" & ("Kein") & "</font>" & Space(1) & ("+Einfügen in Liste") & "</h3>" 
      sMessage &= ("Tabulatoren fehlen (Trenner)") & "<br>"
      
      Select Case Message.Question(sMessage, "?", ("Abbrechen"))
        Case 1 
          'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
          sMessage = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
          Message.Info(sMessage)
        Case 2
          '...
      End Select 
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCheckAplus()
  
  Dim sKey As String
  
  If F_i22 < 22 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
    ColumnView1.Font.Size = 12
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
    ColumnView1.Font.Size = 16
  Endif 
  
  ''Size picture
  If ColumnView1.Keys.Max > -1 Then 
    For Each sKey In ColumnView1.Keys
      If ColumnView1[sKey].Picture Then ColumnView1[sKey].Picture = ColumnView1[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView1Resize()
  Endif 
  If ColumnView2.Keys.Max > -1 Then 
    For Each sKey In ColumnView2.Keys
      If ColumnView2[sKey].Picture Then ColumnView2[sKey].Picture = ColumnView2[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView2Resize()
  Endif 
  ColumnView2.Font.Size = ColumnView1.Font.Size
  Text5.Font.Size = ColumnView1.Font.Size
  Text0.Font.Size = ColumnView1.Font.Size
  Text1.Font.Size = ColumnView1.Font.Size
  Text2.Font.Size = ColumnView1.Font.Size
  Text0b.Font.Size = ColumnView1.Font.Size
  TextBoxSearch5.Font.Size = TextBoxSearch5.H / 2
    
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAdd()                                                           '1x new Line at the End
  
  Dim sK0, sK1, sKeySort As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Columns.Sort <> F_iColumnsCount Then ColumnSortSettingCentral()
  
  If ColumnView1.Selection.Max > -1 Then 
    sK0 = ColumnView1.Selection.Last 
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    sK1 = ColumnView1.Count + 1 '=>Add After Last Key .count-1
    If ColumnView1.Exist(sK1) = False Then 
      sKeySort = ColumnView1[sK0][F_iColumnSort] & ".1" 
      ColumnView1.UnselectAll()
      PicAdd = ColumnViewImages("PicAdd").Picture 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                    'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][1] = ""
      ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1][F_iColumnNr] = sK1 
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
    Endif 
  Else 
    ColumnViewAddMin1xCount()
    M = ColumnView1.MoveLast() 'M=0=False>Exist. M=-1=True>Missing
    If M = 0 Then sK0 = ColumnView1.Item.Key Else sK0 = ColumnView1.Count 
    If ColumnView1.Exist(sK0) = True Then 
      ColumnView1[sK0].Selected = True
      ColumnView1[sK0].EnsureVisible()  
    Endif 
    ColumnSortSettingCentral()
    
    ListAdd.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddAppend()                                                          '1x new Line at end
  
  Dim sK0, sK1 As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  PicAdd = ColumnViewImages("PicAdd").Picture 
  '.Header=True is first Line (Title)
  
  M = ColumnView1.MoveLast()
  If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
    sK0 = ColumnView1.Item.Key                                'only Keys     index 0,1,2,3... Keys "1","2","3"...
    ColumnView1[sK0].EnsureVisible()  
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    ColumnView1.UnselectAll()
    M = ColumnView1.MoveNext() 'M=0=False>Exist. M=-1=True>Missing
    If M = -1 Then sK1 = ColumnView1.Count + 1 '+Plus new Line at the End
    If ColumnView1.Exist(sK1) = False Then 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                  'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][F_iColumnNr] = sK1
      ColumnView1[sK1][F_iColumnSort] = Format(Now, "yyyy-mm-ddhh:nn")        '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
      M = ColumnView1.MoveLast()
      ColumnViewSort(F_iColumnSort)
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Endif 
  Else 
    ColumnViewAddMin1xCount()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddMin1xCount()
  
  Dim sK1 As String 
  Dim PicAdd As Picture
  
  If ColumnView1.Keys Then '1 > only Header (Title)
    If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
    sK1 = ColumnView1.Count + 1
    PicAdd = ColumnViewImages("PicAdd").Picture 
    ColumnView1.Add(sK1, "", PicAdd)
    ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
    ColumnView1[sK1][1] = ""
    ColumnView1[sK1][F_iColumnSort] = Format(Now, "yyyy-mm-ddhh:nn")        '|0|1|2|3|...|F_iColumnSort|...
    ColumnView1[sK1][F_iColumnNr] = sK1 
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnSortSettingCentral()
  
  ColumnView1.Mode = Select.Multiple
  If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
  ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  If ColumnView1.Columns.Sort <> F_iColumnSort Then ColumnView1.Columns.Sort = F_iColumnSort 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnsMore(Optional bONoff As Boolean = False)
  
  Dim it As Integer
  
  ' If ColumnView1.Visible = False Then Side(2)
  F_bColumnsMore = bONoff
  
  If bONoff = False Then
    ColumnView1Resize()
  Else 'mehr
    ColumnView1Resize()
    ColumnView1.Columns[0].Width = 200 'Datum
    ColumnView1.Columns[1].Width = 100 'Uhr
    ColumnView1.Columns[2].Width = 50 'Wochentag
    ColumnView1.Columns[3].Width = 50 'Q
    ColumnView1.Columns[4].Width = 70   'KW
    ColumnView1.Columns[5].Width = 300 'Notiz
    ColumnView1.Columns[6].Width = 100 'Uhr
    ColumnView1.Columns[7].Width = 50 'Wochentag
    ColumnView1.Columns[8].Width = 100 'Sekunden
    ColumnView1.Columns[9].Width = 100 'Dauer
    For it = 10 To ColumnView1.Columns.Max
      ColumnView1.Columns[it].Width = 0  '10 Zeile tag
    Next 
    ColumnView1.Columns[8].Alignment = Align.Right
  Endif
      
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0)
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If iSortColumnNr < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True 'Important (wichtig)
      ' If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView1.Columns.Sort <> iSortColumnNr Then ColumnView1.Columns.Sort = iSortColumnNr 
      If ColumnView1.Selection.Max > -1 Then
        sKey = ColumnView1.Selection.Last  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If iSortColumnNr < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True 'Important (wichtig)
      ' If ColumnView2.Sorted = False Then ColumnView2.Sorted = True 'faster
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView2.Columns.Sort <> iSortColumnNr Then ColumnView2.Columns.Sort = iSortColumnNr 
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection[ColumnView2.Selection.Max]  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewRefresh() 
  
  Dim sK1 As String 
  Dim PicEmpty As Picture
  Dim iLine As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1[sK1][0] = "" Or ColumnView1[sK1][5] = "" Then
        ColumnView1.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
    
  Else ''ColumnView2:
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView2[sK1][0] = "" Or ColumnView2[sK1][5] = "" Then
        ColumnView2.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewBackup()
  
  Dim iColumn, iLine, iBackupsMax As Integer 
  Dim sK1, sLine As String
  Dim hColumnView As New F_multiColumnViewValues 'see Form head▲
  
  '****************
  iBackupsMax = 30
  '****************
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
    If Not F_ooCVBackups Then F_ooCVBackups = New Object[]
    hColumnView.iMode = ColumnView1.Mode 'Multi or Single
    hColumnView.iScrollY = ColumnView1.ScrollY
    hColumnView.iSortColumn = ColumnView1.Columns.Sort
    hColumnView.bSortAscending = ColumnView1.Columns.Ascending   'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    hColumnView.bSorted = ColumnView1.Sorted 'as Boolean
    hColumnView.ssKeys = Null 
    hColumnView.ssLines = New String[]
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ''Selected on?
      If ColumnView1[sK1].Selected = False Then 
        ColumnView1[sK1][F_iColumnSelect] = Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'False
      Else 
        ColumnView1[sK1][F_iColumnSelect] = "-" & Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'True
      Endif 
      
      sLine = "" 'Reset
      For iColumn = 0 To ColumnView1.Columns.Max
        sLine = sLine & ColumnView1[sK1][iColumn] & gb.NewLine 'Note: gb.Tab in Column Undo
      Next 
      hColumnView.ssLines.Add(sLine) 'Not forget: New String[]
    Next 
    If F_bESCpressedON = False Then 
      hColumnView.ssKeys = ColumnView1.Keys '-1 Null
      
      ''Backup:   
      F_ooCVBackups.Add(hColumnView) 'added at the end
      
      If F_ooCVBackups.Max > iBackupsMax Then 
        F_ooCVBackups.Delete(1, 1)    'Object Position 1, 1x
        F_ooCVBackups.Remove(1, 1)    '0,|x|,2,3...removed first List-Nr 1x, not 0. -1 all Rest until End
        '...[it].Delete 'Delete Object
        '.Null 'Delete Array
      Endif 
      F_iCVUndoRedoPointer = F_ooCVBackups.Max
      CVUndoRedoLabelCounter()  'Example: "0/0"
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUndoRedo()
  
  Dim it, iLine As Integer   
  Dim sK1, sPicName, sLine As String 
  Dim ssColumns As String[]
  Dim hColumnView As New F_multiColumnViewValues
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ooCVBackups Then 
      ' PicEmpty = ColumnViewImages("PicEmpty").Picture
      If F_iCVUndoRedoPointer < 0 Then F_iCVUndoRedoPointer = 0
      If F_iCVUndoRedoPointer > F_ooCVBackups.Max Then F_iCVUndoRedoPointer = F_ooCVBackups.Max
      
      hColumnView = F_ooCVBackups[F_iCVUndoRedoPointer] 'Object Position, 1x
      If TypeOf(hColumnView) = gb.Object Then '16 Struct
        ColumnView1.Mode = hColumnView.iMode  'Multi or Single
        ' ColumnView1.ScrollY = hColumnView.iScrollY '->see End
        If ColumnView1.Sorted <> hColumnView.bSorted Then ColumnView1.Sorted = hColumnView.bSorted 'faster
        If ColumnView1.Columns.Sort <> hColumnView.iSortColumn Then ColumnView1.Columns.Sort = hColumnView.iSortColumn
        ColumnView1.Columns.Ascending = hColumnView.bSortAscending 'as Boolean
        ' ColumnView1.Keys 'Read only. hColumnView.ssKeys -> ColumnView1.Keys.Insert()
        
        ''Empty?
        If Not hColumnView.ssKeys Then 
          ColumnView1.Clear()
          ColumnSortSettingCentral()
        Else 
          ColumnView1.Keys.Insert(hColumnView.ssKeys)
          If hColumnView.ssLines.Count < ColumnView1.Count Then hColumnView.ssLines.Resize(ColumnView1.Count)
          
          iLine = 0
          If hColumnView.ssKeys Then
            For Each sK1 In ColumnView1.Keys
              sLine = hColumnView.ssLines[iLine]
              iLine = iLine + 1
              If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
              ''[ESC]?
              If F_bESCpressedON = True Then 
                If MessageQuestionBreak() = True Then Break
              Endif 
              
              ssColumns = Split(sLine & String(ColumnView1.Columns.Count, gb.NewLine), gb.Newline) 'Note: gb.Tab in Column Undo
              For it = 0 To ColumnView1.Columns.Max
                ColumnView1[sK1][it] = ssColumns[it]
              Next 
            Next 
          Else 
            ColumnView1.Clear()
          Endif 
          
          ''Selection + Pictures:
          For Each sK1 In ColumnView1.Keys
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ''Selected on? 
            If String.InStr(ColumnView1[sK1][F_iColumnSelect], "-") = 0 Then   'True "-1", False "0"
              ColumnView1[sK1].Selected = False 
              ' ColumnView1[sK1].Background = Color.Default
              ColumnView1[sK1].Foreground = Color.Default
              If String.InStr(ColumnView1[sK1][F_iColumnSelect], "PicMarkGreen") > 0 Then 'Flag
                ColumnView1[sK1].Background = F_iColorGreenAlpha150
                ColumnView1[sK1].Foreground = F_iColorForegroundBlue
              Endif 
            Else 
              ColumnView1[sK1].Selected = True
              ColumnView1[sK1].Background = F_iColorGreenAlpha220
              ColumnView1[sK1].EnsureVisible()
            Endif 
            sPicName = ColumnView1[sK1][F_iColumnSelect]
            ColumnView1[sK1].Picture = ColumnViewImages(sPicName).Picture 'without "-"
          Next
          ColumnViewSort(F_iColumnSort) 
          ColumnView1.ScrollY = hColumnView.iScrollY
        Endif 
      Endif
    Endif
    
    CVUndoRedoLabelCounter() 'Example: "0/0"
    F_bSaved = False
  Else ''ColumnView2: 
    ColumnViewInfo(("Such-Liste ohne Rückgängig / Wiederherstellen")) ' Search-List without Undo/Redo
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CVUndoRedoLabelCounter()
  
  Dim sText, T1, T2, sSpace, sMin, sMax As String 
  
  sSpace = Space(1)
  sMin = ("min.")
  sMax = ("max.")
  If F_ooCVBackups Then 
    T1 = Str(F_ooCVBackups.Max)
    sText = T1
    If F_iCVUndoRedoPointer <= F_ooCVBackups.Max Then sText = Str(F_iCVUndoRedoPointer) & "/" & T1
  Else 
    T1 = "0"
    sText = T1 & "/" & T1
  Endif 
  If F_ooDateTimeNoticeBackup Then
    T2 = Str(F_ooDateTimeNoticeBackup.Max)
  Else 
    T2 = "0"
  Endif
  ListBackupCounter.Text = sText
  ListBackupCounter.Tooltip = ("<rückgängig") & sSpace & sText & sSpace & ("wiederherstellen>")
  
  MenuUndoMin1.Text = "0/" & T1 & sSpace & sMin
  MenuRedoMax1.Text = T1 & "/" & T1 & sSpace & sMax
  
  MenuUndoMin2.Text = "0/" & T2 & sSpace & sMin
  MenuRedoMax2.Text = T2 & "/" & T2 & sSpace & sMax
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewInfo(Optional CVText As String = "")
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    If CVText = "" Then  
      If ColumnView1.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView1.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView1.Selection.Count) & Space(1) & ("Edit") 
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView1.Columns.Max < 4 Then ColumnView1Resize()
    ColumnView1.Columns[5].Title = CVText
    
  Else ''ColumnView2:
    If CVText = "" Then  
      If ColumnView2.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView2.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView2.Selection.Count) & Space(1) & ("Edit")
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView2.Columns.Max < 4 Then ColumnView2Resize()
    ColumnView2.Columns[5].Title = CVText
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewFind(Optional UpDown As String = "+")
  
  Dim M, it, iLine, iPosition As Integer
  Dim sK1, sText, sFindText As String 
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Count > 0 Then 
      sFindText = TextListSearch.Text
      sFindText = String.LCase(Replace(sFindText, gb.NewLine, "", gb.String))
      PanelSearchList.Visible = True 
      PanelDatum.Visible = False 
      M = ColumnView1.MoveCurrent()
      If ColumnView1.Mode <> Select.Single Then ColumnView1.Mode = Select.Single
      TextListSearch.Foreground = Color.DarkRed
      For it = 0 To ColumnView1.Count - 1 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If UpDown = "+" Then 
          M = ColumnView1.MoveBelow() '▼
          If M = -1 Then M = ColumnView1.MoveFirst() 'M=0=False>Exist. M=-1=True>Missing
        Else 
          M = ColumnView1.MoveAbove() '▲
          If M = -1 Then M = ColumnView1.MoveLast()  
        Endif 
        If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
          sK1 = ColumnView1.Item.Key
          sText = String.LCase(ColumnView1[sK1][F_iColumnUndo]) 
          iPosition = String.InStr(sText, sFindText)  
          If iPosition > 0 Then Break
        Endif 
      Next
      If iPosition > 0 Then
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1].EnsureVisible
        TextListSearch.Foreground = Color.DarkGreen
        ListFound.Picture = PicTemplateApply.Picture
        ListFound.Visible = True 
        ListFound.Raise
        If String.Len(sK1) < 4 Then 
          LabelSearchLineNr.Text = ("Zeile") & Space(1) & sK1 'only Key (Nummer)  
        Else 
          LabelSearchLineNr.Text = sK1 'only Key (Nummer)  
        Endif 
      Else 
        Try ListFound.Picture = PicTemplateQuestionRound.Picture '[?]
        ListFound.Visible = True 
        ListFound.Raise
        LabelSearchLineNr.Text = ("Zeile") & Space(1) & "?"
      Endif 
      ButtonSearchPanel.Background = TextListSearch.Foreground
    Endif 
  Else 
    If UpDown = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnSelectAll()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Menu1Group_Click()
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ColumnViewCheckBoxAbc()
  
  Dim sKey, sK1, sSort As String
  Dim ssKeys, ssSort As New String[]
  Dim it, iLine, it2, M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    ColumnView1.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView1.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView1[sKey][0] & ColumnView1[sKey][1] '0000-00-00 & 00:00
        If ColumnView1[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView1[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView1.Sorted = True
      ' ColumnView1.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1][F_iColumnSort] = iLine
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView1.Count > 1 Then '1 > only Header (Title)
      ColumnView1.Sorted = True 
      ColumnView1.Columns.Ascending = True
      ColumnView1.Columns.Sort = F_iColumnSort
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView1.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then 
        ColumnView1[sKey].Selected = True 
        ColumnView1[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
    
  Else ''ColumnView2:
    ColumnView2.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView2.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView2[sKey][0] & ColumnView2[sKey][1] '0000-00-00 & 00:00
        If ColumnView2[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView2[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView2.Sorted = True
      ' ColumnView2.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        it2 = it2 + 1
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1][F_iColumnSort] = it2
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sKey][F_iColumnSort] = ColumnView2[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView2.Count > 1 Then '1 > only Header (Title)
      ColumnView2.Sorted = True 
      ColumnView2.Columns.Ascending = True
      ColumnView2.Columns.Sort = F_iColumnSort
      M = ColumnView2.MoveLast()
      If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView2.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView2.Exist(sKey) = True Then 
        ColumnView2[sKey].Selected = True 
        ColumnView2[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
  Endif 
Ende:

Catch
  FMain.ErrorText
  
End

Public Sub ColumnAbcInfo()
  
  Dim sInfo As String 
  
  If F_bCheckBoxAbc = False Then 
    sInfo = ("Datei")
  Else 
    sInfo = ("Datum")
  Endif 
  ListCheckBoxAZLabel.Text = sInfo 
  ListCheckBoxAZ.Picture = ListCheckBoxAZ.Picture.Image.Mirror(False, True).Picture
  ColumnViewAscending()
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewListChangeLED() '○ ●
  
  If F_iCVUndoRedoPointerSave > 0 And F_iCVUndoRedoPointer < F_iCVUndoRedoPointerSave Then
    ListIsChanged.Picture = PicTemplateLEDyellow.Picture
  Else If F_iCVUndoRedoPointer < 2 Or F_iCVUndoRedoPointer = F_iCVUndoRedoPointerSave Then 
    ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Else 
    ListIsChanged.Picture = PicTemplateLEDred.Picture
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListButtonsRefresh()
  
  Dim iColor As Integer
  ''Reset
  LabelInfo.Visible = False
  iColor = Color.Default
  If ListDown.Background <> iColor Then ListDown.Background = iColor
  If ListUp.Background <> iColor Then ListUp.Background = iColor
  If ListCut.Background <> iColor Then ListCut.Background = iColor
  If ListCopy.Background <> iColor Then ListCopy.Background = iColor
  If ListPaste.Background <> iColor Then ListPaste.Background = iColor
  If ListSelectAll.Background <> iColor Then ListSelectAll.Background = iColor
  If ListAdd.Background <> iColor Then ListAdd.Background = iColor
  If ListMark.Background <> iColor Then ListMark.Background = iColor
  If ListRefresh.Background <> iColor Then ListRefresh.Background = iColor
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True
  If Object.Type(Last) = "Button" Then Last.Background = F_iColorGreenAlpha150
  If Object.Type(Last) = "PictureBox" Then Last.Background = F_iColorGreenAlpha150 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Blue 
  If Object.Type(Last) = "Label" Then Last.Background = F_iColorGreenAlpha150
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = F_iColorGreenAlpha150 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = F_iColorGreenAlpha150
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = F_iColorGreenAlpha150 
    ListCheckBoxAZLabel.Background = F_iColorGreenAlpha150 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False
  If Object.Type(Last) = "Button" Then Last.Background = Color.Default
  If Object.Type(Last) = "PictureBox" Then Last.Background = Color.Default 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Default 
  If Object.Type(Last) = "Label" Then Last.Background = Color.Default
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = Color.Default 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = Color.Default
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = Color.Default 
    ListCheckBoxAZLabel.Background = Color.Default 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColorPicButtonReplace()
  
  Dim cPic As Picture
  
  cPic = ListSelectAll.Picture
  cPic = cPic.Image.Replace(Color.Black, Color.SelectedBackground).Picture  '(Oldcolor, Newcolor)
  ListSelectAll.Picture = cPic
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxSearch5_MouseDown()
  
  If TextBoxSearch5.Text = ("Suche") Then TextBoxSearch5.Text = ""
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = True 
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150 
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Blue
    Case "new" 
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "linenumber"
      ColumnView1.Background = F_iColorGreenAlpha220
    Case "moreswitches"
      PanelListMenu.Background = F_iColorGreenAlpha150
    Case "text5resize", "searchtext5"
      PanelText5.Background = F_iColorGreenAlpha150
    Case "arrowpaste"
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "newplus"
      Text0.Visible = False 
      Text0b.Visible = False 
      Text1.Visible = False
      Text2.Visible = False
      Text5.Visible = False 
      TextBackgroundAll(Color.White)
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
    Case "save" 
      ColumnView1.Background = F_iColorGreenAlpha220
      LabelInfoPathG(FilePathForm())
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = F_iColorBlue
      TextBoxPath.Foreground = Color.Default
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = True
      ButtonSum.Background = F_iColorGreenAlpha150
      ButtonDauer.Border = True
      ButtonDauer.Background = F_iColorGreenAlpha150
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  End Select
  
  If FMain.F_sErrorInfos Then 
    IconError.Visible = True 
    IconError.Raise() '▲Top▲
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Last.Tag = ButtonDateCancel.Tag Then 
    '...
  Else If Object.Type(Last) = "Button" Then
    Last.Border = False 
    If Last.Background <> Color.Green Then Last.Background = Color.Default
    ListColumnCorrect.Border = F_bCorrectListON
    If F_bCorrectListON = True Then Last.Background = Color.Green Else Last.Background = Color.Default
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Default
    Case "new"
      TextBackgroundAll(Color.Transparent)
    Case "linenumber"
      ColumnView1.Background = Color.Transparent
    Case "moreswitches"
      PanelListMenu.Background = Color.Transparent
    Case "text5resize", "searchtext5"
      PanelText5.Background = Color.Transparent
    Case "arrowpaste"
      TextBackgroundAll(Color.Transparent)
    Case "newplus"
      Text0.Visible = True   
      Text0b.Visible = True  
      Text1.Visible = True
      Text2.Visible = ButtonSum.Visible  
      Text5.Visible = True 
      TextBackgroundAll(Color.Transparent)
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "save"
      ColumnView1.Background = Color.Transparent
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Gray
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = False
      ButtonSum.Background = Color.Default
      ButtonDauer.Border = False
      ButtonDauer.Background = Color.Default
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = Color.Default
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp() 'PictureBox
  
  ' If Object.Type(Last) = "PictureBox" Then ButtonGroupSelect(Last.Tag)
  ' If Last.Name = LabelDiagramTitle.Name Then ButtonGroupSelect(Last.Tag)
  ' ButtonGroupSelect(Last.Tag)
  Select Case Object.Type(Last) 
    Case "Menu"
      '...
    Case "ToggleButton"
      '...
    Case Else 
      ButtonGroupSelect(Last.Tag)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click() 'Click with Buttons or Menue
  
  Select Case Object.Type(Last) 
    Case "Menu"
      ButtonGroupSelect(Last.Tag)
    Case "ToggleButton"
      ButtonGroupSelect(Last.Tag)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "Left")
  
  Dim sKey, sPath, sDir, sFile As String   
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  ' ColumnViewAddMin1xCount()
  sMouseLMR = String.Lower(String.Left(sMouseLMR, 1)) 'Example: "L" '> Left, Middle, Right
  
  Select Case String.LCase(sLastTag)
    Case "add"
      ButtonPathAddG()
    Case "opentermine"
      sPath = FilePathForm() 
      ReadG(sPath, True) 'True: with Dialog
    Case "projectform"
      Form5Projekte.Show
      Form5Projekte.Visible = True
    Case "openbackup"
      sPath = M01Functions.OpenBackupDirFile(FilePathForm())
      ReadG(sPath, True) 'True: with Dialog
    Case "birthdaysoutside" 'Outside —▶
      GeburtstageAuslagernG() '(Auslagern nach F_sPathEveryYear)
    Case "birthdaysinside" 'Inside ◀—
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      ReadG(sPath, True) 'True: with Dialog
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "newplus"
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd"))
      Text1Insert(Format(Time, "hh:nn"))
      Text2Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      PanelText5.Background = Color.White
      ColumnView1.UnselectAll()
      NewLineG()
    Case "reload"
      ColumnViewReload()
    Case "save"
      SaveG()
    Case "saveascopy"
      sPath = FilePathForm()
      sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
      sFile = File.Name(sPath) & "_copy." & File.Ext(sPath)
      sPath = FileDialogPathReturn(sDir &/ sFile, "save", sPath)
      If sPath Then  'Null = Canceled
        If Exist(sPath) = False Then File.Save(sPath, "empty")
        If Exist(sPath) = True Then SaveG(sPath)
      Endif 
      
    Case "exportselection"
      ExportSelectionG()
    Case "termineauslagern"
      TermineAuslagernG()
    Case "termineeinlagern"
      TermineEinlagernG()
    Case "openfeiertageplus"
      If Settings[FMain.Name &/ "OsterSonntag", ""] = "" Then M03Feiertage.HolidaysCalculate() 'Calculeted Holidays
      Form8ZusFeiertage.Window.Show
      ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
    Case "editortermine"
      sPath = FilePathForm()
      M01Functions.FileToForm3Text(sPath)
    Case "editorbirthdays"
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      M01Functions.FileToForm3Text(sPath)
    Case "exportzeichensatz"
      Form13Export.Window.Show
      ' Form13Export.Window.Visible = True  'Wayland error?
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "newline"
      ColumnView1.UnselectAll()
      NewLineG()
    Case "inputline"
      If F_iMusterTermine1Names2Projects3 = 2 Then CheckProjectOnlyName(Text5.Text) 'Test
      ButtonInputG()
      TextBackgroundAll(Color.Transparent)
      
    Case "windowt5plus"
      WindowT5plusG()
    Case "new"
      TextNeuClear()
    Case "searchpanel"
      ButtonSucheG()
    Case "searchpanel5notice"
      PanelSearchText5.Visible = True 
      PanelSearchText5.Raise
      F_iText5SearchPosition = 0
      TextBoxSearch5.SetFocus
    Case "cancelsearch5"
      PanelSearchText5.Visible = False
    Case "searchtext5"
      Text5Search()
    Case "text5resize"
      Text5Resize()
    Case "arrowpaste"
      PasteLineArrow()
      TextBackgroundAll(Color.White)
    Case "cancelbutton"
      SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
    Case "moreswitches"
      MoreButtonsG()
    Case "searchbutton", "search"
      ButtonSearchG()
      If ColumnView2.Visible = True Then ColumnViewFind("+") '↓
    Case "searchdown"
      ColumnViewFind("+") '↓
    Case "searchup"
      ColumnViewFind("-") '↑
    Case "searchliston"
      If ButtonSearchListOn.Background <> Color.Green Then ButtonSearchListOn.Background = Color.Green Else ButtonSearchListOn.Background = Color.Default
      SearchListG()
    Case "searchpanel"
      ListMenuGroupFunctions("searchpanel")
    Case "cancelsearch"
      CancelSearchG()
    Case "saveselection"
      SaveSelectionG()
    Case "labeldateinfo"
      LabelDatumInfo()
    Case "labeltimer"
      LabelTimerG()
    Case "linenumber"
      sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible
    Case "fileinfo"
      FileInfoG()
    Case "title"
      CheckProjectOnlyName(Text5.Text) 'Test
    Case "close"
      ButtonCancelG()
      
      'Extra:
    Case "csv"
      ButtonExternStartG(Last.Tag)
    Case "projectname"
      PanelText5.Background = Color.White
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Case "allyears"
      If F_iMusterTermine1Names2Projects3 = 1 Then CheckBox1G()
    Case "buttonprojecton"
      If F_iMusterTermine1Names2Projects3 = 2 Then 
        CheckBoxONoff.Value = Not CheckBoxONoff.Value
        ProjectONoff(CheckBoxONoff.Value)
      Endif 
    Case "checkbox"
      ' If F_iMusterTermine1Names2Projects3 = 2 Then ProjectONoff(CheckBoxONoff.Value)
    Case "t4", "dauer" 'Duration Button 00:00:00
      If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck() '=calculate new (neu berechnen)
      TextBackgroundAll(Color.White)
    Case "bis"
      If F_iMusterTermine1Names2Projects3 = 1 Then ButtonUntil()
    
    'Error-Lines:
    Case "correctlines"
      ColumnViewCorrectLines(True)
    Case "gotoerrorlinedown"
      ColumnViewGotoErrorLines("down")
    Case "gotoerrorlineup"
      ColumnViewGotoErrorLines("up")
    Case "morecolumns"
      F_bColumnsMore = Not F_bColumnsMore
      ColumnsMore(F_bColumnsMore)
  End Select
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ListMenuGroup_Click() '—▶ Menu _Click!
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroup_MouseDown() 'PanelListMenu □ □ □ □ □ □ □ □
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroupFunctions(Optional sLastTag As String = "")
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form18Projektbearbeiten.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  If ColumnView1.Columns.Max > -1 Then 
    ListButtonsRefresh()
    If Not F_ooCVBackups Then ColumnViewBackup()
    
    Select Case String.LCase(sLastTag)
      Case "selectall"
        ColumnViewSelectAll() 'SelectAll<>UnselectAll
      Case "unselectall"
        ColumnView1.UnselectAll()  
      Case "selectall2"
        ColumnView2.Mode = Select.Multiple
        ColumnView2.SelectAll()  
        ColumnView2to1()
      Case "unselectall2" 
        ColumnView2.UnselectAll()
        ColumnView2to1()
      Case "copy"
        ColumnViewCopy()
      Case "copy2"
        ColumnViewCopy()
      Case "cut" 'delete, remove
        ColumnViewCut()
      Case "cut2"
        ColumnViewCut()
        ColumnView2to1()
      Case "new" 'Clear
        TextNeuClear()
      Case "add", "+1x"
        ColumnViewAdd()
      Case "addappend"
        ColumnViewAddAppend()
      Case "paste", "insert" 
        ColumnViewPaste()
      Case "up"
        ColumnViewUp()
      Case "down"
        ColumnViewDown()
      Case "markgreen"
        ColumnViewMarkGreen()
      Case "refresh", "clean" ', "reload"  'new Numbers 1,2,3...
        ColumnViewRefresh()
        ColumnView1Resize()
      Case "reload"
        ColumnViewReload()
      Case "searchpanel"
        SearchPanelG()
      Case "sortabc"
        ColumnViewCheckBoxAbc()
      Case "original"
        ColumnViewOrig()
      Case "original2"
        ColumnViewOrig()
        ColumnView2to1()
      Case "undo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer - 1
        ColumnViewUndoRedo()
      Case "counterlabel"
        MenuUndoRedo.Popup
      Case "redo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer + 1
        ColumnViewUndoRedo()
      Case "undomin"
        F_iCVUndoRedoPointer = 0
        ColumnViewUndoRedo()
      Case "redomax"
        F_iCVUndoRedoPointer = F_ooCVBackups.Max
        ColumnViewUndoRedo()
      Case "undotext"
        DateTimeNoticeBackup("<")
      Case "redotext"
        DateTimeNoticeBackup(">")
      Case "undotextmin"
        F_iDateTimeNoticeBackupPointer = 0
        DateTimeNoticeBackup("<")
      Case "redotextmax"
        F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        DateTimeNoticeBackup(">")
      Case "textundo"
        Text5.Undo()
      Case "textredo"
        Text5.Redo()
      Case "correctlines"
        ColumnViewCorrectLines(True)
      Case "errorlinescut"
        ColumnviewCheckErrorDaySum()
      Case "correctlinescut"
        ColumnviewCheckErrorDaySum()
      Case "unknowlinestext"
        mnuFehlzeilenG()
        
      Case "columnsminus"
        F_bColumnsMore = False
        ColumnsMore(F_bColumnsMore)
      Case "columnsplus"
        F_bColumnsMore = True
        ColumnsMore(F_bColumnsMore)
      Case "sortpics"
        ColumnViewSortPics()
      Case "double"
        ColumnViewDouble()
      Case "compare1"
        ColumnViewCompare(False)
      Case "compare2"
        ColumnViewCompare(True)
      Case "aplus" 'A+
        If F_i22 < 22 Then 
          F_i22 = 22  'greater (groesser) +
        Else 
          F_i22 = 16 
        Endif 
        ColumnViewCheckAplus()
    End Select
    
    Select Case String.LCase(sLastTag)
      Case "selectall", "unselectall", "save", "changed", "counterlabel", "searchpanel", "columnsminus", "columnsplus"
      Case "undo", "redo", "undomin", "redomax", "textundo", "textredo", "undotext", "redotext", "undotextmin", "redotextmax"
      Case "double", "compare1", "compare2", "aplus"
        '... making no backup
      Case Else 
        F_bListChanged = True
        ColumnViewBackup()
    End Select
  Endif 
  ColumnViewListChangeLED()
  If LabelInfo.Text = "" Then ColumnViewInfo() 'Default Select
  WindowTitle()
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ColumnViewSelectAll()
  
  If ColumnView2.Visible = True Then 
    If ColumnView2.Selection.Max < 1 Then 
      ColumnView2.Mode = Select.Multiple
      ColumnView2.SelectAll()
    Else 
      ColumnView2.UnselectAll()  
    Endif 
  Else 
    If ColumnView1.Selection.Max < 1 Then 
      ColumnView1.Mode = Select.Multiple
      ColumnView1.SelectAll()
    Else 
      ColumnView1.UnselectAll()  
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonPathAddG()
  
  Dim sPath As String 
  
  sPath = TextBoxPath.Text 
  If Settings[FMain.Name &/ "ProjectTest"] = sPath Then 
    sPath = M01Functions.DemoDiagramFile() 'as String 
    ReadG(sPath, False) 'True=Dialogfenster
  Else
    If Exist(sPath) = False Then sPath = FilePathForm()
    ReadG(sPath, False) 'True=Dialogfenster
    ' ButtonPaintDiagramG() '>Form16Diagramm
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then mnuDatei.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnviewCheckErrorDaySum()
  Dim sKey, sKeyLast, sErrorLines, sCorrectLines, sText, sMessage As String 
  Dim picQuestionRed, PicOK, PicCut As Picture
  Dim iLine, it, iErrorLines, iCorrectLines As Integer
  Dim bCutErrorLines, bCutCorrectLines As Boolean
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If ColumnView1.Current Then 
    picQuestionRed = PicTemplateQuestionRed.Picture.Image.Stretch(F_i22, F_i22).Picture
    PicOK = ColumnViewImages("PicOK").Picture
    PicCut = ColumnViewImages("PicCut").Picture
 
    For Each sKey In ColumnView1.Keys
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form16Diagramm.Window.Title) = True Then Break
      Endif 

      If ColumnView1[sKey].Background = F_iSelectRedAlpha220 Then 
        iErrorLines = iErrorLines + 1
      Endif 
      If ColumnView1[sKey].Background = F_iSelectGreenAlpha220 Then 
        iCorrectLines = iCorrectLines + 1
      Endif 
    Next
    ProgressBarONoff(False)
      
    sMessage &= "<h4><font color=gray>" & ("Beispiel Fehler in Dauer") & ": " & ("Weniger als 0 Sekunden oder mehr als 1 Tag") & Space(1) & "(60s×60s×24h=86400s)" & "</font></h4>"
    sMessage &= "<h3><font color=red>" & "○ " & ("Fehler-Zeilen") & ": " & iErrorLines & "</font></h3>"
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Korrigierte Zeilen") & ": " & iCorrectLines & "</font></h3>"
    
    Select Case Message.Question(sMessage, "○ " & ("Ausschneiden"), "● " & ("Ausschneiden"), ("Abbrechen"))
      Case 1 'Cut
        bCutErrorLines = True 
      Case 2 'Directory
        bCutCorrectLines = True 
      Case 3 'Cancel
        ''...
    End Select
    
    If bCutErrorLines = True Then 
      For Each sKey In ColumnView1.Keys
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
        Endif 
        If ColumnView1[sKey].Background = F_iSelectRedAlpha220 Then 
          sKeyLast = sKey
          For it = 0 To F_iColumnsReadMax
            If it < F_iColumnsReadMax Then 
              sErrorLines &= ColumnView1[sKey][it] & hTab
            Else 
              sErrorLines &= ColumnView1[sKey][it] & hReturn  
            Endif 
            ColumnView1[sKey][it] = Null
          Next
          ColumnView1[sKey].Picture = PicCut
        Endif 
      Next 
      If sErrorLines Then 
        Clipboard.Clear()
        Clipboard.Copy(sErrorLines)
        F_iUnknownCounter = iErrorLines
        MenuErrorLinesCut.Text = ("?-Fehler-Zeilen") & ": " & iErrorLines
        ListColumnCorrect.Text = iErrorLines
        If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
        sText = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String 
        F_sUnknownLinesText = sText & gb.NewLine & sErrorLines 
        mnuFehlzeilenG()
        Message.Info(sText, ("Abbrechen"))
      Endif 
    Endif 
  
    If bCutCorrectLines = True Then 
      For Each sKey In ColumnView1.Keys
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form18Projektbearbeiten.Window.Title) = True Then Break
        Endif 
        If ColumnView1[sKey].Background = F_iSelectGreenAlpha220 Then 
          sKeyLast = sKey
          For it = 0 To F_iColumnsReadMax
            If it < F_iColumnsReadMax Then 
              sCorrectLines &= ColumnView1[sKey][it] & hTab
            Else 
              sCorrectLines &= ColumnView1[sKey][it] & hReturn  
            Endif 
            ColumnView1[sKey][it] = Null
          Next
          ColumnView1[sKey].Picture = PicCut
        Endif 
      Next 
      If sCorrectLines Then 
        Clipboard.Clear()
        Clipboard.Copy(sCorrectLines)
        If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible
        sText = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String 
        F_sUnknownLinesText = sText & gb.NewLine & sCorrectLines 
        mnuFehlzeilenG()
        Message.Info(sText, ("Abbrechen"))
      Endif 
    Endif   
  Endif
  ProgressBarONoff(False)
    
  Catch 
  FMain.ErrorText
End

Public Sub ButtonCancelG()
  
  Form18Projektbearbeiten.Window.Close
  
Catch 
  FMain.ErrorText
  
End '...............................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form20OpenSource.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form20OpenSource.class
74,2 KB
' Gambas class file

'F_ = Form 
Public F_bESCpressedON As Boolean
Public F_bFormBackgroundColorChanged As Boolean
Public F_bMovingON As Boolean
Public F_iColorBlue As Integer
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iOnly1x As Integer
Public F_iSearchPosConfig As Integer
Public F_iSearchPosIcon As Integer
Public F_iSearchPosSource As Integer
Public F_iSearchPosText As Integer
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_sForm As String = Me.Name 
Public F_sPathConfigTXT As String 
Public F_sPathIconsPNG As String 
Public F_sPathSourceCacheTXT As String 
Public F_sPathSourceTXT As String 
Public F_sPathTextTXT As String 
Public F_ssIconSelectionKeys As String[]
Public F_sTitleBasicText As String

''_________________________________________________________________________________________________
'' This program terminwecker is Open Source (o), Freeware (f) from www.design-cad.de 2012, 2021, 2022, 2023, 2024
'' This program is written in Gambas3. Thanks. Merci. Danke.

Public Function FilePathForm() As String 
  
  Return Application.Path
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  If Not Form20OpenSource.Window.Icon Then Form20OpenSource.Window.Icon = FMain.Window.Icon
  Form20OpenSource.Window.Title = Application.Name & " - " & ("offener Quellcode 'Open Source'") & Space(3) & "Gambas" & Space(1) & System.FullVersion
  F_sTitleBasicText = Form20OpenSource.Window.Title
  SettingsReadSave("read")
  FormBackgroundColor()
  WindowStretchCursor()
  'M01Functions.SystemDirFileToTrash("test")
   
Catch
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  Form20OpenSource.Window.FullScreen = False
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then Form20OpenSource.Window.Title = ("Abbruch mit [ESC]") Else Form20OpenSource.Window.Title = F_sTitleBasicText
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form20OpenSource.Window.Maximized = False Then
    Form20OpenSource.Window.Maximized = True
  Else
    Form20OpenSource.Window.Maximized = False
    Form20OpenSource.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    F_iColorBlue = Color.Lighter(Color.Lighter(Color.Blue))
    SideG("sidesource")
    'For devolopmenter, for programmer:
    If String.InStr(Application.Path, "/home/") > 0 Then ComponentsToDirConnection() 'not as installed program in root (system)
    ' OpenSourceLoad()
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function ComponentsToDirConnection(Optional bSave As Boolean = False) As String 
  
  Dim sDir, sFile, sDirFile, sDirComponents, sDirFileComponet, sProject, sComponentsList, sComponentLine, sText, sComponentsOff As String
  Dim iCounter, iCountOff As Integer
  
  If String.InStr(Application.Path, "/home/") > 0 Then 
    sDir = Component.Path '/usr/lib/gambas3/
    sDirComponents = Application.Path &/ "components" 
    If bSave = True Then
      If IsDir(sDirComponents) = False Then Try Mkdir sDirComponents
    Endif 
    
    ''Components File-List:
    sProject = Application.Path &/ ".project" 'File with point is unvisible
    If Exist(sProject) = True Then sComponentsList = File.Load(sProject)
    
    If IsDir(sDir) = True And IsDir(sDirComponents) = True Then 
      ''Delete all components in .hidden
      For Each sFile In Dir(sDirComponents, "gb.*.gambas", gb.File)
        sDirFile = sDirComponents &/ sFile 
        If bSave = True Then 
          If Exist(sDirFile) = True Then Try Kill sDirFile
        Endif 
      Next
    Endif
    
    ''Components System-Root:
    If IsDir(Component.Path) = True Then 
      ''Copy all refreshed components in .hidden
      For Each sFile In Dir(Component.Path, "gb.*.gambas", gb.File).Sort()
        sDirFile = Component.Path &/ sFile 
        sDirFileComponet = sDirComponents &/ sFile 
        sComponentLine = Replace(sFile, ".gambas", "")
        sComponentLine = Replace(sComponentLine, "gb.", "Component=gb.")
        ''Components exist:
        If sComponentsList And String.InStr(sComponentsList, sComponentLine) > 0 Then 
          If bSave = True Then 
            Try Copy sDirFile To sDirFileComponet
          Endif 
          sText &= sDirFile & gb.NewLine
          iCounter = iCounter + 1
        Else 
          sComponentsOff &= sDirFile & gb.NewLine
          iCountOff = iCountOff + 1
        Endif 
      Next
    Endif
  Endif 
  
  Print "Components:"
  Print sText 
  Print "iCount=" & iCounter
  Print
  Print sProject & ":"
  Print sComponentsList
  Print 
  Print "sComponentsOff:"
  Print sComponentsOff
  Print "iCountOff=" & iCountOff
  
  Return sText
  ''Menu > Project > Properties > Libraries > more...   (Menü > Projekt > Einstellungen > Bibliotheken > weitere...)
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iPH, iPH2, iBW, iBH As Integer 
  Dim fPart As Float 
  
  If Form20OpenSource.Width < 200 Then Form20OpenSource.Width = 200
  If Form20OpenSource.Height < 200 Then Form20OpenSource.Height = 200
  
  PicBackground.Move(0, 0, Form20OpenSource.ClientW, Form20OpenSource.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Border Width (Randbreite)
  iBH = PicBackground.Height / 100 * 3 'Border Height
  
  iPH = 50 'Pixel, Panel Height
  iPH2 = iPH / 2
  PanelBorder.Move(iBW, iBH, Form20OpenSource.ClientW - (iBW * 2), Form20OpenSource.ClientH - (iBH * 2))
  IconError.Move(Form20OpenSource.ClientW - 32, 0, 32, 32)
  
  PanelList.Move(0, 0, PanelBorder.W, PanelBorder.H - iPH2 - iPH)
  PicBackgroundGridTrans.Move(0, 0, PanelList.W, PanelList.H)
  TextArea1Source.Move(0, 0, PanelList.W, PanelList.H)
  TextArea2Config.Move(0, 0, PanelList.W, PanelList.H)
  TextArea3Text.Move(0, 0, PanelBorder.W, TextArea1Source.H)
  IconView1.Move(0, 0, PanelList.W, PanelList.H)
  
  PanelPath.Move(0, PanelList.Top + PanelList.H, PanelList.W, iPH2)
  PanelClose.Move(0, PanelPath.Top + PanelPath.H, PanelList.W, iPH)
  
  ButtonFileInfo.Move(0, 0, iPH2, iPH2)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (iPH2 * 4), iPH2)
  ButtonPathAdd.Move(TextBoxPath.Left + TextBoxPath.W, 0, iPH2 * 3, iPH2)
  LabelInfo.Move(iPH2, 0, PanelPath.W - iPH2, PanelPath.H)
  ProgressBar1.Move(0, 0, PanelPath.W, PanelPath.H)
  
  ButtonDir.Move(0, 0, iPH, iPH)
  ButtonOpen.Move(ButtonDir.Left + ButtonDir.W, 0, iPH, iPH)
  ButtonSave.Move(ButtonOpen.Left + ButtonOpen.W, 0, iPH, iPH)
  fPart = (PanelClose.W - (iPH * 10)) / 4.5
  ButtonSideSource.Move(ButtonSave.Left + ButtonSave.W, 0, fPart, iPH)
  ButtonSideConfig.Move(ButtonSideSource.Left + ButtonSideSource.W, 0, fPart, iPH)
  ButtonSideText.Move(ButtonSideConfig.Left + ButtonSideConfig.W, 0, fPart, iPH)
  ButtonSideIcons.Move(ButtonSideText.Left + ButtonSideText.W, 0, fPart, iPH)
  ButtonPanelSearch.Move(ButtonSideIcons.Left + ButtonSideIcons.W, 0, fPart, iPH)
  ButtonFree.Move(ButtonPanelSearch.Left + ButtonPanelSearch.W, 0, iPH, iPH)
  ButtonClose.Move(ButtonFree.Left + ButtonFree.W, 0, PanelClose.W - (ButtonFree.Left + ButtonFree.W), iPH)
  
  PanelSearch.Move(PanelClose.Left, PanelClose.Top, PanelClose.W, PanelClose.H)
  TextAreaSearch.Move(0, 0, PanelSearch.W - (ButtonSearch.W * 5), PanelSearch.H)
  LabelBgSearch.Move(0, 0, TextAreaSearch.W, TextAreaSearch.H)
  PicBoxSelectionTop.Move(TextAreaSearch.Left + TextAreaSearch.W, 0, PanelSearch.H, PanelSearch.H) '1:1
  ButtonSearch.Move(PicBoxSelectionTop.Left + PicBoxSelectionTop.W, 0, ButtonSearch.W, PanelSearch.H)
  ButtonSearchBack.Move(ButtonSearch.Left + ButtonSearch.W, 0, ButtonSearch.W, PanelSearch.H)
  ButtonSearchCancel.Move(ButtonSearchBack.Left + ButtonSearchBack.W, 0, PanelSearch.W - (ButtonSearchBack.Left + ButtonSearchBack.W), PanelSearch.H)
  
  ''Form stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form20OpenSource.ClientW - iPH - iBW, Form20OpenSource.ClientH - iPH - iBH, iPH, iPH)  
  
  RaiseOrder()
  
Catch
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  PicBackgroundGridTrans.Lower()
  LabelBgSearch.Lower()
  WindowStretch.Raise() 'Level ▲Top▲
  PanelSearch.Raise()
  IconError.Raise()
  ''_____________________________________________________________________________''
  '(*1) Alternative in New Gambas-Version with TextBox. _Change() only Text, not Color) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub GridTransparentOnOff()
  
  Dim sPath As String
  
  sPath = "images/grid_transparentsquares.png" 'Path relative
  If Not PicBackgroundGridTrans.Picture Then 
    If Exist(sPath) = False Then   
      PicBackgroundGridTrans.Picture = M01Functions.GridTransparentBackgroundSquares(Color.SetAlpha(Color.Gray, 200)).Picture
    Endif 
    If Exist(sPath) = True Then PicBackgroundGridTrans.Picture = Picture.Load(sPath)   
    PicBackgroundGridTrans.Background = Color.Transparent
  Else 
    PicBackgroundGridTrans.Picture = Null
    PicBackgroundGridTrans.Background = Color.Transparent
  Endif 
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form20OpenSource.Left]
      iY = Settings[F_sForm &/ "Top", Form20OpenSource.Top]
      iW = Settings[F_sForm &/ "Width", Form20OpenSource.W]
      iH = Settings[F_sForm &/ "Height", Form20OpenSource.H]
      Form20OpenSource.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form20OpenSource.Left
      Settings[F_sForm &/ "Top"] = Form20OpenSource.Top
      Settings[F_sForm &/ "Width"] = Form20OpenSource.Width
      Settings[F_sForm &/ "Height"] = Form20OpenSource.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Function OpenSourceLoad() As String 
  
  Dim sFile, sDirFile, sDirFileB, sDir, sDirApp As String
  Dim sChangelog, sOpenSourceTXT, sFileText, sInfo, sText, sTextClockMuster, sFilesSizeAll, sText2, sFileChangedDate As String
  Dim iFiles, iLines, iLines1, iLines2, iLetters, iMuster As Integer
  
  F_bESCpressedON = False 'Reset
  ProgressBar1.Value = 0
  ProgressBarONoff(True)
  
  LabelInfo.Text = "<font color=blue><b>" & Form20OpenSource.Window.Title & "</b></font>"
  LabelInfo.Visible = True 
  sOpenSourceTXT = "opensourse.txt"
  ' Wait 0.3
  
  '******************************
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then
    'Example Path absolute: "/dir/file.ext"   Desktop.Open("/dir/file.ext")
    sDirApp = Application.Path & "/" 'Path absolute, complete
  Else 'relative
    'Example Path relative: "dir/file.ext"    Picture.Load("images/file.png")
    'Example Path relative: ".../dir/file.ext"
    sDirApp = "" 'Path relative. In Root System.Path = "/usr/..." or in User.Home = "/home/user/..."
    ' sDirApp = System.Find(Application.Name) & "/" 'System.Path = "/usr/..." ''Installed in Root?
    sDirFile = "text" &/ sOpenSourceTXT
    If Exist(sDirFile) = True Then sText = File.Load(sDirFile)  
    Goto JumpEnd  'Goto not in For...Next Loop
  Endif
  'Picture.Load("images/aplus_32.png") 'Path relative
  
  '******************************
  'in  Root "/usr/..." only Read
  
  sDir = sDirApp & "text"
  sFile = LCase(Application.Name) & "-" & "demo_clockmuster.txt" 'Text-File
  sDirFile = sDir &/ sFile
  sDirFileB = Settings[FMain.Name &/ "F_sDirClock", FMain.F_sDirClock] &/ sFile
  ' sDirFileB = Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt]
  
  If M01Functions.AccessDirFileReadWrite(sDir, 1) = True Then  ' only in "/home/user/..."   'write=1
    If Exist(sDirFileB) = True Then 
      If Exist(sDirFile) = True Then Kill sDirFile
      Copy sDirFileB To sDirFile
    Endif
  Endif 
  
  ''Lines? 
  ''Remove "/home/user/"... dir/file.txt
  If Exist(sDirFile) = True Then 
    sTextClockMuster = File.Load(sDirFile)
    sTextClockMuster = Replace(sTextClockMuster, User.Home & "/", "") ' & "<USER>")
    File.Save(sDirFile, sTextClockMuster)
    sText2 = Replace(sTextClockMuster, "level=begin" & gb.NewLine, "")
    iLines1 = Split(sTextClockMuster & gb.NewLine, gb.NewLine).Max
    iLines2 = Split(sText2 & gb.NewLine, gb.NewLine).Max
    iMuster = iLines1 - iLines2
  Endif  
  
  sDir = sDirApp & ".hidden" ' Directorys with "." are not visible and in Root "/usr/..." not readable 
  sFile = "CHANGELOG"   'Text-File without Ext (ohne Datei-Endung *.txt)
  sDirFile = sDir &/ sFile
  sDirFileB = sDirApp & "text" &/ sFile
  'Save not in Root, but in "/home/user/..."
  If M01Functions.AccessDirFileReadWrite(sDirFile, 1) = True Then  ' only in "/home/user/..."   'write=1
    If Exist(sDirFile) = True Then 
      If Exist(sDirFileB) = True Then Try Kill sDirFileB
      Copy sDirFile To sDirFileB
    Endif 
  Endif 
  If M01Functions.AccessDirFileReadWrite(sDirFileB, 0) = True Then 'Read=0
    sFileChangedDate &= sDirFileB & Space(3) & ("Geändert") & ": " & Format(Stat(sDirFileB).LastModified, "yyyy-mm-dd") ' ddd hh:nn:ss
    sChangelog = File.Load(sDirFileB)
    sChangelog = sFile & gb.NewLine & sChangelog
  Endif 
  
  'Title:
  sText = ("Open Source") & Space(1) & ("(Quell-Text)") & ":" & gb.NewLine & gb.NewLine
  
  ''Image-Files, icons *.png:
  sDir = sDirApp & "images"
  Try iFiles = Dir(sDir, "*.png", gb.File).Count     
  sInfo = Str(iFiles) & Space(1) & ("Eigene") & Space(1) & ("Bilder, Programm-Icons") & gb.NewLine
  sInfo &= Str(iMuster) & Space(1) & ("Uhr-Muster") & gb.NewLine
  
  ''All Files:
  sDir = sDirApp
  Try iFiles = RDir(sDir, "*", gb.File, False).Count 'Dir or RDir(Folder, Pattern*.*, gb.Directory and/or gb.File)
  sInfo &= Str(iFiles) & Space(1) & ("Dateien") & gb.NewLine
  
  ''[ESC]?
  If F_bESCpressedON = True Then Goto JumpEnd  'Goto not in For...Next Loop
  
  ''Application Quell-Code Form:
  sDir = sDirApp & ".src"
  For Each sFile In Dir(sDir, "*.{class,module}")
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
    Endif 
    ProgressBarONoff(True)
    sDirFile = sDir &/ sFile
    If sFile Ends "~" Then 'sFile Example Ends: "FMain.Class~"  Example Begins: "~FMain.Class"
      ''...
    Else 
      If Exist(sDirFile) = True Then
        sFileText = File.Load(sDirFile) 
        If sFileText <> "" Then 
          sText &= gb.NewLine 
          sText &= ("Datei") & ": " & String(50, ".") & gb.NewLine 
          sText &= sDirFile & gb.NewLine 
          sText &= "hidden=" & File.IsHidden(sDirFile) & gb.NewLine  'True or False
          ' sText &= "relative=" & File.IsRelative(sDirFile) & gb.NewLine  'True or False, Gambas3: "A relative path is a path that does not start with / or ~."
          sText &= "realpath=" & File.RealPath(sDirFile) & gb.NewLine '"Return the the canonicalized absolute pathname of a path, with no symbolic links inside."
          sText &= M01Functions.FileSizeLongText(Stat(sDirFile).Size) & gb.NewLine
          sText &= sFileText & gb.NewLine & gb.NewLine 
          ' Print sDirFile
        Endif 
      Endif
    Endif 
  Next
  
  ''Application Quell-Code Form:
  sDir = sDirApp 
  For Each sFile In Dir(sDir, "*.project")
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
    Endif 
    ProgressBarONoff(True)
    sDirFile = sDir &/ sFile
    If sFile Ends "~" Then 'sFile Example Ends: "FMain.Class~"  Example Begins: "~FMain.Class"
      ''...
    Else 
      If Exist(sDirFile) = True Then
        sFileText = File.Load(sDirFile) 
        If sFileText <> "" Then 
          sText &= gb.NewLine 
          sText &= ("Datei") & ": " & String(50, ".") & gb.NewLine 
          sText &= sDirFile & gb.NewLine 
          sText &= "hidden=" & File.IsHidden(sDirFile) & gb.NewLine  'True or False
          ' sText &= "relative=" & File.IsRelative(sDirFile) & gb.NewLine  'True or False, Gambas3: "A relative path is a path that does not start with / or ~."
          sText &= "realpath=" & File.RealPath(sDirFile) & gb.NewLine '"Return the the canonicalized absolute pathname of a path, with no symbolic links inside."
          sText &= M01Functions.FileSizeLongText(Stat(sDirFile).Size) & gb.NewLine
          sText &= sFileText & gb.NewLine & gb.NewLine 
          ' Print sDirFile
        Endif 
      Endif
    Endif 
  Next
  
  ''[ESC]?
  If F_bESCpressedON = True Then Goto JumpEnd  'Goto not in For...Next Loop
  
  sText &= sChangelog & gb.NewLine
  iLetters = String.Len(sText)
  iLines = Split(sText & gb.NewLine, gb.NewLine).Max
  sDir = sDirApp & "text"
  sFile = sOpenSourceTXT'all text
  sDirFile = sDir &/ sFile
  
  sText &= gb.NewLine 
  sText &= gb.NewLine 
  sText &= ("Programm") & ": " & Application.Name & Space(1) & Application.Version & gb.NewLine 
  sText &= sFileChangedDate & gb.NewLine
  sText &= Format(iLetters, "#,###") & Space(1) & ("Schrift-Zeichen") & gb.NewLine '"#,###" 'thousand separators
  sText &= Format(iLines, "#,###") & Space(1) & ("Zeilen") & gb.NewLine
  sText &= sInfo & gb.NewLine
  sText &= "#sFilesSizeAll#" & gb.NewLine
  sText &= ("Dieses Programm ist kostenlos (Freeware)") & ". " & ("Free for all humans.") & gb.NewLine
  sText &= ("App, Software, Program") & ": " & Application.Name & Space(1) & ("is Open Source (o), Freeware (f) from www.design-cad.de") & gb.NewLine
  sText &= ("This program") & Space(1) & Application.Name & Space(1) & ("is written in Gambas") & System.FullVersion & gb.NewLine 'Example: 3.16.90
  sText &= "gambas3-runtime (>= 3.16) (<< 3.99.0)" & gb.NewLine '???
  sText &= ("gambas3 runtime. Interpreter-Version") & ": " & System.Version & ". " & ("Thanks (Merci, Danke)") & "." & gb.NewLine 
  
  sText = Replace(sText, "/" & User.Name, "/" & "<USER>")
  
  ''Save:
  If sText Then 
    If M01Functions.AccessDirFileReadWrite(sDir, 1) = True Then  ' only in "/home/user/..."   'write=1
      If Exist(sDirFile) = True Then Kill sDirFile
      File.Save(sDirFile, sText)
      If Exist(sDirFile) = True Then 
        sFilesSizeAll = M01Functions.FileSizeLongText(Stat(sDirFile).Size) & Space(1) & sOpenSourceTXT
        sText = Replace(sText, gb.NewLine & "#sFilesSizeAll#", sFilesSizeAll & gb.NewLine)
        File.Save(sDirFile, sText)
      Endif 
    Endif 
  Endif 
  
JumpEnd:
  ProgressBarONoff(True)
  PicBackgroundGridTrans.Background = Color.Transparent
  TextArea1Source.Clear()
  TextArea1Source.SelectAll()
  ProgressBarONoff(True)
  TextArea1Source.Insert(sText) ''◀——— all
  TextArea1Source.EnsureVisible()
  
  'Show Progress...
  Wait 0.3
  ProgressBarONoff(False)
  
  Return sDirFile
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  ProgressBarONoff(False)
  
End

Public Sub SettingsLoad() 'unused
  
  Dim sDirFile, sInfo, sText As String
  Dim iLines As Integer
  
  ProgressBarONoff(True)
  
  sDirFile = Settings.Path 
  If Exist(sDirFile) = True Then Try sText = File.Load(sDirFile)   ''Settings.DefaultDir &/ Application.Name & ".conf"
  iLines = Split(sText & gb.NewLine, gb.NewLine).Max 
  
  If Not sText Then sInfo = ("leer")
  
  sText &= sInfo & gb.NewLine
  sText &= gb.NewLine 
  sText &= gb.NewLine 
  sText &= sDirFile & gb.NewLine 
  sText &= Stat(sDirFile).Size & " Bytes" & gb.NewLine 
  sText &= Str(Len(sText)) & Space(1) & ("Schrift-Zeichen") & gb.NewLine
  sText &= Str(iLines) & Space(1) & ("Zeilen") & gb.NewLine
  sText &= ("App, Software, Program") & ": " & Application.Name & Space(1) & ("is Open Source (o), Freeware (f) from www.design-cad.de") & gb.NewLine
  sText &= ("This program is written in Gambas") & System.Version & "." & Space(1) & ("Thanks (Merci, Danke)") & "." & gb.NewLine
  sText = Replace(sText, "/" & User.Name, "/" & "USER")
  TextArea1Source.Clear()
  TextArea1Source.SelectAll()
  TextArea1Source.Insert(sText)
  PicBackgroundGridTrans.Background = Color.Lighter(&HFFC800&) 'Post-Package
  ProgressBarONoff(False)
  
Catch
  FMain.ErrorText
  
End

Public Sub OpenSave(Optional sOpenSave As String = "open", Optional sDirFile As String = "")
  
  Dim ssSpli As String[]
  Dim sSep, sDir, sFile, sText, sPath, sFound, sDirFileBackup, sMessage As String
  
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sFile = File.Name(sDirFile)
  sSep = Space(1) 'Separator
  
  'sDirFile = Settings.Path
  'Example: User.Home &/ ".config/gambas3" &/ Application.Name & ".conf"   or short  "~/.config/gambas3/gambas3.conf"
  
  sDirFileBackup = sDir &/ "backup_" & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & "_" & sFile
  
  Select Case sOpenSave
      
    Case "opensource"
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Quell-Code einlesen...")
      sDirFile = OpenSourceLoad() 'as String 
      
    Case "savesource"
      If TextArea1Source.Text = "" Then 
        Message.Info(("Leer"))
      Else 
        Form20OpenSource.Window.Title = Application.Name & " - " & ("Quell-Code speichern...")
        Dialog.Filter = ["*.txt", ("Nur-Text")] 'and autom. All Files *.* -1  
        sDirFile = sDir &/ "opensource.txt"
        Dialog.Path = sDirFile
        Dialog.AutoExt = True ''needs component: gb.form.dialog
        Dialog.Title = Application.Name & " - " & ("Datei speichern...")
        If Dialog.SaveFile() = True Then Return                                        ''-1=TRUE=Cancel  file is not saved
        
        ''save:
        sDirFile = Dialog.Path
        If Exist(File.Dir(sDirFile)) = True Then 
          ProgressBarONoff(True)
          If TextArea1Source.Visible = True Then Try File.Save(sDirFile, TextArea1Source.Text)
        Endif 
      Endif 
      
    Case "openconfig" ''Open
      sDirFile = Settings.Path
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Einstellungen öffnen...")
      Dialog.Filter = ["*.conf", ("Text Einstellungen (Configuration)") & sSep & Application.Name, "*.txt", ("Nur-Text")]
      Dialog.Path = sDirFile
      Dialog.Title = Application.Name & " - " & ("Datei öffnen...")
      If Dialog.OpenFile() = True Then Return                                        ''-1=TRUE=Cancel  file is not opend
      
      ''load:
      ProgressBarONoff(True)
      sDirFile = Dialog.Path
      If Exist(sDirFile) = True Then sText = File.Load(sDirFile)
      sText = Replace(sText, "/" & User.Name, "/" & "USER")
      TextArea2Config.Clear()
      TextArea2Config.SelectAll()
      TextArea2Config.Insert(sText)
      
    Case "saveconfig" ''Save
      If TextArea2Config.Text = "" Then 
        Message.Info(("Leer"))
      Else 
        sDirFile = Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf] 'sDirFile = Settings.Path
        Form20OpenSource.Window.Title = Application.Name & " - " & ("Einstellungen öffnen...")
        Dialog.Filter = ["*.conf", ("Nur-Text")] 'and autom. All Files *.* -1
        Dialog.Path = sDirFile
        Dialog.AutoExt = True ''needs component: gb.form.dialog
        Dialog.Title = Application.Name & " - " & ("Datei speichern...")
        If Dialog.SaveFile() = True Then Return                                        ''-1=TRUE=Cancel  file is not saved
        
        ''save:
        sDirFile = Dialog.Path
        If Exist(File.Dir(sDirFile)) = True Then 
          ProgressBarONoff(True)
          If TextArea2Config.Visible = True Then 
            If sDirFile = Settings.Path Then 
              ProgressBarONoff(False)
              sMessage = "<h4>" & sDirFile & "</h4>" 
              sMessage &= "<h3>" & ("Programm-Einstellungen (Configuration)") & "<br>" 
              sMessage &= "<font color=red>" & ("Original überschreiben, speichern?") & "</font></h3>"
              Select Case Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
                Case 1
                  Try File.Save(sDirFile, TextArea2Config.Text)
                Case 2 
                  sDirFile = ""
              End Select 
            Else 
              Try File.Save(sDirFile, TextArea2Config.Text)
            Endif 
          Endif 
        Endif 
      Endif 
      
    Case "opentext"
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Paket-Info einlesen...")
      sPath = System.Find("dpkg-query") 'Debian Package-Manager (Paket-Verwaltung)
      sFound = System.Find(Application.Name)
      If sPath <> "" And sFound <> "" Then Shell sPath & Space(1) & "--status" & Space(1) & Application.Name To sText 'all infos about "installed" Software
      If sText Then 
        ssSpli = Split(sText & ",", ",")
        sText = ssSpli.Join(gb.NewLine)
        sText = Replace(sText, "/" & User.Name, "/" & "USER")
        TextArea3Text.Clear()
        TextArea3Text.SelectAll()
        TextArea3Text.Insert(sText)
      Else 
        TextArea3Text.SelectAll()
        TextArea3Text.Insert(("Software-Paket") & Space(1) & Application.Name & ": " & ("Fehlt") & ". " & ("Info nicht möglich"))
      Endif 
      sDirFile = sFound '"/usr/bin/terminwecker"  Software-Package binary ▶□■□■□■◀  
      
    Case "savetext"
      If TextArea3Text.Text = "" Then 
        Message.Info(("Leer"))
      Else 
        sDirFile = sDir &/ "package-info-software.txt"
        Form20OpenSource.Window.Title = Application.Name & " - " & ("Text speichern...")
        Dialog.Filter = ["*.txt", ("Nur-Text")] 'and autom. All Files *.* -1  
        Dialog.Path = sDirFile
        Dialog.AutoExt = True ''needs component: gb.form.dialog
        Dialog.Title = Application.Name & " - " & ("Datei speichern...")
        If Dialog.SaveFile() = True Then Return                                        ''-1=TRUE=Cancel  file is not saved
        
        ''save:
        sDirFile = Dialog.Path
        If Exist(File.Dir(sDirFile)) = True Then 
          ProgressBarONoff(True)
          If TextArea3Text.Visible = True Then Try File.Save(sDirFile, TextArea3Text.Text)
        Endif 
      Endif 
      
    Case "openicons"
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Icons einlesen...")
      sDirFile = IconListAdd() 'as String
      sDirFile = Application.Path &/ "images" &/ File.Name(sDirFile)
      Iconview1.UnselectAll()
      
    Case "saveicons"
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Icons speichern...")
      sDirFile = IconListSave() 'as String
      
  End Select
  
JumpEnd:
  ''Check: 
  If Exist(sDirFile) = True Or sText <> "" Then 
    PicBackgroundGridTrans.Background = F_iColorSelectGreen150
  Else 
    PicBackgroundGridTrans.Background = F_iColorSelectRed150
  Endif 
  
  ProgressBarONoff(False)
  ''Refresh Title
  If TextArea1Source.Visible = True Then 
    SideG("sidesource")
    TextBoxPath.SelectAll()
    Wait
    TextBoxPath.Insert(sDirFile)
    F_sPathSourceTXT = sDirFile
  Else If TextArea2Config.Visible = True Then 
    SideG("sideconfig")
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
    F_sPathConfigTXT = sDirFile
  Else If TextArea3Text.Visible = True Then 
    SideG("sidetext")
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
    F_sPathTextTXT = sDirFile
  Else If IconView1.Visible = True Then 
    SideG("sideicons")
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
    F_sPathIconsPNG = sDirFile
  Endif 
  
  LabelInfoPathG(sDirFile)
  
  'Not Access with "." in Directory?   Example: ".hidden"
  If Exist(sDirFile) = True Then 
    If String.InStr(sOpenSave, "open") > 0 Then 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 0) = False Then Message.Info(sDirFile & "<br><br>" & ("Existiert, aber nicht lesbar (Zugriffsrechte?)"))'read=0, write=1
    Else If String.InStr(sOpenSave, "save") > 0 Then 
      If M01Functions.AccessDirFileReadWrite(sDirFile, 1) = False Then Message.Info(sDirFile & "<br><br>" & ("Existiert, aber nicht beschreibbar (Zugriffsrechte?)"))'read=0, write=1
    Endif  
  Endif 
  
Catch 
  FMain.ErrorText
  ProgressBarONoff(False)
  
End

Public Sub TextArea1Source_MouseDown()
  
  PicBackgroundGridTrans.Visible = False
  PanelList.Background = Color.White
  If F_bFormBackgroundColorChanged = True Then 
    F_bFormBackgroundColorChanged = False 'Reset
    FormBackgroundColor()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub TextArea2Config_MouseDown()
  
  PicBackgroundGridTrans.Visible = False
  PanelList.Background = Color.White
  If F_bFormBackgroundColorChanged = True Then 
    F_bFormBackgroundColorChanged = False 'Reset
    FormBackgroundColor()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub TextArea3Text_MouseDown()
  
  PicBackgroundGridTrans.Visible = False
  PanelList.Background = Color.White
  If F_bFormBackgroundColorChanged = True Then 
    F_bFormBackgroundColorChanged = False 'Reset
    FormBackgroundColor()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub IconView1_MouseDown()
  
  Dim sDir, sFile, sDirFile, sDirFileCache, sDirApp As String  
  
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then
    sDirApp = Application.Path
  Else 
    sDirApp = "./" 'Application.Path ' In Root System.Path = "/usr/..." or in User.Home = "/home/user/..."
  Endif
  ' Print sDirApp
  '******************************
  
  If IsDir(sDirApp) = True Then   ' In Root "/usr/..." only Read
    sDir = sDirApp &/ "images"
    If IconView1.Current Then 
      sFile = IconView1.Current.Text
      sDirFile = sDir &/ sFile
      ' sDirFileCache = File.Dir(Temp()) &/ sFile
      sDirFileCache = M01Functions.CheckDirectoryCache() &/ sFile
      If Exist(sDirFile) = True Then 
        If Exist(sDirFileCache) = True Then Try Kill sDirFileCache
        Try Copy sDirFile To sDirFileCache
        If Exist(sDirFileCache) = True Then sDirFile = sDirFileCache
      Endif 
    Endif 
    PicBackgroundGridTrans.Background = Color.Transparent
  Endif 
  
  If Mouse.Left Then '|◀
    LabelInfoPathG(sDirFile)
  Else If Mouse.Middle Then '▶|◀
    LabelInfoPathG(sDirFile)
    Desktop.Open(sDirFile) 'Open with Standard-Program
    ' M01Functions.ExternStart("gimp", sDirFile)
  Else If Mouse.Right Then '▶|
    MenuEdit.Popup()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub IconView1_MouseUp()
  
  ' IconView1SelectionCount()
  If IconView1.Current Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(IconView1.Current.Text)
    IconView1SelectionCount()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub IconView1_DblClick()
  
  If PicBackgroundGridTrans.Background = Color.Transparent Then 
    PicBackgroundGridTrans.Background = Color.Background
  Else 
    PicBackgroundGridTrans.Background = Color.Transparent
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub IconView1_Select()
  
  If IconView1.Current Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(IconView1.Current.Text)
    IconView1SelectionCount()
    LabelBgSearch.Background = Color.Default
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function IconView1SelectionCount() As Integer
  
  Dim iSelectionCount As Integer
  
  ' If IconView1.Selection.Count > 0 Then 'Gambas 3.17.90
  If IconView1.Selection.Max > -1 Then iSelectionCount = IconView1.Selection.Count
  Me.Title = Application.Name & " - " & ("Auswahl") & Space(1) & iSelectionCount & Space(1) & ("von") & Space(1) & IconView1.Count
  
  Return iSelectionCount
  
Catch
  FMain.ErrorText
  
End

Public Sub TextArea1Source_MouseUp()
  
  F_iSearchPosSource = TextArea1Source.Pos
  
  If TextArea1Source.Selection.Text Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(TextArea1Source.Selection.Text)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub TextArea2Config_MouseUp()
  
  F_iSearchPosConfig = TextArea2Config.Pos
  
  If TextArea2Config.Selection.Text Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(TextArea2Config.Selection.Text)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub TextArea3Text_MouseUp()
  
  F_iSearchPosText = TextArea3Text.Pos
  
  If TextArea3Text.Selection.Text Then 
    TextAreaSearch.SelectAll()
    TextAreaSearch.Insert(TextArea3Text.Selection.Text)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub PrintFileIcons()
  
  Dim sKey, sDirCache, sDirSub, sDir, sFile, sPath, sMessage As String 
  Dim iPics As Integer
  Dim Img As Image
  
  sDirCache = M01Functions.CheckDirectoryCache()
  sDirSub = Settings[F_sForm &/ "F_sDirPrintCache", Null]
  
  ''Check + Sub-Directory:
  If IsDir(sDirSub) = False Then 
    M01Functions.CheckDirAppName()
    sDirSub = sDirCache &/ Application.Name & "-printcache"
    If IsDir(sDirSub) = False Then Try Mkdir sDirSub
  Endif 
  
  ''Delete files in Cache
  If IsDir(sDirSub) = True Then 
    For Each sFile In Dir(sDirSub, "*", gb.File)
      Try Kill sDirSub &/ sFile
    Next 
  Endif 
  
  ''Save Pictures:
  If IconView1SelectionCount() = 0 Then IconView1.SelectAll()
  If IsDir(sDirSub) = True Then 
    iPics = IconView1SelectionCount()
    iPics = String.Len(Str(iPics)) 'as Integer
    For Each sKey In IconView1.Selection
      If IconView1[sKey].Picture Then 
        Img = IconView1[sKey].Picture.Image 
        sFile = Application.Name & "-free-icon-" & Format(0, String(iPics, "0")) & IconView1[sKey].Text
        If String.InStr(sFile, Space(1)) > 0 Then sFile = Replace(sFile, Space(1), "_")
        If File.Ext(sFile) <> "png" Then sFile = sFile & ".png"
        sPath = sDirSub &/ sFile 
        ' Print sPath
        Img.Save(sPath)
      Endif 
    Next 
    '******************************************
    ''HTML > Browser
    M01Functions.PrintFile(sDirSub, Me.Title, 32)
    '******************************************
  Else 
    If IconView1SelectionCount() = 0 Then sMessage = "<h3><font color=red>" & ("Bilder fehlen") & "</font></h3>"
    If IsDir(sDirSub) = False Then sMessage &= "<h3><font color=red>" & ("Ordner fehlt") & "</font></h3>"
    sMessage &= sDirSub
    
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 'Directory
        If IsDir(sDirSub) = True Then sDir = sDirSub Else sDir = File.Dir(sDirSub)
        M01Functions.FileManagerOpen(sDir)
      Case 2
        '... 
    End Select
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  '◀▷'[......■■...]  False: [■■■□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form20OpenSource.Window.Maximized = Not Form20OpenSource.Window.Maximized 
  If Form20OpenSource.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form20OpenSource.Window.FullScreen = True Or Form20OpenSource.Window.Maximized = True Then 
      F_bMovingON = False
      Form20OpenSource.Window.FullScreen = False
      Form20OpenSource.Window.Maximized = False
      If Form20OpenSource.Left + Form20OpenSource.W > Screen.AvailableWidth Then Form20OpenSource.Move(Form20OpenSource.Left, Form20OpenSource.Top, Screen.AvailableWidth - Form20OpenSource.Left, Screen.AvailableHeight - Form20OpenSource.Top)
    Else
      F_bMovingON = True
      Form20OpenSource.Window.FullScreen = False
      Form20OpenSource.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form20OpenSource.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form20OpenSource.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form20OpenSource.ClientW - WindowStretch.W, Form20OpenSource.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form20OpenSource.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form20OpenSource.W = Mouse.ScreenX - F_iX1
    Form20OpenSource.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form20OpenSource.ClientW - WindowStretch.W, Form20OpenSource.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form20OpenSource.ClientW - WindowStretch.W, Form20OpenSource.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form20OpenSource.Window.Maximized = Not Form20OpenSource.Window.Maximized 
    If Form20OpenSource.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  ' ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form20OpenSource.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
  ' MoveLine.Cursor = New Cursor(Picture["images/size_32.png"].Image.Stretch(MoveLine.H, MoveLine.H).RotateLeft().Picture, 0, 0)
  ' MoveLine.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then MenuFile.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  If Exist(F_sPathSourceCacheTXT) = True Then Kill F_sPathSourceCacheTXT
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonDirG()
  
  Dim sDirApp As String 
  
  ButtonDir.Background = Color.Default
  sDirApp = "~" 'in Root                           Gambas3  System.Path = "/usr"
  If String.InStr(Application.Path, System.Path) = 0 Then sDirApp = Application.Path 'in /home/user/...
  sDirApp = M01Functions.FileManagerOpen(sDirApp) 'Path or "" Null
  If Exist(sDirApp) = False Then ButtonDir.Background = Color.Red
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconSelectionTop()
  
  Dim hIconview As IconView
  Dim sK1 As Integer
  
  hIconview = New IconView(PanelHidden)
  hIconview.Sorted = False
  hIconView.Mode = Select.Multiple
  F_ssIconSelectionKeys = New String[]
  
  For Each sK1 In IconView1.Keys
    If IconView1[sK1].Selected = True Then 
      hIconview.Add(sK1, IconView1[sK1].Text, IconView1[sK1].Picture) 
      F_ssIconSelectionKeys.Add(sK1)
    Endif 
  Next
  For Each sK1 In IconView1.Keys
    If IconView1[sK1].Selected = False Then 
      hIconview.Add(sK1, IconView1[sK1].Text, IconView1[sK1].Picture) 
    Endif 
  Next
  
  IconView1.Clear
  IconView1.Sorted = False 
  IconView1.Mode = Select.Multiple
  For Each sK1 In hIconView.Keys
    Iconview1.Add(sK1, hIconView[sK1].Text, hIconView[sK1].Picture) 
    If F_ssIconSelectionKeys.Find(sK1) > -1 Then 
      Iconview1[sK1].Selected = True 
    Else 
      Iconview1[sK1].Selected = False   
    Endif 
  Next
  
  If Not F_ssIconSelectionKeys Then 
    If LabelBgSearch.Background = F_iColorSelectRed150 Then 
      LabelBgSearch.Background = Color.White
    Else 
      LabelBgSearch.Background = F_iColorSelectRed150
    Endif
    LabelBgSearch.Text = ("Ende Suche")
  Else 
    LabelBgSearch.Background = F_iColorSelectGreen150
    LabelBgSearch.Text = ("Gefunden") 
  Endif 
  
  hIconview.Delete()
  IconView1SelectionCount()
  
Catch
  FMain.ErrorText
  
End

Public Function IconListAdd() As String 
  
  Dim sFile, sDirFile, sKey As String 
  Dim iLine, iSize As Integer
  Dim Img As Image
  Dim ssFilesAll, ssFindFiles, ssRestFiles As String[]
  Dim sFindText As String
  
  iSize = 64 'Pixel Icon W x H
  IconView1.Clear()
  IconView1.GridSize = 1 'Pixel (not Icon-Size) Distance Icon border □◀—▶□
  IconView1.IconLines = 1 'max. Lines (Line 1, Line2, ...) Ξ
  Iconview1.Mode = Select.Multiple
  F_ssIconSelectionKeys = New String[]
  ssFindFiles = New String[]
  ssRestFiles = New String[]
  
  sFindText = TextAreaSearch.Selection.Text
  sFindText = "*" & Replace(sFindText, " ", "*") & "*"
  
  ssFilesAll = Dir("images", "*.png") 
  
  If ssFilesAll Then 
    Iconview1.UnselectAll()
    Iconview1.Clear()
    For Each sFile In ssFilesAll.Sort()
      iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
      Endif 
      
      If sFile Like sFindText Then ssFindFiles.Add(sFile) Else ssRestFiles.Add(sFile)
    Next 
    If F_bESCpressedON = True Then Goto JumpEnd
    
    If ssFindFiles.Max > -1 Then 
      For Each sFile In ssFindFiles.Sort()
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
        Endif 
        
        sDirFile = "images" &/ sFile 
        If Exist(sDirFile) = True Then 
          Img = Image.Load(sDirFile)
          If Img Then 
            If Img.H <> iSize Or Img.W <> iSize Then Img = Img.Stretch(iSize, iSize)
            sKey = IconView1.Count + 1
            IconView1.Add(sKey, sFile, Img.Picture)
            Iconview1[sKey].Selected = True 
            F_ssIconSelectionKeys.Add(sKey)
          Endif
        Endif 
      Next 
    Endif 
    If F_bESCpressedON = True Then Goto JumpEnd
    
    If ssRestFiles.Max > -1 Then 
      For Each sFile In ssRestFiles.Sort()
        iLine = iLine + 1
        ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
        Endif 
        
        sDirFile = "images" &/ sFile 
        If Exist(sDirFile) = True Then 
          Img = Image.Load(sDirFile)
          If Img Then 
            If Img.H <> iSize Or Img.W <> iSize Then Img = Img.Stretch(iSize, iSize)
            sKey = IconView1.Count + 1
            IconView1.Add(sKey, sFile, Img.Picture)
            Iconview1[sKey].Selected = False 
          Endif
        Endif 
      Next 
    Endif 
    If PanelSearch.Visible = False Then Iconview1.UnselectAll()
    
  JumpEnd:
    
    ProgressBarONoff(False)
  Endif 
  
  Return sDirFile
  
Catch
  FMain.ErrorText
  
End

Public Function IconListSave() As String 
  
  Dim sDir, sFile, sDirFile, sDirFileLast, sMessage As String 
  Dim sKey As String 
  Dim ssCompare As New String[]
  Dim iLine, iCount, iExist, iSelected, iFound As Integer
  Dim Img As Image
  Dim picIcon As Picture
  
  For Each sKey In IconView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
    Endif 
    
    If IconView1[sKey].Selected = True Then 
      iSelected = iSelected + 1
      ssCompare.Add(IconView1[sKey].Text)
    Endif 
  Next 
  If F_bESCpressedON = True Then Goto JumpEnd 
  
  If iSelected = 0 Then 
    ProgressBarONoff(False) 
    sMessage = ("Auswahl Bilder") & ": " & iSelected
    sMessage &= "<h3>" & ("Vorher Bilder markieren") & "</h3>"
    Message.Info(sMessage, ("Abbrechen"))
    Goto JumpEnd
  Endif 
  
  ProgressBarONoff(False)
  sDir = Settings[FMain.Name &/ "F_sDirPictures", FMain.F_sDirPictures]
  ' sDirName = "icons"
  ' sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  ' If Exist(sDir &/ sDirName) = False Then Try Mkdir sDir &/ sDirName
  ' If Exist(sDir &/ sDirName) = True Then sDir = sDir &/ sDirName
  
  Dialog.Path = sDir
  Dialog.Filter = ["*.png", "Bildformat png"]
  Dialog.Title = Application.Name & " - " & ("Icons speichern...") & Space(1) & ("im Ordner")
  If Dialog.SelectDirectory() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Ordner-Name zurück
    '=False, nicht abgebrochen
  Endif
  'nicht abgebrochen
  sDir = Dialog.Path
  
  ''Check:
  iCount = Dir(sDir, "*.png").Count
  
  For Each sFile In Dir(sDir, "*.png").Sort()
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
    Endif 
    
    If ssCompare.Find(sFile, gb.string) > -1 Then iFound = iFound + 1
  Next 
  If F_bESCpressedON = True Then Goto JumpEnd 
  
  If iCount > 0 Then 
    ProgressBarONoff(False) 
    sMessage = sDir & "<br>"
    sMessage &= ("Vorhandene Bilder im Ordner") & ": " & Str(iCount) & "<br>"
    sMessage &= "<h3><font color=red><b>" & ("Überschreiben") & ": " & iFound & "</b></font></h3>"
    sMessage &= "<h3><font color=blue><b>" & "● " & ("Speichern") & ": " & iSelected & "</b></font></h3>"
    
    Select Case Message.Question(sMessage, "● " & ("Speichern") & Space(1) & iSelected, ("Ordner..."), ("Abbrechen"))
      Case 1 'Save, overwrite
        ''...
      Case 2 'Directory
        If ssCompare Then sDirFile = sDir &/ ssCompare.Last
        If Exist(sDirFile) = True Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else 
          M01Functions.FileManagerOpen(sDir)  
        Endif 
        Goto JumpEnd
      Case 3 'Cancel
        Goto JumpEnd
    End Select 
  Endif 
  
  For Each sKey In IconView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
    Endif 
    
    If IconView1[sKey].Selected = True Then 
      sFile = IconView1[sKey].Text
      sDirFile = "images" &/ sFile 
      Img = Image.Load(sDirFile)
      picIcon = Img.Picture
      If picIcon Then 
        picIcon.Save(sDir &/ sFile)
        If Exist(sDir &/ sFile) = True Then iExist = iExist + 1
        sDirFileLast = sDir &/ sFile
      Endif
    Endif 
  Next 
  ProgressBarONoff(False) 
  
  sMessage = sDir & "<br>" 
  sMessage &= "<h3><font color=darkgreen>" & iExist & Space(1) & ("von") & Space(1) & iSelected & Space(1) & "(" & IconView1.Count & ")" & "</font></h3>"
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
    Case 1 'Directory
      If Exist(sDirFileLast) = True Then 
        M01Functions.FileManagerOpen(sDirFileLast)
      Else 
        M01Functions.FileManagerOpen(sDir)
      Endif 
    Case 2 'Cancel
      '...
  End Select 
  
JumpEnd:
  
  Return sDirFileLast
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub CopyIconG()
  
  Dim sDir, sFile, sDirFile, sDirApp, sMessage As String  
  Dim imgIcon As Image
  
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then
    sDirApp = Application.Path
  Else 
    sDirApp = "./" 'Application.Path ' In Root System.Path = "/usr/..." or in User.Home = "/home/user/..."
  Endif
  ' Print sDirApp
  '******************************
  
  If IsDir(sDirApp) = True Then   ' In Root "/usr/..." only Read
    sDir = sDirApp &/ "images"
    If IconView1.Current Then sFile = IconView1.Current.Text
    sDirFile = sDir &/ sFile
  Endif 
  
  If Exist(sDirFile) = True Then 
    ' Desktop.Open(sDirFile) 'Open with Standard-Program
    sDir = sDirApp &/ "images" 
    If IconView1.Current Then sFile = IconView1.Current.Text
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then sDirFile = M01Functions.FileRootToTemp(sDirFile)' /temp/gambas1000/.../     Programm-Close = delete File
  Endif 
  
  If IconView1.Current Then imgIcon = IconView1.Current.Picture.Image
  
  If imgIcon Then 
    Clipboard.Clear()
    Clipboard.Copy(imgIcon) 
  Else 
    sMessage = "<h3><font color=darkgreen>" & ("Ein Icon auswählen") & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Fehlt") & ":" & "</font></h3>"
    sMessage &= sDirFile 
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDir)
      Case 2 'Cancel 
        '...
    End Select
  Endif 
  
Catch 
  FMain.ErrorText
  
End  

Public Sub CopyIconExternG()
  
  Dim sDir, sFile, sDirFile, sDirApp, sMessage As String 
  
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then
    sDirApp = Application.Path
  Else 
    sDirApp = "./" 'Application.Path ' In Root System.Path = "/usr/..." or in User.Home = "/home/user/..."
  Endif
  ' Print sDirApp
  '******************************
  
  If IsDir(sDirApp) = True Then   ' In Root "/usr/..." only Read
    sDir = sDirApp &/ "images"
    If IconView1.Current Then sFile = IconView1.Current.Text
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then sDirFile = M01Functions.FileRootToTemp(sDirFile)' /temp/gambas1000/.../     Programm-Close = delete File
  Endif 
  
  If Exist(sDirFile) = True Then 
    Desktop.Open(sDirFile) 'Open with Standard-Program
  Else 
    sMessage = "<h3><font color=darkgreen>" & ("Ein Icon auswählen") & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Fehlt") & ":" & "</font></h3>"
    sMessage &= sDirFile 
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDir)
      Case 2 'Cancel 
        '...
    End Select
  Endif 
  
Catch 
  FMain.ErrorText
  
End  

Public Sub DirectoryIconsG()
  
  Dim sDir, sFile, sDirFile, sDirApp, sMessage As String 
  
  If M01Functions.AccessDirFileReadWrite(Application.Path, 1) = True Then
    sDirApp = Application.Path
  Else 
    sDirApp = "./" 'Application.Path ' In Root System.Path = "/usr/..." or in User.Home = "/home/user/..."
  Endif
  ' Print sDirApp
  '******************************
  
  If IsDir(sDirApp) = True Then   ' In Root "/usr/..." only Read
    sDir = sDirApp &/ "images"
    If IconView1.Current Then sFile = IconView1.Current.Text
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then sDirFile = M01Functions.FileRootToTemp(sDirFile)' /temp/gambas1000/.../     Programm-Close = delete File
  Endif 
  
  If Exist(sDirFile) = True Then 
    M01Functions.FileManagerOpen(sDirFile)
  Else 
    sMessage = "<h3><font color=darkgreen>" & ("Ein Icon auswählen") & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Fehlt") & ":" & "</font></h3>"
    sMessage &= sDirFile 
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        M01Functions.FileManagerOpen(sDir)
      Case 2 'Cancel 
        '...
    End Select
  Endif 
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  ' If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Else 
    LabelInfo.Text = ("Ohne Datei")
  Endif 
  LabelInfo.Background = Color.LightBackground
  LabelInfo.Visible = True 
  
  If Exist(sDirFile) = True Then 
    TextBoxPath.Selectall()
    TextBoxPath.Insert(sDirFile)
  Else 
    TextBoxPath.Selectall()
    TextBoxPath.Insert(("Ohne Datei"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_MouseDown()
  
  LabelBgSearch.Background = Color.White
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaSearch_KeyPress()
  
  If Key.Code = Key.Return Then
    
    SearchText() 'ausführen
    If IconView1.Visible = True Then IconSelectionTop()
    
    Stop Event 'Vorgang hier abbrechen ohne Key.Return
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchText(Optional sUpDown As String = "+")
  
  Dim sFindText As String 
  
  TextAreaSearch.SelectAll()
  
  sFindText = TextAreaSearch.Selection.Text
  
  If TextArea1Source.Visible = True Then 
    ''Code:
    F_iSearchPosSource = TextAreaTempPos(TextArea1Source, F_iSearchPosSource, sUpDown) 'as Integer
    
  Else If TextArea2Config.Visible = True Then 
    ''Config:
    F_iSearchPosConfig = TextAreaTempPos(TextArea2Config, F_iSearchPosConfig, sUpDown) 'as Integer
  Else If TextArea3Text.Visible = True Then 
    ''Text:
    F_iSearchPosText = TextAreaTempPos(TextArea3Text, F_iSearchPosText, sUpDown) 'as Integer
  Else If IconView1.Visible = True Then 
    If Iconview1.Keys.Max = -1 Then OpenSave("openicons") 'IconListAdd()
    ''Icon-Text:
    F_iSearchPosIcon = FindIconView1(sUpDown) 'as Integer
    IconView1SelectionCount()
    
  Else 
    IconView1.Visible = True
    ''Icon-Text:
    F_iSearchPosIcon = FindIconView1(sUpDown) 'as Integer
    IconView1SelectionCount()
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Function FindIconView1(Optional sPlusMinus As String = "+") As Integer
  
  Dim sKey, sKeyFind, sText, sFindText, sDirFile As String
  Dim it As Integer
  
  sText = TextAreaSearch.Selection.Text
  sFindText = "*" & Replace(sText, " ", "*") & "*"
  
  IconView1.UnselectAll()
  
  If F_bESCpressedON = True Then Goto JumpEnd
  
  If sPlusMinus = "+" Then  
    F_iSearchPosIcon = F_iSearchPosIcon + 1 
    If F_iSearchPosIcon < 0 Then F_iSearchPosIcon = 0
    If F_iSearchPosIcon > IconView1.Keys.Max Then F_iSearchPosIcon = 0
    For it = F_iSearchPosIcon To IconView1.Keys.Max '▶
      If F_bESCpressedON = True Then
        If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
      Endif
      
      sKey = IconView1.Keys[it] 'Example Index, Key: 0, "7"
      If Iconview1.Exist(sKey) = True And File.BaseName(Iconview1[sKey].Text) Like sFindText Then 
        Iconview1[sKey].Selected = True 
        F_iSearchPosIcon = it
        sKeyFind = sKey
        ' Break 
      Endif 
    Next 
  Endif
  
  If sPlusMinus = "-" Then  
    F_iSearchPosIcon = F_iSearchPosIcon - 1 
    If F_iSearchPosIcon < 0 Then F_iSearchPosIcon = IconView1.Keys.Max
    If F_iSearchPosIcon > IconView1.Keys.Max Then F_iSearchPosIcon = 0
    For it = F_iSearchPosIcon To 0 Step -1 '◀
      If F_bESCpressedON = True Then
        If MessageQuestionBreak(Form20OpenSource.Window.Title) = True Then Break
      Endif
      sKey = IconView1.Keys[it]  'Example Index, Key: 0, "7"
      If Iconview1.Exist(sKey) = True And File.BaseName(Iconview1[sKey].Text) Like sFindText Then 
        Iconview1[sKey].Selected = True 
        F_iSearchPosIcon = it
        sKeyFind = sKey
        ' Break 
      Endif 
    Next 
  Endif 
  
  If F_bESCpressedON = True Then Goto JumpEnd
  
  If IconView1.Exist(sKeyFind) = True Then
    sKey = sKeyFind
    IconView1[sKey].EnsureVisible
    sDirFile = "images" &/ IconView1[sKey].Text
    If Exist(sDirFile) = True Then LabelInfoPathG(sDirFile)
    LabelBgSearch.Background = F_iColorSelectGreen150
    ButtonSearch.Background = F_iColorSelectGreen150
    IconView1[sKey].Selected = False 
    Wait 0.3
    IconView1[sKey].Selected = True 
    Wait 0.3
    IconView1[sKey].Selected = False 
    Wait 0.3
    IconView1[sKey].Selected = True  
  Else 
    If LabelBgSearch.Background = F_iColorSelectRed150 Then 
      LabelBgSearch.Background = Color.White
    Else 
      LabelBgSearch.Background = F_iColorSelectRed150
    Endif
    ButtonSearch.Background = F_iColorSelectRed150
    If sPlusMinus = "+" Then  
      F_iSearchPosIcon = 0
    Else If sPlusMinus = "-" Then  
      F_iSearchPosIcon = IconView1.Keys.Max
    Endif 
  Endif
  
JumpEnd:
  ProgressBar1.Visible = False 
  
  Return F_iSearchPosIcon 
  
Catch
  FMain.ErrorText
  
End

Public Function TextAreaTempPos(Optional hTextArea As TextArea, Optional iLastPos As Integer, Optional sUpDown As String = "+") As Integer
  
  Dim iPos As Integer
  Dim sFindText As String 
  
  LabelBgSearch.Text = "" 'Reset
  sFindText = TextAreaSearch.Text
  
  If hTextArea Then 
    If iLastPos < 0 Then iLastPos = 0
    If sUpDown = "+" Then '> plus down ▼
      iPos = String.InStr(hTextArea.Text, sFindText, iLastPos) 'as Integer  0=not found in String.InStr()
      If iPos > 0 Then 
        ButtonSearch.Background = F_iColorSelectGreen150
      Else 
        ButtonSearch.Background = F_iColorSelectRed150
      Endif 
      ButtonSearchBack.Background = Color.Default
      iLastPos = iPos + 1
    Else '"-" '< minus up ▲
      If iLastPos < String.Len(sFindText) Then iLastPos = String.Len(hTextArea.Text) - 1
      If iLastPos < 1 Then iLastPos = 1
      iPos = String.RInStr(hTextArea.Text, sFindText, iLastPos) 
      If iPos > 0 Then 
        ButtonSearchBack.Background = F_iColorSelectGreen150
      Else 
        ButtonSearchBack.Background = F_iColorSelectRed150
      Endif 
      ButtonSearch.Background = Color.Default
      iLastPos = iPos - 1 
    Endif
    If iPos < 1 Then 'not found 
      If LabelBgSearch.Background = F_iColorSelectRed150 Then 
        LabelBgSearch.Background = Color.White
      Else 
        LabelBgSearch.Background = F_iColorSelectRed150
      Endif
      iLastPos = 0
      LabelBgSearch.Text = ("Ende Suche")
    Else 
      LabelBgSearch.Background = F_iColorSelectGreen150 
      If iPos - 1 < 1 Then iPos = 1
      hTextArea.Select(iPos - 1, String.Len(sFindText)) 'begin min. with 1
      LabelBgSearch.Text = ("Position") & ": " & iPos
    Endif
    hTextArea.EnsureVisible()
  Endif 
  
  Return iLastPos
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer2KeyPress_Timer()
  
  Dim sPath As String 
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  
  sPath = TextBoxPath.Text 
  sPath = Replace(sPath, gb.NewLine, "")
  
  If TextArea1Source.Visible = True Then 
    SideG("sidesource")
    OpenSave("opensource", sPath)
  Else If TextArea2Config.Visible = True Then  
    SideG("sideconfig")
    OpenSave("openconfig", sPath)
  Else If TextArea3Text.Visible = True Then   
    SideG("sidetext")
    OpenSave("opentext", sPath)
  Else If IconView1.Visible = True Then 
    SideG("sideicons")
    OpenSave("openicons", sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideEmptyMessage() 
  
  Dim sMessage As String 
  Dim bEmpty As Boolean ' =False
  
  If TextArea1Source.Visible = True And Not TextArea1Source.Text Then 
    bEmpty = True 
  Else If TextArea2Config.Visible = True And Not TextArea2Config.Text Then  
    bEmpty = True 
  Else If TextArea3Text.Visible = True And Not TextArea3Text.Text Then  
    bEmpty = True 
  Else If Iconview1.Visible = True And Iconview1.Keys.Max = -1 Then  
    bEmpty = True 
  Endif 
  
  If bEmpty = True Then 
    sMessage = "<h3><font color=red>" & ("Leer") & "</font></h3>"
    sMessage &= "<h3><font color=darkgreen>" & ("Eine Ansichts-Seite auswählen, Beispiel") & ":" & "</font></h3>"
    sMessage &= "<h3><font color=blue>" & MenuIconSide.Text & "</font></h3>"
    
    Message.Info(sMessage, ("Abbrechen"))
    SideG("sideicons")
    OpenSave("openicons") 'IconListAdd()
    ' MenuView.Popup()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FreeInfo()
  
  Dim sMessage As String 
  
  sMessage = "<font size=3 color=darkblue>"
  sMessage &= ("Dieses Programm ist kostenlos (Freeware)") & "<br><br>"
  'Free for all people, small and large, narrow and wide, on earth and around the earth.
  'Frei für alle Menschen, für kleine und große, schmale und breite, auf der Erde und um die Erde (Space-Station) 
  sMessage &= "<font color=gray>" & ("Frei für alle Menschen, für kleine und große, schmale und breite, auf der Erde und um die Erde.") & "</font><br><br>"
  sMessage &= ("App, Software, Program") & ": " & Application.Name & Space(1) & ("is Open Source (o), Freeware (f) from www.design-cad.de") & "<br><br>"
  sMessage &= ("This program") & Space(1) & Application.Name & Space(1) & ("is written in Gambas") & System.FullVersion & "<br><br>" 'Example: 3.16.90
  sMessage &= ("gambas3 runtime. Interpreter-Version") & ": " & System.Version & ". " & ("Thanks (Merci, Danke)") & "." 'Example: 3
  sMessage &= "</font>"
  
  Message.Info(sMessage)
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup") 'Backup-Program
  If bExist = True Then
    Shell "deja-dup" 'start Program
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuSettings_Show()
  
  If PicBackgroundGridTrans.Visible = True And PicBackgroundGridTrans.Picture Then MenuTransparent.Checked = True Else MenuTransparent.Checked = False 
  If PicBackgroundGridTrans.Background = Color.White Then MenuWhite.Checked = True Else MenuWhite.Checked = False 
  If PicBackgroundGridTrans.Background = Color.Background Then MenuLightGray.Checked = True Else MenuLightGray.Checked = False 
  
Catch
  FMain.ErrorText
  
End

' Public Sub MenuSettings_LostFocus()
'   
'   MenuSettings.Close
'   Print "close"
'   Catch
'   FMain.ErrorText
'   
' End

Public Sub ListMenuGroup_Click()
  
  ButtonGroupSelect(Last.Tag)
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    If Last.Background <> Color.Green Then 
      Last.Background = F_iColorSelectGreen150
      Last.Border = True 
    Endif 
    If Last.Tag = ButtonFileInfo.Tag Then LabelInfoPathG(TextBoxPath.Text)
    If Last.Tag = ButtonPanelSearch.Tag And PanelSearch.Visible = True Then Last.Background = Color.Green
  Endif 
  
  Select Case String.LCase(Last.Tag)
    Case LabelInfo.Tag
      LabelInfo.Visible = False
    Case "save"
      LabelInfoPathG(TextBoxPath.Text)
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = F_iColorBlue
      TextBoxPath.Foreground = Color.Default
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Then 
    If Last.Background <> Color.Green Then 
      Last.Background = Color.Default
      Last.Border = False 
    Endif 
    If Last.Tag = ButtonPanelSearch.Tag And PanelSearch.Visible = False Then Last.Background = Color.Default 
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case LabelInfo.Tag
      LabelInfo.Visible = False
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Gray
  End Select 
  
Catch
  FMain.ErrorText
  
End

Public Sub SideG(Optional sSide As String = "icons")
  
  Dim sDirFile As String
  
  ''Reset:
  TextArea1Source.Visible = False 
  TextArea2Config.Visible = False 
  TextArea3Text.Visible = False 
  IconView1.Visible = False 
  PicBackgroundGridTrans.Visible = False
  
  PanelList.Background = Color.Default
  PicBackgroundGridTrans.Background = Color.Default
  ButtonSideSource.Background = Color.Default  
  ButtonSideConfig.Background = Color.Default 
  ButtonSideText.Background = Color.Default 
  ButtonSideIcons.Background = Color.Default 
  ButtonSideSource.Border = False 
  ButtonSideConfig.Border = False
  ButtonSideText.Border = False 
  ButtonSideIcons.Border = False
  
  ButtonOpen.Visible = False 
  
  Select Case sSide
      
    Case "sidesource"
      TextArea1Source.Visible = True 
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Quell-Code") & Space(1) & "(Open Source)"
      ButtonSideSource.Border = True 
      ButtonSideSource.Background = Color.Green 
      sDirFile = F_sPathSourceTXT
      
    Case "sideconfig"
      TextArea2Config.Visible = True 
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Einstellungen") & Space(1) & "(*.conf;*.txt)"
      ButtonSideConfig.Border = True 
      ButtonSideConfig.Background = Color.Green 
      ButtonOpen.Visible = True
      sDirFile = F_sPathConfigTXT
      
    Case "sidetext"
      TextArea3Text.Visible = True 
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Paket-Info") & Space(1) & "(*.txt)"
      ButtonSideText.Border = True 
      ButtonSideText.Background = Color.Green 
      sDirFile = F_sPathTextTXT
      
    Case "sideicons"
      IconView1.Visible = True 
      Form20OpenSource.Window.Title = Application.Name & " - " & ("Bilder") & Space(1) & "(*.png)" & Space(1) & ("Programm-Icons")
      ButtonSideIcons.Border = True 
      ButtonSideIcons.Background = Color.Green 
      sDirFile = F_sPathIconsPNG
      PicBackgroundGridTrans.Visible = True
      
  End Select 
  
  LabelInfoPathG(sDirFile)
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  F_bESCpressedON = False 'Reset
  
  sLastTag = LCase(sLastTag)
  
  Select Case sLastTag
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "directoryicons"
      DirectoryIconsG()
      
    Case "fileinfo"
      FileInfoG()
      
    Case "labelinfo"
      LabelInfoPathG() 
      
    Case ButtonDir.Tag 
      ButtonDirG()
      
    Case "sidesource"
      SideG(sLastTag)
      If TextArea1Source.Text = "" Then OpenSave("opensource")
      
    Case "sideconfig"
      SideG(sLastTag)
      If TextArea2Config.Text = "" Then OpenSave("openconfig")
      
    Case "sidetext"
      SideG(sLastTag)
      If TextArea3Text.Text = "" Then OpenSave("opentext")
      
    Case "sideicons"
      SideG(sLastTag)
      If IconView1.Count < 10 Then OpenSave("openicons") 'IconListAdd()
      
    Case "opensource"
      SideG("sidesource")
      OpenSave("opensource")
      
    Case "openconfig"
      SideG("sideconfig")
      OpenSave("openconfig")
      
    Case "opentext"
      SideG("sidetext")
      OpenSave("opentext")
      
    Case "openicons"
      SideG("sideicons")
      OpenSave("openicons")
      
    Case "copyicon"
      CopyIconG()
      
    Case "copyiconextern"
      CopyIconExternG()
      
    Case "printfile"
      If IconView1.Visible = False Then SideG("sideicons")
      If IconView1.Count < 10 Then OpenSave("openicons") 'IconListAdd()
      PrintFileIcons()  ' PrintFile() ''open extern, Example: Browser
      
    Case "savesource"
      SideG("sidesource")
      OpenSave("savesource")
      
    Case "saveconfig"
      SideG("sideconfig")
      OpenSave("saveconfig")
      
    Case "savetext"
      SideG("sidetext")
      OpenSave("savetext")
      
    Case "saveicons"
      SideG("sideicons")
      OpenSave("saveicons")
      
    Case "open"
      If TextArea1Source.Visible = True Then 
        OpenSave("opensource") 
      Else If TextArea2Config.Visible = True Then 
        OpenSave("openconfig") 
      Else If TextArea3Text.Visible = True Then 
        OpenSave("opentext") 
      Else If IconView1.Visible = True Then 
        OpenSave("openicons") 
      Else 
        SideG("sideicons")
        OpenSave("openicons")
      Endif 
      
    Case "save"
      If TextArea1Source.Visible = True Then 
        OpenSave("savesource") ''save
      Else If TextArea2Config.Visible = True Then 
        OpenSave("saveconfig") ''save
      Else If TextArea3Text.Visible = True Then 
        OpenSave("savetext") ''save
      Else If IconView1.Visible = True Then 
        OpenSave("saveicons") ''save
      Else 
        SideG("sideicons")
        OpenSave("saveicons") ''save
      Endif 
      
    Case "white"
      If IconView1.Visible = False Then SideG("sideicons")
      If IconView1.Count < 10 Then IconListAdd()
      PicBackgroundGridTrans.Background = Color.White
    Case "gray"
      If IconView1.Visible = False Then SideG("sideicons")
      If IconView1.Count < 10 Then IconListAdd()
      PicBackgroundGridTrans.Background = Color.Background
      
    Case "transparent"
      If IconView1.Visible = False Then SideG("sideicons")
      If IconView1.Count < 10 Then IconListAdd()
      ' IconView1.Background = Color.Transparent
      PicBackgroundGridTrans.Background = Color.Transparent
      GridTransparentOnOff()
      
    Case "selectall"
      If TextArea1Source.Visible = True Then TextArea1Source.SelectAll()
      If TextArea2Config.Visible = True Then TextArea2Config.SelectAll()
      If TextArea3Text.Visible = True Then TextArea3Text.SelectAll()
      If IconView1.Visible = True Then IconView1.SelectAll()
      
    Case "unselectall"
      If TextArea1Source.Visible = True Then TextArea1Source.Unselect()
      If TextArea2Config.Visible = True Then TextArea2Config.Unselect()
      If TextArea3Text.Visible = True Then TextArea3Text.Unselect()
      If IconView1.Visible = True Then IconView1.UnselectAll()
      
    Case "iconselectiontop"
      If Iconview1.Visible = False Then 
        SideG("sideicons")
        If Iconview1.Keys.Max = -1 Then OpenSave("openicons")  'IconListAdd()
      Endif
      PanelSearch.Visible = True 
      If IconView1.Visible = True Then IconSelectionTop()
      
    Case "refreshbackground"
      FormBackgroundColor()
      GridTransparentOnOff()
      
    Case "settings"
      Form6Einst.Window.Show
      F_bFormBackgroundColorChanged = True
      
    Case "free"
      FreeInfo()
      
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm) 
      
    Case "searchpanel"
      PanelSearch.Visible = Not PanelSearch.Visible
      If PanelSearch.Visible = True Then SideEmptyMessage()
      ' If PanelSearch.Visible = True Then SearchText("+")
      
    Case "searchdown"
      SearchText("+")
      
    Case "searchup"
      SearchText("-")
      
    Case "searchcancel"
      PanelSearch.Visible = False 
      
    Case "close", "cancelform"
      Form20OpenSource.Window.Close
      
  End Select
  
  If IconView1.Visible = True Then PicBoxSelectionTop.Visible = True Else PicBoxSelectionTop.Visible = False
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '..........................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form8ZusFeiertage.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form8ZusFeiertage.class
60,3 KB
' Gambas class file

Public F_bChangeON As Boolean
Public F_bESCpressedON As Boolean
Public F_bListChanged As Boolean
Public F_bMovingON As Boolean
Public F_date As New Date[14] '13 + 1 = 14
Public F_dateOstern As Date 
Public F_iColorChangeBG As Integer = Color.Yellow
Public F_iColorGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorGreen230 As Integer = Color.SetAlpha(Color.Green, 230)
Public F_iColorGreenBG As Integer = &HCFFF9F&
Public F_iColorRed200 As Integer = Color.SetAlpha(Color.Red, 200)
Public F_iOnly1x As Integer
Public F_iX1 As Integer
Public F_iY1 As Integer
Public F_oObject As Object
Public F_sForm As String = Me.Name 

Public Function FilePathForm() As String 
  
  Return Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt", FMain.F_sPathHolidaysPlus_txt]
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  
  Form8ZusFeiertage.Window.Title = Application.Name & " - " & ("+Feiertage einfügen")
  If Not Form8ZusFeiertage.Window.Icon Then Form8ZusFeiertage.Window.Icon = FMain.Window.Icon
  
  SettingsReadSave("read")
  FormBackgroundColor()
  WindowStretchCursor()
  
  ValueBoxYear.Value = Year(Date)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    F_iOnly1x = 1
    FormStart()
    F_bChangeON = True
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True 'Reset 
  F_bESCpressedON = True 'noch ungenutzt
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form8ZusFeiertage.Window.Maximized = False Then
    Form8ZusFeiertage.Window.Maximized = True
  Else
    Form8ZusFeiertage.Window.Maximized = False
    Form8ZusFeiertage.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim BX, BY, DisX, DisY, iTH, BH, C1, C2, C3, C4, CH, P, L, T, U As Integer
  Dim oChild As Object
  
  If Form8ZusFeiertage.Width < 200 Then Form8ZusFeiertage.Width = 200
  If Form8ZusFeiertage.Height < 200 Then Form8ZusFeiertage.Height = 200
  
  BX = Form8ZusFeiertage.ClientW / 100 * 4 '3.2 ' Randbreite
  BY = Form8ZusFeiertage.ClientH / 100 * 4 '3
  '************************
  P = 10                      'Font + Padding
  DisX = 20                   'Distance X ↔
  DisY = 10                   'Distance Y ↕
  BH = 40 'ButtonCancel.H
  '************************
  IconError.Move(Form8ZusFeiertage.ClientW - 32, 0, 32, 32)
  PicBackground.Move(0, 0, Form8ZusFeiertage.ClientW, Form8ZusFeiertage.ClientH)
  For Each oChild In ScrollView1.Children
    If Object.Type(oChild) = "TextArea" Or Object.Type(oChild) = "Label" Or Object.Type(oChild) = "TextBox" Then oChild.Font = Z0.Font
  Next
  iTH = LabelTitle.Font.TextHeight(LabelTitle.Text) + P 'Title Height
  C1 = Z0.Font.TextWidth("123") + DisX
  C2 = D0.Font.TextWidth("yyyy-mm-dd") + P + DisX 
  C3 = W0.Font.TextWidth("dd") + DisX
  C4 = Form8ZusFeiertage.ClientW - Desktop.Y - (2 * BX) - C1 - C2 - C3 - (DisX * 3) 
  CH = D0.Font.TextHeight("yyyy-mm-dd") + P
  T = DisY + CH
  
  PanelTitle.Move(BX, BY, Form8ZusFeiertage.ClientW - (2 * BX), iTH)
  ButtonNew.Move(0, 0, C1 + DisX, iTH)
  ValueBoxYear.Move(ButtonNew.Left + ButtonNew.W, 0, C2 - (iTH * 0.5), iTH)
  PicBoxMinusYear.Move(ValueBoxYear.Left + ValueBoxYear.W, 0, iTH * 0.5, iTH * 0.5)
  PicBoxPlusYear.Move(PicBoxMinusYear.Left, PicBoxMinusYear.Top + PicBoxPlusYear.H, iTH * 0.5, iTH * 0.5)
  ButtonRefresh.Move(PicBoxMinusYear.Left + PicBoxMinusYear.W + DisX, 0, C3, iTH)
  LabelTitle.Move(ButtonRefresh.Left + ButtonRefresh.W + DisX, 0, C4 - (iTH * 1.5), iTH)
  LabelTitleB.Move(LabelTitle.Left - 2, LabelTitle.Top + 2, LabelTitle.Width, LabelTitle.Height)
  LabelTitleB.Text = LabelTitle.Text 
  LabelTitleB.Font = LabelTitle.Font 
  ButtonTip.Move(LabelTitle.Left + LabelTitle.W, 0, iTH * 1.5, iTH)
  
  ScrollView1.Move(BX, PanelTitle.Top + PanelTitle.H + DisY, PanelTitle.W, Form8ZusFeiertage.ClientH - PanelTitle.H - (4 * BY))
  Z1.Move(0, 0, C1, CH)
  Z2.Move(0, T * 1, C1, CH)
  Z3.Move(0, T * 2, C1, CH)
  Z4.Move(0, T * 3, C1, CH)
  Z0.Move(0, T * 4, C1, CH) 'Easter (Ostern)
  Z5.Move(0, T * 5, C1, CH)
  Z6.Move(0, T * 6, C1, CH)
  Z7.Move(0, T * 7, C1, CH)
  Z8.Move(0, T * 8, C1, CH)
  Z9.Move(0, T * 9, C1, CH) 'Christmas (Weihnachten)
  Z10.Move(0, T * 10, C1, CH)
  Z11.Move(0, T * 11, C1, CH)
  Z12.Move(0, T * 12, C1, CH)
  Z13.Move(0, T * 13, C1, CH)
  
  L = Z1.Left + Z1.W + DisX
  D1.Move(L, Z1.Top, C2, CH)
  D2.Move(L, Z2.Top, C2, CH)
  D3.Move(L, Z3.Top, C2, CH)
  D4.Move(L, Z4.Top, C2, CH)
  D0.Move(L, Z0.Top, C2, CH) 'Ostern
  D5.Move(L, Z5.Top, C2, CH)
  D6.Move(L, Z6.Top, C2, CH)
  D7.Move(L, Z7.Top, C2, CH)
  D8.Move(L, Z8.Top, C2, CH)
  D9.Move(L, Z9.Top, C2, CH) 'Weihnachten
  D10.Move(L, Z10.Top, C2, CH)
  D11.Move(L, Z11.Top, C2, CH)
  D12.Move(L, Z12.Top, C2, CH)
  D13.Move(L, Z13.Top, C2, CH)
  
  L = D1.Left + D1.W + DisX
  W1.Move(L, Z1.Top, C3, CH)
  W2.Move(L, Z2.Top, C3, CH)
  W3.Move(L, Z3.Top, C3, CH)
  W4.Move(L, Z4.Top, C3, CH)
  W0.Move(L, Z0.Top, C3, CH) 'Ostern
  W5.Move(L, Z5.Top, C3, CH)
  W6.Move(L, Z6.Top, C3, CH)
  W7.Move(L, Z7.Top, C3, CH)
  W8.Move(L, Z8.Top, C3, CH)
  W9.Move(L, Z9.Top, C3, CH) 'Weihnachten
  W10.Move(L, Z10.Top, C3, CH)
  W11.Move(L, Z11.Top, C3, CH)
  W12.Move(L, Z12.Top, C3, CH)
  W13.Move(L, Z13.Top, C3, CH)
  
  L = W1.Left + W1.W + DisX
  T1.Move(L, Z1.Top, C4, CH)
  T2.Move(L, Z2.Top, C4, CH)
  T3.Move(L, Z3.Top, C4, CH)
  T4.Move(L, Z4.Top, C4, CH)
  T0.Move(L, Z0.Top, C4, CH) 'Ostern
  T5.Move(L, Z5.Top, C4, CH)
  T6.Move(L, Z6.Top, C4, CH)
  T7.Move(L, Z7.Top, C4, CH)
  T8.Move(L, Z8.Top, C4, CH)
  T9.Move(L, Z9.Top, C4, CH) 'Teihnachten
  T10.Move(L, Z10.Top, C4, CH)
  T11.Move(L, Z11.Top, C4, CH)
  T12.Move(L, Z12.Top, C4, CH)
  T13.Move(L, Z13.Top, C4, CH)
  
  ''Date:
  PanelDate.Move(D1.Left, D1.Top, (T1.Left + T1.W) - D1.Left, D9.Top - D1.Top)
  DateChooser1.Move(0, 0, PanelDate.W, PanelDate.H - BH)
  ButtonCancelDate.Move(0, DateChooser1.Top + DateChooser1.H, PanelDate.W, BH)
  
  ''List:
  PanelList.Move(ScrollView1.Left, ScrollView1.Top, ScrollView1.W, ScrollView1.H)   
  TextArea1.Move(0, 0, PanelList.W, PanelList.H - BH)
  ButtonCancelList.Move(0, PanelList.H - BH, PanelList.W, BH)
  
  ''Panel Save:
  PanelMenu.Move(BX, Form8ZusFeiertage.ClientH - (BH + BY), PanelTitle.W, BH)
  U = T1.W / 5
  ButtonBackup.Move(0, 0, Z1.W, BH)
  ButtonSave.Move(D1.Left, 0, D1.W, BH)
  ButtonList.Move(D1.Left + D1.W, 0, T1.Left - (D1.Left + D1.W), BH)
  ButtonCancel.Move(ButtonList.Left + ButtonList.W, 0, C4, BH)
  
  If F_bMovingON = False Then WindowStretch.Move(Form8ZusFeiertage.ClientW - BX - BH, Form8ZusFeiertage.ClientH - BY - BH, BH, BH)  
  ResizeOrder()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizeOrder()
  
  PicBackground.Lower
  LabelTitle.Raise
  LabelTitleB.Lower
  ValueBoxYear.Raise
  PicBoxMinusYear.Raise
  PicBoxPlusYear.Raise
  ButtonRefresh.Raise
  ButtonNew.Raise
  IconError.Raise
  TextArea1.Raise
  WindowStretch.Raise
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG()
  
  Dim sHolidaysPlus, sTextOld, sMessage, sPath, sLastTime, sTitle As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  Z0.Text = Replace(Z0.Text, "+", "")
  Z1.Text = Replace(Z1.Text, "+", "")
  Z2.Text = Replace(Z2.Text, "+", "")
  Z3.Text = Replace(Z3.Text, "+", "")
  Z4.Text = Replace(Z4.Text, "+", "")
  Z5.Text = Replace(Z5.Text, "+", "")
  Z6.Text = Replace(Z6.Text, "+", "")
  Z7.Text = Replace(Z7.Text, "+", "")
  Z8.Text = Replace(Z8.Text, "+", "")
  Z9.Text = Replace(Z9.Text, "+", "")
  Z10.Text = Replace(Z10.Text, "+", "")
  Z11.Text = Replace(Z11.Text, "+", "")
  Z12.Text = Replace(Z12.Text, "+", "")
  Z13.Text = Replace(Z13.Text, "+", "")
  
  sTitle = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Zusaetzliche Feiertage, Gedenktage") & Space(1) & ("Trenner: TABulator") & hReturn
  sHolidaysPlus = ""
  sHolidaysPlus &= "HolidaysPlus00" & hTab & Z0.Text & hTab & D0.Text & hTab & W0.Text & hTab & T0.Text & hReturn  ' Ostern
  sHolidaysPlus &= "HolidaysPlus01" & hTab & Z1.Text & hTab & D1.Text & hTab & W1.Text & hTab & T1.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus02" & hTab & Z2.Text & hTab & D2.Text & hTab & W2.Text & hTab & T2.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus03" & hTab & Z3.Text & hTab & D3.Text & hTab & W3.Text & hTab & T3.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus04" & hTab & Z4.Text & hTab & D4.Text & hTab & W4.Text & hTab & T4.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus05" & hTab & Z5.Text & hTab & D5.Text & hTab & W5.Text & hTab & T5.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus06" & hTab & Z6.Text & hTab & D6.Text & hTab & W6.Text & hTab & T6.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus07" & hTab & Z7.Text & hTab & D7.Text & hTab & W7.Text & hTab & T7.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus08" & hTab & Z8.Text & hTab & D8.Text & hTab & W8.Text & hTab & T8.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus09" & hTab & Z9.Text & hTab & D9.Text & hTab & W9.Text & hTab & T9.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus10" & hTab & Z10.Text & hTab & D10.Text & hTab & W10.Text & hTab & T10.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus11" & hTab & Z11.Text & hTab & D11.Text & hTab & W11.Text & hTab & T11.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus12" & hTab & Z12.Text & hTab & D12.Text & hTab & W12.Text & hTab & T12.Text & hReturn
  sHolidaysPlus &= "HolidaysPlus13" & hTab & Z13.Text & hTab & D13.Text & hTab & W13.Text & hTab & T13.Text & hReturn
  ''Entfernen:
  sHolidaysPlus = Replace(sHolidaysPlus, "yyyy-mm-dd", "")
  ' sHolidaysPlus = Replace(sHolidaysPlus, "<-?", "")
  
  ''Check:
  sPath = FilePathForm() 'Hinweis: im Programm-Ordner bzw. Root-Ordner nur "lesen" erlaubt
  If Exist(sPath) = True Then 'FMain.F_sPathHolidaysPlus_txt
    ' Try sLastTime = Format(Stat(sPath).LastModified, "yyyy-mm-dd ddd hh:nn:ss") 'as String
    sLastTime = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & Space(1) & M01Functions.FileSizeLongText(Stat(sPath).Size) & "</b></font>" 
    Try sTextOld = File.Load(sPath)
    sMessage = "<b>" & "● " & sPath & "</b>" & "<br>"
    sMessage &= sLastTime & "<br>" 
    sMessage &= "<font color=darkgray>" & ("Datei-Inhalt") & ":" & "</font><br>" 
    sMessage &= "<font color=darkgray>" & sTextOld & "</font><br>" 
    sMessage &= "<font color=darkgreen><b>" & ("Neu") & ":" & "</b></font><br>"
    sMessage &= sHolidaysPlus
    sMessage &= "<h4><font color=darkgreen><b>" & ("Speichern") & "</font><font color=red><b>" & Space(1) & ("und vorhandene Datei überschreiben?") & "</b></font></h4>"
  Else 
    sMessage = "<font color=gray><b>" & "● " & sPath & "</b></font><br>" & "<br>"
    sMessage &= "<b>" & ("Die Datei existiert noch nicht") & "</b><br>" & "<br>"
    sMessage &= "<font color=gray>" & sHolidaysPlus & "</font>"
  Endif 
  
  Select Case Message.Question(sMessage, "● " & ("Speichern"), ("Ordner..."), ("Abbrechen")) 'max.3 Buttons
    Case 1 ''Save:
      Settings[FMain.Name &/ "sHolidaysPlus"] = sHolidaysPlus '=> M03Feiertage.FeiertagePlusBerechnen(YDate)
      sPath = M01Functions.FileTextPlus(sPath, sTitle & sHolidaysPlus, True) ' TRUE=overwrite (überschreiben)
      ''Settings extra:
      Settings[FMain.Name &/ "HolidaysPlus00"] = Z0.Text & hTab & D0.Text & hTab & W0.Text & hTab & T0.Text  ' Ostern
      Settings[FMain.Name &/ "HolidaysPlus01"] = Z1.Text & hTab & D1.Text & hTab & W1.Text & hTab & T1.Text 
      Settings[FMain.Name &/ "HolidaysPlus02"] = Z2.Text & hTab & D2.Text & hTab & W2.Text & hTab & T2.Text 
      Settings[FMain.Name &/ "HolidaysPlus03"] = Z3.Text & hTab & D3.Text & hTab & W3.Text & hTab & T3.Text 
      Settings[FMain.Name &/ "HolidaysPlus04"] = Z4.Text & hTab & D4.Text & hTab & W4.Text & hTab & T4.Text 
      Settings[FMain.Name &/ "HolidaysPlus05"] = Z5.Text & hTab & D5.Text & hTab & W5.Text & hTab & T5.Text 
      Settings[FMain.Name &/ "HolidaysPlus06"] = Z6.Text & hTab & D6.Text & hTab & W6.Text & hTab & T6.Text 
      Settings[FMain.Name &/ "HolidaysPlus07"] = Z7.Text & hTab & D7.Text & hTab & W7.Text & hTab & T7.Text 
      Settings[FMain.Name &/ "HolidaysPlus08"] = Z8.Text & hTab & D8.Text & hTab & W8.Text & hTab & T8.Text 
      Settings[FMain.Name &/ "HolidaysPlus09"] = Z9.Text & hTab & D9.Text & hTab & W9.Text & hTab & T9.Text 
      Settings[FMain.Name &/ "HolidaysPlus10"] = Z10.Text & hTab & D10.Text & hTab & W10.Text & hTab & T10.Text 
      Settings[FMain.Name &/ "HolidaysPlus11"] = Z11.Text & hTab & D11.Text & hTab & W11.Text & hTab & T11.Text 
      Settings[FMain.Name &/ "HolidaysPlus12"] = Z12.Text & hTab & D12.Text & hTab & W12.Text & hTab & T12.Text 
      Settings[FMain.Name &/ "HolidaysPlus13"] = Z13.Text & hTab & D13.Text & hTab & W13.Text & hTab & T13.Text 
      BackgroundsRefresh()
      ButtonSave.Background = Color.ButtonBackground
      TextChanged(False)
    Case 2 ''Directory:
      If Exist(sPath) = False Then sPath = File.Dir(sPath)
      M01Functions.FileManagerOpen(sPath)
    Case 3 ''Cancel:
      '... 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub TipG()
  
  Dim sMessage As String 
  
  sMessage = ("Siehe im Fenster '+Bearbeiten'") & "<br><br>"
  sMessage &= "<font size=4 color=darkgreen><b>" & ("*Jedes Jahr") & "</b></font>"
  Select Case Message.Question(sMessage, ("+Bearbeiten"), ("Abbrechen"))
    Case 1 
      Form2Bearb.Window.Show
    Case 2
      '...Cancel
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub BackgroundsRefresh()
  
  Dim iCol1, iCol2, iCol3 As Integer
  
  iCol1 = Color.SelectedBackground
  iCol2 = Color.Default
  iCol3 = F_iColorGreen230
  
  Z0.Background = iCol1 'Easterday (Ostern)
  Z1.Background = F_iColorGreenBG
  Z2.Background = F_iColorGreenBG
  Z3.Background = F_iColorGreenBG
  Z4.Background = iCol2
  Z5.Background = iCol2
  Z6.Background = F_iColorGreenBG
  Z7.Background = F_iColorGreenBG
  Z8.Background = F_iColorGreenBG
  Z9.Background = iCol1 'Christmas (Weihnachten)
  Z10.Background = iCol2
  Z11.Background = iCol2
  Z12.Background = iCol2
  Z13.Background = iCol2
  
  D0.Background = iCol1
  D1.Background = iCol2
  D2.Background = iCol2
  D3.Background = iCol2
  D4.Background = iCol2
  D5.Background = iCol2
  D6.Background = iCol2
  D7.Background = iCol2
  D8.Background = iCol2
  D9.Background = iCol1
  D10.Background = F_iColorGreenBG
  D11.Background = F_iColorGreenBG
  D12.Background = F_iColorGreenBG
  D13.Background = F_iColorGreenBG
  
  W0.Background = iCol1
  W1.Background = iCol3
  W2.Background = iCol3
  W3.Background = iCol3
  W4.Background = iCol2
  W5.Background = iCol2
  W6.Background = iCol3
  W7.Background = iCol3
  W8.Background = iCol3
  W9.Background = iCol1
  W10.Background = iCol3
  W11.Background = iCol3
  W12.Background = iCol3
  W13.Background = iCol3
  
  T0.Background = iCol1
  T1.Background = F_iColorGreenBG
  T2.Background = F_iColorGreenBG
  T3.Background = F_iColorGreenBG
  T4.Background = iCol2
  T5.Background = iCol2
  T6.Background = F_iColorGreenBG
  T7.Background = F_iColorGreenBG
  T8.Background = F_iColorGreenBG
  T9.Background = iCol1
  T10.Background = F_iColorGreenBG
  T11.Background = F_iColorGreenBG
  T12.Background = F_iColorGreenBG
  T13.Background = F_iColorGreenBG
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListG() 'gespeicherte Feiertage
  
  Dim sText, sInfoText, sYear, sDatum As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If PanelList.Visible = True Then
    ButtonList.Background = F_iColorChangeBG
    TextArea1.Text = ""
    ' PanelList.Visible = True
    PanelList.Raise
    sText = Settings[FMain.Name &/ "F_sFeiertage", Null]
    sYear = ValueBoxYear.Value
    If sText = Null Or sYear <> Str(Year(Date)) Then 
      sDatum = Format(Date(sYear, 1, 1), "yyyy-mm-dd")
      M03Feiertage.HolidaysCalculate(sDatum) 'inclusiv neues Settings[FMain.Name &/ "F_sFeiertage"]
      sText = Settings[FMain.Name &/ "F_sFeiertage", Null]
    Endif 
    ' sText = Replace(sText, "TAB2", hReturn & "TAB2") 'TAB2018-01-01TAB#(...)
    ' sText = Replace(sText, gb.Tab, hTab)
    
    sInfoText = "Das Ostersonntag-Datum wird mit einer Formel berechnet, auch intern im Programm (Gauß'sche Oster-Formel, Carl Friedrich Gauß (Mathematiker 1777-1855))." & hReturn
    sInfoText &= "Tage (-) vor oder (+) nach dem berechneten OsterSonntag-Datum für die noerdliche Erdhalbkugel:" & hReturn
    sInfoText &= "Ostern ist am ersten Sonntag nach dem ersten Vollmond des Fruehlingsanfangs (21.03)." & hReturn
    sInfoText &= hReturn
    sInfoText &= "Beispiel 'bewegliche Feiertage':" & hReturn
    sInfoText &= "Pfingstsonntag = +49" & hReturn
    sInfoText &= "Rosenmontag = -48" & hReturn
    sInfoText &= hReturn
    sInfoText &= "Beispiel 'unbewegliche Feiertage':" & hReturn
    sInfoText &= "Neujahr = 01.Januar" & hReturn
    sInfoText &= "1. Weihnachtstag = 25.12" & hReturn
    sInfoText &= hReturn
    
    sInfoText &= "Rosenmontag = -48" & hReturn
    sInfoText &= "Aschermittwoch = -46" & hReturn
    sInfoText &= "Palmsonntag = -7" & hReturn
    sInfoText &= "Gründonnerstag = -3 Tage vor OsterSonntag-Datum" & hReturn
    sInfoText &= "Karfreitag =  -2" & hReturn
    sInfoText &= "OsterSonntag-Datum = 0" & hReturn '*** Berechnet nach: Gauß'sche Osterformel
    sInfoText &= "Ostermontag = + 1" & hReturn
    sInfoText &= "Christi Himmelfahrt = +39" & hReturn
    sInfoText &= "Pfingstsonntag = +49" & hReturn
    sInfoText &= "Pfingstmontag = +50" & hReturn
    sInfoText &= "Fronleichnam = +60" & hReturn
    sInfoText &= "Heilige Drei Könige = 06.01." & hReturn
    sInfoText &= "Mariae Himmelfahrt = 15.08." & hReturn
    sInfoText &= "Muttertag = 2. Sonntag im Mai" & hReturn
    sInfoText &= "Michaelis = 29.9 Namenstag" & hReturn
    sInfoText &= "Deutsche Einheit = 03.10" & hReturn
    sInfoText &= "Reformationstag = 31.10" & hReturn
    sInfoText &= "Buß- und Bettag = 11 Tage vor 1. Advent" & hReturn
    sInfoText &= "Nikolaus = 6.12 Namenstag" & hReturn
    sInfoText &= "1. Advent  = Sonntag nach 26. Nov. oder  4. Sonntag vor 25.12." & hReturn
    sInfoText &= "Heilig Abend = 24.12" & hReturn
    sInfoText &= "1. Weihnachtstag = 25.12" & hReturn
    sInfoText &= "2. Weihnachstag = 26.12" & hReturn
    sInfoText &= "Neujahr = 01.01" & hReturn
    sInfoText &= "Trinitatis. Sonntag nach Pfingstsonntag." & hReturn
    sInfoText &= "Maifeiertag / Tag der Arbeit = 01.05" & hReturn
    sInfoText &= "Erntedankfest = 1. Sonntag im Oktober (kath.) oder 1. So in 40KW oder Sonntag nach Michaelis ((evang., hl. Michael) das ist der 29. September)" & hReturn
    sInfoText &= "St. Martin = 11.November" & hReturn
    sInfoText &= "Volkstrauertag. 22. Sonntag nach Trinitatis oder zweiten Sonntag vor erstem Advent, 3 Tage vor Buß-und Bettag" & hReturn
    sInfoText &= "Allerheiligen = 1.November" & hReturn
    sInfoText &= "Silvester = 31.12" & hReturn
    
    sInfoText &= "Valentinstag = +44" & hReturn
    sInfoText &= "Frühlingsanfang  +79 (+ eventuell Schalttag)" & hReturn
    sInfoText &= "Sommeranfang  +171 (+ eventuell Schalttag)" & hReturn
    sInfoText &= "Friedensfest (nur in Augsburg/Bayern)  + 219 (+ eventuell Schalttag)" & hReturn
    sInfoText &= "Herbstanfang  +275 (+ eventuell Schalttag)" & hReturn
    sInfoText &= "Winteranfang  +355 (+ eventuell Schalttag)" & hReturn
    
    sInfoText &= "Jahreszeiten nördliche Erdhalbkugel" & hReturn
    sInfoText &= "20/21 März Frühling" & hReturn
    sInfoText &= "21/22 Juni Sommer" & hReturn
    sInfoText &= "22/23 Sept. Herbst" & hReturn
    sInfoText &= "21/22 Dez. Winter" & hReturn
    
    sInfoText &= "Beginn Sommerzeit letzter Sonntag im März" & hReturn
    sInfoText &= "Beginn Winterzeit letzter Sonntag im Oktober" & hReturn
    
    sInfoText &= "____________________________________________" & hReturn
    sInfoText &= "Quelle: Deutsche Bundesbehörde www.ptb.de Physikalisch-Technische Bundesanstalt (PTB), Ostertabelle, Ostertermine" & hReturn
    sInfoText &= "Quelle: Eigene allgemeine Sammlung 2000 bis 2012." & hReturn
    sInfoText &= "Tipp: Gesetzliche Feiertage und weitere Gedenktage sind zunehmend im Internet auf staatlichen Seiten veröffentlicht: Kultusministerium, Ferien, Länder-Ministerien, Behörden, offizielle Städte-Seiten..." & hReturn
    TextArea1.SelectAll()
    TextArea1.Insert(sText & hReturn & sInfoText)
    TextArea1.Pos = 0 'Len(TextArea1.Text)
    TextArea1.EnsureVisible()
  Else
    ButtonList.Background = Color.ButtonBackground
    ' PanelList.Visible = False
  Endif
  ButtonList.Border = PanelList.Visible 'True or False
  
Catch 
  FMain.ErrorText
  
End

Public Function OsterSonntagDate(Optional iYear As Integer = 0) As Date
  
  Dim hDate As Date
  
  If iYear = 0 Then iYear = ValueBoxYear.Value
  If iYear < 1583 Then iYear = Year(Date)
  hDate = Date.EasterDay(iYear) 'neu in Gambas3
  If IsDate(Str(hDate)) = False Then hDate = M03Feiertage.OsterterminDate(Date)
  
  Return hDate
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateCheck(Optional Feld As Integer = 0)
  
  Dim sDatum, sEmpty As String 
  Dim hDate As Date
  Dim iCol, iColG, iZahl As Integer
  Dim sQuestion As String 
  
  sQuestion = ""
  sEmpty = ""
  F_bChangeON = False 
  IconError.Visible = False
  F_dateOstern = OsterSonntagDate(ValueBoxYear.Value) 'as Date
  iCol = Color.Default
  iColG = Color.LightGray
  
  Select Case Feld
      
    Case 0
      D0.Text = sQuestion
      Z0.Text = "0"
      If IsInteger(Replace(Z0.Text, "+", "")) Then  
        hDate = F_dateOstern
        D0.Text = Format(hDate, "yyyy-mm-dd")
        W0.Text = Format(hDate, "ddd")
        T0.Text = ("Ostersonntag")
      Endif 
      
    Case 1
      D1.Foreground = Color.Black
      D1.Text = sQuestion
      If IsInteger(Replace(Z1.Text, "+", "")) Then 
        iZahl = CInteger(Z1.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D1.Text = Format(hDate, "yyyy-mm-dd")
        W1.Text = Format(hDate, "ddd")
        If D1.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D1.Background = iCol
        W1.Background = iCol
      Endif 
      
    Case 2
      D2.Foreground = Color.Black
      D2.Text = sQuestion
      If IsInteger(Replace(Z2.Text, "+", "")) Then  
        iZahl = CInteger(Z2.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D2.Text = Format(hDate, "yyyy-mm-dd")
        W2.Text = Format(hDate, "ddd")
        If D2.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D2.Background = iCol
        W2.Background = iCol
      Endif 
      
    Case 3
      D3.Foreground = Color.Black
      D3.Text = sQuestion
      If IsInteger(Replace(Z3.Text, "+", "")) Then  
        iZahl = CInteger(Z3.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D3.Text = Format(hDate, "yyyy-mm-dd")
        W3.Text = Format(hDate, "ddd")
        If D3.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D3.Background = iCol
        W3.Background = iCol
      Endif 
      
    Case 4
      D4.Foreground = Color.Gray
      D4.Text = sQuestion
      If IsInteger(Replace(Z4.Text, "+", "")) Then  
        iZahl = CInteger(Z4.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D4.Text = Format(hDate, "yyyy-mm-dd")
        W4.Text = Format(hDate, "ddd")
        ' If D4.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        ' D4.Background = iCol
        ' W4.Background = iCol  
      Endif 
      
    Case 5
      D5.Foreground = Color.Gray
      D5.Text = sQuestion
      If IsInteger(Replace(Z5.Text, "+", "")) Then 
        iZahl = CInteger(Z5.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D5.Text = Format(hDate, "yyyy-mm-dd")
        W5.Text = Format(hDate, "ddd")
        ' If D5.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        ' D5.Background = iCol
        ' W5.Background = iCol 
      Endif 
      
    Case 6
      D6.Foreground = Color.Black
      D6.Text = sQuestion
      If IsInteger(Replace(Z6.Text, "+", "")) Then  
        iZahl = CInteger(Z6.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D6.Text = Format(hDate, "yyyy-mm-dd")
        W6.Text = Format(hDate, "ddd")
        If D6.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D6.Background = iCol
        W6.Background = iCol
      Endif 
      
    Case 7
      D7.Foreground = Color.Black
      D7.Text = sQuestion
      If IsInteger(Replace(Z7.Text, "+", "")) Then 
        iZahl = CInteger(Z7.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D7.Text = Format(hDate, "yyyy-mm-dd")
        W7.Text = Format(hDate, "ddd")
        If D7.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D7.Background = iCol
        W7.Background = iCol
      Endif 
      
    Case 8
      D8.Foreground = Color.Black
      D8.Text = sQuestion
      If IsInteger(Replace(Z8.Text, "+", "")) Then 
        iZahl = CInteger(Z8.Text)
        hDate = DateAdd(F_dateOstern, gb.day, iZahl)
        D8.Text = Format(hDate, "yyyy-mm-dd")
        W8.Text = Format(hDate, "ddd")
        If D8.Text = sQuestion Then iCol = Color.Background Else iCol = Color.Default 
        D8.Background = iCol
        W8.Background = iCol
      Endif
      
      '..................................................................... 
    Case 9 'Weihnachten yyyy-12-25
      sDatum = Replace(D9.Text, Space(1), "")
      sDatum = Replace(sDatum, "yyyy-mm-dd", "")
      ' D9.Foreground = Color.Black
      ' W9.Background = F_iColorChangeBG 'ist (noch) kein Kalender-Datum
      W9.Text = sQuestion
      If sDatum Like "????-??-??" Then
        sDatum = Year(F_dateOstern) & String.Right(sDatum, 6)
        hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
        If IsDate(Str(hDate)) = True Then
          Z9.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
          D9.Text = Format(hDate, "yyyy-mm-dd")
          ' D9.Background = F_iColorGreenBG
          W9.Text = Format(hDate, "ddd")
          ' W9.Background = Color.Green 'ist ein Kalender-Datum
        Endif
      Else
        Z9.Text = sEmpty
        ' D9.Foreground = iColG
        W9.Background = iColG 'ist nicht im Datum-Format
      Endif
      
    Case 10
      sDatum = Replace(D10.Text, Space(1), "")
      sDatum = Replace(sDatum, "yyyy-mm-dd", "")
      D10.Foreground = Color.Black
      W10.Background = F_iColorChangeBG 'ist (noch) kein Kalender-Datum
      W10.Text = sQuestion
      If sDatum Like "????-??-??" Then
        sDatum = Year(F_dateOstern) & String.Right(sDatum, 6)
        hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
        If IsDate(Str(hDate)) = True Then
          Z10.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
          D10.Text = Format(hDate, "yyyy-mm-dd")
          ' D10.Background = F_iColorGreenBG
          W10.Text = Format(hDate, "ddd")
          W10.Background = Color.Green 'ist ein Kalender-Datum
        Endif
      Else
        Z10.Text = sEmpty
        ' D10.Foreground = iColG
        W10.Background = iColG 'ist nicht im Datum-Format
      Endif
      
    Case 11
      sDatum = Replace(D11.Text, Space(1), "")
      sDatum = Replace(sDatum, "yyyy-mm-dd", "")
      D11.Foreground = Color.Black
      W11.Background = F_iColorChangeBG 'ist (noch) kein Kalender-Datum
      W11.Text = sQuestion
      If sDatum Like "????-??-??" Then
        sDatum = Year(F_dateOstern) & String.Right(sDatum, 6)
        hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
        If IsDate(Str(hDate)) = True Then
          Z11.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
          D11.Text = Format(hDate, "yyyy-mm-dd")
          ' D11.Background = F_iColorGreenBG
          W11.Text = Format(hDate, "ddd")
          W11.Background = Color.Green 'ist ein Kalender-Datum
        Endif
      Else
        Z11.Text = sEmpty
        ' D11.Foreground = iColG
        W11.Background = iColG 'ist nicht im Datum-Format
      Endif
      
    Case 12
      sDatum = Replace(D12.Text, Space(1), "")
      sDatum = Replace(sDatum, "yyyy-mm-dd", "")
      D12.Foreground = Color.Black
      W12.Background = F_iColorChangeBG 'ist (noch) kein Kalender-Datum
      W12.Text = sQuestion
      If sDatum Like "????-??-??" Then
        sDatum = Year(F_dateOstern) & String.Right(sDatum, 6)
        hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
        If IsDate(Str(hDate)) = True Then
          Z12.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
          D12.Text = Format(hDate, "yyyy-mm-dd")
          ' D12.Background = F_iColorGreenBG
          W12.Text = Format(hDate, "ddd")
          W12.Background = Color.Green 'ist ein Kalender-Datum
        Endif
      Else
        Z12.Text = sEmpty
        ' D12.Foreground = iColG
        W12.Background = iColG 'ist nicht im Datum-Format
      Endif
      
    Case 13
      sDatum = Replace(D13.Text, Space(1), "")
      sDatum = Replace(sDatum, "yyyy-mm-dd", "")
      D13.Foreground = Color.Black
      W13.Background = F_iColorChangeBG 'ist (noch) kein Kalender-Datum
      W13.Text = sQuestion
      If sDatum Like "????-??-??" Then
        sDatum = Year(F_dateOstern) & String.Right(sDatum, 6)
        hDate = M01Functions.DateCheckyyyymmddhhnn(sDatum, "00:00") 'as Date
        If IsDate(Str(hDate)) = True Then
          Z13.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
          D13.Text = Format(hDate, "yyyy-mm-dd")
          ' D13.Background = F_iColorGreenBG
          W13.Text = Format(hDate, "ddd")
          W13.Background = Color.Green 'ist ein Kalender-Datum
        Endif
      Else
        Z13.Text = sEmpty
        ' D13.Foreground = iColG
        W13.Background = iColG 'ist nicht im Datum-Format
      Endif
      
    Case Else
      '...Leerlauf
  End Select
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  F_bChangeON = True 
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Function OpenG() As String 
  
  Dim sPath, sText, sLastTime, sMessage As String
  Dim bOpen As Boolean = False  
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sPath = FilePathForm()
  
  If Exist(sPath) = True Then 
    ' Try sLastTime = sPath & gb.NewLine & Format(Stat(sPath).LastModified, "yyyy-mm-dd dddhh:nn:ss") 'as String
    sLastTime = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & Space(1) & M01Functions.FileSizeLongText(Stat(sPath).Size) & "</b></font>" & "<br>"
    Try sText = File.Load(sPath)
    ' If Not sText Then sText = ("leer")
  Endif 
  If sText Then 
    sMessage = sPath & "<br>"
    sMessage &= sLastTime & "<br><br>"
    sMessage &= "<font color=gray>" & sText & "</font><br>" 
    Select Case Message.Question(sMessage, ("Öffnen"), ("Ordner..."), ("Abbrechen"))
      Case 1
        bOpen = True 
      Case 2 ''Directory:
        bOpen = False  
        If Exist(sPath) = False Then sPath = File.Dir(sPath)
        M01Functions.FileManagerOpen(sPath)
      Case 3 '... Cancel´
        bOpen = False  
    End Select
  Else 
    sMessage = sPath & "<br>"
    sMessage &= "<font color=red>" & ("Nicht gefunden") & "</font>" & "<br>"
    sMessage &= "<h3><font color=darkgreen>" & ("Datei erstellen mit") & Space(1) & "<b>" & ButtonSave.Tooltip & "</b></font></h3>" 
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1
        If Exist(sPath) = False Then sPath = File.Dir(sPath)
        M01Functions.FileManagerOpen(sPath)
      Case 2
        ''...
     End Select
    bOpen = False 
  Endif
  If bOpen = True Then 
    ReadG(sText)
    DateCheckAll()
    BackgroundsRefresh()
    TextChanged(True) 
  Endif 
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG(Optional sText As String = "")
  
  Dim ssLines, ssFSpli As String[]
  Dim sFound As String 
  Dim it, iFound As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ssLines = Split(sText & hReturn, hReturn) 'as String[]
  
  For it = 0 To ssLines.Max
    iFound = ssLines.Find("*" & "HolidaysPlus" & Format(it, "00") & "*", gb.Like) 
    If iFound > -1 Then 
      sFound = ssLines[iFound]
      sFound = Replace(sFound, "HolidaysPlus" & Format(it, "00") & hTab, "")
      ssFSpli = Split(sFound & hTab & hTab & hTab, hTab) 'as String[]
      If it = 0 Then 'Easter (Ostern)
        Z0.Text = ssFSpli[0] 
        D0.Text = ssFSpli[1] 
        W0.Text = ssFSpli[2] 
        ' T0.Text = ssFSpli[3] 
      Endif  
      If it = 1 Then 
        Z1.Text = ssFSpli[0] 
        D1.Text = ssFSpli[1] 
        W1.Text = ssFSpli[2] 
        T1.Text = ssFSpli[3] 
      Endif  
      If it = 2 Then 
        Z2.Text = ssFSpli[0] 
        D2.Text = ssFSpli[1] 
        W2.Text = ssFSpli[2] 
        T2.Text = ssFSpli[3] 
      Endif  
      If it = 3 Then 
        Z3.Text = ssFSpli[0] 
        D3.Text = ssFSpli[1] 
        W3.Text = ssFSpli[2] 
        T3.Text = ssFSpli[3] 
      Endif  
      If it = 4 Then 
        Z4.Text = ssFSpli[0] 
        D4.Text = ssFSpli[1] 
        W4.Text = ssFSpli[2] 
        T4.Text = ssFSpli[3] 
      Endif  
      If it = 5 Then 
        Z5.Text = ssFSpli[0] 
        D5.Text = ssFSpli[1] 
        W5.Text = ssFSpli[2] 
        T5.Text = ssFSpli[3] 
      Endif  
      If it = 6 Then 
        Z6.Text = ssFSpli[0] 
        D6.Text = ssFSpli[1] 
        W6.Text = ssFSpli[2] 
        T6.Text = ssFSpli[3] 
      Endif  
      If it = 7 Then 
        Z7.Text = ssFSpli[0] 
        D7.Text = ssFSpli[1] 
        W7.Text = ssFSpli[2] 
        T7.Text = ssFSpli[3] 
      Endif  
      If it = 8 Then 
        Z8.Text = ssFSpli[0] 
        D8.Text = ssFSpli[1] 
        W8.Text = ssFSpli[2] 
        T8.Text = ssFSpli[3] 
      Endif  
      If it = 9 Then 'Christmas (Weihnachten)
        Z9.Text = ssFSpli[0] 
        D9.Text = ssFSpli[1] 
        W9.Text = ssFSpli[2] 
        ' T9.Text = ssFSpli[3] 
      Endif  
      If it = 10 Then 
        Z10.Text = ssFSpli[0] 
        D10.Text = ssFSpli[1] 
        W10.Text = ssFSpli[2] 
        T10.Text = ssFSpli[3] 
      Endif  
      If it = 11 Then 
        Z11.Text = ssFSpli[0] 
        D11.Text = ssFSpli[1] 
        W11.Text = ssFSpli[2] 
        T11.Text = ssFSpli[3] 
      Endif  
      If it = 12 Then 
        Z12.Text = ssFSpli[0] 
        D12.Text = ssFSpli[1] 
        W12.Text = ssFSpli[2] 
        T12.Text = ssFSpli[3] 
      Endif  
      If it = 13 Then 
        Z13.Text = ssFSpli[0] 
        D13.Text = ssFSpli[1] 
        W13.Text = ssFSpli[2] 
        T13.Text = ssFSpli[3] 
        Break
      Endif  
    Endif 
  Next 
  
Catch 
  FMain.ErrorText
  
End

Public Function FormTextAllCurrent() As String 
  
  Dim sAll As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sAll &= Z0.Text & hTab & D0.Text & hTab & W0.Text & hTab & T0.Text & hReturn  ' Ostern ' Ostern
  sAll &= Z1.Text & hTab & D1.Text & hTab & W1.Text & hTab & T1.Text & hReturn
  sAll &= Z2.Text & hTab & D2.Text & hTab & W2.Text & hTab & T2.Text & hReturn
  sAll &= Z3.Text & hTab & D3.Text & hTab & W3.Text & hTab & T3.Text & hReturn
  sAll &= Z4.Text & hTab & D4.Text & hTab & W4.Text & hTab & T4.Text & hReturn
  sAll &= Z5.Text & hTab & D5.Text & hTab & W5.Text & hTab & T5.Text & hReturn
  sAll &= Z6.Text & hTab & D6.Text & hTab & W6.Text & hTab & T6.Text & hReturn
  sAll &= Z7.Text & hTab & D7.Text & hTab & W7.Text & hTab & T7.Text & hReturn
  sAll &= Z8.Text & hTab & D8.Text & hTab & W8.Text & hTab & T8.Text & hReturn
  sAll &= Z9.Text & hTab & D9.Text & hTab & W9.Text & hTab & T9.Text & hReturn
  sAll &= Z10.Text & hTab & D10.Text & hTab & W10.Text & hTab & T10.Text & hReturn
  sAll &= Z11.Text & hTab & D11.Text & hTab & W11.Text & hTab & T11.Text & hReturn
  sAll &= Z12.Text & hTab & D12.Text & hTab & W12.Text & hTab & T12.Text & hReturn
  sAll &= Z13.Text & hTab & D13.Text & hTab & W13.Text & hTab & T13.Text & hReturn
  
  Return sAll
  
Catch 
  FMain.ErrorText
  
End

Public Sub NumberGroup_KeyPress() 'alternative: ValueBox
  
  ' Last.Background = F_iColorChangeBG
  If M01Functions.KeyPressCheck("0123456789-+", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub NumberGroup_Change()
  
  Dim i As Integer
  
  If F_bChangeON = True Then  
    i = CInt(Last.Tag)
    Try DateCheck(i)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub NumberGroup_MouseDown()
  
  If Object.Type(Last) = "TextBox" Then Last.Background = Color.White
  
End

Public Sub DateGroup_KeyPress() 
  
  ' Last.Background = F_iColorChangeBG
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateGroup_Change()
  
  If F_bChangeON = True Then
    If Last.Text Like "????-??-??" And Last.Tag Then F_oObject = Last Else F_oObject = Null
    TextChanged(True) 
    If IsInteger(Str(Last.Tag)) = True Then DateLabelNumber(CInteger(Str(Last.Tag)))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateLabelNumber(Optional iTagNr As Integer = 0)
  
  Dim iDays As Integer
  Dim dateDatum As Date
  
  If F_dateOstern Then '-00
    Select Case iTagNr
      Case 10
        dateDatum = M01Functions.DateCheckyyyymmddhhnn(D10.Text, "00:00") 'as Date
        iDays = DateDiff(F_dateOstern, dateDatum, gb.Day)
        Z10.Text = Str(iDays)
      Case 11
        dateDatum = M01Functions.DateCheckyyyymmddhhnn(D11.Text, "00:00") 'as Date
        iDays = DateDiff(F_dateOstern, dateDatum, gb.Day)
        Z11.Text = Str(iDays)
      Case 12
        dateDatum = M01Functions.DateCheckyyyymmddhhnn(D12.Text, "00:00") 'as Date
        iDays = DateDiff(F_dateOstern, dateDatum, gb.Day)
        Z12.Text = Str(iDays) 
      Case 13
        dateDatum = M01Functions.DateCheckyyyymmddhhnn(D13.Text, "00:00") 'as Date
        iDays = DateDiff(F_dateOstern, dateDatum, gb.Day)
        Z13.Text = Str(iDays)
    End Select 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateGroup_MouseDown()
  
  Dim hDate As Date
  Dim iZahl As Integer
  
  If Object.Type(Last) = "TextBox" Then Last.Background = Color.White
  If IsInteger(Last.Tag) = True Then iZahl = CInteger(Last.Tag)
  If iZahl > 9 And iZahl < 14 Then  
    PanelDate.Visible = Not PanelDate.Visible 
    PanelDate.Raise
    DateChooser1.Tag = Last.Tag
    If Last.Text Like "*????-??-??*" Then 
      hDate = M01Functions.DateCheckyyyymmddhhnn(Last.Text, "00:00") 'as Date
      DateChooser1.Value = hDate
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekdayGroup_MouseDown()
  
  Dim i As Integer
  
  If IsInteger(Last.Tag) = True Then 
    i = CInteger(Last.Tag)
    Try DateCheck(i)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekdayGroup_Enter()
  
  Last.Border = Border.Plain 
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekdayGroup_Leave()
  
  Last.Border = Border.None 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextGroup_KeyPress()
  
  ' Last.Background = F_iColorChangeBG
  If Key.Code = Key.Return Then Stop Event 'Vorgang abbrechen
  TextChanged(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextGroup_Change()
  
  If F_bChangeON = True Then  
    Last.Background = Color.White
    TextChanged(True)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextGroup_MouseDown()
  
  If Object.Type(Last) = "TextArea" Then Last.Background = Color.White
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextChanged(Optional bChanged As Boolean = False)
  
  Select Case bChanged
    Case True
      ButtonSave.Background = Color.SelectedBackground
      F_bListChanged = True 
    Case False 
      ButtonSave.Background = Color.Default
      F_bListChanged = False 
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Change()
  
  Select Case DateChooser1.Tag 
    Case 10
      D10.Text = Format(DateChooser1.Value, "yyyy-mm-dd")
    Case 11
      D11.Text = Format(DateChooser1.Value, "yyyy-mm-dd")
    Case 12
      D12.Text = Format(DateChooser1.Value, "yyyy-mm-dd")
    Case 13
      D13.Text = Format(DateChooser1.Value, "yyyy-mm-dd")
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form8ZusFeiertage.Left]
      iY = Settings[F_sForm &/ "Top", Form8ZusFeiertage.Top]
      iW = Settings[F_sForm &/ "Width", Form8ZusFeiertage.W]
      iH = Settings[F_sForm &/ "Height", Form8ZusFeiertage.H]
      Form8ZusFeiertage.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form8ZusFeiertage.Left
      Settings[F_sForm &/ "Top"] = Form8ZusFeiertage.Top
      Settings[F_sForm &/ "Width"] = Form8ZusFeiertage.Width
      Settings[F_sForm &/ "Height"] = Form8ZusFeiertage.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ValueBoxYear_Change()
  
  If F_bChangeON = True Then 
    If String.Len(ValueBoxYear.Text) = 4 Then 
      ValueBoxYear.Background = Color.Default 
      F_dateOstern = OsterSonntagDate() ' greater > 1583
      DateCheckAll()
    Else 
      ValueBoxYear.Background = F_iColorRed200
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateCheckAll()
  
  Dim it As Integer
  
  For it = 0 To 13
    DateCheck(it)
  Next 
  
  If PanelList.Visible = True Then ListG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim hDate As Date
  Dim sF, sEmpty As String 
  Dim ssFSpli As New String[]
  Dim iColR, iColD, iColS, iColG, iColL, iColT As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  iColR = Color.Red
  iColD = Color.Default
  iColS = Color.SelectedForeground
  iColG = Color.Gray
  iColL = Color.LightGray
  iColT = Color.Transparent
  F_bChangeON = False 
  sEmpty = ""
  'Tage vor/nach OsterSonntagDate:
  'Ostern ist am ersten Sonntag nach dem ersten Vollmond des Fruehlingsanfangs (21.03).
  '1. Weihnachtstag = 25.12
  'Pfingstsonntag = + 49
  'Rosenmontag = -48 
  ' F_dateOstern = Date.EasterDay(Year(Date)) 'Date.EasterDay needs component: gb.util
  
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus00", Null] ''Eastern (Ostern)
  sF = Replace(sF, "HolidaysPlus00" & hTab, "")    
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    F_dateOstern = M01Functions.DateCheckyyyymmddhhnn(ssFSpli[1], "00:00") 'as Date
    ValueBoxYear.Value = Year(F_dateOstern)
    Z0.Text = "0"
    D0.Text = Format(F_dateOstern, "yyyy-mm-dd")
    W0.Text = Format(F_dateOstern, "ddd")
    T0.Text = ("Ostersonntag")
  Else 
    ValueBoxYear.Value = Year(Date)
    F_dateOstern = OsterSonntagDate(Year(Date))
    Z0.Text = "0"
    D0.Text = Format(F_dateOstern, "yyyy-mm-dd") 
    W0.Text = Format(F_dateOstern, "ddd")
    T0.Text = ("Ostersonntag")
  Endif  
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus01", Null] 
  sF = Replace(sF, "HolidaysPlus01" & hTab, "")    
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    Z1.Text = ssFSpli[0] 
    D1.Text = ssFSpli[1] 
    W1.Text = ssFSpli[2] 
    T1.Text = ssFSpli[3] 'Better Textbox > Undo-Redo without Color change, TextArea with Color change
  Else 
    Z1.Text = sEmpty
    D1.Text = sEmpty 
    W1.Text = sEmpty
    T1.Text = sEmpty
  Endif 
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus02", Null] 
  sF = Replace(sF, "HolidaysPlus02" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    Z2.Text = ssFSpli[0] 
    D2.Text = ssFSpli[1] 
    W2.Text = ssFSpli[2] 
    T2.Text = ssFSpli[3] 
  Else 
    Z2.Text = sEmpty
    D2.Text = sEmpty 
    W2.Text = sEmpty
    T2.Text = sEmpty
  Endif   
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus03", Null] 
  sF = Replace(sF, "HolidaysPlus03" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    Z3.Text = ssFSpli[0] 
    D3.Text = ssFSpli[1] 
    W3.Text = ssFSpli[2] 
    T3.Text = ssFSpli[3]
  Else 
    Z3.Text = sEmpty
    D3.Text = sEmpty 
    W3.Text = sEmpty
    T3.Text = sEmpty
  Endif   
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus04", Null] 
  sF = Replace(sF, "HolidaysPlus04" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    Z4.Text = "-48" 
    D4.Text = ssFSpli[1] 
    W4.Text = ssFSpli[2] 
    T4.Text = ("Rosenmontag")
  Else 
    Z4.Text = "-48" 
    D4.Text = sEmpty 
    W4.Text = sEmpty
    T4.Text = ("Rosenmontag")
  Endif  
  '..........................................
  'Z0 Ostern
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus05", Null] 
  sF = Replace(sF, "HolidaysPlus05" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    Z5.Text = "49"
    D5.Text = ssFSpli[1] 
    W5.Text = ssFSpli[2] 
    T5.Text = ("Pfingstsonntag")
  Else 
    Z5.Text = sEmpty
    D5.Text = sEmpty 
    W5.Text = sEmpty
    T5.Text = ("Pfingstsonntag")
  Endif    
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus06", Null] 
  sF = Replace(sF, "HolidaysPlus06" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    Z6.Text = ssFSpli[0] 
    D6.Text = ssFSpli[1] 
    W6.Text = ssFSpli[2] 
    T6.Text = ssFSpli[3] 
  Else 
    Z6.Text = sEmpty
    D6.Text = sEmpty 
    W6.Text = sEmpty
    T6.Text = sEmpty
  Endif    
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus07", Null] 
  sF = Replace(sF, "HolidaysPlus07" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    Z7.Text = ssFSpli[0] 
    D7.Text = ssFSpli[1] 
    W7.Text = ssFSpli[2] 
    T7.Text = ssFSpli[3] 
  Else 
    Z7.Text = sEmpty
    D7.Text = sEmpty 
    W7.Text = sEmpty
    T7.Text = sEmpty
  Endif    
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus08", Null] 
  sF = Replace(sF, "HolidaysPlus08" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then 
    Z8.Text = ssFSpli[0] 
    D8.Text = ssFSpli[1] 
    W8.Text = ssFSpli[2] 
    T8.Text = ssFSpli[3] 
  Else 
    Z8.Text = sEmpty
    D8.Text = sEmpty 
    W8.Text = sEmpty
    T8.Text = sEmpty
  Endif    
  '..........................................
  ' sF = Settings[FMain.Name &/ "HolidaysPlus09", Null] 'Christmas  (Weihnachten)
  hDate = Date(Year(F_dateOstern), 12, 25) 'Fix
  Z9.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
  D9.Text = Format(hDate, "yyyy-mm-dd")
  W9.Text = Format(hDate, "ddd")
  T9.Text = ("Weihnachten")
  '------------------------------------------
  sF = Settings[FMain.Name &/ "HolidaysPlus10", Null] 
  sF = Replace(sF, "HolidaysPlus10" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then
    ssFSpli[1] = Str(Year(F_dateOstern)) & String.Right(ssFSpli[1], 6)
    hDate = M01Functions.DateCheckyyyymmddhhnn(ssFSpli[1], "00:00") 'as Date
    Z10.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
    D10.Text = Format(hDate, "yyyy-mm-dd")
    W10.Text = Format(hDate, "ddd")
    T10.Text = ssFSpli[3]
  Else 
    Z10.Text = sEmpty
    D10.Text = sEmpty 
    W10.Text = sEmpty
    T10.Text = sEmpty
  Endif    
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus11", Null] 
  sF = Replace(sF, "HolidaysPlus11" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    ssFSpli[1] = Str(Year(F_dateOstern)) & String.Right(ssFSpli[1], 6)
    hDate = M01Functions.DateCheckyyyymmddhhnn(ssFSpli[1], "00:00") 'as Date
    Z11.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
    D11.Text = Format(hDate, "yyyy-mm-dd")
    D11.Foreground = iColD
    W11.Text = Format(hDate, "ddd")
    T11.Text = ssFSpli[3]
  Else 
    Z11.Text = sEmpty
    D11.Text = sEmpty 
    W11.Text = sEmpty
    T11.Text = sEmpty
  Endif      
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus12", Null] 
  sF = Replace(sF, "HolidaysPlus12" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    ssFSpli[1] = Str(Year(F_dateOstern)) & String.Right(ssFSpli[1], 6)
    hDate = M01Functions.DateCheckyyyymmddhhnn(ssFSpli[1], "00:00") 'as Date
    Z12.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
    D12.Text = Format(hDate, "yyyy-mm-dd")
    D12.Foreground = iColD
    W12.Text = Format(hDate, "ddd")
    T12.Text = ssFSpli[3]
  Else 
    Z12.Text = sEmpty
    D12.Text = sEmpty 
    W12.Text = sEmpty
    T12.Text = sEmpty
  Endif      
  '..........................................
  sF = Settings[FMain.Name &/ "HolidaysPlus13", Null] 
  sF = Replace(sF, "HolidaysPlus13" & hTab, "")
  ssFSpli = Split(sF & String(4, hTab), hTab)
  If String.Len(ssFSpli[3]) > 0 Then  
    ssFSpli[1] = Str(Year(F_dateOstern)) & String.Right(ssFSpli[1], 6)
    hDate = M01Functions.DateCheckyyyymmddhhnn(ssFSpli[1], "00:00") 'as Date
    Z13.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
    D13.Text = Format(hDate, "yyyy-mm-dd")
    D13.Foreground = iColD
    W13.Text = Format(hDate, "ddd")
    T13.Text = ssFSpli[3]
  Else 
    Z13.Text = sEmpty
    D13.Text = sEmpty 
    W13.Text = sEmpty
    T13.Text = sEmpty
  Endif      
  '..........................................
  
  ButtonSave.Background = Color.ButtonBackground
  TextChanged(False)  
  F_bChangeON = True
  DateCheckAll()
  BackgroundsRefresh()
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  
Catch ' "2012", "2018", "2021"
  FMain.ErrorText
  
End

Public Sub NewG()
  
  Dim hDate As Date
  Dim sEmpty As String 
  Dim iColR, iColD, iColS, iColG, iColL, iColT As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  iColR = Color.Red
  iColD = Color.Default
  iColS = Color.SelectedForeground
  iColG = Color.Gray
  iColL = Color.LightGray
  iColT = Color.Transparent
  
  F_bChangeON = False 
  
  F_dateOstern = OsterSonntagDate(Year(Date))
  ValueBoxYear.Value = Year(F_dateOstern)
  sEmpty = ""
  '.......................................... Easter (Ostern)
  
  Z0.Text = "0"
  D0.Text = Format(F_dateOstern, "yyyy-mm-dd")
  W0.Text = Format(F_dateOstern, "ddd")
  T0.Text = ("Ostersonntag")
  '..........................................
  
  Z1.Text = sEmpty
  D1.Text = sEmpty
  W1.Text = sEmpty
  T1.Text = sEmpty 
  '..........................................
  
  Z2.Text = sEmpty
  D2.Text = sEmpty
  W2.Text = sEmpty
  T2.Text = sEmpty 
  '..........................................
  
  Z3.Text = sEmpty
  D3.Text = sEmpty
  W3.Text = sEmpty
  T3.Text = sEmpty
  '..........................................
  
  Z4.Text = "-48" 
  D4.Text = sEmpty
  W4.Text = sEmpty
  T4.Text = ("Rosenmontag")
  '..........................................
  'Z0 Ostern
  '..........................................
  
  Z5.Text = "49"
  D5.Text = sEmpty
  W5.Text = sEmpty
  T5.Text = ("Pfingstsonntag")
  '..........................................
  
  Z6.Text = sEmpty
  D6.Text = sEmpty
  W6.Text = sEmpty
  T6.Text = sEmpty 
  '..........................................
  
  Z7.Text = sEmpty
  D7.Text = sEmpty
  W7.Text = sEmpty
  T7.Text = sEmpty 
  '..........................................
  
  Z8.Text = sEmpty
  D8.Text = sEmpty
  W8.Text = sEmpty
  T8.Text = sEmpty 
  '..........................................'Christmas  (Weihnachten)
  
  hDate = Date(Year(F_dateOstern), 12, 25)
  Z9.Text = DateDiff(F_dateOstern, hDate, gb.Day) 'as Integer
  D9.Text = Format(hDate, "yyyy-mm-dd")
  W9.Text = Format(hDate, "ddd")
  T9.Text = ("Weihnachten")
  '------------------------------------------
  
  Z10.Text = sEmpty
  D10.Text = sEmpty
  W10.Text = sEmpty
  T10.Text = sEmpty 
  '..........................................
  
  Z11.Text = sEmpty
  D11.Text = sEmpty
  W11.Text = sEmpty
  T11.Text = sEmpty 
  '..........................................
  
  Z12.Text = sEmpty
  D12.Text = sEmpty
  W12.Text = sEmpty
  T12.Text = sEmpty 
  '..........................................
  
  Z13.Text = sEmpty
  D13.Text = sEmpty
  W13.Text = sEmpty
  T13.Text = sEmpty 
  '..........................................
  
  ButtonSave.Background = Color.Red
  TextChanged(True)  
  F_bChangeON = True
  DateCheckAll()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form8ZusFeiertage.Window.Maximized = Not Form8ZusFeiertage.Window.Maximized 
  If Form8ZusFeiertage.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form8ZusFeiertage.Window.FullScreen = True Or Form8ZusFeiertage.Window.Maximized = True Then 
      F_bMovingON = False
      Form8ZusFeiertage.Window.FullScreen = False
      Form8ZusFeiertage.Window.Maximized = False
      If Form8ZusFeiertage.Left + Form8ZusFeiertage.W > Screen.AvailableWidth Then Form8ZusFeiertage.Move(Form8ZusFeiertage.Left, Form8ZusFeiertage.Top, Screen.AvailableWidth - Form8ZusFeiertage.Left, Screen.AvailableHeight - Form8ZusFeiertage.Top)
    Else
      F_bMovingON = True
      Form8ZusFeiertage.Window.FullScreen = False
      Form8ZusFeiertage.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form8ZusFeiertage.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form8ZusFeiertage.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form8ZusFeiertage.ClientW - WindowStretch.W, Form8ZusFeiertage.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form8ZusFeiertage.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form8ZusFeiertage.W = Mouse.ScreenX - F_iX1
    Form8ZusFeiertage.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form8ZusFeiertage.ClientW - WindowStretch.W, Form8ZusFeiertage.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form8ZusFeiertage.ClientW - WindowStretch.W, Form8ZusFeiertage.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form8ZusFeiertage.Window.Maximized = Not Form8ZusFeiertage.Window.Maximized 
    If Form8ZusFeiertage.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form8ZusFeiertage.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Last.Background = Color.Green
  If Object.Type(Last) = "Button" Then Last.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  Last.Background = Color.Default
  If Object.Type(Last) = "Button" Then Last.Border = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  F_bESCpressedON = False
  
  Select Case String.LCase(sLastTag) 
    Case "list"
      PanelList.Visible = Not PanelList.Visible
      ButtonList.Border = PanelList.Visible 'True or False
      If PanelList.Visible = True Then ListG()
    Case "backup"
      OpenG()
    Case "save"
      SaveG()
    Case "plusyear"
      ValueBoxYear.Value = ValueBoxYear.Value + 1
    Case "minusyear"
      ValueBoxYear.Value = ValueBoxYear.Value - 1
    Case "refresh"
      DateCheckAll()
    Case "new"
      ValueBoxYear.Value = Year(Date)
      NewG() 'neu anfangen
      BackgroundsRefresh()
    Case "tip", "tipp"
      TipG()
    Case "date"
      PanelDate.Visible = False 
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      Form8ZusFeiertage.Window.Close
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "cancel"
      Form8ZusFeiertage.Window.Close
  End Select
  
Catch 
  FMain.ErrorText
  
End 

Public Sub Form_Close()
  
  Dim sMessage As String 
  
  If F_bListChanged = True Then
    sMessage = "<h3><font color=red><b>" & ("Veränderungen") & "</b></font></h3>"
    sMessage &= "<font color=gray>" & FilePathForm() & "</font>"
    
    Select Case Message.Question(sMessage, ("Speichern..."), ("Nein"), ("Abbrechen"))
      Case 1 'Save (Speichern)
        SaveG()
      Case 2 'Close (Beenden ohne Speichern)
        '... Leerlauf
      Case 3 'Cancel (Abbrechen)
        Stop Event  ' Vorgang abbrechen, zurück zur Form
    End Select
  Endif
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  
End '................................................



Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form1FileOpen.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form1FileOpen.class
107 KB
' Gambas class file

Public F_bBookmarkChanged As Boolean
Public F_bChangeON As Boolean
Public F_bESCpressedON As Boolean
Public F_bMovingON As Boolean
Public F_iCheckPathON As Integer
Public F_iColorSelectBackground As Integer = Color.Lighter(Color.LightBackground)
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer
Public F_iFilterIndex As Integer
Public F_iMoveLineMaxH As Integer
Public F_iMoveLineMinH As Integer
Public F_iMoveLineTop As Integer
Public F_iOnly1x As Integer
Public F_iPanelH As Integer = 40 'Pixel
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sDirBookmarkLast As String 
Public F_sForm As String = Me.Name 
Public F_sPath2Redo As String
Public F_sPath2Undo As String
Public F_sPathBookmarks As String 
Public F_ssKeysCopy As String[]          'ColumnView1.Selection.Max > -1  'internally, instead of Clipboard.Copy()

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Form1FileOpen.Tag 'Path from other Form
  If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt]
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub FindLatestFile()

  Dim sDirFile, sMessage As String 
  
  sDirfile = FindDirFile(User.Home, Application.Name & ".txt", 3) 'as String, with /media/
  
  If Exist(sDirfile) = False Then
    sMessage = "<h3><font color=blue>" & Application.Name & ".txt" & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Nicht gefunden") & "</font></h3>"
  Else 
    sMessage = "<h3><font color=gray>" & File.Dir(sDirfile) & "/" & "</font><font color=blue>" & File.Name(sDirfile) & "</font></h3>"
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirfile) & "</b></font>" & Space(1) & "<font color=darkgreen>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    sMessage &= "<h3><font color=darkgreen>" & ("Gefunden") & "</font></h3>"
  Endif 
  
  Select Case Message.Question(sMessage, ("Auswählen"), ("Ordner..."), ("Abbrechen"))
    Case 1
      FileChooser1.Dir = File.Dir(sDirfile)
      FileChooser1.FileView.UnselectAll()
      FileChooser1.FileView.Current = File.Name(sDirfile)
      If sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt] Then 
        F_iCheckPathON = 1
      Else 
        F_iCheckPathON = 2
        TextBoxPath2.SelectAll
        TextBoxPath2.Insert(sDirFile)
      Endif 
      CheckPathStandard1Alternative2(F_iCheckPathON)
    Case 2
      M01Functions.FileManagerOpen(sDirFile)
    Case 3
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function FindDirFile(Optional sStartDir As String = User.Home, Optional sSearchPattern As String = "*", iType_Dir1_File2_DirFile3 As Integer = 3) As String 
  
  Dim sDirFile, sDir, sLatest As String 
  Dim it, iLine, iDirFile As Integer
  Dim ssSpli As New String[]
  Dim bExact As Boolean 
  
  Select Case iType_Dir1_File2_DirFile3
    Case 1
      iDirFile = gb.Directory
    Case 2
      iDirFile = gb.File
    Case 3
      iDirFile = gb.Directory + gb.File
  End Select 
  
  If String.InStr(sSearchPattern, "*") = 0 Then bExact = True Else bExact = False 'with "*"
  
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = File.Dir(sDirFile)
  
  ''Extern Media, USB-Stick, ...?
  If Exist(sDirFile) = True Then 
    ProgressBarONoff(True) 
    'Search in Sub-Directories (Recursively, Rekursiv, RDir):
    ssSpli = RDir(sDir, "*" & sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
    For it = 0 To ssSpli.Max
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sDirFile = sDir &/ ssSpli[it]
      If bExact = True Then 
        If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
      Endif
      If Not sLatest And sDirFile Then 
        sLatest = sDirFile
      Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
        If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
      Endif
      ' sList &= sDirFile & gb.NewLine
    Next 
  Endif
  
  ssSpli = RDir(sStartDir, "*" & sSearchPattern & "*", iDirFile).Sort() ' Sort for .FindSorted(), faster than .Find()
  
  ''Start Directory:
  For it = 0 To ssSpli.Max
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sDirFile = sStartDir &/ ssSpli[it]
    If bExact = True Then 
      If File.Name(sDirFile) <> sSearchPattern Then sDirFile = Null
    Endif
    If Not sLatest And sDirFile Then 
      sLatest = sDirFile
    Else If Exist(sDirFile) = True And Exist(sLatest) = True Then 
      If Stat(sDirFile).LastModified > Stat(sLatest).LastModified Then sLatest = sDirFile 
    Endif
    ' sList &= sDirFile & gb.NewLine
  Next 
  ProgressBarONoff(False) 
  
  Return sLatest ' Null or /Dir or file.ext or /Dir/File.ext  
  
Catch
  FMain.ErrorText
  ProgressBarONoff(False) 
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End


Public Sub Form_Open()
  
  Menu1.Visible = False
  
  If Not Form1FileOpen.Window.Icon Then Form1FileOpen.Window.Icon = FMain.Window.Icon
  Form1FileOpen.Window.Title = Application.Name & " - " & ("Datei mit Terminen wählen...") & ("Typ") & ": " & "terminwecker.txt"
  'Form1FileOpen.Tag —▶ Path?
  
  MoveLine.Top = 0
  FormBackgroundColor()
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sPath, sPathB As String 
  
  Form1FileOpen.Tag = Null 'Reset (Path)
  sPath = FilePathForm() 'as String
  
  If F_iCheckPathON = 2 Then sPathB = TextBoxPath2.Text 'Alternative
  If F_iCheckPathON = 1 Then sPathB = TextBoxPath1.Text 'Standard
  
  SettingsReadSave("save")
  
  ''Check: save change?
  If Exist(sPath) = True And sPath <> sPathB Then
    ButtonApplyG()
    FMain.F_bNeueinlesenStarten = True
  Endif 
  
  ' Print FMain.F_sPathTerminweckerActual_txt
  ' Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt"] = FMain.F_sPathTerminweckerActual_txt
  ' 
  ' Print Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", "Fehlt"]
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case sReadSave
    Case "read", "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form1FileOpen.Left]
      iY = Settings[F_sForm &/ "Top", Form1FileOpen.Top]
      iW = Settings[F_sForm &/ "Width", Form1FileOpen.W]
      iH = Settings[F_sForm &/ "Height", Form1FileOpen.H]
      Form1FileOpen.Move(iX, iY, iW, iH)
      FileChooser1.Font.Size = Settings[F_sForm &/ "FileChooser1.Font.Size", FileChooser1.Font.Size] 
      ' Settings.Read(FileChooser1) '—▶Settings.Write(FileChooser1) in Form_Close() 
      F_iFilterIndex = Settings[F_sForm &/ "F_iFilterIndex", F_iFilterIndex] 
      
    Case "save", "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form1FileOpen.Left
      Settings[F_sForm &/ "Top"] = Form1FileOpen.Top
      Settings[F_sForm &/ "Width"] = Form1FileOpen.Width
      Settings[F_sForm &/ "Height"] = Form1FileOpen.Height
      Settings[F_sForm &/ "FileChooser1.Font.Size"] = FileChooser1.Font.Size 
      ' Settings.Write(FileChooser1) '—▶Settings.Read(...)
      Settings[F_sForm &/ "F_iFilterIndex"] = F_iFilterIndex
      
  End Select 
  
  ' SettingsBookmarksReadSave(sReadSave)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then 
    FormStart()
    F_iOnly1x = F_iOnly1x + 1
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Termine
  F_iColumnNr = 6                                  'Termine 6, in Projects 13
  F_iColumnUndo = 7                                'Termine 7, in Projects 10
  F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
  F_iColumnSort = 9                                'Termine 9, in Projects 12
  
  ''Column-Count 1,2,3...n
  F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
  F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
  
  ''Bookmarks:
  ' FMain.F_ccBookmarksStandards = M01Functions.BookmarksDefaultG()
    
  ''Standard: "/home/<BENUTZER>/terminwecker/terminwecker.txt"
  ' Try FileChooser1.Root = File.Dir(Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt])
  
  FileChooser1Filter()
  FileChooser1DirViewSelectedPath()
  ' FileChooser1SelectPath()
  AplusG()
  CheckBoxtxtG() 'behind Filter
  CheckONoff()
  WindowStretchCursor()
  PanelText5.Visible = False 
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  
  F_bChangeON = True 'Reset
  Timer1.Enabled = True '>TextBoxPath2.Text
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()
  '.Delay = 1000 '1 Sec.
  If Exist(TextBoxPath2.Text) = True Then 
    TextBoxPath2.Foreground = Color.DarkGreen
  Else
    TextBoxPath2.Foreground = Color.Red
  Endif 
  
  If String.InStr(FileChooser1.Dir, "/media") > 0 And IsDir(FileChooser1.Dir) = False Then
    ButtonDirAlternative2.Picture = PicTemplateUSBarrow.Picture
  Else If String.InStr(FileChooser1.Dir, "/media") > 0 And IsDir(FileChooser1.Dir) = True Then
    ButtonDirAlternative2.Picture = PicTemplateUSB.Picture
  Else 
    ButtonDirAlternative2.Picture = PicTemplateDirQuestion.Picture
  Endif
    
  Catch 
  FMain.ErrorText
End

Public Sub FileChooser1DirViewSelectedPath()

  Dim sPath, sMedia As String 
  
  sPath = FilePathForm()
  If InStr(String.LCase(sPath), "/media") > 0 Then FileChooser1.Dir = "/media"
  
  'File?
  If IsDir(sPath) = False Then 
    FileChooser1.Dir = File.Dir(sPath)
    FileChooser1.DirView.SetFocus()
    FileChooser1.FileView.Current = File.Name(sPath)
    FileChooser1.FileView.SetFocus()
  Else 'Dir?
    FileChooser1.Dir = sPath
    FileChooser1.DirView.SetFocus()
  Endif 
  
  ''Path Alternative:
  TextBoxPath2.SelectAll
  TextBoxPath2.Insert(Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt])
  If String.InStr(TextBoxPath2.Text, "/media") = 0 Then 
    sMedia = Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt", TextBoxPath2.Text] 
    If String.InStr(sMedia, "/media") > 0 Then 
      TextBoxPath2.SelectAll
      TextBoxPath2.Insert(sMedia) 
    Endif 
  Endif
  F_sPath2Undo = TextBoxPath2.Text
  
  ''Path Standard:
  TextBoxPath1.SelectAll
  TextBoxPath1.Insert(Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt])
  If sPath = TextBoxPath1.Text And Exist(sPath) = True Then F_iCheckPathON = 1 Else F_iCheckPathON = 2
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReloadPath2Alternative()
  
  ''Redo
  If TextBoxPath2.Text = F_sPath2Undo Then
    TextBoxPath2.SelectAll
    TextBoxPath2.Insert(F_sPath2Redo)
  Else ''Undo
    TextBoxPath2.SelectAll
    TextBoxPath2.Insert(F_sPath2Undo)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileChooser1Filter()
  
  Dim sPath As String
  Dim Filter0, FilterText0, Filter1, FilterText1, Filter2, FilterText2 As String
  Dim Filter3, FilterText3, Filter4, FilterText4, Filter5, FilterText5 As String
  
  ''0
  Filter0 = "*.*" 'all files
  FilterText0 = ("Alle Datei-Formate")
  
  ''1
  Filter1 = "*.txt"
  FilterText1 = ("Nur-Text")
  
  ''2
  sPath = FilePathForm()  'as String
  Filter2 = File.Name(sPath) 
  FilterText2 = File.Name(sPath) 
  
  ''3
  Filter3 = Application.Name & "*_oldyears.txt" & ";" & Application.Name & "*_vergangene.txt"
  FilterText3 = ("Ausgelagerte") & Space(1) & ("Dateien") & Space(1) & Application.Name & ".txt"
  
  ''4
  Filter4 = "*proje*.txt"
  FilterText4 = ("Projekte")
  
  ''5
  Filter5 = "proje*_oldyears.txt;proje*_vergangene.txt"
  FilterText5 = ("Ausgelagerte") & Space(1) & ("Projekte")
  
  ''-1 
  'all files, automatically
  
  FileChooser1.Filter = [Filter0, FilterText0, Filter1, FilterText1, Filter2, FilterText2, Filter3, FilterText3, Filter4, FilterText4, Filter5, FilterText5] 'autom. + All Files *.*
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsBookmarksReadSave(Optional sReadSave As String = "read") '???
  
  Dim sText, sLine, sPath, sDir, sFile As String
  Dim ssSpli As String[]
  Dim ssBookmark As String[]
  Dim cBookmark As Collection
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = File.Dir(sPath)
  sFile = Application.Name & "_bookmarks.txt"
  F_sPathBookmarks = Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt]
  If Exist(F_sPathBookmarks) = False Then F_sPathBookmarks = sDir &/ sFile
  
  Select Case sReadSave
      
    Case "read", "r"
      If Not FileChooser1.Bookmarks Then FileChooser1.Bookmarks = New Collection[]
      FileChooser1.Refresh()
      Wait 0.3
      
      'Read from File first:
      If Not sText Then 
        If Exist(F_sPathBookmarks) = True Then sText = File.Load(F_sPathBookmarks)
      Endif 
      'Read from Settings second: 
      If String.InStr(String.LCase(sText), "bookmark=") = 0 Then 
        sText = Settings[FMain.Name &/ "sBookmarks", Null]
      Endif 
      
      ssSpli = Split(sText & gb.NewLine, gb.NewLine)
      For Each sLine In ssSpli 
        If String.InStr(String.LCase(sLine), "bookmark=") > 0 Then 
          cBookmark = New Collection
          ssSpli = New String[]
          ssSpli = Split(sLine & "=", "=")
          ssBookmark = New String[]
          If ssSpli Then ssBookmark = Split(ssSpli[1] & String(3, gb.Tab), gb.Tab)
          If ssBookmark Then 
            cBookmark["Path"] = Trim(UnQuote(ssBookmark[0])) '/Dir/file.txt Trim(Delete Space in String, left and right)
            cBookmark["Name"] = Trim(UnQuote(ssBookmark[1])) 'terminwecker
            cBookmark["Icon"] = Trim(UnQuote(ssBookmark[2])) ' Example: "icon:/22/bookmark"
            If FileChooser1.Bookmarks.Find(cBookmark) = -1 Then FileChooser1.Bookmarks.Add(cBookmark) 'not double
          Endif   
        Endif 
      Next 
      ' Desktop.Open(Settings.Path)
      
    Case "save", "s"
      FileChooser1.Refresh()
      Wait 0.3
      sText = ""
      If FileChooser1.Bookmarks Then 
        sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Lesezeichen") & gb.NewLine
        sText &= "[Bookmarks]" & gb.NewLine
        sText &= "Count=" & FileChooser1.Bookmarks.Count & gb.NewLine
        For Each cBookmark In FileChooser1.Bookmarks
          If cBookmark["Path"] Then 
            sText &= "Bookmark" & "=" & Quote(cBookmark["Path"]) & gb.Tab & Quote(cBookmark["Name"]) & gb.Tab & Quote(cBookmark["Icon"]) & gb.NewLine
          Endif 
        Next 
        
        'To Settings:
        Settings[FMain.Name &/ "sBookmarks"] = sText
        
        'To File:
        If IsDir(sDir) = True Then File.Save(F_sPathBookmarks, sText)
        ColumnView1Resize()
        
      Else 
        ' Message.Info(("Leer"), ("Abbrechen"))
      Endif
      
      ' Example File F_sPathBookmarks: 
      ' #terminwecker 3.0.340
      ' [Bookmarks]
      ' bookmark="/home/user/terminwecker" "terminwecker" "icon:/22/clock"
      ' bookmark="/media/<USER>" "Andere Orte..." "icon:/22/system"
      ' ...
      ' bookmark="Path" & gb.Tab & "Name" & gb.Tab & "Icon" & gb.NewLine
      
  End Select 
  
  'Gambas3:
  ' FileChooser.Bookmarks (gb.form)
  ' FileChooser1.ShowBookmark = True
  ' The drop-down menu contains 3 types of bookmarks:
  ' 1.Standard bookmarks
  ' 2.Private bookmarks
  ' 3.User bookmarks
  ' The Bookmarks property documented here concerns type 2: private bookmarks.
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1BookmarkRemoveAdd()
  
  Dim cBookmark As Collection
  Dim sPath, sName, sIcon, sSort, sText, sLine, sDirFile, sDir, sExist, sFound, sQuestion, sMessage As String 
  Dim bFound As Boolean
  Dim iFound As Integer
  Dim ssSpli As String[]
  
  'Info: "FileChooser.Bookmarks.Add" getrennt von "Bookmarks.Add"
  
  sDirFile = Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt]
  If Exist(sDirFile) = True Then sText = File.Load(sDirFile)
  iFound = String.InStr(sText, "=" & FileChooser1.Dir & "=")
  If iFound > 0 Then bFound = True Else bFound = False  

  
  ''Current Dir & File = Bookmark
  ' sDirFile = FileChooser1.SelectedPath
  sDir = FileChooser1.Dir
  
  LabelInfoG(sDirFile)
  
  cBookmark = New Collection
  cBookmark["Path"] = sDir 
  cBookmark["Name"] = File.Name(sDir) 
  cBookmark["Icon"] = "icon:/22/bookmark" 
  
  sFound &= ("Path") & ": " & "<font color=darkgreen>" & cBookmark["Path"] & "</font><br>"
  sFound &= ("Name") & ": " & "<font color=darkgreen>" & cBookmark["Name"] & "</font><br>"
  
  If bFound = False Then 
    sExist = "<h3><font color=blue>" & "●" & Space(1) & ("Hinzufügen") & ":" & "</font></h3>" 
    sQuestion = "●" & Space(1) & ("Hinzufügen")
  Else 
    sExist = "<h3><font color=red>" & "○" & Space(1) & ("Entfernen") & ":" & "</font></h3>"
    sQuestion = "○" & Space(1) & ("Entfernen")
  Endif 
  sExist &= "<h3>" & sFound & "</h3>"
  
  sMessage = "<h2><font color=gray>" & ("Lesezeichen für Ordner") & "</font></h2>" 
  sMessage &= sExist 

  If Exist(sDirfile) = False Then
    sMessage &= "<h3><font color=blue>" & Application.Name & ".txt" & "</font></h3>"
    sMessage &= "<h3><font color=red>" & ("Nicht gefunden") & "</font></h3>"
  Else 
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirfile) & "/" & "</font><font color=blue>" & File.Name(sDirfile) & "</font></h3>"
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirfile) & "</b></font>" & Space(1) & "<font color=darkgreen>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    sMessage &= "<h3><font color=darkgreen>" & ("Gefunden") & "</font></h3>"
  Endif 
  
  Select Case Message.Question(sMessage, sQuestion, ("Liste..."), ("Abbrechen")) 'Case[0,1,2]
    Case 1 
      'Add+
      If bFound = False Then 
        sPath = sDir
        sName = File.BaseName(sDir)
        sIcon = "icon:/22/bookmark"
        sSort = "1"
        sLine = ("Count=Count+1") & gb.NewLine
        If Exist(sDirFile) = False Then 
          sLine = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Lesezeichen") & gb.NewLine
          sLine &= "[Bookmarks]" & gb.NewLine
          sLine &= "Count=1" & gb.NewLine
        Endif
        sLine &= "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" & sSort & "=" & gb.NewLine
        If Not sText Or Exist(sDirFile) = False Then 
          M01Functions.FileTextPlus(sDirFile, sLine, True) ' TRUE=overwrite (überschreiben)
        Else 
          M01Functions.FileAppendText(sDirFile, sLine)
        Endif 
      Else   'Remove-
        If Exist(sDirFile) = True Then 
          sExist = File.Load(sDirFile)
          ssSpli = Split(sExist & gb.NewLine, gb.NewLine)
          sText = Null
          For Each sLine In ssSpli
            If String.InStr(sExist, "=" & sDir & "=") = 0 Then sText &= sLine & gb.NewLine
          Next
          M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
        Endif 
      Endif 

    Case 2
      If PanelBookMark.Visible = False Then 
        PicBoxBookmarkList.Picture = PicTemplateArrowSelectDown.Picture
        PanelBookMark.Visible = True
        ColumnView1BookmarksOpenSaveReload("reload")
        PanelBookMark.Raise()
      Else 'Directory...
        M01Functions.FileManagerOpen(sDirFile)
      Endif 
      
    Case 3 'Cancel
      ''...
      
  End Select
  
  ''_________________________________________________________________________''
  ' /home/user/.config/gb.form.conf  (einfache Textdatei)  Edit about FileChooser
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1LoadBookmarks(Optional sPathBookmarks As String = "") '???
  
  Dim sKey, sName, sIcon, sPath, sSelect As String 
  Dim cBookmark As Collection
  Dim ccExistBookmarks As Collection[]
  Dim picStandard, picUser As Picture
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  ' F_sPathBookmarks = File.Dir(sPath) &/ Application.Name & "_bookmarks.txt"
  If Exist(sPathBookmarks) = False Then 
    sPathBookmarks = Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt]
  Endif 
  
  picStandard = PicTemplateClock.Picture.Image.Stretch(22, 22).Picture
  picUser = Picture.Load("icon:/22/clock")
  
  ColumnView1.Clear()
  ColumnView1Resize()
  ccExistBookmarks = New Collection[]
  ccExistBookmarks = M01Functions.BookmarksDefaultG() 'as Collection[]

  ''Read Bookmarks
  If Not FileChooser1.Bookmarks Then 
    FileChooser1.Bookmarks = New Collection[]
    SettingsBookmarksReadSave("read")
    FileChooser1.Bookmarks.Insert(ccExistBookmarks) 'as Collection[]
    Wait 0.3
  Endif 
  
  For Each cBookmark In ccExistBookmarks
    If cBookmark["Path"] Then 
      
      sKey = ColumnView1.Count + 1
      sPath = cBookmark["Path"]
      sName = cBookmark["Name"]
      sIcon = cBookmark["Icon"]
      If String.InStr(sIcon, ":") = 0 Or Exist(sIcon) = False Then sIcon = "icon:/22/bookmark"  
      If sPath = TextBoxPath2.Text Then sSelect = sKey Else sSelect = F_sDirBookmarkLast
      If ccExistBookmarks.Find(cBookmark) = -1 Then ccExistBookmarks.Add(cBookmark)
      
      ColumnView1.Add(sKey, "")
      ColumnView1[sKey].Picture = Picture[sIcon]'picUser 
      ColumnView1[sKey][0] = sPath 
      ColumnView1[sKey][1] = sName
      ColumnView1[sKey][2] = sIcon 
      ColumnView1[sKey][F_iColumnSort] = sKey 
    Endif 
  Next 
  
  ''Select, Show
  If ColumnView1.Exist(sSelect) = True Then 
    ColumnView1[sSelect].Selected = True
    ' ColumnView1[sSelect].Background = F_iColorSelectGreen150
    ColumnView1[sSelect].EnsureVisible
    sPath = ColumnView1[sSelect][0]
    sName = ColumnView1[sSelect][1]
  Endif 
  
  If Exist(sPath) = True Then ColumnView1SelectPathInfo(sPath)
  ColumnView1Resize()
  F_bBookmarkChanged = False
  
  FileChooser1.Refresh()
  Wait 0.3
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1BookmarksOpenSaveReload(Optional sOpenSaveReload As String = "start")

  Dim sText, sDirFile, sKey, sName, sIcon, sPath, sLine, sSort, sTitle, sMessage As String 
  Dim ssSpli, ssLines As String[]
  Dim iCount, iBookmarks As Integer
  Dim picSave, picLoad, picReload, picDouble As Picture
  Dim cBookmark As Collection
  ' Dim ccExistBookmarks As Collection[]
  ' Dim picStandard, picUser As Picture
  
  ' picStandard = PicTemplateClock.Picture.Image.Stretch(22, 22).Picture
  ' picUser = Picture.Load("icon:/22/clock")
  picSave = ButtonSaveBookmarks.Picture.Image.Stretch(22, 22).Picture
  picLoad = ButtonOpenBookmarks.Picture.Image.Stretch(22, 22).Picture
  picReload = ButtonBookmarksReload.Picture.Image.Stretch(22, 22).Picture
  picDouble = PicTemplateDoubleLine.Picture.Image.Stretch(22, 22).Picture
  If sOpenSaveReload = "start" Then picReload = PicBoxBookmark.Picture.Image.Stretch(22, 22).Picture
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  ' F_sPathBookmarks = File.Dir(sPath) &/ Application.Name & "_bookmarks.txt"
  sDirFile = Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt]

  Select Case sOpenSaveReload
    Case "open"
      sDirFile = M01Functions.FileDialogPathReturn(sDirFile, "open", sDirFile) 'no Path = cancel
      If Exist(sDirFile) = False Then Return 'Cancel
      
      If ColumnView1.Keys.Max = -1 Or ColumnView1.Columns.Max < F_iColumnNr Then ColumnView1Resize()
      
      ''ColumnView1
      ssLines = New String[]
      For Each sKey In ColumnView1.Keys
        sPath = ColumnView1[sKey][0] 
        sName = ColumnView1[sKey][1]
        sIcon = ColumnView1[sKey][2] 
        sSort = ColumnView1[sKey][3] 
        sLine = "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" '& sSort & "="
        ssLines.Add(sLine) 
      Next
      
      ''Add
      sText = File.Load(sDirFile)
      sText = Replace(sText, gb.Tab, "=", gb.String)
      For Each sLine In Split(sText & gb.NewLine, gb.NewLine)
        If sLine And String.InStr(String.LCase(sLine), "bookmark=") > 0 Then 
          ssSpli = Split(sLine & String(F_iColumnNr, "="), "=")
          For Each sKey In ssSpli
            '"bookmark = ssSpli[0]"
            sPath = ssSpli[1] 
            sName = ssSpli[2]
            sIcon = ssSpli[3] 
            sSort = ssSpli[4] 
            sLine = "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" '& sSort & "="
            If ssLines.Find("*=" & sPath & "=*", gb.Like) = -1 Then ssLines.Add(sLine) 'not double
          Next
        Endif
      Next
      
      ColumnView1.Clear()
      ColumnView1Resize()
      For Each sLine In ssLines
        ssSpli = Split(sLine & String(F_iColumnNr, "="), "=")
        sPath = ssSpli[1] 
        sName = ssSpli[2]
        sIcon = ssSpli[3] 
        sSort = ssSpli[4] 
        If sPath Then 
          sKey = ColumnView1.Count + 1
          ColumnView1.Add(sKey, "")
          ColumnView1[sKey][0] = sPath 
          ColumnView1[sKey][1] = sName
          ColumnView1[sKey][2] = sIcon 
          ColumnView1[sKey][F_iColumnSort] = sKey 
          ColumnView1[sKey].Picture = picLoad
        Endif 
      Next
      ColumnViewSort(F_iColumnSort)
      ColumnView1SelectPathInfo(sDirFile)
      
    Case "save"
      If FMain.F_ccBookmarksStandards Then iBookmarks = FMain.F_ccBookmarksStandards.Count
      sMessage = "<h2><font color=red>" & ("Liste mit Lesezeichen speichern?") & "</font></h2>"
      sMessage &= sDirFile 
      sMessage &= "<h3>"
      sMessage &= "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & Space(1) & "<font color=blue>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
      sMessage &= "</h3>"
      sMessage &= "<h3><font color=darkgreen><font size=7>" & iBookmarks & "</font>" & Space(1) & ("Standard-Lesezeichen bleiben erhalten.") & "</font></h3>"
      
      Select Case Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
        Case 1
          '...
        Case 2 'Cancel
          Return 
      End Select 
       
      If ColumnView1.Keys.Max = -1 Or ColumnView1.Columns.Max < F_iColumnNr Then ColumnView1Resize()
      sText = Null
      iCount = 0
      ssLines = New String[]
      sTitle = ("#" & Application.Name & Space(1) & Application.Version) & Space(1) & ("Lesezeichen") & gb.NewLine
      sTitle &= "[Bookmarks]" & gb.NewLine
      For Each sKey In ColumnView1.Keys
        sPath = ColumnView1[sKey][0] 
        sName = ColumnView1[sKey][1]
        sIcon = ColumnView1[sKey][2] 
        sSort = sKey
        sLine = "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" & sSort & "="
        If ssLines.Find("*=" & sPath & "=*", gb.Like) = -1 Then 
          ssLines.Add(sLine) 'not double
          sText &= sLine & gb.NewLine
          iCount = iCount + 1
          ColumnView1[sKey].Picture = picSave
        Else 
          ColumnView1[sKey].Picture = picDouble
        Endif 
      Next
      sTitle &= "Count=" & iCount & gb.NewLine
      sText = sTitle & sText 
      M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
      ColumnView1SelectPathInfo(sDirFile)
      
    Case "reload", "start"
      If ColumnView1.Keys.Max = -1 Or ColumnView1.Columns.Max < F_iColumnNr Then ColumnView1Resize()
      If Not FMain.F_ccBookmarksStandards Then FMain.F_ccBookmarksStandards = M01Functions.BookmarksDefaultG() 'as Collection[] 
      ssLines = New String[]
      iCount = 0
      For Each cBookmark In FMain.F_ccBookmarksStandards
        iCount = iCount + 1
        sPath = cBookmark["Path"] 
        sName = cBookmark["Name"] 
        sIcon = cBookmark["Icon"] 
        sSort = iCount 
        sLine = "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" '& sSort & "="
        If ssLines.Find("*=" & sPath & "=*", gb.Like) = -1 Then ssLines.Add(sLine) 'not double
      Next
      
      If Exist(sDirFile) = True Then 
        ''Add
        sText = File.Load(sDirFile)
        For Each sLine In Split(sText & gb.NewLine, gb.NewLine)
          If sLine And String.InStr(String.LCase(sLine), "bookmark=") > 0 Then 
            sLine = Replace(sLine, gb.Tab, "=")
            ssSpli = Split(sLine & String(F_iColumnNr, "="), "=")
            For Each sKey In ssSpli
              '"bookmark = ssSpli[0]"
              sPath = UnQuote(ssSpli[1]) 
              sName = UnQuote(ssSpli[2])
              sIcon = UnQuote(ssSpli[3])
              sSort = UnQuote(ssSpli[4])
              sLine = "Bookmark" & "=" & sPath & "=" & sName & "=" & sIcon & "=" '& sSort & "="
              If ssLines.Find("*=" & sPath & "=*", gb.Like) = -1 Then ssLines.Add(sLine) 'not double
            Next
          Endif
        Next
        
        ColumnView1.Clear()
        ColumnView1Resize()
        For Each sLine In ssLines
          ssSpli = Split(sLine & String(F_iColumnNr, "="), "=")
          sPath = ssSpli[1] 
          sName = ssSpli[2]
          sIcon = ssSpli[3] 
          sSort = ssSpli[4]
          If sPath Then
            sKey = ColumnView1.Count + 1
            ColumnView1.Add(sKey, "")
            ColumnView1[sKey][0] = sPath 
            ColumnView1[sKey][1] = sName
            ColumnView1[sKey][2] = sIcon 
            ColumnView1[sKey][F_iColumnSort] = sKey 
            ColumnView1[sKey].Picture = picReload
            If String.InStr(sIcon, "icon:/22/") > 0 Or Exist(sIcon) = True Then ColumnView1[sKey].Picture = Picture[sIcon]
          Endif 
        Next
        ColumnViewSort(F_iColumnSort)
        ColumnView1SelectPathInfo(sDirFile)
        TextBoxBookmarkPath.Clear()
        TextBoxBookmarkName.Clear()
      Endif 
  End Select
  
  Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  Dim it As Integer
  
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                            'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Lesezeichen Ordner") '& ": " & FileChooser1.Bookmarks.Count & Space(2)
  ColumnView1.Columns[1].Title = ("Name")    'Title
  ColumnView1.Columns[2].Title = ("Icon")    'Example: "icon:/22/bookmark"
  
  ColumnView1.Columns[0].Width = (ColumnView1.ClientWidth / 10) * 7
  ColumnView1.Columns[1].Width = (ColumnView1.ClientWidth / 10) * 2
  ColumnView1.Columns[2].Width = (ColumnView1.ClientWidth / 10) * 1
  
  For it = 3 To ColumnView1.Columns.Max  
    ColumnView1.Columns[it].Title = "" 
    ColumnView1.Columns[it].Width = 0   
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[1].Width = ColumnView1.ClientWidth - (ColumnView1.Columns[0].Left + ColumnView1.Columns[0].W) 
  ColumnViewAscending()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End


Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Lesezeichen Ordner") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Lesezeichen Ordner") & Space(2)
  Endif 
  ' If ColumnView2.Columns.Ascending = True Then  
  '   ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ' Else 
  '   ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  ' Endif 
  
Catch 
  FMain.ErrorText
    
End

Public Sub ColumnView1_Click()
  
  Dim sPath, sName, sIcon, sKey As String 
  
  If ColumnView1.Current Then  'Header 0
    If ColumnView1.Current Then 
      sKey = ColumnView1.Current.Key
      ColumnView1.Tag = sKey
      sPath = ColumnView1[sKey][0] '[0] or .Text
      sName = ColumnView1[sKey][1] 
      sIcon = ColumnView1[sKey][2]
      If sPath And sName Then 
        ' F_sDirBookmarkLast = sPath
        ColumnView1SelectPathInfo(sPath)
        TextBoxBookmarkPath.Background = F_iColorSelectBackground
        TextBoxBookmarkName.Background = F_iColorSelectBackground
        TextBoxBookmarkPath.SelectAll()
        TextBoxBookmarkPath.Insert(sPath)
        TextBoxBookmarkName.SelectAll()
        TextBoxBookmarkName.Insert(sName)
        ButtonDirApply.Border = True 
      Endif 
      If Exist(TextBoxBookmarkPath.Text) = True Then 
        PicBoxPathLED.Picture = PicTemplateLEDgreen.Picture
      Else 
        PicBoxPathLED.Picture = PicTemplateLEDred.Picture
      Endif
    Else 
      TextBoxBookmarkPath.Background = Color.White
      TextBoxBookmarkName.Background = Color.White
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupTextBoxBookmark_MouseDown()
  
  If Object.Type(Last) = "TextBox"
    Select Case Last.Tag 
      Case TextBoxBookmarkPath.Tag 
        ButtonBookmarkInsertLine.Background = F_iColorSelectGreen150
        ButtonBookmarkInsertLine.Border = True  
      Case TextBoxBookmarkName.Tag 
        ButtonBookmarkInsertLine.Background = F_iColorSelectGreen150
        ButtonBookmarkInsertLine.Border = True  
    End Select 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1InsertLine()
  
  Dim sKey, sMessage As String
  Dim picChanged As Picture
  
  sKey = ColumnView1.Tag
  If ColumnView1.Exist(sKey) = True Then 
    picChanged = ButtonBookmarkInsertLine.Picture.Image.Stretch(22, 22).Picture
    If ColumnView1.Exist(sKey) = True Then 
      ColumnView1[sKey].Picture = picChanged
      ColumnView1[sKey][0] = TextBoxBookmarkPath.Text 
      ColumnView1[sKey][1] = TextBoxBookmarkName.Text 
      ColumnView1[sKey][2] = "icon:/22/bookmark"
      F_bBookmarkChanged = True 
    Endif 
  Else 
    If ColumnView1.Columns.Count > 0 Then 
      sMessage = "<h3>" & ColumnView1.Columns[0].Title & "</h3>"
    Endif 
    If ColumnView1.Keys.Count = 0 Then 
      sKey = ColumnView1.Count + 1
      ColumnView1.Add(sKey, "")
      ColumnView1[sKey][0] = ""
      ColumnView1[sKey][1] = ""
      ColumnView1[sKey][2] = ""
      ColumnView1[sKey].Picture = Picture["icon:/22/add"]
    Endif 
    sMessage &= "<h3><font color=#" & Hex(Color.SelectedBackground, 6) & ">" & ("Vorher eine Zeile auswählen") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1SelectPathInfo(Optional sDirFile As String = "")
  
  Dim sDir, sFile, sHTMLspace As String 
  
  sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html
  If IsDir(sDirfile) = True Then sDir = sDirFile Else sDir = File.Dir(sDirFile)
  sFile = File.Name(sDirFile)
  
  If sFile Like "*" & Application.Name & "*.txt" Then 
    sFile = "<font color=darkgreen><b>" & sFile & "</b></font>" & String(3, sHTMLspace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>"
  Else If IsDir(sDirFile) = True Then 
    sDir = sDirFile
    sFile = "<font color=blue><b>" & ("Datei wählen") & "</b></font>" & String(3, sHTMLspace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>"
  Else 
    sFile = "<font color=red><b>" & ("Datei fehlt") & "</b></font>" 
  Endif 
  LabelPathBookmark.Text = sDir &/ sFile
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1Save() '???
  
  Dim sKey, sDirFile, sPath, sPathSelected, sMessage As String 
  Dim ssDirFiles As String[]
  Dim cBookmark As Collection
  Dim ccBookmarks As Collection[]
  Dim iStandards As Integer
  Dim picAdd, picQuestion, picSaved As Picture
  
  Return 
  
  ''Check:
  picAdd = PicTemplateAdd.Picture.Image.Stretch(22, 22).Picture
  picQuestion = PicTemplateQuestionRed.Picture.Image.Stretch(22, 22).Picture  'Picture["icon:/22/question"] '(*1)
  picSaved = ButtonSaveBookmarks.Picture.Image.Stretch(22, 22).Picture
  
  If ColumnView1.Keys Then 'save all
    ccBookmarks = New Collection[]
    
    For Each sKey In ColumnView1.Keys
      cBookmark = New Collection
      cBookmark["Path"] = ColumnView1[sKey][0]
      cBookmark["Name"] = ColumnView1[sKey][1] 
      cBookmark["Icon"] = ColumnView1[sKey][2] 'Example: "icon:/22/clock" (*1)
      If cBookmark["Icon"] = "" Then cBookmark["Icon"] = "icon:/22/bookmark"
      If ccBookmarks.Find(cBookmark) = -1 Then 
        ccBookmarks.Add(cBookmark)
        ColumnView1[sKey].Picture = picAdd 
      Else 
        ColumnView1[sKey].Picture = picQuestion 
      Endif 
      If ColumnView1[sKey].Selected = True Then sPathSelected = sPath
    Next 
    
    If IsDir(sPathSelected) = True Then 
      sDirfile = ""
      ssDirFiles = Dir(sPathSelected, "*" & Application.Name & ".txt", gb.File)  'as String[]
      If ssDirFiles Then 
        If ssDirFiles.Count > 0 Then sDirfile = sPathSelected &/ ssDirFiles[0] Else sDirfile = sPathSelected
      Endif 
      If Exist(sDirfile) = True Then FileChooser1SelectPath(sDirfile) Else FileChooser1SelectPath(sPathSelected)
    Endif 
  Endif 
  
  If Not FMain.F_ccBookmarksStandards Then FMain.F_ccBookmarksStandards = M01Functions.BookmarksDefaultG() 'as Collection[] 
  iStandards = FMain.F_ccBookmarksStandards.Count 
  
  sMessage = "<h2><font color=blue>" & ("Lesezeichen") & "</font></h2>"
  sMessage &= "<h3><font color=red>" & "● " & ("Veränderte Liste speichern?") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & Str(iStandards) & Space(1) & ("Standard-Lesezeichen bleiben") & "</font></h3>"
  
  Select Message.Question(sMessage, "● " & ("Speichern"), ("Nein"), ("Abbrechen"))
    Case 1 
      If Not ccBookmarks Then ccBookmarks = New Collection[]
      FileChooser1.Bookmarks = ccBookmarks
      FileChooser1.Refresh()
      Wait 0.3
      ''Save:
      SettingsBookmarksReadSave("save")
      If Exist(sDirFile) = True Then LabelInfoPath2G(sDirFile)
      ''Load new:
      ColumnView1LoadBookmarks()
      If ColumnView1.Keys Then 
        For Each sKey In ColumnView1.Keys
          ColumnView1[sKey].Picture = picSaved 
        Next 
      Endif 
      F_bBookmarkChanged = False 'Reset
    Case 2
      ''...
    Case 3
      ''...
  End Select 
  
  ''____________________________________________________________________''
  '(*1)"gb.form.stock"
  'Gambas3: "This component provides a Default icon set that Is Automatically loaded by the gb.form component when needed."
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAdd()                                                           '1x new Line at the End
  
  Dim sK0, sK1, sKeySort As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Columns.Sort <> F_iColumnsCount Then ColumnSortSettingCentral()
  
  If ColumnView1.Selection.Max > -1 Then 
    sK0 = ColumnView1.Selection.Last 
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    sK1 = ColumnView1.Count + 1 '=>Add After Last Key .count-1
    If ColumnView1.Exist(sK1) = False Then 
      sKeySort = ColumnView1[sK0][F_iColumnSort] & ".1" 
      ColumnView1.UnselectAll()
      PicAdd = ButtonBookmarkAddLine.Picture.Image.Stretch(22, 22).Picture
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                    'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][1] = ""
      ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1][F_iColumnNr] = sK1 
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
    Endif 
  Else 
    ColumnViewAddMin1xCount()
    M = ColumnView1.MoveLast() 'M=0=False>Exist. M=-1=True>Missing
    If M = 0 Then sK0 = ColumnView1.Item.Key Else sK0 = ColumnView1.Count 
    If ColumnView1.Exist(sK0) = True Then 
      ColumnView1[sK0].Selected = True
      ColumnView1[sK0].EnsureVisible()  
    Endif 
    ColumnSortSettingCentral()
    
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1Cut(Optional bAll As Boolean = False)
  
  Dim sKey, sPath, sName, sIcon As String 
  Dim picCut, picQuestion As Picture
  
  picCut = ButtonCut.Picture.Image.Stretch(22, 22).Picture
  picQuestion = PicTemplateQuestionRed.Picture.Image.Stretch(22, 22).Picture
  
  If bAll = True Then ColumnView1.SelectAll()
  If ColumnView1.Selection Then 'Header 0
    For Each sKey In ColumnView1.Selection
      sPath = ColumnView1[sKey][0] 
      sName = ColumnView1[sKey][1] 
      sIcon = ColumnView1[sKey][2]
      If sPath Then 
        ColumnView1[sKey].Picture = picCut
      Else 
        ColumnView1[sKey].Picture = picQuestion
      Endif 
      ColumnView1[sKey][0] = ""
      ColumnView1[sKey][1] = ""
      ColumnView1[sKey][2] = ""
      F_bBookmarkChanged = True
    Next 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnSortSettingCentral()
  
  ColumnView1.Mode = Select.Multiple
  If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
  ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  If ColumnView1.Columns.Sort <> F_iColumnSort Then ColumnView1.Columns.Sort = F_iColumnSort 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddMin1xCount()
  
  Dim sK1 As String 
  Dim PicAdd As Picture
  
  If ColumnView1.Keys Then '1 > only Header (Title)
    If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
    sK1 = ColumnView1.Count + 1
    PicAdd = PicTemplateAdd.Picture.Image.Stretch(22, 22).Picture
    ColumnView1.Add(sK1, "", PicAdd)
    ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
    ColumnView1[sK1][1] = ""
    ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
    ColumnView1[sK1][F_iColumnNr] = sK1 
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUp() '▲
  
  Dim it As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicUp As Picture
  
  ''ColumnView1:
  If ColumnView1.Selection.Max > -1 Then 
    PicUp = ButtonBookmarkListUp.Picture.Image.Stretch(22, 22).Picture 
    ColumnSortSettingCentral()
    F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
    For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
      ' iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sK1 = F_ssKeysCopy[it]
      ColumnView1[sK1].Picture = PicUp
      ColumnView1[sK1][F_iColumnSelect] = "PicUp"
      M = ColumnView1.MoveTo(sK1)
      ' M = ColumnView1.MoveBelow() '▼down
      M = ColumnView1.MoveAbove() '▲up
      If M = -1 Then ColumnView1.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
      sK2 = ColumnView1.Item.Key
      sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
      sC2 = ColumnView1[sK2][F_iColumnSort]
      ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
      ColumnView1[sK2][F_iColumnSort] = sC1
    Next 
    ColumnViewSort(F_iColumnSort)
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewDown() '▼
  
  Dim it As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicDown As Picture
  
  ''ColumnView1:
  If ColumnView1.Selection.Max > -1 Then 
    PicDown = ButtonBookmarkListDown.Picture.Image.Stretch(22, 22).Picture
    ColumnSortSettingCentral()
    F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
    For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
      ' iLine = iLine + 1
      ' If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sK1 = F_ssKeysCopy[it]
      ColumnView1[sK1].Picture = PicDown
      ColumnView1[sK1][F_iColumnSelect] = "PicDown"
      M = ColumnView1.MoveTo(sK1)
      M = ColumnView1.MoveBelow() '▼down
      'M = ColumnView1.MoveAbove() '▲up
      If M = -1 Then ColumnView1.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
      sK2 = ColumnView1.Item.Key
      sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
      sC2 = ColumnView1[sK2][F_iColumnSort] 'Read Column
      ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
      ColumnView1[sK2][F_iColumnSort] = sC1 'Change Column
    Next 
    ColumnViewSort(F_iColumnSort)
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0)
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If iSortColumnNr < ColumnView1.Columns.Count Then 
    ColumnView1.Sorted = True 'Important (wichtig)
    ' If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
    ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
    If ColumnView1.Columns.Sort <> iSortColumnNr Then ColumnView1.Columns.Sort = iSortColumnNr 
    If ColumnView1.Selection.Max > -1 Then
      sKey = ColumnView1.Selection.Last  'only Key, Example: sKey = "9"
    Else 
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
    Endif
    If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub FileChooser1SelectPath(Optional sDirFile As String = "")
  
  Dim sDir, sFile As String 
  
  If Exist(sDirFile) = False Then sDirfile = FilePathForm()
  If InStr(String.LCase(sDirFile), "/media") > 0 Then FileChooser1.Dir = "/media"
  
  FileChooser1.Dir = User.Home
  
  If Exist(sDirFile) = True Then
    If IsDir(sDirfile) = True Then 
      sDir = sDirfile
      sFile = ""
    Else 
      sDir = File.Dir(sDirFile) 
      sFile = File.Name(sDirfile)
    Endif 
    
    FileChooser1.Dir = sDir 
    FileChooser1.DirView.SetFocus
    
    If sFile Then 
      FileChooser1.FileView.Current = sFile
      FileChooser1.FileView.SetFocus
      FileChooser1.FilterIndex = 1
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DirStandardAlternative(Optional bStandard As Boolean = True)
  Dim sDir, sDirFile, sDirMediaUser, sMessage As String 
  Dim ssDirs As String[]
  ' sDirMediaUser = Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt", FMain.F_sPathMediaTerminwecker_txt]
  sDirMediaUser = "/media" &/ User.Name
  
  Select Case bStandard
    Case True 'Standard
      sDir = File.Dir(Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sDirAppName])
    Case False 'Alternative, Example: USB-Stick
      sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
      If IsDir(sDir) = True Then 
        FileChooser1.Dir = sDir
      Else 
        ssDirs = New String[]
        ssDirs = RDir(sDirMediaUser, "*" & Application.Name, gb.Directory)
        If ssDirs Then sDir = sDirMediaUser &/ ssDirs.First
      Endif 
  End Select
  
  If IsDir(sDir) = True Then 
    If String.InStr(sDir, "/media") > 0 Then 
      ButtonDirAlternative2.Picture = PicTemplateUSB.Picture
      F_bChangeON = True
      FileChooser1.Dir = User.Home
      FileChooser1.Dir = sDir
      F_bChangeON = False
      sDirFile = sDir &/ Application.Name & ".txt"
      If Exist(sDirFile) = True Then FileChooser1.SelectedPath = sDirFile
    Else 
      ButtonDirAlternative2.Picture = PicTemplateDirQuestion.Picture
    Endif
  Else 
    sMessage = "<h3><font color=gray>" & ("Ordner") & ":" "</font></h3>" 
    sMessage &= "<h3><font color=gray>" & sDir & "</font></h3>" 
    sMessage &= "<font color=red>" & ("Nicht gefunden") & "</font>"
    Message.Info(sMessage, ("Abbrechen"))
    If String.InStr(sDir, "/media") > 0 Then 
      ButtonDirAlternative2.Picture = PicTemplateUSBarrow.Picture
    Else 
      ButtonDirAlternative2.Picture = PicTemplateDirQuestion.Picture
    Endif
  Endif 

Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
    sValue = Replace(sValue, "bg_", "bglinie_")
    MoveLine.Picture = Picture.Load(sValue) 
    MoveLine.Stretch = True
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
    MoveLine.Background = PicBackground.Background
    MoveLine.Stretch = False
  Endif
  If String.LCase(sValue) Like "*alum*" Then FileChooser1.Foreground = Color.DarkBlue 'Metal
  If String.LCase(sValue) Like "*holz*" Then FileChooser1.Foreground = Color.Default 'Wood
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True 
  IconError.Visible = False
  ProgressBar1.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form1FileOpen.Window.Maximized = False Then
    Form1FileOpen.Window.Maximized = True
  Else
    Form1FileOpen.Window.Maximized = False
    Form1FileOpen.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH, iW, iPH As Integer 'Border Width, Border Height, Panel Height
  Dim fPart As Float
  
  If Form1FileOpen.Width < 200 Then Form1FileOpen.Width = 200
  If Form1FileOpen.Height < 200 Then Form1FileOpen.Height = 200
  
  PicBackground.Move(0, 0, Form1FileOpen.ClientW, Form1FileOpen.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Randbreite
  iBH = PicBackground.Height / 100 * 3
  
  '******************************
  iPH = F_iPanelH 'Panel Height in Pixeln
  
  F_iMoveLineMinH = iBH
  F_iMoveLineMaxH = Form1FileOpen.ClientH - (iPH * 6) - iBH
  '******************************
  If F_iOnly1x = 0 Then MoveLine.Top = F_iMoveLineMaxH
  
  'Ausrichtungen an Bewegungslinie
  '-----------------------------------------------------------------------
  MoveLine.Move(iBW, MoveLine.Top, PicBackground.Width - (iBW * 2), iPH) '.Top Begin => Form_Open
  '-----------------------------------------------------------------------
  If MoveLine.Top < F_iMoveLineMinH Or MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH
  
  IconError.Move(Form1FileOpen.ClientW - 32, 0, 32, 32)
  FileChooser1.Move(iBW, iBH, Form1FileOpen.ClientW - (iBW * 2), MoveLine.Top + MoveLine.H) ' Form1FileOpen.ClientH - (iBH * 2) - (iPH * 5))
  ProgressBar1.Move(MoveLine.Left, MoveLine.Top, MoveLine.Width, MoveLine.Height)
  
  ''PanelInfo:
  PanelInfo.Move(iBW, MoveLine.Top + MoveLine.H, FileChooser1.W, iPH)
  PicBoxBookmark.Move(0, 0, iPH, iPH)
  LabelInfo.Move(PicBoxBookmark.Left + PicBoxBookmark.W, 0, PanelInfo.W - (iPH * 8), iPH)
  PicBoxTrashOpen.Move(LabelInfo.Left + LabelInfo.W, 0, iPH, PanelInfo.H)
  LabelCheckFilterTxt.Move(PicBoxTrashOpen.Left + PicBoxTrashOpen.W, 0, iPH * 3, PanelInfo.H)
  LabelBGCheckBoxtxt.Move(LabelCheckFilterTxt.Left, LabelCheckFilterTxt.Top, LabelCheckFilterTxt.W, LabelCheckFilterTxt.H)
  ListAplus.Move(LabelCheckFilterTxt.Left + LabelCheckFilterTxt.W, 0, iPH, iPH)
  WindowT5plus.Move(ListAplus.Left + ListAplus.W + iPH, 0, iPH, iPH)
  
  ''PanelBGPath2:
  PanelPath2.Move(iBW, Form1FileOpen.ClientH - (iPH * 3.5) - iBH, PanelInfo.W, iPH)
  ButtonDirAlternative2.Move(0, 0, iPH, iPH)
  CheckBoxFilePath2.Move(iPH, 0, iPH, iPH)
  LabelPath2.Move(CheckBoxFilePath2.Left + CheckBoxFilePath2.W, 0, LabelPath2.Font.TextWidth(LabelPath2.Text) + 25, iPH)
  TextBoxPath2.Move(LabelPath2.Left + LabelPath2.W, 0, PanelPath2.W - (LabelPath2.Left + LabelPath2.W) - (iPH * 4), iPH)
  LabelInfoPath2.Move(TextBoxPath2.Left, TextBoxPath2.Top, TextBoxPath2.W, TextBoxPath2.H)
  PicBoxBookmarkList.Move(PanelPath2.W - (iPH * 4), 0, iPH, iPH)
  ReloadPath2.Move(PanelPath2.W - (iPH * 3), 0, iPH, iPH)
  PicBoxSearch2.Move(PanelPath2.W - (iPH * 2), 0, iPH, iPH)
  PicBoxFileInfo2.Move(PanelPath2.W - iPH, 0, iPH, iPH)
  
  ''PanelBGPath1:
  PanelPath1.Move(iBW, PanelPath2.Top + PanelPath2.H, PanelPath2.W, iPH)
  ButtonDirStandard.Move(0, 0, iPH, iPH)
  CheckBoxFilePath1.Move(iPH, 0, iPH, iPH)
  LabelPath1.Move(CheckBoxFilePath1.Left + CheckBoxFilePath1.W, 0, LabelPath1.Font.TextWidth(LabelPath2.Text) + 25, iPH)
  TextBoxPath1.Move(LabelPath1.Left + LabelPath1.W, 0, PanelPath1.W - (LabelPath1.Left + LabelPath1.W) - (iPH * 2), iPH)
  LabelInfoPath1.Move(TextBoxPath1.Left, TextBoxPath1.Top, TextBoxPath1.W, TextBoxPath1.H)
  PicBoxSearch1.Move(PanelPath1.W - (iPH * 2), 0, iPH, iPH)
  PicBoxFileInfo1.Move(PanelPath1.W - iPH, 0, iPH, iPH)
  
  ''PanelClose:
  PanelClose.Move(iBW, PanelPath1.Top + PanelPath1.H, PanelPath1.W, iPH * 1.5)
  fPart = (PanelClose.W - iPH) / 6
  ButtonMenu.Move(0, 0, iPH, PanelClose.H)
  ButtonSearchLatestFile.Move(ButtonMenu.Left + ButtonMenu.W, 0, fPart, PanelClose.H)
  ButtonDirAlternativeCopy.Move(ButtonSearchLatestFile.Left + ButtonSearchLatestFile.W, 0, fPart, PanelClose.H)
  ButtonAdd.Move(ButtonDirAlternativeCopy.Left + ButtonDirAlternativeCopy.W, 0, fPart, PanelClose.H)
  ButtonRead.Move(ButtonAdd.Left + ButtonAdd.W, ButtonApply.Top, fPart, PanelClose.H)
  ButtonApply.Move(ButtonRead.Left + ButtonRead.W, 0, fPart, PanelClose.H)
  ButtonCancel.Move(ButtonApply.Left + ButtonApply.W, ButtonApply.Top, PanelClose.W - (ButtonApply.Left + ButtonApply.W), PanelClose.H)
  
  ''Text-Height:
  ' AplusG()
  
  ''Panel TextArea:
  PanelText5Resize()
  
  iW = ButtonCancel.H 'WindowStretch.Picture.W 'Example: 32
  If F_bMovingON = False Then WindowStretch.Move(Form1FileOpen.ClientW - iBW - iW, Form1FileOpen.ClientH - iBH - iW, iW, iW)  
  
  If PanelText5.H < F_iMoveLineMaxH Then 
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture
  Else 
    WindowT5plus.Picture = PicTemplatePageMini.Picture  
  Endif
  RaiseOrder() '▼ or ▲
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelText5Resize()
  
  Dim iPH, iDis, iPart As Integer
  
  iPH = F_iPanelH
  iDis = 5 'Distance in Pixel
  
  ''Panel TextArea:
  FileChooser1.Move(FileChooser1.Left, FileChooser1.Top, FileChooser1.W, MoveLine.Top - FileChooser1.Top)
  PanelInfo.Move(FileChooser1.Left, MoveLine.Top + MoveLine.H, FileChooser1.W, PanelInfo.H)
  PanelText5.Move(FileChooser1.Left, PanelInfo.Top + PanelInfo.H, FileChooser1.W, Me.H - (FileChooser1.Top * 2) - PanelClose.H - MoveLine.Top)
  TextArea.Move(0, 0, PanelText5.W, PanelText5.H - (iPH * 2))
  LabelText5Path.Move(0, TextArea.Top + TextArea.H, PanelText5.W, iPH)
  ButtonTextAreaCancel.Move(0, LabelText5Path.Top + LabelText5Path.H, PanelText5.W, PanelText5.H - (LabelText5Path.Top + LabelText5Path.H))
  LabelTextCancel.Move(0, ButtonTextAreaCancel.Top, ButtonTextAreaCancel.W / 4, ButtonTextAreaCancel.H)
  
  ''PanelBookMark:
  PanelBookMark.Move(MoveLine.Left, FileChooser1.Top, MoveLine.W, MoveLine.Top - FileChooser1.Top)
  ColumnView1.Move(0, 0, PanelBookMark.W, PanelBookMark.H - (iPH * 3))
  PanelPathName.Move(0, ColumnView1.Top + ColumnView1.H, ColumnView1.W, iPH)
  TextBoxBookmarkPath.Move(0, 0, (ColumnView1.W / 10) * 7 - iPH, iPH)
  PicBoxPathLED.Move(TextBoxBookmarkPath.Left + TextBoxBookmarkPath.W, 0, iPH, iPH)
  TextBoxBookmarkName.Move(TextBoxBookmarkPath.Left + TextBoxBookmarkPath.W + iPH, 0, ColumnView1.W - (TextBoxBookmarkPath.Left + TextBoxBookmarkPath.W + iPH) - (iPH * 2), iPH)
  ButtonBookmarkInsertLine.Move(TextBoxBookmarkName.Left + TextBoxBookmarkName.W, 0, iPH * 2, iPH)
  LabelTippBookmak.Move(0, PanelPathName.Top + PanelPathName.H, iPH * 5, iPH)
  LabelPathBookmark.Move(LabelTippBookmak.Left + LabelTippBookmak.W, LabelTippBookmak.Top, PanelBookMark.W - (LabelTippBookmak.Left + LabelTippBookmak.W), iPH)
  
  iPart = PanelBookMark.W / 11
  PanelBookmarkMenu.Move(0, LabelPathBookmark.Top + LabelPathBookmark.H, PanelBookMark.W, iPH)
  ButtonBookmarkAddLine.Move(0, 0, iPart, iPH)
  ButtonBookmarkListDown.Move(ButtonBookmarkAddLine.Left + ButtonBookmarkAddLine.W, 0, iPart, iPH)
  ButtonBookmarkListUp.Move(ButtonBookmarkListDown.Left + ButtonBookmarkListDown.W, 0, iPart, iPH)
  ButtonCut.Move(ButtonBookmarkListUp.Left + ButtonBookmarkListUp.W, 0, iPart, iPH)
  ButtonCutAll.Move(ButtonCut.Left + ButtonCut.W, 0, iPart, iPH)
  ButtonOpenBookmarks.Move(ButtonCutAll.Left + ButtonCutAll.W, 0, iPart, iPH)
  ButtonSaveBookmarks.Move(ButtonOpenBookmarks.Left + ButtonOpenBookmarks.W, 0, iPart, iPH)
  ButtonBookmarksReload.Move(ButtonSaveBookmarks.Left + ButtonSaveBookmarks.W, 0, iPart, iPH)
  ButtonDir.Move(ButtonBookmarksReload.Left + ButtonBookmarksReload.W, 0, iPart, iPH)
  ButtonDirApply.Move(ButtonDir.Left + ButtonDir.W, 0, iPart, iPH)
  ButtonCancelBookmark.Move(ButtonDirApply.Left + ButtonDirApply.W, 0, PanelBookMark.W - (ButtonDirApply.Left + ButtonDirApply.W), iPH)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseDown()
  
  F_bMovingON = True
  F_iY1 = Mouse.Y
  MoveLine.Raise
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseMove()
  
  If F_bMovingON = True Then
    MoveLine.Top = MoveLine.Top + Mouse.Y - F_iY1 
    If MoveLine.Top < F_iMoveLineMinH Then MoveLine.Top = F_iMoveLineMinH 'Obergrenze
    If MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH 'Untergrenze
    PanelText5Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseUp()
  
  F_bMovingON = False
  
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Resize()
  
  ' If MoveLine.Top <> F_iMoveLineMinH Then
  If PanelText5.Visible = False Then  
    F_iMoveLineTop = MoveLine.Top 
    MoveLine.Top = F_iMoveLineMaxH
  Else 
    MoveLine.Top = F_iMoveLineMinH
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub AplusG()
  
  If FileChooser1.Font.Size < 16 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
  Endif 
  
  ''Text-Height:
  LabelInfo.Font.Size = FileChooser1.Font.Size
  LabelCheckFilterTxt.Font.Size = FileChooser1.Font.Size
  LabelPath2.Font.Size = FileChooser1.Font.Size
  LabelPath1.Font.Size = FileChooser1.Font.Size
  TextBoxPath2.Font.Size = FileChooser1.Font.Size
  TextBoxPath1.Font.Size = FileChooser1.Font.Size ' TextBoxPath1.Font.TextHeight("Abc123") / 1.5 '.Size as Float
  TextArea.Font.Size = FileChooser1.Font.Size
  ColumnView1.Font.Size = FileChooser1.Font.Size
  TextBoxBookmarkPath.Font.Size = FileChooser1.Font.Size
  TextBoxBookmarkName.Font.Size = FileChooser1.Font.Size
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonApplyG() 
  
  Dim sPath, sFilePath1, sFilePath2, sLatestFilePath, sMessage, sFileSize As String
  Dim bSave As Boolean '=False
  
  sFilePath2 = TextBoxPath2.Text 'Alternative:...
  sFilePath1 = TextBoxPath1.Text 'Standard: /home/<user>/terminwecker/terminwecker.txt
  sLatestFilePath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  If String.InStr(String.LCase(sFilePath2), "/media") > 0 And String.LCase(File.Ext(sLatestFilePath)) = "txt" Then
    ' sFilePath2 = CheckDirectoryButtonApply(sFilePath2)
    Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt"] = sFilePath2
  Endif 
  bSave = True 
  
  ''Check Format
  If F_iCheckPathON = 2 Then 
    PanelPath2.Background = F_iColorSelectGreen150
    If Exist(sFilePath2) = True Then
      sFileSize = M01Functions.FileSizeText(sFilePath2) 'as String
      If M01Functions.isTerminweckerFile(sFilePath2, True) = False Then '(Path, MessageQuestionFalse) as Boolean  
        bSave = False
      Endif 
    Endif 
  Endif 
  If F_iCheckPathON = 1 Then 
    If Exist(sFilePath1) = False Then File.Save(sFilePath1, "")
    If Exist(sFilePath1) = True Then
      sFileSize = M01Functions.FileSizeText(sFilePath1) 'as String
      If M01Functions.isTerminweckerFile(sFilePath1) = False Then '(Path, MessageQuestionFalse) as Boolean  
        bSave = False
      Endif 
    Endif 
  Endif 
  
  ''Question  
  If bSave = True Then 
    sPath = ""
    sMessage = "<font size=4 color=gray>" & ("Bestätigen") & "</font>" & "<br>"
    sMessage &= "<h3><font color=darkblue>" & "○ " & ("Standard") & ": " & "</font></h3>"
    sMessage &= "<font size=4 color=darkblue>" & File.Dir(sFilePath1) & "/" & "<b>" & File.Name(sFilePath1) & "</b></font>" & "<br><br>"
    If Exist(sFilePath1) = True Then  
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sFilePath1) & "</b></font>" & Space(1) & "<font color=darkgreen>" & M01Functions.FileSizeLongText(Stat(sFilePath1).Size) & "</font>"
    Endif
    sMessage &= "<br><br>"
    
    sMessage &= "<h3><font color=darkgreen>" & "● " & ("Alternativ") & ": " & "</font></h3>" 
    sMessage &= "<font size=4 color=darkgreen>" & File.Dir(sFilePath2) & "/" & "<b>" & File.Name(sFilePath2) & "</b></font>" & "<br><br>"
    If Exist(sFilePath2) = True Then  
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sFilePath2) & "</b></font>" & Space(1) & "<font color=darkgreen>" & M01Functions.FileSizeLongText(Stat(sFilePath2).Size) & "</font>"
    Endif 
    
    sMessage &= "<br><br><br>"
    sMessage &= "<font color=gray>" & ("Tipp: Wiederherstellung, Hinzufügen... siehe unter +Bearbeiten>Datei>Sicherungskopien...") & "</font>"
    Select Case Message.Question(sMessage, "○ " & ("Standard"), "● " & ("Alternativ"), ("Abbrechen"))       
      Case 1 ''Standard
        FMain.F_sPathTerminweckerActual_txt = sFilePath1
        sPath = sFilePath1
        CheckBoxesPath(TextBoxPath1.Tag, sPath)
        
      Case 2 ''Alternative
        FMain.F_sPathTerminweckerActual_txt = sFilePath2
        sPath = sFilePath2
        CheckBoxesPath(TextBoxPath2.Tag, sPath)
        
      Case 3 ''Cancel (Abbrechen)
        bSave = False 
    End Select
  Endif 
  
  If bSave = True Then 
    ''Check:
    If Exist(sPath) = True Then 
      Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt"] = sPath 'klein/Großschreibung beachten, besser alles klein
      If String.InStr(String.LCase(sPath), "/media") > 0 Then 
        FMain.F_sPathMediaTerminwecker_txt = sPath
        Settings[FMain.Name &/ "F_sPathMediaTerminwecker_txt"] = sPath
      Endif 
    Else 
      sMessage = "<font color=red><b>" & ("Datei nicht gefunden") & ": " & "</b><br><br>"
      sMessage &= sPath & "</font><br><br>"
      sMessage &= ("Aktuelle Termin-Datei") & ": " & "<br><br>"
      sMessage &= "<b>" & sLatestFilePath & "</b>"
      
      Message.Info(sMessage, ("Abbrechen"))
      
      ''Reset:
      FMain.F_sPathTerminweckerActual_txt = sLatestFilePath 
      Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt"] = sLatestFilePath
      
    Endif 
    M01Functions.FileNamesSettingsReload()
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise()
  
End

Public Function CheckDirectoryButtonApply(Optional sDirFileToSelect As String = "") As String
  
  Dim sDirOld, sDirNew, sText, sFile, sDirFileSelectNew, sMessage As String 
  Dim it As Integer
  Dim ssSpli As String[]
  
  If String.InStr(String.LCase(sDirFileToSelect), Application.Name & "/") = 0 Then 
    sDirOld = File.Dir(sDirFileToSelect)
    ssSpli = Dir(sDirOld, "*" & Application.Name & "*.txt*", gb.File)
    If ssSpli Then 
      For Each sFile In ssSpli.Sort()
        If sFile Then 
          sText &= sFile & "<br>"
          it = it + 1 
          If it = 10 Then 
            sText &= "..." & "<br>"
            Break
          Endif  
        Endif 
      Next 
    Endif 
    sMessage &= "<h4><font color=gray>" & sDirFileToSelect & "</font></h4>" 
    sMessage &= "<h4><font color=gray>" & File.Dir(sDirFileToSelect) & "<font color=darkgreen>" & "/" & Application.Name & "/" & "</font>" & File.Name(sDirFileToSelect) & "</font></h4>" 
    sMessage &= "<h3><font color=darkgreen>" & "/" & Application.Name & "/" & "</font></h3>" 
    sMessage &= "<h3><font color=blue>" & Space(1) & ("Ordner kopieren als Unter-Ordner?") & "</font></h3>" 
    sMessage &= "<font color=gray>" & sText & "</font>" & "<br>"
    
    Select Case Message.Question(sMessage, ("Ordner kopieren") & Space(1) & Application.Name, ("Ordner..."), ("Abbrechen"))
      Case 1 ''New Directory
        sDirNew = sDirOld &/ Application.Name
        If IsDir(sDirNew) = True Then sDirNew = sDirNew &/ Application.Name
        If IsDir(sDirNew) = True Then 
          Message.Info(("Abbruch. Unter-Ordner schon vorhanden. Tipp: Umbenennen") & gb.NewLine & sDirNew)
        Else  
          If IsDir(sDirOld) = True And IsDir(sDirNew) = False Then Try Copy sDirOld To sDirNew
          sDirFileSelectNew = sDirNew &/ File.Name(sDirFileToSelect)
          sDirFileToSelect = sDirFileSelectNew
        Endif 
      Case 2 'Directory
        M01Functions.FileManagerOpen(sDirFileToSelect)
        
      Case 3 'Cancel
        ''...
    End Select 
  Endif  
  
  Return sDirFileToSelect
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxtxtG()
  
  If F_iFilterIndex = 0 Then 
    LabelCheckFilterTxt.Text = "○ *.txt" 'off
  Else
    LabelCheckFilterTxt.Text = "● *.txt" 'on
  Endif
  FileChooser1.FilterIndex = F_iFilterIndex
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextPathGroup_Change()
  
  If Exist(Last.Text) = True Then 'Or Exist(FileChooser1.SelectedPath) = True
    Last.Foreground = FileChooser1.Foreground
    ' If F_iCheckPathON = False Then TextBoxPath1.Foreground = Color.Gray
  Else
    Last.Foreground = Color.Red
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextPathGroup_KeyPress()
  
  If Key.Code = Key.Return Then
    FileChooser1SelectPath(Last.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextPathGroup_Enter()
  
  Last.Background = F_iColorSelectGreen150
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextPathGroup_Leave()
  
  Last.Background = Color.Transparent
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileChooser1_Change() '/home/<user>/.config/gambas3/terminwecker.conf
  
  Dim sDirFile, sEmpty As String
  
  If F_bChangeON = True Then 
    sDirFile = FileChooser1.SelectedPath '.Multi = False, only one File
    If IsDir(sDirFile) = False And Exist(sDirFile) = True Then 
      If Stat(sDirFile).Size = 0 Or sDirFile <> TextBoxPath1.Text Then 
        If Stat(sDirFile).Size = 0 Then sEmpty = ("Leer")
        TextBoxPath2.SelectAll
        TextBoxPath2.Insert(sDirFile)
        LabelInfoG(sDirFile)
        ' CheckBoxesPath(LabelInfo.Tag, sDirFile)
      Endif 
    Endif 
    LabelInfo.Background = Color.Default
    If String.LCase(TextBoxPath2.Text) Like "*termin*.txt" Then 
      LabelPath2.Background = F_iColorSelectBackground
    Else 
      LabelPath2.Background = Color.Default
    Endif 
    If TextBoxPath2.Text <> F_sPath2Undo Then F_sPath2Redo = TextBoxPath2.Text
    ' PanelText5.Visible = False
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LoadPreview(Optional sDirFile As String = "")
  
  Dim sText As String 
  
  If Exist(sDirFile) = True Then 
    If Stat(sDirFile).Size > 1000000 Then 
      TextArea.SelectAll()
      Try TextArea.Insert("Große Datei")
      LabelTextCancel.Text = ("Zeilen") & ": " & "?" 
    Else 
      Try sText = File.Load(sDirFile)
      TextArea.SelectAll()
      Try TextArea.Insert(sText)
      If Stat(sDirFile).Size = 0 Then LabelTextCancel.Text = ("Leer") Else LabelTextCancel.Text = ("Zeilen") & ": " & Str(Split(sText, gb.NewLine).Max) 
      TextArea.EnsureVisible() 'aktuelle Position im sichtbaren Bereich
      M01Functions.isTerminweckerFile(sDirFile, True)    '(Path, MessageQuestionFalse) as Boolean  
    Endif 
  Else 
    LabelTextCancel.Text = ("Datei-Auswahl: Keine")
  Endif 
  If Exist(sDirFile) = True Then
    LabelText5Path.Text = sDirFile & Space(1) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & Space(1) & "<font color=blue>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Else 
    TextArea.Clear
    LabelText5Path.Text = ""
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonEditG()
  
  Form2Bearb.Window.Show
  ' Form2Bearb.Window.Visible = True  'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonDirAlternativeCopyG()
  
  Dim sDirSelect, sDirFile, sDirFileCopy, sDirBackup, sDirFileBackup, sDir, sDirStandard, sDirCurrent, sDirAlternative, sPathStandard, sPathActual, sPathAlternative As String 
  Dim sSelectColor, sText1, sPathLines, sRed, sStandardInfo, sMissing1, sMissing2, sFreeSpace1, sFreeSpace2, sMessage As String 
  Dim ssPathsCopy As String[]
  Dim it, iLine, iExistFiles, iFiles As Integer

  sSelectColor = "#" & Hex(Color.SelectedBackground, 6) 'Example: "#123456"

  sDirCurrent = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  sDirSelect = FileChooser1.Dir
  sDirAlternative = sDirSelect
  sDirStandard = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  sPathStandard = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt]
  sDirBackup = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
  
  ssPathsCopy = New String[]
  ssPathsCopy.Add(sPathStandard) 'not _oldyears.txt!
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathTerminweckerUntil_txt", FMain.F_sPathTerminweckerUntil_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathHolidaysPlus_txt", FMain.F_sPathHolidaysPlus_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt", FMain.F_sPathPhotoSubtitleDate_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathClockMuster_txt", FMain.F_sPathClockMuster_txt])
  ssPathsCopy.Add(Settings[FMain.Name &/ "F_sPathClockColors_txt", FMain.F_sPathClockColors_txt])
  sDirFile = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", FMain.F_sPathMusicStandard_mp3]
  If Exist(sDirFile) = True Then ssPathsCopy.Add(sDirFile)
  ssPathsCopy.Sort() '> .FindSorted()
  
  If String.InStr(sDirCurrent & "/", "/media/") = 0 Then
    sMessage = "<h2><font color=darkgreen>" & ("Ordner aktuell") & ":" & "</font></h2>"
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirCurrent) & "/" & "</font><font color=darkgreen>" & File.BaseName(sDirCurrent) & "</font></h3>" 
    sMessage &= "<br>" 
    sMessage &= "<h2><font color=" & sSelectColor & ">" & ("Ordner Auswahl") & ":" & "</font></h2>" 
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirSelect) & "/" & "</font><font color=#" & Hex(Color.SelectedBackground, 6) & ">" & File.BaseName(sDirSelect) & "</font></h3>" 
    sMessage &= "<br>"
    sMessage &= "<font color=gray>" & ("Ordner Auswahl alternativ: Einen anderen Ort wählen") & "<br>"
    sMessage &= ("(extern z.B. in media, Speicher USB-Stick)") & "</font>"
    sMessage &= "<h3><font color=gray>" & "○ " & "/" & "<font color=blue>" & "media" & "</font>" & "/..." & "</font></h3>"
    
    Select Case Message.Question(sMessage, "○ " & ("Ordner") & ": /media/...", ("Abbrechen"))
      Case 1
        sDir = FindDirFile("/media" &/ User.Name, Application.Name, 1) 'as String, with /media/
        If IsDir(sDir) = True Then FileChooser1.Dir = sDir Else FileChooser1.Dir = "/media" &/ User.Name 
      Case 2 
        ''...
    End Select
    
  Else 
    ' If File.BaseName(sDirAlternative) <> Application.Name Then sDirAlternative = sDirSelect &/ Application.Name
    ' sPathActual = FindDirFile(User.Home, Application.Name & ".txt", 3) 'as String, with /media/
    sPathActual = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
    sPathAlternative = File.SetDir(sPathActual, sDirAlternative)
        
    ''Dir:
    If IsDir(sDirCurrent) = True Then sFreeSpace1 = Space(1) & "<font color=gray>" & ("Frei") & ": " & M01Functions.FileSizeLongToText(Dfree(sDirCurrent)) & "</font>"
    If Stat(sDirCurrent).Size + 100 > Dfree(sDirAlternative) Then sRed = "red" Else sRed = "gray"
    If IsDir(sDirAlternative) = True Then sFreeSpace2 = Space(1) & "<font color=" & sRed & ">" & ("Frei") & ": " & M01Functions.FileSizeLongToText(Dfree(sDirAlternative)) & "</font>"
    
    If IsDir(sDirCurrent) = False Then sMissing1 = Space(1) & "<font color=red>" & ("Nicht gefunden") & "</font>"
    If IsDir(sDirAlternative) = False Then sMissing2 = Space(1) & "<font color=darkgreen>" & Application.Name & "</font>" & Space(1) & "<font color=red>" & ("als Unter-Ordner erstellen") & "</font>"
    If M01Functions.AccessDirFileReadWrite(sDirCurrent, 1) = False Then sMissing1 &= Space(1) & "<font color=gray>" & ("Zugriffsrechte? (Access)") & "</font>"
    If M01Functions.AccessDirFileReadWrite(sDirAlternative, 1) = False Then sMissing2 &= Space(1) & "<font color=gray>" & ("Zugriffsrechte? (Access)") & "</font>"
    If sDirCurrent = sDirStandard Then sStandardInfo = Space(1) & ("=") & Space(1) & ("Standard") Else sStandardInfo = ""
    
    sMessage &= "<h2><font color=gray>" & ("Kopieren, aktualisieren") & "</font></h2>"
    
    If sDirCurrent = sDirSelect Then 'A=B
      sMessage &= "<font color=gray>" & ("Von") & " A:" & "</font>" & "<br>" 
      sMessage &= "<h3><font color=gray>" & sDirCurrent & "</font>" & "</h3>" 
      sMessage &= "<br>"
      sMessage &= "<hr>" '———
      sMessage &= "<font color=gray>" & ("Nach") & " B:" & "</font>" & "<br>" 
      sMessage &= "<h3><font color=gray>" & sDirSelect & "</font>" & "</h3>" 
      sMessage &= "<br>" & "<br>" 
      sMessage &= ("Die Ordner sind identisch.") & "<br>" 
      sMessage &= ("B-") & ("Auswahl ändern.") & "</font>"
      sMessage &= "<h2><font color=black>" & ("Abbrechen") & "</font></h2>" 
      Message.Info(sMessage, ("Abbrechen"))
      Goto JumpEnd
    Endif
    
    sMessage &= "<font color=gray>" & ("Von") & " A:" & "</font>"
    sMessage &= "<h2><font color=darkgreen>" & "○ " & ("Ordner aktuell") & "</font></h2>"
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirCurrent) & "/" & "<font color=darkgreen>" & File.BaseName(sDirCurrent) & "</font>" & "/" & "</font><br>" & sMissing1 & sFreeSpace1 & "</h3>"
    If Exist(sPathActual) = True Then 
      sMessage &= sPathActual & "<br>"
      sMessage &= "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathActual) & "</font>" & Space(1) & "<font color=blue>" & M01Functions.FileSizeLongText(Stat(sPathActual).Size) & "</font>" & "<br>"
    Endif 
    sMessage &= "<br>" 
    sMessage &= "<hr>" '———
    sMessage &= "<font color=gray>" & ("Nach") & " B:" & "</font>"
    sMessage &= "<h2><font color=" & sSelectColor & ">" & "● " & ("Ordner alternativ") & "</font></h2>"
    sMessage &= "<h3><font color=gray>" & File.Dir(sDirSelect) & "/" & "<font color=" & sSelectColor & ">" & File.BaseName(sDirSelect) & "</font>" & "/" & "</font><br>" & sMissing2 & sFreeSpace2 & "</h3>"
    If Exist(sPathAlternative) = True Then 
      sMessage &= sPathAlternative & "<br>"
      sMessage &= "<font color=" & sSelectColor & ">" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPathAlternative) & "</font>" & Space(1) & "<font color=blue>" & M01Functions.FileSizeLongText(Stat(sPathAlternative).Size) & "</font>" & "<br>" & "<br>"
    Endif 
    
    ''Exist Files?
    If Exist(sPathAlternative) = True Then 
      sPathLines = ""
      iFiles = 0
      If ssPathsCopy Then 
        For Each sDirfile In ssPathsCopy
          If Exist(sDirFile) = True Then iExistFiles = iExistFiles + 1
          sDirFileCopy = File.SetDir(sDirfile, sDirAlternative)
          If Exist(sDirFileCopy) = True Then 
            sPathLines &= "<font size=1 color=red>" & File.Name(sDirFileCopy) & Space(1) & M01Functions.FileLastModifiedText(sDirFileCopy) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileCopy).Size) & "</font><br>"
            iFiles = iFiles + 1
          Else 
            sPathLines &= "<font size=1 color=" & sSelectColor & ">" & File.Name(sDirFileCopy) & "</font><br>"
          Endif
        Next
      Endif 
    Endif 
    sMessage &= "<font size=4 color=blue><b>" & iExistFiles & Space(1) & ("Dateien kopieren") & "</b></font><br>"
    If iFiles > 0 Then 
    sMessage &= "<font size=4 color=red><b>" & iFiles & "</b></font><font size=4 color=" & sSelectColor & "><b>" & Space(1) & ("von") & Space(1) & iExistFiles & Space(1) & "</b></font><font size=4 color=red><b>" & ("überschreiben, aktualisieren") & "</b></font><br>"
    Endif 
    sMessage &= sPathLines
    sMessage &= "<font color=gray>" & ("Tipp: Siehe Sicherungskopien im Ordner") & Space(1) & sDirBackup & "</font>"
    
    Select Case Message.Question(sMessage, "● " & ("Kopieren nach Ordner B"), ("Ordner..."), ("Abbrechen"))
      Case 1
        '........................................................................................
        ''Directory?
        If IsDir(sDirBackup) = False Then M01Functions.CheckDirAppName()
        If IsDir(File.Dir(sDirAlternative)) = True And IsDir(sDirAlternative) = False Then Try Mkdir sDirAlternative
        If IsDir(sDirAlternative) = True Then 
          ''Backup?
          If Exist(sPathAlternative) = True Then 
            sDirFile = M01Functions.FileBackupPathName(sPathAlternative)
            If IsDir(sDirBackup) = True Then Try Copy sPathAlternative To sDirfile 'Backup
          Endif 
        Endif
        ''Copy
        If Exist(sPathActual) = True Then 
          sDir = sDirCurrent
          sText1 = ""
          If ssPathsCopy Then 
            For Each sDirfile In ssPathsCopy
              iLine = iLine + 1
              If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
              ''[ESC]?
              If F_bESCpressedON = True Then 
                If MessageQuestionBreak() = True Then Break
              Endif 
              
              sDirFileCopy = File.SetDir(sDirfile, sDirAlternative)

              ''Exist? Backup first
              If Exist(sDirFile) = True And Exist(sDirFileCopy) = True Then 
                sDirFileBackup = M01Functions.FileBackupPathName(sDirFileCopy)
                Try Copy sDirFile To sDirFileBackup
              Endif 
              ''Copy
              If Exist(sDirFile) = True Then Try Copy sDirfile To sDirFileCopy
              If Exist(sDirFileCopy) = True Then 
                it = it + 1
                If it < 15 Then 
                  If String.InStr(FMain.F_sFilesChangedList, sDirfile) = 0 Then FMain.F_sFilesChangedList &= sDirFile
                  If String.InStr(FMain.F_sFilesChangedList, sDirFileCopy) = 0 Then FMain.F_sFilesChangedList &= sDirFileCopy
                  sText1 &= "<font color=gray>" & File.Name(sDirFileCopy) & "</font>" & Space(1) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileCopy) & "</font>" & Space(1) & "<font color=blue>" & M01Functions.FileSizeLongText(Stat(sDirFileCopy).Size) & "</font>" & "<br>"
                Else If it = 15 Then 
                  sText1 &= "..." & "<br>"
                Endif 
              Endif 
            Next
          Endif 
        Endif 
        
        ''Show
        If IsDir(sDirAlternative) = True Then FileChooser1.Dir = sDirAlternative
        If Exist(sPathAlternative) = True Then 
          FileChooser1.Reload()
          FileChooser1.FileView.Current = File.Name(sPathAlternative)
          CheckPathStandard1Alternative2(2)
        Endif 
        
        sMessage = "<h3><font color=gray>" & File.Dir(sDirAlternative) & "/" & "</font><font color=blue>" & File.BaseName(sDirAlternative) & "/..." & "</font></h3>"
        sMessage &= "<h3><font color=blue>" & ("Kopierte Dateien") & ": " & Str(it) & Space(1) & ("von") & Space(1) & Str(iExistFiles) & "</font></h3>"
        
        If sText1 Then sMessage &= "<font color=gray>" & sText1 & "</font>"
        
        Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
          Case 1
            M01Functions.FileManagerOpen(sPathAlternative)
          Case 2 'Cancel 
            '...
        End Select
        '........................................................................................ 
        
      Case 2
        M01Functions.FileManagerOpen(sPathActual)
      Case 3 'Cancel
        'Reset
        TextBoxPath2.SelectAll()
        TextBoxPath2.Insert(File.SetDir(sPathStandard, sDirCurrent))
    End Select
  Endif 
  JumpEnd:
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonReadG()
  
  Dim sPath As String
  
  ButtonRead.Background = Color.Green 
  sPath = FileChooser1.SelectedPath
  If Exist(sPath) = True Then 
    Form3Text.Tag = sPath
    Form3Text.Window.Show
    ' Form3Text.Window.Visible = True  'Wayland error?
    Form3Text.SetFocus
  Else
    LabelInfoG(("Eine Datei auswählen"))
  Endif
  Wait 0.5
  ButtonRead.Background = Color.Default 
  
Catch 
  FMain.ErrorText
  ButtonRead.Mouse = Mouse.Pointing
  
End

Public Sub StandardPathG()
  
  Dim sPath As String 
  
  FileChooser1.FilterIndex = 0 ' Nur-Text *.txt, -1 all files
  sPath = FMain.F_sPathTerminweckerStandard_txt
  If Exist(sPath) = True Then 
    FileChooser1SelectPath(sPath)
  Else
    LabelInfoG(sPath & " ? " & "<font color=red>" & ("Datei nicht gefunden") & "</font>")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG(Optional sPath As String = "")
  
  Form19FileInfo.Tag = sPath
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End 

Public Sub SearchG(Optional sPath As String = "")
  ' Try Shell "exo-open --launch FileManager" & Space(1) & TextBoxPath1.Text 'Typ: FileManager, WebBrowser,... - Die bevorzugten Programme (System).
  
  If Exist(sPath) = False Then sPath = File.Dir(sPath)
  If Exist(sPath) = False Then sPath = FilePathForm()
  If Exist(sPath) = False Then sPath = User.Home
  M01Functions.FileManagerOpen(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form1FileOpen.Window.Maximized = Not Form1FileOpen.Window.Maximized 
  If Form1FileOpen.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form1FileOpen.Window.FullScreen = True Or Form1FileOpen.Window.Maximized = True Then 
      F_bMovingON = False
      Form1FileOpen.Window.FullScreen = False
      Form1FileOpen.Window.Maximized = False
      If Form1FileOpen.Left + Form1FileOpen.W > Screen.AvailableWidth Then Form1FileOpen.Move(Form1FileOpen.Left, Form1FileOpen.Top, Screen.AvailableWidth - Form1FileOpen.Left, Screen.AvailableHeight - Form1FileOpen.Top)
    Else
      F_bMovingON = True
      Form1FileOpen.Window.FullScreen = False
      Form1FileOpen.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form1FileOpen.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form1FileOpen.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form1FileOpen.ClientW - WindowStretch.W, Form1FileOpen.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form1FileOpen.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form1FileOpen.W = Mouse.ScreenX - F_iX1
    Form1FileOpen.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form1FileOpen.ClientW - WindowStretch.W, Form1FileOpen.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form1FileOpen.ClientW - WindowStretch.W, Form1FileOpen.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form1FileOpen.Window.Maximized = Not Form1FileOpen.Window.Maximized 
    If Form1FileOpen.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form1FileOpen.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
  ' MoveLine.Cursor = New Cursor(Picture["images/size_32.png"].Image.Stretch(MoveLine.H, MoveLine.H).RotateLeft().Picture, 0, 0)
  ' MoveLine.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoG(Optional sInfoText As String = "") '<HTML>
  
  Dim sDirFile, sEmpty, sHTMLspace As String 
  
  sDirFile = sInfoText
  If Exist(sDirFile) = True Then
    sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html  (no break space)
    If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>"
    sInfoText = File.Name(sDirFile) & String(3, sHTMLspace) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & sEmpty
  Endif 
  
  LabelInfo.Visible = True 
  If sInfoText Then
    If Exist(sDirFile) = True Then
      LabelInfo.Text = ("Info") & ": " & Space(1) & sInfoText
    Else 
      LabelInfo.Text = ("Info") & ": " & Space(1) & sInfoText & Space(1) & "<font color=red>" & ("Fehlt") & "</font>"
    Endif 
    LabelInfo.Background = F_iColorSelectBackground
  Else 
    LabelInfo.Text = sInfoText
    LabelInfo.Background = Color.Default
  Endif 
  LabelInfo.Raise() 'Top
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoPath2G(Optional sDirFile As String = Null) '<HTML>
  
  Dim sEmpty As String 
  
  If Exist(sDirFile) = False Then sDirFile = TextBoxPath2.Text
  If Exist(sDirFile) = True Then
    If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>"
    LabelInfoPath2.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & sEmpty
    LabelInfoPath2.Visible = True 
    LabelInfoPath2.Raise()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoPath1G(Optional sDirFile As String = Null) '<HTML>
  
  Dim sEmpty As String 
  
  If Exist(sDirFile) = False Then sDirFile = TextBoxPath1.Text
  If Exist(sDirFile) = True Then
    If Stat(sDirFile).Size = 0 Then sEmpty = Space(1) & "<font color=red><b>" & ("Leer") & "</b></font>"
    LabelInfoPath1.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & sEmpty
    LabelInfoPath1.Visible = True 
    LabelInfoPath1.Raise()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() '▼Bottom▼
  LabelBGCheckBoxtxt.Lower()
  LabelCheckFilterTxt.Raise()
  LabelInfoPath2.Raise()
  LabelInfoPath1.Raise()
  PanelText5.Raise()
  LabelTextCancel.Raise()
  WindowStretch.Raise() '▲Top Level▲
  IconError.Raise()
  ProgressBar1.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckPathStandard1Alternative2(Optional iCheckPath As Integer = 2)
  
  Select Case iCheckPath
    Case 2
      F_bChangeON = False
      F_iCheckPathON = 2
      CheckONoff()
      If Exist(TextBoxPath2.Text) = True And FileChooser1.SelectedPath <> TextBoxPath2.Text Then
        FileChooser1SelectPath(TextBoxPath2.Text)
      Endif 
      CheckBoxesPath(LabelInfoPath2.Tag, TextBoxPath2.Text)
      F_bChangeON = True 
      
    Case 1
      F_bChangeON = False
      F_iCheckPathON = 1
      CheckONoff()
      If Exist(TextBoxPath1.Text) = True And FileChooser1.SelectedPath <> TextBoxPath1.Text Then 
        FileChooser1SelectPath(TextBoxPath1.Text)
      Endif 
      CheckBoxesPath(LabelInfoPath1.Tag, TextBoxPath1.Text)
      F_bChangeON = True 
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckONoff() '—▶ F_iCheckPathON
  
  Select Case F_iCheckPathON
    Case 2
      CheckBoxFilePath2.Picture = PicTemplateCheckON.Picture
      CheckBoxFilePath1.Picture = PicTemplateCheckoff.Picture
      
    Case 1
      CheckBoxFilePath2.Picture = PicTemplateCheckoff.Picture
      CheckBoxFilePath1.Picture = PicTemplateCheckON.Picture
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxesPath(Optional sLabelTagInfoPath2Path1 As String, Optional sPath As String)
  
  Dim sSizeText, sHTMLspace As String 
  
  sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html  (no break space)
  LabelInfoG("") 'empty, Reset
  LabelPath2.Background = Color.Default 
  
  Select Case sLabelTagInfoPath2Path1
      
    Case LabelInfo.Tag, "info" 
      If Exist(sPath) = True And String.LCase(File.Ext(sPath)) = "txt" Then 
        LabelInfo.Background = F_iColorSelectBackground
        If M01Functions.isTerminweckerFile(sPath) = False Then '(Path, MessageQuestionFalse) as Boolean 
          sSizeText = "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font>"
          LabelInfoG(File.Name(sPath) & String(3, sHTMLspace) & "<font color=red><b>" & ("Keine Datei mit Terminen?") & "</b></font>" & String(3, sHTMLspace) & sSizeText) 'True > KiB .FormatSize needs component gb.util
        Else 
          If String.LCase(File.Name(sPath)) Like "*termin*.txt" Then 
            sSizeText = "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font>"
            LabelInfoG(File.Name(sPath) & String(3, sHTMLspace) & String(3, sHTMLspace) & sSizeText)
            LabelPath2.Background = F_iColorSelectBackground
          Else 
            LabelInfoG(File.Name(sPath) & String(3, sHTMLspace) & "<font color=blue><b>" & ("Lesbare Termine, keine Datei terminwecker*.txt") & "</b></font>")
          Endif 
        Endif 
      Else '*.png...
        LabelInfoG(File.Name(sPath) & String(3, sHTMLspace) & "<font color=red><b>" & ("Keine Text-Datei *.txt") & "</b></font>")
        ' PanelText5.Visible = False
      Endif 
      LabelInfo.Tooltip = sPath
      LabelInfoPath2.Visible = False 
      LabelInfoPath1.Visible = False 
      
    Case LabelInfoPath2.Tag, "infopath2" 
      If Exist(sPath) = True And String.LCase(File.Ext(sPath)) = "txt" Then 
        TextBoxPath2.Foreground = Color.DarkGreen
        If Stat(sPath).Size = 0 Or M01Functions.isTerminweckerFile(sPath) = False Then '(Path, MessageQuestionFalse) as Boolean  
          sSizeText = "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font>"
          LabelInfoPath2G(("Keine Datei mit Terminen?") & Space(3) & sSizeText) 'True > KiB .FormatSize needs component gb.util
          TextBoxPath2.Foreground = Color.Red 
        Else 
          LabelInfoPath2G("<font color=darkgreen>" & File.Name(sPath) & "</font>")
          LabelPath2.Background = F_iColorSelectBackground 
        Endif  
      Else 
        LabelInfoPath2G("<font color=red><b>" & ("Keine Text-Datei *.txt") & "</b></font>")
        TextBoxPath2.Foreground = Color.Red 
      Endif 
      LabelInfoPath2.Visible = True 
      LabelInfoPath1.Visible = False 
      LabelInfoPath2.Background = F_iColorSelectBackground
      LabelInfoPath1.Background = F_iColorSelectBackground
      LabelPath2.Tooltip = sPath
      F_iCheckPathON = 2 '—▶Alternativ
      
    Case LabelInfoPath1.Tag, "infopath1" 
      If Exist(sPath) = True And String.LCase(File.Ext(sPath)) = "txt" Then  
        TextBoxPath1.Foreground = Color.DarkGreen
        If Stat(sPath).Size = 0 Or M01Functions.isTerminweckerFile(sPath) = False Then '(Path, MessageQuestionFalse) as Boolean  
          sSizeText = "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font>"
          LabelInfoPath1G(("Keine Datei mit Terminen?") & Space(3) & sSizeText) 'True > KiB .FormatSize needs component gb.util
          TextBoxPath1.Foreground = Color.Red 
        Endif 
      Else 
        LabelInfoPath1G("<font color=red><b>" & ("Keine Text-Datei *.txt") & "</b></font>")
        TextBoxPath1.Foreground = Color.Red 
      Endif 
      LabelInfoPath2.Visible = False 
      LabelInfoPath1.Visible = True 
      LabelInfoPath2.Background = F_iColorSelectBackground
      LabelInfoPath1.Background = F_iColorSelectBackground
      LabelPath1.Tooltip = sPath
      F_iCheckPathON = 1 '—▶Standard
      
  End Select
  
  If F_iCheckPathON = 1 And Exist(sPath) = False Then LabelInfoG(("Siehe >home>Startseite, Desktop, System, Lesezeichen..."))
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_Enter()
  
  LabelInfoPath2.Visible = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1ShowOnOff()
  
  If PanelBookMark.Visible = False Then 
    PicBoxBookmarkList.Picture = PicTemplateArrowSelectDown.Picture
    PanelBookMark.Visible = True
    ' ColumnView1LoadBookmarks()
    ColumnView1BookmarksOpenSaveReload("start")
    PanelBookMark.Raise()
  Else 
    PicBoxBookmarkList.Picture = PicTemplateArrowSelectUp.Picture
    If F_bBookmarkChanged = True Then ColumnView1BookmarksOpenSaveReload("save") 'ColumnView1Save()
    ColumnView1.Clear()
    PanelBookMark.Visible = False
    If IsDir(F_sDirBookmarkLast) = True Then FileChooser1.Dir = F_sDirBookmarkLast
  Endif 
      
  Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Select Case Object.Type(Last) 
      
    Case "TextBox"
      Last.Border = True 
      Last.Background = Color.Default
      
    Case "Button"
      Last.Border = True 
      If String.InStr(Last.Tag, "pastepath") > 0 Then Last.ToolTip = ("Einfügen >") & Space(5) & FileChooser1.SelectedPath
      If Last.Tag = ButtonApply.Tag Then 
        If F_iCheckPathON = 1 Then PanelPath1.Background = F_iColorSelectBackground Else PanelPath2.Background = F_iColorSelectBackground
        PanelInfo.Background = Color.Default
        ' PanelText5.Visible = False
      Endif 
      If Last.Tag = ButtonRead.Tag Then ButtonRead.Tooltip = FileChooser1.SelectedPath
      If Last.Tag = ButtonRead.Tag Then PanelInfo.Background = F_iColorSelectBackground
      ' If Last.Tag = ButtonTextAreaCancel.Tag Then Last.Background = Color.Green
      
    Case "Label", "TextLabel"
      Select Case Last.Tag
        Case LabelInfoPath2.Tag, LabelInfoPath1.Tag
          Last.Visible = False
        Case LabelCheckFilterTxt.Tag 
          FileChooser1.FileView.Background = F_iColorSelectGreen150
          Last.Background = F_iColorSelectGreen150 
        Case Else 
          Last.Background = F_iColorSelectGreen150 
      End Select
      
    Case "PictureBox" 'Check
      If Last.Tag = CheckBoxFilePath2.Tag Then PanelPath2.Background = F_iColorSelectGreen150
      If Last.Tag = CheckBoxFilePath1.Tag Then PanelPath1.Background = F_iColorSelectGreen150
      If Last.Tag = PicBoxSearch2.Tag Or Last.Tag = PicBoxFileInfo2.Tag Then PanelPath2.Background = F_iColorSelectGreen150
      If Last.Tag = PicBoxSearch1.Tag Or Last.Tag = PicBoxFileInfo1.Tag Then PanelPath1.Background = F_iColorSelectGreen150
      If Last.Tag = ReloadPath2.Tag Then Last.Background = F_iColorSelectGreen150
      If Last.Tag = LabelCheckFilterTxt.Tag Then Last.Background = F_iColorSelectGreen150
      If Last.Tag = ListAplus.Tag Then Last.Background = F_iColorSelectGreen150
      If Last.Tag = PicBoxBookmark.Tag Then PanelInfo.Background = F_iColorSelectBackground
      If Last.Tag = PicBoxBookmark.Tag Then LabelInfoG(FileChooser1.SelectedPath)
      If Last.Tag = PicBoxBookmark.Tag Then FileChooser1.DirView.Background = F_iColorSelectGreen150
      If Last.Tag = CheckBoxFilePath2.Tag Then LabelInfoG(TextBoxPath2.Text) 'LabelInfoPath2G()
      If Last.Tag = CheckBoxFilePath1.Tag Then LabelInfoG(TextBoxPath1.Text) 'LabelInfoPath1G()
      If Last.Tag = PicBoxFileInfo2.Tag Then LabelInfoPath2G()
      If Last.Tag = PicBoxFileInfo1.Tag Then LabelInfoPath1G()
      If Last.Tag = PicBoxTrashOpen.Tag Then Last.Background = F_iColorSelectGreen150
      If Last.Tag = PicBoxBookmarkList.Tag Then PanelPath2.Background = F_iColorSelectGreen150
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  Select Case Object.Type(Last) 
      
    Case "TextBox" 
      Last.Border = False 
      Last.Background = Color.Transparent
      
    Case "Button"
      Last.Border = False 
      If Last.Tag = ButtonApply.Tag Then 
        PanelPath2.Background = Color.Default 
        PanelPath1.Background = Color.Default 
      Endif
      
    Case "Label", "TextLabel"
      Select Case Last.Tag
        Case LabelInfoPath2.Tag, LabelInfoPath1.Tag
          Last.Visible = False
        Case LabelCheckFilterTxt.Tag 
          FileChooser1.FileView.Background = Color.Default 
          Last.Background = Color.Default 
        Case Else 
          Last.Background = Color.Default 
      End Select
      
    Case "PictureBox" 'Check
      If Last.Tag = CheckBoxFilePath2.Tag Then PanelPath2.Background = Color.Default
      If Last.Tag = CheckBoxFilePath1.Tag Then PanelPath1.Background = Color.Default
      If Last.Tag = PicBoxSearch2.Tag Or Last.Tag = PicBoxFileInfo2.Tag Then PanelPath2.Background = Color.Default 
      If Last.Tag = PicBoxSearch1.Tag Or Last.Tag = PicBoxFileInfo1.Tag Then PanelPath1.Background = Color.Default 
      If Last.Tag = PicBoxBookmark.Tag Then FileChooser1.DirView.Background = Color.Default 
      If Last.Tag = CheckBoxFilePath2.Tag Then LabelInfoPath2.Visible = False
      If Last.Tag = CheckBoxFilePath1.Tag Then LabelInfoPath2.Visible = False
      If Last.Tag = PicBoxFileInfo2.Tag Then LabelInfoPath1.Visible = False
      If Last.Tag = PicBoxFileInfo1.Tag Then LabelInfoPath1.Visible = False
      If Last.Tag = PicBoxTrashOpen.Tag Then Last.Background = Color.Default 
      PanelInfo.Background = Color.Default
      Last.Background = Color.Default
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  Dim sHTMLspace, sDirFile As String 
  
  F_bESCpressedON = False
  
  sHTMLspace = "&nbsp;" 'Leerzeichen 1x in html  (no break space)
  
  F_bChangeON = True 'Reset
  
  Select Case String.LCase(sLastTag)
    Case "menu"
      Menu1.Popup()
      
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    
    Case "cancelform"
      Form1FileOpen.Window.Close
    
    Case "pathled"
      M01Functions.FileManagerOpen(TextBoxBookmarkPath.Text)
      
    Case "edit" '+Bearbeiten...
      ButtonEditG()
      
    Case "diralternativecopy"
      ButtonDirAlternativeCopyG()
      
    Case "apply"
      ButtonApplyG()
      
    Case "dirapply"
      F_sDirBookmarkLast = TextBoxBookmarkPath.Text
      If IsDir(F_sDirBookmarkLast) = True Then FileChooser1.Dir = F_sDirBookmarkLast
      ColumnView1ShowOnOff()
      
    Case "read"
      ButtonReadG()
      
    Case "reloadpath2"
      PanelPath2.Background = F_iColorSelectGreen150
      ReloadPath2Alternative()
      Wait 0.5
      PanelPath2.Background = Color.Default
      
    Case "standardpath"
      StandardPathG()
      
    Case "checkfiltertxt", LabelCheckFilterTxt.Tag
      If F_iFilterIndex = 0 Then F_iFilterIndex = 1 Else F_iFilterIndex = 0 '0=*.* All files, 1=*.txt
      CheckBoxtxtG()
      
    Case "bookmarkaddline", ButtonBookmarkAddLine.Tag 
      ColumnViewAdd()     
      
    Case "bookmarkcutadd", PicBoxBookmark.Tag
      ColumnView1BookmarkRemoveAdd()
      
    Case "bookmarklistcancel", ButtonCancelBookmark.Tag
      ColumnView1ShowOnOff()
      
    Case "bookmarkdir"
      sDirFile = Settings[FMain.Name &/ "F_sPathBookmarks_txt", FMain.F_sPathBookmarks_txt]
      If Exist(sDirFile) = True Then
        M01Functions.FileManagerOpen(sDirFile)
      Else 
        If IsDir(sDirFile) = True Then 
          M01Functions.FileManagerOpen(sDirFile)
        Else
          M01Functions.FileManagerOpen(TextBoxPath2.Text)
        Endif 
      Endif 
      
    Case "bookmarkcut"
      ColumnView1Cut(False)
      
    Case "bookmarkcutall"
      ColumnView1Cut(True)
      
    Case "bookmarkinsertline", ButtonBookmarkInsertLine.Tag 
      ColumnView1InsertLine()
      
    Case "bookmarkup"
      ColumnViewUp()
      
    Case "bookmarkdown"
      ColumnViewDown()
    
    Case "savebookmarks", ButtonSaveBookmarks.Tag
      ' ColumnView1Save()
      ColumnView1BookmarksOpenSaveReload("save")
      
    Case "openbookmarks", ButtonOpenBookmarks.Tag
      ColumnView1BookmarksOpenSaveReload("open")
      
    Case "reloadbookmarks"
      ColumnView1BookmarksOpenSaveReload("reload")
      
    Case "checkfilepath2", CheckBoxFilePath2.Tag
      CheckPathStandard1Alternative2(2)
      
    Case "checkfilepath1", CheckBoxFilePath1.Tag
      CheckPathStandard1Alternative2(1)
      
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "dirstandard"
      DirStandardAlternative(True)
      
    Case "diralternative"
      DirStandardAlternative(False)
      
    Case "path2", LabelPath2.Tag
      F_bChangeON = False 
      FileChooser1SelectPath(TextBoxPath2.Text)
      If Exist(TextBoxPath2.Text) = False Then LabelInfoG(LabelPath2.Text & String(2, sHTMLspace) & ("Datei nicht gefunden"))
      F_bChangeON = True 
      
    Case "path1", LabelPath1.Tag
      F_bChangeON = False
      FileChooser1SelectPath(TextBoxPath1.Text)
      If Exist(TextBoxPath1.Text) = False Then LabelInfoG(LabelPath1.Text & String(2, sHTMLspace) & ("Datei nicht gefunden"))
      F_bChangeON = True 
      
    Case "fileinfo2"
      FileInfoG(TextBoxPath2.Text)
      
    Case "fileinfo1"
      FileInfoG(TextBoxPath1.Text)
      
    Case "search2"
      SearchG(TextBoxPath2.Text)
      
    Case "search1"
      SearchG(TextBoxPath1.Text)
      
    Case "aplus" 'A+, A-
      If FileChooser1.Font.Size < 16 Then 
        FileChooser1.Font.Size = 16 
      Else 
        FileChooser1.Font.Size = 12
      Endif 
      AplusG()
      
    Case "text5resize"
      If PanelText5.Visible = True Then 
        PanelText5.Visible = False 
        TextArea.SelectAll()
        TextArea.Insert("")
      Else 
        PanelText5.Visible = True 
      Endif 
      LoadPreview(FileChooser1.SelectedPath)
      Text5Resize()
      
    Case "text5path"
      M01Functions.FileManagerOpen(FileChooser1.SelectedPath)
      
    Case "textareacancel"
      PanelText5.Visible = False
      Text5Resize()
      
    Case "trashopen"
      M01Functions.ExternTrash()
      
    Case "findlatestfile"
      FindLatestFile()
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "cancel"
      Form1FileOpen.Window.Close
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End '...............................





Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form6Einst.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form6Einst.class
64,7 KB
' Gambas class file

Public F_bChangedON As Boolean
Public F_bClockAlarmBeforeBehindON As Boolean
Public F_bClockAlarmBeforeBehindUndo As Boolean
Public F_bCheckBoxAluWood As Boolean
Public F_bCheckBoxBG1 As Boolean
Public F_bCheckBoxBG2 As Boolean
Public F_bCheckBoxBGColor As Boolean
Public F_bCheckBoxLastBackup As Boolean
Public F_bCheckBoxQKW As Boolean
Public F_bCheckBoxShowPath As Boolean
Public F_bCheckBoxYear As Boolean
Public F_bCheckUpdateInternetDaily As Boolean
Public F_bMovingON As Boolean
Public F_bPlusAlarmChanged As Boolean
Public F_iBackgroundUndo As Integer
Public F_iColorPackage As String 
Public F_iColorSelectBlue150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorSelectGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelectRed150 As Integer = Color.SetAlpha(Color.Red, 150)
Public F_iOnly1x As Integer
Public F_iVorNachweckzeit30Undo As Integer
Public F_iVorNachweckzeit60Undo As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sDirFileBackupConf As String
Public F_sForm As String = Me.Name 
Public F_sPathText As String 
Public F_sTimeZone As String

Public Function FilePathForm() As String 
  
  Return Settings[FMain.Name &/ "F_sPathSettings_conf", Settings.Path]
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
  '* or (oder):
  'ButtonClose.Cancel = True 
  'ButtonClose.Default = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  PanelConfig.Visible = False
  PanelText.Visible = False
  ScrollViewBorder.Visible = True  
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form6Einst.Window.Maximized = False Then
    Form6Einst.Window.Maximized = True
  Else
    Form6Einst.Window.Maximized = False
    Form6Einst.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End
' Public Sub ShowASpecialSetting() 'Gambas3
'   Dim prhOtherConfFile As Settings
'   Dim prhLangUsed As String
' 
'   ' Read a setting from a file used by another application
'   ' located in /home/user/.config/otherapp/
'   ' and named "international.conf"
'   'First create a new instance of Settings class
'   'with the full path to desired file
'   prhOtherConfFile = New Settings("/home/user/.config/otherapp/international.conf")
'   'next read the "Lang1" value from the "UserPreferences" section
'   prhLangUsed = prhOtherConfFile["UserPreferences/Lang1", Null]
'   If IsNull(prhLangUsed) Then
'     Message.Info("No Lang1 found in conf file (or no Section named UserPreferences)")
'   Else
'     Message.Info("The value of Lang1 that found in conf file is:\n" & prhLangUsed)
'   End If
' End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    ButtonClose.Border = True
    Form_Resize()
    F_bChangedON = True
    FormStart()
    ' FMain.Minimized = True 
    ' Form6Einst.Visible = True 
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim iDiffMinutes As Integer
  Dim sPath, sText, sDiff As String 
  
  LabelTitleB.Font = LabelTitleA.Font
  ' PanelBorder.Tablet = True 'Gambas3: (gb.qt4) Return or set if the ScrollArea will receive tablet events as mouse events.
  
  ' CheckG() 'Color/Wood/Metal
  F_iColorPackage = TextAreaConfig.Background
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", "?"]
  LabelPathB.ToolTip = ("Datei") & ": " & sPath
  sText = ("Datei-Pfad") & ": " & gb.NewLine 
  sText &= sPath & gb.NewLine & gb.NewLine 
  sText &= ("Programm-Pfad") & ": " & gb.NewLine 
  sText &= Application.Path & gb.NewLine
  F_sPathText = sText 
  
  If Component.IsLoaded("gb.util") Then 
    iDiffMinutes = DateDiff(Date.ToUTC(Now), Now, gb.Minute) ' neu in Gambas3, Date.ToUTC needs component: gb.util
  Else 
    iDiffMinutes = System.TimeZone 'as Integer, Component (gb) = Basis Example: "UTC+2", System.TimeZone will Return -7200.
    'Format(Now, "tt") ' Gambas3: "tt" Print the timezone in HHMM format. SEIT 3.1
  Endif 
  If iDiffMinutes < 0 Then sDiff = "" Else sDiff = "+"
  
  sText = ("UTC (koordinierte Weltzeit), Bezugspunkt = 0") & gb.NewLine
  sText &= ("MEZ (Mitteleuropäische Zeit) = +1") & gb.NewLine
  sText &= ("MESZ (Mitteleuropäische Sommerzeit) = +2") & gb.NewLine
  sText &= ("MESZ = UTC+2") & gb.NewLine
  sText &= ("Aktuelle Zeitzone") & ": " & ("UTC") & sDiff & Format(iDiffMinutes / 60, "0") & Space(1) & ("Stunde(n)") & gb.NewLine
  F_sTimeZone = sText 
  
  If F_bChangedON = True 
    TextArea1.SelectAll()
    TextArea1.Insert(F_sPathText & gb.NewLine & F_sTimeZone)
    
    LabelUpdate.Tooltip = LabelUpdate.Tooltip & Space(1) & Quote(("Nur Versionsnummer")) & gb.NewLine & ("Inhalt") & ": " & Quote("0.0.000") & gb.NewLine & ("Installierte Version") & ": " & Quote(Application.Version) & gb.NewLine & CheckBoxUpdate.Tooltip
    
    LabelMusicTitle()
    CheckMusicON()
    WindowStretchCursor()
    If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
    CheckClockAlarmButtonNoteOnOff()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  
  Form6Einst.Title = Application.Name & " - " & ("Einstellungen")  
  If Not Form6Einst.Window.Icon Then Form6Einst.Window.Icon = FMain.Window.Icon
  
  SettingsReadSave("read")
  CheckG() 'Color/Wood/Metal
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  If F_bPlusAlarmChanged = True Then PlusAlarmChangedAccept()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form6Einst.Left]
      iY = Settings[F_sForm &/ "Top", Form6Einst.Top]
      iW = Settings[F_sForm &/ "Width", 500]
      iH = Settings[F_sForm &/ "Height", 800]
      Form6Einst.Move(iX, iY, iW, iH)
      F_bClockAlarmBeforeBehindON = Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON", True] 'Vorweckzeit, Alarm before
      ValueBoxVorweckzeit60.Value = Settings[FMain.Name &/ "F_iVorNachweckzeit60", -60]
      ValueBoxVorweckzeit30.Value = Settings[FMain.Name &/ "F_iVorNachweckzeit30", -30]
      F_bClockAlarmBeforeBehindUndo = F_bClockAlarmBeforeBehindON
      F_iVorNachweckzeit60Undo = ValueBoxVorweckzeit60.Value
      F_iVorNachweckzeit30Undo = ValueBoxVorweckzeit30.Value
      
    Case "s"
      'Save window settings when application closes
      Settings[F_sForm &/ "Top"] = Form6Einst.Top
      Settings[F_sForm &/ "Left"] = Form6Einst.Left
      Settings[F_sForm &/ "Height"] = Form6Einst.Height
      Settings[F_sForm &/ "Width"] = Form6Einst.Width

  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub PlusAlarmChangedAccept()
  
  Dim sMessage, sPath, sCheck As String 
  
  If F_bClockAlarmBeforeBehindON = True Then 
    ' sPath = "images/checkon_32.png"
    If Exist(sPath) = True Then sCheck = "<img src=" & sPath & ">" Else sCheck = "■ " 
    sCheck = "<font color=darkgreen>" & sCheck & ("Eingeschaltet") & "</font>"
  Else 
    ' sPath = "images/checkoff_32.png"
    If Exist(sPath) = True Then sCheck = "<img src=" & sPath & ">" Else sCheck = "□ " 
    sCheck = "<font color=red>" & sCheck & ("Ausgeschaltet") & "</font>"
  Endif 
  
  sMessage = "<h3><font color=gray>" & ("Bestätigen") & "</font>" & "</h3>"
  sMessage &= "<h2><font color=blue>" & sCheck & "</font></h2>"
  sMessage &= "<h4><font color=blue>" & LabelVorweckzeit.Text & "</font></h4>"
  sMessage &= "<h2><font color=blue>" & ValueBoxVorweckzeit60.Value & "</font></h2><h4>" & Space(1) & ValueBoxVorweckzeit60.Tooltip & "</h4>"
  sMessage &= "<h2><font color=blue>" & ValueBoxVorweckzeit30.Value & "</font></h2><h4>" & Space(1) & ValueBoxVorweckzeit30.Tooltip & "</h4>"
  sMessage &= "<font color=gray>" & ("Plus-Alarm nachher") & Space(1) & ("(Termin überschritten)") & ". " & ("Beispiel: 5") & "</font><br>"
  
  Select Case Message.Question(sMessage, ("Bestätigen"), ("Nein"), ("Abbrechen"))
    Case 1 'Accept
      FMain.F_bClockAlarmBeforeBehindON = F_bClockAlarmBeforeBehindON
      FMain.F_iVorNachweckzeit60 = CInteger(ValueBoxVorweckzeit60.Value)
      FMain.F_iVorNachweckzeit30 = CInteger(ValueBoxVorweckzeit30.Value)
      Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = FMain.F_bClockAlarmBeforeBehindON
      Settings[FMain.Name &/ "F_iVorNachweckzeit60"] = FMain.F_iVorNachweckzeit60
      Settings[FMain.Name &/ "F_iVorNachweckzeit30"] = FMain.F_iVorNachweckzeit30
      
      FMain.TermineaktuellTextArea2() 'FMain is loaded?
    Case 2, 3 'No
      Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = F_bClockAlarmBeforeBehindUndo
      Settings[FMain.Name &/ "F_iVorNachweckzeit60"] = F_iVorNachweckzeit60Undo
      Settings[FMain.Name &/ "F_iVorNachweckzeit30"] = F_iVorNachweckzeit30Undo
      FMain.F_bClockAlarmBeforeBehindON = F_bClockAlarmBeforeBehindUndo
      FMain.F_iVorNachweckzeit60 = F_iVorNachweckzeit60Undo
      FMain.F_iVorNachweckzeit30 = F_iVorNachweckzeit30Undo
      FMain.TermineaktuellTextArea2()
      ' Case 3 'Cancel
      ''...
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelMusicTitle()
  
  Dim sPathMusikTitel As String 
  
  sPathMusikTitel = Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"]
  If sPathMusikTitel = "Standard" Then sPathMusikTitel = "music/clockalarmmusic.mp3"
  LabelMusicPath.Text = File.Name(sPathMusikTitel) 'Datei.abc
  LabelMusicPath.Tooltip = sPathMusikTitel 'Ordner/Datei
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxGroup_MouseUp()
  
  Select Case String.LCase(Last.Tag) 
      
    Case "update"
      F_bCheckUpdateInternetDaily = Not F_bCheckUpdateInternetDaily
      Settings[FMain.Name &/ "F_bCheckUpdateInternetDaily"] = F_bCheckUpdateInternetDaily
      FMain.F_bCheckUpdateInternetDaily = F_bCheckUpdateInternetDaily
      FMain.CheckSoftwareUpdateTXT()
      
    Case "year"
      F_bCheckBoxYear = Not F_bCheckBoxYear
      Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON"] = F_bCheckBoxYear 'TRUE or FALSE
      
    Case "qkw"
      F_bCheckBoxQKW = Not F_bCheckBoxQKW
      Settings[FMain.Name &/ "F_bCalendarQuarterWeekON"] = F_bCheckBoxQKW 'TRUE or FALSE 'Quartal 1/4 Year (Q), Week (KW)
      
    Case "bgcolor"
      F_bCheckBoxBGColor = Not F_bCheckBoxBGColor
      F_bCheckBoxAluWood = Not F_bCheckBoxBGColor
      If F_bCheckBoxBGColor = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = ColorButton1.Value 'Path or Color
      
    Case "bgcolorbutton"
      F_bCheckBoxBGColor = True
      F_bCheckBoxAluWood = Not F_bCheckBoxBGColor
      Settings[FMain.Name &/ "FormBackgroundColor"] = ColorButton1.Value 'Path or Color
      Settings[FMain.Name &/ "ColorButton1.Value"] = ColorButton1.Value
      ' If F_bCheckBoxBGColor = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = ColorButton1.Value 'Path or Color
      
    Case "bgaluwood"
      F_bCheckBoxAluWood = Not F_bCheckBoxAluWood
      F_bCheckBoxBGColor = Not F_bCheckBoxAluWood
      If F_bCheckBoxBG1 = False And F_bCheckBoxBG2 = False Then F_bCheckBoxBG1 = True 
      If F_bCheckBoxBG1 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_aluminium1.png" 'Path or Color
      If F_bCheckBoxBG2 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_holz2.png" 'Path or Color
      
    Case "bg1"
      F_bCheckBoxAluWood = True 
      F_bCheckBoxBGColor = Not F_bCheckBoxAluWood
      F_bCheckBoxBG1 = Not F_bCheckBoxBG1
      F_bCheckBoxBG2 = Not F_bCheckBoxBG1
      If F_bCheckBoxBG1 = False And F_bCheckBoxBG2 = False Then F_bCheckBoxBG1 = True 
      If F_bCheckBoxBG1 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_aluminium1.png" 'Path or Color
      If F_bCheckBoxBG2 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_holz2.png" 'Path or Color
      
    Case "bg2"
      F_bCheckBoxAluWood = True 
      F_bCheckBoxBGColor = Not F_bCheckBoxAluWood
      F_bCheckBoxBG2 = Not F_bCheckBoxBG2
      F_bCheckBoxBG1 = Not F_bCheckBoxBG2
      If F_bCheckBoxBG1 = False And F_bCheckBoxBG2 = False Then F_bCheckBoxBG1 = True 
      If F_bCheckBoxBG1 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_aluminium1.png" 'Path or Color
      If F_bCheckBoxBG2 = True Then Settings[FMain.Name &/ "FormBackgroundColor"] = "images/bg_holz2.png" 'Path or Color
    
    Case "lastbackup"
      F_bCheckBoxLastBackup = Not F_bCheckBoxLastBackup
      Settings[FMain.Name &/ "F_bCheckBoxLastBackup"] = F_bCheckBoxLastBackup
      
    Case "showpath"
      F_bCheckBoxShowPath = Not F_bCheckBoxShowPath
      Settings[FMain.Name &/ "FilePathHideONoff"] = F_bCheckBoxShowPath
      
    Case "alarmbefore"
      F_bClockAlarmBeforeBehindON = Not F_bClockAlarmBeforeBehindON
      Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = F_bClockAlarmBeforeBehindON
      Settings[FMain.Name &/ "F_iVorNachweckzeit60"] = CInteger(ValueBoxVorweckzeit60.Value)
      Settings[FMain.Name &/ "F_iVorNachweckzeit30"] = CInteger(ValueBoxVorweckzeit30.Value)
      F_bPlusAlarmChanged = True 
      
  End Select
  
  CheckG()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub CheckBoxGroup_Change()

  If F_bChangedON = True Then 
    If Object.Type(Last) = "ValueBox" Then F_bPlusAlarmChanged = True 
  Endif 
  
Catch 
  FMain.ErrorText

End

Public Sub CheckG() 'Color/Wood/Metal
  
  Dim sPath, sValue As String
  
  F_bCheckUpdateInternetDaily = Settings[FMain.Name &/ "F_bCheckUpdateInternetDaily", False]
  If F_bCheckUpdateInternetDaily = False Then
    CheckBoxUpdate.Picture = PicTemplateConnectOff.Picture
  Else
    CheckBoxUpdate.Picture = PicTemplateConnectON.Picture 
  Endif
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  ColorButton1.Value = Settings[FMain.Name &/ "ColorButton1.Value", ColorButton1.Value]
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    F_bCheckBoxAluWood = True 
    F_bCheckBoxBGColor = False
  Else 
    F_bCheckBoxAluWood = False 
    F_bCheckBoxBGColor = True 
    If IsInteger(sValue) = True Then ColorButton1.Value = CInteger(sValue)
  Endif 
  
  If F_bCheckBoxAluWood = True Then ''Image (Bild)
    If String.InStr(String.LCase(sValue), "1.png") > 0 Then 'Aluminium
      F_bCheckBoxBG1 = True 
      F_bCheckBoxBG2 = False
    Else 
      F_bCheckBoxBG1 = False 
      F_bCheckBoxBG2 = True
    Endif 
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
    PicBackground.Visible = True
    PicBackground.Stretch = True
  Else ''Color (Farbe)
    F_bCheckBoxBG1 = False 
    F_bCheckBoxBG2 = False
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      ColorButton1.Value = PicBackground.Background
    Endif 
    PicBackground.Visible = True
    PicBackground.Picture = Null
  Endif 
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
  If F_bCheckBoxBGColor = True Then 
    CheckBoxBGColor.Picture = PicTemplateConnectON.Picture
    CheckBoxBGAluWood.Picture = PicTemplateConnectOff.Picture
  Endif 
  
  If F_bCheckBoxAluWood = True Then 
    CheckBoxBGColor.Picture = PicTemplateConnectOff.Picture
    CheckBoxBGAluWood.Picture = PicTemplateConnectON.Picture
  Endif 
  
  If F_bCheckBoxBG1 = True Then 
    Checkbg1.Picture = PicTemplateConnectON.Picture
  Else 
    Checkbg1.Picture = PicTemplateConnectOff.Picture
  Endif 
  
  If F_bCheckBoxBG2 = True Then 
    Checkbg2.Picture = PicTemplateConnectON.Picture
  Else 
    Checkbg2.Picture = PicTemplateConnectOff.Picture
  Endif 
  
  F_bCheckBoxLastBackup = Settings[FMain.Name &/ "F_bCheckBoxLastBackup", True]
  If F_bCheckBoxLastBackup = True Then 
    CheckBoxLastBackup.Picture = PicTemplateConnectON.Picture
  Else 
    CheckBoxLastBackup.Picture = PicTemplateConnectOff.Picture  
  Endif
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", "?"]
  LabelPathB.ToolTip = ("Datei") & ": " & sPath
  
  F_bCheckBoxShowPath = Settings[FMain.Name &/ "FilePathHideONoff", True]
  If F_bCheckBoxShowPath = False Then
    LabelPathB.Text = "" ' Ausblenden
    CheckBoxPath.Picture = PicTemplateConnectOff.Picture
  Else
    CheckBoxPath.Picture = PicTemplateConnectON.Picture ' sichbar
    LabelPathB.Text = sPath
  Endif
  
  F_bCheckBoxYear = Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON", False]
  If F_bCheckBoxYear = False Then
    CheckBoxYear.Picture = PicTemplateConnectOff.Picture
  Else
    CheckBoxYear.Picture = PicTemplateConnectON.Picture 
  Endif
  
  F_bCheckBoxQKW = Settings[FMain.Name &/ "F_bCalendarQuarterWeekON", False] 'Quartal 1/4 Year (Q), Week (KW)
  If F_bCheckBoxQKW = False Then
    CheckBoxQKW.Picture = PicTemplateConnectOff.Picture
  Else
    CheckBoxQKW.Picture = PicTemplateConnectON.Picture 
  Endif
  
  ' F_bClockAlarmBeforeBehindON = Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON", True] 'Vorweckzeit, Alarm before
  ' ValueBoxVorweckzeit60.Value = Settings[FMain.Name &/ "F_iVorNachweckzeit60"]
  ' ValueBoxVorweckzeit30.Value = Settings[FMain.Name &/ "F_iVorNachweckzeit30", 30]
  ' see —▶SettingsReadSave()
  If F_bClockAlarmBeforeBehindON = False Then
    CheckBoxVorweckzeit.Picture = PicTemplateConnectOff.Picture
  Else
    CheckBoxVorweckzeit.Picture = PicTemplateConnectON.Picture 
  Endif
  FMain.F_bClockAlarmBeforeBehindON = F_bClockAlarmBeforeBehindON
  
  ' FMain.FormBackgroundColor() 'Color/Wood/Metal
  M01Functions.FormsBackgroundColorAll()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iW, iH, iPart, iPH, i32, iScrollBorder, iScrollW As Integer
  
  If Form6Einst.Width < 200 Then Form6Einst.Width = 200
  If Form6Einst.Height < 200 Then Form6Einst.Height = 200
  
  '************************
  iPart = Form6Einst.ClientW / 12
  iPH = 40 'ButtonClose.H 
  i32 = 32 'Pixel
  '************************
  
  PicBackground.Move(0, 0, Form6Einst.ClientW, Form6Einst.ClientH)
  iW = PicBackground.Width / 100 * 3.6 ' Randbreite
  iH = PicBackground.Height / 100 * 3
  If iScrollBorder < 20 Then iScrollBorder = 20
  IconError.Move(Form6Einst.ClientW - 28, 0, 28, 28) '1:1
  
  ''Title:
  ButtonClear.Move(iW, iH, iPH, iPH)
  LabelTitleA.Move(ButtonClear.Left + ButtonClear.W, iH, Form6Einst.ClientW - (iW * 2) - (iPH * 3), LabelTitleA.Font.TextHeight("A"))
  LabelTitleB.Move(LabelTitleA.Left - 2, LabelTitleA.Top + 2, LabelTitleA.W, LabelTitleA.H)
  LabelTitleB.Font = LabelTitleA.Font
  LabelTitleB.Text = LabelTitleA.Text 
  PicBoxTrashOpen.Move(LabelTitleA.Left + LabelTitleA.W, ButtonClear.Top, iPH, iPH)
  ButtonText3Mini.Move(PicBoxTrashOpen.Left + PicBoxTrashOpen.W, ButtonClear.Top, iPH, iPH)
  
  ''Panels:
  ScrollViewBorder.Move(iW, ButtonClear.Top + ButtonClear.H, Form6Einst.ClientW - (iW * 2), Form6Einst.ClientH - LabelTitleA.H - (iH * 2) - iPH)
  iScrollW = ScrollViewBorder.W - iScrollBorder 
  PanelConfig.Move(ScrollViewBorder.Left, ScrollViewBorder.Top, ScrollViewBorder.W, Form6Einst.ClientH - ScrollViewBorder.Top - iH)
  PanelText.Move(ScrollViewBorder.Left, ScrollViewBorder.Top, ScrollViewBorder.W, PanelConfig.H)
  
  ''Update:
  CheckBoxUpdate.Move(0, 0, i32, i32)
  LabelUpdate.Move(i32, CheckBoxUpdate.Top, iScrollW - i32, i32)
  
  ''Calendar:
  CheckBoxYear.Move(0, i32, i32, i32)
  LabelYear.Move(i32, CheckBoxYear.Top, iScrollW - i32, i32)
  
  ''Quarter CalendarWeek:
  CheckBoxQKW.Move(0, i32 * 2, i32, i32)
  LabelQKW.Move(i32, CheckBoxQKW.Top, iScrollW - i32, i32)
  
  ''Background Color:
  CheckBoxBGColor.Move(0, i32 * 3, i32, i32)
  LabelBGColor.Move(i32, CheckBoxBGColor.Top, iScrollW - i32, i32)
  ColorButton1.Move(iScrollW * 0.45, LabelBGColor.Top, i32, i32)
  
  ''Background Alu/Wood:
  CheckBoxBGAluWood.Move(0, i32 * 4, i32, i32)
  LabelBGAluWood.Move(i32, CheckBoxBGAluWood.Top, iScrollW - i32, i32)
  Checkbg1.Move(ColorButton1.Left, CheckBoxBGAluWood.Top, i32, i32)
  LabelBGAluminium.Move(Checkbg1.Left + Checkbg1.W, Checkbg1.Top, iPH * 2.5, i32)
  Checkbg2.Move(LabelBGAluminium.Left + LabelBGAluminium.W, Checkbg1.Top, i32, i32)
  LabelBGWood.Move(Checkbg2.Left + Checkbg2.W, Checkbg1.Top, iScrollW - (Checkbg2.Left + Checkbg2.W), i32)
  
  ''Lastbackup:
  CheckBoxLastBackup.Move(0, i32 * 5, i32, i32)
  LabelLastBackup.Move(i32, CheckBoxLastBackup.Top, iScrollW - i32, i32)
  
  ''Visible Path:
  CheckBoxPath.Move(0, i32 * 6, i32, i32)
  LabelPath.Move(i32, CheckBoxPath.Top, iScrollW - i32, i32)
  LabelPathB.Move(ColorButton1.Left, LabelPath.Top, iScrollW - (ColorButton1.Left + ColorButton1.W), i32)
  
  ''Alarm clock before termin/event:
  CheckBoxVorweckzeit.Move(0, i32 * 7, i32, i32)
  LabelVorweckzeit.Move(i32, CheckBoxVorweckzeit.Top, iScrollW - i32, i32)
  PicBoxMusicPlusAlarm.Move(ColorButton1.Left - i32, CheckBoxVorweckzeit.Top, i32, i32)
  PicBoxLEDPlusAlarm.Move(ColorButton1.Left, LabelVorweckzeit.Top, i32, i32)
  ValueBoxVorweckzeit60.Move(ColorButton1.Left + i32, CheckBoxVorweckzeit.Top, i32 * 1.5, i32)
  LabelVorweckzeitAnd.Move(ValueBoxVorweckzeit60.Left + ValueBoxVorweckzeit60.W, CheckBoxVorweckzeit.Top, i32 * 1.5, i32)
  ValueBoxVorweckzeit30.Move(LabelVorweckzeitAnd.Left + LabelVorweckzeitAnd.W, CheckBoxVorweckzeit.Top, i32 * 1.5, i32)
  LabelVorweckzeitMin.Move(ValueBoxVorweckzeit30.Left + ValueBoxVorweckzeit30.W, CheckBoxVorweckzeit.Top, iScrollW - (ValueBoxVorweckzeit30.Left + ValueBoxVorweckzeit30.W), i32)
  
  ''Text Info:
  TextArea1.Move(0, CheckBoxVorweckzeit.Top + CheckBoxVorweckzeit.H + (iPH / 2), iScrollW - iPH, iPH * 2)
  ButtonText3Maxi.Move(TextArea1.Left + TextArea1.W, TextArea1.Top, iPH, iPH)
  
  ''Music:
  PicBoxNote.Move(0, TextArea1.Top + TextArea1.H, i32, i32)
  PicBoxNoteON.Move(TextArea1.Left + TextArea1.W, PicBoxNote.Top, i32, i32)
  LabelMusikTest.Move(i32, PicBoxNote.Top, i32 * 3, i32)
  LabelMusic.Move(LabelMusikTest.Left + LabelMusikTest.W, PicBoxNote.Top, i32 * 3, i32)
  LabelMusicPath.Move(LabelMusic.Left + LabelMusic.W, PicBoxNote.Top, iScrollW - (LabelMusic.Left + LabelMusic.W) - i32, i32)
  
  ''Buttons:
  PicBoxPath.Move(0, PicBoxNote.Top + PicBoxNote.H, i32, i32)
  ButtonPath.Move(0, PicBoxPath.Top, iScrollW, i32)
  PicBoxDir.Move(0, ButtonPath.Top + ButtonPath.H, i32, i32)
  ButtonDir.Move(0, PicBoxDir.Top, iScrollW, i32)
  PicBoxTimeZone.Move(0, ButtonDir.Top + ButtonDir.H, i32, i32)
  ButtonTimeZone.Move(0, PicBoxTimeZone.Top, iScrollW, i32)
  PicBoxSetttings.Move(0, ButtonTimeZone.Top + ButtonTimeZone.H, i32, i32)
  ButtonSettings.Move(0, PicBoxSetttings.Top, iScrollW, i32)
  PicBoxSun.Move(0, ButtonSettings.Top + ButtonSettings.H, i32, i32)
  ButtonSun.Move(0, PicBoxSun.Top, iScrollW, i32)
  PicBoxFeier.Move(0, ButtonSun.Top + ButtonSun.H, i32, i32)
  ButtonFeier.Move(0, PicBoxFeier.Top, iScrollW, i32)
  PicBoxExport.Move(0, ButtonFeier.Top + ButtonFeier.H, i32, i32)
  ButtonExport.Move(0, PicBoxExport.Top, iScrollW, i32)
  PicBoxStart.Move(0, ButtonExport.Top + ButtonExport.H, i32, i32)
  ButtonStart.Move(0, PicBoxStart.Top, iScrollW, i32)
  PicBoxFileChangeList.Move(0, ButtonStart.Top + ButtonExport.H, i32, i32)
  ButtonFileChangeList.Move(0, PicBoxFileChangeList.Top, iScrollW, i32)
  PicBoxIcon.Move(0, ButtonFileChangeList.Top + ButtonFileChangeList.H, i32, i32)
  LabelIcon.Move(0, PicBoxIcon.Top, iScrollW, i32)
  PicBoxIconInfo.Move(iScrollW - (i32 * 2), PicBoxIcon.Top, i32, i32)
  PicBoxIconB.Move(iScrollW - i32, PicBoxIcon.Top, i32, i32)
  
  ''PanelConfig:
  TextAreaConfig.Move(0, 0, PanelConfig.Width, PanelConfig.Height - (ButtonOpenConfig.H * 2))
  TextLabelConfInfo.Move(0, TextAreaConfig.Top + TextAreaConfig.H, TextAreaConfig.W, ButtonOpenConfig.H * 1)
  ButtonOpenConfig.Move(0, TextLabelConfInfo.Top + TextLabelConfInfo.H, PanelConfig.Width / 3)
  ButtonSaveConfig.Move(ButtonOpenConfig.Left + ButtonOpenConfig.Width, ButtonOpenConfig.Top, PanelConfig.Width / 3, ButtonOpenConfig.Height)
  ButtonCancelConfig.Move(ButtonSaveConfig.Left + ButtonSaveConfig.Width, ButtonSaveConfig.Top, ButtonSaveConfig.Width, ButtonSaveConfig.Height)
  
  ''Panel3:
  TextAreaText.Move(0, 0, PanelText.W, PanelText.H - iPH)
  ButtonCopyText.Move(0, TextAreaText.Top + TextAreaText.H, PanelText.W / 2, iPH)
  ButtonCancelText.Move(ButtonCopyText.Left + ButtonCopyText.W, ButtonCopyText.Top, PanelText.W / 2, iPH)
  
  ButtonClose.Move(iW, ScrollViewBorder.Top + ScrollViewBorder.H, Form6Einst.ClientW - (iW * 2), Form6Einst.ClientH - ScrollViewBorder.H - LabelTitleA.H - (iH * 2))
  
  If F_bMovingON = False Then WindowStretch.Move(Form6Einst.ClientW - iW - iPH, ButtonClose.Top, iPH, iPH) '1:1 quadratisch
  
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  ScrollViewBorder.Raise()
  CheckBoxYear.Raise()
  CheckBoxQKW.Raise()
  CheckBoxBGColor.Raise()
  CheckBoxBGAluWood.Raise()
  Checkbg1.Raise()
  Checkbg2.Raise()
  CheckBoxPath.Raise()
  CheckBoxVorweckzeit.Raise()
  
  LabelYear.Lower()
  LabelQKW.Lower()
  LabelBGColor.Lower()
  LabelBGAluminium.Raise()
  LabelBGWood.Raise()
  LabelPath.Lower()
  LabelVorweckzeit.Lower()
  ' LabelVorweckzeitAnd.Lower()
  ' LabelVorweckzeitMin.Lower()
  
  LabelPathB.Raise()
  LabelTitleB.Raise()
  LabelTitleA.Raise()
  PicBoxTrashOpen.Raise()
  ButtonClear.Raise()
  ButtonText3Mini.Raise()
  PanelConfig.Raise()
  PanelText.Raise()
  IconError.Raise()
  
  PicBackground.Lower() '▼Level Bottom▼
  WindowStretch.Raise() '▲Level Top▲
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSettingsClearAll()
  
  Dim sMessage, sQuestion, sDirFile, sDirFileBackup As String 
  
  sDirFile = FilePathForm() 'config
  
  sQuestion = "<font size=4 color=red>" & "○ " & ("Alle Einstellungen 'settings' löschen?") & "<br>"
  sQuestion &= "<b>" & ("(Neu-Zustand)") & "</b></font><br><br>"
  sMessage &= sQuestion & "<br>"
  ' sMessage &= sDirFile & "<br>"
  sMessage &= sDirFile & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
  sMessage &= "<font color=darkgreen>" & ("Diese Configuration-Datei wird geleert/gelöscht.") & "</font>"
  
  Select Case Message.Question(sMessage, "○ " & ("Alle Einstellungen löschen") & "...", ("Ordner..."), ("Abbrechen"))
    Case 1
      sDirFileBackup = FMain.F_sPathSettingsBackup_conf
      If Exist(File.Dir(sDirFileBackup)) = False Then sDirFileBackup = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(Settings.Path) 
      sMessage = sQuestion & "<br><br>"
      sMessage &= "<font color=red>" & sDirFile & "</font><br>" 
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
      sMessage &= "<font color=darkgreen>" & sDirFileBackup & "</font><br>" 
      sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileBackup) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileBackup).Size) & "<br><br>"
      
      sMessage &= Application.Name & "-" & ("Programm beenden und neu starten") & "<br>"
      sMessage &= "<font color=gray>" & ("Tipp: Hauptfenster Menü>Datei>Backup...Einstellungen") & "</font><br>" 
      
      Select Case Message.Question(sMessage, "○ " & ("Alle Einstellungen löschen"), ("Abbrechen"))
        Case 1
          If Exist(sDirFile) = True And Exist(sDirFileBackup) = False Then Try Copy sDirFile To sDirFileBackup
          Settings.Clear()
        Case 2
          '...
      End Select
    Case 2
      sDirFile = FilePathForm() 'config
      If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
      If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      M01Functions.FileManagerOpen(sDirFile)
    Case 3 'Cancel
      '...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxPathG()
  
  PfadEinAus()
  
Catch 
  FMain.ErrorText
  
End

Public Sub PfadEinAus()
  
  Select Case CheckBoxPath.Value
    Case False
      Settings[FMain.Name &/ "FilePathHideONoff"] = 0
      'LabelE3b.Foreground = LabelE3b.Background ' Ausblenden
      LabelPathB.Text = ""
    Case True
      Settings[FMain.Name &/ "FilePathHideONoff"] = 1
      LabelPathB.Foreground = Color.Blue 'FMain.F_iColorClockBlue
      LabelPathB.Text = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", "?"]
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonPathG()
  
  Form3Text.Tag = FMain.F_sPathTerminweckerActual_txt
  Form1FileOpen.Window.Show
  ' Form1FileOpen.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonConfigSaveG(Optional sDirFileBackup As String = "") 'Settings speichern
  
  Dim sDir, sDirFileConf, sTest, sInfo1, sInfo2, sAppName, sMessage As String
  Dim statOld, statNew As Stat
  
  ' sDirFileConf = Settings[FMain.Name &/ "F_sPathSettings_conf", Settings.Path]
  sDirFileConf = FilePathForm()
  If Exist(sDirFileBackup) = False Then sDirFileBackup = sDirFileConf 
  ' TextLabelConfInfo.Text = sDirFileConf '—▶ Original
  TextLabelConfInfo.Text = sDirFileConf & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFileConf) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileConf).Size) 
  TextLabelConfInfo.Tooltip = sDirFileConf
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If IsDir(File.Dir(sDirFileBackup)) = False Then sDirFileBackup = sDir &/ File.Name(sDirFileConf) '/home/user/terminwecker/backup_file.txt
  
  If Exist(sDirFileBackup) = True Then sInfo1 = M01Functions.FileLastModifiedText(sDirFileBackup) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileBackup).Size) Else sInfo1 = "<font color=red>" & ("Nicht gefunden") & "</font>"
  
  If Exist(sDirFileConf) = True Then sInfo2 = M01Functions.FileLastModifiedText(sDirFileConf) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFileConf).Size) Else sInfo2 = "<font color=red>" & ("Nicht gefunden") & "</font>"
  
  ''Test:
  PanelConfig.Background = F_iColorSelectRed150
  If Exist(sDirFileConf) = True And M01Functions.AccessDirFileReadWrite(sDirFileConf, 1) = False Then 'Write1
    sTest = "<font color=red>" & ("Beschreiben nicht möglich? Zugangsrechte?") & "</font>" & "<br>"  'as Boolean, Erlaubt_Read0_Write1_Exec2_Alle3
  Endif 
  sMessage = "<h2><font color=darkgreen><b>" & ("Backup Einstellungen [settings]") & "</b></font>" & "</h2>"
  sMessage &= "<h3><font color=gray>" & ("Von:") & "</font>" & "<br>"
  sMessage &= "<font color=darkgreen><b>" & sDirFileBackup & "</b></font>" & "<br>"
  sMessage &= "<font color=darkgreen>" & ("vor") & Space(1) & sInfo1 & "</font>" & "</h3>"
  sMessage &= "<hr>" '———
  sMessage &= "<h3><font color=gray>" & ("Nach:") & "</font>" & "<br>"
  sMessage &= "<font color=blue><b>" & sDirFileConf & "</b></font>" & "<br>"
  sMessage &= "<font color=blue>" & ("vor") & Space(1) & sInfo2 & "</font>" & "</h3>"
  sMessage &= sTest 
  sMessage &= "● " & "<b><font color=blue>" & ("Original") & Space(1) & "</font>" & "<font color=red>" & ("überschreiben?") & "</font></b>" & "<br>"
  ' sMessage &= ("Vorsicht: Einstellungen nur mit Fachwissen ändern.") & "<br>"
  sMessage &= ("Im Notfall alle Einstellungen löschen. Das Programm startet dann wie im Neu-Zustand.") 
  
  ''Info:
  Select Case Message.Question(sMessage, "● " & ("Speichern"), ("Ordner..."), ("Abbrechen")) 'Case[0,1,2,3]
    Case 1 'Save
      ''...
    Case 2 'Directory...
      If Exist(sDirFileConf) = False Then sDirFileConf = File.Dir(sDirFileConf)
      M01Functions.FileManagerOpen(sDirFileConf)
      TextLabelConfInfo.Text = sDirFileBackup
      Goto JumpEnd
    Case 3 'Cancel
      TextLabelConfInfo.Text = sDirFileBackup
      Goto JumpEnd
  End Select
  sMessage = "" 'Reset
  
  ''Backup:
  If Exist(sDirFileConf) = True Then 
    statOld = Stat(sDirFileConf)
    Try Copy sDirFileConf To sDirFileBackup
  Endif
  
  ''Save:
  sDirFileConf = M01Functions.FileTextPlus(sDirFileConf, TextAreaConfig.Text, True) ' TRUE=overwrite (überschreiben)
  If Exist(sDirFileConf) = True Then statNew = Stat(sDirFileConf)
  
  ''Check:
  If Exist(sDirFileConf) = True And statOld <> statNew Then  
    PanelConfig.Background = F_iColorSelectGreen150 'Color.White
    ButtonSaveConfig.Background = Color.Default
    sMessage = sDirFileConf & "<br>"
    sMessage &= "<h3><font color=darkgreen><b>" & ("Gespeichert") & "</b></font></h3>"
    sAppName = "<font size=7 color=#" & Hex(FMain.F_iColorClockBlue, 6) & "><b>" & Application.Name & "</b></font>" 
    sMessage &= sAppName & "<br>" 
    sMessage &= "<h2><font color=blue><b>" & ("Bitte dieses Programm beenden und neu starten") & Space(1) & "<font color=darkgreen>" & ("(mit den neuen Einstellungen)") & "</b></font></h2>" 
    TextLabelConfInfo.Text = sDirFileConf
  Else
    PanelConfig.Background = F_iColorSelectRed150
    ButtonSaveConfig.Background = F_iColorSelectRed150
    sMessage = sDirFileConf & "<br>"
    sMessage &= "<h3><font color=red><b>" & ("Nicht gespeichert") & "</b></font></h3>"
    TextLabelConfInfo.Text = "<font color=red><b>" & ("Nicht gespeichert") & "</b></font>"
  Endif
  ButtonOpenConfig.ToolTip = ("Öffnen") & ": " & sDirFileBackup
  ButtonSaveConfig.Tooltip = ("Speichern") & ": " & sDirFileConf
  TextLabelConfInfo.Tooltip = TextLabelConfInfo.Text
  
  ''Info:
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
    Case 1 'Directory...
      If Exist(sDirFileConf) = False Then sDirFileConf = File.Dir(sDirFileConf)
      M01Functions.FileManagerOpen(sDirFileConf)
    Case 2 'Cancel
      '...Leerlauf 
  End Select
  
JumpEnd:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonConfigOpenG(Optional sBackup As String = "")
  
  Dim sDirFile, sDir, sDirFileConf, sDirFileBackup, sText As String
  
  sDirFileConf = FilePathForm()
  sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirAppName]
  If Exist(sDir) = True Then sDirFileBackup = sDir &/ File.Name(sDirFileConf) '/home/user/terminwecker/backup_file.txt
  If Exist(sDirFileBackup) = False Then sDirFileBackup = FMain.F_sPathSettingsBackup_conf
  
  ''Load:
  If sBackup = "" And Exist(sDirFileConf) = True Then 
    ' If Not TextArea2.Text Then 
    sText = File.Load(sDirFileConf)
    TextAreaConfig.SelectAll()
    TextAreaConfig.Insert(sText)
    ButtonOpenConfig.Background = F_iColorPackage
    ButtonSaveConfig.Background = F_iColorPackage
    sDirFile = sDirFileConf
    PanelConfig.Background = F_iColorSelectGreen150
    ' Else
    ' MessageQuestionON(("Neu einlesen?"))
    ' Endif 
  Else If Exist(sBackup) = True Then
    ' If Not TextArea2.Text Then 
    sText = File.Load(sBackup)
    TextAreaConfig.SelectAll()
    TextAreaConfig.Insert(sText)
    ButtonSaveConfig.Background = F_iColorPackage
    ButtonSaveConfig.Background = F_iColorSelectRed150
    sDirFile = sBackup
    PanelConfig.Background = F_iColorSelectBlue150
    ' Endif 
  Else 
    MessageQuestionON(sDirFile & "<br>" & ("Fehlt?"), sDirFile)
  Endif
  ButtonOpenConfig.ToolTip = ("Öffnen") & ": " & sDirFileBackup
  ButtonSaveConfig.Tooltip = ("Speichern") & ": " & sDirFileConf
  ' TextLabelConfInfo.Text = sDirFile
  TextLabelConfInfo.Text = sDirFile & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) 
  TextLabelConfInfo.Tooltip = sDirFile
  If String.InStr(String.LCase("." & File.Ext(sDirFile)), ".conf") > 0 Then 
    TextLabelConfInfo.Foreground = Color.Default
  Else 
    TextLabelConfInfo.Text = "<br>" & "<font color=red><b>" & ("Keine .conf Datei") & ": " & "</b></font>"
    TextLabelConfInfo.Text &= sDirFile 
    PanelConfig.Background = Color.White
  Endif
  ''Settings:
  'sDirFile = User.Home &/ ".config/gambas3" &/ Application.Name & ".conf"
  'Zeichen "#" oder ";" sind Notizzeilen und werden ignoriert
  'Titel sind ["Ordner/x"] = [Ordner]
  'Werte werden mit "=" getrennt, Leerstellen sind Trenner   sValue=0 1 2 3
  'Alle Werte sind "Strings"
  
  'Sichert die Gambas-Konfiguration-Datei 
  'Das Verzeichnis muß vorhanden und der Zugriff(Rechte) muß erlaubt sein. In Root (Wurzelverzeichnisse) nicht möglich, nur Read-Only (lesen), aber in "/home" (Benutzer)-Verzeichnissen.
  'sDirFileOld = User.Home &/ ".config/gambas3" &/ Application.Name & ".conf"
  'Settings.Clear("Titel") ' löscht die Settings unter dem [Titel]. Ohne Titel alles. 
  'File.Load(Settings.DefaultDir &/ Application.Name & ".conf")
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
  
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub MessageQuestionON(Optional sMessage As String = "?", Optional sDirFile As String = "")
  
  Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
    Case 1 'Directory...
      If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
      If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      M01Functions.FileManagerOpen(sDirFile)
    Case 2 'Cancel
      '...Leerlauf 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonDirG()
  
  Dim sDirFile As String
  
  sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerStandard_txt", FMain.F_sPathTerminweckerStandard_txt]
  If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  M01Functions.FileManagerOpen(sDirFile)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxYearG()
  
  Settings[FMain.Name &/ "F_bCalendarHTMLautomaticRefreshON"] = CheckBoxYear.Value 'TRUE or FALSE
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaConfig_MouseDown()
  
  PanelConfig.Background = Color.White
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextAreaConfig_Change()
  
  PanelConfig.Background = Color.White
  ButtonSaveConfig.Background = F_iColorSelectRed150
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSunG()
  
  Form11Breitengrade.Window.Show
  ' Form11Breitengrade.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxQKWG()
  
  Settings[FMain.Name &/ "F_bCalendarQuarterWeekON"] = CheckBoxQKW.Value 'TRUE or FALSE 'Quartal 1/4 Year (Q), Week (KW)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonStartG()
  
  M01Functions.LinkAutoStartCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonExportG() 'ö=oe, ...
  
  Form13Export.Window.Show
  ' Form13Export.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonHolidaysG()
  
  Dim sValue As String
  
  sValue = Settings[FMain.Name &/ "OsterSonntag", Null]
  If String.InStr(sValue, Year(Date)) = 0 Then M03Feiertage.HolidaysCalculate()
  Form8ZusFeiertage.Window.Show
  ' Form8ZusFeiertage.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonFileChangeListG() 
  
  Dim ssSpli As String[]
  Dim sDirFile, sLines, sDirFileLast, sMessage As String 
  Dim iNr As Integer
  
  If FMain.F_sFilesChangedList Then ssSpli = Split(FMain.F_sFilesChangedList, gb.NewLine) 'as String[]
  If ssSpli Then 
    sMessage = "<h3>" & "● " & ("Veränderte Dateien") & ":" & "</h3>" 
    For Each sDirFile In ssSpli 
      If Exist(sDirFile) = True Then 
        sLines &= sDirFile & gb.NewLine
        iNr = iNr + 1
        sMessage &= iNr & ". " & sDirFile & "<br>"
        sMessage &= "<font color=blue><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>" 
        sDirFileLast = sDirFile
      Endif 
    Next 
    
    Select Case Message.Question(sMessage, "● " & ("Liste kopieren"), ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
      Case 1 
        Clipboard.Clear()
        Clipboard.Copy(sLines)
      Case 2 'Directory...
        sDirFile = sDirFileLast
        If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
        If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
        M01Functions.FileManagerOpen(sDirFile)
      Case 3 'Cancel
        '...Leerlauf 
    End Select
  Else 
    sMessage = "<h3>" & ("Veränderte Dateien") & ":" & "</h3>" 
    sMessage &= "<font color=blue><b>" & ("Keine") & "</b></font>" & "<br>" 
    
    MessageQuestionON(sMessage, sDirFile)
  Endif 
  
  ' PanelText.Visible = True 
  ' TextAreaText.SelectAll()
  ' TextAreaText.Insert(Url(sMessage))
  
  ''__________________________________________________________''
  'HTML and Path with "/": Replace(UrlPathElement, '/', '%2F')
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicNoteG()
  Dim bMusicON As Boolean
  
  bMusicON = Settings[FMain.Name &/ "F_bClockAlarmMusicON", FMain.F_bClockAlarmMusicON]
  FMain.F_bClockAlarmMusicON = True 
  Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = True
  If PicBoxNote.Background = Color.Green Then
    PicBoxNote.Background = Color.Default 
    M01Functions.MusicStartStop("", False)
    ' Music.Stop() 'noch einmal zur Sicherheit
  Else
    PicBoxNote.Background = Color.Green 
    M01Functions.MusicStartStop("", True)
    LabelMusicTitle()
  Endif
  
  ''Reset:
  Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = bMusicON
  FMain.F_bClockAlarmMusicON = bMusicON 
  
Catch 
  FMain.ErrorText
  ''___________________________________________________________________________''
  'Music.Play(1,0) > (Loop 1x, default 0) needs component: (gb.sdl2.audio)
  'Music.Stop()
  'Read Status: iInfo = Music.State 'as Integer  '< Music.Stopped, Music.Playing, Music.Paused 'as Integer Constanten
  
End

Public Sub PicNotePlusAlarmG()
  Dim bMusicON As Boolean
  Dim sDirMusic, sFile, sDirFile, sPath As String 
  
  bMusicON = Settings[FMain.Name &/ "F_bClockAlarmMusicON", FMain.F_bClockAlarmMusicON]
  FMain.F_bClockAlarmMusicON = True 
  Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = True
  sPath = Settings[FMain.Name &/ "F_sPathMusicPlusAlarm_wav", FMain.F_sPathMusicPlusAlarm_wav]
  sDirMusic = Settings[FMain.Name &/ "F_sDirMusic", FMain.F_sDirMusic]
  sFile = File.Name(sPath)
  sDirFile = sDirMusic &/ sFile 
  If Exist(sDirFile) = False Then sDirFile = sPath
  F_bClockAlarmBeforeBehindON = Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON", False] 
  F_bClockAlarmBeforeBehindON = Not F_bClockAlarmBeforeBehindON
  Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = F_bClockAlarmBeforeBehindON
  If F_bClockAlarmBeforeBehindON = True Then
    ' PicBoxMusicPlusAlarm.Background = Color.Green 
    M01Functions.MusicStartStop(sDirFile, True)
    PicBoxMusicPlusAlarm.Picture = PicTemplateNoteGreen.Picture
  Else
    ' PicBoxMusicPlusAlarm.Background = Color.Default 
    M01Functions.MusicStartStop("", False)
    PicBoxMusicPlusAlarm.Picture = PicTemplateNoteRed.Picture
  Endif
  
  ''Reset:
  Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = bMusicON
  FMain.F_bClockAlarmMusicON = bMusicON 
  
Catch 
  FMain.ErrorText
  ''___________________________________________________________________________''
  'Music.Play(1,0) > (Loop 1x, default 0) needs component: (gb.sdl2.audio)
  'Music.Stop()
  'Read Status: iInfo = Music.State 'as Integer  '< Music.Stopped, Music.Playing, Music.Paused 'as Integer Constanten
  
End

Public Sub CheckMusicON()
  
  If Component.IsLoaded("gb.sdl2.audio") Then 'neue Komponente
    If Music.State = Music.Playing Then 
      LabelMusikTest.Text = ("Stopp")
      LabelMusikTest.Tooltip = ("Stopp Musik-Test")
      PicBoxNote.Background = Color.Green
    Else 
      LabelMusikTest.Text = ("Test")
      LabelMusikTest.Tooltip = ("Start Musik-Test")
      PicBoxNote.Background = Color.Default
    Endif
  Else
    LabelMusikTest.Text = ("Fehlt")
    LabelMusikTest.Tooltip = LabelMusikTest.Text & Space(1) & "gb.sdl2.audio"
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelMusicG()

  M01Functions.MusicSelectionDialog()
  LabelMusicTitle()
  M01Functions.CheckDirMusic()
  ' Form6Einst.Raise 'Fokus zurück falls verloren
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form6Einst.Window.Maximized = Not Form6Einst.Window.Maximized 
  If Form6Einst.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form6Einst.Window.FullScreen = True Or Form6Einst.Window.Maximized = True Then 
      F_bMovingON = False
      Form6Einst.Window.FullScreen = False
      Form6Einst.Window.Maximized = False
      If Form6Einst.Left + Form6Einst.W > Screen.AvailableWidth Then Form6Einst.Move(Form6Einst.Left, Form6Einst.Top, Screen.AvailableWidth - Form6Einst.Left, Screen.AvailableHeight - Form6Einst.Top)
    Else
      F_bMovingON = True
      Form6Einst.Window.FullScreen = False
      Form6Einst.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form6Einst.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form6Einst.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form6Einst.ClientW - WindowStretch.W, Form6Einst.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form6Einst.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form6Einst.W = Mouse.ScreenX - F_iX1
    Form6Einst.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form6Einst.ClientW - WindowStretch.W, Form6Einst.ClientH - WindowStretch.H)
    WindowStretch.Raise()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form6Einst.ClientW - WindowStretch.W, Form6Einst.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form6Einst.Window.Maximized = Not Form6Einst.Window.Maximized 
    If Form6Einst.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form6Einst.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()
  '.Delay = 1000 '1 Sekunde
  
  ButtonText3Mini.Visible = PanelText.Visible
  CheckMusicON()
  CheckLinkIcon()
  PicBoxLEDPlusAlarm.Tooltip = "(" & ValueBoxVorweckzeit60.Text & ", " & ValueBoxVorweckzeit30.Text & ", " & "0" & ")" & Space(1) & ("(Grün, Gelb, Rot)")
  CheckClockAlarmButtonNoteOnOff()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub CheckLinkIcon()
  
  Dim sDesktop, sPath As String 
  Dim ssDesktop As String[]
  
  sDesktop = Desktop.GetDirectory("DESKTOP")  ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS"
  ssDesktop = Dir(sDesktop, "*" & String.LCase(Application.Name) & "*", gb.File)
  If ssDesktop Then sPath = String.LCase(Application.Name) & "icon.png" 'in Program-Directory
  If Exist(sPath) = True Then PicBoxIconB.Picture = Picture.Load(sPath) Else PicBoxIconB.Picture = PicTemplateQuestion.Picture
  
Catch 
  FMain.ErrorText
  
End

Public Sub SystemDatumZeitG()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gnome-control-center")
  If bExist = True Then
    Shell "gnome-control-center datetime" 'startet Programm mit Dateipfad oder Text einfügen
    ' M01Functions.ExternStart("gnome-control-center", "info-overview") 'Zeit und Datum, Seite Betriebssysem-Info
  Endif
  If bExist = False Then bExist = System.Exist("unity-control-center")
  If bExist = True Then
    Shell "unity-control-center datetime" ' Datum und Zeit, Einstellungen im Betriebssystem
    'M01Functions.ExternStart("unity-control-center", "datetime") 'Zeit und Datum
  Endif
  If bExist = False Then
    Message.Info(("System-Uhr nicht gefunden"))
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconInfoG()
  
  Dim sText, sDirFile As String 
  
  sDirFile = Desktop.GetDirectory("DESKTOP") &/ Application.Name & ".desktop" 
  
  sText = ("Icon-Info verständlich:") & gb.NewLine & gb.NewLine
  sText &= ("Ein Icon (Symbol-Bild) ist nicht das Programm selbst.") & gb.NewLine
  sText &= ("Ein Icon ist wie ein Wegweiser zum Ziel, aber nicht das Ziel selbst.") & gb.NewLine
  sText &= ("Wenn der 'Wegweiser' entfernt wird, bleibt das Ziel dennoch davon unberührt.") & gb.NewLine
  sText &= ("Umgekehrt kann ein Programm gelöscht sein oder fehlen und das Icon-Symbol ist in der Bildschirm-Oberfläche geblieben und reagiert nicht, weil das Ziel nicht (mehr) vorhanden ist.") & gb.NewLine 
  sText &= "■ " & ("Icon") & " ——▶ " & ("Programm, Software, App (Applikation), Anwendung") & gb.NewLine 
  sText &= gb.NewLine
  sText &= LabelIcon.Tooltip & gb.NewLine 
  sText &= gb.NewLine
  sText &= ("Desktop") & ":" & gb.NewLine 
  sText &= ("Icon/Symbol im Startbildschirm") & Space(1) & ("Schreibtisch") & ":" & gb.NewLine 
  sText &= sDirFile & gb.NewLine
  sText &= ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & gb.NewLine 
  
  'sText &= ("A Program-Icon is a little Symbol-Picture\nin Desktop (Start-Screen).\nClick the little File behind Icon and the Program start.")
          
  PanelText.Background = Color.Background  
  PanelText.Visible = True 
  TextAreaText.SelectAll()
  TextAreaText.Insert(sText)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckClockAlarmButtonNoteOnOff()
  
  If Settings[FMain.Name &/ "F_bClockAlarmMusicON", FMain.F_bClockAlarmMusicON] = True Then 
    PicBoxNoteON.Picture = PicTemplateNoteGreen.Picture
    PicBoxNoteON.Tooltip = ("Uhr-Alarm eingeschaltet")
  Else 
    PicBoxNoteON.Picture = PicTemplateNoteRed.Picture
    PicBoxNoteON.Tooltip = ("Uhr-Alarm ausgeschaltet")
  Endif 

  If Settings[FMain.Name &/ "F_bClockAlarmBeforeBehindON"] = True Then 
    PicBoxMusicPlusAlarm.Picture = PicTemplateNoteGreen.Picture
  Else
    PicBoxMusicPlusAlarm.Picture = PicTemplateNoteRed.Picture
  Endif
  
  FMain.CheckClockAlarmButtonNoteOnOff()
  
Catch
  
  FMain.ErrorText
  
End

Public Sub CheckIconInDesktop()
  Dim sDirFile, sMessage As String 
  
  sDirFile = Desktop.GetDirectory("DESKTOP") &/ Application.Name & ".desktop"
  If Exist(sDirFile) = True Then  
    sMessage = "<h3><font color=darkgreen>" & ("Gefunden") & ":" & "</font></h3>"
  Else 
    sMessage = "<h3><font color=blue>" & ("Nicht im Ordner") & ":" & "</font></h3>"
  Endif
  sMessage &= "<h3>" & ("Programm-Icon (Symbol) im Startbildschirm") & Space(1) & ("Schreibtisch") & ":" & "</h3>"
  sMessage &= "● " & File.Dir(sDirFile) &/ "<font color=darkgreen>" & File.Name(sDirFile) & "</font><br>" 
  If Exist(sDirFile) = True Then 
    sMessage &= "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b></font>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "<br>"
  Endif 
  ' MessageQuestionON(sMessage, sDirFile) '/home/user/DESKTOP       ("Schreibtisch"), Desktop.GetDirectory("DESKTOP"))
  Select Case Message.Question(sMessage, "● " & ("Öffnen") & "...", ("Ordner..."), ("Abbrechen")) 'Case[0,1,2]
    Case 1 'Open
      If Exist(sDirFile) = True Then Desktop.Open(sDirFile) Else M01Functions.FileManagerOpen(File.Dir(sDirFile))
    Case 2 'Directory...
      If Exist(sDirFile) = False Then sDirFile = File.Dir(sDirFile)
      If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      M01Functions.FileManagerOpen(sDirFile)
    Case 3 'Cancel
      '...Leerlauf 
  End Select
    
  Catch
  
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Last.Background <> Color.Green Then Last.Background = F_iColorSelectGreen150
  If Object.Type(Last) = "PictureBox" Then Last.Border = Border.Plain Else Last.Border = True 
  
  Select Case String.LCase(Last.Tag)
    Case PicBoxMusicPlusAlarm.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(PicBoxMusicPlusAlarm.Tooltip) 
    Case PicBoxLEDPlusAlarm.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(PicBoxLEDPlusAlarm.Tooltip) 
    Case LabelMusicPath.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"]) 
    Case ButtonPath.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]) 
    Case ButtonDir.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]) 
    Case ButtonFileChangeList.Tag 
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(("Veränderte Dateien") & ":" & gb.NewLine & FMain.F_sFilesChangedList) 
    Case LabelIcon.Tag
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(Desktop.GetDirectory("DESKTOP") &/ Application.Name & ".desktop") '/home/user/DESKTOP       ("Schreibtisch")
      ' Case "note", "showpathbg"
      '   '...
      ' Case ButtonOpenConfig.Tag, ButtonSaveConfig.Tag, ButtonCancelConfig.Tag
      '   '...
      ' Case ButtonClose.Tag 
      '   Last.Background = Color.Green
      '   Last.Border = True 
    Case Else
      TextArea1.Clear()
      TextArea1.SelectAll()
      TextArea1.Insert(Last.Tooltip) 
  End Select
  
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Blue
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  If Last.Background <> Color.Green Then Last.Background = Color.Default
  
  Select Case String.LCase(Last.Tag)
    Case "note", "showpathbg", PicBoxMusicPlusAlarm.Tag
      '...
    Case ButtonOpenConfig.Tag, ButtonSaveConfig.Tag, ButtonCancelConfig.Tag
      '...
    Case ButtonClose.Tag 
      Last.Background = Color.Default
      Last.Border = True 
    Case Else
      Last.Background = Color.Default
      Last.Border = False
  End Select
  
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxGroup_Enter()
  
  Dim iSelectColor As Integer
  
  iSelectColor = Color.Green 
  
  Select Case String.LCase(Last.Tag)
      
    Case CheckBoxUpdate.Tag 
      CheckBoxUpdate.Background = iSelectColor 
      LabelUpdate.Background = iSelectColor 
    
    Case CheckBoxYear.Tag 
      CheckBoxYear.Background = iSelectColor 
      LabelYear.Background = iSelectColor 
      
    Case CheckBoxQKW.Tag
      CheckBoxQKW.Background = iSelectColor 
      LabelQKW.Background = iSelectColor 
      
    Case CheckBoxBGColor.Tag
      CheckBoxBGColor.Background = iSelectColor 
      LabelBGColor.Background = iSelectColor 
      
    Case CheckBoxBGAluWood.Tag
      CheckBoxBGAluWood.Background = iSelectColor 
      LabelBGAluWood.Background = iSelectColor 
      
    Case Checkbg1.Tag
      Checkbg1.Background = iSelectColor 
      LabelBGAluminium.Background = iSelectColor 
      
    Case Checkbg2.Tag
      Checkbg2.Background = iSelectColor 
      LabelBGWood.Background = iSelectColor 
    
    Case CheckBoxLastBackup.Tag
      CheckBoxLastBackup.Background = iSelectColor 
      LabelLastBackup.Background = iSelectColor 
      
    Case CheckBoxPath.Tag
      CheckBoxPath.Background = iSelectColor 
      LabelPath.Background = iSelectColor 
      
    Case CheckBoxVorweckzeit.Tag
      CheckBoxVorweckzeit.Background = iSelectColor 
      LabelVorweckzeit.Background = iSelectColor 
      LabelVorweckzeitAnd.Background = iSelectColor 
      LabelVorweckzeitMin.Background = iSelectColor 
      
  End Select  
  
  TextArea1.Clear()
  TextArea1.SelectAll()
  TextArea1.Insert(Last.Tooltip) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBoxGroup_Leave()
  
  Dim iSelectColor As Integer
  
  iSelectColor = Color.Transparent 
  
  Select Case String.LCase(Last.Tag)
    
    Case CheckBoxUpdate.Tag 
      CheckBoxUpdate.Background = iSelectColor 
      LabelUpdate.Background = iSelectColor 
      
    Case CheckBoxYear.Tag 
      CheckBoxYear.Background = iSelectColor 
      LabelYear.Background = iSelectColor 
      
    Case CheckBoxQKW.Tag
      CheckBoxQKW.Background = iSelectColor 
      LabelQKW.Background = iSelectColor 
      
    Case CheckBoxBGColor.Tag
      CheckBoxBGColor.Background = iSelectColor 
      LabelBGColor.Background = iSelectColor 
      
    Case CheckBoxBGAluWood.Tag
      CheckBoxBGAluWood.Background = iSelectColor 
      LabelBGAluWood.Background = iSelectColor 
      
    Case Checkbg1.Tag
      Checkbg1.Background = iSelectColor 
      LabelBGAluminium.Background = iSelectColor 
      
    Case Checkbg2.Tag
      Checkbg2.Background = iSelectColor 
      LabelBGWood.Background = iSelectColor 
      
    Case CheckBoxLastBackup.Tag
      CheckBoxLastBackup.Background = iSelectColor 
      LabelLastBackup.Background = iSelectColor 
      
    Case CheckBoxPath.Tag
      CheckBoxPath.Background = iSelectColor 
      LabelPath.Background = iSelectColor 
      
    Case CheckBoxVorweckzeit.Tag
      CheckBoxVorweckzeit.Background = iSelectColor 
      LabelVorweckzeit.Background = iSelectColor 
      LabelVorweckzeitAnd.Background = iSelectColor 
      LabelVorweckzeitMin.Background = iSelectColor 
      
  End Select  
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "")
  
  Dim sDirFile, sText As String 
  
  Select Case String.LCase(sLastTag)
    Case "clear"
      ' ButtonClearG()
      ButtonSettingsClearAll()
    Case "timezone"
      SystemDatumZeitG()
    Case "text3resize"
      TextAreaText.SelectAll()
      sText = F_sPathText & gb.NewLine & gb.NewLine
      sText &= ("Uhr-Alarm") & ":" & gb.NewLine 
      sText &= Settings[FMain.Name &/ "F_sPathMusicSelect_mp3", "Standard"] & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= LabelVorweckzeit.Text & ":" & gb.NewLine 
      sText &= LabelVorweckzeitMin.Tooltip & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= F_sTimeZone & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= ("Veränderte Dateien") & ":" & gb.NewLine 
      sText &= FMain.F_sFilesChangedList & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= ("Icon/Symbol im Startbildschirm") & Space(1) & ("Schreibtisch") & ":" & gb.NewLine 
      sText &= Desktop.GetDirectory("DESKTOP") &/ Application.Name & ".desktop" & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= LabelIcon.Tooltip & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= ("Neue Version (Update)") & ":" & gb.NewLine 
      sText &= LabelUpdate.Tooltip & gb.NewLine 
      sText &= gb.NewLine
      
      sText &= LabelPath.Text & ":" & gb.NewLine 
      sText &= LabelPath.Tooltip & gb.NewLine 
      sText &= LabelPathB.Tooltip & gb.NewLine 
      
      TextAreaText.Insert(sText)
      ScrollViewBorder.Visible = False 
      PanelText.Visible = True 
    Case "canceltext"
      PanelText.Visible = False 
      ScrollViewBorder.Visible = True 
    Case "copytext"
      TextAreaText.SelectAll()
      Clipboard.Copy(TextAreaText.Selection.Text)
    Case "settings" 'Panel2
      ScrollViewBorder.Visible = False 
      PanelConfig.Visible = True 
      ButtonConfigOpenG()
    Case "openconfig"
      sDirFile = FilePathForm() 
      sDirFile = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirAppName] &/ File.Name(sDirFile)
      sDirFile = FileDialogPathReturn(sDirFile, "open", Settings[FMain.Name &/ "F_sPathSettings_conf", FMain.F_sPathSettings_conf])
      F_sDirFileBackupConf = sDirFile
      ButtonConfigOpenG(sDirFile) 'Backup config
    Case "saveconfig"
      ButtonConfigSaveG(F_sDirFileBackupConf) 'Settings speichern
    Case "cancelconfig"
      PanelConfig.Visible = False
      ScrollViewBorder.Visible = True  
    Case "path"
      ButtonPathG()
    Case "filemanager"
      sDirFile = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt] 
      M01Functions.FileManagerOpen(sDirFile)
    Case "directory"
      ButtonDirG()
      ' Case "settings"
      '   ButtonSettingsG() 'Panel2
    Case "sun"
      ButtonSunG()
    Case "dayplus"
      ButtonHolidaysG()
    Case "export"
      ButtonExportG()
    Case "autostart"
      ButtonStartG()
    Case "tmp"  
      ' ButtonTempG()
      
    Case "filechangelist"
      ButtonFileChangeListG()
    Case "symbol"
      ' M01Functions.Symbol_Desktop()
      M01Functions.LinkDesktopCreate()
    Case "iconinfo"
      ScrollViewBorder.Visible = False 
      IconInfoG()
    Case "desktop"
      CheckIconInDesktop()
    Case "music", "musicpath"
      LabelMusicG()
    Case "musictestplusalarm"
      PicNotePlusAlarmG() ' Musiktest
    Case "musictest", "note"
      PicNoteG() ' Musiktest
    Case "musiconoff"
      FMain.F_bClockAlarmMusicON = Not FMain.F_bClockAlarmMusicON
      Settings[FMain.Name &/ "F_bClockAlarmMusicON"] = FMain.F_bClockAlarmMusicON
      CheckClockAlarmButtonNoteOnOff()
    Case "trashopen"
      M01Functions.ExternTrash()
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "cancelform"
      FMain.F_bNeueinlesenStarten = True  'See FMain.RefreshAll()
      Form6Einst.Window.Close()  
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "close"
      FMain.F_bNeueinlesenStarten = True  'See FMain.RefreshAll()
      Form6Einst.Window.Close()
      
  End Select
  CheckMusicON()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '.........................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form19FileInfo.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form19FileInfo.class
10,7 KB
' Gambas class file

Public F_bMovingON As Boolean
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_sForm As String = Me.Name 

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Form19FileInfo.Tag 'Path from other Form
  If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerStandard_txt]
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  
  Dim sPath As String 
  
  Form19FileInfo.Window.Title = Application.Name & " - " & ("Info")
  If Not Form19FileInfo.Window.Icon Then Form19FileInfo.Window.Icon = FMain.Window.Icon
  
  '**********************
  sPath = Form19FileInfo.Tag
  '**********************
  
  If sPath = Null Then 
    sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
    Form19FileInfo.Tag = sPath
  Endif 
  
  FileProperties1.Path = sPath                                                            '"/Dir/file.ext" or "/Dir"
  If Exist(sPath) = True Then 
    LabelPath.Text = File.Dir(sPath) &/ "<font color=blue><b>" & File.Name(sPath) & "</b></font>"
    LabelPath.Text &= Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</b></font>"     'TextLabel > HTML
    If Stat(sPath).Size < 1000000 Then 
      LabelPath.Background = Color.SetAlpha(Color.Green, 150)
    Else If Stat(sPath).Size < 2000000 Then 
      LabelPath.Background = Color.Yellow
    Else 
      LabelPath.Background = Color.SetAlpha(Color.Red, 150)
    Endif 
  Else 
    LabelPath.Text = ("Ohne Datei")
    LabelPath.Foreground = Color.Red
  Endif 
  FormBackgroundColor()
  WindowStretchCursor()
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form19FileInfo.Left]
      iY = Settings[F_sForm &/ "Top", Form19FileInfo.Top]
      iW = Settings[F_sForm &/ "Width", Form19FileInfo.W]
      iH = Settings[F_sForm &/ "Height", Form19FileInfo.H]
      Form19FileInfo.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form19FileInfo.Left
      Settings[F_sForm &/ "Top"] = Form19FileInfo.Top
      Settings[F_sForm &/ "Width"] = Form19FileInfo.Width
      Settings[F_sForm &/ "Height"] = Form19FileInfo.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form19FileInfo.Window.Maximized = False Then
    Form19FileInfo.Window.Maximized = True
  Else
    Form19FileInfo.Window.Maximized = False
    Form19FileInfo.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iPH, i32, iBW, iBH As Integer 
  
  If Form19FileInfo.Width < 200 Then Form19FileInfo.Width = 200
  If Form19FileInfo.Height < 200 Then Form19FileInfo.Height = 200
  
  '**************
  iPH = 48 'ButtonCancel.H
  i32 = 32 'px Pixel
  '**************
  PicBackground.Move(0, 0, Form19FileInfo.ClientWidth, Form19FileInfo.ClientHeight) 'Hintergrund Aluminium, Holz oder Farbe
  iBW = PicBackground.Width / 100 * 3 ' Border Width (Randbreite)
  iBH = PicBackground.Height / 100 * 3 'Border Height
  
  IconError.Move(Form19FileInfo.ClientW - i32, 0, i32, i32)
  
  PanelBorder.Move(iBW, iBH, Form19FileInfo.ClientW - (iBW * 2), Form19FileInfo.ClientH - (iBH * 2))
  FileProperties1.Move(0, 0, PanelBorder.W, PanelBorder.H - (i32 * 3) - iPH)
  LabelTipp.Move(0, FileProperties1.Top + FileProperties1.H, FileProperties1.W, i32)
  LabelPath.Move(0, LabelTipp.Top + LabelTipp.H, LabelTipp.W, i32 * 2)
  PicBoxAddOut.Move(FileProperties1.W - i32, LabelTipp.Top, i32, i32)
  PicBoxAddOut.Raise()
  
  ButtonDir.Move(0, LabelPath.Top + LabelPath.H, iPH * 2, iPH)
  ButtonSystem.Move(ButtonDir.Left + ButtonDir.W, ButtonDir.Top, iPH * 2, iPH)
  ButtonTrashOpen.Move(ButtonSystem.Left + ButtonSystem.W, ButtonDir.Top, iPH * 2, iPH)
  ButtonCancel.Move(ButtonTrashOpen.Left + ButtonTrashOpen.W, ButtonDir.Top, Form19FileInfo.ClientW - (ButtonTrashOpen.Left + ButtonTrashOpen.W), iPH)
  
  ''Form stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form19FileInfo.ClientW - iPH - iBW, Form19FileInfo.ClientH - iPH - iBH, iPH, iPH)  
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub WindowStretch_DblClick()
  
  Form19FileInfo.Window.Maximized = Not Form19FileInfo.Window.Maximized 
  If Form19FileInfo.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form19FileInfo.Window.FullScreen = True Or Form19FileInfo.Window.Maximized = True Then 
      F_bMovingON = False
      Form19FileInfo.Window.FullScreen = False
      Form19FileInfo.Window.Maximized = False
      If Form19FileInfo.Left + Form19FileInfo.W > Screen.AvailableWidth Then Form19FileInfo.Move(Form19FileInfo.Left, Form19FileInfo.Top, Screen.AvailableWidth - Form19FileInfo.Left, Screen.AvailableHeight - Form19FileInfo.Top)
    Else
      F_bMovingON = True
      Form19FileInfo.Window.FullScreen = False
      Form19FileInfo.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form19FileInfo.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form19FileInfo.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form19FileInfo.ClientW - WindowStretch.W, Form19FileInfo.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form19FileInfo.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form19FileInfo.W = Mouse.ScreenX - F_iX1
    Form19FileInfo.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form19FileInfo.ClientW - WindowStretch.W, Form19FileInfo.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form19FileInfo.ClientW - WindowStretch.W, Form19FileInfo.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form19FileInfo.Window.Maximized = Not Form19FileInfo.Window.Maximized 
    If Form19FileInfo.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form19FileInfo.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonDirG()
  
  Dim sPath As String 
  
  ButtonDir.Background = Color.Default
  Try sPath = Form19FileInfo.Tag
  If Exist(sPath) = False Then 
    sPath = FilePathForm()
    If Exist(sPath) = False Then sPath = User.Home
  Endif 
  sPath = M01Functions.FileManagerOpen(sPath) 'Path or "" Null
  If Exist(sPath) = False Then ButtonDir.Background = Color.Red
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  Last.Background = Color.Green
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  Last.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "Left")
  Dim sPath As String 
  
  sMouseLMR = String.Left(sMouseLMR, 1)
  
  Select Case String.LCase(sLastTag)
    
    Case ButtonDir.Tag '"directory"
      ButtonDirG()
    
    Case "dir" 'Menu
      sPath = FilePathForm()
      If Exist(sPath) = False Then sPath = User.Home
      M01Functions.FileManagerOpen(sPath)
      
    Case ButtonSystem.Tag 'Apps
      M01Functions.SystemStandardApplications() 'System Info
      
    Case "trashopen"
      M01Functions.ExternTrash()
      
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    
    Case "resetform"
      M01Functions.ResetForm(F_sForm)  
      
    Case "cancelform", ButtonCancel.Tag 
      Form19FileInfo.Window.Close
      
  End Select 
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End '..............................





Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form12Timerplus.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form12Timerplus.class
100 KB
' Gambas class file

'F_=Form
Public F_bbCheckBoxesMerker As New Boolean[11] '0-10
Public F_bChangeON As Boolean 
Public F_bESCpressedON As Boolean
Public F_bListeveraendert As Boolean
Public F_bMovingON As Boolean
Public F_dateEingabeDatum As Date
Public F_dateNow As Date 
Public F_iColorBlueAlpha150 As Integer = Color.SetAlpha(Color.Blue, 150)
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorSelected As Integer = Color.LightBackground 
Public F_iColorSelectGreen As Integer = Color.Green
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iF_iOnly1x As Integer
Public F_iMusterTermine1Names2Projects3 As Integer = 1 '!!! ******************************************
Public F_iSekunden As Integer
Public F_iSide As Integer
Public F_iWochentag As Integer
Public F_iWochentagMerker As Integer
Public F_iWorkPlace0123 As Integer
Public F_iX1 As Integer 
Public F_iY1 As Integer
Public F_picFavicon As Picture
Public F_sDatumMerker As String
Public F_sForm As String = Me.Name 
Public F_sNewOrdnerDateiHTML As String 
Public F_sOrdnerDateiHTML As String
Public F_sPfadFavicon As String
Public F_ssNotizMerker As New String[11]
Public F_statOrdnerDateiHTMLZeitAlt As Stat
Public F_statOrdnerDateiHTMLZeitNew As Stat
Public F_sTitleBasicText As String
Public F_sUhrMerker As String
Public F_sURLblankempty As String = "about:blank" 'empty (leer)  

Public Function FilePathForm() As String 
  
  Return Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Menu1.Visible = False
  MenuBG.Visible = False
  Form12Timerplus.Window.Title = Application.Name & " - " & ("Timerplus") & "+"
  F_sTitleBasicText = Form12Timerplus.Window.Title
  If Not Form12Timerplus.Window.Icon Then Form12Timerplus.Window.Icon = FMain.Window.Icon
  Menu1.Visible = False
  
  FormBackgroundColor()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  If System.Error > 0 Then Form12Timerplus.Window.Close()
  
End

Public Sub Form_Activate()
  
  If F_iF_iOnly1x = 0 Then 
    FormStart()
    F_iF_iOnly1x = 1
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  Dim it As Integer
  Dim ssWT As New String[8] ' 0, 1-7=8  hier wegen Übereinstimmung mit Schalter-Nummern 1-7.
  Dim dateDatum As Date
  Dim picIcon As Picture
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1, 2 'Termine, Project-Names
      F_iColumnNr = 6                                  'Termine 6, in Projects 13
      F_iColumnUndo = 7                                'Termine 7, in Projects 10
      F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 9                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
      
    Case 3 'Projects
      F_iColumnNr = 13                                  'Termine 6, in Projects 13
      F_iColumnUndo = 10                                'Termine 7, in Projects 10
      F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 12                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  End Select 
  
  F_bChangeON = False 'siehe oben im Form-Kopf Deklarationen
  
  SettingsReadSave("read")
  TextBoxAdress.Text = F_sURLblankempty
  TextBoxPath.Text = FilePathForm()
  TextT5.Text = ("Notiz") 'Fest, fix
  
  dateDatum = DateAdd(Now, gb.Day, 7 - WeekDay(Now)) ' This example gives the date for the next coming sunday
  it = 0
  ssWT[1] = Format(DateAdd(dateDatum, gb.day, it), "ddd")     'So 0  gb.Sunday
  ssWT[2] = Format(DateAdd(dateDatum, gb.day, it + 1), "ddd") 'Mo 1
  ssWT[3] = Format(DateAdd(dateDatum, gb.day, it + 2), "ddd") 'Di 2
  ssWT[4] = Format(DateAdd(dateDatum, gb.day, it + 3), "ddd") 'Mi 3
  ssWT[5] = Format(DateAdd(dateDatum, gb.day, it + 4), "ddd") 'Do 4
  ssWT[6] = Format(DateAdd(dateDatum, gb.day, it + 5), "ddd") 'Fr 5
  ssWT[7] = Format(DateAdd(dateDatum, gb.day, it + 6), "ddd") 'Sa 6
  
  ButtonWeekDay0.Text = ssWT[1] 'So
  ButtonWeekDay1.Text = ssWT[2]
  ButtonWeekDay2.Text = ssWT[3]
  ButtonWeekDay3.Text = ssWT[4]
  ButtonWeekDay4.Text = ssWT[5]
  ButtonWeekDay5.Text = ssWT[6]
  ButtonWeekDay6.Text = ssWT[7]
  
  LabelW1.Text = ssWT[1] 'So
  LabelW2.Text = ssWT[2]
  LabelW3.Text = ssWT[3]
  LabelW4.Text = ssWT[4]
  LabelW5.Text = ssWT[5]
  LabelW6.Text = ssWT[6]
  LabelW7.Text = ssWT[7]
  
  'TextBoxWP0.Text = Settings[F_sForm &/ "TextM0", TextBoxWP0.Text] 'Neu, deaktiviert
  TextBoxWP1.Text = Settings[F_sForm &/ "TextM1", TextBoxWP1.Text] 'Speicher-Name
  TextBoxWP2.Text = Settings[F_sForm &/ "TextM2", TextBoxWP2.Text]
  TextBoxWP3.Text = Settings[F_sForm &/ "TextM3", TextBoxWP3.Text]
  
  F_iWorkPlace0123 = Settings[F_sForm &/ "F_iWorkPlace0123", 1]
  WorkPlace(F_iWorkPlace0123, "read") 'only read
  
  Form_Resize()
  
  WindowStretchCursor()
  PicArrowR.Picture = PicTemplateArrowLine.Picture.Image.Stretch(22, 22).Picture
  picIcon = M01Functions.ExternStandardBrowserIcon() 'as Picture
  If picIcon Then ButtonBrowser.Picture = picIcon.Image.Stretch(22, 22).Picture
  picIcon = Picture.Load("images/info_32.png")
  If picIcon Then ButtonFileInfo.Picture = picIcon.Image.Stretch(22, 22).Picture
  If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  F_bChangeON = True 
  
End

Public Sub CalendarRefresh()
  
  Dim sOrdnerDateiTXT As String
  
  ProgressBarONoff(True)
  
  sOrdnerDateiTXT = FilePathForm()  '*.txt
  
  F_sOrdnerDateiHTML = sOrdnerDateiTXT 
  If String.LCase(File.Ext(F_sOrdnerDateiHTML)) <> "html" Then F_sOrdnerDateiHTML = F_sOrdnerDateiHTML & ".html"
  If Exist(F_sOrdnerDateiHTML) = True Then 
    F_statOrdnerDateiHTMLZeitAlt = Stat(F_sOrdnerDateiHTML) 
  Else 
    F_statOrdnerDateiHTMLZeitAlt = Null
  Endif 
  
  F_sNewOrdnerDateiHTML = M04Kalender.CalendarReadCreateHTML(sOrdnerDateiTXT) 'as String
  
  ''Check:
  If String.LCase(File.Ext(F_sNewOrdnerDateiHTML)) <> "html" Then F_sNewOrdnerDateiHTML = F_sNewOrdnerDateiHTML & ".html"
  If Exist(F_sNewOrdnerDateiHTML) = True Then 
    WebView1.Url = "file://" & F_sOrdnerDateiHTML & "#heute"
  Else 
    WebView1.Url = F_sURLblankempty
  Endif 
  TextBoxAdress.Text = F_sNewOrdnerDateiHTML
  LabelMessage.Text = WebView1.Url
  
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  Form12Timerplus.Mouse = Mouse.Default
  ProgressBar1.Visible = False
  
End

Public Sub CalendarTestRefresh()
  
  Dim sTempPath As String
  
  ProgressBarONoff(True)
  
  sTempPath = M01Functions.CheckDirectoryCache() &/ Application.Name & "-empty.txt"
  File.Save(sTempPath, TextAreaEdit1.Text)
  
  F_sOrdnerDateiHTML = sTempPath 
  If String.LCase(File.Ext(F_sOrdnerDateiHTML)) <> "html" Then F_sOrdnerDateiHTML = F_sOrdnerDateiHTML & ".html"
  If Exist(F_sOrdnerDateiHTML) = True Then 
    F_statOrdnerDateiHTMLZeitAlt = Stat(F_sOrdnerDateiHTML) 
  Else 
    F_statOrdnerDateiHTMLZeitAlt = Null
  Endif 
  
  F_sNewOrdnerDateiHTML = M04Kalender.CalendarReadCreateHTML(sTempPath, Year(F_dateEingabeDatum), Year(F_dateEingabeDatum) + 1) 'as String
  
  ''Check:
  If String.LCase(File.Ext(F_sNewOrdnerDateiHTML)) <> "html" Then F_sNewOrdnerDateiHTML = F_sNewOrdnerDateiHTML & ".html"
  If Exist(F_sNewOrdnerDateiHTML) = True Then 
    WebView1.Url = "file://" & F_sOrdnerDateiHTML & "#heute"
  Else 
    WebView1.Url = F_sURLblankempty
  Endif 
  TextBoxAdress.Text = F_sNewOrdnerDateiHTML
  LabelMessage.Text = WebView1.Url
  
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  Form12Timerplus.Mouse = Mouse.Default
  ProgressBar1.Visible = False
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  ' If Timer1.Enabled = True Then
  '   ' F_bESCpressedON = M01Functions.ESCmessage() 'as Boolean, True or False
  '   If F_bESCpressedON = True Then Timer1.Stop()
  ' Else
  '   F_bESCpressedON = False
  ' Endif
  
  ''Reset:
  F_bChangeON = True 'Reset
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  Form12Timerplus.Mouse = Mouse.Default
  WebView1.Stop()
  IconError.Visible = False
  
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then Form12Timerplus.Window.Title = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") Else Form12Timerplus.Window.Title = F_sTitleBasicText
  Me.Maximized = False
  Me.FullScreen = False
    
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC2_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'Beispielaufruf: 
  'ohne Value         ProgressBarONoff(TRUE)
  'oder direkt mit    ProgressBar1.Value = Zaehler / ColumnView1.Count
  'oder direkt mit    ProgressBar1.Value = 0.99 / ColumnView1.Count * it
  'ProgressBar1.Pulse = True  '◀▷'[......■■...]  False: [■■■□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'zurck zum Anfang
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 'Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'Ausschalten
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt kurz Steuerung ab, Aufbau
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'zurück zum Anfang
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer() 'Timer1.Delay = 1000  = 1 Sekunde
  
  If PanelKalender.Visible = True Then ProgressBarONoff(True)
  
  If F_bESCpressedON = True Then
    If M01Functions.ESCmessage() = True Then 
      Timer1.Stop()
      Goto ESCEnde
    Endif
  Endif
  F_iSekunden = F_iSekunden + 1
  
ESCEnde: 
  If PanelKalender.Visible = True And Timer1.Enabled = False Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ColumnView1Resize()
  
  Dim it As Integer
  
  ColumnView1.Sorted = True
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(1)
  ' ColumnView1.Columns[0].Text = ("Datum")
  ColumnView1.Columns[1].Text = ("Uhr")
  ColumnView1.Columns[2].Text = Space(1)
  ColumnView1.Columns[3].Text = Space(1)
  ColumnView1.Columns[4].Text = Space(1)
  ColumnView1.Columns[5].Text = ("Notizen")
  ColumnView1.Columns[0].Width = 200  '.AutoResize = False?
  ColumnView1.Columns[1].Width = 70
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 70
  ColumnView1.Columns[5].Width = 0
  For it = 6 To ColumnView1.Columns.Max     '>9 or >13
    ColumnView1.Columns[it].Title = ""         'ColumnsUndo
    ColumnView1.Columns[it].Width = 0          'ColumnsUndo
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[5].Left + 20
  ColumnViewAscending()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
Catch 
  FMain.ErrorText
  
End


Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  ' If ColumnView2.Columns.Ascending = True Then  
  '   ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ' Else 
  '   ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  ' Endif 
  
Catch 
  FMain.ErrorText
    
End

Public Sub ReadG()
  
  Dim it, n, iLine, iWoche, iWocheLast As Integer
  Dim iBereichAnfang, iBereichEnde As Integer
  Dim T0, T1, T2, T3, T4, T5 As String
  Dim ssNotiz As New String[11] '=0-9  0, 1-10 hier ohne Null wegen Übereinstimmung bei Schalter-Nummern 1-10
  Dim bbCheckWoche As New Boolean[11]
  Dim hDate, hDateAnfang, hDateNext As Date
  Dim sKey As String 
  
  ProgressBarONoff(True)
  'Check: 
  hDate = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date "yyyy-mm-dd", "hh:nn"
  F_bChangeON = False 
  
  'bbCheckWoche[0] ...'hier ohne Array 0
  bbCheckWoche[1] = CheckBox1.Value 'True or False
  bbCheckWoche[2] = CheckBox2.Value
  bbCheckWoche[3] = CheckBox3.Value
  bbCheckWoche[4] = CheckBox4.Value
  bbCheckWoche[5] = CheckBox5.Value
  bbCheckWoche[6] = CheckBox6.Value
  bbCheckWoche[7] = CheckBox7.Value
  bbCheckWoche[8] = CheckBox8.Value
  bbCheckWoche[9] = CheckBox9.Value
  bbCheckWoche[10] = CheckBox10.Value
  
  For it = bbCheckWoche.Max To 0 Step -1 'letzte CheckWoche ermitteln
    If bbCheckWoche[it] = True Then 
      iWocheLast = it
      Break
    Endif 
  Next
  
  If CheckBox1.Value = True Then ssNotiz[1] = Text1.Text
  If CheckBox2.Value = True Then ssNotiz[2] = Text2.Text
  If CheckBox3.Value = True Then ssNotiz[3] = Text3.Text
  If CheckBox4.Value = True Then ssNotiz[4] = Text4.Text
  If CheckBox5.Value = True Then ssNotiz[5] = Text5.Text
  If CheckBox6.Value = True Then ssNotiz[6] = Text6.Text
  If CheckBox7.Value = True Then ssNotiz[7] = Text7.Text
  If CheckBox8.Value = True Then ssNotiz[8] = Text8.Text
  If CheckBox9.Value = True Then ssNotiz[9] = Text9.Text
  If CheckBox10.Value = True Then ssNotiz[10] = Text10.Text
  
  ColumnView1.Visible = False
  ColumnView1.Clear()
  ColumnView1.Header = 1 ' Sichtbar
  ColumnView1.Sorted = CheckBox2.Value ' siehe Schalter
  'Spalten (Columns) erzeugen
  ColumnView1.Columns.Count = 12               '7 = 0 bis 6
  
  ColumnView1Resize()
  
  ColumnView1.Scroll(0, 0) 'Reset Scrollbars left,top
  
  'zum ersten eingestellten Wochentag
  For it = 0 To 7
    hDateAnfang = DateAdd(hDate, gb.day, it) 'as Date
    If WeekDay(hDateAnfang) = F_iWochentag Then Break
  Next
  
  iWoche = 1
  For it = 0 To SliderList.MaxValue Step 7 '2 Jahre im Wochen-Rhythmus
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    hDateNext = DateAdd(hDateAnfang, gb.day, it) 
    If iWoche > 10 Or iWoche > iWocheLast Then iWoche = 1
    
    If bbCheckWoche[iWoche] = True And ssNotiz[iWoche] <> "" Then ' 0-9
      T0 = Format(hDateNext, "yyyy-mm-dd")
      T1 = TextT1.Text
      T2 = Format(hDateNext, "ddd")
      T3 = M01Functions.DateQuarterG(hDateNext) & "Q" '1...4
      T4 = Format(M01Functions.DateCalenderWeek(hDateNext), "00") & ("KW") '00...52
      T5 = "+" & ssNotiz[iWoche]
      T5 = Replace(T5, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
      T5 = Replace(T5, FMain.F_sTab, Space(3))
      iBereichAnfang = DateDiff(Date, hDateNext, gb.day) 'Anfang Heute
      iBereichEnde = DateDiff(Date(Year(Date), 12, 31), hDateNext, gb.day) 'Ende letzter Tag im Jahr
      
      sKey = ColumnView1.Count + 1
      ColumnView1.Add(sKey, "")
      ColumnView1[sKey][0] = T0
      ColumnView1[sKey][1] = T1
      ColumnView1[sKey][2] = T2
      ColumnView1[sKey][3] = T3
      ColumnView1[sKey][4] = T4
      ColumnView1[sKey][5] = T5
      
      ''Undo:
      ColumnView1[sKey][6] = T0
      ColumnView1[sKey][7] = T1
      ColumnView1[sKey][8] = T2
      ColumnView1[sKey][9] = T3
      ColumnView1[sKey][10] = T4
      ColumnView1[sKey][11] = T5
      
      'Check Bereich mit Pfeil ▶
      If iBereichAnfang >= 0 And iBereichEnde <= 0 Then 
        ColumnView1[sKey].Picture = PicArrowR.Picture
        n = n + 1
      Endif 
    Endif 'ssNotiz
    iWoche = iWoche + 1
  Next
  
  ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  LabelRhythmusInfo.Text = Str("▶") & Str(n) & "/" & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  CheckBoxesInfo()
  ProgressBarONoff(False)
  ColumnView1.Visible = True
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  ProgressBarONoff(False)
  ColumnView1.Visible = True
  
End

Public Sub Form_Resize()
  
  Dim it, n, iWert As Integer
  Dim BX, BY, iPH, fWert As Float
  
  If Form12Timerplus.Width < 200 Then Form12Timerplus.Width = 200
  If Form12Timerplus.Height < 200 Then Form12Timerplus.Height = 200
  
  BX = Form12Timerplus.ClientW / 100 * 3.2 ' Border (Randbreite)
  BY = Form12Timerplus.ClientH / 100 * 3
  '************************
  iPH = 40 'Pixel px  Panel Height
  '************************
  IconError.Move(Form12Timerplus.ClientW - 32, 0, 32, 32)
  PicBackground.Move(0, 0, Form12Timerplus.Clientw, Form12Timerplus.ClientH)
  fWert = (Form12Timerplus.ClientW - (BX * 2)) / 7 'Weekdays
    
  ''Title:
  LabelTimerplusA.Move(BX, BY, Form12Timerplus.ClientW - (fWert * 4) - (BX * 2), iPH * 2) 
  LabelTimerplusA.Font.Size = M01Functions.FontSizeCheck(LabelTimerplusA.Text, LabelTimerplusA.Font, LabelTimerplusA.W, False) * 0.6 ''Wrap=False
  If LabelTimerplusA.Font.Size > 35 Then LabelTimerplusA.Font.Size = 35
  ''Shadow (Schatten)
  LabelTimerplusB.Font = LabelTimerplusA.Font
  LabelTimerplusB.Move(LabelTimerplusA.Left - 3, LabelTimerplusA.Top + 3, LabelTimerplusA.Width, LabelTimerplusA.Height) 
  
  PanelMerker.Move(LabelTimerplusA.Left + LabelTimerplusA.W, LabelTimerplusA.Top, Form12Timerplus.ClientW - BX - (LabelTimerplusA.Left + LabelTimerplusA.W), LabelTimerplusA.H)
  
  ''Panel Rhythmus 1-10:
  PanelRhythmus.Move(LabelTimerplusA.Left, LabelTimerplusA.Top + LabelTimerplusA.H, Form12Timerplus.ClientW - (BX * 2), Form12Timerplus.ClientH - (BY * 2) - LabelTimerplusA.H - (iPH * 5))
  PanelWT.Move(0, 0, PanelRhythmus.W, iPH)
  fWert = PanelWT.W / 7
  For it = 0 To PanelWT.Children.Max 'So, Mo, Di, Mi, Do, Fr, Sa   'ToggleButtonW 1-7
    n = CInteger(Str(PanelWT.Children[it].Tag)) '0-6
    PanelWT.Children[it].Move(fWert * n, 0, fWert, iPH)
    PanelWT.Children[it].Font.Size = iPH / 2
  Next 
  
  ListContainer1.Move(0, PanelWT.Top + PanelWT.H, PanelRhythmus.W, PanelRhythmus.H - PanelWT.H)
  ''Notiz-Felder:
  Text1.W = ListContainer1.W - Text1.Left - Desktop.Y
  Text2.W = Text1.W
  Text3.W = Text1.W
  Text4.W = Text1.W
  Text5.W = Text1.W
  Text6.W = Text1.W
  Text7.W = Text1.W
  Text8.W = Text1.W
  Text9.W = Text1.W
  Text10.W = Text1.W
  
  
  ButtonWorkPlace0.Move(-iPH * 2.5, 0, iPH * 2.5, iPH) 'unused
  iWert = TextBoxWP1.Font.TextHeight("WorkPlace") + 8
    
  ''Workplace 1:
  ButtonWorkPlace1.Move(ButtonWorkPlace0.Left + ButtonWorkPlace0.W, 0, fWert * 0.5, PanelMerker.H - iWert)
  ButtonPlus1.Move(ButtonWorkPlace1.Left + ButtonWorkPlace1.W, 0, fWert * 0.5, ButtonWorkPlace1.H)
  PanelMerkerBG1.Move(ButtonWorkPlace1.Left, 0, fWert, PanelMerker.H)
  
  ''Workplace 2:
  ButtonWorkPlace2.Move(ButtonPlus1.Left + ButtonPlus1.W, 0, ButtonWorkPlace1.W, ButtonWorkPlace1.H)
  ButtonPlus2.Move(ButtonWorkPlace2.Left + ButtonWorkPlace2.W, 0, ButtonWorkPlace1.W, ButtonWorkPlace1.H)
  PanelMerkerBG2.Move(ButtonWorkPlace2.Left, 0, fWert, PanelMerker.H)
  
  ''Workplace 3:
  ButtonWorkPlace3.Move(ButtonPlus2.Left + ButtonPlus2.W, 0, ButtonWorkPlace1.W, ButtonWorkPlace1.H)
  ButtonPlus3.Move(ButtonWorkPlace3.Left + ButtonWorkPlace3.W, 0, ButtonWorkPlace1.W, ButtonWorkPlace1.H)
  PanelMerkerBG3.Move(ButtonWorkPlace3.Left, 0, fWert, PanelMerker.H)
  
  ''Workplace Names:
  TextBoxWP0.Move(ButtonWorkPlace0.Left, ButtonWorkPlace0.Top + ButtonWorkPlace0.H, ButtonWorkPlace0.W, iWert)'unused
  TextBoxWP1.Move(PanelMerkerBG1.Left, ButtonWorkPlace1.Top + ButtonWorkPlace1.H, PanelMerkerBG1.W, iWert)
  TextBoxWP2.Move(PanelMerkerBG2.Left, ButtonWorkPlace2.Top + ButtonWorkPlace1.H, PanelMerkerBG2.W, iWert)
  TextBoxWP3.Move(PanelMerkerBG3.Left, ButtonWorkPlace3.Top + ButtonWorkPlace1.H, PanelMerkerBG3.W, iWert)
  
  ButtonRhythmusTextOpen.Move(ButtonPlus3.Left + ButtonPlus3.W, ButtonPlus3.Top, fWert * 0.5, PanelMerker.H)
  ButtonRhythmusTextSave.Move(ButtonRhythmusTextOpen.Left + ButtonRhythmusTextOpen.W, ButtonRhythmusTextOpen.Top, ButtonRhythmusTextOpen.W, ButtonRhythmusTextOpen.H)
  
  ButtonMenu.Move(Form12Timerplus.ClientW - BX - ButtonMenu.W, PanelMerker.Top, ButtonMenu.W, PanelMerker.H)
  
  ''Panel Date:
  PanelDateChooser.Move(PanelRhythmus.Left, PanelRhythmus.Top, PanelRhythmus.W, PanelRhythmus.H)
  DateChooser1.Move(0, 0, PanelDateChooser.W, PanelDateChooser.H - iPH)
  CancelDate.Move(0, DateChooser1.Top + DateChooser1.H, PanelDateChooser.W, iPH)
  ColumnView3.Move(BX, BY, TextT0.Left + TextT0.W, Form12Timerplus.ClientH - (BY * 2)) 'Liste "00:00", ...., "23:59"
  
  ''Panel List:
  PanelListe.Move(PanelRhythmus.Left, PanelRhythmus.Top, PanelRhythmus.W, PanelRhythmus.H)
  fWert = iPH 
  PicArrowR.Move(0, 0, fWert, fWert)
  
  ButtonMinusDay.Move(PicArrowR.Left + PicArrowR.W, 0, fWert, fWert)
  ButtonPlusDay.Move(ButtonMinusDay.Left + ButtonMinusDay.W, 0, fWert, fWert)
  LabelListeInfo.Move(ButtonPlusDay.Left + ButtonPlusDay.W, 0, fWert * 5, ButtonMinusDay.H)
  
  ButtonMinusCWeek.Move(LabelListeInfo.Left + LabelListeInfo.W, 0, fWert, fWert)
  ButtonPlusCWeek.Move(ButtonMinusCWeek.Left + ButtonMinusCWeek.W, 0, fWert, fWert)
  LabelListeInfoCWeek.Move(ButtonPlusCWeek.Left + ButtonPlusCWeek.W, 0, PanelListe.W - (ButtonPlusCWeek.Left + ButtonPlusCWeek.W) - (fWert * 3), ButtonMinusDay.H)
  
  LabelListeDateDiff.Move(LabelListeInfoCWeek.Left + LabelListeInfoCWeek.W, 0, PanelListe.W - (LabelListeInfoCWeek.Left + LabelListeInfoCWeek.W), ButtonMinusDay.H)
  ColumnView1.Move(0, ButtonMinusDay.Top + ButtonMinusDay.H, PanelListe.W - (iPH * 2), PanelListe.H - ButtonMinusDay.H)
  PanelSlider.Move(PanelListe.W - (iPH * 2), ColumnView1.Top, iPH * 2, ColumnView1.H)
  ButtonMinusWeek.Move(0, 0, fWert, fWert)
  SliderList.Move(0, fWert, fWert, PanelSlider.H - (iPH * 2))
  ButtonPlusWeek.Move(0, PanelSlider.H - fWert, fWert, fWert)
  fWert = PanelSlider.H / 7
  LabelW1.Move(ButtonMinusWeek.W, fWert * 0, ButtonMinusWeek.W, fWert)
  LabelW2.Move(ButtonMinusWeek.W, fWert * 1, ButtonMinusWeek.W, fWert)
  LabelW3.Move(ButtonMinusWeek.W, fWert * 2, ButtonMinusWeek.W, fWert)
  LabelW4.Move(ButtonMinusWeek.W, fWert * 3, ButtonMinusWeek.W, fWert)
  LabelW5.Move(ButtonMinusWeek.W, fWert * 4, ButtonMinusWeek.W, fWert)
  LabelW6.Move(ButtonMinusWeek.W, fWert * 5, ButtonMinusWeek.W, fWert)
  LabelW7.Move(ButtonMinusWeek.W, fWert * 6, ButtonMinusWeek.W, fWert)
  
  ''Panel Text:
  PanelText.Move(PanelRhythmus.Left, PanelRhythmus.Top, PanelRhythmus.W, PanelRhythmus.H)
  TextAreaEdit1.Move(0, 0, PanelRhythmus.W, PanelRhythmus.H)
  
  ''Panel Calendar:
  PanelKalender.Move(PanelRhythmus.Left, PanelRhythmus.Top, PanelRhythmus.W, PanelRhythmus.H)
  ButtonBrowser.Font = TextBoxAdress.Font
  iWert = TextBoxAdress.Font.TextHeight(TextBoxAdress.Text) + 10
  PanelKalPath.Move(0, 0, PanelKalender.W, iWert)
  KalFileInfo.Move(0, 0, iWert, iWert)
  TextBoxAdress.Move(KalFileInfo.Left + KalFileInfo.W, 0, PanelKalPath.W - (KalFileInfo.Left + KalFileInfo.W) - (iWert * 9), iWert)
  LabelInfoAdress.Move(TextBoxAdress.Left, TextBoxAdress.Top, TextBoxAdress.W, TextBoxAdress.H)
  ButtonBrowser.Move(PanelKalPath.W - (iWert * 9), 0, iWert * 9, iWert)
  ButtonIcon.Move(PanelKalPath.W - iWert, 0, iWert, iWert)
  WebView1.Move(0, PanelKalPath.Top + PanelKalPath.H, PanelKalender.W, PanelKalender.H - (PanelKalPath.Top + PanelKalPath.H))
  
  ''Panel Tabs:
  PanelTabs.Move(PanelRhythmus.Left, PanelRhythmus.Top + PanelRhythmus.H, PanelRhythmus.W, iPH * 1)
  ' TabStrip1.Move(0, 0, PanelTabs.W, PanelTabs.H)
  fWert = PanelTabs.W / PanelTabs.Children.Count
  ButtonRhythmus.Move(0, 0, fWert, PanelTabs.H)
  ButtonList.Move(ButtonRhythmus.Left + ButtonRhythmus.W, 0, fWert, PanelTabs.H)
  ButtonCalendar.Move(ButtonList.Left + ButtonList.W, 0, fWert, PanelTabs.H)
  ButtonText.Move(ButtonCalendar.Left + ButtonCalendar.W, 0, fWert, PanelTabs.H)
  ButtonCut.Move(ButtonText.Left + ButtonText.W, 0, fWert, PanelTabs.H)
  ButtonDemo.Move(ButtonCut.Left + ButtonCut.W, 0, fWert, PanelTabs.H)
    
  ''Panel Info 1-10:
  PanelInfo.Move(PanelRhythmus.Left, PanelTabs.Top + PanelTabs.H, PanelRhythmus.W, iPH / 2)
  LabelRhythmusInfo.Move(0, 0, PanelInfo.H * 7, Panelinfo.H)
  LabelRhythmus.Move(LabelRhythmusInfo.Left + LabelRhythmusInfo.W, 0, PanelInfo.W / 2, PanelInfo.H)
  LabelRhythmus0to10Text.Move(LabelRhythmus.Left + LabelRhythmus.W, 0, PanelInfo.W - (LabelRhythmus.Left + LabelRhythmus.W), Panelinfo.H)
  ProgressBar1.Move(0, 0, PanelInfo.W, Panelinfo.H)
  
  ''Panel Notice:
  PanelDateTimeNotiz.Move(PanelRhythmus.Left, PanelInfo.Top + Panelinfo.H, PanelRhythmus.W, iPH * 1.5)
  TextT0.Move(0, 0, TextT0.Font.TextWidth("yyyy-mm-dd "), iPH)
  TextT1.Move(TextT0.Left + TextT0.W + (iPH / 2), 0, TextT1.Font.TextWidth("hh:nn "), TextT0.H)
  LabelWT.Move(TextT1.Left + TextT1.W, 0, iPH * 3, TextT0.H)
  TextT5.Move(LabelWT.Left + LabelWT.W, 0, PanelDateTimeNotiz.W - (LabelWT.Left + LabelWT.W) - iPH, TextT0.H)
  LabelMessage.Move(0, iPH, PanelDateTimeNotiz.W, PanelDateTimeNotiz.H - TextT0.H)
  Text0BG.Move(TextT0.Left, TextT0.Top, TextT0.W, TextT0.H)
  Text1BG.Move(TextT1.Left, TextT1.Top, TextT1.W, TextT1.H)
  ListIsChanged.Move(PanelDateTimeNotiz.W - iPH, 0, iPH, iPH)
  
  ''Panel File-Path:
  PanelPath.Move(PanelRhythmus.Left, PanelDateTimeNotiz.Top + PanelDateTimeNotiz.H + (iPH * 0.5), PanelRhythmus.W, iPH * 0.5)  
  ButtonFileInfo.Move(0, 0, PanelPath.H, PanelPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelPath.H)  
  LabelInfo.Move(TextBoxPath.Left, TextBoxPath.Top, TextBoxPath.W, TextBoxPath.H)
  
  ''Panel Save:
  PanelSave.Move(PanelRhythmus.Left, PanelPath.Top + PanelPath.H, PanelRhythmus.W, Form12Timerplus.ClientH - (PanelPath.Top + PanelPath.H) - BY)
  ButtonEdit.Move(0, 0, LabelWT.Left, PanelSave.H) 
  ButtonSave.Move(ButtonEdit.Left + ButtonEdit.W, 0, TextT5.W / 2, PanelSave.H)
  CancelForm.Move(ButtonSave.Left + ButtonSave.W, 0, PanelSave.W - (ButtonSave.Left + ButtonSave.W), PanelSave.H)
  
  WindowStretch.Height = PanelSave.H
  If F_bMovingON = False Then WindowStretch.Move(Form12Timerplus.ClientW - WindowStretch.Height - BX, Form12Timerplus.ClientH - WindowStretch.Height - BY, WindowStretch.Height, WindowStretch.Height) 'quadratisch
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  PanelMerkerBG1.Lower
  PanelMerkerBG2.Lower
  PanelMerkerBG3.Lower
  LabelTimerplusB.Raise() 'Schatten
  LabelTimerplusA.Raise() '▲Top▲
  PanelDateChooser.Raise
  WindowStretch.Raise 'Level ▲Top▲
  IconError.Raise
  
  Text0BG.Raise() 'Changed auch bei Farbwechsel, deshalb extra Background für Farbhinweis
  Text1BG.Raise()
  
  TextT0.Raise()
  TextT1.Raise()
  
  LabelInfoAdress.Raise() '*.html
  LabelInfo.Raise() '*.txt
  ButtonFileInfo.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sMessage As String 
  
  If F_bListeveraendert = True Then
    SideG(1) 'Notice
  
    sMessage &= LabelRhythmus.Text & "<br>" 
    sMessage &= "<h3><font color=red>" & ("Veränderte Liste") & "</font></h3>"
    sMessage &= "<font color=gray>" & FilePathForm() & "</font>" 'FMain.F_sPathTerminweckerActual_txt
    
    Select Message.Question(sMessage, ("Speichern..."), ("Nein"), ("Abbrechen"))
      Case 1 ''Save
        SaveListG() 'Termine anhängen
      Case 2 ''Close
        '...
      Case 3 ''Cancel
        Stop Event  ' Vorgang abbrechen
    End Select
  Endif
  Settings[F_sForm &/ "F_iWorkPlace0123"] = F_iWorkPlace0123
  Settings[F_sForm &/ "TextM1"] = TextBoxWP1.Text
  Settings[F_sForm &/ "TextM2"] = TextBoxWP2.Text
  Settings[F_sForm &/ "TextM3"] = TextBoxWP3.Text
  WorkPlace(F_iWorkPlace0123, "save")
  
  SettingsReadSave("save")
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form12Timerplus.Window.Maximized = False Then
    Form12Timerplus.Window.Maximized = True
  Else
    Form12Timerplus.Window.Maximized = False
    Form12Timerplus.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub RefreshDate(Optional dateDatum As Date = Now)
  
  Dim it As Integer
  
  F_bChangeON = False 
  SliderList.MinValue = 0
  SliderList.MaxValue = DateDiff(Date(Year(dateDatum), 1, 1), Date(Year(dateDatum) + 1, 12, 31), gb.day) ' 2 Jahre= 2*365
  SliderList.Value = DateDiff(Date(Year(dateDatum), 1, 1), dateDatum, gb.day)
  F_iWochentag = WeekDay(dateDatum)
  LabelMessage.Background = Color.Default
  LabelWT.Background = Color.Default
  Text0Insert(Format(dateDatum, "yyyy-mm-dd"))
  LabelMessage.Text = Format(dateDatum, "dddd")
  Text1Insert(Format(dateDatum, "hh:nn"))
  LabelWT.Text = Format(dateDatum, "ddd")
  LabelListeInfo.Text = Space(1) & Format(dateDatum, "dddd")
  it = DateDiff(Date, dateDatum, gb.day) 'as Integer
  If it < 0 Then 
    LabelListeDateDiff.Text = DateDiff(Date, dateDatum, gb.day) 
    LabelListeInfo.Foreground = Color.DarkBlue
    Text0BG.Background = &H678DB2&
  Else
    LabelListeDateDiff.Text = "+" & DateDiff(Date, dateDatum, gb.day)  
    LabelListeInfo.Foreground = Color.DarkGreen
    Text0BG.Background = &HCFFF9F&
  Endif 
  If String.InStr(LabelListeDateDiff.Text, "T") = 0 Then LabelListeDateDiff.Text = LabelListeDateDiff.Text & Space(1) & ("Tage") 'Days (Tage)
  LabelListeDateDiff.Foreground = LabelListeInfo.Foreground
  Text1BG.Background = Text0BG.Background
  SoSaButtons(F_iWochentag)
  ReadG()
  ArrowLines()
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSaGroupPanelRhythmus_Enter()
  
  If Last.Background <> F_iColorSelectGreen Then 
    Last.Background = F_iColorGreenAlpha150
    Last.Border = True 
  Else 
    Last.Border = True 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSaGroupPanelRhythmus_Leave()
  
  If Last.Background <> F_iColorSelectGreen Then 
    Last.Background = Color.Transparent
    Last.Border = False 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSaGroupPanelRhythmus_Click()
  
  'Wochentage
  'gb.Sunday Sunday 0 'as Integer
  'gb.Monday Monday 1
  'gb.Tuesday Tuesday 2
  'gb.Wednesday Wednesday 3
  'gb.Thursday Thursday 4
  'gb.Friday Friday 5
  'gb.Saturday Saturday 6
  
  F_iWochentag = CInteger(Str(Last.Tag))
  
  F_dateEingabeDatum = M01Functions.DateLastWeekDay(F_dateEingabeDatum, F_iWochentag)
  RefreshDate(F_dateEingabeDatum)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1AlsText() 
  
  Dim n, iLine As Integer
  Dim sKey, sLine, sExist, sText As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Text <> "" Then'keine leeren Zeilen
      sLine = ""
      sLine = sLine & ColumnView1[sKey][0] & hTab
      sLine = sLine & ColumnView1[sKey][1] & hTab
      sLine = sLine & ColumnView1[sKey][2] & hTab
      sLine = sLine & ColumnView1[sKey][3] & hTab
      sLine = sLine & ColumnView1[sKey][4] & hTab
      sLine = sLine & ColumnView1[sKey][5] & hReturn
      If String.InStr(gb.Tab & sExist & gb.Tab, gb.Tab & sLine & gb.Tab) > 0 Then ' doppelte Zeilen nicht übernehmen
        'Leerlauf
      Else
        sExist = sExist & gb.Tab & sLine & gb.Tab
        sText = sText & sLine
        n = n + 1
      Endif
    Endif
  Next
  ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  LabelRhythmusInfo.Text = Str(n) & Space(1) & Space(1) & ("Zeilen")
  TextAreaEdit1.SelectAll()
  TextAreaEdit1.Insert(sText) 'wie unter "Einfügen"
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveListG() 'anhängen
  
  Dim sText, sLine, sDirFile, sMessage As String
  Dim it, n, iLine As Integer
  Dim statInfoOld As Stat
  Dim statInfoNew As Stat
  Dim sKey As String
  Dim ssLines As New String[]
  Dim hTab, hReturn As String 
  
  If F_iSide <> 4 Then SideG(4)
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFile = FilePathForm() 'FMain.F_sPathTerminweckerActual_txt
  If Exist(sDirFile) = True Then statInfoOld = Stat(sDirFile) ' statInfoOld as Date
  TextBoxPath.Foreground = Color.Default
  IconError.Visible = False
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    'IF ColumnView1[sKey][5] <> "" THEN 'keine leeren Zeilen
    If ColumnView1[sKey].Text <> "" Then
      sLine = ""
      sLine = sLine & ColumnView1[sKey][0] & hTab
      sLine = sLine & ColumnView1[sKey][1] & hTab
      sLine = sLine & ColumnView1[sKey][2] & hTab
      sLine = sLine & ColumnView1[sKey][3] & hTab
      sLine = sLine & ColumnView1[sKey][4] & hTab
      sLine = sLine & ColumnView1[sKey][5] '& hReturn
      If ssLines.Find(sLine) = -1 Then ssLines.Add(sLine)' doppelte Zeilen nicht übernehmen
    Endif
  Next
  n = ssLines.Count
  sMessage = ""
  If ssLines.Count < 20 Then 
    sMessage &= ssLines.Join(hReturn)
  Else 
    For it = 0 To ssLines.Max
      If it < 10 Then 
        sMessage &= ssLines[it] & hReturn
      Else If it = 10 Then 
        sMessage &= "..." & hReturn
      Else If it > ssLines.Max - 10
        sMessage &= ssLines[it] & hReturn
      Endif 
    Next 
  Endif 
  ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  LabelRhythmusInfo.Text = Str(n) & Space(1) & ("Zeilen")
  
  If sMessage = "" Then 
    SideG(1) 'Rhythmus, Notizen
    sMessage = "<h4><font color=gray><b>" & LabelRhythmus.Text & "</b></font></h4>" ''□1□2□3□4□5□6□7□8□9□10
    sMessage &= "<h4><font color=blue><b>" & ("Leere Liste") & "</b></font></h4>" 'h=Head, Title 
    sMessage &= "<h3><font color=darkgreen><b>" & ("Rhythmus: Mindestens eine Woche aktivieren.") & "</b></font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Else
    sMessage &= "<h4><font color=darkgreen><b>" & Quote(sDirFile) & "</b></h4>" 
    sMessage &= "<h3><font color=darkgreen><b>" & ("+Hinzufügen in die Datei") & "</b></font></h3>"
    
    Select Case Message.Question(sMessage, "+" & ("Speichern"), ("Abbrechen"))
      Case 1
        ''...weiter
      Case 2
        Goto GoEnde
    End Select
    LabelMessage.Text = sDirFile
    LabelMessage.Tooltip = ("Kalender") & ": " & Space(1) & F_sOrdnerDateiHTML
    LabelMessage.Foreground = Color.Default
    ''+save (speichern, anhängen)
    sText = ssLines.Join(hReturn)
    If sText Then sDirFile = M01Functions.FileTextPlus(sDirFile, sText, False) ' TRUE=overwrite (überschreiben)
    If Exist(sDirFile) = True Then
      statInfoNew = Stat(sDirFile)
      If Not statInfoOld Then statInfoOld = statInfoNew
      If statInfoOld.LastModified = statInfoNew.LastModified Then ' wurde nicht verändert?
        LabelMessage.Foreground = Color.Red
      Else 'gespeichert
        ListChanged(False)
      Endif
      LabelMessage.Text = sDirFile 
      LabelMessage.Tooltip = sDirFile & Space(1) & Format(statInfoNew.LastModified, "ddd dd.mm.yyyy hh:nn") & Space(1) & File.FormatSize(Stat(sDirFile).Size, False) 'needs Component gb.util, False KB True KiB... 
      SideG(3)
    Else
      TextBoxPath.Foreground = Color.Red
      TextBoxPath.Text = sDirFile 
      TextBoxPath.Tooltip = ("Datei nicht gefunden") & "!"
      ListChanged(True)
    Endif 'Exist, statInfoNew
    TextBoxAdress.Text = F_sOrdnerDateiHTML
    TextBoxAdress.Foreground = LabelMessage.Foreground
    TextBoxAdress.Tooltip = LabelMessage.Tooltip
  Endif 'sText=""
  
GoEnde:
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung .Raise(), unterste Ebene .Lower()
  
End

Public Sub SliderList_Change()
  
  If F_bChangeON = True Then 
    F_dateEingabeDatum = DateAdd(Date(Year(Date), 1, 1), gb.day, SliderList.Value) 'as Date 1.Januar
    Text0Insert(Format(F_dateEingabeDatum, "yyyy-mm-dd"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SliderList_MouseUp()
  
  RefreshDate(F_dateEingabeDatum)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SliderPlusGroup_MouseUp()
  
  Dim iMouseLMR As Integer
  
  If Mouse.Left Then iMouseLMR = 0 'andere Art Mouse.Button
  If Mouse.Middle Then iMouseLMR = 1
  If Mouse.Right Then iMouseLMR = 2
  SliderPlusGroupG(Last.Tag, iMouseLMR) 'Mouse Integer 0=Left, 1=Middle, 2=Right
  
Catch 
  FMain.ErrorText
  
End

Public Sub SliderPlusGroup_Enter()
  
  Last.Background = F_iColorSelectGreen
  If Last.Tag = ButtonMinusWeek.Tag Or Last.Tag = ButtonPlusWeek.Tag Then SliderList.Background = F_iColorSelectGreen
  
Catch 
  FMain.ErrorText
  
End

Public Sub SliderPlusGroup_Leave()
  
  Last.Background = Color.Default
  SliderList.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub SliderPlusGroupG(Optional sUpDown As String = "up", Optional iMouseLMR As Integer = 0) ' 0=Left, 1=Middle, 2=Right
  
  Select Case String.LCase(sUpDown)
      
    Case "minusday", ButtonMinusDay.Tag
      If iMouseLMR = 0 Then SliderList.Value = SliderList.Value - 1 'minus 1 Tag
      
    Case "plusday", ButtonPlusDay.Tag
      If iMouseLMR = 0 Then SliderList.Value = SliderList.Value + 1 
      
    Case "minusweek", ButtonMinusWeek.Tag '1x Rhytmus
      If iMouseLMR = 0 Then  
        SliderList.Value = SliderList.Value - 7     'Kalender zählt 1 Woche rückwärts, nächster Wochentag - 7, z.B. Mi bis Mi.
      Else
        SliderList.Value = SliderList.Value - 1     'minus 1 Tag
      Endif
      
    Case "plusweek", ButtonPlusWeek.Tag
      If iMouseLMR = 0 Then 
        SliderList.Value = SliderList.Value + 7     'Kalender zählt 1 Woche vorwärts, nächster Wochentag + 7
      Else
        SliderList.Value = SliderList.Value + 1     'plus 1 Tag
      Endif
      
  End Select
  
  F_dateEingabeDatum = DateAdd(Date(Year(F_dateEingabeDatum), 1, 1), gb.day, SliderList.Value) 'as Date 1.Januar
  RefreshDate(F_dateEingabeDatum)
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckBoxNoticeToText() As String 
  
  Dim sText, sCheck, sOn, sOff As String
  
  sOn = "■" & Space(1)
  sOff = "□" & Space(1)
  If CheckBox1.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text1.Text & gb.NewLine
  If CheckBox2.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text2.Text & gb.NewLine
  If CheckBox3.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text3.Text & gb.NewLine  
  If CheckBox4.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text4.Text & gb.NewLine 
  If CheckBox5.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text5.Text & gb.NewLine
  If CheckBox6.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text6.Text & gb.NewLine
  If CheckBox7.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text7.Text & gb.NewLine
  If CheckBox8.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text8.Text & gb.NewLine
  If CheckBox9.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text9.Text & gb.NewLine
  If CheckBox10.Value = True Then sCheck = sOn Else sCheck = sOff
  sText &= sCheck & Text10.Text & gb.NewLine
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Checkgruppe_Click()
  
  ReadG()
  ListChanged(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckGroupReset()
  
  Dim iColor As Integer
  
  iColor = Color.Blue
  
  CheckBox1.Foreground = Color.Default
  CheckBox2.Foreground = Color.Default
  CheckBox3.Foreground = Color.Default
  CheckBox4.Foreground = Color.Default
  CheckBox5.Foreground = Color.Default
  CheckBox6.Foreground = Color.Default
  CheckBox7.Foreground = Color.Default
  CheckBox8.Foreground = Color.Default
  CheckBox9.Foreground = Color.Default
  CheckBox10.Foreground = Color.Default
  
  If CheckBox1.Value = True Then CheckBox1.Foreground = iColor
  If CheckBox2.Value = True Then CheckBox2.Foreground = iColor
  If CheckBox3.Value = True Then CheckBox3.Foreground = iColor
  If CheckBox4.Value = True Then CheckBox4.Foreground = iColor
  If CheckBox5.Value = True Then CheckBox5.Foreground = iColor
  If CheckBox6.Value = True Then CheckBox6.Foreground = iColor
  If CheckBox7.Value = True Then CheckBox7.Foreground = iColor
  If CheckBox8.Value = True Then CheckBox8.Foreground = iColor
  If CheckBox9.Value = True Then CheckBox9.Foreground = iColor
  If CheckBox10.Value = True Then CheckBox10.Foreground = iColor
  
  CheckBoxesInfo() 'as Integer, only read
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckBoxesInfo() As Integer
  
  Dim sText, sFill, sEmpty As String
  Dim it As Integer '=0
  
  sFill = "+"
  sEmpty = "-"
  it = it + 1 
  If CheckBox1.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it) 'sText = sText & ...
  it = it + 1
  If CheckBox2.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox3.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox4.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox5.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox6.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox7.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox8.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox9.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  it = it + 1
  If CheckBox10.Value = True Then sText &= sFill & Str(it) Else sText &= sEmpty & Str(it)
  
  it = Split(sText, sFill).Max
  LabelRhythmus0to10Text.Text = ("Rhythmus") & ": " & Str(it) & Space(1) & ("von 10 Wochen") 
  sText = Replace(sText, sFill, " ■")
  sText = Replace(sText, sEmpty, " □")
  LabelRhythmus.Text = sText '' Example: " ■1 □2 □3 □4 □5 □6 □7 □8 □9 □10"
  Return it 'Anzahl Aktivierungen Checked
  
Catch 
  FMain.ErrorsText
  
End

Public Sub SideGroup_Enter()
  
  Last.Border = True 
  If Last.Background = F_iColorSelectGreen Then     
    ''...
  Else 
    Last.Background = F_iColorGreenAlpha150
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideGroup_Leave()
  
  If Last.Background = F_iColorSelectGreen Then     
    ''...
  Else 
    Last.Background = Color.Default
    Last.Border = False 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideGroup_Click()
  
  SideG(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SideG(Optional iSeite As Integer = 1)
  
  If Exist(TextBoxPath.Text) = False Then TextBoxPath.Foreground = Color.Red Else TextBoxPath.Foreground = Color.Gray
  
  PanelDateChooser.Visible = False
  PanelRhythmus.Visible = False
  PanelListe.Visible = False
  PanelKalender.Visible = False
  PanelText.Visible = False
  PanelMerker.Visible = False
  ButtonMenu.Visible = False
  ListIsChanged.Visible = False
  ButtonRhythmus.Border = False 
  ButtonList.Border = False 
  ButtonCalendar.Border = False 
  ButtonText.Border = False 
  ButtonCut.Border = False 
  ButtonDemo.Border = False 
  ButtonRhythmus.Background = Color.Default 
  ButtonList.Background = Color.Default 
  ButtonCalendar.Background = Color.Default  
  ButtonText.Background = Color.Default  
  ButtonCut.Background = Color.Default  
  ButtonDemo.Background = Color.Default 
  
  F_iSide = iSeite 
  
  Select Case iSeite
    Case 0, 1 ''Notices
      PanelRhythmus.Visible = True
      PanelMerker.Visible = True
      ListIsChanged.Visible = True
      ButtonRhythmus.Border = True 
      ButtonRhythmus.Background = F_iColorSelectGreen 
      
    Case 2 ''List                   Termine
      PanelListe.Visible = True
      ButtonMenu.Visible = True
      ButtonList.Border = True  
      ButtonList.Background = F_iColorSelectGreen 
      ReadG()
      
    Case 3 ''Calendar-Year Test
      PanelKalender.Visible = True
      WebView1.Visible = True 
      If ColumnView1.Count = 0 Then ReadG()
      ColumnView1AlsText()
      CalendarTestRefresh()
      ButtonCalendar.Border = True  
      ButtonCalendar.Background = F_iColorSelectGreen 
      
    Case 32 ''Calendar-Year 
      PanelKalender.Visible = True
      WebView1.Visible = True 
      CalendarRefresh()
      ButtonCalendar.Border = True  
      ButtonCalendar.Background = F_iColorSelectGreen 
      
    Case 4 ''Text
      PanelText.Visible = True
      If ColumnView1.Count = 0 Then ReadG()
      ColumnView1AlsText()
      ButtonText.Border = True 
      ButtonText.Background = F_iColorSelectGreen 
      
    Case 5 ''Cut, leer, löschen, ausschneiden
      PanelRhythmus.Visible = True
      PanelMerker.Visible = True
      ListIsChanged.Visible = True
      WorkPlaceNew()
      ButtonRhythmus.Border = True 
      ButtonRhythmus.Background = F_iColorSelectGreen 
    
    Case 6 ''Demo
      PanelRhythmus.Visible = True
      PanelMerker.Visible = True
      ListIsChanged.Visible = True
      WorkPlaceDemo()
      ButtonRhythmus.Border = True 
      ButtonRhythmus.Background = F_iColorSelectGreen 
      
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
  Form12Timerplus.Mouse = Mouse.Default
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen2_Click()
  
  mnuFehlerMeldungen_Click
  
End

Public Sub MenuSystemInfo_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuSystemInfo2_Click()

  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub TextT5_MouseDown()
  
  SideG(1)
  
End

Public Sub ZeilenauswahlLoeschen()
  
  Dim it2, iLine, iCounter As Integer
  Dim sKey As String 
  
  For Each sKey In ColumnView1.Keys 'Zeilen
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Selected = True Then
      For it2 = 0 To 5 'ColumnView1.Columns.Count - 1   ' ab 5 Wiederherstellungzeile7
        ColumnView1[sKey][it2] = ""
      Next
      ColumnView1[sKey].Picture = mnuZeilenAuswahlEntfernen.Picture
      iCounter = iCounter + 1
    Endif
  Next
  LabelMessage.Text = iCounter & Space(1) & ("Zeilen entfernt")
  ColumnView1.Columns[5].Text = LabelMessage.Text
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZeilenauswahlKopieren()
  
  Dim it2, iLine, iCounter As Integer
  Dim sLine, sText, sKey As String
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  For Each sKey In ColumnView1.Keys 'Zeilen
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Selected = True Then
      sLine = ""
      For it2 = 0 To 5 'ColumnView1.Columns.Count - 1   ' ab 5 Wiederherstellungzeile7
        If it2 < 5 Then
          sLine = sLine & ColumnView1[sKey][it2] & hTab
        Else If it2 = 5 Then
          sLine = sLine & ColumnView1[sKey][it2] & hReturn
        Endif
      Next
      sText = sText & sLine
      iCounter = iCounter + 1
    Endif
  Next
  If iCounter > 0 Then
    Clipboard.Clear
    Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
    'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
  Endif
  LabelMessage.Text = Str(iCounter) & Space(1) & ("Zeilen kopiert")
  ColumnView1.Columns[5].Text = LabelMessage.Text
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_MouseUp() '_MouseDown nur Auswahl 1
  
  If Mouse.Left Then LabelMessage.Text = ("Auswahl") & ": " & Space(1) & Str(ColumnView1.Selection.Count) & "/" & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  If Mouse.Right Then Menu1.Popup ' erst in V3?
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_KeyPress()
  
  If Key.Code = Key.Delete Then ZeilenauswahlLoeschen()
  
End

Public Sub TextT0_MouseUp()
  
  If PanelDateChooser.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(1)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextT1_MouseUp()
  
  If PanelDateChooser.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextT0_KeyPress()
  
  If Key.Code = Key.Return Then
    F_dateEingabeDatum = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
    RefreshDate(F_dateEingabeDatum)
    Stop Event 'Vorgang abbrechen
  Else If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Or Key.Code = Key.BackSpace Or Key.Code = Key.Delete Then
    ' erlauben   Muster Eingabe Datum: "2020-04-15"
    If TextT0.Text Like "????-??-??" Then 
      F_dateEingabeDatum = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
      RefreshDate(F_dateEingabeDatum)
    Endif 
    TextT0Check()
  Else
    If F_bESCpressedON = False Then LabelMessage.Text = ("Tasten") & ": " & Space(1) & "0123456789-"
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextT1_KeyPress()
  
  If Key.Code = Key.Return Then
    TextT1Check()
    F_dateEingabeDatum = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
    RefreshDate(F_dateEingabeDatum)
    Stop Event 'Vorgang abbrechen
  Else If String.InStr("0123456789:", Key.Text) > 0 Or Key.Code = Key.BackSpace Or Key.Code = Key.Delete Then
    ' erlauben
    If TextT0.Text Like "????-??-??" Then 
      F_dateEingabeDatum = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
      RefreshDate(F_dateEingabeDatum)
    Endif 
    TextT0Check()
  Else
    If F_bESCpressedON = False Then LabelMessage.Text = ("Tasten") & ": " & Space(1) & "0123456789:"
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SelectHide0Date1Clock2Timer3(Optional iHide0_Date1_Clock2_Timer3_Clock4 As Integer = 0)
  
  Dim hDate As Date
  
  Select Case iHide0_Date1_Clock2_Timer3_Clock4
    Case 0 '' Close
      PanelDateChooser.Visible = False 
      ColumnView3.Visible = False
      
    Case 1 '' Date
      hDate = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
      
      DateChooser1.Value = hDate
      DateChooser1.Mode = DateChooser1.DateTime
      PanelDateChooser.Visible = True
      ColumnView3.Visible = False
      
    Case 2 '' Time
      hDate = M01Functions.DateCheckyyyymmddhhnn(TextT0.Text, TextT1.Text) 'as Date
      
      ClockTimeList0to24h(hDate)
      ColumnView3.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      DateChooser1.Value = hDate 
      DateChooser1.Mode = DateChooser1.DateTime
      PanelDateChooser.Visible = True 
      ColumnView3.Visible = True
      
    Case 3 ' Timer3 
      ''... siehe Form +Bearbeiten
      
    Case Else 'ohne
      PanelDateChooser.Visible = False 
      ColumnView3.Visible = False
      
  End Select
  
  ColumnView3.Raise() 'top
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h(Optional hDate As Date = Now)
  
  Dim it, it2, n, iSelect As Integer
  Dim sValue As String
  Dim sSelect As String
  
  sSelect = Format(hDate, "hh:nn")
  
  ColumnView3.Clear
  'ColumnView3.Header = 1 ' Sichtbar
  ColumnView3.Sorted = False ' nicht sortieren!
  'Spalten (Columns) erzeugen
  ColumnView3.Columns.Count = 1
  ColumnView3.Columns[0].Width = ColumnView3.Width
  
  For it = 0 To 23 'Stunden SS:
    For it2 = 0 To 59 'Minuten :MM
      sValue = Format(it, "00") & ":" & Format(it2, "00")
      n = ColumnView3.Count
      ColumnView3.Add(n, sValue)
      If it2 Mod 10 = 0 Then ''00:00, 00:15, 00:30, ...
        ColumnView3[n].Foreground = Color.Default 
      Else 
        ColumnView3[n].Foreground = Color.LightGray  
      Endif 
      If it2 Mod 30 = 0 Then ''00:00, 00:30, 01:00, ... 
        ColumnView3[n].Background = Color.LightGray 
      Endif 
      If ColumnView3[n].Text = sSelect Then
        ColumnView3[n].Selected = True
        iSelect = n
      Endif
    Next
  Next
  sValue = "00:00"
  n = n + 1
  ColumnView3.Add(n, sValue) '"00:00",..., "00:00" am Anfang und Ende
  ColumnView3[iSelect].EnsureVisible
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Data(dateValue As Date) ' dateValue frei gewählter Variablenname  gambas3
  
  If WeekDay(dateValue) = gb.Friday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Blue, 220) '&HC3DDFF
  Else If WeekDay(dateValue) = gb.Sunday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Yellow, 200)
  Endif 
  DateChooser1.Colors[Date] = F_iColorSelectGreen 'heute
  
  'Info:
  'DateChooser1.Mode = DateChooser1.DateOnly
  'DateChooser1.Colors.Clear()
  'DateChooser1.Data.Foreground = Color.Red
  'DateChooser1.Data.Font = Font["Italic"] 
  'DateChooser1.Colors["12/31/2000"] = F_iColorSelectGreen ' System, engl. 
  'DateChooser1.Mode = DateChooser1.DateTime 'Kalender- und Zeit-Tabelle, Heute + aktuelle Uhr
  
Catch 
  FMain.ErrorText
  
End ' DateChooser1_Data(dateValue As Date)

Public Sub DateChooser1_Click()
  
  Dim sDate, sTime As String
  Dim bChanged As Boolean
  
  sDate = Format(DateChooser1.Value, "yyyy-mm-dd")
  sTime = Format(DateChooser1.Value, "hh:nn")
  
  If TextT0.Text <> sDate Then 
    ' TextT0.Text = sDate
    Text0BG.Background = F_iColorSelected
    F_dateEingabeDatum = DateChooser1.Value ' as Date
    bChanged = True
  Endif  
  If String.Left(TextT1.Text, 4) <> String.Left(sTime, 4) Then '12:30 > 12:35 
    ' TextT1.Text = sTime
    Text1BG.Background = F_iColorSelected
    bChanged = True
  Endif 
  If bChanged = True Then RefreshDate(DateChooser1.Value) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_MouseUp()
  
  Dim dDate, dTime As Date 
  
  If ColumnView3.Current.Text Then 
    dDate = DateChooser1.Value 'as Date
    dTime = CDate(ColumnView3.Current.Text) '00:00 (*1)
    F_dateNow = Date(Year(dDate), Month(dDate), Day(dDate), Hour(dTime), Minute(dTime), Second(dTime)) 'as Date 
    DateChooser1.Value = F_dateNow
    Text1Insert(Format(F_dateNow, "hh:nn"))
  Endif 
  
  ''______________________________________________________________________________________________''
  '(*1) Gambas3: "CDate(): Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Hier nur bei hh:nn
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_MouseDown()
  
  ColumnView3.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0Insert(Optional sDatum As String = "yyyy-mm-dd")
  
  TextT0.SelectAll()
  TextT0.Insert(sDatum)
  If TextT0.Text Not Like "*????-??-??" Then TextT0Check()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1Insert(Optional sTime As String = "hh:nn")
  
  TextT1.SelectAll()
  TextT1.Insert(sTime)
  If TextT1.Text Not Like "*??:??" Then TextT1Check()
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextT0Check() 'yyyy-mm-dd
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  Dim sValue As String
  Dim Datensatz As Variant
  Dim hDate As Date
  Dim iDiff As Integer
  Dim Zeile As String
  
  If F_bChangeON = True Then 'FALSE: keine Reaktion auslösen, nur Eingabe
    If TextT0.Text Like "*????-??-??" Then 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD Datum
      sValue = Str(TextT0.Text)
      hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
      If Not hDate Then
        LabelMessage.Text = "?"
        LabelWT.Text = LabelMessage.Text 
        LabelListeDateDiff.Text = "+0?"
      Else
        LabelMessage.Text = Format(hDate, "dddd") 'Nur Vorgabe als as Date MM/DD/YYYY   oder Now
        LabelWT.Text = Format(hDate, "ddd")
        F_dateEingabeDatum = hDate
        LabelMessage.Foreground = Color.Default
        iDiff = DateDiff(Now, hDate, gb.Day) 'as Integer
        If iDiff < 0 Then LabelListeDateDiff.Text = Str(iDiff) Else LabelListeDateDiff.Text = "+" & Str(iDiff)
      Endif
      LabelListeDateDiff.Tooltip = ("Heute") & Space(1) & LabelListeDateDiff.Text & Space(3) & TextT0.Text
      ' LabelListeInfo.Text = LabelMessage.Text ''Example: "Sonntag" oder "?" oder ...
      If String.InStr(LabelListeDateDiff.Text, "T") = 0 Then LabelListeDateDiff.Text = LabelListeDateDiff.Text & Space(1) & ("Tage") 'Days (Tage)
    Else If String.InStr(sValue, "-") = 0 Then   'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Timer
      Datensatz = String.LCase(TextT0.Text)
      Zeile = M01Functions.CheckTimerTextWeekdays0to6(Datensatz)
      If Zeile <> "" Then 'Timer
        ' TextT0.Text = Zeile 'Wichtig: nicht in sich selbst 
        LabelMessage.Foreground = Color.Default
        LabelMessage.Text = ("Timer") & ": " & Zeile
      Else
        LabelMessage.Text = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
        LabelMessage.Foreground = Color.Red
      Endif
      LabelWT.Text = ("Ti") ' Timer
    Endif 'TTTT Timer
    
  Endif 'F_bChangeON
  
  LabelWT.Foreground = LabelMessage.Foreground
  
Catch 'Fehler abfangen, sonst Meldung und evtl. Stopp
  FMain.ErrorText
  'weiter ohne Fehlerreaktion
  LabelMessage.Text = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
  LabelMessage.Foreground = Color.Red
  LabelWT.Text = "?"
  LabelWT.Foreground = LabelMessage.Foreground
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
End

Public Sub TextT1Check() ' 00:00
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  Dim iHH, iNN As Integer
  Dim ssSpli As String[]
  
  If F_bChangeON = True Then 
    Text1BG.Background = Color.White
    If TextT1.Text Like "??:??" Then 'TTTTTTTTTTTTTTTTTTTTT
      LabelMessage.Text = LabelMessage.Tag
      ssSpli = Split(TextT1.Text & ":", ":")
      If ssSpli Then 
        Try iHH = CInteger(ssSpli[0])
        Try iNN = CInteger(ssSpli[1])
        If iHH < 0 Or iNN < 0 Or iHH > 23 Or iNN > 59 Then
          Text1BG.Background = Color.Red
          LabelMessage.Text = "Max. 23:59"
        Endif
      Endif 
    Else '--------------------------------------------------
      Text1BG.Background = Color.Red
      LabelMessage.Text = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
    Endif
    
    LabelWT.Text = "SS:MM"
  Endif 
  ' If PanelDateChooser.Visible = True Then DateChooser1.SetFocus()
  
Catch 
  FMain.ErrorText
  '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
End

Public Sub SoSaButtons(Optional iWTag As Integer = 4)
  
  Dim iColor As Integer
  
  iColor = Color.Transparent
  LabelW1.Background = iColor
  LabelW2.Background = iColor
  LabelW3.Background = iColor
  LabelW4.Background = iColor
  LabelW5.Background = iColor
  LabelW6.Background = iColor
  LabelW7.Background = iColor
  
  ButtonWeekDay0.Background = iColor
  ButtonWeekDay1.Background = iColor
  ButtonWeekDay2.Background = iColor
  ButtonWeekDay3.Background = iColor
  ButtonWeekDay4.Background = iColor
  ButtonWeekDay5.Background = iColor
  ButtonWeekDay6.Background = iColor
  
  ButtonWeekDay0.Border = False
  ButtonWeekDay1.Border = False
  ButtonWeekDay2.Border = False
  ButtonWeekDay3.Border = False
  ButtonWeekDay4.Border = False
  ButtonWeekDay5.Border = False
  ButtonWeekDay6.Border = False
  
  iColor = F_iColorSelectGreen
  Select Case iWTag
    Case gb.Sunday '0
      ButtonWeekDay0.Border = True
      ButtonWeekDay0.Background = iColor
      LabelW1.Background = iColor
    Case gb.Monday
      ButtonWeekDay1.Border = True
      ButtonWeekDay1.Background = iColor
      LabelW2.Background = iColor
    Case gb.Tuesday
      ButtonWeekDay2.Border = True
      ButtonWeekDay2.Background = iColor
      LabelW3.Background = iColor
    Case gb.Wednesday
      ButtonWeekDay3.Border = True
      ButtonWeekDay3.Background = iColor
      LabelW4.Background = iColor
    Case gb.Thursday
      ButtonWeekDay4.Border = True
      ButtonWeekDay4.Background = iColor
      LabelW5.Background = iColor
    Case gb.Friday
      ButtonWeekDay5.Border = True
      ButtonWeekDay5.Background = iColor
      LabelW6.Background = iColor
    Case gb.Saturday '6
      ButtonWeekDay6.Border = True
      ButtonWeekDay6.Background = iColor
      LabelW7.Background = iColor
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Menu1_Show()
  
  If PicArrowR.Background = F_iColorSelectGreen Then mnuZeilenPfeile.Checked = True Else mnuZeilenPfeile.Checked = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub ArrowLines()
  
  Dim n, iLine, iCol As Integer
  Dim sKey, sKeyArrowFirst As String 
  
  If PicArrowR.Background = F_iColorSelectGreen Then 'nur ▶Zeilen
    iCol = Color.Darker(Color.SelectedBackground)
    ColumnView1.Visible = False 
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1[sKey].Picture = PicArrowR.Picture Then
        '...▶Leerlauf
        n = n + 1
        ColumnView1[sKey].Foreground = iCol
        If Not sKeyArrowFirst Then sKeyArrowFirst = sKey
      Else 
        ColumnView1[sKey][0] = ""
        ColumnView1[sKey][1] = ""
        ColumnView1[sKey][2] = ""
        ColumnView1[sKey][3] = ""
        ColumnView1[sKey][4] = ""
        ColumnView1[sKey][5] = ""
      Endif
    Next
    sKey = sKeyArrowFirst
    If ColumnView1.Exist(sKey) = True Then 
      ColumnView1[sKey].Selected = True
      ColumnView1[sKey].EnsureVisible
    Endif 
  Else 
    iCol = Color.Default
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      n = n + 1
      ColumnView1[sKey].Foreground = iCol
      ColumnView1[sKey][0] = ColumnView1[sKey][6]
      ColumnView1[sKey][1] = ColumnView1[sKey][7]
      ColumnView1[sKey][2] = ColumnView1[sKey][8]
      ColumnView1[sKey][3] = ColumnView1[sKey][9]
      ColumnView1[sKey][4] = ColumnView1[sKey][10]
      ColumnView1[sKey][5] = ColumnView1[sKey][11]
    Next
  Endif 
  ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(n) & Space(1) & ("Zeilen")
  LabelRhythmusInfo.Text = Str("▶") & Str(n) & "/" & Str(ColumnView1.Count) & Space(1) & ("Zeilen")
  ColumnView1.Visible = True
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  ColumnView1.Visible = True
  
End

Public Sub WorkPlaceNew()
  
  Dim sMessage As String 
  
  If PanelRhythmus.Visible = False Then SideG(1)
  sMessage &= String.Left(CheckBoxNoticeToText(), 500)
  sMessage &= "<br><font color=red><b>" & ("Alle Notiz-Felder ausschneiden und neu anfangen?") & "</b></font>"
  Select Case Message.Question(sMessage, ("Neu anfangen"), ("Abbrechen"))
    Case 1
      CheckBox1.Foreground = Color.Default
      CheckBox2.Foreground = Color.Default
      CheckBox3.Foreground = Color.Default
      CheckBox4.Foreground = Color.Default
      CheckBox5.Foreground = Color.Default
      CheckBox6.Foreground = Color.Default
      CheckBox7.Foreground = Color.Default
      CheckBox8.Foreground = Color.Default
      CheckBox9.Foreground = Color.Default
      CheckBox10.Foreground = Color.Default
      
      CheckBox1.Value = False
      CheckBox2.Value = False
      CheckBox3.Value = False
      CheckBox4.Value = False
      CheckBox5.Value = False
      CheckBox6.Value = False
      CheckBox7.Value = False
      CheckBox8.Value = False
      CheckBox9.Value = False
      CheckBox10.Value = False
      
      Text1.Text = ("Notiz 1")
      Text2.Text = ("Notiz 2")
      Text3.Text = ("Notiz 3")
      Text4.Text = ("Notiz 4")
      Text5.Text = ("Notiz 5")
      Text6.Text = ("Notiz 6")
      Text7.Text = ("Notiz 7")
      Text8.Text = ("Notiz 8")
      Text9.Text = ("Notiz 9")
      Text10.Text = ("Notiz 10")
      ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(0) & Space(1) & ("Zeilen")
      LabelRhythmusInfo.Text = Str("▶") & Str(0) & "/" & Str(0) & Space(1) & ("Zeilen")
      CheckBoxesInfo()
      
      ListChanged(True)
      
    Case 2 'Cancel, Abbrechen 
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceDemo()
  
  Dim sMessage As String 
  
  If PanelRhythmus.Visible = False Then SideG(1)
  sMessage &= String.Left(CheckBoxNoticeToText(), 500)
  sMessage &= "<br><font color=red><b>" & ("Alle Notiz-Felder ausschneiden und neu anfangen?") & "</b></font>"
  sMessage &= "<h3><font color=blue><b>" & "● " & ("Demo mit Beispiel-Eingaben") & "</b></font></h3>"
  Select Case Message.Question(sMessage, "● " & ("Neu anfangen") & Space(1) & ("mit Demo"), ("Abbrechen"))
    Case 1
      CheckBox1.Foreground = Color.Default
      CheckBox2.Foreground = Color.Default
      CheckBox3.Foreground = Color.Default
      CheckBox4.Foreground = Color.Default
      CheckBox5.Foreground = Color.Default
      CheckBox6.Foreground = Color.Default
      CheckBox7.Foreground = Color.Default
      CheckBox8.Foreground = Color.Default
      CheckBox9.Foreground = Color.Default
      CheckBox10.Foreground = Color.Default
      
      CheckBox1.Value = False
      CheckBox2.Value = False
      CheckBox3.Value = False
      CheckBox4.Value = True
      CheckBox5.Value = False
      CheckBox6.Value = True
      CheckBox7.Value = False
      CheckBox8.Value = False
      CheckBox9.Value = False
      CheckBox10.Value = False
      
      Text1.Text = ("Notiz 1")
      Text2.Text = ("Notiz 2")
      Text3.Text = ("Notiz 3")
      Text4.Text = ("Notiz 4") & Space(1) & ("Abstand 4 Wochen")
      Text5.Text = ("Notiz 5")
      Text6.Text = ("Notiz 6") & Space(1) & ("Abstand 2 Wochen") & gb.NewLine & ("Zurück zum Anfang mit Abstand 4 Wochen")
      Text7.Text = ("Notiz 7")
      Text8.Text = ("Notiz 8")
      Text9.Text = ("Notiz 9")
      Text10.Text = ("Notiz 10")
      ColumnView1.Columns[5].Text = ("Notizen") & Space(1) & Str(0) & Space(1) & ("Zeilen")
      LabelRhythmusInfo.Text = Str("▶") & Str(0) & "/" & Str(0) & Space(1) & ("Zeilen")
      CheckBoxesInfo()
      
      ListChanged(True)
      ReadG()
    Case 2 'Cancel, Abbrechen 
      ''...
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceChange(Optional iWorkPlaceNew As Integer = 1) 'unused
  
  ''Old:
  WorkPlace(F_iWorkPlace0123, "save")
  
  ''New:
  F_iWorkPlace0123 = iWorkPlaceNew
  WorkPlace(F_iWorkPlace0123, "read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlace(Optional iWorkPlace0123 As Integer = 0, Optional sSaveRead As String = "read")
  
  Dim sWorkPlace0123, sText0, sText1 As String 
  
  sWorkPlace0123 = F_sForm &/ "WorkPlace" & Str(iWorkPlace0123) & "_"
  
  F_bChangeON = False 'siehe oben im Form-Kopf Deklarationen
  
  ''Save, speichern:
  If String.LCase(sSaveRead) = "save" Then ' merken, speichern
    
    Settings[sWorkPlace0123 & "Checkbox1"] = CheckBox1.Value
    Settings[sWorkPlace0123 & "Checkbox2"] = CheckBox2.Value
    Settings[sWorkPlace0123 & "Checkbox3"] = CheckBox3.Value
    Settings[sWorkPlace0123 & "Checkbox4"] = CheckBox4.Value
    Settings[sWorkPlace0123 & "Checkbox5"] = CheckBox5.Value
    Settings[sWorkPlace0123 & "Checkbox6"] = CheckBox6.Value
    Settings[sWorkPlace0123 & "Checkbox7"] = CheckBox7.Value
    Settings[sWorkPlace0123 & "Checkbox8"] = CheckBox8.Value
    Settings[sWorkPlace0123 & "Checkbox9"] = CheckBox9.Value
    Settings[sWorkPlace0123 & "Checkbox10"] = CheckBox10.Value
    Settings[sWorkPlace0123 & "Text1"] = Text1.Text
    Settings[sWorkPlace0123 & "Text2"] = Text2.Text
    Settings[sWorkPlace0123 & "Text3"] = Text3.Text
    Settings[sWorkPlace0123 & "Text4"] = Text4.Text
    Settings[sWorkPlace0123 & "Text5"] = Text5.Text
    Settings[sWorkPlace0123 & "Text6"] = Text6.Text
    Settings[sWorkPlace0123 & "Text7"] = Text7.Text
    Settings[sWorkPlace0123 & "Text8"] = Text8.Text
    Settings[sWorkPlace0123 & "Text9"] = Text9.Text
    Settings[sWorkPlace0123 & "Text10"] = Text10.Text
    Settings[sWorkPlace0123 & "TextT0"] = TextT0.Text 'Datum
    Settings[sWorkPlace0123 & "TextT1"] = TextT1.Text 'Uhr
    ' Settings[sWorkPlace0123 & "PicArrowR"] = PicArrowR.Background 
    
  Else If String.LCase(sSaveRead) = "read" Then  ''Read, lesen: 
    
    CheckBox1.Value = Settings[sWorkPlace0123 & "Checkbox1", False]
    CheckBox2.Value = Settings[sWorkPlace0123 & "Checkbox2", False] 
    CheckBox3.Value = Settings[sWorkPlace0123 & "Checkbox3", False] 
    CheckBox4.Value = Settings[sWorkPlace0123 & "Checkbox4", False] 
    CheckBox5.Value = Settings[sWorkPlace0123 & "Checkbox5", False] 
    CheckBox6.Value = Settings[sWorkPlace0123 & "Checkbox6", False] 
    CheckBox7.Value = Settings[sWorkPlace0123 & "Checkbox7", False]
    CheckBox8.Value = Settings[sWorkPlace0123 & "Checkbox8", False] 
    CheckBox9.Value = Settings[sWorkPlace0123 & "Checkbox9", False] 
    CheckBox10.Value = Settings[sWorkPlace0123 & "Checkbox10", False] 
    Text1.Text = Settings[sWorkPlace0123 & "Text1", ("Notiz 1")] 
    Text2.Text = Settings[sWorkPlace0123 & "Text2", ("Notiz 2")] 
    Text3.Text = Settings[sWorkPlace0123 & "Text3", ("Notiz 3")] 
    Text4.Text = Settings[sWorkPlace0123 & "Text4", ("Notiz 4")] 
    Text5.Text = Settings[sWorkPlace0123 & "Text5", ("Notiz 5")] 
    Text6.Text = Settings[sWorkPlace0123 & "Text6", ("Notiz 6")] 
    Text7.Text = Settings[sWorkPlace0123 & "Text7", ("Notiz 7")] 
    Text8.Text = Settings[sWorkPlace0123 & "Text8", ("Notiz 8")] 
    Text9.Text = Settings[sWorkPlace0123 & "Text9", ("Notiz 9")] 
    Text10.Text = Settings[sWorkPlace0123 & "Text10", ("Notiz 10")] 
    sText0 = Settings[sWorkPlace0123 & "TextT0", Format(Date, "yyyy-mm-dd")]
    sText1 = Settings[sWorkPlace0123 & "TextT1", Format(Time, "hh:nn")]
    Text0Insert(sText0) '"0000-00-00" Date (Datum) 
    Text1Insert(sText1) '"00:00" Time (Uhrzeit) 
    F_dateEingabeDatum = M01Functions.DateCheckyyyymmddhhnn(sText0, sText1)
    ' PicArrowR.Background = Settings[sWorkPlace0123 & "PicArrowR", Color.Default] 
    WorkPlaceRefresh()
  Endif
  
  ''Apply, anwenden:
  RaiseOrder()
  CheckGroupReset() '—▶CheckBoxesInfo() 'nur lesen. Rhythmus: 0 von 10 Wochen 
  SideG(1) '1=Rhythmus, Notizen
  RefreshDate(F_dateEingabeDatum)
  ListChanged(False)
  F_bChangeON = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ListChanged(Optional bTrueFalse As Boolean = False)
  
  Select Case bTrueFalse
    Case True 'Ja
      F_bListeveraendert = True
      ListIsChanged.Picture = PicTemplateLEDred.Picture 'verändert, changed
    Case False 'Nein
      F_bListeveraendert = False
      ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelRhythmus0to10Text_MouseDown()
  
  CheckGroupReset() 'nur lesen: □ 1 Woche □ 2 Woche .... □ 10 Woche 
  
End

Public Sub WindowStretch_DblClick()
  
  Form12Timerplus.Window.Maximized = Not Form12Timerplus.Window.Maximized 
  If Form12Timerplus.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form12Timerplus.Window.FullScreen = True Or Form12Timerplus.Window.Maximized = True Then 
      F_bMovingON = False
      Form12Timerplus.Window.FullScreen = False
      Form12Timerplus.Window.Maximized = False
      If Form12Timerplus.Left + Form12Timerplus.W > Screen.AvailableWidth Then Form12Timerplus.Move(Form12Timerplus.Left, Form12Timerplus.Top, Screen.AvailableWidth - Form12Timerplus.Left, Screen.AvailableHeight - Form12Timerplus.Top)
    Else
      F_bMovingON = True
      Form12Timerplus.Window.FullScreen = False
      Form12Timerplus.Window.Maximized = False
      WindowStretch.Background = F_iColorSelectGreen
      F_iX1 = Form12Timerplus.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form12Timerplus.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form12Timerplus.ClientW - WindowStretch.W, Form12Timerplus.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form12Timerplus.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form12Timerplus.W = Mouse.ScreenX - F_iX1
    Form12Timerplus.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form12Timerplus.ClientW - WindowStretch.W, Form12Timerplus.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form12Timerplus.ClientW - WindowStretch.W, Form12Timerplus.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form12Timerplus.Window.Maximized = Not Form12Timerplus.Window.Maximized 
    If Form12Timerplus.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = F_iColorSelectGreen
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form12Timerplus.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()

  If Mouse.Right Then Menu1.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonEditG()
  
  Form2Bearb.Window.Show
  ' Form2Bearb.Window.Visible = True 'Wayland error?
  
Catch
  FMain.ErrorText
  
End

Public Sub FileHTMLinfoG()
  
  Form19FileInfo.Tag = AdressFileTxt() '*.html
  Form19FileInfo.Window.Show
  Form19FileInfo.Visible = True  
  
Catch 
  FMain.ErrorText
  
End  

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = FilePathForm() '*.txt
  
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True   'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoAdressG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = AdressFileTxt() 
  If Exist(sDirFile) = True Then
    LabelInfoAdress.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>"
    LabelInfoAdress.Visible = True 
    LabelInfoAdress.Background = Color.LightBackground
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = TextBoxPath.Text ' AdressFileTxt() 
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function AdressFileTxt() As String 
  
  Dim sPath As String 
  
  sPath = TextBoxAdress.Text 
  sPath = Replace(sPath, "file:", "")
  sPath = Replace(sPath, "///", "")
  sPath = Replace(sPath, "//", "")
  sPath = Replace(sPath, "/:", "")
  sPath = Replace(sPath, "#heute", "")
  sPath = Replace(sPath, gb.NewLine, "")
  If Exist(sPath) = False Then sPath = FilePathForm()  'Standard
  
  Return sPath
  
Catch 
  FMain.ErrorText
  
End

Public Sub BrowserG()
  
  Dim sPath As String
  
  If Exist(F_sNewOrdnerDateiHTML) = True Then sPath = F_sNewOrdnerDateiHTML Else sPath = FilePathForm() & ".html"
  If Exist(sPath) = True Then
    ButtonBrowser.Background = F_iColorGreenAlpha150
    sPath = "file://" & Quote(sPath) & "#heute"
    If System.Exist("firefox") = True Then ButtonBrowser.Text = ">Browser"
    M01Functions.ExternStart("firefox", sPath)
    TextBoxAdress.Foreground = Color.Default
  Else
    TextBoxAdress.Foreground = Color.Red
  Endif
  If M01Functions.CheckQT4QT5() = True Then 'gb.qt5.webkit = gb.qt4.webkit
    LabelMessage.Text = WebView1.Status 'as String 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconPathOpenG()
  
  Dim sPath As String 
  
  sPath = FilePathForm() 
  sPath = File.Dir(sPath) &/ Application.Name & "_" & "favicon.png"
  sPath = M01Functions.FileManagerOpen(sPath) 'Path or "" Null
  If Exist(sPath) = False Then LabelMessage.Text = (("Fehlt") & ": " & ButtonIcon.Tooltip)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSaPanelListeGroup_MouseDown()
  
  F_iWochentag = CInteger(Str(Last.Tag))
  
  F_dateEingabeDatum = M01Functions.DateLastWeekDay(F_dateEingabeDatum, F_iWochentag)
  RefreshDate(F_dateEingabeDatum)
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub WorkPlaceRefresh()
  
  If F_iWorkPlace0123 = ButtonWorkPlace1.Tag Then ButtonWorkPlace1.Border = True Else ButtonWorkPlace1.Border = False
  If F_iWorkPlace0123 = ButtonWorkPlace2.Tag Then ButtonWorkPlace2.Border = True Else ButtonWorkPlace2.Border = False
  If F_iWorkPlace0123 = ButtonWorkPlace3.Tag Then ButtonWorkPlace3.Border = True Else ButtonWorkPlace3.Border = False
  If F_iWorkPlace0123 = ButtonWorkPlace1.Tag Then ButtonWorkPlace1.Background = F_iColorSelectGreen Else ButtonWorkPlace1.Background = Color.Default
  If F_iWorkPlace0123 = ButtonWorkPlace2.Tag Then ButtonWorkPlace2.Background = F_iColorSelectGreen Else ButtonWorkPlace2.Background = Color.Default
  If F_iWorkPlace0123 = ButtonWorkPlace3.Tag Then ButtonWorkPlace3.Background = F_iColorSelectGreen Else ButtonWorkPlace3.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceMGroup_Enter()
  
  If Object.Type(Last) = "Button" And Last.Background <> F_iColorSelectGreen Then 
    Last.Border = True
    Last.Background = F_iColorGreenAlpha150
  Endif 
  If Object.Type(Last) = "TextBox" Then Last.Border = True
  If Last.Tag = 1 Then PanelMerkerBG1.Background = Color.White
  If Last.Tag = 2 Then PanelMerkerBG2.Background = Color.White
  If Last.Tag = 3 Then PanelMerkerBG3.Background = Color.White
    
  Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceMGroup_Leave()
  
  If Object.Type(Last) = "Button" And Last.Background <> F_iColorSelectGreen Then 
    Last.Border = False
    Last.Background = Color.Default
  Endif 
  If Object.Type(Last) = "TextBox" Then Last.Border = False
  If Last.Tag = 1 Then PanelMerkerBG1.Background = Color.Default
  If Last.Tag = 2 Then PanelMerkerBG2.Background = Color.Default
  If Last.Tag = 3 Then PanelMerkerBG3.Background = Color.Default
  
  Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceMGroup_MouseUp()
  Dim sMessage As String 
  
  ' If Mouse.Left And Object.Type(Last) = "Button" Then WorkPlaceChange(Last.Tag)
  
  If Mouse.Left Then 
    F_iWorkPlace0123 = Last.Tag '1, 2, 3
    If Object.Type(Last) = "Button" Then 
      If String.InStr(String.LCase(Last.Name), "plus") > 0 Then  'ButtonPlus1, ButtonWorkPlace1
        sMessage = "<h3><font color=darkgreen>" & F_iWorkPlace0123 & Space(1) & ("Arbeitsplatz") & "</font></h3>"
        sMessage &= "<h4><font color=blue>" & "● " & ("Merken (Einstellungen, Settings)") & "</font></h4>"
        sMessage &= String.Left(CheckBoxNoticeToText(), 500)
        
        Select Case Message.Question(sMessage, "● " & ("Merken"), ("Abbrechen"))
          Case 1
            WorkPlace(F_iWorkPlace0123, "save")
          Case 2
            '... Cancel
        End Select
        
      Else 
        WorkPlace(F_iWorkPlace0123, "read")  
        sMessage = "<h3><font color=darkgreen>" & F_iWorkPlace0123 & Space(1) & ("Arbeitsplatz") & "</font></h3>"
        sMessage &= "<h4><font color=gray>" & ("Geöffnet (Einstellungen, Settings)") & "</font></h4>"
        sMessage &= String.Left(CheckBoxNoticeToText(), 500)
        
        Message.Info(sMessage, ("Abbrechen"))
        
      Endif 
    Else If Object.Type(Last) = "TextBox" Then 
      LabelMessage.Text = ("Eingabe") & ": " & Space(1) & Last.Text 
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WorkPlaceMGroup_KeyPress()
  Dim sLastCharacter As String
  
  If Object.Type(Last) = "TextBox" And String.InStr("0,1,2,3", Last.Tag) > 0 Then 
    If Key.Text Then sLastCharacter = Key.Text
    If Last.Font.TextWidth(Last.Text) > Last.W - 4 Then 
      Last.Foreground = Color.Red 
      LabelMessage.Text = ("Eingabe war zu lang") & ": " & Space(1) & Last.Text & sLastCharacter 'UTF-8 with ö
    Else 
      Last.Foreground = Color.Default 
      LabelMessage.Text = ("Eingabe") & ": " & Space(1) & Last.Text & sLastCharacter
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Notizgruppe_KeyPress()
  
  If Object.Type(Last) = "TextArea" Then 
    If String.Len(Last.Text) > 200 Then 
      Last.Foreground = Color.Red 
      LabelMessage.Text = ("Eingabe war zu lang") & ": " & ">200" & Space(1) & Last.Text
    Else 
      Last.Foreground = Color.Default 
      LabelMessage.Text = ("Eingabe") & ": " & Space(1) & Last.Text
    Endif 
    ListChanged(True)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Notizgruppe_Change()
  
  If F_bChangeON = True Then 'FALSE: keine Reaktion auslösen, nur Eingabe
    If Object.Type(Last) = "TextArea" Then 
      ListChanged(True)
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form12Timerplus.Left]
      iY = Settings[F_sForm &/ "Top", Form12Timerplus.Top]
      iW = Settings[F_sForm &/ "Width", Form12Timerplus.W]
      iH = Settings[F_sForm &/ "Height", Form12Timerplus.H]
      Form12Timerplus.Move(iX, iY, iW, iH)
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form12Timerplus.Left
      Settings[F_sForm &/ "Top"] = Form12Timerplus.Top
      Settings[F_sForm &/ "Width"] = Form12Timerplus.Width
      Settings[F_sForm &/ "Height"] = Form12Timerplus.Height
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RhythmusTextOpenSave(Optional sOpenSave As String = "open")
  Dim it, iNumber, iCheck As Integer
  Dim sDir, sDirFile, sText, sLine, sMessage As String 
  Dim ssSpli As String[]
  Dim bCheckON As Boolean
  
  Select Case sOpenSave
    Case "open"
      sDirFile = Settings[FMain.Name &/ "F_sPathTimerPlus_txt", FMain.F_sPathTimerPlus_txt]
      ' If FMain.F_sPathTimerPlus_txt Then sFile = File.Name(FMain.F_sPathTimerPlus_txt) Else sFile = Application.Name & "_timer_plus.txt"
      ' If IsDir(File.Dir(sDirFile)) = True Then sDir = File.Dir(sDirFile) Else sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      ' sDirFile = sDir &/ sFile
      
      ''Dialog:
      sDirFile = FileDialogPathReturn(sDirFile, "open", sDirFile) 'Last-Path, open/save, Standard-Path
      
      ''load:
      If Exist(sDirFile) = True Then sText = File.Load(sDirFile) Else Goto JumbEnd
      
      F_bbCheckBoxesMerker = New Boolean[11] 
      F_ssNotizMerker = New String[11]
      
      For Each sLine In Split(sText & gb.NewLine, gb.NewLine) ' gb.NewLine = "\n"
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        If String.InStr(sLine, "CheckBox=") > 0 Then 
          ssSpli = Split(sLine & "=", "=")
          If ssSpli Then 
            If IsInteger(ssSpli[1]) = True Then iNumber = CInteger(ssSpli[1]) Else iNumber = 0 'False=0
            If IsInteger(ssSpli[2]) = True Then iCheck = CInteger(ssSpli[2]) Else iCheck = 0 'False=0
            If iCheck = 0 Then bCheckON = False Else bCheckON = True
            If iNumber < F_bbCheckBoxesMerker.Count Then F_bbCheckBoxesMerker.Add(bCheckON, iNumber)
            ' Print iNumber, bCheckON
          Endif 
        Endif
        If String.InStr(sLine, "TextArea=") > 0 Then 
          ssSpli = Split(sLine & "=", "=")
          If ssSpli Then 
            If IsInteger(ssSpli[1]) = True Then iNumber = CInteger(ssSpli[1]) Else iNumber = 0 'False=0
            If iNumber < F_ssNotizMerker.Count Then F_ssNotizMerker.Add(UnQuote(ssSpli[2]), iNumber)
            ' Print iNumber, ssSpli[2]
          Endif 
        Endif
      Next
      If F_bESCpressedON = False Then
        CheckBox1.Value = F_bbCheckBoxesMerker[1]
        CheckBox2.Value = F_bbCheckBoxesMerker[2]
        CheckBox3.Value = F_bbCheckBoxesMerker[3]
        CheckBox4.Value = F_bbCheckBoxesMerker[4]
        CheckBox5.Value = F_bbCheckBoxesMerker[5]
        CheckBox6.Value = F_bbCheckBoxesMerker[6]
        CheckBox7.Value = F_bbCheckBoxesMerker[7]
        CheckBox8.Value = F_bbCheckBoxesMerker[8]
        CheckBox9.Value = F_bbCheckBoxesMerker[9]
        CheckBox10.Value = F_bbCheckBoxesMerker[10]
        
        Text1.SelectAll()
        Text2.SelectAll()
        Text3.SelectAll()
        Text4.SelectAll()
        Text5.SelectAll()
        Text6.SelectAll()
        Text7.SelectAll()
        Text8.SelectAll()
        Text9.SelectAll()
        Text10.SelectAll()
        
        Text1.Insert(F_ssNotizMerker[1])
        Text2.Insert(F_ssNotizMerker[2])
        Text3.Insert(F_ssNotizMerker[3])
        Text4.Insert(F_ssNotizMerker[4])
        Text5.Insert(F_ssNotizMerker[5])
        Text6.Insert(F_ssNotizMerker[6])
        Text7.Insert(F_ssNotizMerker[7])
        Text8.Insert(F_ssNotizMerker[8])
        Text9.Insert(F_ssNotizMerker[9])
        Text10.Insert(F_ssNotizMerker[10])
        
        ''Check:
        If sText Then 
          sMessage = "<h4>" & sDirFile & "</h4>" 
          sMessage &= "<h3><font color=darkgreen>" & ("Geöffnet") & "</font></h3>" 
          sMessage &= "<h4>" & "<font color=blue>" & ("Tipp: Merken in Arbeitsplatz 1, 2 oder 3") & "</font>" & "</h4>"
          sMessage &= String.Left(CheckBoxNoticeToText(), 500)
          Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
            Case 1
              M01Functions.FileManagerOpen(sDirFile)
            Case 2 
              ''...
          End Select 
        Endif 
        ListChanged(True)
      Endif 

      
    Case "save"
      F_bbCheckBoxesMerker = New Boolean[] 
      
      F_bbCheckBoxesMerker.Add(Null)
      F_bbCheckBoxesMerker.Add(CheckBox1.Value)
      F_bbCheckBoxesMerker.Add(CheckBox2.Value)
      F_bbCheckBoxesMerker.Add(CheckBox3.Value)
      F_bbCheckBoxesMerker.Add(CheckBox4.Value)
      F_bbCheckBoxesMerker.Add(CheckBox5.Value)
      F_bbCheckBoxesMerker.Add(CheckBox6.Value)
      F_bbCheckBoxesMerker.Add(CheckBox7.Value)
      F_bbCheckBoxesMerker.Add(CheckBox8.Value)
      F_bbCheckBoxesMerker.Add(CheckBox9.Value)
      F_bbCheckBoxesMerker.Add(CheckBox10.Value)

      F_ssNotizMerker = New String[] 
      
      F_ssNotizMerker.Add(Null)
      F_ssNotizMerker.Add(Text1.Text)
      F_ssNotizMerker.Add(Text2.Text)
      F_ssNotizMerker.Add(Text3.Text)
      F_ssNotizMerker.Add(Text4.Text)
      F_ssNotizMerker.Add(Text5.Text)
      F_ssNotizMerker.Add(Text6.Text)
      F_ssNotizMerker.Add(Text7.Text) 
      F_ssNotizMerker.Add(Text8.Text) 
      F_ssNotizMerker.Add(Text9.Text)
      F_ssNotizMerker.Add(Text10.Text)
      
      sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & LabelTimerplusA.Text & gb.NewLine
      For it = 1 To F_bbCheckBoxesMerker.Max '1-10
        sText &= "CheckBox=" & it & "=" & CInteger(F_bbCheckBoxesMerker[it]) & gb.NewLine
      Next
      For it = 1 To F_ssNotizMerker.Max
        sText &= "TextArea=" & it & "=" & Quote(F_ssNotizMerker[it]) & gb.NewLine
      Next
      
      sDirFile = Settings[FMain.Name &/ "F_sPathTimerPlus_txt", FMain.F_sPathTimerPlus_txt]
      ' If FMain.F_sPathTimerPlus_txt Then sFile = File.Name(FMain.F_sPathTimerPlus_txt) Else sFile = Application.Name & "_timer_plus.txt"
      ' If IsDir(File.Dir(sDirFile)) = True Then sDir = File.Dir(sDirFile) Else sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      ' sDirFile = sDir &/ sFile
      
      ' Dialog.Filter = ["*.txt", ("Nur-Text"), "*" & sFile, LabelTimerplusA.Text]'and autom. All Files *.* -1
      ' Dialog.Path = sDirFile
      ' Dialog.AutoExt = True ''needs component: gb.form.dialog
      ' Dialog.Title = Application.Name & " - " & ("Datei speichern...")
      ' If Dialog.SaveFile() = True Then Return                            ''-1=TRUE=Cancel  file is not saved
      
      ''save:
      ' sDirFile = Dialog.Path
      sDirFile = FileDialogPathReturn(sDirFile, "save", sDirFile) 'Last-Path, open/save, Standard-Path
      If Not sDirFile Then Return  
    
      sDir = File.Dir(sDirFile)
      If sText And IsDir(sDir) = True Then 
        If M01Functions.AccessDirFileReadWrite(sDir, 1) = True Then 
          sDirFile = M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
          ''Check:
          If Exist(sDirFile) = True Then 
            sMessage = "<h4>" & sDirFile & "</h4>"
            sMessage &= "<font color=gray>" & Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup] &/ "..." & "</font>" 
            sMessage &= "<h3><font color=darkgreen>" & ("Gespeichert") & "</font></h3>" 
            sMessage &= "<h4>" & "<font color=blue>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>" & "</h4>"
            sMessage &= String.Left(CheckBoxNoticeToText(), 500)
            
            Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
              Case 1
                M01Functions.FileManagerOpen(sDirFile)
              Case 2 
                ''...
            End Select 
            ListChanged(False)
          Endif 
        Endif
      Endif 
      
  End Select
  
  JumbEnd:
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
 
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = True 
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150 
  Endif  
  
  Select Case String.LCase(Last.Tag)
      
    Case "labelrhythmus"
      LabelRhythmusInfo.Background = Color.Transparent
      LabelRhythmus.Background = Color.Transparent
      LabelRhythmus0to10Text.Background = Color.Transparent
      
    Case PicArrowR.Tag, "arrowlines"
      Last.Border = True
      
    Case KalFileInfo.Tag, "filehtmlinfo"
      LabelInfoAdress.Visible = True 
      LabelInfoAdressG(TextBoxAdress.Text)
      
    Case ButtonSave.Tag, "save"
      PanelText.Background = F_iColorSelectGreen
      
    Case ButtonFileInfo.Tag, "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
      ButtonFileInfo.Background = F_iColorSelectGreen
          
    Case LabelInfo.Tag, "info" 
      Last.Visible = True  
      
    Case "pathbg", "panelpath" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = Color.LightBackground
      TextBoxPath.Foreground = Color.Default
      
    Case "canceldate"
      Last.Border = True
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()

  If Object.Type(Last) = "Button" Then
    Last.Border = False 
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Else If Object.Type(Last) = "TextBox" Then
    If Last.Background <> Color.Green Then Last.Background = Color.Transparent
  Endif  
  
  PanelMerker.Background = Color.Default
  PanelText.Background = Color.Default
  
  Select Case String.LCase(Last.Tag)
      
    Case "labelrhythmus"
      LabelRhythmusInfo.Background = Color.Transparent
      LabelRhythmus.Background = Color.Transparent
      LabelRhythmus0to10Text.Background = Color.Transparent
      
    Case PicArrowR.Tag, "arrowlines"
      Last.Border = True
      
    Case KalFileInfo.Tag, "filehtmlinfo"
      LabelInfoAdress.Visible = False 
      
    Case ButtonSave.Tag, "save"
      PanelText.Background = Color.Default
      
    Case ButtonFileInfo.Tag, "fileinfo"
      LabelInfo.Visible = False 
      ButtonFileInfo.Background = Color.Default
    
    Case LabelInfo.Tag, "info" 
      Last.Visible = False 
      
    Case "pathbg", "panelpath" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Transparent
    
    Case "canceldate"
      Last.Border = True
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()

  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown()
  
  ButtonGroupSelect(Last.Tag)
 
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String)
  
  F_bESCpressedON = False
  sLastTag = String.LCase(sLastTag)
  
  Select Case sLastTag
    Case "workplacenew"
      SideG(5)
    Case "rhythmustextopen"
      RhythmusTextOpenSave("open")
    Case "rhythmustextsave"
      RhythmusTextOpenSave("save")
    Case "menu"
      Menu1.Popup
    Case "save"
      SaveListG() 'Append (Termine anhängen)
    Case "new"
      SideG(5) 'Cut
    Case "edit"
      ButtonEditG()
    Case "arrowlines" '▶
      If PicArrowR.Background = F_iColorSelectGreen Then PicArrowR.Background = Color.Default Else PicArrowR.Background = F_iColorSelectGreen
      ArrowLines()
    Case "canceldate"
      SelectHide0Date1Clock2Timer3(0)
    Case "filehtmlinfo"
      FileHTMLinfoG()
    Case "fileinfo"
      FileInfoG()  
    Case "browser"
      BrowserG()
    Case "icon"
      IconPathOpenG() 
      ' Case "labelrhythmus"
      '   SideG(1)
    Case "adress", TextBoxAdress.Tag
      Last.Background = Color.White
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "copy"
      ZeilenauswahlKopieren()
    Case "cut"
      ZeilenauswahlLoeschen()
    Case "arrows"
      If PicArrowR.Background = F_iColorSelectGreen Then PicArrowR.Background = Color.Default Else PicArrowR.Background = F_iColorSelectGreen
      ArrowLines()
    Case "reload"
      ReadG()
    Case "calendar"
      SideG(32)''Calendar-Year 
      CalendarRefresh()
    Case "minusday", ButtonMinusDay.Tag
      SliderPlusGroupG(sLastTag)
    Case "plusday", ButtonPlusDay.Tag
      SliderPlusGroupG(sLastTag)
    Case "minusweek", ButtonMinusWeek.Tag '1x Rhytmus
      SliderPlusGroupG(sLastTag)
    Case "plusweek", ButtonPlusWeek.Tag
      SliderPlusGroupG(sLastTag)
    Case "resetslider"
      F_dateEingabeDatum = Date(Year(Date), Month(Date), Day(Date))
      Text0Insert(Format(F_dateEingabeDatum, "yyyy-mm-dd"))
      ReadG()
    Case "cancelform"
      Form12Timerplus.Window.Close()
  End Select
  
Catch 
  FMain.ErrorText
  
End '..................................





Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form2Bearb.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form2Bearb.class
246 KB
' Gambas class file

'F_ = Form level
Public F_bChangeON As Boolean
Public F_bCheckBoxAbc As Boolean
Public F_bESCpressedON As Boolean
Public F_bKeyboardInput As Boolean
Public F_bListChanged As Boolean
Public F_bMakeBackup As Boolean
Public F_bMoreButtons As Boolean
Public F_bMovingON As Boolean
Public F_bSaved As Boolean
Public F_dateNow As Date 
Public F_i22 As Integer = 22 'Example: 22 'Pixel Icon WxH —▶ColumnView
Public F_iColorBlue As Integer
Public F_iColorForegroundBlue As Integer = Color.DarkBlue
Public F_iColorGreen As Integer
Public F_iColorGreenAlpha150 As Integer = Color.SetAlpha(Color.Green, 150) ' (Color,  Alpha-Transparent)
Public F_iColorGreenAlpha220 As Integer = Color.SetAlpha(Color.Green, 220) 
Public F_iColorRed As Integer
Public F_iColorRedAlpha150 As Integer = Color.SetAlpha(Color.Red, 150) 
Public F_iColorYellow As Integer
Public F_iColumnNr As Integer 
Public F_iColumnsCount As Integer     'Termine 10, Projects 14. Example: Columns:|0|1|2|3|4|5|6|7|8|9|n-1 (10-1)
Public F_iColumnSelect As Integer  
Public F_iColumnSort As Integer 
Public F_iColumnsReadMax As Integer 
Public F_iColumnUndo As Integer 
Public F_iCVUndoRedoPointer As Integer
Public F_iCVUndoRedoPointerSave As Integer
Public F_iDateTimeNoticeBackupPointer As Integer
Public F_iListChangedCounter As Integer
Public F_iMoveLineMaxH As Integer
Public F_iMoveLineMinH As Integer
Public F_iMoveLineTop As Integer
Public F_iMusterTermine1Names2Projects3 As Integer = 1 '!!! ******************************************
Public F_iOldLines As Integer
Public F_iOnly1x As Integer
Public F_iSearchPosition As Integer
Public F_iSecondsFileRead As Integer
Public F_iText5SearchPosition As Integer
Public F_iText5Seconds As Integer
Public F_iUndoRedoText5Pointer As Integer
Public F_iUnknownCounter As Integer
Public F_iX1 As Integer
Public F_iX2 As Integer
Public F_iY1 As Integer
Public F_iY2 As Integer
Public F_longFilesRead As Long '>Files
Public F_ooColumnViewImages As Object[]
Public F_ooCVBackups As Object[]                                                   'ColumnView1 ->Backups
Public F_ooDateTimeNoticeBackup As Object[]
Public F_sCVinfoSelectLineFirst As String = ("Vorher eine Zeile markieren oder erstellen")
Public F_sDirDefault As String = Desktop.GetDirectory("PICTURES") &/ Application.Name
Public F_sForm As String = Me.Name 
Public F_sLinesCopy As String 
Public F_sPathText5Temp_txt As String 
Public F_sProjectOnlyName As String
Public F_ssCVImgNames As String[]
Public F_ssKeysCopy As String[]          'ColumnView1.Selection.Max > -1  'internally, instead of Clipboard.Copy()
Public F_ssUndoRedoText5 As String[]
Public F_statFilePathForm As Stat
Public F_sText5StartExampleName As String
Public F_sTitleBasicText As String
Public F_sUnknownLinesText As String

Public Struct F_multiColumnViewValues 'Example in Sub: Dim hColumnView as New F_multiColumnViewValues
  bSortAscending As Integer
  bSorted As Integer
  iMode As Integer
  iScrollY As Integer
  iSortColumn As Integer
  ssKeys As String[] 
  ssLines As String[]
End Struct 

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]  '... "terminwecker.txt"
    Case 2
      sPath = Settings[FMain.Name &/ "F_sPathProjectsNames_txt", FMain.F_sPathProjectsNames_txt] '..."projects_names.txt"
    Case 3
      sPath = Settings[FMain.Name &/ "F_sPathProjectsAllTimes_txt", FMain.F_sPathProjectsAllTimes_txt] '..."projects_all.txt"
  End Select 
  
  Return sPath 
  
Catch 
  FMain.ErrorText
  
End

Public Function FilePathFormOldYears() As String 
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  Return File.Dir(sPath) &/ File.BaseName(sPath) & ("_oldyears.txt")
  
Catch 
  FMain.ErrorText
  
End

Public Function ProjectOnlyName() As String 
  
  F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  Return F_sProjectOnlyName
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtons(Optional bMore As Boolean = True)
  
  Dim bON As Boolean
  
  ''More:
  PanelListMenu.Visible = bMore 
  TextUndo.Visible = bMore
  TextRedo.Visible = bMore
  TextNeu.Visible = bMore
  ButtonSearch2ON.Visible = Not bMore
  ButtonTabelleExtern.Visible = bMore 
  ButtonOpen.Visible = False  'unused, deaktivate (Deaktiviert)
  
  ''Reset:
  bON = False
  ButtonBis.Visible = bON '{until}
  CheckBox1.Visible = bON '*EveryYear
  LabelTimer.Visible = bON 'Timer-
  LabelTitle.Visible = bON 
  LabelTitle.Raise()
  LabelTitleB.Visible = bON 
  ButtonProjectON.Visible = bON 
  ButtonSum.Visible = bON 
  ButtonName.Visible = bON 
  Text2.Visible = bON 
  Text2BG.Visible = bON 
  ButtonDauer.Visible = bON 
  ButtonTest.Visible = bON 
  ButtonPathAdd.Visible = bON
  
  Select Case F_iMusterTermine1Names2Projects3
      
    Case 1
      ''Notice:
      If Form2Bearb.Name = Form2Bearb.Name Then 
        bON = True 
        ButtonBis.Visible = bON '{until}
        CheckBox1.Visible = bON '*EveryYear
        LabelTimer.Visible = bON 'Timer-
      Endif 
      
    Case 2
      ''Projects Names:
      If Form2Bearb.Name = Form5Projekte.Name Then 
        bON = True 
        LabelTitle.Visible = bON 
        LabelTitle.Raise()
        LabelTitleB.Visible = bON 
        ButtonProjectON.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
    Case 3
      ''Projects edit:
      If Form2Bearb.Name = Form18Projektbearbeiten.Name Then 
        bON = True
        ButtonSum.Visible = bON 
        ButtonName.Visible = bON 
        Text2.Visible = bON 
        Text2BG.Visible = bON 
        ButtonDauer.Visible = bON 
        ButtonTest.Visible = bON 
      Endif 
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH As Integer 'Border Width, Height (Rand Breite, Hoehe)
  Dim iPH, iPH2, iT0W, iT1W, iXW, iXH, iTH, iH, iW, iDis As Integer 'Panel Height
  
  If Form2Bearb.Width < 200 Then Form2Bearb.Width = 200
  If Form2Bearb.Height < 200 Then Form2Bearb.Height = 200
  
  PicBackground.Move(0, 0, Form2Bearb.ClientW, Form2Bearb.ClientH)
  iBW = PicBackground.Width / 100 * 3 ' Randbreite
  iBH = PicBackground.Height / 100 * 3
  
  '*************************************************
  iDis = 10
  iPH = 50  'Text0.Font.TextHeight("0000-00-00") + iDis 'Distance
  iPH2 = iPH / 2
  iTH = iPH2  'TextBoxSearch5.Font.TextHeight("Path") + iDis
  iT0W = 150  'Text0.Font.TextWidth("0000-00-00") + iDis
  iT1W = 100 ' Text1.Font.TextWidth("00:00") + iDis
  F_iMoveLineMinH = iBH
  F_iMoveLineMaxH = Form2Bearb.ClientH - (iPH * 5.5) - iBH 
  '*************************************************
  
  'Adjust to MoveLine (Ausrichten an ▼-Bewegungslinie-▲)
  '-----------------------------------------------------------------------
  MoveLine.Move(iBW, MoveLine.Top, PicBackground.Width - (iBW * 2), iPH2) '.Top Begin => Form_Open
  '-----------------------------------------------------------------------
  If MoveLine.Top < F_iMoveLineMinH Or MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH
  
  IconError.Move(Form2Bearb.ClientW - 32, 0, 32, 32)
  ProgressBar1.Move(MoveLine.Left, MoveLine.Top, MoveLine.Width, MoveLine.Height)
  
  ColumnView1.Move(iBW, iBH, MoveLine.Width, MoveLine.Top - iBH)
  
  ''Panel 0000-00-00 00:00...
  ' iXH = LabelTimer.Font.TextHeight("Timer-") + iDis
  iXH = iPH2
  PanelDatum.Move(iBW, MoveLine.Top + MoveLine.H, ColumnView1.W, iPH + iXH)
  Text0.Move(0, iPH / 3, iT0W, iPH / 3 * 2)
  Text0BG.Move(Text0.Left, Text0.Top, Text0.W, Text0.H)
  Text1.Move(Text0.Left + Text0.W + iDis, Text0.Top, iT1W, Text0.H)
  Text1BG.Move(Text1.Left, Text1.Top, Text1.W, Text1.H)
  LabelTimer.Move(Text0.Left, Text0.Top + Text0.H, Text0.W * 0.65, iXH) 
  ButtonWeekDay.Move(LabelTimer.Left + LabelTimer.W, LabelTimer.Top, (LabelTimer.Left + LabelTimer.W + iDis + iT1W) - (LabelTimer.Left + LabelTimer.W), LabelTimer.H)
  WindowT5plus.Move(PanelDatum.W - iXH, PanelDatum.H - iXH, iXH, iXH)
  ButtonSearch2ON.Move(WindowT5plus.Left, 0, WindowT5plus.W, WindowT5plus.H)
  LabelDateNow.Move(Text0.Left, 0, Text0.W, iPH2)
  LabelTimeNow.Move(Text1.Left, 0, Text1.W, iPH2)
  ' LabelDateNow.Font.Size = LabelDateNow.Font.TextHeight("0123") * 0.65
  LabelTimeNow.Font.Size = LabelDateNow.Font.Size
  ' Text0.Font.Size = Text0.Font.TextHeight("0123") * 0.65
  
  Text1.Font.Size = Text0.Font.Size
  ' LabelTimer.Font.Size = LabelTimer.Font.TextHeight("0123") * 0.65
  ButtonWeekDay.Font.Size = LabelTimer.Font.Size
  LabelDateNow.Font.Size = LabelTimer.Font.Size
  LabelTimeNow.Font.Size = LabelTimer.Font.Size
  
  ''Extra —▶ Project:
  PanelTitle.Move(iBW, PanelDatum.Top + PanelDatum.H, PanelDatum.W, Form2Bearb.ClientH - (iBH * 2) - ColumnView1.H - MoveLine.H - PanelDatum.H - (iPH * 2) - iTH)
  ButtonName.Move(0, 0, Text0.Left + Text0.W, Text0.H)
  ButtonSum.Move(0, ButtonName.Top + ButtonName.H, Text1.Left - Text0.Left, PanelTitle.H - (ButtonName.Top + ButtonName.H)) 
  ButtonDauer.Move(Text1.Left, ButtonSum.Top, Text1.W, ButtonSum.H)
  Text2.Move(Text1.Left, 0, Text1.W, Text1.H)
  Text2BG.Move(Text2.Left, Text2.Top, Text2.W, Text2.H)
  ButtonTest.Move(PanelTitle.W - (iPH * 2), 0, iPH * 2, PanelTitle.H)
  ButtonProjectON.Move(0, 0, iPH, PanelTitle.H)
  LabelTitle.Move(iPH, 0, Text1.Left + Text1.W + iDis - iPH, PanelTitle.H)
  LabelTitleB.Move(LabelTitle.Left - 2, LabelTitle.Top + 2, LabelTitle.Width, LabelTitle.Height)
  LabelTitleB.Lower
  LabelTitleB.Text = LabelTitle.Text
  LabelTitleB.Font = LabelTitle.Font
  LabelTitleB.Alignment = LabelTitle.Alignment
  
  If F_iMusterTermine1Names2Projects3 = 1 Then 
    ''Termine:
    PanelText5.Move(0, 0, PanelTitle.W, PanelTitle.H)
  Else 
    ''Projects:
    PanelText5.Move(Text2.Left + Text2.W + iDis, 0, PanelTitle.W - (Text2.Left + Text2.W + iDis) - ButtonTest.W, PanelTitle.H)
  Endif 
  Text5.Move(0, 0, PanelText5.W, PanelTitle.H)
  
  ''Panel + ▶ Paste into List:
  PanelPaste.Move(iBW, PanelTitle.Top + PanelTitle.H, PanelDatum.W, iPH)
  ButtonAdd.Move(0, 0, iPH, iPH)
  ButtonInput.Move(iPH, 0, (PanelPaste.W / 2) - iPH, iPH)
  iXW = PanelPaste.W / 4
  CheckBox1.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  CheckBoxONoff.Move(ButtonInput.Left + ButtonInput.W, 0, iXW, iPH)
  ButtonBis.Move(CheckBox1.Left + CheckBox1.W, 0, iXW - iPH, iPH)
  ButtonSearch5ON.Move(PanelPaste.W - iPH, 0, iPH, iPH)
  
  ''Panel Path:
  PanelPath.Move(iBW, PanelPaste.Top + PanelPaste.H, PanelDatum.W, iTH)
  ButtonFileInfo.Move(0, 0, iPH, PanelPath.H)
  TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, 0, PanelPath.W - (ButtonFileInfo.Left + ButtonFileInfo.W), PanelPath.H)
  LabelInfo.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelPath.W - iTH, ButtonFileInfo.H)
  ButtonPathAdd.Move(LabelInfo.Left + LabelInfo.W, 0, PanelPath.W - (LabelInfo.Left + LabelInfo.W), iTH)
  
  ''Panel Text5 Search:
  PanelSearchText5.Move(PanelPaste.Left, PanelPaste.Top, PanelPaste.W, PanelPaste.H)
  TextBoxSearch5.Move(0, 0, PanelPath.W, PanelSearchText5.H)
  CancelSearch5.Move(PanelSearchText5.W - PanelSearchText5.H, 0, PanelSearchText5.H, PanelSearchText5.H)
  ButtonSearch5.Move(CancelSearch5.Left - (PanelSearchText5.H * 3), 0, PanelSearchText5.H * 3, PanelSearchText5.H)
  
  ''Panel Save:
  PanelSave.Move(iBW, PanelPath.Top + PanelPath.H, PanelDatum.W, iPH) 
  ButtonOpen.Move(0, 0, iPH, iPH)
  ButtonNewPlus.Move(0, 0, iPH, iPH)
  ButtonTabelleExtern.Move(ButtonNewPlus.Left + ButtonNewPlus.W, 0, iPH, iPH)
  ButtonSave.Move(ButtonTabelleExtern.Left + ButtonTabelleExtern.W, 0, ButtonInput.W, PanelSave.H)
  ButtonFormCancel.Move(ButtonSave.Left + ButtonSave.W, ButtonSave.Top, PanelSave.W - (ButtonSave.Left + ButtonSave.W) - TextNeu.W, PanelSave.H)  
  ButtonCancelB.Move(PanelSave.W - PanelSave.H - TextNeu.W, ButtonSave.Top, PanelSave.H, PanelSave.H)
  
  ''Arrow Paste ▶ 0000-00-00 00:00...
  PfeilEinfuegen.Move(0, PanelDatum.Top, iBW, iPH)
  PanelSearchList.Move(PanelDatum.Left, PanelDatum.Top, PanelDatum.Width, PanelDatum.Height)
  PanelSearchResize()
  
  ''Panel Menu List:
  PanelListMenu.Move(Text1.Left + Text1.W + iDis, 0, PanelDatum.W - (Text1.Left + Text1.W + iDis), iPH * 0.7)
  If Form2Bearb.Window.Maximized = True Then PanelListMenu.H = Text1.H
  PanelListMenuResize()
  
  ''Panel Menu Text5:
  PanelTextMenu.Move(PanelListMenu.Left, ButtonWeekDay.Top, PanelListMenu.W - iPH, ButtonWeekDay.H)
  iW = PanelTextMenu.H
  iH = PanelTextMenu.H
  TextUndo.Move(0, 0, iW, iH)
  Text5UndoCounter.Move(iW, 0, iW * 3, iH)
  TextRedo.Move(iW * 4, 0, iW, iH)
  TextNeu.Move(iW * 6, 0, iW * 3, iH)
  ButtonLineNr.Move(iW * 9, 0, PanelTextMenu.W - (iW * 13), iH)
  ButtonS.Move(PanelTextMenu.W - (iW * 4), 0, iW * 4, iH)
  
  ''Find Lines:
  ColumnView2.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Select 0000-00-00 00:00
  DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Timer: 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  ScrollViewWeekDay.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
  
  ''Time 00:00 > 23:59
  ColumnView3.Move(iBW, iBH, Text1.W + iDis, DateChooser1.H)
  
  ''Panel Until {bis}:
  PanelBis.Move(iBW + Text1.Left + Text1.W + iDis, PanelDatum.Top, PanelDatum.W - (Text1.Left + Text1.W + iDis), PanelDatum.Height)
  Label7Bis.Move(0, 0, Label7Bis.W, Text0.Height)
  Text0b.Move(Label7Bis.Left + Label7Bis.Width, 0, Text0.Width, Text0.Height)
  Text0bBG.Move(Text0b.Left, Text0b.Top, Text0b.W, Text0b.H)
  Label3b.Move(Text0b.Left, Text0b.Top + Text0b.Height, Text0b.Width, PanelBis.Height - Text0b.Height)
  LabelbisX.Move(0, Label3b.Top, Label3b.H, Label3b.Height)
  CancelBis.Move(PanelBis.W - iPH, 0, iPH, iPH)
  ButtonDateCancel.Move(PanelBis.Left, PanelBis.Top, PanelBis.W, PanelBis.H)
  
  ''Panel Text5 stretch:
  If PanelText5.H < F_iMoveLineMaxH Then 
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture
  Else 
    WindowT5plus.Picture = PicTemplatePageMini.Picture.Image.Stretch(WindowT5plus.H, WindowT5plus.H).Picture  
  Endif
  
  ''Form stretch:
  If F_bMovingON = False Then WindowStretch.Move(Form2Bearb.ClientW - iBW - iPH, Form2Bearb.ClientH - iBH - iPH, iPH, iPH)  
  
  ''List resize:
  If F_iOnly1x > 0 Then ColumnView1Resize()
  
  RaiseOrder()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub PanelSearchResize()
  
  Dim iXW As Integer
  
  iXW = PanelSearchList.H * 1.1
  TextListSearch.Move(0, 0, PanelSearchList.W - (iXW * 11), PanelSearchList.H)
  If TextListSearch.W < Text0.W Then 
    TextListSearch.W = Text0.W
    iXW = (PanelSearchList.W - TextListSearch.W) / 11
  Endif 
  ButtonSearchPanel.Move(TextListSearch.Left + TextListSearch.W, 0, iXW * 2, PanelSearchList.H)
  ListFound.Move(ButtonSearchPanel.Left + ButtonSearchPanel.W, 0, iXW, PanelSearchList.H)
  ButtonSearchListOn.Move(ListFound.Left + ListFound.W, 0, iXW * 2, PanelSearchList.H)
  ButtonSearchDown.Move(ButtonSearchListOn.Left + ButtonSearchListOn.W, 0, iXW, PanelSearchList.H)
  ButtonSearchUp.Move(ButtonSearchDown.Left + ButtonSearchDown.W, 0, iXW, PanelSearchList.H)
  LabelSearchLineNr.Move(ButtonSearchUp.Left + ButtonSearchUp.W, 0, iXW * 2, PanelSearchList.H)
  SaveSelection.Move(LabelSearchLineNr.Left + LabelSearchLineNr.W, 0, iXW, PanelSearchList.H)
  ButtonSearchCancel.Move(PanelSearchList.W - iXW, 0, iXW, PanelSearchList.H)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelListMenuResize()
  
  Dim iCount, iW, iH, iDis As Integer 'Width, Height, Distance
  
  iCount = 21 ' |i|i|...|iii|
  iW = PanelListMenu.H  
  iH = PanelListMenu.H 
  iDis = PanelListMenu.W - (iW * iCount)
  iDis = iDis / iCount 
  iDis = iW + iDis
  If iDis < iW Then iDis = iW
  
  ListDown.Move(0, 0, iW, iH)
  ListUp.Move(iDis, 0, iW, iH)
  ListCut.Move(iDis * 2, 0, iW, iH)
  ListCopy.Move(iDis * 3, 0, iW, iH)
  ListPaste.Move(iDis * 4, 0, iW, iH)
  ListSelectAll.Move(iDis * 5, 0, iW, iH)
  ListAdd.Move(iDis * 6, 0, iW, iH)
  ListUndo.Move(iDis * 7, 0, iW, iH)
  ListRedo.Move(iDis * 11, 0, iW, iH)
  ListBackupCounter.Move(ListUndo.Left, 0, (ListRedo.Left + ListRedo.W) - ListUndo.Left, iH)
  ListBackupCounter.Lower
  ListSearch.Move(iDis * 12, 0, iW, iH)
  ListMark.Move(iDis * 13, 0, iW, iH)
  ListRefresh.Move(iDis * 14, 0, iW, iH)
  ListReload.Move(iDis * 15, 0, iW, iH)
  ListAplus.Move(iDis * 16, 0, iW, iH)
  ListCheckBoxAZ.Move(iDis * 17, 0, iW, iH)
  ListCheckBoxAZLabel.Move(iDis * 17 + iW, 0, iW * 2, iH)
  ListIsChanged.Move(iDis * 20, 0, iW, iH)
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower() 'Level ▼Bottom▼
  WindowStretch.Raise() 'Level ▲Top▲
  ButtonSearchCancel.Raise()
  
  Text0BG.Raise() 'Changed auch bei Farbwechsel, deshalb extra Background für Farbhinweis (*1)
  Text1BG.Raise()
  Text2BG.Raise()
  Text0bBG.Raise()
  
  Text0.Raise()
  Text1.Raise()
  Text2.Raise()
  Text0b.Raise()
  
  LabelDateNow.Raise()
  LabelTimeNow.Raise()
  
  ''_____________________________________________________________________________''
  '(*1) Alternative in New Gambas-Version with TextBox. _Change() only Text, not Color) 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  F_bChangeON = True
  SelectHide0Date1Clock2Timer3(0)
  ProgressBarONoff(False)
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then ColumnViewInfo(("Abbruch mit [ESC]")) Else ColumnViewInfo()
  Me.Maximized = False
  Me.FullScreen = False
  
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuUndoRedo_Show()

  UndoRedoText5Show()
  
Catch 
  FMain.ErrorText

End

Public Sub UndoRedoText5Show()

  Dim n As Integer
  
  If Not F_ssUndoRedoText5 Then F_ssUndoRedoText5 = New String[]
  If F_ssUndoRedoText5 Then 
    If F_ssUndoRedoText5.Max = -1 Then 
      MenuText5Undo3.Text = ("max") & "-3" & Space(1) & ("leer") & Space(1) & ("Text-Eingabe Tastatur")
      MenuText5Undo2.Text = ("max") & "-2" & Space(1) & ("leer")
      MenuText5Undo1.Text = ("max") & "-1" & Space(1) & ("leer")
      MenuText5Undo0.Text = ("max") & "-0" & Space(1) & ("leer") 
    Else 
      n = F_ssUndoRedoText5.Max - 3
      If n > -1 And F_ssUndoRedoText5.Max > n Then 
        MenuText5Undo3.Text = ("max") & Space(1) & Str(n + 1) & "/" & Str(F_ssUndoRedoText5.Max + 1) 
        If String.Len(F_ssUndoRedoText5[n]) > 20 Then 
          MenuText5Undo3.Text &= Space(1) & String.Left(F_ssUndoRedoText5[n], 10) & "..." & String.Right(F_ssUndoRedoText5[n], 10)
        Endif 
      Else 
        MenuText5Undo3.Text = ("max") & "-3 " & ("leer")
      Endif 
      
      n = F_ssUndoRedoText5.Max - 2
      If n > -1 And F_ssUndoRedoText5.Max > n Then 
        MenuText5Undo2.Text = ("max") & Space(1) & Str(n + 1) & "/" & Str(F_ssUndoRedoText5.Max + 1) 
        If String.Len(F_ssUndoRedoText5[n]) > 20 Then 
          MenuText5Undo2.Text &= Space(1) & String.Left(F_ssUndoRedoText5[n], 10) & "..." & String.Right(F_ssUndoRedoText5[n], 10)
        Endif 
      Else 
        MenuText5Undo2.Text = ("max") & "-2 " & ("leer")
      Endif 
      
      n = F_ssUndoRedoText5.Max - 1
      If n > -1 And F_ssUndoRedoText5.Max > n Then 
        MenuText5Undo1.Text = ("max") & Space(1) & Str(n + 1) & "/" & Str(F_ssUndoRedoText5.Max + 1)
        If String.Len(F_ssUndoRedoText5[n]) > 20 Then 
          MenuText5Undo1.Text &= Space(1) & String.Left(F_ssUndoRedoText5[n], 10) & "..." & String.Right(F_ssUndoRedoText5[n], 10)
        Endif 
      Else 
        MenuText5Undo1.Text = ("max") & "-1 " & ("leer")
      Endif 
      
      n = F_ssUndoRedoText5.Max - 0
      If n > -1 And F_ssUndoRedoText5.Max > n Then 
        MenuText5Undo0.Text = ("max") & Space(1) & Str(n + 1) & "/" & Str(F_ssUndoRedoText5.Max + 1)
        If String.Len(F_ssUndoRedoText5[n]) > 20 Then 
          MenuText5Undo0.Text &= Space(1) & String.Left(F_ssUndoRedoText5[n], 10) & "..." & String.Right(F_ssUndoRedoText5[n], 10)
        Endif 
      Else 
        MenuText5Undo0.Text = ("max") & "-0 " & ("leer")
      Endif 
    Endif 
    
    Text5UndoCounter.Text = Str(F_iUndoRedoText5Pointer + 1) & Space(1) & "/" & Space(1) & Str(F_ssUndoRedoText5.Max + 1)
    Text5UndoCounter.Tooltip = Text5UndoCounter.Text & Space(1) & ("Notiz-Eingabe") 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoText5Add(Optional sText5 As String = "")
  
  If sText5 Then 
    If Not F_ssUndoRedoText5 Then F_ssUndoRedoText5 = New String[]
    If F_ssUndoRedoText5.Max = -1 Then F_ssUndoRedoText5.Add(sText5)
    If F_ssUndoRedoText5.Last <> sText5 Then 
      F_ssUndoRedoText5.Add(sText5) '(sText5, 1)
      F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max
    Endif
    UndoRedoText5Show()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoText5Pointer(Optional sUndoRedoMax As String = "undo")
  
  If Not F_ssUndoRedoText5 Then F_ssUndoRedoText5 = New String[]
  
  Select Case String.LCase(sUndoRedoMax)
      
    Case "u", "undo"
      F_iUndoRedoText5Pointer = F_iUndoRedoText5Pointer - 1
      
    Case "r", "redo"
      F_iUndoRedoText5Pointer = F_iUndoRedoText5Pointer + 1
      
    Case "min"
      F_iUndoRedoText5Pointer = -1
      
    Case "max"
      F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max
      
    Case "s", "select"
      F_iUndoRedoText5Pointer = F_iUndoRedoText5Pointer
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoText5Pointer < 0 Then F_iUndoRedoText5Pointer = -1
  If F_iUndoRedoText5Pointer > F_ssUndoRedoText5.Max Then F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max
  
  ''Replace Text
  Text5.SelectAll()
  If F_iUndoRedoText5Pointer > -1 Then 
    Text5.Insert(F_ssUndoRedoText5[F_iUndoRedoText5Pointer])
  Else 
    Text5.Insert("")
  Endif 
  
  UndoRedoText5Show()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form2Bearb.Window.Maximized = False Then
    Form2Bearb.Window.Maximized = True
  Else
    Form2Bearb.Window.Maximized = False
    Form2Bearb.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Picture (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
    sValue = Replace(sValue, "bg_", "bglinie_")
    MoveLine.Picture = Picture.Load(sValue) 
    MoveLine.Stretch = True
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
    MoveLine.Background = PicBackground.Background
    MoveLine.Stretch = False
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  FMain.F_bNeueinlesenStarten = False
  IconError.Visible = False
  mnuMaus.Visible = False
  mnuMaus2.Visible = False
  If Not Form2Bearb.Window.Window.Icon Then Form2Bearb.Window.Window.Icon = FMain.Window.Icon
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1 'Termine
      Form2Bearb.Window.Title = Application.Name & " - " & ("Bearbeiten")
    Case 2 'Project-Names
      Form2Bearb.Window.Title = Application.Name & " - " & ("Projekte")
    Case 3 'Projects
      Form2Bearb.Window.Title = Application.Name & " - " & ("Projekt bearbeiten")
  End Select 
  F_sTitleBasicText = Form2Bearb.Window.Title
  MoveLine.Top = 0
  SettingsReadSave("read")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    ColumnViewCheckAplus()
    FormStart()
    If F_iMusterTermine1Names2Projects3 = 1 Then Timer1.Start() Else Timer1.Stop()
    ReadG()
    If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
  Endif
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormStart()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
  ''Column-Number 0,1,2,3...n-1   .Max = .Count-1
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1, 2 'Termine, Project-Names
      F_iColumnNr = 6                                  'Termine 6, in Projects 13
      F_iColumnUndo = 7                                'Termine 7, in Projects 10
      F_iColumnSelect = 8 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 9                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 5   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 10    'Count                    'Termine 10, in Projects 14
      
    Case 3 'Projects
      F_iColumnNr = 13                                  'Termine 6, in Projects 13
      F_iColumnUndo = 10                                'Termine 7, in Projects 10
      F_iColumnSelect = 11 '"0" or "-1"                 'Termine 8, in Projects 11
      F_iColumnSort = 12                                'Termine 9, in Projects 12
      
      ''Column-Count 1,2,3...n
      F_iColumnsReadMax = 9   'Count                    'Termine 5, in Projects  9
      F_iColumnsCount = 14    'Count                    'Termine 10, in Projects 14
  End Select 
  
  '******************************
  F_iColorYellow = ColumnView2.Background
  F_iColorGreen = Color.Green
  F_iColorRed = Color.Red 
  F_iColorBlue = Color.Lighter(Color.Lighter(Color.Blue))
  '******************************
  
  MoreButtons(F_bMoreButtons)
  FormBackgroundColor()
  ColumnViewImagesRead()
  ButtonSave.Background = Color.Default 
  
  F_bChangeON = False
  LabelInfoPathG(FilePathForm())
  WeekDays0to6()
  F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then 
    F_sText5StartExampleName = Text5TempFileLoad() 'as String, Read file
  Else 
    Text0Insert(Format(Date, "yyyy-mm-dd"))
    Text0bInsert(Format(Date, "yyyy-mm-dd"))
    Text1Insert(Format(Time, "hh:nn"))
    Text5Insert(F_sText5StartExampleName)
  Endif 
  Text5.Pos = String.Len(Text5.Text)
  Text5.SetFocus
  ButtonWeekDay.Text = Format(Date, "dddd")
  ButtonWeekDay.Tooltip = Format(Date, "dddd")
  TextUndo.Picture = ListUndo.Picture.Image.Stretch(F_i22, F_i22).Picture
  TextRedo.Picture = ListRedo.Picture.Image.Stretch(F_i22, F_i22).Picture
  MenuSaveAsCopy.Picture = MenuSaveAsCopy.Picture.Image.Desaturate().Contrast(1).Picture
  
  TextBackgroundAll(Color.Transparent)
  F_bChangeON = True
  
  F_bListChanged = False
  F_bKeyboardInput = False
  ColorPicButtonReplace()
  WindowStretchCursor()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FilePathCheck()
  
  Dim sDirFile As String
  ' TextBoxPath.Text = FilePathForm()
  sDirFile = TextBoxPath.Text 
  
  If sDirFile = "" Then TextBoxPath.Text = ("Datei fehlt?")  
  TextBoxPath.ToolTip = ("Datei=") & Space(1) & TextBoxPath.Text
  If Exist(sDirFile) = False Then
    TextBoxPath.Foreground = F_iColorRed
    ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture
  Else
    TextBoxPath.Foreground = Color.Gray
    If F_iSecondsFileRead = 2 Then 'slowly?
      ButtonFileInfo.Picture = ColumnViewImages("PicQuestion").Picture 'Pixel 22, 22
    Else 
      ButtonFileInfo.Picture = mnuInfo.Picture.Image.Stretch(F_i22, F_i22).Picture
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WeekDays0to6()
  
  Dim ssWeekdays As New String[]
  
  ssWeekDays = M01Functions.Weekdays0to6LocalLanguage() 'new in Gambas3
  
  If ssWeekdays.Count >= 7 Then 
    ToggleButtonW1.Text = ssWeekdays[0] 'So
    ToggleButtonW2.Text = ssWeekdays[1] 'Mo
    ToggleButtonW3.Text = ssWeekdays[2] 'Di
    ToggleButtonW4.Text = ssWeekdays[3] 'Mi
    ToggleButtonW5.Text = ssWeekdays[4] 'Do
    ToggleButtonW6.Text = ssWeekdays[5] 'Fr
    ToggleButtonW7.Text = ssWeekdays[6] 'Sa
  Endif 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewSortPics()
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_iColumnSelect < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView1.Columns.Sort = F_iColumnSelect
      If ColumnView1.Selection.Max > -1 Then
        ' sKey = ColumnView1.Selection[ColumnView1.Selection.Max]  'only Key, Example: Last sKey = "9"
        sKey = ColumnView1.Selection.Last
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If F_iColumnSelect < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      ColumnView2.Columns.Sort = F_iColumnSelect
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection.Last  'only Key, Example: Last sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewImagesRead()  'Note: Work with Images = faster. Convert to Picture at End.
  
  Dim ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgDate, ImgDayMinus, ImgDayPlus, ImgTime, ImgTimeMinus, ImgTimePlus As Image
  Dim iSize As Integer
  
  ''End-Names:
  F_ssCVImgNames = ["PicAdd", "PicCut", "PicDouble", "PicDown", "PicEmpty", "PicFind", "PicHome", "PicMarkGreen", "PicOFF", "PicOK", "PicON", "PicQuestion", "PicRefresh", "PicSave", "PicUp", "PicWarning", "PicDate", "PicDayMinus", "PicDayPlus", "PicTime", "PicTimeMinus", "PicTimePlus"]
  
  iSize = F_i22 'Pixel 
  ImgAdd = ListAdd.Picture.Image.Stretch(iSize, iSize)
  ImgCut = ListCut.Picture.Image.Stretch(iSize, iSize)
  ImgDouble = PicTemplateDouble.Picture.Image.Stretch(iSize, iSize)
  ImgDown = ListDown.Picture.Image.Stretch(iSize, iSize)
  ImgEmpty = New Image(iSize, iSize, Color.Transparent) 'Image is faster than Picture
  ImgFind = ListSearch.Picture.Image.Stretch(iSize, iSize) 
  ImgHome = PicTemplateLEDgreen.Picture.Image.Stretch(iSize, iSize) 
  ImgMarkGreen = ListMark.Picture.Image.Stretch(iSize, iSize) 'Flag
  ImgOff = PicTemplateConnectOff.Picture.Image.Stretch(iSize, iSize)
  ImgOK = PicTemplateApply.Picture.Image.Stretch(iSize, iSize) 
  ImgON = PicTemplateConnectON.Picture.Image.Stretch(iSize, iSize)
  ImgQuestion = mnuZeilenvergleichen.Picture.Image.Stretch(iSize, iSize)
  ImgRefresh = PicTemplateReChange.Picture.Image.Stretch(iSize, iSize)
  ImgSave = ButtonSave.Picture.Image.Stretch(iSize, iSize)
  ImgUp = ListUp.Picture.Image.Stretch(iSize, iSize)
  ImgWarning = IconError.Picture.Image.Stretch(iSize, iSize)
  ImgDate = MenuMoveDate.Picture.Image.Stretch(iSize, iSize)
  ImgDayMinus = MenuMoveDayMinus.Picture.Image.Stretch(iSize, iSize)
  ImgDayPlus = MenuMoveDayPlus.Picture.Image.Stretch(iSize, iSize)
  ImgTime = MenuMoveTime.Picture.Image.Stretch(iSize, iSize)
  ImgTimeMinus = MenuMoveHourMinus.Picture.Image.Stretch(iSize, iSize)
  ImgTimePlus = MenuMoveHourPlus.Picture.Image.Stretch(iSize, iSize)
  
  ''Images:
  F_ooColumnViewImages = [ImgAdd, ImgCut, ImgDouble, ImgDown, ImgEmpty, ImgFind, ImgHome, ImgMarkGreen, ImgOff, ImgOK, ImgON, ImgQuestion, ImgRefresh, ImgSave, ImgUp, ImgWarning, ImgDate, ImgDayMinus, ImgDayPlus, ImgTime, ImgTimeMinus, ImgTimePlus]
  
  ''Example:
  'PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewImages(Optional sName As String = "PicEmpty") As Image
  
  Dim iFound As Integer
  
  If String.InStr(sName, "-") > 0 Then sName = Replace(sName, "-", "") '"-" for selected Line
  If F_ssCVImgNames And F_ooColumnViewImages Then iFound = F_ssCVImgNames.Find(sName) '-1 not found
  If iFound = -1 Then iFound = F_ssCVImgNames.Find("PicEmpty")
  
  Return F_ooColumnViewImages[iFound]
  
Catch 
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ReadG(Optional sDirFile As String = "", Optional bDialog As Boolean = False) ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  'Aus der Datei wird zeilenweise gelesen
  
  Dim hFile As File 'Stream
  Dim iColumn, iUnknownCounter, iEmptyOrDouble, iLine, iLines As Integer
  Dim sKey, sLine, sLinePart, sText, sUnknown, sMessage, sDemo As String
  Dim ssExist, ssRepair As String[]
  Dim PicEmpty As Picture
  Dim dateBegin, dateEnd As Date 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  
  ''Reset:
  F_bESCpressedON = False
  IconError.Visible = False
  F_sUnknownLinesText = "" 
  dateBegin = Now
  Error.Clear()
  
  ''Dialog:
  If bDialog = True Then 'Add+
    sDirFile = FileDialogPathReturn(sDirFile, "open", FilePathForm()) 'no Path = cancel
    If Exist(sDirFile) = False Then Goto JumpEnd    'Cancel (Abgebrochen)
  Else 
    ColumnView1.Clear() 'delete all lines, but not title (header)
    F_longFilesRead = 0
  Endif
  
  ''File-Name or Standard or Demo:
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = False Then
    ''Empty, Demo-File
    sDemo = M01Functions.DemoFileTermineOrProjects(FilePathForm()) 'Terminwecker or Projects
    If Exist(sDemo) = True Then Try Move sDemo To sDirFile 
  Endif
  If sDirFile <> TextBoxPath.Text Then 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
  Endif 
  FilePathCheck()
  
  ''Check Columns:
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  F_iOldLines = ColumnView1.Count
  If F_iOldLines = 0 Then ColumnSortSettingCentral()
  ' If F_iOldLines = 0 Then PicNew = PicEmpty Else PicNew = PicAdd
  ' ColumnView1.Header = True 
  ColumnView1.Visible = False
  ' ColumnView1.Sorted = False     'Enter-List (Liste nach Eingang aus Datei)
  
  ProgressBarONoff(True)
  Form2Bearb.Window.Title = Application.Name & " - " & ("Datei lesen...")
  
  ''Check first lines. File-Format:
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    If M01Functions.isTerminweckerFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Else 
    If M01Functions.isProjectFile(sDirFile, True) = False Then Goto JumpEnd '(Path, MessageQuestionFalse) as Boolean  
  Endif 
  
  ''Backup:
  If Not F_ooCVBackups Then ColumnViewBackup()
  
  'Read and add Column Lines (Zeilen (rows) erzeugen)
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  If Exist(sDirFile) = True Then
    F_longFilesRead = F_longFilesRead + Stat(sDirFile).Size 'as Long
    ssExist = New String[]
    ColumnView1.Sorted = False 
    ''Read ########################################
    hFile = Open sDirFile For Read
    
    hFile.EndOfLine = gb.Unix 'as Integer, 0=Unix, 1=Windows, 2=Mac
    'Gambas3: "Note that gb.Unix actually allows you to read both Unix and Windows line formats. But it only writes Unix format."
    ' gb.Unix For lines separated by Chr$(10).
    ' gb.Windows For lines separated by Chr$(13) & Chr$(10).    ' gb.CrLf = "\r\n" = Chr$(13) & Chr$(10)
    ' gb.Mac For lines separated by Chr$(13).
    If F_iMusterTermine1Names2Projects3 > 1 Then ssExist.Sort() '>Projects
    
    For Each sLine In hFile.Lines  ''all Lines in File
      sLine = Replace(sLine, gb.Cr, "") '"\r"
      If sLine And String.Left(sLine, 1) <> "#" And ssExist.ExistSorted(sLine) = False Then '.FindSorted() > faster ~10x
        ''Test Rest:
        If sLine Like "*????-??-??*??:??*????-??-??*?Q" & gb.Tab & "*" Then 
          If sLine Then ssRepair = ReadRepairG(sLine) Else ssRepair = Null 'as String[]
          If ssRepair Then ssExist.Insert(ssRepair)
        Else 
          ssExist.Add(sLine) 
        Endif 
      Else 
        iEmptyOrDouble = iEmptyOrDouble + 1
      Endif 
      
      iLines = iLines + 1
      If iLines Mod 100 = 0 Then 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          sMessage = sDirFile & "<br>"
          If Stat(sDirFile).Size > 2000000 Then '2MiB
            sMessage &= M01Functions.FileSizeText(sDirFile) & "<br>"
            sMessage &= "<font color=red><b>" & ("Große Datei = Mehr Zeit") & "</b></font><br><br>"
            sMessage &= ("Zeile") & ": " & iLines & "<br>"
            sMessage &= ("Tipp: Menü > Datei > Auslagern...") 
          Endif 
          If MessageQuestionBreak(sMessage) = True Then Break
        Endif 
        ProgressBarONoff(True) 
      Endif 
    Next 
    
  Finally ' If Error, then next Line, always. (Immer ausführen, auch bei einem Fehler. Muß immer vor Catch sein (wenn vorhanden))
    hFile.Close() ' ########################################
  Endif 
  
  'Check "\r" Return,  Typ Window-File "\r\n"= gb.CrLF=Chr$(13) & Chr$(10)
  If Exist(sDirFile) = True And String.InStr(sLine, gb.Cr) > 0 Then 
    sText = File.Load(sDirFile)
    If sText Then 
      ssExist = New String[]
      sText = Replace(sText, gb.Cr, gb.NewLine)
      ssExist = Split(sText & gb.NewLine, gb.NewLine) 
    Endif 
  Endif 
  
  If Not Error Then 
    For iLine = 0 To ssExist.Max '.........................................
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form2Bearb.Window.Title) = True Then Break
      Endif 
      
      sLine = ssExist[iLine] 'one line
      
      If String.Len(sLine) > 10 Then 'min.
        
        sKey = Str(ColumnView1.Count + 1)
        ColumnView1.Add(sKey, "")
        
        iColumn = 0
        For Each sLinePart In Split(sLine & String(F_iColumnsCount, hTab), hTab) ' Stringarray
          If iColumn = 0 Then 
            ColumnView1[sKey][iColumn] = Trim(sLinePart) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          Else If iColumn < F_iColumnsReadMax + 1 Then 
            ColumnView1[sKey][iColumn] = sLinePart
          Endif 
          If iColumn = F_iColumnsReadMax Then Break
          iColumn = iColumn + 1
        Next
        
        If iColumn = F_iColumnsReadMax Then
          ColumnView1[sKey][F_iColumnUndo] = sLine 'Original Line (Originalzeile)
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = sKey
          If F_iOldLines = 0 Then
            ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
          Else 
            ColumnView1[sKey][F_iColumnSelect] = "PicAdd"  
          Endif 
        Else  'too many or not enough Separators '(zu viele oder zu wenige sSeparator) '|0|1|2|3|4|5|> |
          ColumnView1[sKey][F_iColumnUndo] = sLine 
          ColumnView1[sKey][F_iColumnNr] = sKey
          ColumnView1[sKey][F_iColumnSort] = 0
          iUnknownCounter = iUnknownCounter + 1
          If iUnknownCounter < 5 Then F_sUnknownLinesText &= sLine & gb.NewLine 'ssUnknown.Add(sLine)
          ColumnView1[sKey][F_iColumnSelect] = "PicWarning" '!
        Endif 'F_iColumnsReadMax
      Endif 
      
    Next '................................................. 
  Endif 
  'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  
  F_iUnknownCounter = iUnknownCounter
  mnuFehlzeilen.Text = ("?-Zeilen=") & F_iUnknownCounter
  If iUnknownCounter > 0 Then 
    F_sUnknownLinesText = Str(iEmptyOrDouble) & Space(1) & ("von") & Space(1) & Str(ssExist.Count) & Space(1) & ("Zeilen leer oder doppelt") & gb.NewLine 
    F_sUnknownLinesText &= Str(iUnknownCounter) & Space(1) & ("?-Zeilen") & ". " & ("Beispiel") & ": " & gb.NewLine 
    sUnknown = M01Functions.CheckTextTerminwecker(F_sUnknownLinesText)
    F_sUnknownLinesText &= sUnknown
  Endif 
  ButtonSave.Background = Color.Default
  ColumnviewIcons()
  ColumnView1.UnselectAll() '>AddAppend
  ''Activate or Deactivate:
  ColumnViewAddAppend() ''with ColumnViewSort() 'with .EnsureVisible()
  ColumnViewBackup()
  If F_iMusterTermine1Names2Projects3 = 2 Then ProjectLineSelection() '>Form5Projekte
  ' TextBoxPath.SelectAll()
  ' TextBoxPath.Insert(sDirFile) '>Form18Diagramm
  ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  F_bListChanged = False
  If sDirFile = FilePathForm() Then F_statFilePathForm = Stat(sDirFile)
  
JumpEnd:
  ColumnView1Resize() 'with Title-Info
  If ColumnView1.Columns.Count > 5 Then 
    If ColumnView1.Columns[5].Title Then ColumnViewInfo(ColumnView1.Columns[5].Title)
  Endif 
  ColumnView1.Visible = True
  ProgressBarONoff(False)
  dateEnd = Now 
  F_iSecondsFileRead = DateDiff(dateEnd, dateBegin, gb.Second) 'as Integer
  WindowTitle()
  
Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText
  IconError.Raise '▲top level▲  (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
  IconError.Visible = True
  TextBoxPath.Foreground = F_iColorRed
  If Exist(sDirFile) = True Then Close #hFile
  ColumnView1.Visible = True
  
End ' EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Public Function ReadRepairG(Optional sLine As String = "") As String[]

  Dim iColumn As Integer
  Dim sLinePart, sUnknown, sYYYYMMDD As String 
  Dim ssUnknown As String[]
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  iColumn = 0
  For Each sLinePart In Split(sLine & hTab, hTab) ' Stringarray
    ' Print sLinePart
    If sLinePart And sLinePart Like "*????-??-??*" Then 
      If iColumn < F_iColumnsReadMax Then 
        sUnknown &= sLinePart & hTab
      Else
        If Not ssUnknown Then ssUnknown = New String[]
        sYYYYMMDD = String.Right(sLinePart, 10)
        If sYYYYMMDD Like "*????-??-??*" Then 
          sUnknown &= String.Left(sLinePart, String.Len(sLinePart) - 10) 
          ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
          iColumn = 0
          sUnknown = sYYYYMMDD & hTab ''Reset, Begin...
        Endif 
      Endif
    Else If iColumn > 0 Then 
      sUnknown &= sLinePart & hTab
    Endif 
    iColumn = iColumn + 1
  Next
  If Replace(sUnknown, hTab, "") Then 
    If Not ssUnknown Then ssUnknown = New String[]
    ssUnknown.Add(sUnknown) 'Trim Example: " 0000-00-00 " > "0000-00-00"
  Endif  
  ' If ssUnknown Then sUnknown = ssUnknown.Join(hReturn)
  
  Return ssUnknown
  
Catch 'Catch Error (Fehler abfangen)
  FMain.ErrorText

End

Public Sub ColumnviewIcons()
  
  Dim sKey, sIcon As String 
  Dim iLine As Integer
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sIcon = ColumnView1[sKey][F_iColumnSelect]
    ColumnView1[sKey].Picture = ColumnViewImages(sIcon).Picture 
  Next
  
Catch
  FMain.ErrorText
  
End

Public Sub WindowTitle()
  
  Dim sKey As String = "?"
  Dim sSpace As String 
  
  sSpace = Space(1)
  
  If ColumnView2.Visible = False Then 
    Form2Bearb.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView1.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & ")"
    If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last
    ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
  Else 
    Form2Bearb.Window.Title = F_sTitleBasicText & Space(5) & Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Zeilen") & " (" & F_iOldLines & " " & ("vorher") & ")"
    If ColumnView2.Selection.Max > -1 Then sKey = ColumnView2.Selection.Last
    If String.Len(sKey) < 4 Then 
      LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey 'only Key (number)
    Else 
      LabelSearchLineNr.Text = sKey 'only Key (number)  
    Endif 
    SaveSelection.Tooltip = Str(ColumnView2.Selection.Count) & sSpace & ("von") & sSpace & Str(ColumnView2.Count) & Space(1) & ("Auswahl speichern in...")
  Endif 
  ColumnViewAscending()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAscending()
  
  If ColumnView1.Columns.Ascending = True Then  
    ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView1.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  If ColumnView2.Columns.Ascending = True Then  
    ColumnView2.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  Else 
    ColumnView2.Columns[0].Title = "△▼" & Space(6) & ("Datum") & Space(2)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
  
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub Form_Close()
  
  Dim sStandard, sMessage As String 
  
  SettingsReadSave("save") 'Save window settings when application closes
  
  If F_bListChanged = False And F_bKeyboardInput = True Then
    sMessage = "<font color=gray>" & String.Left(Text5.Text, 50) & "</font>" & "<br>"
    sMessage &= "..." & "<br>"
    sMessage &= "<font color=red><b>" & ("Nicht gespeichert.") & "</b></font>" & "<br>"
    
    Select Message.Question(sMessage, ("Bearbeiten..."), ("Schliessen"), ("Abbrechen"))
      Case 1, 3 'Edit, Close
        Stop Event  ' Vorgang abbrechen
      Case 2 'Cancel
        '...
    End Select
  Endif
  
  If F_bListChanged = True Then
    sMessage = "<h1><font color=red>" & ("Veränderte Liste") & "</font></h1>" 
    sMessage &= "<font color=gray>" & FilePathForm() & "</font>" & "<br>"
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If F_sProjectOnlyName = String.LCase(Application.Name) Then 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font><font color=gray>" & Space(1) & ("(Standard)") & "</font></h3>"
      Else 
        sStandard = "<h3><font color=gray>" & ("Aktiviert") & ": " & "</font><font color=darkgreen>" & F_sProjectOnlyName & "</font></h3>"
      Endif 
      sMessage &= sStandard 
      sMessage &= CheckProjectOnlyName(F_sProjectOnlyName) & "<br>"
    Endif
    
    Select Message.Question(sMessage, "○ " & ("Speichern"), ("Schliessen"), ("Abbrechen"))
      Case 1 'Save:
        SaveG()
      Case 2 'Close:
        '...Leerlauf
      Case 3 'Cancel:
        Stop Event  ' Vorgang abbrechen
    End Select
  Endif
  
  F_bESCpressedON = False
  ' If F_iListChangedCounter > 0 Then 
  FMain.F_bNeueinlesenStarten = True ' —▶ Timer   'See FMain.RefreshAll()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form2Bearb.Left]
      iY = Settings[F_sForm &/ "Top", Form2Bearb.Top]
      iW = Settings[F_sForm &/ "Width", Form2Bearb.W]
      iH = Settings[F_sForm &/ "Height", Form2Bearb.H]
      Form2Bearb.Move(iX, iY, iW, iH)
      F_bMoreButtons = Settings[F_sForm &/ "F_bMoreButtons", F_bMoreButtons]
      F_i22 = Settings[F_sForm &/ "F_i22", F_i22] 
      TextListSearch.SelectAll()
      TextListSearch.Insert(Settings[F_sForm &/ "TextListSearch.Text", TextListSearch.Text])
      
    Case "s" ''Save
      'Save window settings when application closes (Fenster-Position sichern wenn es geschlossen wird)
      Settings[F_sForm &/ "Left"] = Form2Bearb.Left
      Settings[F_sForm &/ "Top"] = Form2Bearb.Top
      Settings[F_sForm &/ "Width"] = Form2Bearb.Width
      Settings[F_sForm &/ "Height"] = Form2Bearb.Height
      Settings[F_sForm &/ "F_bMoreButtons"] = F_bMoreButtons
      Settings[F_sForm &/ "F_i22"] = F_i22
      Settings[F_sForm &/ "TextListSearch.Text"] = TextListSearch.Text
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveG(Optional sDirFileAsCopy As String = "")
  
  Dim sText, sMessage As String
  Dim iLine, iColumn, iDoubleLines As Integer
  Dim sPath, sDirFile As String
  Dim sInfo1, sInfo2 As String
  Dim sKey, sLine As String
  Dim PicSave, PicDouble, PicQuestion As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  PicSave = ColumnViewImages("PicSave").Picture 
  PicDouble = ColumnViewImages("PicDouble").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture 
  
  If sDirFileAsCopy Then 
    sDirFile = sDirFileAsCopy
  Else 
    sDirFile = FilePathForm()
  Endif
  
  If Exist(sDirFile) = True Then 
    sInfo1 = Format(Stat(sDirFile).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sDirFile).Size 
  Else 
    sInfo1 = Format(Now, "yyyy-mm-dd hh:nn:ss.uu") & "0" 
  Endif 
  sInfo2 = sInfo1 
  
  If Not F_ooCVBackups Then ColumnViewBackup()
  TextBoxPath.Foreground = Color.Default
  IconError.Visible = False
  F_bESCpressedON = False
  Form2Bearb.Window.Title = Application.Name & " - " & File.Name(sDirFile) & Space(2) & ("speichern...")
  'Muster: SicherungsDatei = SicherungOrdner &/ "backup_" & Name & "_" & Format(Now, "yyyy-mm-dd_dddhh-nn-ss") & ".txt"
  ssExist = New String[]
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form2Bearb.Window.Title) = True Then Break
    Endif 
    
    If ColumnView1[sKey].Text <> "" Then
      sLine = ""
      For iColumn = 0 To ColumnView1.Columns.Max
        If iColumn < F_iColumnsReadMax Then 
          sLine &= ColumnView1[sKey][iColumn] & hTab
        Else
          sLine &= ColumnView1[sKey][iColumn] '& hReturn
          ' sLine = Replace(sLine, String.Chr(65533), String.Chr(182)) '"?" unknow, "¶" Return "\r"
          Break
        Endif
      Next
      If ssExist.Find(sLine) = -1 Then ' no double (nicht doppelte Zeilen)
        ssExist.Add(sLine)
        ' sText = sText & sLine 
        ColumnView1[sKey].Picture = PicSave
        ColumnView1[sKey][F_iColumnSelect] = "PicSave"
      Else
        '..Leerlauf
        iDoubleLines = iDoubleLines + 1
        ColumnView1[sKey].Picture = PicDouble
        ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
      Endif 
      
    Else 
      ColumnView1[sKey].Picture = PicQuestion
      ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
    Endif
  Next
  If ssExist Then sText = ssExist.Join(hReturn)  '& hReturn
  
  ''Title:
  If sText Then 
    If String.InStr(sText, "#" & Application.Name) = 0 Then sText = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Termine") & Space(1) & ("Trenner: TABulator") & gb.NewLine & sText 
  Endif
  
  If F_bESCpressedON = True Then Goto Ende
  
  ''Save:
  sPath = M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
  ' Print sText 
  
  If Not FMain.F_sProjectOnlyName Then FMain.F_sProjectOnlyName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name])
  ' M01Functions.ProjectLineOpenRefreshClose(FMain.F_dateProjectStart, Now, True) 'TRUE (open/refresh), FALSE (close)
  
  If Exist(sPath) = True Then 
    If iDoubleLines > 0 Then ButtonLineNr.Text = ("Doppelte Zeilen") & ": " & Str(iDoubleLines)
    F_bListChanged = False
    sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size
  Else ''Alternativ:
    sMessage = sPath & hReturn 
    sMessage &= ("Datei nicht gefunden") & "!" & hReturn & hReturn 
    sMessage &= ("Liste speichern?")
    Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
      Case 1
        Dialog.Path = sDirFile
        Dialog.AutoExt = True 
        Dialog.Title = ("Liste speichern...")
        'If Dialog.SaveFile() Then Return 'Kurzform
        If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
          Return ' User pressed Cancel -
        Else 'Gibt Datei-Name zurück
          '=False, nicht abgebrochen
        Endif
        sPath = M01Functions.FileTextPlus(Dialog.Path, sText, True) ' TRUE=overwrite (überschreiben)
        If Exist(sPath) = True Then sInfo2 = Format(Stat(sPath).LastModified, "yyyy-mm-dd hh:nn:ss.uu") & Stat(sPath).Size 
        F_bListChanged = False
        'FMain.F_bNeueinlesenStarten = TRUE ' über Timer
      Case 2
        '... Cancel
    End Select
  Endif
  
Ende:
  ProgressBarONoff(False)
  If Exist(sPath) = True Then ''Check
    F_statFilePathForm = Stat(sPath) 'Refresh
    If sInfo1 = sInfo2 Then ' nicht gespeichert nicht verändert?
      TextBoxPath.Foreground = F_iColorRed
      IconError.Visible = True
      sMessage = sPath & "<br><br>" 
      sMessage &= "<font color=red>" & ("Nicht gespeichert?") & "</font>"
      Select Case Message.Warning(sMessage, ("Ordner..."), ("Abbrechen"))
        Case 1 'Directory
          M01Functions.FileManagerOpen(sPath)
        Case 2 'Cancel
          '...
      End Select 
    Else ''gespeichert
      ButtonSave.Background = Color.Default 
      F_iCVUndoRedoPointerSave = F_iCVUndoRedoPointer
    Endif
    TextBoxPath.Text = sPath '& Space(1) & Format(Stat(sPath).LastModified, "ddd dd.mm.yyyy hh:nn") & Space(3) & File.FormatSize(Stat(sPath).Size, True) 'Format(statInfo2.Size, "#,###") & "" & "Bytes"
    LabelInfoPathG(sPath)
  Endif 'Exist
  F_bKeyboardInput = F_bListChanged
  ColumnViewBackup()
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  ' ColumnViewListChangeLED()
  If F_bListChanged = False Then ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Form2Bearb.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise
  Form2Bearb.Window.Title = F_sTitleBasicText
  
End

Public Sub ColumnView1_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  ' If Mouse.Right Then mnuMaus.Popup 'or > Eigenschaften PopupMenu = mnuMaus
  If Mouse.Right Then mnuBearbeiten.Popup
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView1_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions("cut")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewClick()
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim iT8 As Integer
  Dim sKey, sValue As String
  Dim hDate, dateTime As Date
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    sKey = ColumnViewCurrentKey()
    If ColumnView1.Exist(sKey) = True Then 
      T0 = ColumnView1[sKey][0] 'Datum
      T1 = ColumnView1[sKey][1] 'Uhr
      T2 = ColumnView1[sKey][2] 'WTag von
      T3 = ColumnView1[sKey][3] 'Q
      T4 = ColumnView1[sKey][4] 'KW
      T5 = ColumnView1[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView1[sKey][6] 'Uhr
        T7 = ColumnView1[sKey][7] 'WTag bis
        T8 = ColumnView1[sKey][8] 'Sek.
        T9 = ColumnView1[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr  
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView1.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView1.Columns.Max > 5 Then ColumnView1.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    If Not F_ooDateTimeNoticeBackup Then DateTimeNoticeBackup("+")
    F_bChangeON = False
    ' sKey = ColumnViewCurrentKey()
    sKey = ColumnView2.Current.Key
    sKey = ColumnView2[sKey][F_iColumnNr]
    If ColumnView1.Exist(sKey) = True Then 
      ColumnView1[sKey].Selected = True 
      ColumnView1[sKey].EnsureVisible
    Endif 
    sKey = ColumnView2.Current.Key
    If ColumnView2.Exist(sKey) = True Then 
      T0 = ColumnView2[sKey][0] 'Datum
      T1 = ColumnView2[sKey][1] 'Uhr
      T2 = ColumnView2[sKey][2] 'WTag von
      T3 = ColumnView2[sKey][3] 'Q
      T4 = ColumnView2[sKey][4] 'KW
      T5 = ColumnView2[sKey][5] 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        T6 = ColumnView2[sKey][6] 'Uhr
        T7 = ColumnView2[sKey][7] 'WTag bis
        T8 = ColumnView2[sKey][8] 'Sek.
        T9 = ColumnView2[sKey][9] 'Dauer
      Endif 
    Endif 
    If T0 And T5 Then 
      If T0 Like "*????-??-??*" Then ' * Es können kodierte System-Vorzeichen vorgestellt sein?
        hDate = M01Functions.DateCheckyyyymmddhhnn(T0, "00:00") 'as Date
        T0 = Format(hDate, "yyyy-mm-dd")
        T2 = Format(hDate, "dddd")
      Endif
      
      sValue = Trim(T5)
      sValue = Replace(sValue, hReturn, String.Chr(182), gb.String) ' Replace Return "¶" (ersetzen)
      sValue = Replace(sValue, hTab, Space(3))
      sValue = Replace(sValue, Chr(10), ".") 'gb.Lf = Chr$(10) = "\n", gb.NewLine = gb.Lf
      sValue = Replace(sValue, Chr(13), ".") 'gb.Windows = Chr$(13) & Chr$(10), gb.Cr = Chr$(13), gb.CrLf = gb.Windows
      T5 = sValue
      
      Text0Insert(T0) 'Datum 
      Text1Insert(T1) 'Uhr 
      Text5Insert(T5) 'Projekt-Notiz
      If F_iMusterTermine1Names2Projects3 = 3 Then
        Text2Insert(T6) 'Uhr 
        ButtonSum.Tooltip = T8 'Sek.
        ' ButtonDauer.Text = T9 '00:00:00 Dauer
        If IsInteger(T8) = True Then 
          iT8 = CInteger(T8)
          dateTime = Date(Year(hDate), Month(hDate), Day(hDate), 0, 0, 0)
          dateTime = DateAdd(dateTime, gb.Second, iT8)
          ButtonDauer.Text = Format(dateTime, "hh:nn:ss")
        Else 
          ButtonDauer.Text = "??:??"  
        Endif 
      Endif 
      TextBackgroundAll(Color.Transparent)
      F_bChangeON = True
      ButtonWeekDay.Text = String.Left(T2, 2)
      ButtonWeekDay.Tooltip = T2
      DateTimeNoticeBackup("+")
      'PanelText5.Background = Color.Transparent
      ColumnView2.Mode = Select.Multiple
      LabelInfo.Visible = False
      F_bKeyboardInput = False
      If ColumnView2.Columns.Max > 5 Then ColumnView2.Columns[5].Title = ("Notiz") & Space(3) & ("Projekt-Name")
    Endif 
    If F_iMusterTermine1Names2Projects3 = 2 Then
      If Text5.Text = F_sProjectOnlyName Then 
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Else 
        ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
      Endif 
    Endif 
    WindowTitle()
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateTimeNoticeBackup(Optional UndoRedo As String = "+")
  
  Dim hObj As Object
  
  Select Case UndoRedo
    Case "+" ''Backup
      If Not F_ooDateTimeNoticeBackup Then F_ooDateTimeNoticeBackup = New Object[]  
      hObj = [Text0.Text, Text1.Text, Text5.Text, Text2.Text]
      F_ooDateTimeNoticeBackup.Push(hObj)
      F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
    Case "<" ''Undo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer - 1
        If F_iDateTimeNoticeBackupPointer < 0 Then F_iDateTimeNoticeBackupPointer = 0
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
    Case ">" ''Redo
      If F_ooDateTimeNoticeBackup Then 
        F_iDateTimeNoticeBackupPointer = F_iDateTimeNoticeBackupPointer + 1
        If F_iDateTimeNoticeBackupPointer > F_ooDateTimeNoticeBackup.Max Then F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        hObj = F_ooDateTimeNoticeBackup[F_iDateTimeNoticeBackupPointer]
        If hObj Then 
          Try Text0Insert(hObj[0])
          Try Text1Insert(hObj[1])
          Try Text5Insert(hObj[2])
          Try Text2Insert(hObj[3])
        Endif 
      Endif 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Function Columnview1EnsureVisible() As String 'Key
  
  Dim sK2 As String 
  
  If ColumnView1.Visible = True Then 
    ' If ColumnView1.Keys.Count > 0 Then 'Error
    If ColumnView1.Current Then 
      sK2 = ColumnView1.Current.Key
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Else If ColumnView2.Visible = True Then 
    If ColumnView2.Current Then 
      sK2 = ColumnView2.Current.Key
      If ColumnView2.Exist(sK2) = True Then ColumnView2[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  Endif 
  
  Return sK2
  
  Catch 
    FMain.ErrorText
  
End

Public Sub ButtonInputG() 'Zeileneintrag einfügen
  
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim T0b, T1b, T2b, T3b, T4b, T5b As String 
  Dim sLine, sText, sMessageLines As String
  Dim sValue, sMessage, sHTMLa, sHTMLb, sSpace, sUntil As String
  Dim sKey As String
  Dim iSecond, iHH, iMM As Integer
  Dim it, iLine, iDiff, iCounter, iOnly1x As Integer
  Dim hDate0, hDate1, hDate2, hDateNr As Date
  Dim sTime1, sTime2 As String 
  Dim ssTime As String[]
  Dim PicRefresh As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  F_bESCpressedON = False
  PicRefresh = ColumnViewImages("PicRefresh").Picture 
  
  sHTMLa = "<font color=darkgreen><b>"
  sHTMLb = "</b></font>"
  sSpace = "&nbsp;" 'Leerzeichen 1x
  Try sUntil = "<font color=#" & Hex(Label7Bis.Foreground, 6) & ">" & ButtonBis.Text & "</font>"
  
  If Not F_ooCVBackups Then ColumnViewBackup()

  Columnview1EnsureVisible()
  
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T1 = Text1.Text
    T2 = Format(hDate1, "ddd")
    T3 = Str(M01Functions.DateQuarterG(hDate1)) & ("Q")
    T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      T6 = Text2.Text
      T7 = T2
      T8 = ButtonSum.Tooltip
      T9 = ButtonDauer.Text
      
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then iSecond = 0
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Else 
    ''Timer
    T0 = Text0.Text
    T1 = Text1.Text
    T2 = T0
    T3 = ("-Q")
    T4 = ("-KW") '00...52
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
  Endif
  
  sKey = ColumnViewCurrentKey() 'as String 
  If sKey Then
    ColumnView1[sKey][0] = T0
    ColumnView1[sKey][1] = T1
    ColumnView1[sKey][2] = T2
    ColumnView1[sKey][3] = T3
    ColumnView1[sKey][4] = T4
    ColumnView1[sKey][5] = T5
    If F_iMusterTermine1Names2Projects3 = 3 Then 
      If Not T8 Then T8 = ButtonSum.Tooltip
      If Not T9 Then T9 = ButtonDauer.Text
      ButtonSum.Tooltip = T8
      ButtonDauer.Text = T9
      ColumnView1[sKey][6] = T6
      ColumnView1[sKey][7] = T7
      ColumnView1[sKey][8] = T8
      ColumnView1[sKey][9] = T9
    Endif 
    ColumnView1[sKey].Picture = PicRefresh
    ColumnView1[sKey][F_iColumnSelect] = "PicRefresh"
    F_bListChanged = True
    F_iListChangedCounter = F_iListChangedCounter + 1
  Endif 
  
  If PanelBis.Visible = True Then '{{{{{{{{{{{{{...}}}}}}}}}}}}}
    sValue = Text0b.Text
    If sValue Like "*????-??-??*" Then
      hDate2 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
      iDiff = DateDiff(hDate1, hDate2, gb.day)
      T5 = Replace(String.Left(T5, 3), "{", "") & String.Mid(T5, 4) 'erst vorne Klammern entfernen
      T5 = Replace(String.Left(T5, 3), "}", "") & String.Mid(T5, 4)
      Try it = String.InStr(T5, "_", -Len(T5)) ' Ende mit mehreren "_" entfernen 
      If it > 0 Then T5 = String.Left(T5, it)
      sText = ""
      iCounter = 0
      iOnly1x = 0
      For it = 0 To iDiff
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        iCounter = iCounter + 1
        hDateNr = DateAdd(hDate1, gb.Day, it) 'gb.Day=Integer, it=Integer
        T0b = Format(hDateNr, "yyyy-mm-dd")
        T1b = T1
        T2b = Format(hDateNr, "ddd")
        T3b = Str(M01Functions.DateQuarterG(hDateNr)) & ("Q")
        T4b = Format(M01Functions.DateCalenderWeek(hDateNr), "00") & ("KW") '00...52
        T5b = String.Left(T5, 30) & "_"
        If it = 0 Then T5b = T5 & "_"  'Anfang mit ganzem Text & "_"
        If it = iDiff Then T5b = "}" & T5b
        If it = 0 Then T5b = "{" & T5b  '{}
        sLine = T0b & hTab & T1b & hTab & T2b & hTab & T3b & hTab & T4b & hTab & T5b & hReturn
        sText = sText & sLine ' —▶ append (kompletter Text für Datei, > anhängen)
        If it < 4 Or it = iDiff Then '1,2,3... + last line
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Else If it = 4 Then '1x...
          sMessageLines &= "<br><b>" & "..." & "</b><br>" 
        Else If it > iDiff - 4 Then 
          sMessageLines &= sHTMLa & iCounter & "." & sHTMLb & Space(2) & sLine 
        Endif
      Next
      sMessageLines &= "<hr>"  'Separator line (Trennlinie) ———————— 
      If iCounter = 1 Then
        sValue = ("Zeile")
      Else
        sValue = ("Zeilen")
      Endif
      sMessage = "<h3>" & sHTMLa & Format(hDate1, "yyyy-mm-dd ddd") & sSpace & sUntil & sSpace & Format(hDate2, "yyyy-mm-dd ddd") & sHTMLb & "</h3>"  
      sMessage &= sMessageLines & "<br>" 
      sMessage &= "<h3>" & "+" & Str(iCounter) & sSpace & sValue & "." & sSpace & sHTMLa & ("+Einfügen in die Liste") & "?" & sHTMLb & "</h3>"
      
      ProgressBarONoff(False) 
      Select Case Message.Question(sMessage, ("+Einfügen"), ("Abbrechen"))
        Case 1
          PanelBis.Visible = False
          F_sLinesCopy = sText 
          ColumnViewPaste() 
          F_bListChanged = True
        Case 2 ' Cancel
          '...
      End Select
      
    Endif 
  Endif 'PanelBis {{{{{{{{{{{{{{{{{{{{{{{{{{
  
  TextBackgroundAll(Color.White)
  ButtonSave.Background = Color.Red
  ButtonInput.Background = F_iColorGreen
  ColumnViewBackup()
  ColumnViewListChangeLED()
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonInputCheck() 'calculate Line new (Zeileneintrag neu berechnen)
  
  Dim T0, T5, T8, T9 As String 
  Dim iSecond, iT8, iHH, iMM As Integer
  Dim hDate0, hDate1, hDate2 As Date
  Dim sTime1, sTime2 As String
  Dim ssTime As String[]
  Dim sValue As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sValue = Text0.Text
  If sValue Like "*????-??-??*" Then
    hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    T0 = Format(hDate1, "yyyy-mm-dd")
    T5 = Text5.Text
    
    T5 = Replace(T5, hReturn, String.Chr(182)) ' Returnzeichen ¶ ersetzen
    T5 = Replace(T5, gb.NewLine, String.Chr(182))
    T5 = Replace(T5, hTab, Space(3))
    
    If T0 <> Text0.Text Then Text0Insert(T0)
    If T5 <> Text5.Text Then Text5Insert(T5)
    
    If F_iMusterTermine1Names2Projects3 = 3 Then
      T8 = ButtonSum.Tooltip
      If IsInteger(T8) = True Then iT8 = CInteger(T8)
      sTime1 = Text1.Text 
      sTime2 = Text2.Text
      If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
        hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
        
        ssTime = Split(sTime1 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        ssTime = Split(sTime2 & ":", ":")
        If ssTime Then 
          iHH = CInteger(ssTime[0])
          iMM = CInteger(ssTime[1])
        Endif 
        hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
        
        If iT8 > 0 Then hDate2 = DateAdd(hDate1, gb.Second, iT8) 'Seconds (genauer)—▶ 00:00:00
        
        iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
        T8 = Str(iSecond)
        If iSecond < 0 Then 
          iSecond = 0
          ColumnViewInfo(("Projekt-Zeit eingeben/korrigieren."))
        Else 
          ColumnViewInfo(("=neu berechnet"))
        Endif 
        T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
        If T9 <> ButtonDauer.Text Then ButtonDauer.Border = True
        ButtonSum.Tooltip = T8
        ButtonDauer.Text = T9
      Endif
    Endif 
  Endif
  
  ''_______________________________________________________________________________________''
  ''Gambas3: "CDate() Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektEin_Click()
  
  ProjectONoff(True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuProjektAus_Click()
  
  ProjectONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLineSelection()
  
  Dim bFound As Boolean
  Dim sKey, sK1, sT5, sPath As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicOff = ColumnViewImages("PicOFF").Picture 
  
  If Not F_sProjectOnlyName Then F_sProjectOnlyName = ProjectOnlyName()
  
  ' ColumnView1.UnselectAll()   
  ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey][0] <> "" Then
      ColumnView1[sKey].Picture = PicOff
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF"
      sT5 = String.LCase(ColumnView1[sKey][5])
      sT5 = Replace(sT5, gb.NewLine, "") 'no new line "\n" = Chr(10)
      sT5 = Replace(sT5, gb.Cr, "") 'no Return "\r" = Chr$(13)            gb.CrLF = Chr(13) & Chr(10)
      If sT5 = F_sProjectOnlyName Then
        ColumnView1[sKey].Picture = PicON
        ColumnView1[sKey][F_iColumnSelect] = "PicON"
        ColumnView1[sKey].EnsureVisible
        ColumnView1[sKey].Selected = True
        sK1 = sKey
        bFound = True
        Text0Insert(ColumnView1[sKey][0])
        Text1Insert(ColumnView1[sKey][1])
        Text5Insert(ColumnView1[sKey][5])
        ButtonProjectON.Picture = PicTemplateConnectON.Picture
      Endif
    Endif
  Next
  ' CheckBoxONoff.Value = bFound
  ' CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
  sPath = CheckProjectOnlyName(Text5.Text) 'Dir/File.txt < (F_sProjectOnlyName) 
  If Exist(sPath) = True Then
    TextBoxPath.Text = sPath
  Else
    TextBoxPath.Text = ("Ohne Datei")
  Endif
  If ColumnView1.Exist(sK1) = False Then sK1 = ColumnView1.Keys.Last
  If ColumnView1.Exist(sK1) = True Then 
    If ColumnView1[sK1][5] = F_sProjectOnlyName And bFound = True Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture 
    Else 
      ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    Endif 
    ColumnView1[sK1].EnsureVisible
    If ColumnView1[sK1][5] = "" Then 
      ButtonProjectON.Picture = PicTemplateConnectON.Picture
    Endif 
  Endif 
  
  ColumnViewInfo(("Aktivieren") & ": " & Space(1) & F_sProjectOnlyName)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectONoff(Optional bONoff As Boolean = False)
  
  Dim bFound As Boolean 
  Dim sKey, sK1, sT5 As String 
  Dim PicEmpty, PicON, PicOff As Picture
  Dim iLine As Integer
  
  If F_iMusterTermine1Names2Projects3 = 2 Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    PicON = ColumnViewImages("PicON").Picture 
    PicOff = ColumnViewImages("PicOFF").Picture 
    
    F_sProjectOnlyName = ProjectOnlyName()
    
    sK1 = ColumnViewCurrentKey()
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ColumnView1[sKey].Picture = PicOff 
      ColumnView1[sKey][F_iColumnSelect] = "PicOFF"
    Next 
    If sK1 And bONoff = True Then
      If ColumnView1[sK1][0] <> "" Then
        ColumnView1[sK1].Picture = PicON
        ColumnView1[sK1][F_iColumnSelect] = "PicON"
        ColumnView1[sK1].EnsureVisible
        ColumnView1[sK1].Selected = True
        'Check Name:
        sT5 = ColumnView1[sK1][5]
        sT5 = Replace(sT5, "/", "_") 'no Directory
        sT5 = Replace(sT5, Space(1), "_") 'no Space
        sT5 = Replace(sT5, gb.NewLine, "") 'no Return
        ColumnView1[sK1][5] = String.LCase(sT5)
        bFound = True
        Text0Insert(ColumnView1[sK1][0])
        Text1Insert(ColumnView1[sK1][1])
        Text5Insert(ColumnView1[sK1][5])
        F_sProjectOnlyName = ColumnView1[sK1][5]
        F_bListChanged = True
        ButtonSave.Background = Color.Red
        ColumnViewBackup()
        ColumnViewListChangeLED()
        WindowTitle()
        ButtonProjectON.Picture = PicTemplateConnectON.Picture 
      Endif
    Endif
    CheckBoxONoff.Value = bFound
    CheckBoxONoff.Text = ("Projekt Ein/Aus") & Space(3) & F_sProjectOnlyName
    If bFound = False Then ButtonProjectON.Picture = PicTemplateConnectOff.Picture 
    If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
    ColumnViewInfo(("Aktiviert") & ": " & Space(1) & F_sProjectOnlyName)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProjectLinesSaveRefresh()
  
  Dim sKey As String 
  Dim PicEmpty, PicON, PicAdd, PicSave As Picture
  Dim iLine As Integer
  
  PicEmpty = ColumnViewImages("PicEmpty").Picture 
  PicON = ColumnViewImages("PicON").Picture 
  PicAdd = ColumnViewImages("PicAdd").Picture 
  PicSave = ColumnViewImages("PicSave").Picture 
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView1[sKey].Picture = PicON Then F_sProjectOnlyName = ColumnView1[sKey][5]
    If ColumnView1[sKey].Picture <> PicAdd Then 
      ColumnView1[sKey].Picture = PicEmpty ' Bild entladen
      ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
    Endif 
    If ColumnView1[sKey][0] <> "" Then 
      ColumnView1[sKey].Picture = PicSave
      ColumnView1[sKey][F_iColumnSelect] = "PicSave"
    Endif 
  Next
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckProjectOnlyName(Optional sCheckProjectName As String = "") As String 
  
  Dim sDir, sTempPathTest As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirProject", FMain.F_sDirProject]
  If Not sCheckProjectName Then sCheckProjectName = String.LCase(Settings[FMain.Name &/ "F_sProjectOnlyName", FMain.F_sProjectOnlyName]) 'Einheitliche kleinschreibung
  
  ''Check
  sCheckProjectName = Replace(sCheckProjectName, "/", "_") 'no Directory
  sCheckProjectName = Replace(sCheckProjectName, Space(1), "_") 'no Space
  sCheckProjectName = Replace(sCheckProjectName, gb.NewLine, "") 'no Return
  sCheckProjectName = String.LCase(sCheckProjectName)
  
  ' sTempPathTest = M01Functions.FileTempDirFileTxt(sCheckProjectName)
  sTempPathTest = M01Functions.CheckDirectoryCache() &/ sCheckProjectName & ".txt"
  Try File.Save(sTempPathTest, "Test" & Now) 'temp-Files werden am Programm-Ende automatisch gelöscht.
  If Exist(sTempPathTest) = True Then 
    Text5Insert(sCheckProjectName)
    ButtonTest.Picture = PicTemplateBookA.Picture
    ButtonTest.Tooltip = ("Test. Als Datei-Name geeignet") & ": " & Space(1) & ("project_") & sCheckProjectName & ".txt"
    PanelText5.Background = F_iColorGreenAlpha150
  Else 
    ButtonTest.Picture = PicTemplateBookQuestion.Picture 'Picture["icon:/32/help"]
    ButtonTest.Tooltip = ("Test. Nicht als Datei-Name geeignet. Ungültige Zeichen?") & Space(1) & ("Eingabe") & ": " & ("Abc-z, 0-9")
    PanelText5.Background = F_iColorRedAlpha150
  Endif 
  ColumnViewInfo(ButtonTest.Tooltip)
  Return sDir &/ ("project_") & sCheckProjectName & ".txt"
  
Catch 
  FMain.ErrorText
  
End

Public Function ColumnViewCurrentKey() As String 
  
  Dim sKey As String 
  
  If ColumnView1.Selection.Max = -1 Then ListMenuGroupFunctions("addappend")
  If ColumnView1.Selection.Max > -1 Then sKey = ColumnView1.Selection.Last 'only Key (number)
  ButtonLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  Return sKey
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5_MouseDown()
  
  PanelText5.Background = Color.White
  F_iText5SearchPosition = Text5.Pos
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_KeyPress()
  
  DateChooser1.Tag = "0"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_Change()
  
  Dim hDate As Date
  
  hDate = M01Functions.DateCheckyyyymmddhhnn(Text0b.Text, "00:00") 'as Date
  If hDate Then
    Label3b.Text = Format(hDate, "dddd") 'as Date
    Label3b.Foreground = Color.Default
    Text0bBG.Background = F_iColorGreenAlpha150
  Else
    Label3b.Text = "?"
    Label3b.Foreground = Color.Red
    Text0bBG.Background = F_iColorRedAlpha150
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_KeyPress()
  
  DateChooser1.Tag = "0b"
  If M01Functions.KeyPressCheck("0123456789-", Key.Text, Key.Code) = True Then
    '...erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SelectHide0Date1Clock2Timer3(Optional iHide0_Date1_Clock2_Timer3_Clock4 As Integer = 0)
  
  Dim sValue As String
  Dim hDate As Date
  
  DateChooser1.Visible = False
  ColumnView1.Visible = True
  ColumnView2.Visible = False
  ColumnView3.Visible = False
  ScrollViewWeekDay.Visible = False
  ButtonDateCancel.Visible = False
  PanelSearchList.Visible = False
  
  Select Case iHide0_Date1_Clock2_Timer3_Clock4
    Case 0 'ohne
      ColumnView1.Visible = True
      If LabelTimerWT.Tag And Text0.Text <> LabelTimerWT.Tag Then Text0Insert(LabelTimerWT.Tag)
      LabelTimerWT.Tag = Null
    Case 1 'Datum
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView1.Left, ColumnView1.Top, ColumnView1.Width, ColumnView1.Height)
      If DateChooser1.Tag = "0" Then
        sValue = Text0.Text
      Else
        PanelBis.Visible = True
        sValue = Text0b.Text
        If sValue Like "????-??-??" Then
          '...Leerlauf
        Else
          sValue = Format(Date, "yyyy-mm-dd")
        Endif
      Endif
      
      If String.InStr(sValue, "-") = 0 Then
        '...Leerlauf
        hDate = Date
      Else
        If sValue Like "????-??-??" Then
          
          hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        Else
          hDate = Date
        Endif
      Endif
      DateChooser1.Mode = DateChooser1.DateOnly
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      ButtonDateCancel.Visible = True
    Case 2 ''Uhr
      If MoveLine.Top < F_iMoveLineMinH + MoveLine.H Then 'sichtbar und vermeiden Font-Size-Error
        MoveLine.Top = F_iMoveLineMaxH
        Form_Resize()
      Endif 
      DateChooser1.Move(ColumnView3.Left + ColumnView3.W, ColumnView1.Top, ColumnView1.Width - ColumnView3.W, ColumnView1.Height)
      DateChooser1.Mode = DateChooser1.DateTime 'TimeOnly
      If DateChooser1.Tag = "1" Then 
        If IsDate(Text1.Text) = True Then Try hDate = Time(CDate(Text1.text)) Else hDate = Time
      Else  
        If IsDate(Text2.Text) = True Then Try hDate = Time(CDate(Text2.text)) Else hDate = Time
      Endif 
      DateChooser1.Value = hDate
      DateChooser1.Raise 'oberste Ebene, Erhebung (raise), unterste Ebene (lower)
      ButtonDateCancel.Raise 
      DateChooser1.Visible = True
      
      ClockTimeList0to24h()
      ButtonDateCancel.Raise 
      ColumnView3.Raise 
      ColumnView3.Visible = True
      ButtonDateCancel.Visible = True
    Case 3 ''Timer
      ScrollViewWeekDay.Raise 
      ButtonDateCancel.Raise
      ScrollViewWeekDay.Visible = True
      If Text0.Text Not Like "????-??-??" Then TextBoxWT.Insert(Text0.Text)
      ButtonDateCancel.Visible = True
    Case 4 ''{Bis}
      If F_iMusterTermine1Names2Projects3 = 1 Then 
        If Text0b.Text Like "????-??-??" Then
          'Leerlauf
        Else
          Text0bInsert(Format(Date, "yyyy-mm-dd"))
        Endif
        PanelBis.Visible = True
        PanelBis.Raise
        ButtonBis.Background = Label7Bis.Background
        Text0b.Pos = String.Len(Text0b.Text)
        ' Text0b.SetFocus
      Endif 
    Case Else ''ohne
      ColumnView1.Visible = True
  End Select
  ButtonInput.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0Insert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0.Text <> sDatum Then 
    Text0.SelectAll()
    Text0.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0bInsert(Optional sDatum As String = "yyyy-mm-dd")
  
  If Text0b.Text <> sDatum Then 
    Text0b.SelectAll()
    Text0b.Insert(sDatum)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1Insert(Optional sTime As String = "hh:nn")
  
  If Text1.Text <> sTime Then 
    Text1.SelectAll()
    Text1.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2Insert(Optional sTime As String = "hh:nn")
  
  If Text2.Text <> sTime Then 
    Text2.SelectAll()
    Text2.Insert(sTime)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Insert(Optional sNotiz As String = ("Notiz"))
  
  Text5.Clear()
  Text5.SelectAll()
  Text5.Insert(sNotiz)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_Change() 'yyyy-mm-dd
  
  Dim sValue, sLine, Info As String
  Dim hDate As Date
  
  If Text0.Tag <> "" Then Goto Ende
  Text0BG.Background = Color.White
  If Text0.Text = "" Then Goto Ende
  If Text0.Text Like "????-??-??" Then                                                  ''Datum
    If Error Then Error.Clear()
    sValue = Text0.Text
    
    hDate = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
    If hDate = Null Then
      Text0BG.Background = F_iColorRedAlpha150
      ButtonWeekDay.Text = "?"
      ButtonWeekDay.Tooltip = ("Wochentag")
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Else
      ButtonWeekDay.Text = Format(hDate, "dddd") 'as Date
      ButtonWeekDay.Tooltip = Format(hDate, "dddd") 'as Date
      Text0BG.Background = Color.White
    Endif
  Else If String.InStr(sValue, "-") = 0 Then                                                     ''Timer
    sValue = String.LCase(Text0.Text)
    sLine = M01Functions.CheckTimerTextWeekdays0to6(sValue) 'as String, Check  Timer  SoMoDiMiDoFrSa
    If sLine <> "" Then
      Text0BG.Background = F_iColorGreenAlpha150
      Info = ("Timer") & ": " & sLine
    Else
      Info = ("Beispiel") & ": " & Format(Now, "yyyy-mm-dd")
    Endif
  Endif
  If Info Then ColumnViewInfo(Info)
Ende:
  F_bChangeON = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBackgroundAll(Optional iColor As Integer = Color.Transparent)
  
  Text0BG.Background = iColor
  Text0bBG.Background = iColor
  Text1BG.Background = iColor
  Text2BG.Background = iColor
  PanelText5.Background = iColor
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Data(dateValue As Date) ' dateValue frei gewählter Variablenname  gambas3
  
  If WeekDay(dateValue) = gb.Friday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Blue, 220) '&HC3DDFF
  Else If WeekDay(dateValue) = gb.Sunday Then 
    DateChooser1.Data.Background = Color.SetAlpha(Color.Yellow, 200)
  Endif 
  DateChooser1.Colors[Date] = Color.Green 'heute
  'Info:
  'DateChooser1.Mode = DateChooser1.DateOnly
  'DateChooser1.Colors.Clear()
  'DateChooser1.Data.Foreground = Color.Red
  'DateChooser1.Data.Font = Font["Italic"] 
  'DateChooser1.Colors["12/31/2000"] = Color.Green ' System, engl. 
  'DateChooser1.Mode = DateChooser1.DateTime 'Kalender- und Zeit-Tabelle, Heute + aktuelle Uhr
  
Catch 
  FMain.ErrorText
  
End ' DateChooser1_Data(dateValue As Date)

Public Sub TextNeuClear()
  
  Dim sMessage As String 
  
  sMessage = "<h3><font color=blue>" & "□" & Space(1) & TextNeu.Tooltip & "?" & "</font></h3>" 
  
  Select Message.Question(sMessage, "+" & ("Neue Zeile"), "□" & Space(1) & TextNeu.Tooltip, ("Abbrechen")) '(0,1,2,3)
    Case 1 'New Line
      NewLineG()
      
    Case 2 'New Input
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd")) 'Text0.Text
      Text1Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      ' Text5.SetFocus
      TextBackgroundAll(Color.White)
      
    Case 3 'Cancel
      '...Abbrechen
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text1.Tag <> "" Then Goto Ende
  Text1BG.Background = Color.White
  If Text1.Text Like "??:??" Then 
    Text1BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text1.Text, 1, 2)
    sMM = String.Mid(Text1.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text1BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text1BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text1.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_Change() ' 00:00
  
  Dim sHH, sMM, sInfo As String
  
  If Text2.Tag <> "" Then Goto Ende
  Text2BG.Background = Color.White
  If Text2.Text Like "??:??" Then 
    Text2BG.Background = F_iColorGreenAlpha150
    sHH = String.Mid(Text2.Text, 1, 2)
    sMM = String.Mid(Text2.Text, 4, 2)
    If Val(sHH) > 23 Or Val(sMM) > 59 Then
      Text2BG.Background = F_iColorRedAlpha150
      sInfo = "min. 00:00 > max. 23:59"
    Endif
    If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck()
  Else 
    Text2BG.Background = F_iColorRedAlpha150
    sInfo = ("Uhr-Muster") & ": " & Format(Now, "hh:nn")
  Endif
  If sInfo Then ColumnViewInfo(sInfo)
  
Ende:
  Text2.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewReload()
  
  If F_bListChanged = True Then
    ColumnView2.Visible = False 
    Select Message.Question("<h3><font color=red>" & ("Veränderte Liste") & "</font></h3>", ("Speichern + Neu laden"), ("Neu laden"), ("Abbrechen"))
      Case 1 'Save + Reload (Speichern + neu laden)
        SaveG()
        ReadG()
      Case 2 'Reload (Neu laden)
        ReadG()
      Case 3 'Cancel (Abbrechen)
        '...
    End Select
  Else
    ReadG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSucheG()
  
  If PanelSearchList.Visible = False Then
    PfeilEinfuegen.Visible = False 
    PanelSearchList.Raise() 'Top ▲Level▲ (oberste Ebene, Erhebung (raise), unterste Ebene (lower))
    PanelSearchList.Visible = True
    If ButtonSearchListOn.Background <> Color.Green Then 
      ColumnView2.Visible = False
    Else
      ColumnView2.Visible = True
    Endif
    If TextListSearch.Text = "" Then TextListSearch.Text = Format(Date, "yyyy-mm-")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
    TextListSearch.SetFocus
  Else
    PanelSearchList.Visible = False
    PfeilEinfuegen.Visible = True 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CancelSearchG()
  
  PanelSearchList.Visible = False
  SelectHide0Date1Clock2Timer3(0)
  PanelDatum.Visible = True 
  PfeilEinfuegen.Visible = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchMinusPlus(Optional sMinusPlus As String = "+")
  
  Dim sSearchText, sLine, sKey As String
  Dim it, iLine As Integer
  Dim iBefore As Integer
  Dim bFound As Boolean
  
  If ColumnView2.Visible = True Then 
    SearchListG()
    If sMinusPlus = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnselectAll()
    Goto Ende
  Endif
  
  If String.InStr(TextListSearch.Text, gb.NewLine) > 0 Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, "")
    TextListSearch.Pos = String.Len(TextListSearch.Text)
  Endif
  sSearchText = String.LCase(TextListSearch.Text)
  sSearchText = Replace(sSearchText, Space(1), "*") ' Leerzeichen ersetzen für beliebige Zeichen bei Suche
  sSearchText = "*" & sSearchText & "*"
  iBefore = F_iSearchPosition
  
  If sMinusPlus = "+" Then '+++++++++++++++++++++++++++++
    F_iSearchPosition = F_iSearchPosition + 1
    If F_iSearchPosition > ColumnView1.Count - 1 Then F_iSearchPosition = ColumnView1.Count - 1
    For it = F_iSearchPosition To ColumnView1.Count - 1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Else '-------------------------------------------------
    F_iSearchPosition = F_iSearchPosition - 1
    If F_iSearchPosition < 0 Then F_iSearchPosition = 0
    For it = F_iSearchPosition To 0 Step -1
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      sLine = String.LCase(ColumnView1[it][0] & ColumnView1[it][1] & ColumnView1[it][2] & ColumnView1[it][3] & ColumnView1[it][4] & ColumnView1[it][5])
      If sLine Like sSearchText Then
        ColumnView1[it].Selected = True
        ColumnView1[it].EnsureVisible
        F_iSearchPosition = it
        bFound = True
        Goto Ende
      Endif
    Next
  Endif
  
  If bFound = True
    ButtonSearchDown.Background = Color.Default
    ButtonSearchUp.Background = Color.Default
  Else
    F_iSearchPosition = iBefore
    If sMinusPlus = "-" Then
      ButtonSearchDown.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
    If sMinusPlus = "+" Then
      ButtonSearchUp.Background = TextListSearch.Background
      ButtonSearchUp.Background = Color.Default
    Endif
  Endif ' bFound
Ende:
  
  If ColumnView1.Selection.Max > -1 Then sKey = (Val(ColumnView1.Current.Key) + 1) Else sKey = "?" 
  LabelSearchLineNr.Text = "–▷ " & ("Zeile") & Space(1) & sKey
  LabelSearchLineNr.ToolTip = LabelSearchLineNr.Text
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelSearchLineNr_MouseDown()
  
  TextListSearch.Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextListSearch_KeyPress()
  
  If Key.Code = Key.Return Then
    TextListSearch.Text = Replace(TextListSearch.Text, gb.NewLine, String.Chr(182)) '¶
    Timer3KeyPress.Start 'ButtonSearchG() not in Loop _KeyPress
    Stop Event 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonSearchG()
  'SearchMinusPlus("+")
  
  ColumnViewFind("+")
  If Timer3KeyPress.Enabled = False Then SearchListG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchListG()
  
  If ButtonSearchListOn.Background <> Color.Green Then 
    ColumnView2.Visible = False
    ColumnView1.Visible = True
    ColumnView2select1() 'ColumnView2 —▶ ColumnView1
  Else 
    SearchPanelList()
    ColumnView2.Raise
    ColumnView2.Visible = True
    ColumnView1.Visible = False
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelList()
  
  Dim it, iColumn, iLine As Integer
  Dim sK1, sSearchText, sLine As String
  Dim PicFind As Picture
  
  PicFind = ColumnViewImages("PicFind").Picture 
  sSearchText = "*" & Replace(TextListSearch.Text, Space(1), "*") & "*"
  ColumnView2.Clear()
  ColumnView2.Header = True  ' Sichtbar
  'Create Columns (Spalten erzeugen):
  If ColumnView2.Columns.Count <> ColumnView1.Columns.Count Then ColumnView2.Columns.Count = ColumnView1.Columns.Count '+ 1
  For it = 0 To ColumnView1.Columns.Count - 1 'Header/Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
    ColumnView2.Columns[it].Text = ColumnView1.Columns[it].Text
    ColumnView2.Columns[it].Alignment = ColumnView1.Columns[it].Alignment
  Next
  For Each sK1 In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    sLine = String.LCase(Str(ColumnView1[sK1][0] & ColumnView1[sK1][1] & ColumnView1[sK1][2] & ColumnView1[sK1][3] & ColumnView1[sK1][4] & ColumnView1[sK1][5] & ColumnView1[sK1][F_iColumnSelect]))
    If sLine Like sSearchText Then 
      ColumnView2.Add(sK1, "", PicFind)
      ColumnView2[sK1][F_iColumnSelect] = "PicFind"
      For iColumn = 0 To ColumnView1.Columns.Count - 1
        ColumnView2[sK1][iColumn] = ColumnView1[sK1][iColumn]
      Next
    Endif
  Next
  ColumnView2.Columns[5].Title = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")   '"  [Strg+Maus]")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_Click()
  
  Dim sKey As String 
  
  sKey = Val(ColumnView2.Current.Key) + 1
  LabelSearchLineNr.Text = ("Zeile") & Space(1) & Str(sKey)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2select1()                                                               'ColumnView2 —▶ ColumnView1
  
  Dim sK2 As String 
  Dim iLine As Integer
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    ColumnView1.Mode = Select.Multiple
    For Each sK2 In ColumnView2.Selection 'Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].Selected = True
    Next
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1Resize()
  
  Dim sInfo, sSizeAll As String
  Dim it As Integer
  
  sSizeAll = Space(1) & "=" & Space(1) & File.FormatSize(F_longFilesRead, False) 'as String   
  
  If ColumnView1.Count < 2 Then 
    sInfo = Space(2) & ("Leer. Datei öffnen oder +Einfügen") 
  Else 
    If F_iMusterTermine1Names2Projects3 > 1 Then sInfo = Space(3) & ("Projekt-Name") 
    sInfo = ("Notiz") & sInfo & Space(2) & ("Zeilen") & ": " & ColumnView1.Count & sSizeAll
  Endif 
  ColumnView1.Columns.Count = F_iColumnsCount                                             'Columns:|0|1|2|3|...|max|
  ColumnView1.Header = True                                                               'Title, Row index=0
  ColumnView1.Mode = Select.Multiple
  ColumnView1.AutoResize = False                       'last column in last row  |abc| => |abcdef>>| 
  ''**********************************
  ''Here not activate:
  ' ColumnView1.Sorted = True 
  ' ColumnView1.Columns.Ascending = True  '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ''**********************************
  ColumnView1.Resizable = True                                                            'Header <|> <|> Resize with Mouse
  ColumnView1.Columns[0].Alignment = Align.Right                                          '|  123|
  ColumnView1.Columns[2].Alignment = Align.Center                                         '| abc |
  ColumnView1.Columns[6].Alignment = Align.Left                                           '|123  |
  
  ColumnView1.Columns[0].Title = "▲▽" & Space(6) & ("Datum") & Space(2)
  ColumnView1.Columns[1].Title = ("Uhr")     '00:00 Begin
  ColumnView1.Columns[2].Title = Space(1)    'Su Weekday (Wochentag) 
  ColumnView1.Columns[3].Title = Space(1)    '0Q Quater (Quartal)
  ColumnView1.Columns[4].Title = Space(1)    '0CW CalenderWeek (KalenderWoche)
  ColumnView1.Columns[5].Title = sInfo       'Notice (Notiz)
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Title = ""          'Nr
    ColumnView1.Columns[7].Title = ""          'Undo
    ColumnView1.Columns[8].Title = ""          'Select01
    ColumnView1.Columns[9].Title = ""          'Sort
  Else 
    ColumnView1.Columns[6].Title = ("Uhr")     '00:00 End
    ColumnView1.Columns[7].Title = ""          'Su Weekday (Wochentag)
    ColumnView1.Columns[8].Title = ""          'Seconds 123 (Sekunden)
    ColumnView1.Columns[9].Title = ("Dauer")   '00:00:00 Duration  
  Endif 
  
  ColumnView1.Columns[0].Width = 200
  ColumnView1.Columns[1].Width = 80
  ColumnView1.Columns[2].Width = 50
  ColumnView1.Columns[3].Width = 50
  ColumnView1.Columns[4].Width = 80
  ColumnView1.Columns[5].Width = 0           'Notice
  
  If F_iMusterTermine1Names2Projects3 < 3 Then 
    ColumnView1.Columns[6].Width = 0
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 0  
  Else 
    ColumnView1.Columns[6].Width = 70          '00:00 End
    ColumnView1.Columns[7].Width = 0 
    ColumnView1.Columns[8].Width = 0
    ColumnView1.Columns[9].Width = 120         '00:00:00 Duration  
  Endif 
  
  For it = 10 To ColumnView1.Columns.Max     '>9 or >13
    ColumnView1.Columns[it].Title = ""         'ColumnsUndo
    ColumnView1.Columns[it].Width = 0          'ColumnsUndo
  Next 
  '.AutoResize width = longest filename
  ColumnView1.Columns[5].Width = ColumnView1.ClientWidth - ColumnView1.Columns[F_iColumnUndo].Left 
  
  If ColumnView2.Visible = True Then ColumnView2Resize() 
  ColumnViewAscending()
  
  'Muster Termine: 
  '0          1     2  3 4  5       6     7     8         9                                  F_iColumnsCount=10
  '0000-00-00 00:00 WD Q CW Notice  Nr    Undo  Select01  Sort
  
  'Muster Projects: 
  '0          1     2  3 4  5       6     7     8         9        10   11       12   13     F_iColumnsCount=14
  '0000-00-00 00:00 WD Q CW Notice  00:00 WD    Seconds   00:00:00 Undo Select01 Sort Nr
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  IconError.Raise()
  
End

Public Sub ColumnView2Resize()                                                            'ColumnView2 = ColumnView1
  
  Dim sInfo As String
  Dim it As Integer
  
  sInfo = Str(ColumnView2.Count) & Space(1) & ("Zeilen gefunden")
  ColumnView2.Columns.Count = ColumnView1.Columns.Count                                   'Columns:|0|1|2|3|...|max|
  ColumnView2.Header = ColumnView1.Header                                                 'Title, Row index=0
  ColumnView2.Mode = ColumnView1.Mode
  ColumnView2.AutoResize = ColumnView1.AutoResize 'last column in last row  |abc| => |abcdef>>| 
  ColumnView2.Sorted = ColumnView1.Sorted
  ColumnView2.Resizable = ColumnView1.Resizable                                           'Header <|> <|> Resize with Mouse
  ColumnView2.Columns.Ascending = ColumnView1.Columns.Ascending     '"▲▽" sort 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  ColumnView2.Columns[0].Alignment = ColumnView1.Columns[0].Alignment                     '|  123|
  ColumnView2.Columns[2].Alignment = ColumnView1.Columns[2].Alignment                     '| abc |
  ColumnView2.Columns[6].Alignment = ColumnView1.Columns[6].Alignment                     '|  123|
  
  For it = 0 To ColumnView1.Columns.Max
    ColumnView2.Columns[it].Title = ColumnView1.Columns[it].Title
    ColumnView2.Columns[it].Width = ColumnView1.Columns[it].Width
  Next
  ColumnView2.Columns[5].Width = 0
  ColumnView2.Columns[5].Width = ColumnView2.ClientWidth - ColumnView2.Columns[F_iColumnUndo].Left
  ColumnView2.Columns[5].Title = sInfo
  '.AutoResize width = longest text in Column in last row
  
Catch 
  FMain.ErrorText
  IconError.Visible = True
  
End

Public Sub ColumnView2_MouseUp()
  
  If Mouse.Left Then ColumnViewClick()
  If Mouse.Right Then mnuMaus2.popup '> Eigenschaften PopupMenu = mnMaus2
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView2_KeyPress()
  
  If Key.Code = Key.Delete Then ListMenuGroupFunctions(ListCut.Tag) '"cut"
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckBox1G() '*every Year, Birthsdays (*jedes Jahr, Geburtstage)
  
  Select Case CheckBox1.Value
    Case True
      If String.Left(Text5.Text, 1) <> "*" Then Text5Insert("*" & Text5.Text) 'with (mit)
    Case False
      If String.Left(Text5.Text, 1) = "*" Then Text5Insert(String.Mid(Text5.Text, 2)) 'without (ohne)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5JedesJahrpruefen()
  
  If String.Left(Text5.Text, 1) = "*" Then
    CheckBox1.Value = True
  Else
    CheckBox1.Value = False
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0_MouseUp()
  
  DateChooser1.Tag = "0"
  If DateChooser1.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(1)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text0b_MouseUp()
  
  DateChooser1.Tag = "0b"
  SelectHide0Date1Clock2Timer3(1)
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Change()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then
    Text0Insert(sYYYYMMDD)
  Else If DateChooser1.Tag = "0b"
    Text0bInsert(sYYYYMMDD) 'gambas3
  Else If DateChooser1.Tag = "1"
    If Text0.Text Like "????-??-??" Then 
      If Text0.Text <> sYYYYMMDD Then Text0Insert(sYYYYMMDD)
    Endif 
    Text1Insert(sHHNN)
  Else If DateChooser1.Tag = "2"
    Text2Insert(sHHNN)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub DateChooser1_Click()
  
  Dim sYYYYMMDD, sHHNN As String 
  
  sYYYYMMDD = Format(DateChooser1.Value, "yyyy-mm-dd")
  sHHNN = Format(DateChooser1.Value, "hh:nn")
  
  If DateChooser1.Tag = "0" Then Text0Insert(sYYYYMMDD)
  If DateChooser1.Tag = "0b" Then Text0bInsert(sYYYYMMDD)
  If DateChooser1.Tag = "1" Then Text1Insert(sHHNN) '00:00 A
  If DateChooser1.Tag = "2" Then Text2Insert(sHHNN) '00:00 B
  If ColumnView3.Visible = True Then ColumnView3Select(sHHNN)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_MouseUp()
  
  DateChooser1.Tag = "1"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_MouseUp()
  
  DateChooser1.Tag = "2"
  If ColumnView3.Visible = True Then
    SelectHide0Date1Clock2Timer3(0)
  Else
    SelectHide0Date1Clock2Timer3(2)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClockTimeList0to24h()
  
  Dim iHH, iMM, iCounter, iSelect As Integer
  Dim sValue As String
  
  ColumnView3.Clear()
  ColumnView3.Header = False 'without Title (ohne Titel)
  ColumnView3.Sorted = False 'no sort (nicht sortieren!)
  ColumnView3.Columns.Count = 1 'Number Columns (Anzahl Spalten)
  ColumnView3.Columns[0].Width = ColumnView3.Width
  For iHH = 0 To 23 'Hours (Stunden) hh:
    For iMM = 0 To 59 'Minutes (Minuten) :nn
      sValue = Format(iHH, "00") & ":" & Format(iMM, "00")
      iCounter = ColumnView3.Count + 1
      ColumnView3.Add(iCounter, sValue)
      If iMM Mod 10 = 0 Then ''00:00, 00:15, 00:30, ...
        ColumnView3[iCounter].Foreground = Color.Default 
      Else 
        ColumnView3[iCounter].Foreground = Color.LightGray  
      Endif 
      If iMM Mod 30 = 0 Then ''00:00, 00:30, 01:00, ... 
        ColumnView3[iCounter].Background = Color.LightGray 
      Endif 
      If Text1.Text = ColumnView3[iCounter].Text Then
        iSelect = iCounter
      Endif
    Next
  Next
  sValue = "00:00"
  iCounter = ColumnView3.Count + 1
  ColumnView3.Add(iCounter, sValue)
  ColumnView3[iSelect].Selected = True
  ColumnView3[iSelect].EnsureVisible
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3Select(Optional sClock As String = "00:00")
  
  Dim sKey, sFound As String 
  
  If ColumnView3.Keys Then 
    ColumnView3.UnSelectAll()
    For Each sKey In ColumnView3.Keys
      If ColumnView3[sKey].Text = sClock Then 
        ColumnView3[sKey].Selected = True
        sFound = sKey  
        Break
      Endif 
    Next 
    If ColumnView3.Exist(sFound) = True Then 
      ColumnView3[sFound].Selected = True
      ColumnView3[sFound].EnsureVisible()
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_Click()
  
  If DateChooser1.Tag = "1" Then Text1Insert(ColumnView3[ColumnView3.Current.key][0])
  If DateChooser1.Tag = "2" Then Text2Insert(ColumnView3[ColumnView3.Current.key][0])
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3_MouseUp()
  
  Dim dDate, dTime As Date 
  
  If ColumnView3.Current.Text Then 
    dDate = DateChooser1.Value 'as Date
    dTime = CDate(ColumnView3.Current.Text) '00:00 (*1)
    F_dateNow = Date(Year(dDate), Month(dDate), Day(dDate), Hour(dTime), Minute(dTime), Second(dTime)) 'as Date 
    DateChooser1.Value = F_dateNow
    If DateChooser1.Tag = "1" Then Text1Insert(Format(F_dateNow, "hh:nn"))
    If DateChooser1.Tag = "2" Then Text2Insert(Format(F_dateNow, "hh:nn"))
  Endif 
  
  ''______________________________________________________________________________________________''
  '(*1) Gambas3: "CDate(): Vorsicht! Diese Funktion nutzt nicht die eingestellte Lokalisierung."
  'Hier nur bei hh:nn
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text1_KeyPress()
  
  DateChooser1.Tag = "1"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text2_KeyPress()
  
  DateChooser1.Tag = "2"
  If M01Functions.KeyPressCheck("0123456789:", Key.Text, Key.Code) = True Then
    ' erlauben
  Else
    Stop Event 'Vorgang abbrechen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeichensatz2_Click()
  
  M06InfoText.CharsetABCInfo()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuBearbeiten_Show() 'Edit
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatei_Show() 'File
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahl_Show() 'Select
  
  MenuShow()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SearchPanelG()
  
  If PanelSearchList.Visible = False Then
    ButtonSucheG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Click()
  
  Dim sLine As String
  
  If ToggleButtonW1.Value = True Then sLine = sLine & ToggleButtonW1.Text & gb.Sunday '0
  If ToggleButtonW2.Value = True Then sLine = sLine & ToggleButtonW2.Text & gb.Monday '1
  If ToggleButtonW3.Value = True Then sLine = sLine & ToggleButtonW3.Text & gb.Tuesday '2
  If ToggleButtonW4.Value = True Then sLine = sLine & ToggleButtonW4.Text & gb.Wednesday '3
  If ToggleButtonW5.Value = True Then sLine = sLine & ToggleButtonW5.Text & gb.Thursday '4
  If ToggleButtonW6.Value = True Then sLine = sLine & ToggleButtonW6.Text & gb.Friday '5
  If ToggleButtonW7.Value = True Then sLine = sLine & ToggleButtonW7.Text & gb.Saturday '6
  TextBoxWT.Text = sLine
  Text0Insert(sLine)
  LabelTimerWT.Tag = ""
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Enter()
  
  Last.Border = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SoSa_Leave()
  
  Last.Border = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelTimerG()
  
  If ScrollViewWeekDay.Visible = False Then
    SelectHide0Date1Clock2Timer3(3)
  Else
    SelectHide0Date1Clock2Timer3(0)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ApplyWT_Click()
  
  Text0Insert(TextBoxWT.Text)
  LabelTimerWT.Tag = TextBoxWT.Text
  SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowT5plusG()
  
  Form3Text.Tag = Text5.Text
  FMain.F_bZeilenumbruchON = False
  Form3Text.Tooltip = "" 'Path
  Form3Text.Tag = Text5.Text
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFehlzeilen1_Click()
  
  Form3Text.Tag = F_sUnknownLinesText
  Form3Text.Tooltip = "" 'Path
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub AuswahlDatumUhrTimerGroup_Click() 'Gruppe
  
  SelectHide0Date1Clock2Timer3(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoreButtonsG()
  
  If F_bMoreButtons = True Then
    F_bMoreButtons = False
    SelectHide0Date1Clock2Timer3(0)
  Else
    F_bMoreButtons = True
  Endif
  MoreButtons(F_bMoreButtons)
  
Catch 
  FMain.ErrorText
  
End

Public Sub NewLineG()
  
  ColumnView1.UnselectAll()
  ListMenuGroupFunctions("addappend")
  Text5.Pos = String.Len(Text5.Text)
  ' Text5.SetFocus
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxWT_Change()
  
  If TextBoxWT.Text = "" Then
    ApplyWT.Background = Color.ButtonBackground
  Else
    ApplyWT.Background = Color.SelectedBackground
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewOrig()
  
  Dim it, iLine As Integer
  Dim sOrigText As String 
  Dim PicEmpty As Picture
  Dim sKey, sLine As String 
  Dim hTab As String 
  
  ''ColumnView1
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView1[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView1[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView1[sKey].Picture = PicEmpty
          ColumnView1[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then
      hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
      PicEmpty = ColumnViewImages("PicEmpty").Picture 
      For Each sKey In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sOrigText = ColumnView2[sKey][F_iColumnUndo] 
        If sOrigText Then
          it = 0
          For Each sLine In Split(sOrigText, hTab)
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ColumnView2[sKey][it] = sLine
            it = it + 1
            If it > F_iColumnsReadMax Then Break 
          Next
          ColumnView2[sKey].Picture = PicEmpty
          ColumnView2[sKey][F_iColumnSelect] = "PicEmpty"
        Endif
      Next 
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseDown()
  
  F_bMovingON = True
  F_iY1 = Mouse.Y
  MoveLine.Raise
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseMove()
  
  If F_bMovingON = True Then
    MoveLine.Top = MoveLine.Top + Mouse.Y - F_iY1 
    If MoveLine.Top < F_iMoveLineMinH Then MoveLine.Top = F_iMoveLineMinH 'Top▲ (Obergrenze)
    If MoveLine.Top > F_iMoveLineMaxH Then MoveLine.Top = F_iMoveLineMaxH 'Bottom▼ (Untergrenze)
    Form_Resize()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveLine_MouseUp()
  
  Dim sKey As String
  
  F_bMovingON = False
  sKey = ColumnViewCurrentKey()
  If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuMehrSchalter_Click()
  
  MoreButtonsG()
  
End

Public Sub mnuInfo_Click()
  
  Dim sMessage As String 
  
  sMessage = "(c) www.design-cad.de" & "<br><br>"
  'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub Text5_KeyPress()
  
  PanelText5.Background = Color.White
  ButtonInput.Background = Color.Default
  If F_iMusterTermine1Names2Projects3 > 1 Then 
    If InStr(Text5.Text, String.Chr(47)) > 0 Then 'stop sign "/"=chr(47) /Directory/File.xy
      ButtonTest.Picture = PicTemplateBookQuestion.Picture
      PanelText5.Background = F_iColorRedAlpha150
    Endif 
  Endif 
  
  F_bKeyboardInput = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSortAZ_Click()
  
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    ColumnView1.Sorted = True 
    ColumnView1.Columns.Sort = 0 'Datum sortieren
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFensterplus_Click()
  
  WindowT5plusG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuJedesJahr_Click()
  
  CheckBox1.Value = Not CheckBox1.Value
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSchliessen_Click()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExportSelectionG()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuexportselection_Click()
  
  If PanelSearchList.Visible = False Then
    TextListSearch.Text = Format(Now, "yyyy") & "-"
    ButtonSucheG()
    ButtonSearchListOn.Background = Color.Default
    SearchListG()
  Else
    CancelSearchG()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveSelectionG()
  
  Dim sFileBefore, sFileBehind, sDir, sPath, sDirFile, sExistFiles As String 
  Dim sK2, sLine, sText, sExistLines, sSpace, sMessage As String
  Dim iColumn, iLine As Integer
  Dim hDate As Date
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  sSpace = Space(1)
  sPath = FilePathForm()
  sDir = File.Dir(sPath)

  For Each sK2 In ColumnView2.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak() = True Then Break
    Endif 
    
    If ColumnView2[sK2].Selected = True Then
      If ColumnView2[sK2][0] <> "" Then
        sLine = ""
        For iColumn = 0 To 5
          If iColumn < 5 Then
            sLine = sLine & ColumnView2[sK2][iColumn] & hTab
          Else
            sLine = sLine & ColumnView2[sK2][iColumn] & hReturn
            Break
          Endif
        Next
        If String.InStr(sExistLines, sLine) > 0 Then 'no double Lines (ohne doppelte Zeilen)
          '...Leerlauf
        Else
          sExistLines = sExistLines & gb.Tab & sLine & gb.Tab
          sText = sText & sLine
        Endif
      Endif
    Endif
  Next
  
  If sText = "" Then
    Message.Info(("Auswahl") & " = 0", ("Abbrechen"))
    Goto Ende
  Endif
  ColumnView2.Columns[5].Text = ("markierte Zeilen") & sSpace & ColumnView2.Selection.Count & sSpace & ("von") & sSpace & ColumnView2.Count
  sDirFile = sDir &/ "export_" & Format(Now, "yyyy") & Application.Name & ".txt" ' kleine y
  
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  Dialog.Filter = ["*.txt", ("Nur-Text")]
  Dialog.Path = sDirFile
  Dialog.AutoExt = True
  Dialog.Title = ("Datei speichern...")
  'If Dialog.SaveFile() Then Return 'Kurzform
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
    'Goto Ende
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  sDirFile = Dialog.Path
  
  If Exist(sDirFile) = True Then
    hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
    sFileBefore = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
  Endif
  sExistFiles = M01Functions.FileExistQuestionText(sDirFile)
  If sExistFiles <> "" Then sExistFiles = sExistFiles & hReturn & hReturn
  sMessage = ("(Tipp: Mit einem Textprogramm den Zeichensatz verändern)") & "<br>" & "<br>"
  sMessage &= sExistFiles & sDirFile & "<br>"
  
  Select Message.Question(sMessage, ("Speichern"), ("Abbrechen"))
    Case 1 'Speichern
      'File.Save(sDirFile, sText)
      M01Functions.FileTextPlus(sDirFile, sText, True) ' TRUE=overwrite (überschreiben)
      If Exist(sDirFile) = True Then
        hDate = M01Functions.FileLastModifiedDate(sDirFile) 'as Date
        sFileBehind = sDirFile & Space(1) & Format(hDate, "yyyy-mm-dd hh:nn:ss:uu")
      Endif
      If sFileBefore = sFileBehind Then
        Message.Warning(sFileBehind & "<br>" & "<br>" & ("Nicht erfolgreich gespeichert?"))
      Endif
    Case 2 'Abbrechen
      'Leerlauf
  End Select
  'DialogDDDDDDDDDDDDDDDDDDDDDDDD
  
  ''Show File-Data:
  Form3Text.Tag = sDirFile
  Form3Text.Tooltip = sDirFile
  Form3Text.Window.Show
  ' Form3Text.Window.Visible = True  'Wayland error?
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCompare(Optional bExact As Boolean = False)
  
  Dim iLine, iFoundLines, iCheck As Integer
  Dim sExists, T0, T1, T5 As String
  Dim sKey, sLeft, sMid, sRight, sKeyFirstQuestion, sSeparator As String
  Dim PicHome, PicQuestion As Picture
  
  PicHome = ColumnViewImages("PicHome").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture
  ' PicQuestion = Picture["icon:/22/question"] 'in icon ohne Endung .png
  
  sSeparator = Settings[FMain.Name &/ "hTab", gb.Tab]
  F_bESCpressedON = False
  
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Count > 1 Then '1 > only Header (Title)
    
    For Each sKey In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      iCheck = 0 'Reset
      
      T0 = ColumnView1[sKey][0] 'yyyy-mm-dd
      T1 = ColumnView1[sKey][1] '00:00
      T5 = String.LCase(ColumnView1[sKey][5]) 'Notiz
      ' T6 = ColumnView1[sKey][6] '00:00
      ' T8 = ColumnView1[sKey][8] 'Sek.
      ' T9 = ColumnView1[sKey][9] '00:00:00 Dauer
      
      If bExact = True Then
        If String.InStr(sExists, T0 & T1 & T5) > 0 Then iCheck = 10 'faster
        ' If sExists Like "*" & T5 & "*" Then iCheck = 10
      Else 
        sLeft = String.Left(T5, 5)                                                                'linker Teil Notizen
        If String.Len(T5) > 20 Then
          sMid = String.Mid(T5, String.Len(T5) / 2, 10)                                           'mittiger Teil Notizen
        Else
          sMid = ""
        Endif 
        sRight = String.Right(T5, 5)                                                              'rechter Teil Notizen
        If String.InStr(sExists, sLeft) > 0 Then iCheck = iCheck + 1
        If sMid <> "" Then
          If String.InStr(sExists, sMid) > 0 Then iCheck = iCheck + 1
        Endif
        If String.InStr(sExists, sRight) > 0 Then iCheck = iCheck + 1
      Endif 'bExact
      
      If iCheck > 1 Then
        ColumnView1[sKey].Picture = PicQuestion '"?"
        ColumnView1[sKey][F_iColumnSelect] = "PicQuestion"
        iFoundLines = iFoundLines + 1
        ColumnView1[sKey][F_iColumnSort] = Replace(String.Left(T5, 10), "*", "Z") & Str(iFoundLines)
      Else
        ColumnView1[sKey].Picture = PicHome 'Bild
        ColumnView1[sKey][F_iColumnSelect] = "PicHome"
        ColumnView1[sKey][F_iColumnSort] = iLine 
        sKeyFirstQuestion = sKey
      Endif
      sExists &= T0 & T1 & T5 & gb.NewLine
      ' sExists = sExists & sLine & T0 & T1 & T5 & T6 & T8 & T9 & gb.NewLine  ' 0-1-2-3...
    Next
    If bExact = True Then
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen genauer") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine
    Else 
      ColumnView1.Columns[5].Title = ("Ähnliche Zeilen") & ": " & iFoundLines & Space(1) & ("von") & Space(1) & iLine 
    Endif 
    ColumnViewInfo(ColumnView1.Columns[5].Title)
    ColumnViewSort(F_iColumnSort) 
    If ColumnView1.Exist(sKeyFirstQuestion) = True Then 
      ColumnView1.UnSelectAll()
      ColumnView1[sKeyFirstQuestion].Selected = True 
      ColumnView1[sKeyFirstQuestion].EnsureVisible
    Else 
      ColumnView1[ColumnView1.Count].Selected = True 
      ColumnView1[ColumnView1.Count].EnsureVisible  
    Endif 
  Endif 
  ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewDouble() '= ● ●
  
  Dim sKey, sLine As String
  Dim it, iLine, iFound, iFoundLines As Integer
  Dim PicDouble, PicHome As Picture
  Dim ssExist As String[]
  Dim hTab, hReturn As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView1.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView1.Mode = Select.Multiple 
      ColumnView1.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView1[sKey].Picture = PicDouble
          ColumnView1[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView1[sKey][F_iColumnSort] = ColumnView1.Count + iLine
          ColumnView1[sKey].Selected = True
          ColumnView1[sKey].EnsureVisible
        Else
          ColumnView1[sKey].Picture = PicHome
          ColumnView1[sKey][F_iColumnSelect] = "PicHome"
          ColumnView1[sKey][F_iColumnSort] = iLine
          ColumnView1[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Else ''ColumnView2:
    hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
    hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
    F_bESCpressedON = False
    
    If ColumnView2.Columns.Count > F_iColumnSort Then
      PicDouble = ColumnViewImages("PicDouble").Picture 
      PicHome = ColumnViewImages("PicHome").Picture 
      ColumnView2.Mode = Select.Multiple 
      ColumnView2.UnSelectAll()
      ssExist = New String[]
      
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = Null
        For it = 0 To F_iColumnsReadMax
          If it < F_iColumnsReadMax Then 
            sLine &= ColumnView1[sKey][it] & hTab
          Else 
            sLine &= ColumnView1[sKey][it] & hReturn 'even empty Lines (auch leere Zeilen)
          Endif 
        Next
        iFound = ssExist.Find(sLine, gb.String) 'as Integer  -1 not found
        If iFound > -1 Then 
          iFoundLines = iFoundLines + 1
          ColumnView2[sKey].Picture = PicDouble
          ColumnView2[sKey][F_iColumnSelect] = "PicDouble"
          ColumnView2[sKey][F_iColumnSort] = ColumnView2.Count + iLine
          ColumnView2[sKey].Selected = True
          ColumnView2[sKey].EnsureVisible
        Else
          ColumnView2[sKey].Picture = PicHome
          ColumnView2[sKey][F_iColumnSelect] = "PicHome"
          ColumnView2[sKey][F_iColumnSort] = iLine
          ColumnView2[sKey].Selected = False
        Endif
        ssExist.Add(sLine)
      Next 
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo(("Doppelte Zeilen") & ": " & Str(iFoundLines) & Space(1) & ("von") & Space(1) & Str(iLine))
    Endif 
  Endif 
  If ProgressBar1.Visible = True Then ProgressBarONoff(False)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCorrectLines()
  
  Dim iLine, iDay, iColumn, iCorrectedLines, iUnknown As Integer
  Dim T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 As String 
  Dim sK1, sTimerDays, sLine As String
  Dim hDate0, hDate1, hDate2 As Date
  Dim iSecond, iHH, iMM As Integer
  Dim sTime1, sTime2 As String
  Dim sValue As String
  Dim ssWeekdays, ssTime As String[]  
  Dim PicRefresh, PicOK, PicQuestion As Picture
  
  PicRefresh = ColumnViewImages("PicRefresh").Picture 
  PicOK = ColumnViewImages("PicOK").Picture 
  PicQuestion = ColumnViewImages("PicQuestion").Picture 
  ssWeekdays = M01Functions.Weekdays0to6LocalLanguage() 'as String[]
  If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
  
  If ColumnView1.Count > 0 Then
    If ColumnView1.Selection.Max > -1 Then 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sLine = ""
        For iColumn = 0 To F_iColumnsReadMax
          sLine = sLine & ColumnView1[sK1][iColumn]
        Next
        
        T0 = Trim(ColumnView1[sK1][0]) 'yyyy-mm-dd
        T1 = Trim(ColumnView1[sK1][1]) '00:00
        T2 = Trim(ColumnView1[sK1][2]) 'Mo
        T3 = Trim(ColumnView1[sK1][3]) 'Q
        T4 = Trim(ColumnView1[sK1][4]) 'KW
        T5 = Trim(ColumnView1[sK1][5]) 'Trim left and right from String  Example: " Notiz Text " => "Notiz Text"
        If F_iMusterTermine1Names2Projects3 = 3 Then
          T6 = Trim(ColumnView1[sK1][6]) '00:00
          T7 = Trim(ColumnView1[sK1][7]) 'Wochentag
          T8 = Trim(ColumnView1[sK1][8]) 'Sek.
          T9 = Trim(ColumnView1[sK1][9]) '00:00:00
        Endif 
        'T10 = Trim(ColumnView1[sK1][10]) 'ColumnsUndo
        'T11 = Trim(ColumnView1[sK1][11]) 'Icon, Edit
        'T12 = Trim(ColumnView1[sK1][12]) 'Sortieren
        'T13 = Trim(ColumnView1[sK1][13]) 'Nr
        
        'Zeichen  ZZZZZZZZZZZZZZZZZZZZ
        sValue = T5
        sValue = Trim(sValue)
        sValue = Replace(sValue, gb.NewLine, String.Chr(182)) ' Returnzeichen ¶ ersetzen
        sValue = Replace(sValue, Chr(10), ".") 'Chr() ASCII < 128 = UTF-8
        sValue = Replace(sValue, gb.Tab, Space(3))
        T5 = sValue
        
        If T0 <> "" Then
          If T1 Like "??:??" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue) 
          Else If T1 Like "*??:??*" Then
            sValue = Str(T1)
            Try T1 = M01Functions.TimeCheckHHMM(sValue) 
          Else
            sValue = ""
            For iColumn = 0 To ColumnView1.Columns.Max
              If ColumnView1[sK1][iColumn] Like "*??:??*" Then
                sValue = Str(ColumnView1[sK1][iColumn])
                Break
              Endif
            Next
            If sValue = "" Then sValue = "00:00"
            Try T1 = M01Functions.TimeCheckHHMM(sValue)
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            If T6 Like "??:??" Then
              '...Leerlauf
            Else If T6 Like "*??:??*" Then
              sValue = Str(T6)
              Try T6 = M01Functions.TimeCheckHHMM(sValue)
            Endif 
          Endif 
        Endif
        
        sValue = T0
        hDate1 = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If hDate1 Then ' ist ein Datum       DDDDDDDDDDDDDDDDDD
          T0 = Format(hDate1, "yyyy-mm-dd")
          T2 = Format(hDate1, "ddd")
          T3 = M01Functions.DateQuarterG(hDate1) & "Q" '1...4
          T4 = Format(M01Functions.DateCalenderWeek(hDate1), "00") & ("KW") '00...52
        Else 'kein Datum oder Timer?  TTTTTTTTTTTTTTTTTTTTTTTT
          If M01Functions.isZahl(T0) = True Then 'unbekannte Zahl?
            sLine = ""
          Else
            For iDay = 0 To 6 ' 7-Tage
              If String.LCase(T0) Like "*" & String.LCase(ssWeekdays[iDay]) & "*" Then sTimerDays = sTimerDays & ssWeekdays[iDay] 'Teile von SoMoDiMiDoFrSa
            Next
            If sTimerDays <> "" Then
              T0 = sTimerDays
              If T1 = "" Then T1 = "00:00"
              T3 = "-Q"
              T4 = "-KW"
            Else
              sLine = ""
            Endif
          Endif
          If F_iMusterTermine1Names2Projects3 = 3 Then
            sTime1 = T1
            sTime2 = T6
            If sTime1 Like "??:??" And sTime2 Like "??:??" Then 
              hDate0 = Date(Year(hDate1), Month(hdate1), Day(hdate1), 0, 0, 0)
              ssTime = Split(sTime1 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate1 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              ssTime = Split(sTime2 & ":", ":")
              If ssTime Then 
                iHH = CInteger(ssTime[0])
                iMM = CInteger(ssTime[1])
              Endif 
              hDate2 = Date(Year(hDate1), Month(hdate1), Day(hdate1), iHH, iMM, 0)
              
              iSecond = DateDiff(hDate1, hDate2, gb.Second) 'as Integer
              T8 = Str(iSecond)
              If iSecond < 0 Then iSecond = 0
              T9 = Format(DateAdd(hDate0, gb.Second, iSecond), "hh:nn:ss")
              ' Endif 
            Endif 
            T7 = T2 'Mo > Mo
          Endif 
        Endif
        
        'Compare (mit korrigierter Zeile vergleichen)
        If sLine = "" Then
          ColumnView1[sK1].Picture = PicQuestion '?  Fragezeichen
          ColumnView1[sK1][F_iColumnSelect] = "PicQuestion"
          iUnknown = iUnknown + 1
        Else If String.InStr(sLine, T0) = 0 Or Not Trim(sLine) = Trim(T0 & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9) Then
          ColumnView1[sK1].Picture = PicRefresh 'verändert
          ColumnView1[sK1][F_iColumnSelect] = "PicRefresh"
          iCorrectedLines = iCorrectedLines + 1
        Else
          ColumnView1[sK1].Picture = PicOK 'OK
          ColumnView1[sK1][F_iColumnSelect] = "PicOK"
        Endif
        
        'Back (Korrigierte Zeilen zurückschreiben)
        ColumnView1[sK1][0] = T0
        ColumnView1[sK1][1] = T1
        ColumnView1[sK1][2] = T2
        ColumnView1[sK1][3] = T3
        ColumnView1[sK1][4] = T4
        ColumnView1[sK1][5] = T5
        If F_iMusterTermine1Names2Projects3 = 3 Then
          ColumnView1[sK1][6] = T6
          ColumnView1[sK1][7] = T7
          ColumnView1[sK1][8] = T8
          ColumnView1[sK1][9] = T9
        Endif 
      Next
      sValue = ""
      If iUnknown > 0 Then sValue = Space(1) & ("Unbekannte=") & iUnknown & "?"
      ColumnView1.Columns[5].Title = ("Formate korrigiert=") & iCorrectedLines & sValue
      If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible
      If iCorrectedLines > 0 Then 
        ButtonSave.Background = Color.Red
      Endif
      Form2Bearb.Window.Title = F_sTitleBasicText & Space(5) & Str((ColumnView1.Count) & sValue)
      LabelInfo.Text = ColumnView1.Columns[5].Title
      LabelInfo.Visible = True 
    Endif 'ColumnView1.Selection.Max 
  Endif 'ColumnView1.Count
  
Ende:
  
Catch 
  FMain.ErrorText
  
End

Public Sub ProgressBarONoff(Optional bON As Boolean = False)
  'ProgressBar1.Pulse = True  [......◁■■▷...]  or False: [■■■▷□□□□□□□]
  
  If bON = True Then
    If ProgressBar1.Visible = False Then 
      ProgressBar1.Visible = True
      ProgressBar1.Raise 'Top ▲Level▲ (Oberste Ebene, Erhebung (Raise), unterste Ebene (Lower))
    Endif 
    If ProgressBar1.Value >= 1 Then 'Maximum      Value AS Float
      ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
    Else
      ProgressBar1.Value = ProgressBar1.Value + 0.05 ' 0, 0.01 ... 1.0 Zahl zwischen 0 und 1
    Endif
    If ProgressBar1.Value < 0.5 Then 
      ProgressBar1.Pulse = True
    Else
      ProgressBar1.Pulse = False
    Endif 
    Wait 0.00001  'nicht sleep 0.01, gibt Rechenzeit an Betriebssystem zurück
  Else 'End, Finished (Ausschalten, Fortschrittsanzeige beenden, ausblenden)
    ProgressBar1.Pulse = False
    If ProgressBar1.Visible = True Then
      ProgressBar1.Value = 1  '100%
      Wait 0.001 'gibt nur kurz Steuerung ab (Aufbau-Zeit)
      ProgressBar1.Visible = False
    Endif
    ProgressBar1.Value = 0 'Reset (zurück zum Anfang)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_DblClick()
  
  Form2Bearb.Window.Maximized = Not Form2Bearb.Window.Maximized 
  If Form2Bearb.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form2Bearb.Window.FullScreen = True Or Form2Bearb.Window.Maximized = True Then 
      F_bMovingON = False
      Form2Bearb.Window.FullScreen = False
      Form2Bearb.Window.Maximized = False
      If Form2Bearb.Left + Form2Bearb.W > Screen.AvailableWidth Then Form2Bearb.Move(Form2Bearb.Left, Form2Bearb.Top, Screen.AvailableWidth - Form2Bearb.Left, Screen.AvailableHeight - Form2Bearb.Top)
    Else
      F_bMovingON = True
      Form2Bearb.Window.FullScreen = False
      Form2Bearb.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_iX1 = Form2Bearb.ScreenX + Mouse.X - WindowStretch.W 
      F_iY1 = Form2Bearb.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form2Bearb.ClientW - WindowStretch.W, Form2Bearb.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form2Bearb.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form2Bearb.W = Mouse.ScreenX - F_iX1
    Form2Bearb.H = Mouse.ScreenY - F_iY1
    WindowStretch.Move(Form2Bearb.ClientW - WindowStretch.W, Form2Bearb.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form2Bearb.ClientW - WindowStretch.W, Form2Bearb.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form2Bearb.Window.Maximized = Not Form2Bearb.Window.Maximized 
    If Form2Bearb.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize()
  ' ColumnView1Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form2Bearb.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
  ' MoveLine.Cursor = New Cursor(Picture["images/size_32.png"].Image.Stretch(MoveLine.H, MoveLine.H).RotateLeft().Picture, 0, 0)
  ' MoveLine.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then mnuDatei.Popup()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuErgaenzungFeiertage2_Click()
  
  Dim sValue As String 
  
  sValue = Settings[FMain.Name &/ "OsterSonntag", ""] 'EasterDay
  If sValue = "" Then M03Feiertage.HolidaysCalculate()
  Form8ZusFeiertage.Window.Show
  Form8ZusFeiertage.Visible = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExternOpenGroup_Click()
  
  ButtonExternStartG(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonExternStartG(Optional sTag As String = "")
  
  Dim sPath, sCopy, sProgram As String
  
  sPath = FilePathForm()
  If Exist(sPath) = True Then
    Select Case String.LCase(sTag)
      Case "editor"
        sProgram = "gedit"
      Case "office"
        sProgram = "libreoffice"
      Case "browser"
        sProgram = "firefox"
      Case "csv"
        sProgram = "libreoffice"
        sCopy = File.SetExt(sPath, "csv")
        sCopy = M01Functions.ProgramDirCache(sCopy) '/Temp/File.txt
        If IsDir(File.Dir(sCopy)) = True Then 
          If Exist(sCopy) = True Then Try Kill sCopy
          If Exist(sCopy) = False Then Copy sPath To sCopy
          If Exist(sCopy) = True Then sPath = sCopy
        Endif 
    End Select
    If System.Exist(sProgram) = True Then 
      M01Functions.ExternStart(sProgram, sPath) 
    Else 
      Desktop.Open(sPath)
    Endif
    ColumnViewInfo(("Siehe extern") & ": " & ": " & sPath)
  Else 
    ColumnViewInfo(("Datei nicht gefunden") & ": " & sPath)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuHilfe_Show()
  
  Dim longFreeMedia As Long
  Dim sText As String 
  
  longFreeMedia = M01Functions.DirectoryFreeBytesLong("/") 'Alles auf Gerät "/"
  sText = ("Freier Speicher") & ": " & Format(longFreeMedia / 1024 / 1024 / 1024, "0,0") & " GB" & Space(5) & "(" & Format(longFreeMedia, "0,0") & Space(1) & "Bytes)"
  mnuFestplattenbelegung.Text = ("Festplatte") & ", " & sText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSonderzeichen_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gucharmap")
  If bExist = True Then 
    M01Functions.ExternStart("gucharmap") 'Sonderzeichen, Zeichentabelle
  Else 
    bExist = System.Exist("gnome-characters")
    ' Shell "gnome-control-center"
    M01Functions.ExternStart("gnome-characters", "")
    ' M01Functions.ExternStartAlternative("gnome", "info")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuSonderzeichen.Text, "Fehlt") = 0 Then mnuSonderzeichen.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSonderzeichen.Text)
  Endif
  '/usr/share/applications
  'gcalctool 'Taschenrechner
  'gnome-session-properties 'Startprogramme
  'gnome-control-center --overview 'Systemeinstellungen
  'gnome-control-center indicator-datetime  'Zeit und Datum
  'gnome-control-center deja-dup 'Datensicherung
  'gnome-search-tool ' Suche im PC
  'baobab 'Festplattenbelegung
  
Catch 
  FMain.ErrorText
  ''______________________________________________________________''
  'https://manpages.ubuntu.com/manpages/trusty/man1/gucharmap.1.html
  'https://manpages.ubuntu.com/manpages/trusty/man1/gnome-session-properties.1.html
  
End

Public Sub mnuSuchePC_Click()
  
  Dim sPath As String
  
  sPath = FilePathForm()
  ' M01Functions.FileManagerOpen(sPath) 'Suche im PC
  M01Functions.ExternStart("nautilus", sPath)
  ColumnViewInfo(("Siehe extern:" & Space(1) & mnuSuchePC.Text))
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuFestplattenbelegung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("baobab")
  If bExist = True Then
    Shell "baobab" 'startet Programm
    ' M01Functions.ExternStart("baobab") 'Festplattenbelegung
  Else
    bExist = System.Exist("nautilus") 'Filemanager (Dateiverwaltung)
    M01Functions.ExternStart("nautilus", "")
  Endif 
  
  If bExist = False Then 
    If String.InStr(mnuFestplattenbelegung.Text, "Fehlt") = 0 Then mnuFestplattenbelegung.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuFestplattenbelegung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("deja-dup") 'Backup-Program
  If bExist = True Then
    Shell "deja-dup" 'start Program
    'unity-control-center deja-dup
    'M01Functions.ExternStart("gnome-control-center", "deja-dup") 'Datensicherung
  Endif
  If bExist = False Then 
    bExist = System.Exist("unity-control-center")
    If bExist = True Then Shell "unity-control-center deja-dup"
  Endif
  If bExist = False Then 
    If String.InStr(mnuDatensicherung.Text, "Fehlt") = 0 Then mnuDatensicherung.Text &= Space(2) & ("Fehlt!")
    mnuDatensicherung2.Text = mnuDatensicherung.Text
    ColumnViewInfo(mnuDatensicherung.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuSystemDatumZeit_Click()
  
  Dim bExist As Boolean
  
  bExist = System.Exist("gnome-control-center") 'System
  If bExist = True Then
    Shell "gnome-control-center datetime" 'startet Programm
    ' M01Functions.ExternStart("gnome-control-center", "info-overview") 'Zeit und Datum, Seite Betriebssysem-Info
  Endif
  If bExist = False Then bExist = System.Exist("unity-control-center")
  If bExist = True Then
    Shell "unity-control-center datetime" ' Datum und Zeit, Einstellungen im Betriebssystem
    'M01Functions.ExternStart("unity-control-center", "datetime") 'Zeit und Datum
  Endif
  If bExist = False Then
    If String.InStr(mnuSystemDatumZeit.Text, "Fehlt") = 0 Then mnuSystemDatumZeit.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuSystemDatumZeit.Text)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTaschenrechner_Click()
  
  Dim bExist As Boolean
  
  'M01Functions.ExternStart("gcalctool") 'gcalctool 'Taschenrechner
  bExist = M01Functions.ExternCalculator()
  If bExist = False Then 
    If String.InStr(mnuTaschenrechner.Text, "Fehlt") = 0 Then mnuTaschenrechner.Text &= Space(2) & ("Fehlt!")
    ColumnViewInfo(mnuTaschenrechner.Text)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuExport_Click() 'ö=oe, ...
  
  Form13Export.Window.Show
  ' Form13Export.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlExportieren_Click()
  
  SaveSelectionG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelDatumInfo()
  
  Dim sMessage, hTab, hReturn, hSpace As String
  
  hTab = String(5, "&nbsp;") ' Count empty Space (Anzahl Leerzeichen)
  hReturn = "<br>"
  hSpace = "&nbsp;" 'Empty Space (Leerzeichen 1x)
  'Terminwecker/Project-Line-Format:
  sMessage = M01Functions.TerminweckerLine(Format(Now, "yyyy-mm-dd"), Format(Now, "hh:nn"), ("Notiz"))
  sMessage = Replace(sMessage, gb.Tab, hTab)
  sMessage = "<b><font color=gray>" & sMessage & "</font></b>" & hReturn & hReturn
  sMessage &= M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'As String
  sMessage &= ("Wochentag, Quartal und Kalenderwoche werden automatisch berechnet und ergänzt.") & hReturn & hReturn
  sMessage &= ("Tipp") & ": " & hReturn 
  sMessage &= ("*Geburtstage, #Feiertage oder +Timerplus können durch ein einheitliches Zeichen") & hReturn
  sMessage &= ("unter 'Suche' zusammen angezeigt, bearbeitet, exportiert oder gelöscht werden.") & hReturn
  sMessage &= ("Begriffe einheitlich anwenden, mindestens 1x im Text, für eine spätere 'Suche'.") & hReturn 
  sMessage &= ("Beispiel") & hSpace & "<font color=darkgreen>" & ("Suche: *Jahrestreffen xy") & "</font>" & hReturn 
  
  Message.Info(sMessage)
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxPath_KeyPress()
  
  If Key.Code = Key.Return And ProgressBar1.Visible = False Then Timer2KeyPress.Start 'ReadG() not in Loop _KeyPress
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer2KeyPress_Timer()
  
  Dim sPath As String 
  
  Timer2KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  
  sPath = TextBoxPath.Text 
  sPath = Replace(sPath, gb.NewLine, "")
  ReadG(sPath, True)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer3KeyPress_Timer()
  
  Timer3KeyPress.Stop 'Stop Timer, but process 1x all lines in this Sub
  ButtonSearchG() 'not in _KeyPress > Error
  
Catch 
  FMain.ErrorText
  
End

Public Function Text5TempPathReturn() As String

  Dim sFile As String 
  
  F_sPathText5Temp_txt = Settings[FMain.Name &/ "F_sPathText5Temp_txt", FMain.F_sPathText5Temp_txt]
  sFile = File.BaseName(F_sPathText5Temp_txt)
  
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1
      F_sText5StartExampleName = ("Notiz")
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-termin.txt"
    Case 2
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-projectname.txt"
    Case 3
      F_sText5StartExampleName = Settings[FMain.Name &/ "F_sProjectOnlyName", Application.Name]
      F_sPathText5Temp_txt = File.Dir(F_sPathText5Temp_txt) &/ sFile & "-project.txt"
  End Select 
  
  Return F_sPathText5Temp_txt
  
Catch 
  FMain.ErrorText
  
End

Public Function Text5TempFileLoad() As String 
  
  Dim sText As String 
  Dim hReturn As String 
  
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  If Exist(F_sPathText5Temp_txt) = True Then
    sText = File.Load(F_sPathText5Temp_txt)
    PasteLineArrow(sText) 'Chr(182) = "¶"
  Endif 
  
  Return sText 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5TempFileRefresh()

  Dim T5, sText, sPath As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If Exist(F_sPathText5Temp_txt) = False Then F_sPathText5Temp_txt = Text5TempPathReturn()
  
  T5 = Text5.Text
  T5 = Replace(T5, hReturn, String.Chr(182)) ' Replace Return "¶" (ersetzen)
  ''Chr$(13) & Chr$(10) = "\r\n" = gb.CrLF = gb.Cr & gb.LF, gb.LF = gb.NewLine = "\n" = Chr$(10)
  T5 = Replace(T5, gb.NewLine, String.Chr(182))
  T5 = Replace(T5, hTab, Space(3))
  
  Select Case F_iMusterTermine1Names2Projects3
    Case 1
      If String.Len(Text5.Text) > 0 Then 
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 2
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.TerminweckerLine(Text0.Text, Text1.Text, T5 & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
    Case 3
      If String.Len(Text5.Text) > 0 Then
        sText = M01Functions.ProjectLine(Text0.Text, Text1.Text, T5 & Text2.Text & hReturn) 'as String
        sPath = M01Functions.FileTextPlus(F_sPathText5Temp_txt, sText, True) ' TRUE=overwrite (überschreiben)
      Endif 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer() '>Termine
  '.Delay=1000 =1 second
  
  If F_iMusterTermine1Names2Projects3 = 1 And F_bKeyboardInput = True Then 
    F_iText5Seconds = F_iText5Seconds + 1 
    If F_iText5Seconds > 10 Then  
      Text5TempFileRefresh()
      F_iText5Seconds = 0
      F_bKeyboardInput = False
    Endif 
    If F_iText5Seconds > 3 Then UndoRedoText5Add(Text5.Text)
  Endif 
  
  If F_statFilePathForm Then 
    If Exist(F_statFilePathForm.Path) = True Then  
      If F_statFilePathForm.Time <> Stat(F_statFilePathForm.Path).Time Then ColumnViewInfo(("Info") & ": " & ("Datei extern geändert") & Space(1) & Format(F_statFilePathForm.LastModified, "hh:nn:ss"))
      F_statFilePathForm = Stat(F_statFilePathForm.Path) 'Refresh
    Endif 
  Endif 
  If String.Left(Text5.text, 1) = "*" Then CheckBox1.Value = True Else CheckBox1.Value = False
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer4Now_Timer()
  
  LabelDateNow.Text = Format(Now, "yyyy-mm-dd") & Space(3) & Format(Now, "ddd")
  If Second(Time) Mod 2 Then 
    LabelTimeNow.Text = Format(Now, "hh:nn")
  Else 
    LabelTimeNow.Text = Format(Now, "hh nn")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCancelB_MouseDown()
  
  ButtonCancelG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTerminweckerdateiLesen_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuTermineDateiOeffnenSpeichern_Click()
  
  Dim sPath As String 
  
  sPath = FilePathForm()
  M01Functions.FileToForm3Text(sPath)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PasteLineArrow(Optional sLinePaste As String = "")
  
  Dim T0, T1, T5, T6, T8, T9 As String
  Dim sValue As String 
  Dim ssLines, ssLine As String[]
  Dim sLine, sPart As String
  Dim it, iLine, iCounter As Integer
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  If String.InStr(sLinePaste, gb.Tab) > 0 Then 
    sValue = sLinePaste
  Else If Clipboard.Type = Clipboard.Text Then 'nur wenn Text in Zwischenablage ist
    sValue = Clipboard.Paste("text/plain") '()Klammer nicht vergessen!
  Endif 
  
  If sValue Then 
    If String.InStr(sValue, hTab) > 0 And sValue Like "????-??-??*??:??*" Then
      ssLines = Split(sValue & String(2, hReturn), hReturn)
      For Each sLine In ssLines
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, hTab) > 0 And sLine Like "????-??-??*??:??*" Then
          iCounter = iCounter + 1
          ssLine = Split(sLine & String(6, hTab), hTab)
          it = 0
          For Each sPart In ssLine
            If it = 0 Then T0 = sPart
            If it = 1 Then T1 = sPart
            If it = 5 Then T5 = sPart
            If it = 6 Then T6 = sPart 
            If it = 8 Then T8 = sPart
            If it = 9 Then T9 = sPart
            it = it + 1
            If it > F_iColumnsReadMax Then Break
          Next
          If iCounter > 0 Then Break 'only 1 sPart
        Endif
      Next
      Text0Insert(T0) '0000-00-00 
      Text1Insert(T1) '00:00 'A
      Text5Insert(T5) 'Project/Notice
      If F_iMusterTermine1Names2Projects3 = 3 Then 
        Text2Insert(T6) '00:00 'B
        ButtonSum.Tooltip = T8 'Seconds 12345
        ButtonDauer.Text = T9 '00:00:00 Duration
      Endif 
    Endif
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineEinlagernG()
  
  ''Plus
  ReadG(FilePathFormOldYears(), True) 'True: with Dialog
  
Catch 
  FMain.ErrorText
  
End

Public Sub TermineAuslagernG()
  
  Dim iDiffDays, iOldLines, it, iLine As Integer
  Dim sKey, sKeyLast, sValue, sLine, sWithoutDoubles, sTextInside, sTextOutside, sTitleInfo, sMessage As String
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim dateA, dateB, dateDatum1, dateDatum2 As Date
  Dim sBisDatum1, sBisDatum2 As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = FilePathFormOldYears()
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  dateDatum1 = Date(Year(Date) - 6, 12, 31)
  dateDatum2 = Date(Year(Date) - 1, 12, 31)
  sBisDatum1 = ("vor") & " ◀ " & Format(dateDatum1, "yyyy") & Space(1) & ("auslagern") 'vor<<
  sBisDatum2 = ("vor") & " ◁ " & Format(dateDatum2, "yyyy") & Space(1) & ("auslagern") 
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("Vergangene Zeilen auslagern in die Datei") & ":" & "</font></h3>"
  sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
  sMessage &= ("Ausnahme:  *Geburtstage oder andere Termine (*Jedes Jahr) werden nicht verschoben.") & "<br>"
  sMessage &= ("Ausnahme:  Timer SoMoDiMiDoFrSa (Jede Woche) werden nicht verschoben.") & "<br>" 'EN: SuMoTuWeThFrSa (DE: SoMoDiMiDoFrSa)
  
  Select Case Message.Question(sMessage, sBisDatum1, sBisDatum2, ("Abbrechen"))
    Case 1 'Move outside (Auslagern)
      dateA = dateDatum1
    Case 2 'Move outside (Auslagern)
      dateA = dateDatum2
    Case 3 'Cancel (Abbrechen)
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form2Bearb.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form2Bearb.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''No Birthdays "*", no Timer SoSa, Muster: 0000-00-00 00:00 WD Q CW Notice
    If String.Left(ColumnView1[sKey][5], 1) = "*" Or IsInteger(String.Left(ColumnView1[sKey][0], 1)) = False Then 'no *EveryYear (ohne *Geburtstage), no Timer SaSoMoDiMiDoFrSa
      ''...
    Else If ColumnView1[sKey][0] Like "*????-??-??" Then
      If ColumnView1[sKey][5] <> "" Then
        sValue = ColumnView1[sKey][0]
        dateB = M01Functions.DateCheckyyyymmddhhnn(sValue, "00:00") 'as Date
        If dateB Then
          iDiffDays = DateDiff(dateA, dateB, gb.day)
          If iDiffDays < 0 Then
            sLine = ""
            For it = 0 To ColumnView1.Columns.Max
              If it < F_iColumnsReadMax + 1 Then 
                sLine = sLine & ColumnView1[sKey][it] & hTab
                ColumnView1[sKey][it] = ""
              Else 
                sLine = sLine & ColumnView1[sKey][it] & hReturn
                ColumnView1[sKey][it] = ""
                ColumnView1[sKey].Picture = PicCut
                ColumnView1[sKey][F_iColumnSelect] = "PicCut"
                ColumnView1[sKey].Selected = True
                sKeyLast = sKey
                Break
              Endif
            Next
            sTextInside = sTextInside & sLine
            iOldLines = iOldLines + 1
          Endif 'iDiffDays
        Endif 'dateB
      Endif 'ColumnView1[sKey][0]
    Endif 'ColumnView1[sKey][0] LIKE "*????-??-??"
  Next
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then sTextOutside = File.Load(sDirFileOldYears)
    sTextOutside = sTextOutside & sTextInside
    For Each sLine In Split(sTextOutside & gb.NewLine, gb.NewLine)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(("Auslagern")) = True Then Break
      Endif 
      
      If String.InStr(sWithoutDoubles, sLine) = 0 Then sWithoutDoubles &= sLine & hReturn
    Next 
    'File.save(sDirFileOldYears, sTextOutside)
    sPath = M01Functions.FileTextPlus(sDirFileOldYears, sWithoutDoubles, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      Form2Bearb.Window.Title = F_sTitleBasicText & " - " & ("auslagern...fertig")
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iOldLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
      
      sMessage = Str(iOldLines) & Space(1) & ("Zeilen verschoben in Datei") & "<br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen"))
        Case 1 
          SaveG() 'with backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen")
    Message.Info(sTitleInfo, ("Abbrechen"))
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form2Bearb.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub GeburtstageAuslagernG() '*EveryYear Outside (*Jedes Jahr, auslagern)
  
  Dim iOldLines, iDoubleLines, iUnknownLines, iMoveLines, it, iLine As Integer
  Dim sKey, sKeyLast, sLine, sTextLine, sPart, sTextInside, sTextOutside, sExist, sTitleInfo, sMessage As String 
  Dim sPath, sDirFileTermine, sDirFileOldYears As String 
  Dim sHTMLa, sHTMLb, sHTMLaRed, sHTMLbRed, sSpace As String
  Dim PicCut, PicHome As Picture
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  sDirFileTermine = FilePathForm()
  sDirFileOldYears = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear] '*EveryYear (*jedes Jahr, Geburtstage)
  
  PicCut = ColumnViewImages("PicCut").Picture 
  PicHome = ColumnViewImages("PicHome").Picture 
  
  sHTMLa = "<h3><font color=darkgreen><b>"
  sHTMLb = "</b></font></h3>"
  sHTMLaRed = "<font color=red><b>"
  sHTMLbRed = "</b></font>"
  sSpace = Space(1)
  
  sMessage = "<h3><font color=gray>" & ("Heute") & ",  " & Format(Date, "ddd dd-mm-yyyy") & "</font></h3>"
  sMessage &= "<h3><font color=darkgreen>" & ("*Zeilen auslagern in die Datei") & ":" & "</font></h3>" '*Every Year (*Jedes Jahr)
  sMessage &= sHTMLa & "● " & sDirFileOldYears & sHTMLb 
  sMessage &= ("Nur Zeilen (*Jedes Jahr) werden verschoben.") & "<br>"
  sMessage &= ("Beispiel: *Geburtstage")
  
  Select Case Message.Question(sMessage, "● " & "*" & ("Zeilen") & Space(1) & ("auslagern"), ("Abbrechen"))
    Case 1 'Move outside —▶ birthsdays list
      '...
    Case 2 'Cancel
      Goto Ende
  End Select
  F_bESCpressedON = False 
  ColumnView1.UnselectAll()
  Form2Bearb.Window.Title = F_sTitleBasicText & " - " & ("auslagern...")
  
  For Each sKey In ColumnView1.Keys
    iLine = iLine + 1
    If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
    ''[ESC]?
    If F_bESCpressedON = True Then 
      If MessageQuestionBreak(Form2Bearb.Window.Title) = True Then Break
    Endif 
    
    ColumnView1[sKey].Picture = PicHome
    ColumnView1[sKey][F_iColumnSelect] = "PicHome"
    ''Birthdays "*" 
    If String.Left(ColumnView1[sKey][5], 1) = "*" Then 'Muster: 0000-00-00 00:00 WD Q CW *Notice
      sLine = ""
      For it = 0 To ColumnView1.Columns.Max
        If it < F_iColumnsReadMax + 1 Then
          sLine = sLine & ColumnView1[sKey][it] & hTab
          ColumnView1[sKey][it] = ""
        Else 
          Break
        Endif 
      Next
      ColumnView1[sKey].Picture = PicCut
      ColumnView1[sKey].Selected = True
      sKeyLast = sKey
      If sLine Then
        sTextInside = sTextInside & sLine & hReturn
        iOldLines = iOldLines + 1
      Endif 
    Endif  
  Next
  If F_bESCpressedON = True Then Goto Ende
  
  If iOldLines > 0 Then
    If Exist(sDirFileOldYears) = True Then
      sTextOutside = File.Load(sDirFileOldYears) '*EveryYear
    Endif
    sTextOutside = sTextOutside & sTextInside
    For Each sTextLine In Split(sTextOutside & hReturn, hReturn)
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form2Bearb.Window.Title) = True Then Break
      Endif 
      
      If sTextLine Then 
        it = 0
        sLine = ""
        For Each sPart In Split(sTextLine & hTab, hTab) 'Muster: 0000-00-00 00:00 WD Q CW *Notice
          If it < F_iColumnsReadMax + 1 Then sLine = sLine & sPart & hTab
          If it = F_iColumnsReadMax Then Break
          it = it + 1
        Next
        If it = F_iColumnsReadMax And sLine Then 
          sLine = sLine & hReturn
          If String.InStr(sExist, sLine) > 0 Then 
            iDoubleLines = iDoubleLines + 1
          Else 
            sExist &= sLine  'no double
            iMoveLines = iMoveLines + 1
          Endif 
        Else If sLine Then 
          iUnknownLines = iUnknownLines + 1
        Endif 
      Endif 
    Next
    If F_bESCpressedON = True Then Goto Ende
    
    'File.save(sDirFileOldYears, sExist)
    If sExist Then sPath = M01Functions.FileTextPlus(sDirFileOldYears, sExist, True) ' TRUE=overwrite (überschreiben)
    If Exist(sPath) = False Then 
      ColumnViewInfo(sDirFileOldYears & sSpace & ("Fehlt"))
    Else 
      ProgressBarONoff(False) 
      sTitleInfo = ("Ausgelagert") & sSpace & Str(iMoveLines) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen") & sSpace & ("Doppelt") & ": " & Str(iDoubleLines)
      
      sMessage = ("Fehlerhafte Zeilen") & ": " & sHTMLaRed & Str(iUnknownLines) & sHTMLbRed & "<br>"
      sMessage &= ("Doppelte *Zeilen") & ": " & sHTMLaRed & Str(iDoubleLines) & sHTMLbRed & "<br>"
      sMessage &= ("Zeilen verschoben in Datei") & ": " & "<font color=darkgreen><b>" & Str(iMoveLines - iDoubleLines) & Space(1) & ("von") & Space(1) & Str(iMoveLines) & "</b></font><br>"
      sMessage &= sHTMLa & sDirFileOldYears & sHTMLb 
      sMessage &= sHTMLaRed & ("Veränderte Liste") & sHTMLbRed
      
      Select Case Message.Question(sMessage, ("Jetzt speichern"), ("Nein"), ("Abbrechen")) '(0,1,2,3)
        Case 1 'Save now
          SaveG() ' with Backup (verbleibende Liste speichern mit Sicherungskopie)
          ReadG()
        Case 2, 3 'No, Cancel
          '...       
      End Select
    Endif 'sPath
  Else 
    sTitleInfo = "<h3><font color=gray>" & ("In Sammel-Datei:") & "</font></h3>"
    sTitleInfo &= "<h3>" & ("Ausgelagert") & sSpace & Str(0) & sSpace & ("von") & sSpace & Str(ColumnView1.Count) & sSpace & ("Zeilen") & "</h3>"
    Select Case Message.Question(sTitleInfo, ("Datei *JedesJahr (Geburtstage)") & "...", ("Ordner..."), ("Abbrechen"))
      Case 1 'File
        ButtonGroupSelect("editorbirthdays")
      Case 2 'Directory
        M01Functions.FileManagerOpen(sDirFileOldYears)
      Case 3 'Cancel
        '...
    End Select 
  Endif 'iOldLines
  If ColumnView1.Exist(sKeyLast) = True Then ColumnView1[sKeyLast].EnsureVisible()
  WindowTitle()
  ColumnViewInfo(sTitleInfo)
Ende:
  If Not sTitleInfo Then Form2Bearb.Window.Title = F_sTitleBasicText
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuAuswahlBis_Click()
  
  ButtonUntil()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonUntil()
  'Switch central (zentrale Umstellung)
  
  If PanelBis.Visible = False Then
    SelectHide0Date1Clock2Timer3(4)
  Else
    SelectHide0Date1Clock2Timer3(0)
    PanelBis.Visible = False
    ButtonBis.Background = F_iColorGreen
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuZeilenAuswahlOriginal_Click()
  
  ListMenuGroupFunctions("original2")
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuDatensicherung2_Click()
  
  mnuDatensicherung_Click
  
Catch 
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True  'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
    LabelInfo.Visible = True 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Search()
  
  Dim iLen As Integer
  
  F_iText5SearchPosition = String.InStr(String.LCase(Text5.Text), String.LCase(TextBoxSearch5.Text), F_iText5SearchPosition) 'as Integer
  If F_iText5SearchPosition > 0 Then 
    Text5.Pos = F_iText5SearchPosition
    iLen = String.Len(TextBoxSearch5.Text) 'as Integer   UTF-8 with String.x
    Text5.Select(F_iText5SearchPosition - 1, iLen)
    Text5.EnsureVisible
    ' Text5.SetFocus
    F_iText5SearchPosition = F_iText5SearchPosition + 1
    TextBoxSearch5.Background = F_iColorGreenAlpha150
    TextBoxSearch5.SetFocus
  Else 
    TextBoxSearch5.Background = F_iColorRedAlpha150
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Text5Resize()
  
  If MoveLine.Top <> F_iMoveLineMinH Then 
    F_iMoveLineTop = MoveLine.Top 
    MoveLine.Top = F_iMoveLineMinH
    WindowT5plus.Picture = PicTemplatePageMini.Picture
  Else 
    MoveLine.Top = F_iMoveLineTop
    WindowT5plus.Picture = PicTemplatePageMaxi.Picture
  Endif
  Form_Resize()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCopy()
  
  If ColumnView1.Selection.Max > -1 Then
    F_ssKeysCopy = ColumnView1.Selection.Copy()    'only Keys, Example: "3", "1", "2",... without .Sort()
    ColumnViewInfo(("Einfügen der Kopie, nach markierter Zeile."))
    ColumnViewClipboardCopy()
  Else 
    ListCopy.Background = Color.Red
    ColumnViewInfo(("ausgewählte Zeilen") & ": 0")  'No Selection
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewClipboardCopy() 'intern
  
  Dim it, iColumn, iLine As Integer
  Dim sText, sLine, sKey As String 
  Dim hTab, hReturn As String 
  
  hTab = Settings[FMain.Name &/ "hTab", gb.Tab]
  hReturn = Settings[FMain.Name &/ "hReturn", gb.NewLine]
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView1.Columns.Max
          sLine = ColumnView1[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Else ''ColumnView2:
    If F_ssKeysCopy Then 
      For it = 0 To F_ssKeysCopy.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sKey = F_ssKeysCopy[it]
        For iColumn = 0 To ColumnView2.Columns.Max
          sLine = ColumnView2[sKey][iColumn]
          If iColumn < F_iColumnsReadMax + 1 Then 
            sText = sText & sLine & hTab
          Else 
            sText = sText & sLine & hReturn
            Break
          Endif 
        Next 
      Next
      If F_bESCpressedON = True Then Goto Ende
      
      If sText Then 
        Clipboard.Clear()
        Clipboard.Copy(sText) ' Copy in Clipboard (Zwischenablage)
        'sValue = Clipboard.Paste("text/plain") 'Klammer nicht vergessen!
        F_sLinesCopy = sText 
      Endif 
    Endif
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewMarkGreen()
  
  Dim sK1 As String
  Dim PicEmpty As Picture
  Dim PicMarkGreen As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView1.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView1[sK1].Background <> Color.Default Then 
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView1[sK1].Background = F_iColorGreenAlpha150
        ColumnView1[sK1].Foreground = F_iColorForegroundBlue
        ColumnView1[sK1].Picture = PicMarkGreen
        ColumnView1[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
    
  Else ''ColumnView2:
    PicMarkGreen = ColumnViewImages("PicMarkGreen").Picture 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    If ColumnView2.Selection.Max > -1 Then 'Selected Lines?
      sK1 = ColumnViewCurrentKey() 'as String
      If ColumnView2[sK1].Background <> Color.Default Then 
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
      Else 
        ColumnView2[sK1].Background = F_iColorGreenAlpha150
        ColumnView2[sK1].Foreground = F_iColorForegroundBlue
        ColumnView2[sK1].Picture = PicMarkGreen
        ColumnView2[sK1][F_iColumnSelect] = "PicMarkGreen"
      Endif 
    Else 
      ListMark.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCut()
  
  Dim iColumn, iLine As Integer
  Dim PicCut As Picture
  Dim sK1 As String 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView1.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sK1].Picture = PicCut
        ColumnView1[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView1[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      ColumnViewClipboardCopy()
      PicCut = ColumnViewImages("PicCut").Picture 
      For Each sK1 In ColumnView2.Selection
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sK1].Picture = PicCut
        ColumnView2[sK1][F_iColumnSelect] = "PicCut"
        For iColumn = 0 To F_iColumnsReadMax '0 —▶ |F_iColumnsReadMax|...|...
          ColumnView2[sK1][iColumn] = Null 
        Next
      Next
    Else 
      ListCut.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView2to1()                                                               'ColumnView2 ▶ ColumnView1
  
  Dim iColumn, iLine As Integer
  Dim sK2 As String 
  
  If ColumnView2.Count > 0 Then
    ColumnView1.UnselectAll()
    For Each sK2 In ColumnView2.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1.Exist(sK2) Then 
        For iColumn = 0 To ColumnView2.Columns.Max
          ColumnView1[sK2][iColumn] = ColumnView2[sK2][iColumn] 
        Next
        ''ColumnView1 ▶ ColumnView2
        ColumnView1[sK2].Picture = ColumnView2[sK2].Picture
        ColumnView1[sK2].Selected = ColumnView2[sK2].Selected
      Endif 
    Next
  Else 
    ListCut.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUp() '▲
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicUp As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicUp
        ColumnView1[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView1.MoveTo(sK1)
        ' M = ColumnView1.MoveBelow() '▼down
        M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort]
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicUp = ColumnViewImages("PicUp").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = F_ssKeysCopy.Max To 0 Step -1   'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicUp
        ColumnView2[sK1][F_iColumnSelect] = "PicUp"
        M = ColumnView2.MoveTo(sK1)
        ' M = ColumnView2.MoveBelow() '▼down
        M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort]
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewDown() '▼
  
  Dim it, iLine As Integer 
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim PicDown As Picture
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If ColumnView1.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView1.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView1[sK1].Picture = PicDown
        ColumnView1[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView1.MoveTo(sK1)
        M = ColumnView1.MoveBelow() '▼down
        'M = ColumnView1.MoveAbove() '▲up
        If M = -1 Then ColumnView1.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView1.Item.Key
        sC1 = ColumnView1[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView1[sK2][F_iColumnSort] 'Read Column
        ColumnView1[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView1[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Else ''ColumnView2:
    If ColumnView2.Selection.Max > -1 Then 
      PicDown = ColumnViewImages("PicDown").Picture 
      ColumnSortSettingCentral()
      F_ssKeysCopy = ColumnView2.Selection.Copy() 'only Keys     index 0,1,2,3... Keys 1,2,3...
      For it = 0 To F_ssKeysCopy.Max 'selected Keys (Rows)
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sK1 = F_ssKeysCopy[it]
        ColumnView2[sK1].Picture = PicDown
        ColumnView2[sK1][F_iColumnSelect] = "PicDown"
        M = ColumnView2.MoveTo(sK1)
        M = ColumnView2.MoveBelow() '▼down
        'M = ColumnView2.MoveAbove() '▲up
        If M = -1 Then ColumnView2.MoveFirst() '▲ 'M=0=False>Exist. M=-1=True>Missing
        sK2 = ColumnView2.Item.Key
        sC1 = ColumnView2[sK1][F_iColumnSort] 'Read Column
        sC2 = ColumnView2[sK2][F_iColumnSort] 'Read Column
        ColumnView2[sK1][F_iColumnSort] = sC2 'Change Column
        ColumnView2[sK2][F_iColumnSort] = sC1 'Change Column
      Next 
      ColumnViewSort(F_iColumnSort)
    Else 
      ListDown.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
    Endif
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewPaste() 
  
  Dim iColumn, iLine As Integer
  Dim sK0, sK1, sKeySort, sValue, sMessage As String 
  Dim M As Integer = -1 'True -1, False 0 (meaning here True!)
  Dim PicAdd As Picture
  Dim ssKeys As New String[]
  Dim sLine, sPart As String 
  Dim bInfo As Boolean 
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView1.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView1.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView1.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then 
      If ColumnView1.Exist(sK0) = False Then 
        M = ColumnView1.MoveLast()
        If M = 0 Then ColumnView1.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView1.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView1.UnselectAll()
      ColumnView1.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView1.Count + 1 
          ColumnView1.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView1.Columns.Max Then 
              ColumnView1[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView1[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView1[sK1].Selected = True
        Next
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True
    Endif
  Else ''ColumnView2:
    sValue = Clipboard.Paste("text/plain") 'other Formats: "text/plain;text/rtf;text/html"...
    If Split(sValue & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then
      If sValue Like "*????-??-??*??:??*" Then F_sLinesCopy = sValue
    Endif  
    
    If ColumnView2.Selection.Max > -1 Then 
      PicAdd = ColumnViewImages("PicAdd").Picture 
      sK0 = ColumnView2.Selection.Last 'Example: Keys "1","12","4","2",... .Selection[0]="1"
      ' ColumnView2.Sorted = False
    Endif 
    
    If Split(F_sLinesCopy & gb.Tab, gb.Tab).Count > F_iColumnsReadMax Then   
      If ColumnView2.Exist(sK0) = False Then 
        M = ColumnView2.MoveLast()
        If M = 0 Then ColumnView2.MoveCurrent() 'M=0=False>Exist. M=-1=True>Missing
        If M = 0 Then sK0 = ColumnView2.Current.Key
      Endif 
      sKeySort = sK0       'Subpoint 1 —▶ 1.1 Sort
      ' sKeySort = ColumnViewSortNewNr(sKeySort)
      ColumnView2.UnselectAll()
      ColumnView2.Mode = Select.Multiple
      For Each sLine In Split(F_sLinesCopy & gb.NewLine, gb.NewLine) 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If String.InStr(sLine, gb.Tab) > 0 Then 
          sK1 = ColumnView2.Count + 1 
          ColumnView2.Add(sK1, sK1, PicAdd,, sK0) 'Add Last (default), Add After (sK0) 
          ColumnView2[sK1][F_iColumnSelect] = "PicAdd"
          iColumn = 0
          For Each sPart In Split(sLine & String(F_iColumnsReadMax, gb.Tab), gb.Tab)
            If iColumn < ColumnView2.Columns.Max Then 
              ColumnView2[sK1][iColumn] = sPart
            Else 
              Break
            Endif 
            iColumn = iColumn + 1
          Next
          sKeySort = sKeySort & ".1"
          ' sKeySort = ColumnViewSortNewNr(sKeySort)
          ColumnView2[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort| Columns max.
          ColumnView2[sK1][F_iColumnNr] = sK1
          ssKeys.Add(sK1)
        Endif 
        For Each sK1 In ssKeys
          ColumnView2[sK1].Selected = True
        Next
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1].EnsureVisible  'next new Key-Name
      Next
      ColumnViewSort(F_iColumnSort)
    Else 
      ListPaste.Background = Color.Red
      ColumnViewInfo(F_sCVinfoSelectLineFirst)
      bInfo = True 
    Endif
  Endif 
  
  If bInfo = True Then 
    If sValue Then 
      sMessage = String.Left(sValue, 300) & "..." 
      sMessage &= "<h3><font color=blue>" & ("Kein") & "</font>" & Space(1) & ("+Einfügen in Liste") & "</h3>" 
      sMessage &= ("Tabulatoren fehlen (Trenner)") & "<br>"
      
      Select Case Message.Question(sMessage, "?", ("Abbrechen"))
        Case 1 
          'Date >| time >| weekday >| Quarter >| calendar week >| notes LINE FEED
          sMessage = M06InfoText.TerminweckerLinesFormatInfo(F_iMusterTermine1Names2Projects3) 'as String
          Message.Info(sMessage)
        Case 2
          '...
      End Select 
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewCheckAplus()
  
  Dim sKey As String
  
  If F_i22 < 22 Then '?x? Pixel, greater (groesser)
    ListAplus.Picture = PicTemplateAplus.Picture
    ColumnView1.Font.Size = 12
  Else 
    ListAplus.Picture = PicTemplateAminus.Picture
    ColumnView1.Font.Size = 16
  Endif 
  
  ''Size picture
  If ColumnView1.Keys.Max > -1 Then 
    For Each sKey In ColumnView1.Keys
      If ColumnView1[sKey].Picture Then ColumnView1[sKey].Picture = ColumnView1[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView1Resize()
  Endif 
  If ColumnView2.Keys.Max > -1 Then 
    For Each sKey In ColumnView2.Keys
      If ColumnView2[sKey].Picture Then ColumnView2[sKey].Picture = ColumnView2[sKey].Picture.Image.Stretch(F_i22, F_i22).Picture
    Next
    ColumnView2Resize()
  Endif 
  ColumnView2.Font.Size = ColumnView1.Font.Size
  Text5.Font.Size = ColumnView1.Font.Size
  Text0.Font.Size = ColumnView1.Font.Size
  Text1.Font.Size = ColumnView1.Font.Size
  Text2.Font.Size = ColumnView1.Font.Size
  Text0b.Font.Size = ColumnView1.Font.Size
  TextBoxSearch5.Font.Size = TextBoxSearch5.H / 2
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAdd()                                                           '1x new Line at the End
  
  Dim sK0, sK1, sKeySort As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  If ColumnView1.Columns.Sort <> F_iColumnsCount Then ColumnSortSettingCentral()
  
  If ColumnView1.Selection.Max > -1 Then 
    sK0 = ColumnView1.Selection.Last 
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    sK1 = ColumnView1.Count + 1 '=>Add After Last Key .count-1
    If ColumnView1.Exist(sK1) = False Then 
      sKeySort = ColumnView1[sK0][F_iColumnSort] & ".1" 
      ColumnView1.UnselectAll()
      PicAdd = ColumnViewImages("PicAdd").Picture 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                    'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][1] = ""
      ColumnView1[sK1][F_iColumnSort] = sKeySort   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1][F_iColumnNr] = sK1 
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
    Endif 
  Else 
    ColumnViewAddMin1xCount()
    M = ColumnView1.MoveLast() 'M=0=False>Exist. M=-1=True>Missing
    If M = 0 Then sK0 = ColumnView1.Item.Key Else sK0 = ColumnView1.Count 
    If ColumnView1.Exist(sK0) = True Then 
      ColumnView1[sK0].Selected = True
      ColumnView1[sK0].EnsureVisible()  
    Endif 
    ColumnSortSettingCentral()
    
    ListAdd.Background = Color.Red
    ColumnViewInfo(F_sCVinfoSelectLineFirst)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddAppend()                                                          '1x new Line at end
  
  Dim sK0, sK1 As String 
  Dim PicAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
  PicAdd = ColumnViewImages("PicAdd").Picture 
  '.Header=True is first Line (Title)
  
  M = ColumnView1.MoveLast()
  If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
    sK0 = ColumnView1.Item.Key                                'only Keys     index 0,1,2,3... Keys "1","2","3"...
    ColumnView1[sK0].EnsureVisible()  
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    ColumnView1.UnselectAll()
    M = ColumnView1.MoveNext() 'M=0=False>Exist. M=-1=True>Missing
    If M = -1 Then sK1 = ColumnView1.Count + 1 '+Plus new Line at the End
    If ColumnView1.Exist(sK1) = False Then 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                  'Add Last (default), Add After (sK0) 
      ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
      ColumnView1[sK1][F_iColumnNr] = sK1
      ColumnView1[sK1][F_iColumnSort] = sK1                                   '|0|1|2|3|...|F_iColumnSort|...
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
      M = ColumnView1.MoveLast()
      ColumnViewSort(F_iColumnSort)
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Endif 
  Else 
    ColumnViewAddMin1xCount()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewAddMin1xCount()
  
  Dim sK1 As String 
  Dim PicAdd As Picture
  
  If ColumnView1.Keys Then '1 > only Header (Title)
    If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize()
    sK1 = ColumnView1.Count + 1
    PicAdd = ColumnViewImages("PicAdd").Picture 
    ColumnView1.Add(sK1, "", PicAdd)
    ColumnView1[sK1][F_iColumnSelect] = "PicAdd"
    ColumnView1[sK1][1] = ""
    ColumnView1[sK1][F_iColumnSort] = sK1   '|0|1|2|3|...|F_iColumnSort|...
    ColumnView1[sK1][F_iColumnNr] = sK1 
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnSortSettingCentral()
  
  ColumnView1.Mode = Select.Multiple
  If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
  ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
  If ColumnView1.Columns.Sort <> F_iColumnSort Then ColumnView1.Columns.Sort = F_iColumnSort 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewSort(Optional iSortColumnNr As Integer = 0)
  
  Dim sKey As String 
  Dim M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If iSortColumnNr < ColumnView1.Columns.Count Then 
      ColumnView1.Sorted = True 'Important (wichtig)
      ' If ColumnView1.Sorted = False Then ColumnView1.Sorted = True 'faster
      ColumnView1.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView1.Columns.Sort <> iSortColumnNr Then ColumnView1.Columns.Sort = iSortColumnNr 
      If ColumnView1.Selection.Max > -1 Then
        sKey = ColumnView1.Selection.Last  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView1.MoveLast()
        If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible()  'in the visible area
    Endif 
  Else ''ColumnView2:
    If iSortColumnNr < ColumnView2.Columns.Count Then 
      ColumnView2.Sorted = True 'Important (wichtig)
      ' If ColumnView2.Sorted = False Then ColumnView2.Sorted = True 'faster
      ColumnView2.Columns.Ascending = True 'A-Z, 0-1  Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Ascending = ListCheckBoxAZ.Value
      If ColumnView2.Columns.Sort <> iSortColumnNr Then ColumnView2.Columns.Sort = iSortColumnNr 
      If ColumnView2.Selection.Max > -1 Then
        sKey = ColumnView2.Selection[ColumnView2.Selection.Max]  'only Key, Example: sKey = "9"
      Else 
        M = ColumnView2.MoveLast()
        If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      Endif
      If ColumnView2.Exist(sKey) = True Then ColumnView2[sKey].EnsureVisible()  'in the visible area
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewRefresh() 
  
  Dim sK1 As String 
  Dim PicEmpty As Picture
  Dim iLine As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView1[sK1][0] = "" Or ColumnView1[sK1][5] = "" Then
        ColumnView1.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView1[sK1].Picture = PicEmpty
        ColumnView1[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView1[sK1].Background = Color.Default
        ColumnView1[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
    
  Else ''ColumnView2:
    PicEmpty = ColumnViewImages("PicEmpty").Picture 
    
    ColumnSortSettingCentral()
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      If ColumnView2[sK1][0] = "" Or ColumnView2[sK1][5] = "" Then
        ColumnView2.Remove(sK1) 'cut, delete, empty
      Else 
        ColumnView2[sK1].Picture = PicEmpty
        ColumnView2[sK1][F_iColumnSelect] = "PicEmpty"
        ColumnView2[sK1].Background = Color.Default
        ColumnView2[sK1].Foreground = Color.Default
      Endif 
    Next 
    If F_bESCpressedON = False Then  
      ColumnViewAddMin1xCount()
      ColumnViewSort(F_iColumnSort)
      ColumnViewInfo("Aufgeräumt")
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewBackup()
  
  Dim iColumn, iLine, iBackupsMax As Integer 
  Dim sK1, sLine As String
  Dim hColumnView As New F_multiColumnViewValues 'see Form head▲
  
  '****************
  iBackupsMax = 30
  '****************
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Columns.Count <> F_iColumnsCount Then ColumnView1Resize()
    If Not F_ooCVBackups Then F_ooCVBackups = New Object[]
    hColumnView.iMode = ColumnView1.Mode 'Multi or Single
    hColumnView.iScrollY = ColumnView1.ScrollY
    hColumnView.iSortColumn = ColumnView1.Columns.Sort
    hColumnView.bSortAscending = ColumnView1.Columns.Ascending   'A-Z, 0-1  Ascending▲ or Descending▼ (False)
    hColumnView.bSorted = ColumnView1.Sorted 'as Boolean
    hColumnView.ssKeys = Null 
    hColumnView.ssLines = New String[]
    
    For Each sK1 In ColumnView1.Keys
      iLine = iLine + 1
      If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak() = True Then Break
      Endif 
      
      ''Selected on?
      If ColumnView1[sK1].Selected = False Then 
        ColumnView1[sK1][F_iColumnSelect] = Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'False
      Else 
        ColumnView1[sK1][F_iColumnSelect] = "-" & Replace(ColumnView1[sK1][F_iColumnSelect], "-", "") 'True
      Endif 
      
      sLine = "" 'Reset
      For iColumn = 0 To ColumnView1.Columns.Max
        sLine = sLine & ColumnView1[sK1][iColumn] & gb.NewLine 'Note: gb.Tab in Column Undo
      Next 
      hColumnView.ssLines.Add(sLine) 'Not forget: New String[]
    Next 
    If F_bESCpressedON = False Then 
      hColumnView.ssKeys = ColumnView1.Keys '-1 Null
      
      ''Backup:   
      F_ooCVBackups.Add(hColumnView) 'added at the end
      
      If F_ooCVBackups.Max > iBackupsMax Then 
        F_ooCVBackups.Delete(1, 1)    'Object Position 1, 1x
        F_ooCVBackups.Remove(1, 1)    '0,|x|,2,3...removed first List-Nr 1x, not 0. -1 all Rest until End
        ' If F_ooCVBackups.Count > 1 Then F_ooCVBackups.Delete(1, 1) '?
      Endif 
      F_iCVUndoRedoPointer = F_ooCVBackups.Max
      CVUndoRedoLabelCounter()  'Example: "0/0"
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewUndoRedo()
  
  Dim it, iLine As Integer   
  Dim sK1, sPicName, sLine As String 
  Dim ssColumns As String[]
  Dim hColumnView As New F_multiColumnViewValues
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    If F_ooCVBackups Then 
      ' PicEmpty = ColumnViewImages("PicEmpty").Picture
      If F_iCVUndoRedoPointer < 0 Then F_iCVUndoRedoPointer = 0
      If F_iCVUndoRedoPointer > F_ooCVBackups.Max Then F_iCVUndoRedoPointer = F_ooCVBackups.Max
      
      hColumnView = F_ooCVBackups[F_iCVUndoRedoPointer] 'Object Position, 1x
      If TypeOf(hColumnView) = gb.Object Then '16 Struct
        ColumnView1.Mode = hColumnView.iMode  'Multi or Single
        ' ColumnView1.ScrollY = hColumnView.iScrollY '->see End
        If ColumnView1.Sorted <> hColumnView.bSorted Then ColumnView1.Sorted = hColumnView.bSorted 'faster
        If ColumnView1.Columns.Sort <> hColumnView.iSortColumn Then ColumnView1.Columns.Sort = hColumnView.iSortColumn
        ColumnView1.Columns.Ascending = hColumnView.bSortAscending 'as Boolean
        ' ColumnView1.Keys 'Read only. hColumnView.ssKeys -> ColumnView1.Keys.Insert()
        
        ''Empty?
        If Not hColumnView.ssKeys Then 
          ColumnView1.Clear()
          ColumnSortSettingCentral()
        Else 
          ColumnView1.Keys.Insert(hColumnView.ssKeys)
          If hColumnView.ssLines.Count < ColumnView1.Count Then hColumnView.ssLines.Resize(ColumnView1.Count)
          
          iLine = 0
          If hColumnView.ssKeys Then
            For Each sK1 In ColumnView1.Keys
              sLine = hColumnView.ssLines[iLine]
              iLine = iLine + 1
              If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
              ''[ESC]?
              If F_bESCpressedON = True Then 
                If MessageQuestionBreak() = True Then Break
              Endif 
              
              ssColumns = Split(sLine & String(ColumnView1.Columns.Count, gb.NewLine), gb.Newline) 'Note: gb.Tab in Column Undo
              For it = 0 To ColumnView1.Columns.Max
                ColumnView1[sK1][it] = ssColumns[it]
              Next 
            Next 
          Else 
            ColumnView1.Clear()
          Endif 
          
          ''Selection + Pictures:
          For Each sK1 In ColumnView1.Keys
            iLine = iLine + 1
            If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
            ''[ESC]?
            If F_bESCpressedON = True Then 
              If MessageQuestionBreak() = True Then Break
            Endif 
            
            ''Selected on? 
            If String.InStr(ColumnView1[sK1][F_iColumnSelect], "-") = 0 Then   'True "-1", False "0"
              ColumnView1[sK1].Selected = False 
              ' ColumnView1[sK1].Background = Color.Default
              ColumnView1[sK1].Foreground = Color.Default
              If String.InStr(ColumnView1[sK1][F_iColumnSelect], "PicMarkGreen") > 0 Then 'Flag
                ColumnView1[sK1].Background = F_iColorGreenAlpha150
                ColumnView1[sK1].Foreground = F_iColorForegroundBlue
              Endif 
            Else 
              ColumnView1[sK1].Selected = True
              ColumnView1[sK1].Background = F_iColorGreenAlpha220
              ColumnView1[sK1].EnsureVisible()
            Endif 
            sPicName = ColumnView1[sK1][F_iColumnSelect]
            ColumnView1[sK1].Picture = ColumnViewImages(sPicName).Picture 'without "-"
          Next
          ColumnViewSort(F_iColumnSort) 
          ColumnView1.ScrollY = hColumnView.iScrollY
        Endif 
      Endif
    Endif
    
    CVUndoRedoLabelCounter() 'Example: "0/0"
    F_bSaved = False
  Else ''ColumnView2: 
    ColumnViewInfo(("Such-Liste ohne Rückgängig / Wiederherstellen")) ' Search-List without Undo/Redo
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CVUndoRedoLabelCounter()
  
  Dim sText, T1, T2, sSpace, sMin, sMax As String 
  
  sSpace = Space(1)
  sMin = ("min.")
  sMax = ("max.")
  If F_ooCVBackups Then 
    T1 = Str(F_ooCVBackups.Max)
    sText = T1
    If F_iCVUndoRedoPointer <= F_ooCVBackups.Max Then sText = Str(F_iCVUndoRedoPointer) & "/" & T1
  Else 
    T1 = "0"
    sText = T1 & "/" & T1
  Endif 
  If F_ooDateTimeNoticeBackup Then
    T2 = Str(F_ooDateTimeNoticeBackup.Max)
  Else 
    T2 = "0"
  Endif
  ListBackupCounter.Text = sText
  ListBackupCounter.Tooltip = ("<rückgängig") & sSpace & sText & sSpace & ("wiederherstellen>")
  
  MenuUndoMin1.Text = "0/" & T1 & sSpace & sMin
  MenuRedoMax1.Text = T1 & "/" & T1 & sSpace & sMax
  
  MenuUndoMin2.Text = "0/" & T2 & sSpace & sMin
  MenuRedoMax2.Text = T2 & "/" & T2 & sSpace & sMax
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewInfo(Optional CVText As String = "")
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then  
    If CVText = "" Then  
      If ColumnView1.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView1.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView1.Selection.Count) & Space(1) & ("Edit") 
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView1.Columns.Max < 4 Then ColumnView1Resize()
    ColumnView1.Columns[5].Title = CVText
    
  Else ''ColumnView2:
    If CVText = "" Then  
      If ColumnView2.Count < 2 Then '1 > only Header (Title)
        CVText = ("Leer. Eine Datei öffnen.")
      Else If ColumnView2.Selection.Max = -1 Then
        CVText = F_sCVinfoSelectLineFirst 
      Else 
        CVText = Str(ColumnView2.Selection.Count) & Space(1) & ("Edit")
      Endif 
    Endif 
    
    LabelInfo.Alignment = Align.Center
    LabelInfo.Text = CVText
    LabelInfo.Tooltip = CVText
    LabelInfo.Visible = True
    LabelInfo.Raise
    If ColumnView2.Columns.Max < 4 Then ColumnView2Resize()
    ColumnView2.Columns[5].Title = CVText
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewFind(Optional UpDown As String = "+")
  
  Dim M, it, iLine, iPosition As Integer
  Dim sK1, sText, sFindText As String 
  
  If ColumnView2.Visible = False Then 
    If ColumnView1.Count > 0 Then 
      sFindText = TextListSearch.Text
      sFindText = String.LCase(Replace(sFindText, gb.NewLine, "", gb.String))
      PanelSearchList.Visible = True 
      PanelDatum.Visible = False 
      M = ColumnView1.MoveCurrent()
      If ColumnView1.Mode <> Select.Single Then ColumnView1.Mode = Select.Single
      TextListSearch.Foreground = Color.DarkRed
      For it = 0 To ColumnView1.Count - 1 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        If UpDown = "+" Then 
          M = ColumnView1.MoveBelow() '▼
          If M = -1 Then M = ColumnView1.MoveFirst() 'M=0=False>Exist. M=-1=True>Missing
        Else 
          M = ColumnView1.MoveAbove() '▲
          If M = -1 Then M = ColumnView1.MoveLast()  
        Endif 
        If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
          sK1 = ColumnView1.Item.Key
          sText = String.LCase(ColumnView1[sK1][F_iColumnUndo]) 
          iPosition = String.InStr(sText, sFindText)  
          If iPosition > 0 Then Break
        Endif 
      Next
      If iPosition > 0 Then
        ColumnView1[sK1].Selected = True 
        ColumnView1[sK1].EnsureVisible
        TextListSearch.Foreground = Color.DarkGreen
        ListFound.Picture = PicTemplateApply.Picture
        ListFound.Visible = True 
        ListFound.Raise
        If String.Len(sK1) < 4 Then 
          LabelSearchLineNr.Text = ("Zeile") & Space(1) & sK1 'only Key (Nummer)  
        Else 
          LabelSearchLineNr.Text = sK1 'only Key (Nummer)  
        Endif 
      Else 
        Try ListFound.Picture = PicTemplateQuestionRound.Picture '[?]
        ListFound.Visible = True 
        ListFound.Raise
        LabelSearchLineNr.Text = ("Zeile") & Space(1) & "?"
      Endif 
      ButtonSearchPanel.Background = TextListSearch.Foreground
    Endif 
  Else 
    If UpDown = "+" Then ColumnView2.SelectAll() Else ColumnView2.UnSelectAll()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub Menu1Group_Click()
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ColumnViewCheckBoxAbc()
  
  Dim sKey, sK1, sSort As String
  Dim ssKeys, ssSort As New String[]
  Dim it, iLine, it2, M As Integer
  
  ''ColumnView1:
  If ColumnView2.Visible = False Then 
    ColumnView1.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView1.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView1[sKey][0] & ColumnView1[sKey][1] '0000-00-00 & 00:00
        If ColumnView1[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView1[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView1.Sorted = True
      ' ColumnView1.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView1.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        If ColumnView1.Exist(sK1) = True Then ColumnView1[sK1][F_iColumnSort] = iLine
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView1.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView1[sKey][F_iColumnSort] = ColumnView1[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView1.Count > 1 Then '1 > only Header (Title)
      ColumnView1.Sorted = True 
      ColumnView1.Columns.Ascending = True
      ColumnView1.Columns.Sort = F_iColumnSort
      M = ColumnView1.MoveLast()
      If M = 0 Then sKey = ColumnView1.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView1.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then 
        ColumnView1[sKey].Selected = True 
        ColumnView1[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
    
  Else ''ColumnView2:
    ColumnView2.Sorted = False 
    
    If F_bCheckBoxAbc = False Then 
      F_bCheckBoxAbc = True
      For Each sKey In ColumnView2.Keys 
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        sSort = ColumnView2[sKey][0] & ColumnView2[sKey][1] '0000-00-00 & 00:00
        If ColumnView2[sKey][0] = "" Then 
          sSort = "9999-99-9999:99"  'Line at the End
        Endif 
        it = it + 1
        sSort = sSort & it
        ColumnView2[sKey][F_iColumnSort] = sSort
        ssKeys.Add(sSort & "=" & sKey)
      Next 
      If F_bESCpressedON = True Then Goto Ende
      
      ssKeys.Sort()
      
      ' ColumnView2.Sorted = True
      ' ColumnView2.Columns.Ascending = True 'Z-A, 1-0 Ascending▲ or Descending▼ (False)
      ' ColumnView2.Columns.Sort = F_iColumnSort
      
      For it = 0 To ssKeys.Max
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ssSort = Split(ssKeys[it] & "=", "=")
        sK1 = ssSort[1]
        it2 = it2 + 1
        If ColumnView2.Exist(sK1) = True Then ColumnView2[sK1][F_iColumnSort] = it2
      Next 
    Else 
      F_bCheckBoxAbc = False
      For Each sKey In ColumnView2.Keys
        iLine = iLine + 1
        If iLine Mod 100 = 0 Then ProgressBarONoff(True) 
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak() = True Then Break
        Endif 
        
        ColumnView2[sKey][F_iColumnSort] = ColumnView2[sKey][F_iColumnNr] '1,2,3,...
      Next 
    Endif 
    
    If ColumnView2.Count > 1 Then '1 > only Header (Title)
      ColumnView2.Sorted = True 
      ColumnView2.Columns.Ascending = True
      ColumnView2.Columns.Sort = F_iColumnSort
      M = ColumnView2.MoveLast()
      If M = 0 Then sKey = ColumnView2.Item.Key 'M=0=False>Exist. M=-1=True>Missing
      If ColumnView2.Exist(sKey) = False Then sKey = ColumnViewCurrentKey()
      If ColumnView2.Exist(sKey) = True Then 
        ColumnView2[sKey].Selected = True 
        ColumnView2[sKey].EnsureVisible()
      Endif
    Endif  
    ColumnAbcInfo()
  Endif 
Ende:
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnAbcInfo()
  
  Dim sInfo As String 
  
  If F_bCheckBoxAbc = False Then 
    sInfo = ("Datei")
  Else 
    sInfo = ("Datum")
  Endif 
  ListCheckBoxAZLabel.Text = sInfo 
  ListCheckBoxAZ.Picture = ListCheckBoxAZ.Picture.Image.Mirror(False, True).Picture
  ColumnViewAscending()
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnViewListChangeLED() '○ ●
  
  If F_iCVUndoRedoPointerSave > 0 And F_iCVUndoRedoPointer < F_iCVUndoRedoPointerSave Then
    ListIsChanged.Picture = PicTemplateLEDyellow.Picture
  Else If F_iCVUndoRedoPointer < 2 Or F_iCVUndoRedoPointer = F_iCVUndoRedoPointerSave Then 
    ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Else 
    ListIsChanged.Picture = PicTemplateLEDred.Picture
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListButtonsRefresh()
  
  Dim iColor As Integer
  ''Reset
  LabelInfo.Visible = False
  iColor = Color.Default
  If ListDown.Background <> iColor Then ListDown.Background = iColor
  If ListUp.Background <> iColor Then ListUp.Background = iColor
  If ListCut.Background <> iColor Then ListCut.Background = iColor
  If ListCopy.Background <> iColor Then ListCopy.Background = iColor
  If ListPaste.Background <> iColor Then ListPaste.Background = iColor
  If ListSelectAll.Background <> iColor Then ListSelectAll.Background = iColor
  If ListAdd.Background <> iColor Then ListAdd.Background = iColor
  If ListMark.Background <> iColor Then ListMark.Background = iColor
  If ListRefresh.Background <> iColor Then ListRefresh.Background = iColor
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True
  If Object.Type(Last) = "Button" Then Last.Background = F_iColorGreenAlpha150
  If Object.Type(Last) = "PictureBox" Then Last.Background = F_iColorGreenAlpha150 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Blue 
  If Object.Type(Last) = "Label" Then Last.Background = F_iColorGreenAlpha150
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = F_iColorGreenAlpha150 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = F_iColorGreenAlpha150
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = F_iColorGreenAlpha150 
    ListCheckBoxAZLabel.Background = F_iColorGreenAlpha150 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ListMenuGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False
  If Object.Type(Last) = "Button" Then Last.Background = Color.Default
  If Object.Type(Last) = "PictureBox" Then Last.Background = Color.Default 
  If Object.Type(Last) = "CheckBox" Then Last.Foreground = Color.Default 
  If Object.Type(Last) = "Label" Then Last.Background = Color.Default
  If Last.Tag = TextUndo.Tag Then PanelText5.Background = Color.Default 
  If Last.Tag = TextRedo.Tag Then PanelText5.Background = Color.Default
  If Last.Tag = ListCheckBoxAZ.Tag Then 
    ListCheckBoxAZ.Background = Color.Default 
    ListCheckBoxAZLabel.Background = Color.Default 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ColorPicButtonReplace()
  
  Dim cPic As Picture
  
  cPic = ListSelectAll.Picture
  cPic = cPic.Image.Replace(Color.Black, Color.SelectedBackground).Picture  '(Oldcolor, Newcolor)
  ListSelectAll.Picture = cPic
  
Catch 
  FMain.ErrorText
  
End

Public Sub TextBoxSearch5_MouseDown()
  
  If TextBoxSearch5.Text = ("Suche") Then TextBoxSearch5.Text = ""
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then 
    Last.Border = True 
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150 
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = True 
      LabelInfoPathG(TextBoxPath.Text)
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Blue
    Case "new" 
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "linenumber"
      ColumnView1.Background = F_iColorGreenAlpha220
    Case "moreswitches"
      PanelListMenu.Background = F_iColorGreenAlpha150
    Case "text5resize", "searchtext5"
      PanelText5.Background = F_iColorGreenAlpha150
    Case "arrowpaste"
      TextBackgroundAll(F_iColorGreenAlpha150)
    Case "newplus"
      Text0.Visible = False 
      Text0b.Visible = False 
      Text1.Visible = False
      Text2.Visible = False
      Text5.Visible = False 
      TextBackgroundAll(Color.White)
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Top = MoveLine.Top - PfeilEinfuegen.H
      PfeilEinfuegen.Border = True 
      PfeilEinfuegen.Background = F_iColorGreenAlpha150
    Case "save" 
      ColumnView1.Background = F_iColorGreenAlpha220
      LabelInfoPathG(FilePathForm())
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.Plain
      Last.Background = F_iColorBlue
      TextBoxPath.Foreground = Color.Default
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = True
      ButtonSum.Background = F_iColorGreenAlpha150
      ButtonDauer.Border = True
      ButtonDauer.Background = F_iColorGreenAlpha150
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = F_iColorGreenAlpha150
  End Select
  
  If FMain.F_sErrorInfos Then 
    IconError.Visible = True 
    IconError.Raise() '▲Top▲
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Last.Tag = ButtonDateCancel.Tag Then 
    '...
  Else If Object.Type(Last) = "Button" Then
    Last.Border = False 
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Else If Object.Type(Last) = "CheckBox" Then
    If Last.Background <> Color.Green Then Last.Background = Color.Default
  Endif  
  
  Select Case String.LCase(Last.Tag)
    Case "fileinfo"
      LabelInfo.Visible = False 
    Case "info"
      LabelInfo.Visible = False
    Case "allyears" 'Checkboxes without .Border
      Last.Foreground = Color.Default
    Case "new"
      TextBackgroundAll(Color.Transparent)
    Case "linenumber"
      ColumnView1.Background = Color.Transparent
    Case "moreswitches"
      PanelListMenu.Background = Color.Transparent
    Case "text5resize", "searchtext5"
      PanelText5.Background = Color.Transparent
    Case "arrowpaste"
      TextBackgroundAll(Color.Transparent)
    Case "newplus"
      Text0.Visible = True   
      Text0b.Visible = True  
      Text1.Visible = True
      Text2.Visible = ButtonSum.Visible  
      Text5.Visible = True 
      TextBackgroundAll(Color.Transparent)
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "newline" ' ButtonAdd.Tag
      PfeilEinfuegen.Background = Color.Default
      PfeilEinfuegen.Top = PanelDatum.Top 
      PfeilEinfuegen.Border = False 
    Case "save"
      ColumnView1.Background = Color.Transparent
    Case "pathbg" 'Panel Path-Background
      Last.Border = Border.None
      Last.Background = Color.Default
      TextBoxPath.Foreground = Color.Gray
    Case "dauer" 'Duration 00:00 - 00:00 = 00:00:00
      ButtonSum.Border = False
      ButtonSum.Background = Color.Default
      ButtonDauer.Border = False
      ButtonDauer.Background = Color.Default
    Case ButtonSearchPanel.Tag, ButtonSearchListOn.Tag, ButtonSearchDown.Tag, ButtonSearchUp.Tag, SaveSelection.Tag, ButtonSearchCancel.Tag
      Last.Border = True 
      If Last.Background <> Color.Green Then Last.Background = Color.Default
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseUp() 'PictureBox
  
  If Object.Type(Last) = "PictureBox" Or Object.Type(Last) = "Label" Then ButtonGroupSelect(Last.Tag)
  If Mouse.Right = True And Last.Tag = CheckBox1.Tag Then ButtonGroupSelect("birthdaysoutside")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click() 'Click with Buttons or Menue
  
  ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "Left")
  
  Dim sKey, sPath, sDir, sFile As String  
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form2Bearb.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  ' ColumnViewAddMin1xCount()
  sMouseLMR = String.Lower(String.Left(sMouseLMR, 1)) 'Example: "L" '> Left, Middle, Right
  
  Select Case String.LCase(sLastTag)
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
    Case "add"
      ButtonPathAddG()
    Case "opentermine"
      sPath = FilePathForm() 
      ReadG(sPath, True) 'True: with Dialog
    Case "openbackup"
      sPath = M01Functions.OpenBackupDirFile(FilePathForm())
      sPath = FileDialogPathReturn(sPath, "openbackup", FilePathForm()) 'autom.: "All files(*.*) 'Last-Path, open/save, Standard-Path
      If Exist(sPath) = True Then ReadG(sPath, True) 'True: with Dialog
    Case "birthdaysoutside" 'Outside —▶
      GeburtstageAuslagernG() '(Auslagern nach F_sPathEveryYear)
    Case "birthdaysinside" 'Inside ◀—
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      ReadG(sPath, True) 'True: with Dialog
    Case "newplus"
      Text0Insert(Format(Date, "yyyy-mm-dd"))
      Text0bInsert(Format(Date, "yyyy-mm-dd"))
      Text1Insert(Format(Time, "hh:nn"))
      Text2Insert(Format(Time, "hh:nn"))
      Text5Insert("")
      PanelText5.Background = Color.White
      ColumnView1.UnselectAll()
      NewLineG()
    Case "reload"
      ColumnViewReload()
    Case "save"
      SaveG()
    Case "saveascopy"
      sPath = FilePathForm()
      sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
      sFile = File.Name(sPath) & "_copy." & File.Ext(sPath)
      sPath = FileDialogPathReturn(sDir &/ sFile, "save", sPath)
      If sPath Then  'Null = Canceled
        If Exist(sPath) = False Then File.Save(sPath, "empty")
        If Exist(sPath) = True Then SaveG(sPath)
      Endif 
      
    Case "exportselection"
      ExportSelectionG()
    Case "termineauslagern"
      TermineAuslagernG()
    Case "termineeinlagern"
      TermineEinlagernG()
    Case "openfeiertageplus"
      If Settings[FMain.Name &/ "OsterSonntag", ""] = "" Then M03Feiertage.HolidaysCalculate() 'Calculeted Holidays
      Form8ZusFeiertage.Window.Show
      Form8ZusFeiertage.Visible = True
    Case "editortermine"
      sPath = FilePathForm()
      M01Functions.FileToForm3Text(sPath)
    Case "editorbirthdays"
      sPath = Settings[FMain.Name &/ "F_sPathEveryYear", FMain.F_sPathEveryYear]
      If Exist(sPath) = False Then sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ File.Name(sPath)
      M01Functions.FileToForm3Text(sPath)
    Case "exportzeichensatz"
      Form13Export.Window.Show
      ' Form13Export.Window.Visible = True  'Wayland error?
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "newline"
      ColumnView1.UnselectAll()
      NewLineG()
    Case "inputline"
      If F_iMusterTermine1Names2Projects3 = 2 Then CheckProjectOnlyName(Text5.Text) 'Test
      ButtonInputG()
      TextBackgroundAll(Color.Transparent)
      
    Case "windowt5plus"
      WindowT5plusG()
    Case "new"
      TextNeuClear()
    Case "searchpanel"
      ButtonSucheG()
    Case "searchpanel5notice"
      PanelSearchText5.Visible = True 
      PanelSearchText5.Raise
      F_iText5SearchPosition = 0
      TextBoxSearch5.SetFocus
    Case "cancelsearch5"
      PanelSearchText5.Visible = False
    Case "searchtext5"
      Text5Search()
    Case "text5resize"
      Text5Resize()
    Case "arrowpaste"
      PasteLineArrow()
      TextBackgroundAll(Color.White)
    Case "cancelbutton"
      SelectHide0Date1Clock2Timer3(0) ' Cancel (Abbrechen)
    Case "moreswitches"
      MoreButtonsG()
    Case "searchbutton", "search"
      ButtonSearchG()
      If ColumnView2.Visible = True Then ColumnViewFind("+") '↓
    Case "searchdown"
      ColumnViewFind("+") '↓
    Case "searchup"
      ColumnViewFind("-") '↑
    Case "searchliston"
      If ButtonSearchListOn.Background <> Color.Green Then ButtonSearchListOn.Background = Color.Green Else ButtonSearchListOn.Background = Color.Default
      SearchListG()
    Case "searchpanel"
      ListMenuGroupFunctions("searchpanel")
    Case "cancelsearch"
      CancelSearchG()
    Case "saveselection"
      SaveSelectionG()
    Case "labeldateinfo"
      LabelDatumInfo()
    Case "labeltimer"
      LabelTimerG()
    Case "linenumber"
      sKey = ColumnViewCurrentKey()
      If ColumnView1.Exist(sKey) = True Then ColumnView1[sKey].EnsureVisible
    Case "fileinfo"
      FileInfoG()
    Case "title"
      CheckProjectOnlyName(Text5.Text) 'Test
    Case "close"
      ButtonCancelG()
      
      'Extra:
    Case "csv"
      ButtonExternStartG(Last.Tag)
    Case "projectname"
      PanelText5.Background = Color.White
      Text5.Pos = String.Len(Text5.Text)
      ' Text5.SetFocus
    Case "allyears"
      If F_iMusterTermine1Names2Projects3 = 1 Then CheckBox1G()
    Case "buttonprojecton"
      If F_iMusterTermine1Names2Projects3 = 2 Then 
        CheckBoxONoff.Value = Not CheckBoxONoff.Value
        ProjectONoff(CheckBoxONoff.Value)
      Endif 
    Case "checkbox"
      ' If F_iMusterTermine1Names2Projects3 = 2 Then ProjectONoff(CheckBoxONoff.Value)
    Case "t4", "dauer" 'Duration Button 00:00:00
      If F_iMusterTermine1Names2Projects3 = 3 Then ButtonInputCheck() '=calculate new (neu berechnen)
      TextBackgroundAll(Color.White)
    Case "bis"
      If F_iMusterTermine1Names2Projects3 = 1 Then ButtonUntil()
      
  End Select
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ListMenuGroup_Click() '—▶ Menu _Click!
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroup_MouseDown() 'PanelListMenu □ □ □ □ □ □ □ □
  
  ListMenuGroupFunctions(Last.Tag)
  
End

Public Sub ListMenuGroupFunctions(Optional sLastTag As String = "")
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  Form2Bearb.Window.Title = F_sTitleBasicText
  F_bESCpressedON = False
  LabelInfo.Text = "" 
  
  If ColumnView1.Columns.Max > -1 Then 
    ListButtonsRefresh()
    If Not F_ooCVBackups Then ColumnViewBackup()
    
    Select Case String.LCase(sLastTag)
      Case "selectall"
        ColumnViewSelectAll() 'SelectAll<>UnselectAll
      Case "unselectall"
        ColumnView1.UnselectAll()  
      Case "selectall2"
        ColumnView2.Mode = Select.Multiple
        ColumnView2.SelectAll()  
        ColumnView2to1()
      Case "unselectall2" 
        ColumnView2.UnselectAll()
        ColumnView2to1()
      Case "copy"
        ColumnViewCopy()
      Case "copy2"
        ColumnViewCopy()
      Case "cut" 'delete, remove
        ColumnViewCut()
      Case "cut2"
        ColumnViewCut()
        ColumnView2to1()
      Case "new" 'Clear
        TextNeuClear()
      Case "add", "+1x"
        ColumnViewAdd()
      Case "addappend"
        ColumnViewAddAppend()
      Case "paste", "insert" 
        ColumnViewPaste()
      Case "up"
        ColumnViewUp()
      Case "down"
        ColumnViewDown()
      Case "markgreen"
        ColumnViewMarkGreen()
      Case "refresh", "clean" ', "reload"  'new Numbers 1,2,3...
        ColumnViewRefresh()
        ColumnView1Resize()
      Case "reload"
        ColumnViewReload()
      Case "searchpanel"
        SearchPanelG()
      Case "sortabc"
        ColumnViewCheckBoxAbc()
      Case "original"
        ColumnViewOrig()
      Case "original2"
        ColumnViewOrig()
        ColumnView2to1()
        
      Case "undotext5max0"
        F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max - 0
        UndoRedoText5Pointer("select")
      Case "undotext5max1"
        F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max - 1
        UndoRedoText5Pointer("select")
      Case "undotext5max2"
        F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max - 2
        UndoRedoText5Pointer("select")
      Case "undotext5max3"
        F_iUndoRedoText5Pointer = F_ssUndoRedoText5.Max - 3
        UndoRedoText5Pointer("select")
        
      Case "openbackuptext5"              
        Form1FileOpen.Tag = Text5TempPathReturn()
        Form1FileOpen.Window.Show
      Case "undo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer - 1
        ColumnViewUndoRedo()
      Case "counterlabel"
        MenuUndoRedo.Popup
      Case "redo"
        F_iCVUndoRedoPointer = F_iCVUndoRedoPointer + 1
        ColumnViewUndoRedo()
      Case "undomin"
        F_iCVUndoRedoPointer = 0
        ColumnViewUndoRedo()
      Case "redomax"
        F_iCVUndoRedoPointer = F_ooCVBackups.Max
        ColumnViewUndoRedo()
      Case "undotext"
        DateTimeNoticeBackup("<")
      Case "redotext"
        DateTimeNoticeBackup(">")
      Case "undotextmin"
        F_iDateTimeNoticeBackupPointer = 0
        DateTimeNoticeBackup("<")
      Case "redotextmax"
        F_iDateTimeNoticeBackupPointer = F_ooDateTimeNoticeBackup.Max
        DateTimeNoticeBackup(">")
      Case "textundo"
        Text5.Undo()
      Case "textredo"
        Text5.Redo()
      Case "sortpics"
        ColumnViewSortPics()
      Case "correct"
        ColumnViewCorrectLines()
      Case "double"
        ColumnViewDouble()
      Case "compare1"
        ColumnViewCompare(False)
      Case "compare2"
        ColumnViewCompare(True)
      Case "aplus" 'A+
        If F_i22 < 22 Then 
          F_i22 = 22  'greater (groesser) +
        Else 
          F_i22 = 16 
        Endif 
        ColumnViewCheckAplus()
    End Select
    
    Select Case String.LCase(sLastTag)
      Case "selectall", "unselectall", "save", "changed", "counterlabel", "searchpanel"
      Case "undo", "redo", "undomin", "redomax", "textundo", "textredo", "undotext", "redotext", "undotextmin", "redotextmax"
      Case "double", "compare1", "compare2", "aplus"
        '... making no backup
      Case Else 
        F_bListChanged = True
        ColumnViewBackup()
    End Select
  Endif 
  ColumnViewListChangeLED()
  If LabelInfo.Text = "" Then ColumnViewInfo() 'Default Select
  WindowTitle()
  
  'Reset:
  If ProgressBar1.Visible = True Then ProgressBarONoff(False) 
  F_bESCpressedON = False
  
Catch
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise 'Top
  
End

Public Sub ColumnViewSelectAll()
  
  If ColumnView2.Visible = True Then 
    If ColumnView2.Selection.Max < 1 Then 
      ColumnView2.Mode = Select.Multiple
      ColumnView2.SelectAll()
    Else 
      ColumnView2.UnselectAll()  
    Endif 
  Else 
    If ColumnView1.Selection.Max < 1 Then 
      ColumnView1.Mode = Select.Multiple
      ColumnView1.SelectAll()
    Else 
      ColumnView1.UnselectAll()  
    Endif 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonPathAddG()
  
  Dim sPath As String 
  
  sPath = TextBoxPath.Text 
  If Settings[FMain.Name &/ "ProjectTest"] = sPath Then 
    sPath = M01Functions.DemoDiagramFile() 'as String 
    ReadG(sPath, False) 'True=Dialogfenster
  Else
    If Exist(sPath) = False Then sPath = FilePathForm()
    ReadG(sPath, False) 'True=Dialogfenster
    ' ButtonPaintDiagramG() '>Form16Diagramm
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub MoveDateTime(Optional iDate0Time1 As Integer = -1)
  
  Dim sKey, T0, T1, T2, T3, T4 As String 
  Dim date1, date2 As Date 
  Dim iDiff As Integer
  Dim PicDate, PicTime As Picture
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  If Text0.Text Like "????-??-??" Then
    SelectHide0Date1Clock2Timer3(0)
    ' date1 = M01Functions.DateCheckyyyymmddhhnn(Text0.Text, Text1.Text) 'as Date
    PicDate = ColumnViewImages("PicDate").Picture 
    PicTime = ColumnViewImages("PicTime").Picture 
    '.......................................
    iDiff = CheckMoveDateTime(iDate0Time1) 'as Integer
    '.......................................
    For Each sKey In ColumnView1.Keys
      If ColumnView1[sKey].Selected = True Then 
        If ColumnView1[sKey][0] Like "????-??-??" And String.Left(ColumnView1[sKey][5], 1) <> "*" Then 'Dates, no Timer MoDi, no Birthsdays*
          T0 = ColumnView1[sKey][0] 'Datum
          T1 = ColumnView1[sKey][1] 'Uhr
          T2 = ColumnView1[sKey][2] 'WTag von
          T3 = ColumnView1[sKey][3] 'Q
          T4 = ColumnView1[sKey][4] 'KW
          
          date1 = M01Functions.DateCheckyyyymmddhhnn(T0, T1) 'as Date
          ''Calendar, Date
          If iDate0Time1 = 0 Then date2 = DateAdd(date1, gb.Day, iDiff)
          If iDate0Time1 = 1 Then date2 = DateAdd(date1, gb.Minute, iDiff)
          
          T0 = Format(date2, "yyyy-mm-dd")
          T1 = Format(date2, "hh:nn")
          T2 = Format(date2, "ddd")
          T3 = Str(M01Functions.DateQuarterG(date2)) & ("Q")
          T4 = Format(M01Functions.DateCalenderWeek(date2), "00") & ("KW") '00...52
          ColumnView1[sKey][0] = T0
          ColumnView1[sKey][1] = T1
          ColumnView1[sKey][2] = T2
          ColumnView1[sKey][3] = T3
          ColumnView1[sKey][4] = T4
          If iDate0Time1 = 0 Then 
            ColumnView1[sKey].Picture = PicDate
            ColumnView1[sKey][F_iColumnSelect] = "PicDate"
          Else 
            ColumnView1[sKey].Picture = PicTime
            ColumnView1[sKey][F_iColumnSelect] = "PicTime"  
          Endif 
          F_bListChanged = True
          F_iListChangedCounter = F_iListChangedCounter + 1
        Endif 
      Endif 
    Next 
    ButtonSave.Background = Color.Red
    ButtonInput.Background = F_iColorGreen
    ColumnViewBackup()
    ColumnViewListChangeLED()
    ProgressBarONoff(False)
  Else 
    ColumnViewInfo(("Datum fehlt, Muster: yyyy-mm-dd"))
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MoveMinutes(Optional iMinutes As Integer = 0)
  
  Dim sKey, T0, T1, T2, T3, T4 As String 
  Dim date1, date2 As Date 
  Dim iDiff As Integer
  Dim PicDayMinus, PicDayPlus, PicTimeMinus, PicTimePlus As Picture
  
  If ColumnView1.Columns.Count < F_iColumnsCount Then ColumnView1Resize() 'Create and Resize Columns (Spalten erzeugen)
  
  If iMinutes <> 0 Then 
    SelectHide0Date1Clock2Timer3(0)
    PicDayMinus = ColumnViewImages("PicDayMinus").Picture 
    PicDayPlus = ColumnViewImages("PicDayPlus").Picture 
    PicTimeMinus = ColumnViewImages("PicTimeMinus").Picture 
    PicTimePlus = ColumnViewImages("PicTimePlus").Picture 
    '.......................................
    iDiff = iMinutes
    '.......................................
    For Each sKey In ColumnView1.Keys
      If ColumnView1[sKey].Selected = True Then 
        If ColumnView1[sKey][0] Like "????-??-??" And String.Left(ColumnView1[sKey][5], 1) <> "*" Then 'Dates, no Timer MoDi, no Birthsdays*
          T0 = ColumnView1[sKey][0] 'Datum
          T1 = ColumnView1[sKey][1] 'Uhr
          T2 = ColumnView1[sKey][2] 'WTag von
          T3 = ColumnView1[sKey][3] 'Q
          T4 = ColumnView1[sKey][4] 'KW
          
          date1 = M01Functions.DateCheckyyyymmddhhnn(T0, T1) 'as Date
          ''Calendar, Date
          date2 = DateAdd(date1, gb.Minute, iDiff)
          
          T0 = Format(date2, "yyyy-mm-dd")
          T1 = Format(date2, "hh:nn")
          T2 = Format(date2, "ddd")
          T3 = Str(M01Functions.DateQuarterG(date2)) & ("Q")
          T4 = Format(M01Functions.DateCalenderWeek(date2), "00") & ("KW") '00...52
          ColumnView1[sKey][0] = T0
          ColumnView1[sKey][1] = T1
          ColumnView1[sKey][2] = T2
          ColumnView1[sKey][3] = T3
          ColumnView1[sKey][4] = T4
          If Abs(iDiff) >= 24 * 60 Then 
            If iDiff < 0 Then 
              ColumnView1[sKey].Picture = PicDayMinus
              ColumnView1[sKey][F_iColumnSelect] = "PicDayMinus"
            Else 
              ColumnView1[sKey].Picture = PicDayPlus
              ColumnView1[sKey][F_iColumnSelect] = "PicDayPlus"  
            Endif 
          Else 
            If iDiff < 0 Then 
              ColumnView1[sKey].Picture = PicTimeMinus
              ColumnView1[sKey][F_iColumnSelect] = "PicTimeMinus"  
            Else 
              ColumnView1[sKey].Picture = PicTimePlus
              ColumnView1[sKey][F_iColumnSelect] = "PicTimePlus"  
            Endif 
          Endif 
          F_bListChanged = True
          F_iListChangedCounter = F_iListChangedCounter + 1
        Endif 
      Endif 
    Next 
    ButtonSave.Background = Color.Red
    ButtonInput.Background = F_iColorGreen
    ColumnViewBackup()
    ColumnViewListChangeLED()
    ProgressBarONoff(False)
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub MenuShow()
  
  Dim sFileOld, sPlus As String
  Dim iDiff As Integer
  
  Select Case F_iMusterTermine1Names2Projects3 
    Case 1 ''Termine
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Checked = CheckBox1.Value
      mnuJedesJahr.Enabled = True  
      
      mnubirthdaysoutside.Enabled = True 
      mnubirthdaysinside.Enabled = True 
      mnuAuswahlBis.Enabled = True  
      mnuAuswahlTimer.Enabled = True  
      mnueditortermine.Text = ("Termine")
      
    Case 2 ''Project-Names
      mnuProjektEin.Enabled = True 
      mnuProjektAus.Enabled = True 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt-Namen")
      
    Case 3 ''Projects
      mnuProjektEin.Enabled = False 
      mnuProjektAus.Enabled = False 
      mnuJedesJahr.Enabled = False 
      
      mnubirthdaysoutside.Enabled = False 
      mnubirthdaysinside.Enabled = False 
      mnuAuswahlBis.Enabled = False  
      mnuAuswahlTimer.Enabled = False  
      mnueditortermine.Text = ("Projekt")
      
  End Select 
  
  mnuProjektEin.Visible = mnuProjektEin.Enabled 
  mnuProjektAus.Visible = mnuProjektAus.Enabled 
  
  sFileOld = FilePathFormOldYears()
  sFileOld = File.Name(sFileOld)
  mnuTermineAuslagern.Text = ("Auslagern...") & Space(1) & (" >> ") & Space(1) & sFileOld & Space(1) & ("=schneller")
  mnuTermineEinlagern.Text = ("Einlagern...") & Space(1) & (" << ") & Space(1) & sFileOld 
  mnuexportselection.Text = Replace(mnuexportselection.Text, ("(Suche)"), ("(Suche ") & Format(Now, "yyyy") & "-)")
  mnuMehrSchalter.Checked = PanelListMenu.Visible
  
  ''Calendar, Date
  If Text0.Text Like "????-??-??" Then 'not Timer "MiDi", not Birthdays "*"
    iDiff = CheckMoveDateTime(0) 'as Integer Days
    If iDiff < 0 Then sPlus = "" Else sPlus = "+"
    MenuMoveDate.Text = ("Tage") & Space(1) & ("verschieben (markierte Zeilen)") & Space(2) & Text0.Text & Space(1) & ("Tage") & ": " & sPlus & Space(1) & iDiff 
    If iDiff <> 0 Then  
      MenuMoveDate.Enabled = True
    Else 
      MenuMoveDate.Enabled = False
    Endif 
  Else 
    MenuMoveDate.Text = ("Tage") & Space(1) & ("verschieben (markierte Zeilen)") & Space(2) & "????-??-??" & Space(1) & ("Tage") & ": " & sPlus & Space(1) & iDiff 
    MenuMoveDate.Enabled = False
  Endif 
  
  ''Clock, Time
  If Text1.Text Like "??:??" Then 
    iDiff = CheckMoveDateTime(1)'as Integer Minutes
    If iDiff < 0 Then sPlus = "" Else sPlus = "+"
    MenuMoveTime.Text = ("Minuten") & Space(1) & ("verschieben (markierte Zeilen)") & Space(2) & Text1.Text & Space(1) & ("Minuten") & ": " & sPlus & Space(1) & iDiff 
    If iDiff <> 0 Then
      MenuMoveTime.Enabled = True
    Else 
      MenuMoveTime.Enabled = False
    Endif 
  Else 
    MenuMoveTime.Text = ("Minuten") & Space(1) & ("verschieben (markierte Zeilen)") & Space(2) & "??:??" & Space(1) & ("Minuten") & ": " & sPlus & Space(1) & iDiff 
    MenuMoveTime.Enabled = False
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckMoveDateTime(Optional iDate0Time1 As Integer = -1) As Integer
  
  Dim sKey As String 
  Dim iDiff As Integer
  Dim date1, date2 As Date
  
  Select Case iDate0Time1
    Case 0
      ''Calendar, Date
      If Text0.Text Like "????-??-??" Then
        sKey = ColumnViewCurrentKey()
        If ColumnView1.Keys.Find(sKey) > -1 Then '-1 not found
          If ColumnView1[sKey][0] Like "????-??-??" Then
            date1 = M01Functions.DateCheckyyyymmddhhnn(Text0.Text, Text1.Text) 'as Date
            date2 = M01Functions.DateCheckyyyymmddhhnn(ColumnView1[sKey][0], ColumnView1[sKey][1]) 'as Date
            date1 = Date(Year(date1), Month(date1), Day(date1))
            date2 = Date(Year(date2), Month(date2), Day(date2))
            iDiff = DateDiff(date2, date1, gb.Day)
          Endif 
        Endif 
      Endif 
    Case 1
      ''Clock, Time
      If Text1.Text Like "??:??" Then
        sKey = ColumnViewCurrentKey()
        If ColumnView1.Keys.Find(sKey) > -1 Then '-1 not found
          If ColumnView1[sKey][1] Like "??:??" Then
            date1 = M01Functions.DateCheckyyyymmddhhnn(ColumnView1[sKey][0], Text1.Text) 'as Date
            date2 = M01Functions.DateCheckyyyymmddhhnn(ColumnView1[sKey][0], ColumnView1[sKey][1]) 'as Date
            iDiff = DateDiff(date2, date1, gb.Minute)
          Endif 
        Endif 
      Endif 
  End Select 
  
  Return iDiff
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveDate_Click()
  
  MoveDateTime(0)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveTime_Click()
  
  MoveDateTime(1)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveDayPlus_Click()
  
  MoveMinutes(24 * 60)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveDayMinus_Click()
  
  MoveMinutes(-(24 * 60))
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveHourPlus_Click()
  
  MoveMinutes(60)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveHourMinus_Click()
  
  MoveMinutes(-60)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveMinutePlus_Click()
  
  MoveMinutes(10)
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMoveMinuteMinus_Click()
  
  MoveMinutes(-10)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonCancelG()
  
  Form2Bearb.Window.Close
  
Catch 
  FMain.ErrorText
  
End '...............................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.src/Form15Foto.class
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.src/Form15Foto.class
228 KB
' Gambas class file

'' F=Form

Public F_bAreaMoveON As Boolean
Public F_bCrossLineON As Boolean '--|--
Public F_bCutAreaFullScreenON As Boolean
Public F_bEdgeON As Boolean
Public F_bESCpressedON As Boolean
Public F_bFMainMinimizedBefore As Boolean
Public F_bFormResizeChanged As Boolean
Public F_bMovingON As Boolean
Public F_bQuoteDateON As Boolean
Public F_bQuoteStarListChanged As Boolean
Public F_bQuoteStarON As Boolean
Public F_bQuoteTextON As Boolean
Public F_bQuoteTimeON As Boolean
Public F_bRulesON As Boolean
Public F_bZoomLupeON As Boolean
Public F_fDistanceX As Float
Public F_fDistanceY As Float
Public F_fLX1 As Float
Public F_fLY1 As Float
Public F_fTextSizeAPlus As Float 
Public F_fVX1 As Float 'Vorher (Before)
Public F_fVX2 As Float
Public F_fVY1 As Float
Public F_fVY2 As Float
Public F_fX1 As Float 'Float genauer mit Nachkommastellen, hier wichtig
Public F_fX2 As Float
Public F_fY1 As Float
Public F_fY2 As Float
Public F_fZoomFactor As Float
Public F_iColorGreen150 As Integer = Color.SetAlpha(Color.Green, 150)
Public F_iColorGreen220 As Integer = Color.SetAlpha(Color.Green, 220)
Public F_iCopyScaleIndex As Integer 'M1:1,M1:2, ...
Public F_iCVUndoRedoPointer As Integer
Public F_iFormGeometryRectXYWH As Rect 'Rectangle □
Public F_imgScreen As Image 'image is faster than picture
Public F_imgScreenCutArea As Image
Public F_imgZoomLupe As Image
Public F_iOnly1x As Integer
Public F_iPhotoCutH As Integer
Public F_iPhotoCutW As Integer
Public F_iQuotePointer As Integer
Public F_iRulersColorBG As Integer 
Public F_iSaveFormatIndex As Integer  'png = 1, ...
Public F_iSaveQualityJPG As Integer = 80 '80%
Public F_iSecondCounter As Integer 'Zaehler
Public F_iTextLeftCenterRight As Integer 
Public F_iUndoRedoCutAreaPointer As Integer
Public F_iUndoRedoPhotosPointer As Integer
Public F_ooPanelQuotes As Object[]
Public F_ooUndoRedoCutArea As Object[]
Public F_ooUndoRedoPhoto As Object[] 
Public F_picScreen As Picture
Public F_pointFUnit As PointF 'Float (x,y)
Public F_pointFUnitCentimeterXY As PointF '|''''!''''| cm in Pixel
Public F_rectCutAreaUndo As Rect 'Integer
Public F_rectFCutArea As RectF 'Float with comma, exact
Public F_rectFCutMouseLupe As RectF 'Float with comma, exact
Public F_sForm As String = Form15Foto.Name 
Public F_sLabelM7MiniTooltipBasis As String 
Public F_sLabelM7TooltipBasis As String 
Public F_sMovePointsCutArea As String 
Public F_sPathPhotoSubtitleDate_txt As String 
Public F_sPathScreenphotoPNG As String
Public F_sQuoteDateText As String 
Public F_sQuoteDateWithoutText As String = ("Datum") '*yyyy-mm-dd
Public F_sQuoteEmpty As String = ("Leer") '*yyyy-mm-dd
Public F_sRulersCMorCMRELorPIXEL As String = "pixel"
Public F_sSaveFormat As String '*.png, *.jpg, ...
Public F_sScaleUnitText As String
Public F_ssPanelQuotes As String[]
Public F_ssUndo As String[]
Public F_sTitleBasicText As String 

Public F_iColorPicker As Integer
Public F_rectZoom As Rect

Public Function FilePathForm() As String 
  
  Dim sPath As String 
  
  sPath = Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt", FMain.F_sPathPhotoSubtitleDate_txt] 
  
  Return sPath 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_KeyPress()
  
  ' If Key.Code = Key.Esc Then ' see —▶ mnuAbbrechenESC_Click 
  If Key.Code = Key.F11 Then FullScreenONoff()
  
  If Key.Code = Key.Delete And PanelQuotes.Visible = True Then ButtonGroupSelect(ButtonLineCut.Tag)
  
  If Key.Code = Key.Down Or Key.Code = Key.Right Or Key.Text = "+" Then
    ZoomHasFocus(True)
  Else If Key.Code = Key.Up Or Key.Code = Key.Left Or Key.Text = "-" Then
    ZoomHasFocus(False)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ESCkeypress()
  
  IconError.Visible = False
  F_bESCpressedON = Not F_bESCpressedON
  If F_bESCpressedON = True Then Form15Foto.Window.Title = F_sTitleBasicText & Space(2) & ("Abbruch mit [ESC]") Else Form15Foto.Window.Title = F_sTitleBasicText
  CheckZoomLupeCursor(False) 'Mouse.Cross, TimerZoomLupe.Stop
  CheckZoomPhotoOptimal(False) 'False
  Me.Maximized = False
  Me.FullScreen = False
Catch
  FMain.ErrorText
  
End

Public Sub mnuAbbrechenESC_Click()
  
  ESCkeypress()
  
Catch 
  FMain.ErrorText
  
End

Public Sub FullScreenONoff()
  
  If Form15Foto.Window.Maximized = False Then
    Form15Foto.Window.Maximized = True
  Else
    Form15Foto.Window.Maximized = False
    Form15Foto.Window.FullScreen = False
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub Form_Open()
  
  Timer1.Stop
  ''Hide:
  F_bFMainMinimizedBefore = FMain.Window.Minimized 
  ' FMain.Window.Minimized = True '_▼_
  FMain.Window.visible = False 
  
  Form15Foto.Window.Title = Application.Name & " - " & ("Foto")  
  F_sTitleBasicText = Form15Foto.Window.Title
  If Not Form15Foto.Window.Icon Then Form15Foto.Window.Icon = FMain.Window.Icon
  Menu1.Visible = False
  Menu2.Visible = False
  Menu3.Visible = False
  MenuMouse.Visible = False
  SettingsReadSave("read")
  FormBackgroundColor()
  
Catch 
  FMain.ErrorText
  Form15Foto.Window.Raise
  ' Form15Foto.Window.Visible = True 'Wayland error?
  
End

Public Sub Form_Activate()
  
  If F_iOnly1x = 0 Then
    F_iOnly1x = 1
    ' Print "Form_Activate()1"
    
    FormStart()
    If F_bQuoteStarON = True Then CreatePanelQuote()
    ScrollViewQuote.Visible = F_bQuoteStarON
    If Exist(FMain.F_sDirAppName) = True Then M01Functions.BookmarksGlobalStandardLoad()
    ' Form15Foto.Window.Visible = True 'Wayland error?
    ''Screenshot:
    ' ButtonGroupSelect(ButtonM1Foto.Tag) 'Timer1.Start 
  Endif 
  
  If PicBackground.W <> Me.ClientW Or PicBackground.H <> Me.ClientH Then 
    Form_Resize()
  Else
    If Me.Maximized Or Me.FullScreen Then Form_Resize()
  Endif 
  
  ' PicBackground.Lower()
  ' PicBackground.SetFocus
  ' PicBackground.Refresh()
  ' Wait 
  
Catch 
  FMain.ErrorText
  Form15Foto.Window.Raise
  ' Form15Foto.Window.Visible = True 'Wayland error?
  
End

Public Sub FormStart()

  CheckLastestPhoto("open")
  ''Start with Photo?
  If Settings[F_sForm &/ "openformwithnewphoto", False] = True Then PhotoButtonG()
  
  F_sLabelM7TooltipBasis = LabelM7.Tooltip
  F_sLabelM7MiniTooltipBasis = LabelM7Mini.Tooltip
  
  F_iCopyScaleIndex = Settings[Form15Foto.Name &/ "F_iCopyScaleIndex", 1]
  CopyMenuSelected(F_iCopyScaleIndex)
  
  F_iSaveFormatIndex = Settings[Form15Foto.Name &/ "F_iSaveFormatIndex", 1]
  SaveMenuSelected(F_iSaveFormatIndex)
  
  ''Subtitle Path:
  F_sPathPhotoSubtitleDate_txt = Settings[FMain.Name &/ "F_sPathPhotoSubtitleDate_txt", FMain.F_sPathPhotoSubtitleDate_txt] 
  
  F_sPathScreenphotoPNG = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG] 
  
  TextBoxPath.SelectAll()
  TextBoxPath.Insert(F_sPathPhotoSubtitleDate_txt)
  QuoteStarCheck()
  UndoRedoTextLines("save")
  LabelCutArea.Background = F_iColorGreen220
  CornerPointsPicture("reset")
  
  WindowStretchCursor()
  LabelK1htmlCursor()
  CheckRulersG()
  ' ResizePanelQuotes()
  ' M01Functions.CreateMenuButtonRulerColors() 'only 1x for programer, software developer
  ButtonGroupLeaveDeafaultG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ExternStandardProgramNameRefresh()
  
  Dim sName As String 
  Dim ssSpli As String[]
  
  sName = M01Functions.ExternStandardProgramName("image/" & F_sSaveFormat) 'as String 'Example: "text/html" > "firefox"
  If sName Then 
    ssSpli = Split(LabelM3Program.Tooltip & "...", "...")
    LabelM3Program.Tooltip = ssSpli[0] & "..." & sName
    ButtonM3Program.Tooltip = LabelM3Program.Tooltip
    
    ssSpli = Split(mnuStandardprogramExtern.Text & "...", "...")
    mnuStandardprogramExtern.Text = ssSpli[0] & "..." & sName
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub SettingsReadSave(Optional sReadSave As String = "read")
  
  Dim iX, iY, iW, iH As Integer
  
  Select Case String.LCase(String.Left(sReadSave, 1))
    Case "r" ''Read
      iX = Settings[F_sForm &/ "Left", Form15Foto.Left]
      iY = Settings[F_sForm &/ "Top", Form15Foto.Top]
      iW = Settings[F_sForm &/ "Width", Form15Foto.W]
      iH = Settings[F_sForm &/ "Height", Form15Foto.H]
      Form15Foto.Move(iX, iY, iW, iH)
      F_fX1 = Settings[F_sForm &/ "F_fX1", PicBoxPhoto.Left]
      F_fY1 = Settings[F_sForm &/ "F_fY1", PicBoxPhoto.Top]
      F_fX2 = Settings[F_sForm &/ "F_fX2", PicBoxPhoto.Width]
      F_fY2 = Settings[F_sForm &/ "F_fY2", PicBoxPhoto.Height]
      LabelCutArea.Move(PanelGlass.W / 3, PanelGlass.H / 3, PanelGlass.W / 3, PanelGlass.H / 3)
      UndoRedoCutArea() '[hRect,0]
      LabelCutArea.Move(F_fX1, F_fY1, F_fX2, F_fY2)
      UndoRedoCutArea() '[hRect,1]
      PicBoxGrid.Visible = Settings[F_sForm &/ "GridON", 0]
      CheckGrid(PicBoxGrid.Visible)
      F_bCrossLineON = Settings[F_sForm &/ "F_bCrossLineON", 0]
      If F_bCrossLineON = True Then CreateCrossLine()
      F_ssPanelQuotes = Settings[F_sForm &/ "F_ssPanelQuotes", F_ssPanelQuotes]
      F_iQuotePointer = Settings[F_sForm &/ "F_iQuotePointer", F_iQuotePointer]
      F_sQuoteDateText = Settings[F_sForm &/ "F_sQuoteDateText", F_sQuoteDateText]
      F_bQuoteStarON = Settings[F_sForm &/ "F_bQuoteStarON", False]
      F_bQuoteDateON = Settings[F_sForm &/ "F_bQuoteDateON", False]
      F_bQuoteTimeON = Settings[F_sForm &/ "F_bQuoteTimeON", False]
      F_bQuoteTextON = Settings[F_sForm &/ "F_bQuoteTextON", False]
      F_iRulersColorBG = Settings[F_sForm &/ "F_iRulersColorBG", 0]
      F_bRulesON = Settings[F_sForm &/ "F_bRulesON", F_bRulesON]
      F_sRulersCMorCMRELorPIXEL = Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL", F_sRulersCMorCMRELorPIXEL]
      F_iTextLeftCenterRight = Settings[F_sForm &/ "F_iTextLeftCenterRight", LabelCutArea.Alignment]
      F_fTextSizeAPlus = Settings[F_sForm &/ "F_fTextSizeAPlus", LabelCutArea.Font.Size]
      
      TextBoxQuoteExample.Alignment = F_iTextLeftCenterRight
      LabelCutArea.Alignment = F_iTextLeftCenterRight
      TextBoxQuoteExample.Font.Size = F_fTextSizeAPlus
      LabelCutArea.Font.Size = F_fTextSizeAPlus
      CheckFullPageMinMax()
      
    Case "s" ''Save
      'Save window settings when application closes
      Settings[F_sForm &/ "Left"] = Form15Foto.Left
      Settings[F_sForm &/ "Top"] = Form15Foto.Top
      Settings[F_sForm &/ "Width"] = Form15Foto.Width
      Settings[F_sForm &/ "Height"] = Form15Foto.Height
      Settings[F_sForm &/ "F_fX1"] = LabelCutArea.Left
      Settings[F_sForm &/ "F_fY1"] = LabelCutArea.Top
      Settings[F_sForm &/ "F_fX2"] = LabelCutArea.Width
      Settings[F_sForm &/ "F_fY2"] = LabelCutArea.Height
      Settings[F_sForm &/ "GridON"] = PicBoxGrid.Visible 'True or False, -1 or 0
      Settings[F_sForm &/ "F_bCrossLineON"] = F_bCrossLineON
      ' Settings[FMain.Name &/ "F_ssPanelQuotes"] = F_ssPanelQuotes
      Settings[F_sForm &/ "F_iQuotePointer"] = F_iQuotePointer
      Settings[F_sForm &/ "F_sQuoteDateText"] = F_sQuoteDateText
      Settings[F_sForm &/ "F_bQuoteStarON"] = F_bQuoteStarON
      Settings[F_sForm &/ "F_bQuoteDateON"] = F_bQuoteDateON
      Settings[F_sForm &/ "F_bQuoteTimeON"] = F_bQuoteTimeON
      Settings[F_sForm &/ "F_bQuoteTextON"] = F_bQuoteTextON
      ' Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL"] = F_sRulersCMorCMRELorPIXEL
      Settings[F_sForm &/ "F_iTextLeftCenterRight"] = LabelCutArea.Alignment
      Settings[F_sForm &/ "F_fTextSizeAPlus"] = LabelCutArea.Font.Size
      
  End Select 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckGrid(Optional bON As Boolean = False)
  
  If bON = False Then 
    PicBoxGrid.Picture = Null
    PicBoxGrid.Visible = False 
  Else 
    PicBoxGrid.Picture = M01Functions.GridTransparentLinesCM().Picture 'as Image
    If PicBoxGrid.Picture Then PicBoxGrid.Visible = True Else PicBoxGrid.Visible = False 
    PicBoxGrid.Stretch = False ' —▶ Unit 1 "cm"
    F_pointFUnitCentimeterXY = M01Functions.Unit1cm() ''as PointF x,y Float
    ' If Not F_pointFUnitCentimeterXY Then F_pointFUnitCentimeterXY = New PointF
    ' F_pointFUnitCentimeterXY = Settings[Form15Foto.Name &/ "F_pointFUnitCentimeterXY", F_pointFUnitCentimeterXY]
    If F_pointFUnitCentimeterXY.X > 10 Then Eckpunkt1.Width = F_pointFUnitCentimeterXY.X
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CopyMenuSelected(Optional hIndex As Integer = 1)
  
  ' Dim sText As String
  
  F_iCopyScaleIndex = hIndex
  mnuKopieren01.Checked = False
  mnuKopieren02.Checked = False
  mnuKopieren03.Checked = False
  mnuKopieren04.Checked = False
  mnuKopieren05.Checked = False
  mnuKopieren06.Checked = False
  mnuKopieren07.Checked = False
  mnuKopieren08.Checked = False
  mnuKopieren09.Checked = False
  
  ' sText = ("Kopieren")
  
  Select Case hIndex
    Case 1
      mnuKopieren01.Checked = True
      ' mnuKopieren01.Text = sText & " 1:1"
      F_iPhotoCutW = 1
      F_iPhotoCutH = 1
    Case 2
      mnuKopieren02.Checked = True
      ' mnuKopieren02.Text = sText & " 1:2 verkleinern"
      F_iPhotoCutW = 1
      F_iPhotoCutH = 2
    Case 3
      mnuKopieren03.Checked = True
      ' mnuKopieren03.Text = sText & " 1:4"
      F_iPhotoCutW = 1
      F_iPhotoCutH = 4
    Case 4
      mnuKopieren04.Checked = True
      ' mnuKopieren04.Text = sText & " 2:1 vergrößern"
      F_iPhotoCutW = 2
      F_iPhotoCutH = 1
      
    Case 5
      mnuKopieren05.Checked = True
      ' mnuKopieren05.Text = sText & " 32x32 Pixel"
      F_iPhotoCutW = 32
      F_iPhotoCutH = 32
    Case 6
      mnuKopieren06.Checked = True
      ' mnuKopieren06.Text = sText & " 160x120 Pixel"
      F_iPhotoCutW = 160
      F_iPhotoCutH = 120
    Case 7
      mnuKopieren07.Checked = True
      ' mnuKopieren07.Text = sText & " 400x300 Pixel"
      F_iPhotoCutW = 400
      F_iPhotoCutH = 300
      
    Case 8
      mnuKopieren08.Checked = True
      ' mnuKopieren08.Text = sText & " 800x600 Pixel"
      F_iPhotoCutW = 800
      F_iPhotoCutH = 600
      
    Case 9
      mnuKopieren09.Checked = True
      'mnuKopieren09.Text = sText & F_fZoomFactor & "x" & F_fZoomFactor 'Pixel
      F_iPhotoCutW = F_fZoomFactor
      F_iPhotoCutH = F_fZoomFactor
      
  End Select
  CopyButtonG()
  ' PhotoCutArea()
  
Catch 
  FMain.ErrorText
  
End

Public Sub SaveMenuSelected(Optional hIndex As Integer = 1)
  
  F_iSaveFormatIndex = hIndex 
  mnuBildSpeichern01.Checked = False
  mnuBildSpeichern02.Checked = False
  mnuBildSpeichern03.Checked = False
  mnuBildSpeichern04.Checked = False
  mnuBildSpeichern05.Checked = False
  
  Select Case hIndex
    Case 1
      mnuBildSpeichern01.Checked = True
      mnuBildSpeichern01.Text = "Format PNG"
      F_sSaveFormat = "png"
      F_iSaveQualityJPG = 100
    Case 2
      mnuBildSpeichern02.Checked = True
      mnuBildSpeichern02.Text = "Format JPEG, JPG 50%" & Space(5) & ("kleinere Datei")
      F_sSaveFormat = "jpg"
      F_iSaveQualityJPG = 50
    Case 3
      mnuBildSpeichern03.Checked = True
      mnuBildSpeichern03.Text = "Format JPEG, JPG 80%" & Space(8) & ("größere Datei")
      F_sSaveFormat = "jpg"
      F_iSaveQualityJPG = 80
    Case 4
      mnuBildSpeichern04.Checked = True
      mnuBildSpeichern04.Text = "Format Bitmap, BMP"
      F_sSaveFormat = "bmp"
      F_iSaveQualityJPG = 100
    Case 5
      mnuBildSpeichern05.Checked = True
      mnuBildSpeichern05.Text = "Format XPM (icon)"
      F_sSaveFormat = "xpm"
      F_iSaveQualityJPG = 100
    Case Else
      mnuBildSpeichern01.Checked = True
      mnuBildSpeichern01.Text = "Format PNG"
      F_sSaveFormat = "png"
      F_iSaveQualityJPG = 100
  End Select
  
  If F_sSaveFormat = "" Then F_sSaveFormat = "png"
  If F_iSaveQualityJPG = 0 Then F_iSaveQualityJPG = 100
  Settings[Form15Foto.Name &/ "F_sSaveFormat"] = F_sSaveFormat
  Settings[Form15Foto.Name &/ "F_iSaveQualityJPG"] = F_iSaveQualityJPG
  
  If F_iSaveQualityJPG = 100 Then
    Form15Foto.Window.Title = F_sTitleBasicText & Space(3) & "*." & F_sSaveFormat '& Space(1)  & F_iSaveQualityJPG & "%"
  Else
    Form15Foto.Window.Title = F_sTitleBasicText & Space(3) & "*." & F_sSaveFormat & Space(1) & F_iSaveQualityJPG & "%"
  Endif
  
  MenuGrid.Checked = PicBoxGrid.Visible 'True or False
  MenuHelplines.Checked = CrossLineHorizontal1.Visible
  ExternStandardProgramNameRefresh()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Menu1_Show()
  
  ExternStandardProgramNameRefresh()
  MenuQuoteStarOnOff.Checked = F_bQuoteStarON
  MenuQuoteStarOnOff.Picture = ButtonQuotesOnOff.Picture
  
  MenuRulersLines()
  If F_iCopyScaleIndex = 9 Then mnuKopieren09.Checked = True Else mnuKopieren09.Checked = False
  MenuFormOpenWithNewPhoto.Checked = Settings[F_sForm &/ "openformwithnewphoto", False] 
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuRulersLines()
  
  MenuRulersONoff.Checked = F_bRulesON
  If F_sRulersCMorCMRELorPIXEL = MenuRulersCentimeter.Tag Then MenuRulersCentimeter.Checked = True Else MenuRulersCentimeter.Checked = False 
  If F_sRulersCMorCMRELorPIXEL = MenuRulersCMRelative.Tag Then MenuRulersCMRelative.Checked = True Else MenuRulersCMRelative.Checked = False 
  If F_sRulersCMorCMRELorPIXEL = MenuRulersPixel.Tag Then MenuRulersPixel.Checked = True Else MenuRulersPixel.Checked = False 
  
  ''Reset:
  MenuRulersTransparent.Checked = False
  MenuRulersYellow.Checked = False
  MenuRulersWood.Checked = False
  MenuRulersMetal.Checked = False
  MenuRulersGray.Checked = False
  
  Select Case F_iRulersColorBG
    Case 0
      MenuRulersTransparent.Checked = True
    Case 1
      MenuRulersYellow.Checked = True
    Case 2
      MenuRulersWood.Checked = True
    Case 3
      MenuRulersMetal.Checked = True
    Case 4
      MenuRulersGray.Checked = True
  End Select
  
  MenuGrid.Checked = PicBoxGrid.Visible 'True or False
  MenuHelplines.Checked = CrossLineHorizontal1.Visible
  
  ''Check Rulers |''''!''''| cm
  MenuRulersONoff2.Checked = MenuRulersONoff.Checked
  MenuRulersCentimeter2.Checked = MenuRulersCentimeter.Checked
  MenuRulersCMRelative2.Checked = MenuRulersCMRelative.Checked
  MenuRulersPixel2.Checked = MenuRulersPixel.Checked
  ''Colors:
  MenuRulersTransparent2.Checked = MenuRulersTransparent.Checked 
  MenuRulersYellow2.Checked = MenuRulersYellow.Checked 
  MenuRulersWood2.Checked = MenuRulersWood.Checked 
  MenuRulersMetal2.Checked = MenuRulersMetal.Checked 
  MenuRulersGray2.Checked = MenuRulersGray.Checked 
  
  MenuGrid2.Checked = MenuGrid.Checked 'True or False
  MenuHelplines2.Checked = MenuHelplines.Checked
  
Catch 
  FMain.ErrorText
  
End

Public Sub Menu2_Show()
  
  MenuRulersTitle.Text = ("Bildschirm") & Space(1) & Screen.W & " x " & Screen.H & Space(1) & ("Pixel") & ":"
  MenuRulersLines()
  
Catch 
  FMain.ErrorText
  
End

Public Sub MenuMouse_Show()
  
  Dim iMax As Integer
  
  If F_ssUndo Then iMax = F_ssUndo.Max Else iMax = -1
  MenuUndoPointer.Text = (F_iCVUndoRedoPointer + 1) & " / " & (iMax + 1)
  ''Example for .max: "-1 / 0" and .count: "0 / 1" 
  
  If F_ssUndo Then 
    If F_iCVUndoRedoPointer > -1 Then MenuUndo.Enabled = True Else MenuUndo.Enabled = False
    If F_iCVUndoRedoPointer < F_ssUndo.Count Then MenuRedo.Enabled = True Else MenuRedo.Enabled = False
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub RaiseOrder()
  
  PicBackground.Lower 'Level Bottom
  PanelMenu.Raise
  PanelGlass.Raise
  PicBoxPhoto.Lower
  PanelSquare.Raise
  PicBoxGrid.Raise
  LabelInfo.Raise
  WindowStretch.Raise 'Level Top 
  IconError.Raise
  PicBoxPhotoLatest.Raise
  PanelColorZoom.Raise
  PicBoxZoomCross.Raise()
  LabelM7Mini.Raise
  PicBoxRulerHorizontal.Raise
  PicBoxRulerVertical.Raise
  LabelM7b.Alignment = LabelM7.Alignment 'a<– or –>a<– or –>a
  ScrollViewQuote.Raise()
  LabelClipboardInfo.Raise()
  LabelCutArea.Raise 'Cut-Area
  Eckpunkt6.Raise 'top, but under Eckpunkt1...
  Eckpunkt7.Raise
  Eckpunkt8.Raise
  Eckpunkt9.Raise
  
  Eckpunkt1.Raise '+
  Eckpunkt2.Raise '+
  Eckpunkt3.Raise '+
  Eckpunkt4.Raise '+
  Eckpunkt5Middle.Raise '◁○▷
  
  PanelFileSaved.Raise
  PanelQuotes.Raise()
  
Catch 
  FMain.ErrorText
  
End

Public Sub Form_Resize()
  
  Dim iBW, iBH, iW, iLeft, iTop, iSH, iSH2, iDis As Integer 'Border Width, Height (Rand Breite, Hoehe)
  Dim fPart As Float
  
  If Form15Foto.Width < 200 Then Form15Foto.Width = 200
  If Form15Foto.Height < 200 Then Form15Foto.Height = 200
  PicBackground.Move(0, 0, Form15Foto.ClientW, Form15Foto.ClientH)
  IconError.Move(Form15Foto.ClientW - 22, 0, 22, 22)
  
  If F_bMovingON = False Then 
    iBW = PicBackground.Width / 100 * 3 ' Randbreite
    iBH = iBW 'PicBackground.Height / 100 * 3
    iDis = 4
    iSH = (Form15Foto.ClientH - (iBH * 2)) / 12.5 'Schalter-Höhe
    
    PanelGlass.Move(iBW, iBH, Form15Foto.ClientW - (iBW * 2) - (iSH * 3.25) - iDis, Form15Foto.ClientH - (iBH * 2))
    ImageViewPhoto.Move(PanelGlass.Left, PanelGlass.Top, PanelGlass.W, PanelGlass.H)
    PicBoxPhoto.Move(0, 0, PanelGlass.W, PanelGlass.H)
    PanelMenu.Move(PanelGlass.Left + PanelGlass.Width + iDis, PanelGlass.Top, Form15Foto.ClientW - PanelGlass.W - (iBW * 2), PanelGlass.H)
    fPart = iBH * 0.75
    PanelTop.Move(iBW, iBH - fPart, Form15Foto.ClientW - (iBW * 2), fPart)
    LabelPictureSavedPath.Move(0, 0, PanelGlass.W, fPart)
    LabelInfoZoomLupe.Move(0, 0, PanelGlass.W - (fPart * 4), fPart)
    LabelZoomColorPoint.Move(LabelInfoZoomLupe.Left + LabelInfoZoomLupe.W, 0, fPart * 4, fPart)
    
    ListUndo.Move(LabelPictureSavedPath.Left + LabelPictureSavedPath.W, 0, fPart, fPart)
    ListBackupCounter1.Move(ListUndo.Left + ListUndo.W, 0, PanelMenu.W - (fPart * 2), fPart)
    ListRedo.Move(ListBackupCounter1.Left + ListBackupCounter1.W, 0, fPart, fPart)
    
    F_fDistanceX = PanelGlass.Left
    F_fDistanceY = PanelGlass.Top 
    PicBoxGrid.Move(0, 0, PanelGlass.W, PanelGlass.H)
    
    iW = (iSH * 2)
    iLeft = PanelMenu.W - iSH
    iSH2 = iSH / 2
    
    iTop = iSH * 0 '=0
    ButtonM1Foto.Move(0, 0, PanelMenu.W, iSH)
    PicBoxLED.Move(PanelMenu.W - iSH2, 0, iSH2, iSH2)
    
    iTop = iSH * 1
    LabelM2Save.Move(0, iTop, PanelMenu.W - iSH, iSH)
    ButtonM2Save.Move(iLeft, iTop, iSH, iSH)
    
    iTop = iSH * 2
    LabelM3Program.Move(0, iTop, LabelM2Save.W, iSH)
    ButtonM3Program.Move(iLeft, iTop, iSH, iSH)
    
    iTop = iSH * 3
    LabelM4Full.Move(0, iTop, LabelM2Save.W, iSH)
    ButtonM4Full.Move(iLeft, iTop, iSH, iSH)
    
    iTop = iSH * 4
    LabelM5Menu.Move(0, iTop, LabelM2Save.W, iSH)
    ButtonM5Menu.Move(iLeft, iTop, iSH, iSH)
    ButtonM7PanelSquare.Move(PanelMenu.W - iSH - iSH, LabelM5Menu.Top, iSH, iSH)
    
    iTop = iSH * 5
    LabelM6Scale.Move(0, iTop, PanelMenu.W - iSH, iSH)
    
    iTop = iSH * 6
    LabelM7.Move(0, iTop, PanelMenu.W - iSH, iSH) 
    LabelM7.Raise 'Top▲
    LabelM7b.Font = LabelM7.Font 'Shadow
    LabelM7b.Text = LabelM7.Text
    LabelM7b.Alignment = LabelM7.Alignment
    LabelM7b.Move(LabelM7.Left - 2, LabelM7.Top + 2, LabelM7.W, LabelM7.H) 'Shadow
    PicBoxM7ZoomLupe.Move(PanelMenu.W - iSH, LabelM6Scale.Top, iSH, iSH)
    LabelM7Mini.Move(LabelM7.Left, LabelM7.Top + LabelM7.H, PanelMenu.W, iSH / 2)
    ButtonM8Zoom.Move(PanelMenu.W - iSH, iTop, iSH, iSH)
    
    fPart = PanelMenu.W / 4
    PanelSquare.Move(0, LabelM3Program.Top, PanelMenu.W, iSH * 3)
    PicBoxPanelSquareBG.Move(0, 0, PanelSquare.W, PanelSquare.H)
    
    ButtonM7Left.Move(0, 0, fPart, PanelSquare.H / 4)
    ButtonM7Right.Move(ButtonM7Left.Left + ButtonM7Left.W, ButtonM7Left.Top, fPart, ButtonM7Left.H)
    ButtonM7Up.Move(ButtonM7Right.Left + ButtonM7Right.W, ButtonM7Left.Top, fPart, ButtonM7Left.H)
    ButtonM7Down.Move(ButtonM7Up.Left + ButtonM7Up.W, ButtonM7Left.Top, fPart, ButtonM7Left.H)
    
    ButtonM7MinusRight.Move(0, ButtonM7Left.Top + ButtonM7Left.H, fPart, ButtonM7Left.H)
    ButtonM7PlusRight.Move(ButtonM7MinusRight.Left + ButtonM7MinusRight.W, ButtonM7MinusRight.Top, fPart, ButtonM7Left.H)
    ButtonM7MinusDown.Move(ButtonM7PlusRight.Left + ButtonM7PlusRight.W, ButtonM7MinusRight.Top, fPart, ButtonM7Left.H)
    ButtonM7PlusDown.Move(ButtonM7MinusDown.Left + ButtonM7MinusDown.W, ButtonM7MinusRight.Top, fPart, ButtonM7Left.H)
    
    ButtonM7Square.Move(0, ButtonM7PlusDown.Top + ButtonM7PlusDown.H, fPart, ButtonM7Left.H)
    LabelPixelXY.Move(ButtonM7Square.Left + ButtonM7Square.W, ButtonM7Square.Top, PanelSquare.W - fPart, ButtonM7Left.H)
    
    LabelM7Title.Move(0, LabelPixelXY.Top + LabelPixelXY.H, fPart * 3, ButtonM7Left.H)
    ButtonPanelSquareCancel.Move(LabelM7Title.Left + LabelM7Title.W, LabelM7Title.Top, fPart, ButtonM7Left.H)
    
    iTop = iSH * 7.5
    PicBoxCutPreview.Move(0, iTop, PanelMenu.W, iSH * 2.25)
    PanelColorZoom.Move(PicBoxCutPreview.Left, PicBoxCutPreview.Top, PicBoxCutPreview.W, PicBoxCutPreview.H)
    PicBoxZoomLupe.Move(0, 0, PicBoxPhoto.W, PicBoxPhoto.H)
    PicBoxZoomCross.Move(0, 0, PanelColorZoom.W, PanelColorZoom.H)'1:1
    
    iTop = iSH * 9.75
    PanelUndoArea.Move(0, iTop, PanelMenu.W, iSH * 0.75)
    ListUndo2.Move(0, 0, PanelUndoArea.H, PanelUndoArea.H)
    ListBackupCounter2.Move(ListUndo2.Left + ListUndo2.W, 0, PanelUndoArea.W - (PanelUndoArea.H * 2), PanelUndoArea.H)
    ListRedo2.Move(ListBackupCounter2.Left + ListBackupCounter2.W, 0, PanelUndoArea.H, PanelUndoArea.H)
    
    iTop = iSH * 10.5
    ButtonM8Copy.Move(0, iTop, PanelMenu.W, iSH)
    
    iTop = iSH * 11.5
    PicBoxPhotoLatest.Move(0, iTop, iSH, PanelMenu.H - iTop)
    ButtonM10Close.Move(iSH, iTop, PanelMenu.W - iSH, PanelMenu.H - iTop) 'Rest H
    
    WindowStretch.H = iSH
    WindowStretch.Move(PanelMenu.Left + PanelMenu.Width - WindowStretch.H, PanelMenu.Top + PanelMenu.Height - WindowStretch.Height, WindowStretch.Height, WindowStretch.Height) 'quadratisch
    
    ''Control-Picture (Kontroll-Bild)
    PanelFileSaved.Move(PanelGlass.Left, PanelGlass.Top, PanelGlass.W * 0.7, PanelGlass.H * 0.7)
    LabelFileSavedhtml.Move(0, 0, PanelFileSaved.ClientW, LabelFileSavedhtml.Font.TextHeight("Abc") * 4.2)
    ImageView1.Move(0, LabelFileSavedhtml.Top + LabelFileSavedhtml.H, PanelFileSaved.ClientW, PanelFileSaved.ClientH - LabelFileSavedhtml.H - iSH)
    ButtonFileSavedInfo.Move(0, ImageView1.Top + ImageView1.H, iSH, iSH)
    ButtonZoomOptimal.Move(ButtonFileSavedInfo.Left + ButtonFileSavedInfo.W, ButtonFileSavedInfo.Top, iSH, iSH)
    ButtonPreviewDir.Move(ButtonZoomOptimal.Left + ButtonZoomOptimal.W, ButtonFileSavedInfo.Top, iSH, iSH)
    ButtonExtern.Move(ButtonPreviewDir.Left + ButtonPreviewDir.W, ButtonFileSavedInfo.Top, iSH, iSH)
    ButtonFileSavedCancel.Move(ButtonExtern.Left + ButtonExtern.Width, ButtonExtern.Top, PanelFileSaved.W - (ButtonExtern.Left + ButtonExtern.Width), ButtonExtern.H)
    LabelMessageTool.Move(ImageView1.Left, ImageView1.Top, ImageView1.W, ImageView1.H)
    
    ''Panel Quotes
    PanelQuotes.Move(PanelGlass.Left, PanelGlass.Top, PanelGlass.W, PanelGlass.H)
    ColumnView1.Move(0, 0, PanelQuotes.W, PanelQuotes.H - (iSH * 3.5))
    TextBoxQuoteExample.Move(0, ColumnView1.Top + ColumnView1.H, PanelQuotes.W - (iSH * 2), iSH * 0.5)
    PanelTextAPlus.move(TextBoxQuoteExample.Left + TextBoxQuoteExample.W, TextBoxQuoteExample.Top, PanelQuotes.W - (TextBoxQuoteExample.Left + TextBoxQuoteExample.W), TextBoxQuoteExample.H)
    PicBoxTextLeft.Move(0, 0, iSH * 0.5, iSH * 0.5)
    PicBoxTextCenter.Move(PicBoxTextLeft.Left + PicBoxTextLeft.W, 0, PicBoxTextLeft.W, PicBoxTextLeft.H)
    PicBoxTextRight.Move(PicBoxTextCenter.Left + PicBoxTextCenter.W, 0, PicBoxTextLeft.W, PicBoxTextLeft.H)
    PicBoxTextAPlus.Move(PicBoxTextRight.Left + PicBoxTextRight.W, 0, PanelTextAPlus.W - (PicBoxTextRight.Left + PicBoxTextRight.W), PicBoxTextLeft.H)
    
    fPart = PanelQuotes.W / 18
    If fPart < iSH Then 
      fPart = iSH 
      ButtonQuotesLineOnOff.Text = Null
    Else 
      fPart = iSH * 2.5
      ButtonQuotesLineOnOff.Text = ("An/Aus")
    Endif 
    ButtonQuotesLineOnOff.Move(0, TextBoxQuoteExample.Top + TextBoxQuoteExample.H, fPart, iSH)
    ButtonQuotesDateOnOff.Move(ButtonQuotesLineOnOff.Left + ButtonQuotesLineOnOff.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuotesTimeOnOff.Move(ButtonQuotesDateOnOff.Left + ButtonQuotesDateOnOff.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuotesTextOnOff.Move(ButtonQuotesTimeOnOff.Left + ButtonQuotesTimeOnOff.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonLineCut.Move(iSH + ButtonQuotesTextOnOff.Left + ButtonQuotesTextOnOff.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuoteDown.Move(ButtonLineCut.Left + ButtonLineCut.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuoteUp.Move(ButtonQuoteDown.Left + ButtonQuoteDown.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonOpenQuotes.Move(ButtonQuoteUp.Left + ButtonQuoteUp.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonOpenQuotesBackup.Move(ButtonOpenQuotes.Left + ButtonOpenQuotes.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuotesUndo.Move(ButtonOpenQuotesBackup.Left + ButtonOpenQuotesBackup.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ListBackupCounter.Move(ButtonQuotesUndo.Left + ButtonQuotesUndo.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuotesRedo.Move(ListBackupCounter.Left + ListBackupCounter.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonSaveQuotes.Move(ButtonQuotesRedo.Left + ButtonQuotesRedo.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonSaveAsQuotes.Move(ButtonSaveQuotes.Left + ButtonSaveQuotes.W, ButtonQuotesLineOnOff.Top, iSH, iSH)
    ButtonQuotesPanelCancel.Move(ButtonSaveAsQuotes.Left + ButtonSaveAsQuotes.W, ButtonQuotesLineOnOff.Top, PanelQuotes.W - (ButtonSaveAsQuotes.Left + ButtonSaveAsQuotes.W), iSH)
    
    ButtonNewLine.Move(0, ButtonQuotesLineOnOff.Top + ButtonQuotesLineOnOff.H, iSH, iSH)
    TextBoxQuote.Move(ButtonNewLine.Left + ButtonNewLine.W, ButtonNewLine.Top, PanelQuotes.W - (iSH * 7), iSH)
    ButtonInput.Move(TextBoxQuote.Left + TextBoxQuote.W, ButtonNewLine.Top, PanelQuotes.W - (TextBoxQuote.Left + TextBoxQuote.W + iSH), iSH)
    ListIsChanged.Move(ButtonInput.Left + ButtonInput.W, ButtonNewLine.Top, iSH, iSH)
        
    ButtonFileInfo.Move(0, ButtonNewLine.Top + ButtonNewLine.H, iSH, iSH)
    TextBoxPath.Move(ButtonFileInfo.Left + ButtonFileInfo.W, ButtonFileInfo.Top, PanelQuotes.W - (ButtonFileInfo.Left + ButtonFileInfo.W), iSH)
    LabelInfo.Move(TextBoxPath.Left, TextBoxPath.Top, TextBoxPath.W, TextBoxPath.H)
    
    ''*Quotes, Stars, Bookmarks
    PicBoxQuoteStarPanelMenu.Move(PanelQuotes.Left, PanelQuotes.Top + PanelQuotes.H, iBH, iBH)
    ButtonQuotesOnOff.Move(PicBoxQuoteStarPanelMenu.Left + PicBoxQuoteStarPanelMenu.W, PanelQuotes.Top + PanelQuotes.H, iBH, iBH)
    ScrollViewQuote.Move(ButtonQuotesOnOff.Left + ButtonQuotesOnOff.W, ButtonQuotesOnOff.Top, PanelQuotes.W - (iBH * 2), iBH)
    LabelClipboardInfo.Move(ScrollViewQuote.Left, ScrollViewQuote.Top, ScrollViewQuote.W, ScrollViewQuote.H)
    
    F_fDistanceX = PanelGlass.Left
    F_fDistanceY = PanelGlass.Top '- Form15Foto.ClientY
    RaiseOrder()
    LabelCutAreaCheckMax()
    CornerPointsToLabelCutAreaONoff(True)
    
    CrossLinesMove()
    ResizePanelQuotes()
    ImageView1.ZoomFit()
    
    Print "Form_Resize"
  Endif 
  F_bFormResizeChanged = True 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ResizePanelQuotes()
  
  Dim fPart As Float
  Dim it, iCount As Integer
  
  If Not F_ooPanelQuotes Then CreatePanelQuote()
  
  If F_ooPanelQuotes Then
    If F_ooPanelQuotes.Count > 0 Then 
      If F_ssPanelQuotes Then iCount = F_ssPanelQuotes.Count
      If iCount > 0 Then fPart = ScrollViewQuote.W / iCount
      If fPart < ScrollViewQuote.H * 4 Then fPart = ScrollViewQuote.H * 4 
    Else 
      fPart = ScrollViewQuote.W 'not Null
    Endif 
    For it = 0 To F_ooPanelQuotes.Max
      F_ooPanelQuotes[it].Move(it * fPart, 0, fPart, ScrollViewQuote.H)
    Next
    it = F_iQuotePointer
    ScrollViewQuote.EnsureVisible(F_ooPanelQuotes[it].Left, 0, F_ooPanelQuotes[it].W, F_ooPanelQuotes[it].H, Direction.LeftToRight)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreatePanelQuote()
  
  Dim fPart As Float 
  Dim hLabel As Label
  Dim it, iLeft, iH As Integer
  Dim sPath, sText As String
  
  ScrollViewQuote.Children.Clear()
  ScrollViewQuote.Border = False 
  F_ooPanelQuotes = New Object[]
  iH = ScrollViewQuote.H
  
  If Not F_ssPanelQuotes Then 
    sPath = F_sPathPhotoSubtitleDate_txt
    ' F_iQuotePointer = Settings[Form15Foto.Name &/ "F_iQuotePointer", F_iQuotePointer]
    If Exist(sPath) = True Then sText = File.Load(sPath) 
    
    F_ssPanelQuotes = New String[]
    F_ssPanelQuotes = Settings[Form15Foto.Name &/ "F_ssPanelQuotes", F_ssPanelQuotes]
    If F_ssPanelQuotes.Find(F_sQuoteDateWithoutText) = -1 Then 
      F_ssPanelQuotes.Add(F_sQuoteDateWithoutText)
      sText &= F_sQuoteDateWithoutText & gb.NewLine
    Endif 
    If F_ssPanelQuotes.Find(F_sQuoteEmpty) = -1 Then 
      F_ssPanelQuotes.Add(F_sQuoteEmpty)
      sText &= F_sQuoteEmpty & gb.NewLine
    Endif 
    
    F_iQuotePointer = F_ssPanelQuotes.Max
    If sText Then ColumnView3ReadQuotes(sText)
  Endif 
  
  If F_ssPanelQuotes.Count > 0 Then 
    fPart = PanelQuotes.W / F_ssPanelQuotes.Count 
    If fPart < iH * 4 Then fPart = iH * 4 
  Else 
    fPart = PanelQuotes.W 'not Null
  Endif 
  
  For it = 0 To F_ssPanelQuotes.Max 
    iLeft = it * fPart 
    
    hLabel = New Label(ScrollViewQuote) As "GroupQuotes"
    hLabel.Tag = it 
    hLabel.Mouse = Mouse.Pointing
    hLabel.Text = "*" & F_ssPanelQuotes[it]
    hLabel.Tooltip = F_ssPanelQuotes[it]
    hLabel.Alignment = Align.TopNormal
    hLabel.Border = Border.Plain
    If it = F_iQuotePointer Then hLabel.Font.Bold = True Else hLabel.Font.Bold = False 
    hLabel.Move(iLeft, 0, fPart, iH)
    hLabel.Font.Size = hLabel.Font.TextHeight("Abc") * 0.8
    hLabel.Visible = True 
    
    F_ooPanelQuotes.Add(hLabel)
  Next
  If F_iQuotePointer < 0 Or F_iQuotePointer > F_ssPanelQuotes.Max Then F_iQuotePointer = 0
  If F_ssPanelQuotes Then F_sQuoteDateText = F_ssPanelQuotes[F_iQuotePointer]
  ScrollViewQuote.Visible = True 
  F_bQuoteStarListChanged = False 
  ColumnView3ListChanged()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3ListChanged()
  
  If F_bQuoteStarListChanged = False Then 
    ListIsChanged.Picture = PicTemplateLEDgreen.Picture
  Else 
    ListIsChanged.Picture = PicTemplateLEDred.Picture
  Endif
  
  Catch 
  FMain.ErrorText
  
End

Public Sub GroupQuotes_Enter()
  
  Last.Background = F_iColorGreen150
  
End

Public Sub GroupQuotes_Leave()
  
  Last.Background = Color.Default
  
End

Public Sub GroupQuotes_MouseDown()
  
  Dim it As Integer
  
  If F_ooPanelQuotes Then it = F_ooPanelQuotes.Find(Last)
  
  If it > -1 Then 
    ''with Text
    If F_ooPanelQuotes[it].Font.Bold = False Then 
      F_iQuotePointer = it
      For it = 0 To F_ooPanelQuotes.Max
        F_ooPanelQuotes[it].Font.Bold = False 
      Next 
      F_ooPanelQuotes[F_iQuotePointer].Font.Bold = True 
      F_sQuoteDateText = Last.ToolTip
      ' LabelCutArea.Text = "*" & Format(Date, "yyyy-mm-dd") & Space(1) & F_sQuoteDateText
      Settings[Form15Foto.Name &/ "F_iQuotePointer"] = F_iQuotePointer
      Settings[Form15Foto.Name &/ "F_sQuoteDateText"] = F_sQuoteDateText
      If PanelQuotes.Visible = True And F_iQuotePointer < ColumnView1.Count Then 
        ColumnView1.UnSelectAll()
        ColumnView1[F_iQuotePointer + 1].Selected = True 
      Endif
      F_bQuoteStarON = True
      PaintQuote()
    Else 
      ''empty Text
      F_iQuotePointer = it
      For it = 0 To F_ooPanelQuotes.Max
        F_ooPanelQuotes[it].Font.Bold = False 
      Next 
      ' F_ooPanelQuotes[F_iQuotePointer].Font.Bold = True 
      F_sQuoteDateText = "" 'Last.ToolTip
      ' LabelCutArea.Text = "*" & Format(Date, "yyyy-mm-dd") & Space(1) & F_sQuoteDateText
      Settings[Form15Foto.Name &/ "F_iQuotePointer"] = F_iQuotePointer
      Settings[Form15Foto.Name &/ "F_sQuoteDateText"] = F_sQuoteDateText
      If PanelQuotes.Visible = True And F_iQuotePointer < ColumnView1.Count Then 
        ColumnView1.UnSelectAll()
        ' ColumnView3[F_iQuotePointer + 1].Selected = True 
      Endif
      F_bQuoteStarON = False
      PaintQuote()
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewCut()
  
  Dim picCut As Picture
  Dim sK1 As String 
  
  ''ColumnView3:
  If ColumnView1.Selection.Max > -1 Then 
    picCut = PicTemplateCut.Picture.Image.Stretch(22, 22).Picture
    For Each sK1 In ColumnView1.Selection
      ColumnView1[sK1].Picture = picCut
      ColumnView1[sK1][0] = ""
    Next
    F_bQuoteStarListChanged = True 
    ColumnView3ListChanged()
  Else 
    ButtonLineCut.Background = Color.Red
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Function ReadFileQuotes(Optional bFromBackup As Boolean = False) As String 
  
  Dim sDir, sFile, sPath, sDirFile, sText, sFileTime, sMessage As String 
  Dim ssQuotes As String[]
  Dim ssFiles As String[]
  Dim bEmpty As Boolean 
  
  If bFromBackup = True Then 
    sDir = Settings[FMain.Name &/ "F_sDirBackup", FMain.F_sDirBackup]
    sFile = "*" & File.BaseName(F_sPathPhotoSubtitleDate_txt) & "*.txt"
    ssFiles = Dir(sDir, sFile, gb.File)
    If ssFiles Then 
      ssFiles.Sort(gb.Descent)
      If ssFiles.Max > -1 Then sFile = ssFiles.First
      sDirFile = sDir &/ sFile
      If Exist(sDirFile) = True Then sText = File.Load(sDirFile) 
      If String.InStr(sText, "quote=") > 0 Then bEmpty = False Else bEmpty = True 
    Else 
      sFile = File.Name(F_sPathPhotoSubtitleDate_txt)
      sDirFile = sDir &/ sFile
    Endif
    If Exist(sDirFile) = True Then sPath = sDirFile
  Else 
    sFile = File.Name(F_sPathPhotoSubtitleDate_txt)
    
    ''Alternative 1
    sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
    If IsDir(File.Dir(sPath)) = True Then sDir = File.Dir(sPath)
    If IsDir(sDir) = True Then sDirFile = sDir &/ sFile
    If Exist(sDirFile) = True Then sText = File.Load(sDirFile) 
    
    ''Alternative 2
    If Not sText Then 
      sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
      sDirFile = sDir &/ sFile
      If Exist(sDirFile) = True Then sText = File.Load(sDirFile) 
    Endif 
    If IsDir(sDir) = False Then sDirFile = ("Ohne Datei")
    
    ''Alternative 3 Settings
    If Not sText Then 
      ssQuotes = Settings[Form15Foto.Name &/ "F_ssPanelQuotes", F_ssPanelQuotes]
      If ssQuotes Then sText = ssQuotes.Join(gb.NewLine)
      sDirFile = ("Ohne Datei")
    Endif 
    TextBoxPath.SelectAll()
    TextBoxPath.Insert(sDirFile)
    
    If sText Then bEmpty = False Else bEmpty = True 
  Endif 
  
  If Exist(sDirFile) = True Then sFileTime = "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</font>"
  
  sMessage = "<h4><font color=gray>" & ("Sicherungskopie") & ":" & "</font></h4>"
  sMessage &= "<h4><font color=gray>" & sDirFile & "</font>" & Space(1) & sFileTime & "</h4>"
  
  If bEmpty = True Then 
    sMessage &= "<h3><font color=darkgreen>" & "*" & ("Leer") & "</font></h3>"
  Else 
    sMessage &= String.Left(sText, 300) & "..."
  Endif 
  
  sMessage &= "<h3><font color=darkgreen>" & "● " & ("Öffnen") & "?" & "</font></h3>"
  
  Select Case Message.Question(sMessage, "● " & ("Öffnen"), ("Andere Datei öffnen..."), ("Abbrechen"))
      
    Case 1
      ColumnView3ReadQuotes(sText)
    Case 2
      ' ssFilter = [sFile, ("*Sternchen-Zeilen"), "*.txt", ("Nur-Text")]
      sPath = FileDialogPathReturn(sDirFile, "open", F_sPathPhotoSubtitleDate_txt)  'Last-Path, open/save, Standard-Path
      ' sPath = M01Functions.FileDialogOpen(sPath, ssFilter, Form15Foto.Window.Title & " - " & ("Öffnen...")) 'as String
      If Exist(sPath) = True Then sText = File.Load(sPath) 
      If sText Then ColumnView3ReadQuotes(sText)
      
    Case 3
      ''...
      
  End Select 
  
  Return sPath
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView3ReadQuotes(Optional sUndo As String = "")
  
  Dim it, iCounter As Integer
  Dim sKey, sLine, sText, sPath, sClock As String
  Dim ssLines As String[]
  Dim picCalendar, picStar As Picture 
  
  picCalendar = PicTemplateCalendar.Picture.Image.Stretch(22, 22).Picture
  picStar = PicTemplateBookmarkStar.Picture.Image.Stretch(22, 22).Picture
  sPath = F_sPathPhotoSubtitleDate_txt
  
  If sUndo Then
    sText = sUndo 
  Else  
    F_ssPanelQuotes = Settings[Form15Foto.Name &/ "F_ssPanelQuotes", F_ssPanelQuotes]
    If F_ssPanelQuotes Then sText = F_ssPanelQuotes.Join(gb.NewLine)
  Endif 
  
  sClock = Format(Now, "yyyy-mm-dd")
  
  ColumnView1.Clear()
  'ColumnView3.Header = 1 ' Sichtbar
  ColumnView1.Sorted = False ' nicht sortieren!
  'ColumnView1.Columns.Sort = TRUE
  'Spalten (Columns) erzeugen
  ColumnView1.Mode = Select.Multiple
  ColumnView1.Columns.Count = 1
  ColumnView1.Columns[0].Width = ColumnView1.Width
  
  If sText Then ssLines = Split(sText & gb.NewLine, gb.NewLine)
  
  ''From File?
  If ssLines And String.InStr(sText, "quote=") > 0 Then 
    F_ssPanelQuotes = New String[]
    For Each sLine In ssLines 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form15Foto.Window.Title) = True Then Break
      Endif 
      If sLine And String.InStr(sLine, "quote=") > 0 Then
        sLine = Replace(sLine, "quote=", "") 'Example: quote="Quelle Zitat1"
        sLine = UnQuote(sLine) 'Example: Quelle Zitat1
        If F_ssPanelQuotes.Find(sLine) = -1 And sLine <> F_sQuoteDateWithoutText And sLine <> F_sQuoteEmpty Then 
          iCounter = ColumnView1.Count + 1
          ColumnView1.Add(iCounter, "")
          ColumnView1[iCounter][0] = sLine 
          ColumnView1[iCounter].Picture = picStar
          ' ColumnView3[iCounter].Selected = True
          ' ColumnView3[iCounter].EnsureVisible
          F_ssPanelQuotes.Add(sLine)
        Endif 
      Endif 
    Next
  Endif
  
  ''From Settings?
  If sText And String.InStr(sText, "quote=") = 0 Then 
    F_ssPanelQuotes = New String[]
    For Each sLine In ssLines 
      ''[ESC]?
      If F_bESCpressedON = True Then 
        If MessageQuestionBreak(Form15Foto.Window.Title) = True Then Break
      Endif 
      If sLine Then
        If F_ssPanelQuotes.Find(sLine) = -1 And sLine <> F_sQuoteDateWithoutText And sLine <> F_sQuoteEmpty Then 
          iCounter = ColumnView1.Count + 1
          ColumnView1.Add(iCounter, "")
          ColumnView1[iCounter][0] = sLine 
          ColumnView1[iCounter].Picture = picStar
          F_ssPanelQuotes.Add(sLine)
        Endif 
      Endif 
    Next
  Endif
  
  iCounter = ColumnView1.Count + 1
  ColumnView1.Add(iCounter, "")
  ColumnView1[iCounter][0] = F_sQuoteDateWithoutText
  ColumnView1[iCounter].Picture = picCalendar
  F_ssPanelQuotes.Add(F_sQuoteDateWithoutText)
  
  iCounter = ColumnView1.Count + 1
  ColumnView1.Add(iCounter, "")
  ColumnView1[iCounter][0] = F_sQuoteEmpty
  ColumnView1[iCounter].Picture = picStar
  F_ssPanelQuotes.Add(F_sQuoteEmpty)
  
  ScrollViewQuote.Visible = F_bQuoteStarON
  If ScrollViewQuote.Visible = True Then 
    If Not F_sQuoteDateText Then F_sQuoteDateText = Settings[Form15Foto.Name &/ "F_sQuoteDateText", F_sQuoteDateText] 
    If F_sQuoteDateText Then 
      ColumnView1.UnSelectAll()
      For Each sKey In ColumnView1.Keys
        If ColumnView1[sKey].Text = F_sQuoteDateText Then 
          ColumnView1[sKey].Selected = True 
          Break 
        Endif 
      Next 
    Endif
  Endif
  If F_ooPanelQuotes Then 
    F_iQuotePointer = Settings[Form15Foto.Name &/ "F_iQuotePointer", F_iQuotePointer]
    If F_iQuotePointer > -1 And F_iQuotePointer < F_ooPanelQuotes.Count Then 
      it = F_iQuotePointer
      ScrollViewQuote.EnsureVisible(F_ooPanelQuotes[it].Left, 0, F_ooPanelQuotes[it].W, F_ooPanelQuotes[it].H)
    Endif 
  Endif   
  
  If ColumnView1.Keys.Count = 0 Then ColumnViewAddAppend()
  If F_sQuoteDateText Then 
    TextBoxQuote.SelectAll()
    TextBoxQuote.Insert(F_sQuoteDateText)
  Endif 
  F_bQuoteStarListChanged = True
  ColumnView3ListChanged()
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnView3SaveQuotes()
  
  Dim sKey, sLine, sText, sPath, sDir, sFile, sTitle, sMessage As String
  Dim ssLines As New String[]
  Dim picSaved As Picture
  Dim M, it, iLines As Integer
  Dim bSave As Boolean
  
  picSaved = ButtonSaveQuotes.Picture.Image.Stretch(22, 22).Picture
  
  sFile = File.Name(F_sPathPhotoSubtitleDate_txt)
  
  sPath = Settings[FMain.Name &/ "F_sPathTerminweckerActual_txt", FMain.F_sPathTerminweckerActual_txt]
  sDir = File.Dir(sPath)
  If IsDir(sDir) = True Then 
    sPath = sDir &/ sFile 
  Else 
    sPath = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName] &/ sFile
  Endif 
  
  For it = 0 To ColumnView1.Count - 1 
    If it = 0 Then 
      M = ColumnView1.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
    Else 
      M = ColumnView1.MoveBelow() '▼down
    Endif 
    If M = 0 Then 
      sKey = ColumnView1.Item.Key
      sLine = ColumnView1[skey].Text 
      If sLine Then 'not empty?
        ssLines.Add(sLine)
        sText &= "quote=" & Quote(sLine) & gb.NewLine
        iLines = iLines + 1
      Endif 
    Endif 
  Next
  
  sMessage = "<h3><font color=gray>" & ("*Liste Quell-Angaben") & ":" & Space(1) & iLines & Space(1) & "</font></h3>"
  sMessage &= "<h2><font color=darkgreen>" & ("Speichern") & "</font></h2>"
  sMessage &= "<h4><font color=blue>" & sPath & "</font>" & Space(1) 
  sMessage &= "<font color=darkgreen>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sPath) & "</font></h4>"
  
  Select Case Message.Question(sMessage, ("Speichern"), ("Ordner..."), ("Abbrechen"))
    Case 1
      bSave = True 
    Case 2 'Directory
      If Exist(sPath) = False Then sPath = Settings.Path
      M01Functions.FileManagerOpen(sPath)
    Case 2
      ''...
  End Select
  
  If bSave = True Then 
    If ssLines Then 
      ' sText = ssLines.Join(gb.NewLine)
      If IsDir(sDir) = True Then 
        
        ''Save:
        sTitle = "#" & Application.Name & Space(1) & Application.Version & Space(1) & ("Fußnoten-Zitate") & gb.NewLine
        sText = sTitle & sText
        '****************************************************
        sPath = M01Functions.FileTextPlus(sPath, sText, True) ' TRUE=overwrite (überschreiben)
        '****************************************************
        If Exist(sPath) = False Then 
          ''Alternative:
          sPath = ("Ohne Datei")
        Else
          F_bQuoteStarListChanged = False 'Reset
          ColumnView3ListChanged()
        Endif 
        TextBoxPath.SelectAll()
        TextBoxPath.Insert(sPath)
      Endif 
      For Each sKey In ColumnView1.Keys
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form15Foto.Window.Title) = True Then Break
        Endif 
        ColumnView1[sKey].Picture = picSaved
      Next
    Endif
    F_ssPanelQuotes = ssLines.Copy()
    Settings[Form15Foto.Name &/ "F_ssPanelQuotes"] = ssLines.Copy()
    UndoRedoTextLines("save")    
    F_bQuoteStarListChanged = False
    ColumnView3ListChanged()
    CreatePanelQuote()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView3SaveAsQuotes(Optional sExt As String = "txt")
  
  Dim sPath, sText, sTitel, sNew, sLine, sKey As String 
  Dim ssFilter, ssLines As New String[]
  Dim M, it, iLines As Integer
  Dim picSaved As Picture
  
  ssFilter.Add("*.txt") 'Filter
  ssFilter.Add("Nur-Text") 'FilterText
  ' ssFilter.Add("*.csv") 'Filter
  ' ssFilter.Add("Tabelle, Trenner: Return (NewLine)") 'FilterText
  ' "*" 
  ' "All Files" ' Standard Anhang
  sTitel = Application.Name & " - " & ("Speichern unter...")
  picSaved = ButtonSaveQuotes.Picture.Image.Stretch(22, 22).Picture
  
  sPath = TextBoxPath.Text
  sPath = File.SetExt(sPath, sExt)
  
  If PanelQuotes.Visible = True Then
    For it = 0 To ColumnView1.Count - 1 
      If it = 0 Then 
        M = ColumnView1.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
      Else 
        M = ColumnView1.MoveBelow() '▼down
      Endif 
      If M = 0 Then 
        sKey = ColumnView1.Item.Key
        sLine = ColumnView1[skey].Text 
        If sLine Then 'not empty?
          ssLines.Add(sLine)
          sText &= "quote=" & Quote(sLine) & gb.NewLine
          iLines = iLines + 1
        Endif 
      Endif 
    Next
  
    sPath = M01Functions.FileDialogSave(sPath, sText, ssFilter, sTitel) 'as String
    If Exist(sPath) = True Then 
      ' sNew = M01Functions.FileLastModifiedTimeSize(sPath) 'as String 
      ' sNew = "<b><font color=darkgreen>" & ("Gespeichert") & ": " & "</b></font>" & Space(1) & sNew
      For Each sKey In ColumnView1.Keys
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form15Foto.Window.Title) = True Then Break
        Endif 
        If ColumnView1[skey].Text Then ColumnView1[sKey].Picture = picSaved
      Next
      ListIsChanged.Picture = PicTemplateLEDgreen.Picture 
      F_ssPanelQuotes = ssLines.Copy()
      Settings[Form15Foto.Name &/ "F_ssPanelQuotes"] = ssLines.Copy()
      UndoRedoTextLines("save")    
      F_bQuoteStarListChanged = False
      ColumnView3ListChanged()
      CreatePanelQuote()
    Else 
      sNew = "<b><font color=red>" & ("Datei fehlt") & ": " & "</b></font>" & Space(1) & sPath
      Message.Info(sNew, ("Abbrechen"))
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewUpDown(Optional sUpDown As String = "up") '▲
  
  Dim sK1, sK2, sC1, sC2 As String 
  Dim M As Integer = -1
  Dim picStar, picUp, picDown As Picture
  
  picStar = PicTemplateBookmarkStar.Picture.Image.Stretch(22, 22).Picture
  
  ''ColumnView3:
  Select Case sUpDown
    Case "up"
      If PanelQuotes.Visible = True Then 
        If ColumnView1.Selection.Max > -1 Then 
          picUp = PicTemplateListUp.Picture 
          sK1 = ColumnView1.Selection.First
          M = ColumnView1.MoveTo(sK1)
          ' M = ColumnView3.MoveBelow() '▼down
          M = ColumnView1.MoveAbove() '▲up
          If M = -1 Then ColumnView1.MoveFirst() '▼ 'M=0=False>Exist. M=-1=True>Missing
          sK2 = ColumnView1.Item.Key
          sC1 = ColumnView1[sK1][0] 
          sC2 = ColumnView1[sK2][0]
          ColumnView1[sK1][0] = sC2 'Change Column
          ColumnView1[sK2][0] = sC1
          ColumnView1[sK2].Selected = True 
          ColumnView1[sK1].Picture = picStar '*
          ColumnView1[sK2].Picture = picUp '▲
          F_bQuoteStarListChanged = True 
        Endif
      Endif 
    Case "down"
      If PanelQuotes.Visible = True Then 
        If ColumnView1.Selection.Max > -1 Then 
          picDown = PicTemplateListDown.Picture 
          sK1 = ColumnView1.Selection.First
          M = ColumnView1.MoveTo(sK1)
          M = ColumnView1.MoveBelow() '▼down
          ' M = ColumnView3.MoveAbove() '▲up
          If M = -1 Then ColumnView1.MoveLast() '▼ 'M=0=False>Exist. M=-1=True>Missing
          sK2 = ColumnView1.Item.Key
          sC1 = ColumnView1[sK1][0] 
          sC2 = ColumnView1[sK2][0]
          ColumnView1[sK1][0] = sC2 'Change Column
          ColumnView1[sK2][0] = sC1
          ColumnView1[sK2].Selected = True 
          ColumnView1[sK1].Picture = picStar '*
          ColumnView1[sK2].Picture = picDown '▼
          F_bQuoteStarListChanged = True 
        Endif
      Endif 
  End Select
  ColumnView3ListChanged()
  
Catch
  FMain.ErrorText
  
End

Public Function MessageQuestionBreak(Optional sMessage As String = ("Unterbrochen mit [ESC]")) As Boolean
  ''[ESC]?
  
  If F_bESCpressedON = True Then 
    sMessage = "<h3><font color=red>" & sMessage & "</font></h3>"
    
    Select Case Message.Question(sMessage, ("weiter..."), ("Abbrechen"))
      Case 1
        F_bESCpressedON = False
      Case 2
        F_bESCpressedON = True
    End Select
  Endif 
  
  Return F_bESCpressedON 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ColumnViewAddAppend()                                                          '1x new Line at end
  
  Dim sK0, sK1 As String 
  Dim picAdd As Picture
  Dim M As Integer
  
  If ColumnView1.Columns.Count < 1 Then ColumnView3ReadQuotes()
  picAdd = ButtonNewLine.Picture.Image.Stretch(22, 22).Picture
  
  '.Header=True is first Line (Title)
  
  M = ColumnView1.MoveLast()
  If M = 0 Then 'M=0=False>Exist. M=-1=True>Missing
    sK0 = ColumnView1.Item.Key                                'only Keys     index 0,1,2,3... Keys "1","2","3"...
    ColumnView1[sK0].EnsureVisible()  
  Endif 
  
  If ColumnView1.Exist(sK0) = True Then 
    ColumnView1.UnselectAll()
    M = ColumnView1.MoveNext() 'M=0=False>Exist. M=-1=True>Missing
    If M = -1 Then sK1 = ColumnView1.Count + 1 '+Plus new Line at the End
    If ColumnView1.Exist(sK1) = False Then 
      ColumnView1.Add(sK1, "", PicAdd,, sK0)                                  'Add Last (default), Add After (sK0) 
      ColumnView1[sK1].Selected = True
      ColumnView1[sK1].EnsureVisible()  
      M = ColumnView1.MoveLast()
      F_bQuoteStarListChanged = True 
      ColumnView3ListChanged()
    Endif 
  Else 'empty +1 
    sK1 = ColumnView1.Count + 1 
    ColumnView1.Add(sK1, "", PicAdd)          
    ColumnView1[sK1].Selected = True
    ColumnView1[sK1].EnsureVisible()  
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Function Columnview1EnsureVisible() As String 'Key
  
  Dim sK2 As String 
  
  If ColumnView1.Visible = True Then 
    If ColumnView1.Current Then 
      sK2 = ColumnView1.Current.Key
      If ColumnView1.Exist(sK2) = True Then ColumnView1[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
    Endif 
  ' Else If ColumnView2.Visible = True Then 
  '   If ColumnView2.Current Then 
  '     sK2 = ColumnView2.Current.Key
  '     If ColumnView2.Exist(sK2) = True Then ColumnView2[sK2].EnsureVisible() 'visible area (sichtbarer Bereich)
  '   Endif 
  Endif 
  
  Return sK2
  
  Catch 
    FMain.ErrorText
  
End

Public Sub ButtonInputG() 'Zeileneintrag einfügen
  
  Dim sKey As String
  Dim picChanged As Picture
  
  Columnview1EnsureVisible()
  
  If ColumnView1.Selection.Max > -1 Then 
    picChanged = PicTemplateReChange.Picture.Image.Stretch(22, 22).Picture
    sKey = ColumnView1.Selection.First
    ColumnView1[sKey].Text = TextBoxQuote.Text
    ColumnView1[sKey].Picture = picChanged
  Else 
    ColumnViewAddAppend()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub ColumnView1_Click()
  
  Dim sKey, sLine As String 
  Dim it As Integer
  
  If ColumnView1.Selection.Max > -1 Then 
    sKey = ColumnView1.Selection.First 
    sLine = ColumnView1[sKey].Text
    TextBoxQuote.SelectAll()
    TextBoxQuote.Insert(sLine)
    F_iQuotePointer = CInteger(sKey) - 1
    If F_ooPanelQuotes Then 
      For it = 0 To F_ooPanelQuotes.Max
        If it = F_iQuotePointer Then 
          F_ooPanelQuotes[it].Background = Color.Green
          F_ooPanelQuotes[it].Font.Bold = True 
          Settings[Form15Foto.Name &/ "F_iQuotePointer"] = F_iQuotePointer
          ScrollViewQuote.EnsureVisible(F_ooPanelQuotes[it].Left, 0, F_ooPanelQuotes[it].W, F_ooPanelQuotes[it].H)
        Else 
          F_ooPanelQuotes[it].Background = Color.Default   
          F_ooPanelQuotes[it].Font.Bold = False 
        Endif 
      Next
      SelectQuote()
    Else 'New
      CreatePanelQuote()
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GroupUndo_Click()
  
  Select Case Last.Tag
    Case "quotesundo"
      UndoRedoTextLines("undo")
    Case "quotesredo"
      UndoRedoTextLines("redo")
    Case "sortabc"
      ColumnView1.Sorted = Not ColumnView1.Sorted
      ColumnView1.Columns.Ascending = Not ColumnView1.Columns.Ascending
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
    Case "openquotes"
      ReadFileQuotes()
    Case "openquotesbackup"
      ReadFileQuotes(True)
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoTextLines(Optional sUndoRedoSave As String = "save")
  
  Dim sKey, sText As String 
  Dim ssLines As New String[]
  Dim iMax As Integer
  
  If Not F_ssUndo Then F_ssUndo = New String[]
  
  Select Case sUndoRedoSave 
    Case "save"
      For Each sKey In ColumnView1.Keys
        ''[ESC]?
        If F_bESCpressedON = True Then 
          If MessageQuestionBreak(Form15Foto.Window.Title) = True Then Break
        Endif 
        ssLines.Add(ColumnView1[sKey].Text)
      Next
      F_ssUndo.Add(ssLines.Join(gb.NewLine))
      F_iCVUndoRedoPointer = F_ssUndo.Max
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      
    Case "undo"''-
      F_iCVUndoRedoPointer = F_iCVUndoRedoPointer - 1
      If F_iCVUndoRedoPointer < 0 Then F_iCVUndoRedoPointer = -1
      If F_iCVUndoRedoPointer > F_ssUndo.Max Then F_iCVUndoRedoPointer = F_ssUndo.Max
      If F_iCVUndoRedoPointer > -1 Then 
        sText = F_ssUndo[F_iCVUndoRedoPointer]
      Else 
        sText = F_sQuoteEmpty
      Endif 
      ColumnView3ReadQuotes(sText)
      
    Case "redo"''+
      F_iCVUndoRedoPointer = F_iCVUndoRedoPointer + 1
      If F_iCVUndoRedoPointer < 0 Then F_iCVUndoRedoPointer = -1
      If F_iCVUndoRedoPointer > F_ssUndo.Max Then F_iCVUndoRedoPointer = F_ssUndo.Max
      If F_iCVUndoRedoPointer > -1 Then 
        sText = F_ssUndo[F_iCVUndoRedoPointer]
      Else 
        sText = F_sQuoteEmpty
      Endif 
      ColumnView3ReadQuotes(sText)
  End Select
  If F_ssUndo Then iMax = F_ssUndo.Max Else iMax = -1
  MenuUndoPointer.Text = (F_iCVUndoRedoPointer + 1) & " / " & (iMax + 1)
  ListBackupCounter.Text = MenuUndoPointer.Text
  
Catch
  FMain.ErrorText
  
End

Public Sub FileInfoG()
  
  Form19FileInfo.Tag = TextBoxPath.Text 'as String 
  Form19FileInfo.Window.Show
  ' Form19FileInfo.Window.Visible = True 'Wayland error?
  
Catch 
  FMain.ErrorText
  
End  

Public Sub LabelInfoPathG(Optional sDirFile As String = Null) '<HTML>
  
  ' If Exist(sDirFile) = False Then sDirFile = FilePathForm()
  If Exist(sDirFile) = True Then
    LabelInfo.Text = File.Name(sDirFile) & Space(3) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
  Else 
    LabelInfo.Text = ("Ohne Datei")
  Endif 
  LabelInfo.Background = Color.LightBackground
  LabelInfo.Visible = True 
  
  If Exist(sDirFile) = True Then 
    TextBoxPath.Selectall()
    TextBoxPath.Insert(sDirFile)
  Else 
    TextBoxPath.Selectall()
    TextBoxPath.Insert(("Ohne Datei"))
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutAreaCheckMax()
  
  Dim X, Y, W, H As Integer
  'LabelCutArea in Form+PanelGlass, Eckpunkte in Form. 
  
  '|◀▷|
  If LabelCutArea.Left < 0 Then X = 0 Else X = LabelCutArea.Left 
  
  If LabelCutArea.Left + LabelCutArea.W > PanelGlass.W Then 
    X = PanelGlass.W - LabelCutArea.W 
    W = LabelCutArea.W
  Else 
    W = LabelCutArea.W
  Endif 
  
  '_▲▽
  If LabelCutArea.Top < 0 Then Y = 0 Else Y = LabelCutArea.Top
  
  If LabelCutArea.Top + LabelCutArea.H > PanelGlass.H Then 
    Y = PanelGlass.H - LabelCutArea.H 
    H = LabelCutArea.H
  Else 
    H = LabelCutArea.H
  Endif 
  
  LabelCutArea.Move(X, Y, W, H) 
  LabelCutArea.Raise
  LabelCutArea.Visible = True 
  LabelCutArea.Background = F_iColorGreen220
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelMessageTool_MouseDown()

  Dim sSoftwareCenter, sTool As String
  
  sTool = "gnome-screenshot" 'Ubuntu mangages: "gnome-software allows you to add and remove applications and update your system."
  ' sTool = System.Find(sTool)
  'https://manpages.ubuntu.com/manpages/xenial/en/man1/gnome-software.1.html
  LabelMessageTool.Visible = False 
  
  ''Software-Center  *.deb > Install > De-Install
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("snap-store")
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("gnome-software")
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("ubuntu-software")
  If sSoftwareCenter = "" Then sSoftwareCenter = System.Find("gnome-control-center")
  ' If sSoftwareCenter <> "" Then sSoftwareCenter = sSoftwareCenter & Space(1) & sTool
  Clipboard.Clear
  Clipboard.Copy(sTool, "text/plain")
  
  Shell sSoftwareCenter  ' "gnome-control-center application" 
  
Catch 
  FMain.ErrorText

End

Public Sub PhotoButtonG()
  
  Timer1.Stop
  PhotoScreen()
  
  Print "PhotoButtonG()"
  
  CopyButtonG()' PhotoCutArea()'LabelPixelWxHScalePicture()
  
  Timer1.Start
  
Catch 
  FMain.ErrorText

End

Public Sub Form_Close() 
  
  CheckLastestPhoto("save")
  SettingsReadSave("save") 
  ' FMain.Window.Minimized = F_bFMainMinimizedBefore
  ' FMain.Window.Show()
  FMain.Window.Visible = True 'Wayland error?
  FMain.Window.Raise() 'top level
  ' Windows[FMain.Id].TopOnly = True 
  FMain.F_bFMainSetFocus = True '—▶ FMain
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckZoomPhotoOptimal(Optional bImageViewON As Boolean = False)
  
  ImageViewPhoto.Visible = bImageViewON
  PanelGlass.Visible = Not ImageViewPhoto.Visible
  
  If ImageViewPhoto.Visible = True Then LabelM4Full.Enabled = False Else LabelM4Full.Enabled = True
  CornerPointsToLabelCutAreaONoff(LabelM4Full.Enabled)
  
  If F_bZoomLupeON = True Then 
    PanelColorZoom.Visible = True
    PicBoxCutPreview.Visible = False
  Else 
    PanelColorZoom.Visible = False
    PicBoxCutPreview.Visible = True
  Endif 
  
  If PicBoxPhoto.Picture Then 
    ImageViewPhoto.Update(PicBoxPhoto.Picture.Image)
  Else 
    ImageViewPhoto.Update(PicTemplateQuestion256.Picture.Image.Stretch(Screen.W, Screen.H))
  Endif 
  Form15Foto.Window.Title = Application.Name & " - " & ("Zoom") & ": " & Round(ImageViewPhoto.Zoom, -1)
  
  ' ButtonGroup_Leave()
  ButtonGroupLeaveDeafaultG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckLastestPhoto(Optional sOpenSave As String = "open")
  
  Dim sDir, sFile, sDirFile As String 
  
  sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
  
  sFile = "photolatest.png"
  sDirFile = sDir &/ sFile
  PicBoxPhotoLatest.Tooltip = ("Zuletzt gemachtes Foto übernehmen")
  
  Select Case sOpenSave
    Case "open"
      If Exist(sDirFile) = True Then 
        PicBoxPhotoLatest.Picture = Picture.Load(sDirFile) 
        PicBoxPhotoLatest.Tooltip &= "<br>" & sDirFile & "<br>" & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & "</b>" & Space(1) & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</font>"
      Endif 
      If PicBoxPhotoLatest.Picture Then 
        PicBoxPhoto.Picture = PicBoxPhotoLatest.Picture.Copy()
        If Not F_ooUndoRedoPhoto Then 
          PictureFotoAddUndoSelect(PicBoxPhotoLatest.Picture.Image)
        Else 
          If F_ooUndoRedoPhoto.Find(PicBoxPhotoLatest.Picture.Image) = -1 Then PictureFotoAddUndoSelect(PicBoxPhotoLatest.Picture.Image)
        Endif 
      Endif 
      ' If Not PicBoxPhotoLatest.Picture Then PicBoxPhotoLatest.Picture = PicTemplateQuestion256.Picture
      
    Case Else '"save"
      If IsDir(sDir) = True And PicBoxPhoto.Picture Then PicBoxPhoto.Picture.Save(sDirFile) 
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoScreen(Optional bFormON As Boolean = False) 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  
  Dim imgScreen As Image
  Dim picScreen As Picture
  Dim sDir, sFile, sFileTest, sDirFile, sTool As String

  sDir = Desktop.GetDirectory("PICTURES") 'as String  (Bilder)
  sFile = "Screenshot.png"
  sDirFile = sDir &/ sFile 
  If Exist(sDirFile) = True Then Try Kill sDirFile 
  
  Timer1.Stop
  ' F_iFormGeometryRectXYWH = Form15Foto.Window.Geometry 'Rect(x, y, w, h)
  PicBoxLED.Picture = PicTemplateLEDred.Picture
  PicBoxCutPreview.Background = Color.Background
  
  If bFormON = True Then 
    CornerPointsToLabelCutAreaONoff(False)
    LabelCutArea.Visible = False 
  Endif 
  
  sDir = FMain.F_sDirCache
  If IsDir(sDir) = False Then 
    sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
    If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache() 'M01Functions.CheckDirAppName()
  Endif 
  sDirFile = sDir &/ sFile
  If Exist(sDirFile) = False
    sFileTest = String.LCase(sFile) '"Screenshot.png", "screenshot.png", "screenshot.PNG"
    If Exist(sDir &/ sFileTest) = True Then 
      sDirFile = sDir &/ sFileTest 
      ' Settings[FMain.Name &/ "F_sPathScreenphotoPNG"] = sDirFile 
    Endif 
  Endif 
  ' F_sPathScreenphotoPNG = sDirFile
  
  PicBoxPhoto.Picture = Null 'Reset
  
  If bFormON = False Then
    ''Screen without Form: □
    If Desktop.Platform = "x11" Then 
      Form15Foto.Window.Visible = False 
      Wait 0.3 'Menü und Dock ausblenden lassen
    Else 
      'No click, no event. Move Form-Window outside the screen:
      Form15Foto.Window.Visible = False
      Wait 0.5
    Endif 
  Endif 
  PicBoxPhoto.Picture = Null 'Reset
  If Exist(sDirfile) = True Then Kill sDirFile
  
  ''Desktop Full Screen Photo:
  '*****************************************
  ' imgScreen = Desktop.Screenshot().Image ''as Picture, Bildschirmfoto alles=(), Auschnitt=(x,y,w,h)
  ' PicBoxPhoto.Picture = Desktop.Screenshot()  ''as Picture, Bildschirmfoto alles=(), Auschnitt=(x,y,w,h)
  
  ' System.Find("gnome-screenshot")
  ' Shell "gnome-screenshot --file=" & User.Home &/ ".cache/gnome-screenshot" &/ "xx.png" Wait
  ' Shell "gnome-screenshot -c" Wait
  sTool = "gnome-screenshot"
  ' sTool = "screengrab"
  ' sTool = "gdm3"
  
  If System.Exist(sTool) = False Then sTool = System.Find(sTool) 
  If sTool Then Shell sTool & Space(1) & "--file=" & sDirFile Wait
  ' Shell sTool & Space(1) & "--clipboard" & Space(1) & "--display=gdm3" Wait 'Terminal: "echo $DISPLAY" —▶ ":0"
  ' If sTool Then Shell sTool & Space(1) & "--clipboard" Wait
  ' Wait until at least one event is processed.
  If Exist(sDirFile) = True Then imgScreen = Image.Load(sDirFile)
  ' If Clipboard.Type = Clipboard.Image Then imgScreen = Clipboard.Paste()
  ' If Exist(sDirFile) = True Then PicBoxPhoto.Picture = Picture.Load(sDirFile)
  ' If PicBoxPhoto.Picture Then imgScreen = PicBoxPhoto.Picture.Image
  
  ''Gambas3 Screenshot:
  If Not imgScreen Then 'Desktop.Screenshot() 'as Picture   ?—▶ /home/user/PICTURES/Screenshot.png
    'PictureBox.Picture = Desktop.Screenshot() 'Return as Picture AND save Picture as file Screenshot.png, Screenshot1.png, Screenshot2.png, ... 
    ' Try picScreen = Desktop.Screenshot() ''as Picture, Bildschirmfoto alles=(), Auschnitt=(x,y,w,h)
    picScreen = M01Functions.ScreenshotGambasCentral() 'as Picture  Desktop.Screenshot()
    If picScreen Then imgScreen = picScreen.Image
  Endif 
  
  If M01Functions.ScreenshotImageExist(imgScreen) = True Then 
    FMain.F_sScreenshotToolPath = "gambas" & System.Version 'Example: "gambas3"
  Else 
    ''Missing? Alternative:
    imgScreen = M01Functions.ScreenshotImageAlternative() 'as Image
  Endif 
  
  ''If missing too, then Demo:
  If Not imgScreen Then imgScreen = M01Functions.ScreenshotImageDemo(PicBackground.ScreenX, PicBackground.ScreenY, PicBackground.W, PicBackground.H) 'as Image
  
  ' If imgScreen Then 
  '   Clipboard.Clear
  '   Clipboard.Copy(imgScreen) 'Image, not Picture!
  ' Endif 
  
  ''Reset Form-Position:
  If Desktop.Platform = "x11" Then 
    Form15Foto.Window.Minimized = False
    Form15Foto.Window.Visible = True 'Wayland error?
    Form15Foto.Window.TopOnly = True 'not in Wayland?
  Else  
    Form15Foto.Window.Visible = True 
    
    ' sInfo = ("Hinweis zum System: Wechsel von 'X11' zu 'Wayland' Window-Manager (Fenster-Macher).") & gb.NewLine
    ' sInfo &= ("Probleme beim veränderten Fensterverhalten und in der Zwischenablage.") & gb.NewLine
    ' sInfo &= ("Aktiv") & ": " & Desktop.Platform ' as String, "x11" or "wayland" 
    ' sInfo &= gb.NewLine
    ' If String.InStr(FMain.F_sErrorMessagesExtra, sInfo) = 0 Then FMain.F_sErrorMessagesExtra &= sInfo & gb.NewLine
    ' If FMain.F_sErrorInfos Then 
    '   IconError.Picture = Picture.Load("images/warning_32.png")
    ' Else 
    '   IconError.Picture = Picture.Load("images/infomessage_32.png")
    ' Endif 
    ' IconError.Visible = True  
  Endif 
  
  ''Check full visible:
  If imgScreen Then 
    PicBoxPhoto.Picture = imgScreen.Picture '◀—
    
    ''Save:
    If PicBoxPhoto.Picture And IsDir(sDir) = True Then PicBoxPhoto.Picture.Save(sDirFile)
    ' If IsDir(sDir) = True Then imgScreen.Save(sDirFile)
    
    ''Check Clipboard Load Return:
    'Clipboard.Copy(Data As Variant, Format As String) 'Data=Text, Format= text/plain, Format= Data, not Image.
    ' If Clipboard.Type <> Clipboard.Image And Exist(sDirFile) = True Then 
    ' If Exist(sDirFile) = True Then 
    '   Clipboard.Clear
    '   Clipboard.Copy(Image.Load(sDirFile)) 'Image, not Picture!
    ' Endif 
    ' F_imgScreen = imgScreen '◀—   ???
    ' If Clipboard.Type = Clipboard.Image Then imgTemp = Clipboard.Paste()
    ' If Not imgTemp Then imgTemp = M01Functions.ClipboardImage() 'as Image
    PicBoxLED.Picture = PicTemplateLEDgreen.Picture
    ButtonM8Copy.Background = Color.Green
    PicBoxCutPreview.Background = Color.Green
    UndoRedoPhotoImageAdd(imgScreen)
  Else 
    PicBoxLED.Picture = PicTemplateLEDyellow.Picture
    ButtonM8Copy.Background = Color.Yellow
    PicBoxCutPreview.Background = Color.Yellow
  Endif
  ' If picScreen Then F_imgScreen = picScreen.Image
  ' Timer1.Start
  
  Print "PhotoScreen"
  'Problem, Error? copy finished, paste unfinished (*1)
  
  ''________________________________________________''
  '"https://gambaswiki.org/wiki/howto/package/v3.18"
  'register mime type "application-x-gambasscript.png"
  'Gambas3: "The gbs3 symbolic link MUST be in the PATH, otherwise scripts will not work."
  'component: gb.image
  'component: gb.image.imlib ?
  'wikipedia: "Das Wayland-Protokoll enthält keine API zur Bildsynthese. Jeder Wayland-Client ist für Bildsynthese seines Fensterinhaltes selbst verantwortlich und schreibt das Ergebnis in seinen eigenen Puffer. Für Bildsynthese kann es eine eigene Engine mitbringen oder eine externe Bibliothek nutzen, wie z. B. Cairo, OpenGL oder Vulkan, oder auch die Rerendering engine von Qt oder GTK+ benutzen."
  'https://de.wikipedia.org/wiki/Wayland_(Display-Server-Protokoll)
  '(*1) broken image (unvollständig, abgebrochenes Bild)?  https://wiki.ubuntu.com/ClipboardPersistence
  'pngquant komprimiert png ähnlich gif. Aktivierung siehe Menü > Werkzeuge > Einstellungen... (Properties). Sicherheitsprobleme > "https://de.wikipedia.org/wiki/Libpng". 'Multi' png. mng ist ein Tochterformat von png, ebenso apng. Multi-Bilder, animiert (Film). Abwärtskompatibel. Ersatz für gif (gifa animation). 
Catch 
  FMain.ErrorText
  
End 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Public Sub CutImageSaveAndReadInClipboard() 'Test, unused?

  Dim sDir, sDirFile, sTool As String 
  Dim imgScreen As Image
  
  ' Copying a file to the clipboard in Linux
  ' 1    $ xclip-copyfile file1. $ xclip-copyfile file1 file2.
  ' 2    $ xclip-copyfile /etc/hosts.
  ' 3    $ cd /tmp/ $ xclip-pastefile.
  sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
  If IsDir(sDir) = False Then M01Functions.CheckDirAppName
  sDirFile = sDir &/ File.Name(F_sPathScreenphotoPNG)
  If IsDir(File.Dir(sDirFile)) = False Then M01Functions.CheckDirAppName(File.Dir(sDirFile), False)
  ' Settings[FMain.Name &/ "F_sPathScreenphotoPNG"] = sDirFile 
  ' If PicBoxCutPreview.Picture Then PicBoxCutPreview.Picture.Save(sDirFile)
  If PicBackground.Picture Then PicBackground.Picture.Save(sDirFile)
  
  ''Alternative 3: xwd (x11)
  ' If Not imgScreen Then 
  sTool = "xwd"  'x11-apps
  '- xwd, a utility for taking window dumps ("screenshots") of the X session;
  'Only Text:  - xclipboard, a tool to manage cut-and-pasted text selections;
  
  ' If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
  ' '' -silent (Operate silently, i.e. don't ring any bells before and after dumping the window)
  ' If Exist(sTool) = False Then sTool = System.Find(sTool) 'Else sTool = ""   'X11  "xwd -screen -out FILE"
  ' If Exist(sTool) = True Then 
  FMain.F_sScreenshotToolPath = sTool 'no search, faster
  ' sDirFile = M01Functions.ProgramDirCache("xwd-screenshot-cut.png")
  ' If Exist(sDirFile) = True Then Try Kill sDirFile
  ' If sTool Then Shell sTool & Space(1) & "-root -out " & sDirFile Wait  '-root = Fullscreen
  ' If sTool Then Shell sTool & " -screen -out " & sDirFile 
  ' Shell sTool & " -copyfile " & sDirFile
  If Exist(sDirFile) = True Then 
    Try imgScreen = Image.Load(sDirFile)
    Clipboard.Clear
    Clipboard.Copy(imgScreen)
  Endif 
  ' Endif 
  ' If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
  'MIT, Smithsonian Astrophysical Observatory
  'https://manpages.ubuntu.com/manpages/jammy/en/man1/xwd.1.html
  'https://manpages.ubuntu.com/manpages/lunar/en/man1/xclip-copyfile.1.html
  ' Endif
  
  If imgScreen Then 
    PicBoxLED.Picture = PicTemplateLEDgreen.Picture
    ButtonM8Copy.Background = Color.Green
    PicBoxCutPreview.Background = Color.Green
  Else 
    PicBoxLED.Picture = PicTemplateLEDyellow.Picture
    ButtonM8Copy.Background = Color.Yellow
    PicBoxCutPreview.Background = Color.Yellow
  Endif
  
  ' sTool = "xwd" 
  ' sTool = System.Find(sTool)
  ' If Exist(sTool) = True And Exist(sDirFile) = True Then 
  '   Print sTool 
  '   Shell sTool & Space(1) & sDirFile 
  ' Endif
  
Catch 
  FMain.ErrorText

End

Public Sub CopyButtonG()
  
  Dim sDirFile, sDir, sFile, sExt As String
  Dim imgScreen As Image
  
  Timer1.Stop
  PicBoxLED.Picture = PicTemplateLEDred.Picture
  
  F_sPathScreenphotoPNG = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG] 
  Print Form15Foto.F_sPathScreenphotoPNG
  Print FMain.F_sPathScreenphotoPNG
  sDir = File.Dir(F_sPathScreenphotoPNG)
  sDirFile = F_sPathScreenphotoPNG
  sExt = File.Ext(sDirFile) '"png"
  If sExt = "png" And IsDir(sDir) = False Then 
    sFile = File.Name(sDirFile)
    sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
    ' sDir = FMain.F_sDirAppName
    If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
    If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
    sDirFile = sDir &/ sFile
  Endif 
  
  If ImageViewPhoto.Visible = False Then 
    PhotoCutArea()'LabelPixelWxHScalePicture() ' PaintQuote()
  Endif  

  ' If IsDir(sDir) = True Then sDir = File.Dir(F_sPathScreenphotoPNG)
  If IsDir(sDir) = True Then 
    ' sDirFile = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG] 
    ' If IsDir(File.Dir(sDirFile)) = False Then M01Functions.CheckDirAppName(File.Dir(sDirFile), False)
    If sDir <> sDirFile And Exist(sDirFile) = True Then Kill sDirFile  
    If PicBoxCutPreview.Picture And IsDir(sDir) = True Then PicBoxCutPreview.Picture.Save(sDirFile)
    ' If PicBackground.Picture Then PicBackground.Picture.Save(sDirFile)
    
    If Exist(sDirFile) = True Then 
      imgScreen = Image.Load(sDirFile)
      If Not imgScreen And PicBoxCutPreview.Picture Then imgScreen = PicBoxCutPreview.Picture.Image
      If imgScreen Then 
        Clipboard.Clear
        Clipboard.Copy(imgScreen) 'Image, not Picture!  'image/png mime type
        Wait
        If Clipboard.Type <> Clipboard.Image Then imgScreen = M01Functions.ScreenshotImageAlternative()
        If imgScreen Then CopyImageToClipboard(imgScreen)

        ' If Desktop.Platform = "wayland" Then 'bug, image not finished?
        '   ''Check Clipboard:
        '   ' If Clipboard.Type <> Clipboard.Image Then 
        '   imgScreen = ClipboardCopyImageAlternative(imgScreen) 'as Image
          
        '   ' Try Shell sTool & Space(1) & "--clipboard" Wait    '"-c"    
        '   ' Endif 
        ' Endif 
      Endif 
      
    Endif 
    
    ' CopyButtonG()
    Print "CopyButtonG()"
  Endif 
  
  ' Img = ClipboardCopyImageAlternative(PicBackground.Picture.Image)
  ' CutImageSaveAndReadInClipboard()
  
  ''in Clipboard ([Zwischenablage]):
  ' If PicBoxCutPreview.Picture Then 
  '   Clipboard.Clear() 'no longer?
  '   ' Wait
  '   ' '??? libpng error: Read Error
  '   ' Img = PicBoxCutPreview.Picture.Image
  '   
  '   ' Wait 0.5
  '   ' Clipboard.Current = Clipboard.Default 'Example: "CTRL+V" = primary Paste about keyboard (Tastenkombination)
  '   ' Clipboard.Current = Clipboard.Selection 'Example: secondary, "x11", Mouse selection middle (Menüauswahl) '(*1)
  '   ' Clipboard.Current = Clipboard???
  '   ' „CLIPBOARD“ "wird identisch wie das Pendant aus [Microsoft] Windows benutzt.Der Unterschied zu den bereits erwähnten Systemen ist, dass die Daten nicht extra in der Zwischenablage abgelegt werden, sondern nur deren Referenz. Die Anwendung übernimmt den Besitz der Selektion und kommuniziert dies dem X Server. Sobald ein Einfügen erfolgt, wird das Datenobjekt und seine verfügbaren Formate von der Anwendung angefordert und abhängig davon eingefügt."
  '   ' # Um den Inhalt eines Ordners in die Zwischenablage einzufügen.
  '   ' Set-Clipboard -Path "C:\directory\"
  '   ' # Um den Inhalt der Ablage zu erlangen.
  '   ' Get-Clipboard
  '   ' 
  '   '
  '   ' (*1) https://de.wikipedia.org/wiki/Zwischenablage
  '   Clipboard.Current = Clipboard.Default 'Primary=0
  '   ' Wait
  '   Clipboard.Copy(PicBoxCutPreview.Picture.Image) 'Copy In Clipboard(Zwischenablage) 
  '   ' Wait
  '   ' sHTML = "!file:///home/user/dir/file.ext!"
  '   'xml, html
  '   ' vHTML = "<test>" & gb.NewLine & "<tooltip=" & F_sPathScreenphotoPNG & "/>" & gb.NewLine & "</test>"
  '   ' vHTML = "text/uri-list"
  '   ' sHTML = "image/png" '"application/x-qt-image"
  '   ' If Exist(F_sPathScreenphotoPNG) = True Then 
  '   '   Clipboard.Copy(Img) 'With Try: if Error, then next line. Without Try: If Error, then jump directly to Catch.
  '   '   ' If Error.Text Then 
  '   '   '   vHTML = Error.Text
  '   '   ' Endif
  '   ' Endif 
  '   
  '   ''component gb.cairo?
  '   ' Img = ClipboardCopyImageAlternative(Img)
  '   ' Img = CheckClipboardTypeImage()' —▶Timer 
  ' Endif 
  '  
  ' 
  ' ''Check Clipboard:
  ' If Clipboard.Type = Clipboard.Image Then 
  '   Img = Clipboard.Paste() '◀—
  '   ' Wait
  '   If Not Img Then 
  '     Img = M01Functions.ClipboardImage() 'as Image   ' If Clipboard.Type = Clipboard.Image Then
  '   Endif 
  ' Endif 
  
  ' If Img Then 
  ' If Clipboard.Type = Clipboard.Image Then
  '   PicBoxCutPreview.Background = Color.Green
  '   ' PicBoxCutPreview.Picture = Img.Picture
  '   PicBoxLED.Picture = PicTemplateLEDgreen.Picture
  ' Else
  '   PicBoxCutPreview.Background = Color.Yellow 'Fehler?
  '   ' PicBoxCutPreview.Picture = Null 'Picture[""] 'sichtbar leeren
  '   PicBoxLED.Picture = PicTemplateLEDyellow.Picture
  ' Endif
  
  ButtonM1Foto.Border = True 
  LabelM6Scale.Background = PicBoxCutPreview.Background
  F_iSecondCounter = 0 'Wait 1, sichtbar 
  CheckClipboardTypeImage()
  
  If PanelColorZoom.Visible = False Then Timer1.Start
  ' If Exist(sDirFile) = True And PicBoxPhoto.Picture And PicBoxCutPreview.Picture Then PicBoxLED.Picture = PicTemplateLEDred.Picture
  
  ''______________________________________________________________________________________''
  'Clipboard ([Zwischenablage]):
  ' Problembehebung
  ' Bildschirmfotos
  'https://wiki.ubuntuusers.de/Zwischenablage/  'Bildschirmfotos
  'https://wiki.ubuntu.com/ClipboardPersistence         'Ursache, warum die Zwischenablage manchmal leer ist
  'https://freedesktop.org/wiki/Specifications/ClipboardsWiki/              'selecting but with no explicit copy should only set PRIMARY, never CLIPBOARD
  
  'Installationspaket Mime-Types. Example line in "/usr/share/applications/mimeinfo.cache" (einfaches Textdokument)
  'image/png=display-im6.q16hdri.desktop;firefox.desktop;iconcreatormammut.desktop;org.gnome.eog.desktop;pinta.desktop;shotwell-viewer.desktop;terminwecker.desktop;
  'image/svg+xml   image/x-png    image/x-portable-bitmap
  
  '#Original: /usr/share/applications/mimeinfo.cache
  '#Original —▶Copy: /home/user/.local/share/applications/mimeinfo.cache File in home  read/write
  ' If Exist("/usr/share/applications/mimeinfo.cache") = True Then 
  '   If IsDir("/home/user/.local/share/applications") = False Then Mkdir "/home/user/.local/share/applications"
  '   Copy "/usr/share/applications/mimeinfo.cache" To "/home/user/.local/share/applications/mimeinfo.cache"
  ' Endif 
  
  ' ClipboardCutAreaPreviewSVG()
Catch 
  FMain.ErrorText
  
End

Public Sub CopyImageToClipboard(Optional imgSelect As Image = Null)
  
  If imgSelect Then 
    ' PicBoxPaste.Background = Color.Blue '■
    Clipboard.Clear() 'no longer?
    Clipboard.Copy(imgSelect) ' copy in Clipboard "[Zwischenablage]"
    ' If Clipboard.Type = Clipboard.Image Then PicBoxPaste.Picture = Clipboard.Paste().Picture
    Wait 1
    ' PicBoxPaste.Background = Color.Default '□
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelPixelWxHScalePicture()
  
  Dim MX, MY, X, Y As Integer
  Dim imgTemp As Image
  Dim sInfo, sTitle As String
  
  PanelFileSaved.Visible = False ' Kontrollbild ausblenden
  ' PhotoCutArea() 'aus PictureFoto
  
  If F_rectFCutArea Then 'Position in Original-Size (Screen)
    X = Round(F_rectFCutArea.X, 0) 'LabelCutArea.Left 
    Y = Round(F_rectFCutArea.Y, 0) 'LabelCutArea.Top 
  Else 
    X = LabelCutArea.Left 
    Y = LabelCutArea.Top 
  Endif 
  
  LabelPixelXY.Text = "X" & X & Space(5) & "Y" & Y
  If X < 0 Or Y < 0 Then LabelPixelXY.Foreground = Color.Red Else LabelPixelXY.Foreground = Color.Default 
  
  If F_imgScreen And F_rectFCutArea Then 
    imgTemp = F_imgScreen.Copy(F_rectFCutArea.X, F_rectFCutArea.Y, F_rectFCutArea.W, F_rectFCutArea.H)
  Else If PicBoxCutAreaOrig.Picture Then 
    ''........................................
    imgTemp = PicBoxCutAreaOrig.Picture.Image '◀—
    ''........................................
  Endif 
  If Not imgTemp Then  
    imgTemp = M01Functions.ScreenshotImageDemo() 'as Image, empty, Demo
  Endif 
  
  If imgTemp Then 
    ''< M1:1
    If F_iCopyScaleIndex <= 1 Then ' M1:1...Maßstab  1:F_iPhotoCutH 
      MX = imgTemp.W
      MY = imgTemp.H 
    Else If F_iCopyScaleIndex < 4 Then ' M1:2...Maßstab  1:F_iPhotoCutH 
      MX = Round(imgTemp.W / F_iCopyScaleIndex, 0) 'M1:2 => X:2, Y:2 Achtung: Nicht durch Null teilen
      MY = Round(imgTemp.H / F_iCopyScaleIndex, 0)
      ' imgTemp = M01Functions.StretchPicture(imgTemp, MX, MY)
    Else If F_iCopyScaleIndex = 4 Then ' M2:1...Maßstab  1:F_iPhotoCutH
      ' If F_fZoomFactor = 0 Then F_fZoomFactor = 2
      MX = imgTemp.W * 2  'M2:1 => X*2, Y*2
      MY = imgTemp.H * 2
      ' imgTemp = M01Functions.StretchPicture(imgTemp, MX, MY)
    Else '...800x600...Pixel
      ''M1:1 >       'fix WxH in Pixel
      If F_iCopyScaleIndex = 5 Then 
        MX = 32
        MY = 32
      Endif 
      If F_iCopyScaleIndex = 6 Then 
        MX = 160
        MY = 120
      Endif 
      If F_iCopyScaleIndex = 7 Then 
        MX = 400
        MY = 300
      Endif 
      If F_iCopyScaleIndex = 8 Then 
        MX = 800
        MY = 600
      Endif 
      If F_iCopyScaleIndex >= 9 Then 
        MX = imgTemp.W * F_fZoomFactor
        MY = imgTemp.H * F_fZoomFactor
      Endif 
      ' imgTemp = M01Functions.StretchPicture(imgTemp, MX, MY) 'as Picture
      
    Endif
    
    ''.................................
    imgTemp = imgTemp.Stretch(MX, MY) ' ◀—
    ''.................................
    
    If imgTemp Then 
      PicBoxCutPreview.Picture = imgTemp.Picture '□
      MX = imgTemp.W
      MY = imgTemp.H
    Else 
      MX = 0
      MY = 0
    Endif 
  Endif
  
  Select Case F_iCopyScaleIndex
      
    Case 0 To 1 'M1:1
      LabelM6Scale.Text = "M " & F_iPhotoCutW & ":" & F_iPhotoCutH 'Example: "M 1:1"
    Case 2 To 4
      LabelM6Scale.Text = "M " & F_iPhotoCutW & ":" & F_iPhotoCutH
    Case 5 To 8 'WxH
      LabelM6Scale.Text = F_iPhotoCutW & "x" & F_iPhotoCutH 'Example: "800x600"
    Case Else '9
      If F_fZoomFactor < 1 Then 
        LabelM6Scale.Text = "M 1:" & F_fZoomFactor 
      Else 
        LabelM6Scale.Text = "M " & F_fZoomFactor & ":1"
      Endif 
  End Select
  
  If PicBoxCutPreview.Picture Then 
    If PicBoxCutAreaOrig.Picture Then 
      LabelM7.Text = PicBoxCutAreaOrig.Picture.W & "x" & PicBoxCutAreaOrig.Picture.H 'Cut PicBoxCutPreview □
    Endif
    ' LabelM7.Text = PicBoxCutAreaOrig.Picture.W & "x" & PicBoxCutAreaOrig.Picture.H 'Cut PicBoxCutPreview □
    LabelM7Mini.Text = PicBoxCutPreview.Picture.W & "x" & PicBoxCutPreview.Picture.H & Space(1) & ("im Bild")
    
    ' If F_rectFCutArea Then 
    '   LabelM7.Text = Round(F_rectFCutArea.W, 0) & "x" & Round(F_rectFCutArea.H, 0) 'Cut LabelCutArea □
    ' Else 
    ' LabelM7.Text = PicBoxCutAreaCopy.Picture.W & "x" & PicBoxCutAreaCopy.Picture.H 'Cut PicBoxCutPreview □
    ' Endif 
  Else 
    LabelM7.Text = ("Ausschnitt fehlt")
    LabelM7Mini.Text = "?x?"
  Endif 
  LabelM7b.Text = LabelM7.Text 
  
  If Not F_pointFUnit Then F_pointFUnit = ScaleUnitpointF(F_sRulersCMorCMRELorPIXEL) 'as PointF
  
  If F_iSaveQualityJPG = 100 Then
    sInfo = "*." & F_sSaveFormat
  Else
    sInfo = "*." & F_sSaveFormat & Space(1) & F_iSaveQualityJPG & "%" 
  Endif
  
  If ImageViewPhoto.Visible = True Then 
    sTitle = Application.Name & " - " & ("Zoom") & ": " & Round(ImageViewPhoto.Zoom, -1)
  Else If PicBoxPhoto.Visible = True Then 
    sTitle = Application.Name & " - " & ("Zoom") & ": " & Round(F_fZoomFactor, -1)
  Endif
  
  If F_pointFUnit Then 
    If String.InStr(F_sRulersCMorCMRELorPIXEL, "cm") > 0 Then 'mm*10 = cm
      Form15Foto.Window.Title = sTitle & Space(3) & sInfo & Space(1) & Round((LabelCutArea.X / F_pointFUnit.X) / 10, -1) & ", " & Round((LabelCutArea.Y / F_pointFUnit.Y) / 10, -1) & ", " & Round((LabelCutArea.W / F_pointFUnit.X) / 10, -1) & "x" & Round((LabelCutArea.H / F_pointFUnit.Y) / 10, -1) & Space(1) & ("(x,y,WxH)") & F_sScaleUnitText
    Else 
      Form15Foto.Window.Title = sTitle & Space(3) & sInfo & Space(1) & Round(F_rectFCutArea.X, 0) & ", " & Round(F_rectFCutArea.Y, 0) & ", " & Round(F_rectFCutArea.W, 0) & "x" & Round(F_rectFCutArea.H, 0) & Space(1) & Space(1) & ("(x,y,WxH)") & F_sScaleUnitText
    Endif 
  Endif 
  
  LabelM7.Tooltip = LabelM7.Text & gb.NewLine & F_sLabelM7TooltipBasis
  LabelM7Mini.Tooltip = LabelM7Mini.Text & gb.NewLine & F_sLabelM7MiniTooltipBasis
  
  ''Check: 
  ' If F_rectFCutArea Then 
  '   Print "Max. Check: X" & Round(F_rectFCutArea.X, 0) & ", W" & (Round(F_rectFCutArea.X + F_rectFCutArea.W, 0)) & " =" & Screen.W & ", Y" & Round(F_rectFCutArea.Y, 0) & ", H" & (Round(F_rectFCutArea.Y + F_rectFCutArea.H)) & " =" & Screen.H
  ' Endif 
  ' CheckRulersG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckRulersG()
  
  ''Check Rulers |''''!''''| cm
  If F_bRulesON = True Then CreateRulersG(F_sRulersCMorCMRELorPIXEL)
  
  PicBoxRulerHorizontal.Visible = F_bRulesON
  PicBoxRulerVertical.Visible = F_bRulesON
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPhoto_MouseDown() ' PicBoxGrid_MouseDown = PictureFoto_MouseDown
  
  Dim iW As Integer
  Dim pointXY As Point
  
  If Mouse.Left = True Then
    F_bMovingON = True
    ButtonM4Full.Foreground = Color.Default
    LabelCutArea.Foreground = Color.Default
    LabelCutArea.Raise
    iW = Eckpunkt1.W
    F_fX1 = Mouse.X '+ F_fDistanceX - iW 
    F_fY1 = Mouse.Y '+ F_fDistanceY - iW
    F_fX2 = F_fX1 '+ F_fDistanceX
    F_fY2 = F_fY2 '+ F_fDistanceY
    ' If PicBoxGrid.Visible = True Then GridMagnetic() Else LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    CornerPointsToLabelCutAreaONoff(False)
    
    If F_bZoomLupeON = True Then 
      pointXY = Point(Mouse.X, Mouse.Y)
      LabelCutArea.Move(pointXY.X - (LabelCutArea.W / 2), pointXY.Y - (LabelCutArea.H / 2), LabelCutArea.W, LabelCutArea.H)
      CopyButtonG()
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPhoto_MouseMove()
  
  If F_bMovingON = True And Mouse.Left = True Then
    F_fX2 = Mouse.X '+ F_fDistanceX
    F_fY2 = Mouse.Y '+ F_fDistanceY
    LabelCutArea.Visible = True
    If F_fX1 < 0 Then F_fX1 = 0
    If F_fY1 < 0 Then F_fY1 = 0
    If F_fX1 > PicBoxPhoto.Left + PicBoxPhoto.Width Then F_fX1 = PicBoxPhoto.Left + PicBoxPhoto.Width 
    If F_fY1 > PicBoxPhoto.Top + PicBoxPhoto.Height Then F_fY1 = PicBoxPhoto.Top + PicBoxPhoto.Height 
    If F_fX2 > PicBoxPhoto.Left + PicBoxPhoto.Width Then F_fX2 = PicBoxPhoto.Left + PicBoxPhoto.Width - (F_fX2 - F_fX1)
    If F_fY2 > PicBoxPhoto.Top + PicBoxPhoto.Height Then F_fY2 = PicBoxPhoto.Top + PicBoxPhoto.Height - (F_fY2 - F_fY1)
    If PicBoxGrid.Visible = True Then 
      GridMagnetic() '& F_rectFCutArea
    Else 
      LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    Endif 
    CornerPointsToLabelCutAreaONoff(True)
    If F_bCrossLineON = True Then CrossLinesMove()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPhoto_MouseUp()
  
  If Mouse.Left = True And F_bMovingON = True Then 'nicht bei Punktklick
    ' If PicBoxGrid.Visible = True Then GridMagnetic() Else LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    If F_bZoomLupeON = False Then 
      PhotoCutArea()
    Else 
      ButtonGroupSelect(PicBoxM7ZoomLupe.Tag)
    Endif
  Endif 
  
  If Mouse.Middle = True Then 'nicht bei Punktklick
    If F_bZoomLupeON = True Then 
      If PicBoxPhoto.Picture Then 
        PicBoxPhotoCursorZoomCut()
        ZoomLupeOnOffMessage()
      Endif 
    Endif 
  Endif  
  
  If Mouse.Right Then 
    If LabelCutArea.Visible = False Then 
      LabelCutArea.Visible = True
    Else 
      Menu1.Popup(Mouse.X, 0)  
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub GridMagnetic() '|''''!''''| cm
  
  Dim X, Y, W, H As Integer 
  
  If F_pointFUnitCentimeterXY.X = 0 Then 
    F_pointFUnitCentimeterXY = M01Functions.Unit1cm() 'as PointF x,y Float
    If F_pointFUnitCentimeterXY.X = 0 Then F_pointFUnitCentimeterXY.X = 1 'error by 0
    If F_pointFUnitCentimeterXY.Y = 0 Then F_pointFUnitCentimeterXY.Y = 1
  Endif 
  
  X = Round(LabelCutArea.Left / F_pointFUnitCentimeterXY.X, 0) * F_pointFUnitCentimeterXY.X 'Round Example: 40 ◀— 44, 45 —▶ 50
  Y = Round(LabelCutArea.Top / F_pointFUnitCentimeterXY.Y, 0) * F_pointFUnitCentimeterXY.Y
  W = Round(LabelCutArea.W / F_pointFUnitCentimeterXY.X, 0) * F_pointFUnitCentimeterXY.X               
  H = Round(LabelCutArea.H / F_pointFUnitCentimeterXY.Y, 0) * F_pointFUnitCentimeterXY.Y
  
  LabelCutArea.Move(X, Y, W, H) 
  F_rectFCutArea = RectF(X, Y, W, H)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CrossLinesMove() '' —|—
  
  Dim iLeft1, iLeft2, iTop1, iTop2, iWHalf, iW As Integer
  
  If F_bCrossLineON = True Then
    ''*************
    iW = CrossLineVertical1.W 'Pixel
    ''*************
    iWHalf = CrossLineVertical1.W / 2 '|!|
    iLeft1 = LabelCutArea.Left - iWHalf
    iLeft2 = LabelCutArea.Left + LabelCutArea.W - iWHalf
    iTop1 = LabelCutArea.Top - iWHalf
    iTop2 = LabelCutArea.Top + LabelCutArea.H - iWHalf
    CrossLineHorizontal1.Move(0, iTop1, PanelGlass.W, iW) 
    CrossLineHorizontal2.Move(0, iTop2, PanelGlass.W, iW) 
    CrossLineVertical1.Move(iLeft1, 0, iW, PanelGlass.H) 
    CrossLineVertical2.Move(iLeft2, 0, iW, PanelGlass.H) 
    
    ' Else '>center< 
    '   CrossLineHorizontal1.Move(0, (PanelGlass.W / 2) + iWHalf, PanelGlass.W, CrossLineHorizontal1.H) '——
    '   CrossLineVertical1.Move((PanelGlass.H / 2) + iWHalf, 0, CrossLineVertical1.W, PanelGlass.H) '|
  Endif 
  
  ''Check:
  If CrossLineHorizontal1.Visible <> F_bCrossLineON Then  
    CrossLineHorizontal1.Visible = F_bCrossLineON 
    CrossLineHorizontal2.Visible = F_bCrossLineON 
    CrossLineVertical1.Visible = F_bCrossLineON 
    CrossLineVertical2.Visible = F_bCrossLineON 
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub CreateCrossLine() '+
  
  Dim Img As Image 'New Image(Screen.W, Screen.H, Color.Transparent)
  Dim iLineEndType, iColChange1, iColChange2, it, it3, iStep, iW As Integer
  Dim fStrokeLW, fWHalf, fLength As Float
  Dim bChange As Boolean
  
  ''activate or deactivate with Comment-line '
  '***********************
  ' U = Img.W / 10  'Unit 1x
  ' hOpacity = 0.8 ''Opacity as Float 0=transparent, 1=no  
  iColChange1 = Color.Black 'FMain.F_iColorBlack
  iColChange2 = Color.White
  ' iLineEndType = Paint.LineCapButt 'as Integer=0
  iLineEndType = Paint.LineCapRound 'as Integer=1  'Main.F_iLineEndType 
  
  iW = 4
  If CrossLineHorizontal1.H <> iW Then 
    CrossLineHorizontal1.H = iW
    CrossLineHorizontal2.H = iW
    CrossLineVertical1.W = iW
    CrossLineVertical2.W = iW
  Endif 
  fWHalf = iW / 2 'center -·-·-·-
  fStrokeLW = iW - 1.5 'Paint.LineWidth
  iStep = iW * 2
  fLength = iW
  '***************************
  
  For it3 = 0 To 1
    Select Case it3
      Case 0 ''◀——▶
        Img = New Image(Screen.W, CrossLineHorizontal1.H, Color.Transparent) ''............
      Case 1 ''▼▲
        Img = New Image(CrossLineVertical1.W, Screen.H, Color.Transparent) ''............
    End Select
    
    Paint.Begin(Img)
    Paint.AntiAlias = True 'FMain.F_bAntiAliasON                                                         '...———...
    Paint.LineCap = iLineEndType
    Paint.LineJoin = iLineEndType                                                          'Paint.LineJoinRound 'as Integer=1
    
    Select Case it3
      Case 0 ''◀——▶
        For it = 0 To Img.W Step iStep
          Paint.MoveTo(it, fWHalf)
          Paint.LineTo(it + fLength, fWHalf)
          bChange = Not bChange
          If bChange = True Then 
            Paint.Brush = Paint.Color(iColChange1)
          Else 
            Paint.Brush = Paint.Color(iColChange2)
          Endif 
          Paint.LineWidth = fStrokeLW
          Paint.Stroke()
        Next 
      Case 1 ''▼▲
        For it = 0 To Img.H Step iStep
          Paint.MoveTo(fWHalf, it)
          Paint.LineTo(fWHalf, it + fLength)
          bChange = Not bChange
          If bChange = True Then 
            Paint.Brush = Paint.Color(iColChange1)
          Else 
            Paint.Brush = Paint.Color(iColChange2)
          Endif 
          Paint.LineWidth = fStrokeLW
          Paint.Stroke()
        Next 
    End Select
    Paint.End
    
    Select Case it3
      Case 0 ''◀——▶
        CrossLineHorizontal1.Picture = Img.Picture  '——
        CrossLineHorizontal2.Picture = Img.Picture
        
      Case 1 ''▼▲
        CrossLineVertical1.Picture = Img.Picture  '|
        CrossLineVertical2.Picture = Img.Picture
    End Select  
  Next '' it3
  ' CrossLineHorizontal1.Background = Color.Transparent
  ' CrossLineHorizontal2.Background = Color.Transparent
  ' CrossLineVertical1.Background = Color.Transparent
  ' CrossLineVertical2.Background = Color.Transparent
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxGrid_MouseDown() ' PicBoxGrid_MouseDown = PictureFoto_MouseDown
  
  Dim iW As Integer
  
  If Mouse.Left = True Then
    F_bMovingON = True
    ButtonM4Full.Foreground = Color.Default
    LabelCutArea.Foreground = Color.Default
    LabelCutArea.Raise
    iW = Eckpunkt1.W
    F_fX1 = Mouse.X + F_fDistanceX - iW
    F_fY1 = Mouse.Y + F_fDistanceY - iW
    F_fX2 = F_fX1 + F_fDistanceX
    F_fY2 = F_fY2 + F_fDistanceY
    ' If PicBoxGrid.Visible = True Then GridMagnetic() Else 
    LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    ' CornerPointsToLabelCutAreaONoff(False)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxGrid_MouseMove()
  
  If F_bMovingON = True And Mouse.Left = True Then
    F_fX2 = Mouse.X '+ F_fDistanceX
    F_fY2 = Mouse.Y '+ F_fDistanceY
    LabelCutArea.Visible = True
    If F_fX1 < 0 Then F_fX1 = 0
    If F_fY1 < 0 Then F_fY1 = 0
    If F_fX1 > PicBoxPhoto.Left + PicBoxPhoto.Width Then F_fX1 = PicBoxPhoto.Left + PicBoxPhoto.Width 
    If F_fY1 > PicBoxPhoto.Top + PicBoxPhoto.Height Then F_fY1 = PicBoxPhoto.Top + PicBoxPhoto.Height 
    If F_fX2 > PicBoxPhoto.Left + PicBoxPhoto.Width Then F_fX2 = PicBoxPhoto.Left + PicBoxPhoto.Width - (F_fX2 - F_fX1)
    If F_fY2 > PicBoxPhoto.Top + PicBoxPhoto.Height Then F_fY2 = PicBoxPhoto.Top + PicBoxPhoto.Height - (F_fY2 - F_fY1)
    ' If PicBoxGrid.Visible = True Then GridMagnetic() Else 
    LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    CornerPointsToLabelCutAreaONoff(True)
    If F_bCrossLineON = True Then CrossLinesMove()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxGrid_MouseUp()
  
  If Mouse.Left = True And F_bMovingON = True Then 'nicht bei Punktklick
    If PicBoxGrid.Visible = True Then GridMagnetic() Else LabelCutArea.Move(F_fX1, F_fY1, F_fX2 - F_fX1, F_fY2 - F_fY1)
    CornerPointsToLabelCutAreaONoff(True)
    PhotoCutArea()
  Endif
  If Mouse.Right = True Then Menu1.Popup(Mouse.X, 0)
  If Mouse.Right Then LabelCutArea.Visible = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxGrid_MouseWheel()
  
  If F_bZoomLupeON = True Then ZoomHasFocus(Mouse.Forward)
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckZoomLupeCursor(Optional bZoomLupeON As Boolean = F_bZoomLupeON)
  
  Dim fZoom As Float
  
  ' F_bZoomLupeON = bZoomLupeON
  If bZoomLupeON = True Then 
    PicBoxPhoto.Cursor = New Cursor(PicBoxM7ZoomLupe.Picture, PicBoxM7ZoomLupe.Picture.W * 0.45, PicBoxM7ZoomLupe.Picture.H * 0.45)
    PicBoxPhoto.Mouse = Mouse.Custom
    PicBoxGrid.Cursor = PicBoxPhoto.Cursor
    PanelColorZoom.Visible = True 
    PicBoxCutPreview.Visible = False 
    PicBoxZoomLupe.Picture = PicBoxPhoto.Picture
    F_bZoomLupeON = True 
    TimerZoomLupe.Start
    If ImageViewPhoto.Visible = True Then 
      fZoom = Round(ImageViewPhoto.Zoom, -1)
    Else 
      fZoom = Round(F_fZoomFactor, -1)
    Endif
    Form15Foto.Window.Title = Application.Name & " - " & ("Zoom") & ": " & Str(fZoom) & Space(1) & ("Mausrad -/+")
  Else 
    If TimerZoomLupe.Enabled = True Then TimerZoomLupe.Stop 
    PanelColorZoom.Visible = False  
    PicBoxCutPreview.Visible = True 
    PicBoxZoomLupe.Picture = Null
    PicBoxPhoto.Cursor = Null
    PicBoxPhoto.Mouse = Mouse.Cross
  Endif
  PicBoxGrid.Mouse = PicBoxPhoto.Mouse
  ' PicBoxGrid.Cursor = PicBoxPhoto.Cursor
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoCutArea(Optional imgPhoto As Image)
  
  Dim fScaleX, fScaleY As Float
  Dim fCX1, fCY1, fCX2, fCY2 As Float
  
  PicBoxLED.Picture = PicTemplateLEDred.Picture
  If Not imgPhoto And PicBoxPhoto.Picture Then imgPhoto = PicBoxPhoto.Picture.Image
  
  If imgPhoto Then '<> Picture[""] 
    fScaleX = imgPhoto.Width / PicBoxPhoto.Width
    fScaleY = imgPhoto.Height / PicBoxPhoto.Height
    fCX1 = LabelCutArea.Left * fScaleX
    fCY1 = LabelCutArea.Top * fScaleY
    fCX2 = LabelCutArea.Width * Round(fScaleX, -4) 'Example Round -1: 1.7  Note: -4 Nachkommastellen wichtig, genauer
    fCY2 = LabelCutArea.Height * Round(fScaleY, -4)
    
    If fCX1 < 0 Then fCX1 = 0
    If fCY1 < 0 Then fCY1 = 0
    If fCX2 > imgPhoto.Width Then fCX2 = imgPhoto.Width
    If fCY2 > imgPhoto.Height Then fCY2 = imgPhoto.Height
    F_rectFCutArea = RectF(fCX1, fCY1, fCX2, fCY2)
    PicBoxCutAreaOrig.Picture = imgPhoto.Copy(F_rectFCutArea.X, F_rectFCutArea.Y, F_rectFCutArea.W, F_rectFCutArea.H).Picture
    PicBoxCutPreview.Picture = PicBoxCutAreaOrig.Picture
    
    ''Lupe:
    '........................................................
    fCX1 = (Mouse.ScreenX - PicBoxPhoto.ScreenX) * fScaleX
    fCY1 = (Mouse.ScreenY - PicBoxPhoto.ScreenY) * fScaleY
    fCX2 = PicBoxCutPreview.Width * Round(fScaleX, -4) 'Example Round -1: 1.7  Note: -4 Nachkommastellen wichtig, genauer
    fCY2 = PicBoxCutPreview.Height * Round(fScaleY, -4)
    If fCX1 < 0 Then fCX1 = 0
    If fCY1 < 0 Then fCY1 = 0
    If fCX2 > imgPhoto.Width Then fCX2 = imgPhoto.Width
    If fCY2 > imgPhoto.Height Then fCY2 = imgPhoto.Height
    F_rectFCutMouseLupe = RectF(fCX1, fCY1, fCX2, fCY2)
    '........................................................
    
    LabelPixelWxHScalePicture()
    PaintQuote()
    UndoRedoCutArea()
  Endif

  ' Timer1.Start
  
Catch 
  FMain.ErrorText
  
End

Public Sub PaintQuote()
  
  Dim Img As Image 
  Dim sText As String
  Dim fFontSize As Float
  
  ' Img = F_imgScreen
  
  ''With Text?
  If F_bQuoteStarON = True Then 
    If Not F_sQuoteDateText And F_ssPanelQuotes Then 
      If F_iQuotePointer > -1 And F_iQuotePointer < F_ssPanelQuotes.Count Then 
        F_sQuoteDateText = F_ssPanelQuotes[F_iQuotePointer]
      Endif 
    Endif 
    
    sText = CheckPaintQuote()
    
    PicBoxCutPreview.Picture = PicBoxCutAreaOrig.Picture
    If PicBoxCutAreaOrig.Picture Then Img = PicBoxCutAreaOrig.Picture.Image Else Img = New Image(LabelCutArea.W, LabelCutArea.H, Color.Transparent) 
    If Img And PicBoxCutPreview.Picture Then 
      Img = Img.Stretch(PicBoxCutPreview.Picture.W, PicBoxCutPreview.Picture.H)
    Else 
      ' Img = Img.Stretch(F_rectFCutArea.W, F_rectFCutArea.H)
    Endif 
    
    If Img.W > 0 And Img.H > 0 Then 
      'Paint *Quote Text
      Paint.Begin(Img)
      Paint.LineWidth = 1
      Paint.Font = LabelCutArea.Font '.size = 12 'min.
      
      ''|Text◀—
      If LabelCutArea.Font.TextWidth(sText) > Img.W Then 
        Paint.Brush = Paint.Color(Color.Black)
        fFontSize = M01Functions.FontSizeCheck(sText, LabelCutArea.Font, Img.W)
        If fFontSize < 2 Then fFontSize = 2
        Paint.Font.Size = fFontSize
        Paint.Text(sText, 0, 0, Img.W, Img.H, LabelCutArea.Alignment)
        Paint.Fill()
      Else 
        Paint.Font.Size = LabelCutArea.Font.Size
        Paint.Brush = Paint.Color(Color.White)
        Paint.Text(sText, 0, 0, Img.W, Img.H, LabelCutArea.Alignment)
        Paint.Fill()
        Paint.Brush = Paint.Color(Color.Black)
        Paint.Text(sText, 2, 2, Img.W, Img.H, LabelCutArea.Alignment)
        Paint.Fill()
      Endif
      Paint.End
    Endif 
    PicBoxCutPreview.Picture = Img.Picture
  Else 
    LabelCutArea.Text = "" ''*No Quote
    PicBoxCutPreview.Picture = PicBoxCutAreaOrig.Picture
  Endif 
  
  ''Finished copy image
  ''Example: □ Cut-Image + Text (Date-Quote)
  
Catch 
  FMain.ErrorText
  
End

Public Function CheckPaintQuote() As String 
  
  Dim sText As String
  
  If F_bQuoteDateON = True Then sText = Format(Date, "yyyy-mm-dd") & Space(1)
  If F_bQuoteTimeON = True Then sText &= Format(Time, "hh:nn") & Space(1)
  If F_bQuoteTextON = True Then sText &= F_sQuoteDateText 
  
  If F_bQuoteStarON = True Then
    If Not sText And F_sQuoteDateText <> F_sQuoteEmpty Then 
      sText = "*" & F_sQuoteDateText
    Else 
      If sText Then sText = "*" & sText
    Endif 
  Else 
    sText = ""
  Endif 
  
  LabelCutArea.Text = sText
  If PanelQuotes.Visible = True Then 
    TextBoxQuoteExample.SelectAll
    TextBoxQuoteExample.Insert(("Beispiel") & ": " & sText)
  Endif 
  
  Return sText 'Example: "*2023-11-23 12:00 Zitat Quelle"
  
Catch 
  FMain.ErrorText
  
End

Public Sub FormBackgroundColor() 'Color/Wood/Metal
  
  Dim sValue As String 
  
  sValue = M01Functions.CheckFormBackgroundColorValue() 'as String
  
  If String.InStr(sValue, "/") > 0 Then  ' Image (Bild)
    PicBackground.Visible = True
    PicBackground.Stretch = True
    If Exist(sValue) = True Then PicBackground.Picture = Picture.Load(sValue) 'Path "images/..."
  Else  'Color (Farbe)
    PicBackground.Visible = True
    If IsInteger(sValue) = True Then 
      PicBackground.Background = CInteger(sValue)
      PicBackground.Picture = Null
    Endif 
  Endif
  PicBackground.Lower() '▼down▼ Hintergrund unten
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonM4FullG()
  
  'Full screen, max:
  If LabelCutArea.Left = 0 And LabelCutArea.Top = 0 And LabelCutArea.Width = PanelGlass.Width And LabelCutArea.Height = PanelGlass.Height Then
    F_bCutAreaFullScreenON = False 
    LabelCutArea.Move(F_fVX1, F_fVY1, F_fVX2, F_fVY2)
    PhotoCutArea()
    ' ButtonM4Full.Picture = PicTemplatePageMaxi.Picture
    ButtonM4Full.Picture = PicTemplatePageMini.Picture
    ButtonM4Full.Background = Color.Green
    Wait 1 'sichtbarer Ablauf
    ButtonM4Full.Background = Color.Default
  Else
    F_bCutAreaFullScreenON = True
    F_fVX1 = LabelCutArea.Left
    F_fVY1 = LabelCutArea.Top
    F_fVX2 = LabelCutArea.Width
    F_fVY2 = LabelCutArea.Height
    LabelCutArea.Move(0, 0, PanelGlass.W, PanelGlass.H)
    PicBoxCutAreaOrig.Picture = PicBoxPhoto.Picture
    PhotoCutArea()
    ' ButtonM4Full.Picture = PicTemplatePageMini.Picture
    ButtonM4Full.Picture = PicTemplatePageMaxi.Picture
  Endif
  CornerPointsToLabelCutAreaONoff(True)
  LabelEckBGColor()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFullPageMinMax()
  Dim rectCut, rectPhoto As Rect 'Rectangle □
  
  rectCut = Rect(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W, LabelCutArea.H)
  rectPhoto = Rect(PicBoxPhoto.Left, PicBoxPhoto.Top, PicBoxPhoto.W, PicBoxPhoto.H)
  If rectCut = rectPhoto Then 
    ButtonM4Full.Picture = PicTemplatePageMaxi.Picture
  Else 
    ButtonM4Full.Picture = PicTemplatePageMini.Picture
  Endif
  
  Catch 
  FMain.ErrorText
  
End

Public Sub LabelEckBGColor()
  
  Dim iColor As Integer
  
  iColor = F_iColorGreen220
  Eckpunkt1.Background = iColor
  Eckpunkt2.Background = iColor
  Eckpunkt3.Background = iColor
  Eckpunkt4.Background = iColor
  LabelCutArea.Background = iColor
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonPicProgramExtern()
  
  Dim sDir, sFile, sPath, sTool, sPathCache1, sMessagePic, sMessage As String
  Dim iSelect As Integer
  Dim fRel As Float
  
  CheckZoomPhotoOptimal(False)
  LabelPixelWxHScalePicture()
  PaintQuote()
  
  ' CutAreaSquare()
  sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  If Exist(sDir) = False Then sDir = M01Functions.FileTerminWeckerCreateReturnDirectory() 'as String
  ' sDir = Desktop.GetDirectory("PICTURES") ' "DESKTOP","DOCUMENTS","DOWNLOAD","MUSIC","PICTURES","TEMPLATES","VIDEOS
  ' If Exist(sDir) = False Then sDir = M01Functions.CheckDirectoryCache() 'as String
  ' sPath = sDir &/ "temp_" & ("foto") & ".png"
  sFile = ("BildschirmFoto") & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & "." & "png"
  sPath = M01Functions.ProgramDirCache(sFile) '/sDir/~Datei.txt
  If PicBoxCutPreview.Picture Then '<> Picture[""] Then 'Fehler vermeiden
    If Exist(sPath) = True Then Try Kill sPath
    PicBoxCutPreview.Picture.Save(sPath)
  Endif
  sTool = System.Find("gimp")
  If Exist(sTool) = True Then sTool = Space(1) & "gimp" Else sTool = ""
  
  'Cache:
  sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
  If PicBoxCutPreview.Picture And IsDir(File.Dir(sPathCache1)) = True Then 
    PicBoxCutPreview.Picture.Save(sPathCache1)
    fRel = PicBoxCutPreview.Picture.W / PicBoxCutPreview.Picture.H
  Endif 
  If Exist(sPathCache1) = True Then 
    sMessagePic &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & Round(fRel * 100) & " height=100 >" & Space(1) & ("Ausschnitt") & Space(1)
  Endif 
  sMessage &= "<h3><font color=gray>" & sMessagePic & LabelM6Scale.Text & "</font></h3>"
  sMessage &= "<h2><font color=darkgreen>" & ("Bild-Datei öffnen") & ":" & "</font></h2>" 
  sMessage &= sPath & "<br>"
  If Exist(sPath) = False Then sMessage &= "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
  If PicBoxCutAreaOrig.Picture Then
    If PicBoxCutAreaOrig.Picture.W <> PicBoxCutPreview.Picture.W Or PicBoxCutAreaOrig.Picture.H <> PicBoxCutPreview.Picture.H Then
      sMessage &= "<h3><font color=gray>" & PicBoxCutAreaOrig.Picture.W & " x " & PicBoxCutAreaOrig.Picture.H & " px" & "</font></h3>" 
    Endif 
  Endif
  If PicBoxCutPreview.Picture Then
    sMessage &= "<h3><font color=darkgreen>" & PicBoxCutPreview.Picture.W & " x " & PicBoxCutPreview.Picture.H & " px" & Space(1) & ("im Bild") & "</font></h3>" 
  Endif
  
  Select Case Message.Question(sMessage, ("Öffnen im Bild-Programm...") & sTool, ("Öffnen in Standard-Vorgabe..."), ("Abbrechen"))
    Case 1
      iSelect = 1 
    Case 2
      iSelect = 2
    Case 3 'Abbrechen, Cancel
      iSelect = 3
  End Select
  
  ButtonM3Program.Background = Color.Green
  Wait 1 'sichtbarer Ablauf
  If F_bESCpressedON = False Then 
    Select Case iSelect 
      Case 1
        M01Functions.ExternStart("gimp", sPath) 'mit Datei 
        
      Case 2
        If Exist(sPath) = True Then Desktop.Open(sPath) 
        
      Case 3 'Cancel
        '...
    End Select
  Endif 
  ButtonM3Program.Background = Color.Default
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonFilePicProgramExtern(Optional sScreenFileOrCutFileOrProgram As String = "program")
  
  Dim sDir, sDirFile1, sDirFile2, sDirFileChecck, sMessage As String
  
  If Exist(F_sPathScreenphotoPNG) = True Then
    sDir = File.Dir(F_sPathScreenphotoPNG)
    sDirFile1 = F_sPathScreenphotoPNG
    sDirFile2 = File.Dir(sDirFile1) &/ File.BaseName(sDirFile1) & ("-ausschnitt.png")
  Else 
    sDir = FMain.F_sDirCache
    If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
    If IsDir(sDir) = False Then sDir = M01Functions.CheckDirectoryCache()
    sDirFile1 = sDir &/ ("Screenshot.png")
    sDirFile2 = sDir &/ ("bildschirmfoto-ausschnitt.png")
  Endif 
  
  Select Case sScreenFileOrCutFileOrProgram
      
    Case "file" '/dir/file.png
      
      ''Save screen:
      If IsDir(sDir) = True And PicBoxPhoto.Picture Then 
        PicBoxPhoto.Picture.Save(sDirFile1)
      Endif 
      If Exist(sDirFile2) = True Then M01Functions.FileManagerOpen(sDirFile2) 'Else M01Functions.FileManagerOpen(sDir)
      sDirFileChecck = sDirFile1    
      
    Case "screen" '/dir/file.png
      
      ''Save Cut:
      If IsDir(sDir) = True And PicBoxCutPreview.Picture Then 
        If Exist(sDirFile2) = True Then Try Kill sDirFile1
        LabelPixelWxHScalePicture()
        PaintQuote()
        PicBoxCutPreview.Picture.Save(sDirFile1)
      Endif
      If Exist(sDirFile1) = True Then Desktop.Open(sDirFile1) 
      sDirFileChecck = sDirFile1    
      
    Case "cut" '/dir/file.png
      
      ''Save Cut:
      If IsDir(sDir) = True And PicBoxCutPreview.Picture Then 
        If Exist(sDirFile2) = True Then Try Kill sDirFile2
        LabelPixelWxHScalePicture()
        PaintQuote()
        PicBoxCutPreview.Picture.Save(sDirFile2)
      Endif
      If Exist(sDirFile1) = True Then Desktop.Open(sDirFile2) 
      sDirFileChecck = sDirFile2 
      
  End Select 
  
  ''Check:
  If Exist(sDirFileChecck) = False Then 
    sMessage = "<h3><font color=red>Fehlt: " & sDirFileChecck & "</font></h3>"
    Select Case Message.Question(sMessage, ("Ordner..."), ("Abbrechen"))
      Case 1 ''Directory:
        If IsDir(sDir) = False Then sDir = User.Home
        M01Functions.FileManagerOpen(sDir)
      Case 2  'Cancel
        '...
    End Select 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Timer1_Timer()
  '.Delay = 1000 '=1 Sekunde
  
  'CheckClipboardTypeImage() 'besser über CopyButtonG()
  
  F_iSecondCounter = F_iSecondCounter + 1
  If F_iSecondCounter = 3 Then 
    ButtonM2Save.Background = Color.Default
    ButtonM5Menu.Background = Color.Default
    ButtonExtern.Background = Color.Default
    ' ButtonM8Copy.SetFocus
  Endif
  
  If F_bESCpressedON = True Then Timer1.Stop
  
Catch 
  FMain.ErrorText
  
End

Public Sub TimerZoomLupe_Timer()
   
  '.Delay = 100 ?     1000=1sec.
  If PicBoxPhoto.Picture Then 
  '.Delay = 100 ?     1000=1sec.
  
    ''Pick Color:
    ' If PicBoxPhoto.Visible = True Then   'PicBoxScreenshot
    If F_bZoomLupeON = True Then 
      PicBoxM7ZoomLupe.Background = Color.Green 
      PicBoxZoomLupe.Visible = True 
      LabelPictureSavedPath.Visible = False 
      LabelInfoZoomLupe.Visible = True
      LabelZoomColorPoint.Visible = LabelInfoZoomLupe.Visible
      ZoomArea()
    Else 
      F_bZoomLupeON = False
      PicBoxM7ZoomLupe.Background = Color.Default
      LabelPictureSavedPath.Visible = True 
      LabelInfoZoomLupe.Visible = False
      LabelZoomColorPoint.Visible = LabelInfoZoomLupe.Visible
      TimerZoomLupe.Stop()
    Endif 

    If F_fZoomFactor > 1 Then 
      LabelM6Scale.Text = "M" & F_fZoomFactor & ":1"
    Else 
      LabelM6Scale.Text = "M" & "1:" & F_fZoomFactor 
    Endif 
  Endif  
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckFontForeground()
  '■=■ > □=■
  ''Example: Black-Foreground-Font in Black-Background = no visible —▶ more difference in Color
  
  If M01Functions.ColorInfoRGB(F_iColorPicker, "L") < 150 And M01Functions.ColorInfoRGB(F_iColorPicker, "A") < 150 Then LabelZoomColorPoint.Foreground = Color.White Else LabelZoomColorPoint.Foreground = Color.Black
  
  If F_iColorPicker = Color.Default Or F_iColorPicker = Color.Transparent Then LabelZoomColorPoint.Foreground = Color.Black
  ' LabelZoom.Foreground = LabelInfo.Foreground
  
Catch 
  FMain.ErrorText 
  
End

Public Sub ZoomArea()
  
  If Not F_picScreen Then
    If PicBoxPhoto.Picture Then 
      F_picScreen = PicBoxPhoto.Picture.Image.Stretch(Screen.W, Screen.H).Picture
      F_imgScreen = F_picScreen.Image.Stretch(PicBoxPhoto.W, PicBoxPhoto.H)
      PicBoxZoomLupe.Picture = F_picScreen
    Endif 
  Endif 
  
  If F_picScreen Then    
    ' If Not F_imgScreen Then 
    F_imgScreen = F_picScreen.Image.Stretch(PicBoxPhoto.W, PicBoxPhoto.H)
    If String.LCase(Desktop.Platform) = "wayland" Then 
      F_fX1 = Mouse.ScreenX - PanelGlass.Left 
      F_fY1 = Mouse.ScreenY - PanelGlass.Top ' Desktop.Y '= Screens[0].AvailableY = 0
    Else 'If String.LCase(Desktop.Platform) = "x11" Then 
      F_fX1 = Mouse.ScreenX - PanelGlass.ScreenX
      F_fY1 = Mouse.ScreenY - PanelGlass.ScreenY ' Desktop.Y '= Screens[0].AvailableY = 0
    Endif 
    
    ''Pick Color Pixel-Point:
    F_iColorPicker = F_imgScreen[F_fX1, F_fY1] 'as Integer
    LabelZoomColorPoint.Background = F_iColorPicker
    ZoomLupeG()
  Endif 
  
Catch
  FMain.ErrorText
  
End

Public Sub ZoomLupeG()
  
  PicBoxZoomLupe.Move((-F_fX1 * F_fZoomFactor) + (PanelColorZoom.W / 2), (-F_fY1 * F_fZoomFactor) + (PanelColorZoom.H / 2), PicBoxPhoto.W * F_fZoomFactor, PicBoxPhoto.H * F_fZoomFactor)
  F_rectZoom = Rect(PicBoxZoomLupe.Left, PicBoxZoomLupe.Top, PicBoxZoomLupe.W, PicBoxZoomLupe.H)
  ZoomImage()

Catch
  FMain.ErrorText
  
End

Public Sub ZoomImage()
  
  If Not PicBoxPhoto.Picture Then 
    LabelInfoZoomLupe.Text = ("Fehlt: Bildschirm-Foto") 
    LabelInfoZoomLupe.Tooltip = LabelInfoZoomLupe.Text
  Else  
    ''Refresh ColorPicker:
    ' If PicBoxPhoto.Visible = True Then 
    ' CursorFill()
    
    ''Show Color:
    LabelZoomColorPoint.Background = F_iColorPicker
    CheckFontForeground()
    
    LabelZoomTextG()
  Endif
  
Catch
  FMain.ErrorText
  
End

Public Sub LabelZoomTextG()
  
  LabelInfoZoomLupe.Text = ("Zoom") & Space(1) & Round(F_fZoomFactor, -1) & "x" & Space(1) & ("im Foto") & gb.NewLine & ("Maus-Rad - +")' Example Round —▶ 1.2
  LabelInfoZoomLupe.Tooltip = LabelInfoZoomLupe.Text & gb.NewLine & ("Klick=Reset: Zoom") & Space(1) & Str(F_fZoomFactor) & "x"
  
Catch
  FMain.ErrorText
  
End

Public Sub PicBoxPhotoCursorZoomCut() 
  
  Dim X1, Y1, XRel, YRel As Float
  Dim Img As Image
  
  If PicBoxPhoto.Picture Then 
    TimerZoomLupe.Stop()
    F_bZoomLupeON = False
    PanelColorZoom.Visible = False
    PicBoxCutPreview.Visible = True 
    
    X1 = Mouse.ScreenX - PicBoxPhoto.ScreenX
    Y1 = Mouse.ScreenY - PicBoxPhoto.ScreenY  
    
    XRel = PicBoxPhoto.Picture.W / PicBoxPhoto.W 
    YRel = PicBoxPhoto.Picture.H / PicBoxPhoto.H 
    X1 = X1 - (PicBoxCutPreview.W / 2)
    Y1 = Y1 - (PicBoxCutPreview.H / 2)
    X1 = X1 * XRel
    Y1 = Y1 * YRel
    
    If X1 < 0 Then X1 = 0
    If Y1 < 0 Then Y1 = 0
    
    ' PicBoxZoomLupe.Move((-X1 * F_fZoomFactor) + (PanelZoomLupe.W / 2), (-Y1 * F_fZoomFactor) + (PanelZoomLupe.H / 2), PicBoxPhoto.W * F_fZoomFactor, PicBoxPhoto.H * F_fZoomFactor)
    Img = PicBoxPhoto.Picture.Image.Copy(X1, Y1, PicBoxCutPreview.W * XRel, PicBoxCutPreview.H * YRel)
    Img = Img.Stretch(PicBoxCutPreview.W * F_fZoomFactor, PicBoxCutPreview.H * F_fZoomFactor)
    F_rectFCutMouseLupe = RectF((Img.W / 2) - (PicBoxCutPreview.W / 2), (Img.H / 2) - (PicBoxCutPreview.H / 2), PicBoxCutPreview.W, PicBoxCutPreview.H)
    If F_rectFCutMouseLupe.X < 0 Then F_rectFCutMouseLupe.X = 0
    If F_rectFCutMouseLupe.Y < 0 Then F_rectFCutMouseLupe.Y = 0
    If F_rectFCutMouseLupe.W > PicBoxCutPreview.W Then F_rectFCutMouseLupe.W = PicBoxCutPreview.W
    If F_rectFCutMouseLupe.H > PicBoxCutPreview.H Then F_rectFCutMouseLupe.H = PicBoxCutPreview.H
    Img = Img.Copy(F_rectFCutMouseLupe.X, F_rectFCutMouseLupe.Y, F_rectFCutMouseLupe.W, F_rectFCutMouseLupe.H)
    
    PicBoxCutAreaOrig.Picture = Img.Picture
    PicBoxCutPreview.Picture = Img.Picture
    
    If F_fZoomFactor > 1 Then 
      LabelM6Scale.Text = "M" & F_fZoomFactor & ":1"
    Else 
      LabelM6Scale.Text = "M" & "1:" & F_fZoomFactor 
    Endif 
    
    If PicBoxCutPreview.Picture Then 
      LabelM7.Text = ("Mittel-Klick")
      LabelM7b.Text = LabelM7.Text
      LabelM7Mini.Text = PicBoxCutPreview.Picture.W & "x" & PicBoxCutPreview.Picture.H & Space(1) & ("im Bild")
    Endif  
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomLupeOnOffMessage()
  
  Dim sPathCache1, sMessage, sMessagePic As String 
  Dim fRel As Float
  
  CheckZoomLupeCursor(F_bZoomLupeON)
  
  If F_bZoomLupeON = True Then 
    F_fZoomFactor = 4
    F_iCopyScaleIndex = 9
  Else 
    If PicBoxCutAreaOrig.Picture Then F_imgZoomLupe = PicBoxCutAreaOrig.Picture.Image
    If F_imgZoomLupe Then 
      ' F_imgZoomLupe = F_imgZoomLupe.Stretch(F_imgZoomLupe.W * F_fZoomFactor, F_imgZoomLupe.H * F_fZoomFactor)
      sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
      If F_imgZoomLupe And IsDir(File.Dir(sPathCache1)) = True Then 
        F_imgZoomLupe.Save(sPathCache1)
        fRel = F_imgZoomLupe.W / F_imgZoomLupe.H
      Endif 
      If Exist(sPathCache1) = True Then 
        sMessagePic &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & Round(fRel * 100) & " height=100 >" & Space(1) & ("Ausschnitt") & Space(1)
      Endif 
      F_iCopyScaleIndex = Settings[Form15Foto.Name &/ "F_iCopyScaleIndex", 1] 'Reset
      sMessage &= "<h3><font color=gray>" & sMessagePic & LabelM6Scale.Text & "</font></h3>"
      sMessage &= "<h3><font color=gray>" & LabelM7Mini.Text & "</font></h3>"
      sMessage &= "<h3><font color=blue>" & "● " & ("Ausschnitt als Foto einfügen?") & "</font></h3>"
      
      Select Case Message.Question(sMessage, "● " & ("Einfügen"), ("Kopieren"), ("Abbrechen"))
        Case 1
          If PicBoxCutAreaOrig.Picture Then 
            PicBoxPhoto.Picture = PicBoxCutAreaOrig.Picture'.Image.Stretch(F_imgZoomLupe.W, F_imgZoomLupe.H).Picture
            UndoRedoPhotoImageAdd(PicBoxPhoto.Picture.Image)
            CornerPointsToLabelCutAreaONoff(True)
            PhotoCutArea()
          Endif
        Case 2
          CopyButtonG()
        Case 3
          PhotoCutArea()
      End Select
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckClipboardTypeImage() 
  Dim sDirFile As String
  Dim Img As Image
  
  ''Image in Clipboard? ([Zwischenablage])
  If Clipboard.Type = Clipboard.Image Then
    '...
    Img = Clipboard.Paste()
    If Img Then 
      sDirFile = File.Dir(F_sPathScreenphotoPNG) &/ "Clipboard.png"
      If IsDir(File.Dir(sDirFile)) = True Then 
        If Exist(sDirFile) = True Then Kill sDirFile
        Img.Save(sDirFile)
      Endif 
    Endif
  Else 
    If PicBoxCutPreview.Picture Then 
      Clipboard.Clear() 
      Clipboard.Copy(PicBoxCutPreview.Picture.Image) ', "image/png"
      sDirFile = F_sPathScreenphotoPNG
      If IsDir(File.Dir(sDirFile)) = True Then 
        If Exist(sDirFile) = True Then Kill sDirFile
        PicBoxCutPreview.Picture.Save(sDirFile)
      Endif 
    Endif 
  Endif
  
  If Clipboard.Type = Clipboard.Image Then 'Type Image, not Picture  'Example Mimetype: "image/png"
    PicBoxCutPreview.Background = Color.Green
    ' PicBoxCutPreview.Picture = Img.Picture
    PicBoxLED.Picture = PicTemplateLEDgreen.Picture
    LabelClipboardInfo.Foreground = Color.Green
    LabelClipboardInfo.Visible = True 
  Else
    PicBoxCutPreview.Background = Color.Yellow 'Fehler?
    ' PicBoxCutPreview.Picture = Null 'Picture[""] 'sichtbar leeren
    PicBoxLED.Picture = PicTemplateLEDyellow.Picture
    ' Clipboard.Copy(PicBoxCutPreview.Picture.Image)
    LabelClipboardInfo.Foreground = Color.Red
    LabelClipboardInfo.Visible = True 
  Endif
  LabelM6Scale.Background = PicBoxCutPreview.Background
  CheckCacheClipboardImagePath()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CheckCacheClipboardImagePath()
  Dim sFileTime, sDirFile As String
  
  sDirFile = F_sPathScreenphotoPNG
  
  If Exist(sDirFile) = True Then 
    sFileTime = sDirFile & Space(1) & "<font color=darkgreen><b>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</b></font>"
  Else 
    sFileTime = sDirFile & Space(1) & "<font color=red>" & ("Fehlt") & "</font>"  
  Endif 
  LabelPictureSavedPath.Text = sFileTime
  
  
  sDirFile = File.Dir(F_sPathScreenphotoPNG) &/ "Clipboard.png"
  
  If Exist(sDirFile) = True Then 
    sFileTime = File.Name(sDirFile) & Space(1) & "<font color=darkgreen><b>" & M01Functions.FileSizeLongText(Stat(sDirFile).Size) & "</b></font>"
  Else 
    sFileTime = sDirFile & Space(1) & "<font color=red>" & ("Fehlt") & "</font>"  
  Endif 
  LabelPictureSavedPath.Text &= Space(1) & sFileTime
  
  Catch 
  FMain.ErrorText
  
End

Public Sub ClipboardCutAreaPreviewSVG() '???xxx unused
  
  Dim sTool, sDir, sInfo, sDirFile As String
  Dim imgScreen As Image
  Dim statImage As ImageStat
  
  sDirFile = M01Functions.ProgramDirCache(("Screenshot.png")) '/cache/file.png
  sDir = File.Dir(sDirFile)
  ' If IsDir(File.Dir(sDirFile)) = True And PicBoxCutPreview.Picture Then PicBoxCutPreview.Picture.Save(sDirFile)
  ' sDirFileSVG = File.SetExt(sDirFile, "jpeg")
  ' If IsDir(File.Dir(sDirFileSVG)) = True And PicBoxCutPreview.Picture Then PicBoxCutPreview.Picture.Save(sDirFileSVG, 50)
  ' ' Shell "convert " & sDirFile & " " & sDirFileSVG
  ' If Exist(sDirFileSVG) = True Then Clipboard.Copy(Picture.Load(sDirFileSVG))
  
  If PicBoxCutPreview.Picture Then imgScreen = PicBoxCutPreview.Picture.Image
  
  ''Alternative 6: shutter
  If imgScreen Then
    sTool = "shutter" 
    If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
    If System.Exist(sTool) = False Then sTool = System.Find(sTool) 
    If System.Exist(sTool) = True Then 
      If IsDir(sDir) = True Then 
        If Exist(sDirFile) = True Then Try Kill sDirFile
        Try Shell sTool & " -screenshot -f -n -e -o=" & sDirFile Wait 
        If Exist(sDirFile) = True Then Try imgScreen.Load(sDirFile) 
        Clipboard.Current = Clipboard.Selection
        ' Return or set the clipboard to manage.
        ' Clipboard.Default for the default clipboard.
        ' The default clipboard is the one used by the standard shortcuts CTRL+C, CTRL+X and CTRL+V.
        ' Clipboard.Selection for the secondary (or "selection") clipboard.
        ' The selection clipboard is the one used by the mouse middle button.
        '
        Image.Debug = True 
        statImage = ImageStat(sDirFile) ' as ImageStat. Gambas3: "Returns the image mimetype as a string.The string can be "image/jpeg","image/gif","image/png","image/bmp", or "image/tiff"."
        Print statImage.Type
        '?Missing: gnome-web-photo
        If imgScreen Then Clipboard.Copy(imgScreen)
        
      Endif 
      
      ''Check Clipboard
      ' If Not imgScreen Then
      ' Clipboard.Clear()
      ' Try Shell sTool & Space(1) & "-f -n" Wait     
      ' Try Shell sTool & " -screenshot -f -n -e" Wait                 
      imgScreen = M01Functions.ClipboardImage() 'as Image
      PicBoxCutPreview.Picture = imgScreen.Picture
      ' Endif
    Endif
    If imgScreen Then Settings[FMain.Name &/ "F_sScreenshotToolPath"] = sTool  'no search, faster
    If Not imgScreen Then sInfo &= sTool & "=no" & gb.NewLine Else sInfo &= sTool & "=yes" & gb.NewLine
    '' -f, --full  
    '' -o, --output=FILENAME  (*.png, *.jpg, *.gif, *.bmp,..., *.pdf, *.ps, *.svg)
    '' -n, --no_session 
    '"Do not add the screenshot to the session. This is useful when using Shutter in scripts." (*1)
    '' -e, --exit_after_capture
    '"Exit after the first capture has been made.This Is Useful when using Shutter in scripts."
    '' -web=[URL]    (Capture a webpage.Providing an URL ist optional)
    '"Capture a webpage.Providing an URL ist optional."
    '' -a, --active
    '"Capture the current active window."
    '' -w, --window=[NAME_PATTERN]
    '"Select a window to capture. Providing a NAME_PATTERN (Perl-style regex) ist optional."
    
    '        Example 2:               shutter -s=100,100,300,300 -e
    ' 
    '        Example 3                shutter --window=.*firefox.*
    ' 
    '        Example 4                shutter --web=https://shutter-project.org/ -e
    
    'Shutter - Feature-rich Screenshot Tool
    '(*1) https://manpages.ubuntu.com/manpages/jammy/en/man1/shutter.1.html
    
    '"Sind alle Aufnahmemodi außer der Desktop-Aufnahme deaktiviert, so ist offenbar Wayland im Einsatz. Aktuell muss noch Xorg benutzt werden, um die volle Funktionalität von Shutter benutzen zu können. Um von Wayland auf Xorg zu wechseln, muss die entsprechende Sitzung im Anmeldebildschirm gewählt werden." https://wiki.ubuntuusers.de/Shutter/
    
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function ClipboardCopyImageAlternative(Optional imgTemp As Image = Null) As Image '???xxx
  
  Dim sDirFile, sDir, sTool, sMimeType As String
  
  sMimeType = "image/png"
  
  ' sDir = FMain.F_sDirCache
  ' If IsDir(sDir) = False Then M01Functions.CheckDirAppName()
  ' sDirFile = M01Functions.ProgramDirCache(("gnome-bildschirmfoto.png")) '/cache/file.png
  ' sDir = File.Dir(sDirFile)
  sDir = Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache]
  sDir = FMain.F_sDirAppName
  If IsDir(sDir) = False Then sDir = Settings[FMain.Name &/ "F_sDirAppName", FMain.F_sDirAppName]
  
  ' If IsDir(File.Dir(F_sPathScreenphotoPNG)) = True Then sDir = File.Dir(F_sPathScreenphotoPNG)
  If IsDir(sDir) = True Then sDirFile = sDir &/ File.Name(F_sPathScreenphotoPNG) '& "-ausschnitt.png"
  ' ''Alternative 0: GPaste
  ' If imgTemp Then 
  '   sTool = "gpaste" ''"GPaste - A lightweight clipboard manager for the Gnome desktop" (*1)
  '   If Exist(sTool) = False Then sTool = System.Find(sTool) 
  '   If Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
  '   ''Clipboard ([Zwischenablage])
  '     Clipboard.Clear()
  '     'gpaste-client add <text>    "Add the text into the history" (*1)
  '     'gpaste-client empty         "Empty the history"
  '     Try Shell sTool & Space(1) & "-client file" & Space(1) & sDirFile Wait 
  '   Endif 
  '   '(*1) https://manpages.ubuntu.com/manpages/lunar/en/man1/gpaste-client.1.html
  ' Endif 
  
  'Alternative 1: wayland
  If imgTemp Then 
    sTool = "wl-copy" ''"wl-clipboard - Wayland copy and paste command line utilities" (*2)
    If System.Exist(sTool) = False Then sTool = System.Find(sTool)
    If System.Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
      ''Clipboard ([Zwischenablage])
      Clipboard.Clear()
      '-c, --clear
      '-t mime/type, --type mime/type
      '-l, --list-types
      'wl-copy < ~/Pictures/photo.png
      ' Shell sTool & Space(1) & "--type" & Space(1) & sMimeType & " < " & sDirFile  
      Shell sTool & " < " & sDirFile
    Else 
      If Desktop.Platform = "wayland" And String.InStr(FMain.F_sErrorMessagesExtra, "wl-clipboard") = 0 Then 
        FMain.F_sErrorMessagesExtra &= ("Fehlt") & ": " & Quote("wl-clipboard") & " - command-line copy/paste utilities for Wayland" & ". " & Quote("wl-copy") & gb.NewLine
        FMain.F_sErrorMessagesExtra &= ("Siehe in Software (installieren)") & Space(1) & Quote("wl-clipboard") & Space(1) & ("[Zwischenablage] für Fenster-Verwalter WayLand (für Applikationen auf dem Bildschirm)") & gb.NewLine
      Endif 
    Endif 
    '(*2) https://manpages.ubuntu.com/manpages/impish/man1/wl-clipboard.1.html
  Endif 
  
  ' If imgTemp = Null Then 
  ' sTool = "gnome-screenshot"  ''(*2) gtk+
  ' ' sTool = "gdm"
  ' If InStr(FMain.F_sScreenshotToolPath, sTool) > 0 Then sTool = FMain.F_sScreenshotToolPath '/dir/file.ext
  ' If Exist(sTool) = False Then sTool = System.Find(sTool) 'Else sTool = ""  
  ' If Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
  '   ' If IsDir(sDir) = True Then 
  '   '   Try Shell sTool & Space(1) & "--file=" & sDirFile Wait '-f=
  '   '   If Exist(sDirFile) = True Then Try imgTemp = Image.Load(sDirFile)
  '   ' Endif 
  '   
  '   ''Clipboard ([Zwischenablage])
  '   ' If Not imgTemp Then
  '   Clipboard.Clear()
  '   Try Shell sTool & Space(1) & "--clipboard" Wait    '"-c"           
  '          
  '   ' GTK+-Optionen
  '   '   --class=KLASSE                 Programmklasse wie vom Fenstermanager verwendet
  '   ' 
  '   '
  '   imgTemp = M01Functions.ClipboardImage() 'as Image
  '   ' Endif
  ' Endif 
  
  ''Alternative 1: wayland
  ' If imgTemp Then 
  '   sTool = "wl-paste" ''"wl-clipboard - Wayland copy and paste command line utilities" (*2)
  '   If System.Exist(sTool) = False Then sTool = System.Find(sTool) Else sTool = ""  
  '   If Exist(sTool) = True Then   'Example: "/usr/bin/gnome-screenshot"
  '   ''Clipboard ([Zwischenablage])
  '     ' Clipboard.Clear()
  '     '-c, --clear
  '     '-t mime/type, --type mime/type
  '     '-l, --list-types
  '     Shell sTool & Space(1) & "--type" & Space(1) & sMimeType & Space(1) & imgTemp Wait 
  '   Endif 
  '   '(*2) https://manpages.ubuntu.com/manpages/impish/man1/wl-clipboard.1.html
  ' Endif 
  
  Return imgTemp
  
Catch 
  FMain.ErrorText
  
End

Public Sub QuoteStarG()
  
  ' PanelBookmarks.Visible = Not PanelBookmarks.Visible
  If PanelQuotes.Visible = False Then 
    ColumnView3ReadQuotes()
    PanelQuotes.Visible = True
    PanelQuotes.Raise()
    F_bQuoteStarListChanged = False
    ColumnView3ListChanged()
  Else 
    QuotesStarPanelClose()
  Endif 
  
  QuoteStarCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub QuotesStarPanelClose() 
  
  Dim sMessage As String 
  
  If F_bQuoteStarListChanged = True Then 
    sMessage = "<h2><font color=red>" & "*" & ("Liste verändert") & "</font></h2>" 
    
    Select Case Message.Question(sMessage, ("Speichern..."), ("Nein"), ("Abbrechen"))
      Case 1
        ColumnView3SaveQuotes()
      Case 2
        ''...
      Case 3 'Abbrechen, Cancel
        ''...
    End Select
  Endif
  PanelQuotes.Visible = False 
  ButtonQuotesOnOff.Background = Color.Default
  ScrollViewQuote.Visible = F_bQuoteStarON
  SelectQuote()
  ColumnView1.Clear()
  PaintQuote()
  
Catch 
  FMain.ErrorText
  
End

Public Sub QuoteStarOnOff()
  
  F_bQuoteStarON = Not F_bQuoteStarON
  Settings[Form15Foto.Name &/ "F_bQuoteStarON"] = F_bQuoteStarON
  QuoteStarCheck()
  
Catch 
  FMain.ErrorText
  
End

Public Sub QuoteStarCheck()
  
  Dim sText As String 
  
  ' F_bQuoteStarON = Settings[Form15Foto.Name &/ "F_bQuoteStarON", False]
  
  If F_bQuoteStarON = True Then 
    ButtonQuotesOnOff.Picture = PicTemplateBookmarkStar.Picture
    ButtonQuotesOnOff.Background = Color.Green
    ButtonQuotesOnOff.Border = F_bQuoteStarON
    sText = CheckPaintQuote()
    LabelCutArea.Text = sText
  Else 
    ButtonQuotesOnOff.Picture = PicTemplateBookmarkStar.Picture.Image.Desaturate().Picture
    ButtonQuotesOnOff.Background = Color.Default 
    ButtonQuotesOnOff.Border = F_bQuoteStarON
    LabelCutArea.Text = "" 
    sText = ("Beispiel" & ": " & F_sQuoteEmpty)
  Endif
  TextBoxQuoteExample.SelectAll
  TextBoxQuoteExample.Insert(sText)
  
  ScrollViewQuote.Visible = F_bQuoteStarON
  ButtonQuotesLineOnOff.Picture = ButtonQuotesOnOff.Picture
  ButtonQuotesLineOnOff.Background = ButtonQuotesOnOff.Background
  ButtonQuotesLineOnOff.Border = ButtonQuotesOnOff.Border
  
Catch 
  FMain.ErrorText
  
End

Public Sub Eckpunkte_Enter()
  
  Last.Background = F_iColorGreen150
  
End

Public Sub Eckpunkte_Leave()
  
  Last.Background = Color.Default
  
End

Public Sub Eckpunkte_MouseDown() 
  
  F_bEdgeON = True
  F_fLX1 = Mouse.X 
  F_fLY1 = Mouse.Y 
  LabelCutArea.Visible = True

  If Mouse.Left = True Then  
    If F_bCutAreaFullScreenON = True Then ButtonM4FullG()
    
    ''Diagonal?
    If Mouse.X < Eckpunkt1.W * 0.3 And Mouse.Y < Eckpunkt1.H * 0.3 Then F_sMovePointsCutArea = "movediagonal1" '1
    If Mouse.X > Eckpunkt1.W * 0.7 And Mouse.Y < Eckpunkt1.H * 0.3 Then F_sMovePointsCutArea = "movediagonal2" '2
    If Mouse.X > Eckpunkt1.W * 0.7 And Mouse.Y > Eckpunkt1.H * 0.7 Then F_sMovePointsCutArea = "movediagonal3" '3
    If Mouse.X < Eckpunkt1.W * 0.3 And Mouse.Y > Eckpunkt1.H * 0.7 Then F_sMovePointsCutArea = "movediagonal4" '4
    
    If F_sMovePointsCutArea = "movehorizontal" Then 
      If Last.Tag = 1 Or Last.Tag = 4 Then F_sMovePointsCutArea = "moveleft"
      If Last.Tag = 2 Or Last.Tag = 3 Then F_sMovePointsCutArea = "moveright" 
    Endif 
    
    If F_sMovePointsCutArea = "movevertical" Then 
      If Last.Tag = 1 Or Last.Tag = 2 Then F_sMovePointsCutArea = "movetop"
      If Last.Tag = 3 Or Last.Tag = 4 Then F_sMovePointsCutArea = "movebottom"
    Endif 
    
    If Last.Tag = 6 Then F_sMovePointsCutArea = "movelinetop"
    If Last.Tag = 7 Then F_sMovePointsCutArea = "movelineright"
    If Last.Tag = 8 Then F_sMovePointsCutArea = "movelinebottom"
    If Last.Tag = 9 Then F_sMovePointsCutArea = "movelineleft"
  Endif
  
  If Mouse.Right = True Then 
    If CInteger(Last.Tag) < 5 Then F_sMovePointsCutArea = "movediagonal" & Last.Tag '& 1,2,3 or 4    movediagonal1
    If Last.Tag = 5 Then Menu2.Popup() 'Center-Point
    If Last.Tag = 6 Or Last.Tag = 8 Then F_sMovePointsCutArea = "movevertical" 
    If Last.Tag = 7 Or Last.Tag = 9 Then F_sMovePointsCutArea = "movehorizontal" 
  Endif
  
  CornerPointsPicture(F_sMovePointsCutArea)
  Eckpunkt5Middle.Cursor = New Cursor(Eckpunkt5Middle.Picture, Eckpunkt5Middle.Picture.W / 2, Eckpunkt5Middle.Picture.H / 2)
  Eckpunkt5Middle.Mouse = Mouse.Custom
  ' If F_bFormResizeChanged = True Then CreateRulersG(F_sRulersCMorCMRELorPIXEL)
  
Catch 
  FMain.ErrorText
  
End

Public Sub Eckpunkte_MouseMove() 'Corner-Point
  
  Dim iLeft, iFix As Integer
  
  If F_bEdgeON = True Then 
    iLeft = Mouse.X - F_fLX1
    Select Case F_sMovePointsCutArea
      Case "move"
        Last.Move(Last.X + Mouse.X - F_fLX1, Last.Y + Mouse.Y - F_fLY1)
      Case "movediagonal1"
        Last.Move(Last.X + iLeft, Last.Y + iLeft)
      Case "movediagonal2"
        Last.Move(Last.X + iLeft, Last.Y - iLeft) 
      Case "movediagonal3"
        Last.Move(Last.X + iLeft, Last.Y + iLeft)
      Case "movediagonal4"
        Last.Move(Last.X + iLeft, Last.Y - iLeft)
      Case "moveleft", "moveright", "movehorizontal"
        Last.Left = Last.X + Mouse.X - F_fLX1
      Case "movetop", "movebottom", "movevertical"
        Last.Top = Last.Y + Mouse.Y - F_fLY1
      Case "movelinetop", "movelinebottom"
        Last.Top = Last.Y + Mouse.Y - F_fLY1
      Case "movelineright", "movelineleft"
        Last.Left = Last.X + Mouse.X - F_fLX1
    End Select
    
    '□ max. Randgrenzen, nur im Bild bleiben
    If Last.X + Last.W < PanelGlass.Left Then Last.X = PanelGlass.Left - Last.W
    If Last.Y + Last.H < PanelGlass.Top Then Last.Y = PanelGlass.Top - Last.H
    If Last.X > PanelGlass.Left + PanelGlass.Width Then Last.X = PanelGlass.Left + PanelGlass.Width
    If Last.Y > PanelGlass.Top + PanelGlass.Height Then Last.Y = PanelGlass.Top + PanelGlass.Height
    
    ''Syncronize (synchron bewegen)
    Select Case Last.Tag 
      Case 1
        Eckpunkt2.Top = Eckpunkt1.Top
        Eckpunkt4.Left = Eckpunkt1.Left
      Case 2
        Eckpunkt1.Top = Eckpunkt2.Top
        Eckpunkt3.Left = Eckpunkt2.Left
      Case 3
        Eckpunkt4.Top = Eckpunkt3.Top
        Eckpunkt2.Left = Eckpunkt3.Left
        Eckpunkt8.Top = Eckpunkt4.Top
      Case 4
        Eckpunkt3.Top = Eckpunkt4.Top
        Eckpunkt1.Left = Eckpunkt4.Left
      Case 5
        Eckpunkt1.Top = Eckpunkt5Middle.Top - ((LabelCutArea.H / 2) + (Eckpunkt5Middle.H / 2))
        Eckpunkt2.Top = Eckpunkt1.Top
        Eckpunkt3.Top = Eckpunkt1.Top + LabelCutArea.H + Eckpunkt3.H
        Eckpunkt4.Top = Eckpunkt3.Top
        
        Eckpunkt1.Left = Eckpunkt5Middle.Left - ((LabelCutArea.W / 2) + (Eckpunkt5Middle.W / 2))
        Eckpunkt2.Left = Eckpunkt1.Left + LabelCutArea.W + Eckpunkt3.W
        Eckpunkt3.Left = Eckpunkt2.Left 
        Eckpunkt4.Left = Eckpunkt1.Left
      Case 6
        iFix = Eckpunkt4.Top - Eckpunkt1.Top
        Eckpunkt1.Top = Eckpunkt6.Top
        Eckpunkt2.Top = Eckpunkt6.Top
        If Mouse.Right Then 
          Eckpunkt3.Top = Eckpunkt1.Top + iFix
          Eckpunkt4.Top = Eckpunkt3.Top
        Endif 
      Case 7
        iFix = Eckpunkt2.Left - Eckpunkt1.Left
        Eckpunkt2.Left = Eckpunkt7.Left
        Eckpunkt3.Left = Eckpunkt7.Left
        If Mouse.Right Then 
          Eckpunkt1.Left = Eckpunkt2.Left - iFix
          Eckpunkt4.Left = Eckpunkt1.Left
        Endif 
      Case 8
        iFix = Eckpunkt4.Top - Eckpunkt1.Top
        Eckpunkt3.Top = Eckpunkt8.Top
        Eckpunkt4.Top = Eckpunkt8.Top
        If Mouse.Right Then 
          Eckpunkt1.Top = Eckpunkt3.Top - iFix
          Eckpunkt2.Top = Eckpunkt1.Top
        Endif 
      Case 9
        iFix = Eckpunkt2.Left - Eckpunkt1.Left
        Eckpunkt1.Left = Eckpunkt9.Left
        Eckpunkt4.Left = Eckpunkt9.Left
        If Mouse.Right Then 
          Eckpunkt2.Left = Eckpunkt1.Left + iFix
          Eckpunkt3.Left = Eckpunkt2.Left
        Endif 
    End Select 

    LabelCutAreaToCornerPoints(Last.Tag)
    If PicBoxGrid.Visible = True Then GridMagnetic()
    If F_bCrossLineON = True Then CrossLinesMove()
    PicBoxRulerHorizontal.Move(PanelGlass.Left, Eckpunkt4.Top, PanelGlass.W, Eckpunkt4.H)
    PicBoxRulerVertical.Move(Eckpunkt1.Left, PanelGlass.Top, Eckpunkt1.W, PanelGlass.H)
    ' PicBoxRulerHorizontal.Visible = F_bRulesON
    ' PicBoxRulerVertical.Visible = F_bRulesON
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub Eckpunkte_MouseUp()
  
  Dim iLeftTemp, iW As Integer
  
  F_bEdgeON = False
  iW = Eckpunkt1.W ' = Eckpunt1.H '1:1
  'Change +Point 1-2 or 2-1
  If Eckpunkt1.Left > Eckpunkt2.Left Then '■——□
    iLeftTemp = Eckpunkt1.Left 
    Eckpunkt1.Left = Eckpunkt2.Left - iW 
    Eckpunkt2.Left = iLeftTemp 
    Eckpunkt3.Left = Eckpunkt2.Left
    Eckpunkt4.Left = Eckpunkt1.Left 
  Endif 
  
  If Eckpunkt1.Top > Eckpunkt4.Top Then '▲—▽
    iLeftTemp = Eckpunkt1.Top 
    Eckpunkt1.Top = Eckpunkt4.Top - iW
    Eckpunkt4.Top = iLeftTemp 
    Eckpunkt2.Top = Eckpunkt1.Top
    Eckpunkt3.Top = Eckpunkt4.Top 
  Endif 
  LabelCutAreaCheckMax()
  LabelCutAreaToCornerPoints(Last.Tag)
  If PicBoxGrid.Visible = True Then GridMagnetic()
  If F_bCrossLineON = True Then CrossLinesMove()
  PhotoCutArea()
  CornerPointsToLabelCutAreaONoff(True)
  CornerPointsPicture("reset")
  
Catch 
  FMain.ErrorText
  
End

Public Sub Eckpunkte_MouseWheel()

  Select Case Last.Tag
    Case 1, 2, 5
      F_sMovePointsCutArea = "movevertical" '|
    Case 3, 4 
      F_sMovePointsCutArea = "movehorizontal" '——
    Case 6
      F_sMovePointsCutArea = "movelinetop"
    Case 7
      F_sMovePointsCutArea = "movelineright"
    Case 8
      F_sMovePointsCutArea = "movelinebottom"
    Case 9
      F_sMovePointsCutArea = "movelineleft" 
  End Select
  
  LabelCutArea_MouseWheel()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CornerPointsPicture(Optional sLastTag As String = "reset")
  
  Select Case sLastTag
    Case "reset", "move"
      ''Reset
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture  '+
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowSizeAll.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      ' Eckpunkt5Middle.Mouse = Mouse.SizeAll
      F_sMovePointsCutArea = "move"
      Eckpunkt5Middle.Cursor = New Cursor(Eckpunkt5Middle.Picture, Eckpunkt5Middle.Picture.W / 2, Eckpunkt5Middle.Picture.H / 2)
      Eckpunkt5Middle.Mouse = Mouse.Custom
      
    Case "moveleft"
      Eckpunkt1.Picture = PicTemplateArrowLR.Picture
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateArrowLR.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowLR.Picture
      Eckpunkt1.Mouse = Mouse.SplitH
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SplitH
      Eckpunkt5Middle.Mouse = Mouse.SplitH
      
    Case "moveright"
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt2.Picture = PicTemplateArrowLR.Picture
      Eckpunkt3.Picture = PicTemplateArrowLR.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowLR.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SplitH 
      Eckpunkt3.Mouse = Mouse.SplitH
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SplitH
      
    Case "movetop"
      Eckpunkt1.Picture = PicTemplateArrowUD.Picture
      Eckpunkt2.Picture = PicTemplateArrowUD.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowUD.Picture
      Eckpunkt1.Mouse = Mouse.SplitV
      Eckpunkt2.Mouse = Mouse.SplitV
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SplitV
      
    Case "movebottom"
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateArrowUD.Picture
      Eckpunkt4.Picture = PicTemplateArrowUD.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowUD.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SplitV
      Eckpunkt4.Mouse = Mouse.SplitV
      Eckpunkt5Middle.Mouse = Mouse.SplitV
      
    Case "movediagonal1" '\
      Eckpunkt1.Picture = PicTemplateArrowDiagonalL.Picture 
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowDiagonalL.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SizeNWSE  ' \
      
    Case "movediagonal2" '/
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture 
      Eckpunkt2.Picture = PicTemplateArrowDiagonalR.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowDiagonalR.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SizeNESW  ' /
      
    Case "movediagonal3" '\
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture 
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateArrowDiagonalL.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowDiagonalL.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SizeNWSE  ' \
      
    Case "movediagonal4" '/
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture 
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateArrowDiagonalR.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowDiagonalR.Picture
      Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
      Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
      Eckpunkt5Middle.Mouse = Mouse.SizeNESW  ' /
      
    Case "movehorizontal" '—
      Eckpunkt1.Picture = PicTemplateArrowLR.Picture 
      Eckpunkt2.Picture = PicTemplateArrowLR.Picture
      Eckpunkt3.Picture = PicTemplateArrowLR.Picture
      Eckpunkt4.Picture = PicTemplateArrowLR.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowLR.Picture
      Eckpunkt1.Mouse = Mouse.SplitH
      Eckpunkt2.Mouse = Mouse.SplitH
      Eckpunkt3.Mouse = Mouse.SplitH
      Eckpunkt4.Mouse = Mouse.SplitH
      Eckpunkt5Middle.Mouse = Mouse.SplitH
      
    Case "movevertical" '|
      Eckpunkt1.Picture = PicTemplateArrowUD.Picture 
      Eckpunkt2.Picture = PicTemplateArrowUD.Picture
      Eckpunkt3.Picture = PicTemplateArrowUD.Picture
      Eckpunkt4.Picture = PicTemplateArrowUD.Picture
      Eckpunkt5Middle.Picture = PicTemplateArrowUD.Picture
      Eckpunkt1.Mouse = Mouse.SplitV
      Eckpunkt2.Mouse = Mouse.SplitV
      Eckpunkt3.Mouse = Mouse.SplitV
      Eckpunkt4.Mouse = Mouse.SplitV
      Eckpunkt5Middle.Mouse = Mouse.SplitV
      
  End Select
  
Catch 
  FMain.ErrorText
  
End

Public Sub CornerPointsSquarePicture(Optional sLastTag As String = "reset")
  
  Dim fScaleX, fScaleY As Float
  Dim iW As Integer
  
  Eckpunkt1.Mouse = Mouse.SizeNWSE  ' \
  Eckpunkt2.Mouse = Mouse.SizeNESW  ' /
  Eckpunkt3.Mouse = Mouse.SizeNWSE  ' \
  Eckpunkt4.Mouse = Mouse.SizeNESW  ' /
  
  Select Case sLastTag
    Case "reset"
      ''Reset
      Eckpunkt1.Picture = PicTemplateCornerPointPlus.Picture  '+
      Eckpunkt2.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt3.Picture = PicTemplateCornerPointPlus.Picture
      Eckpunkt4.Picture = PicTemplateCornerPointPlus.Picture
      
    Case "square", ButtonM7Square.Tag '□ W=H 1:1
      fScaleX = PicBoxPhoto.Picture.Width / PicBoxPhoto.Width
      fScaleY = PicBoxPhoto.Picture.Height / PicBoxPhoto.Height
      If fScaleX = 0 Then fScaleX = 1'not Division by zero
      ' If fScaleY = 0 Then fScaleY = 1
      iW = (fScaleY / fScaleX) * LabelCutArea.H
      LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, iW, LabelCutArea.H)
      Eckpunkt1.Picture = ButtonM7Square.Picture
      Eckpunkt2.Picture = ButtonM7Square.Picture
      Eckpunkt3.Picture = ButtonM7Square.Picture
      Eckpunkt4.Picture = ButtonM7Square.Picture
      
    Case "squareminusright", ButtonM7MinusRight.Tag
      LabelCutArea.W = LabelCutArea.W - 1 'Pixel
      Eckpunkt1.Picture = ButtonM7MinusRight.Picture
      Eckpunkt2.Picture = ButtonM7MinusRight.Picture
      Eckpunkt3.Picture = ButtonM7MinusRight.Picture
      Eckpunkt4.Picture = ButtonM7MinusRight.Picture
      
    Case "squareplusright", ButtonM7PlusRight.Tag
      LabelCutArea.W = LabelCutArea.W + 1 'Pixel
      Eckpunkt1.Picture = ButtonM7PlusRight.Picture
      Eckpunkt2.Picture = ButtonM7PlusRight.Picture
      Eckpunkt3.Picture = ButtonM7PlusRight.Picture
      Eckpunkt4.Picture = ButtonM7PlusRight.Picture
      
    Case "squareminusdown", ButtonM7MinusDown.Tag
      LabelCutArea.H = LabelCutArea.H - 1 'Pixel
      Eckpunkt1.Picture = ButtonM7MinusDown.Picture
      Eckpunkt2.Picture = ButtonM7MinusDown.Picture
      Eckpunkt3.Picture = ButtonM7MinusDown.Picture
      Eckpunkt4.Picture = ButtonM7MinusDown.Picture
      
    Case "squareplusdown", ButtonM7PlusDown.Tag
      LabelCutArea.H = LabelCutArea.H + 1 'Pixel
      Eckpunkt1.Picture = ButtonM7PlusDown.Picture
      Eckpunkt2.Picture = ButtonM7PlusDown.Picture
      Eckpunkt3.Picture = ButtonM7PlusDown.Picture
      Eckpunkt4.Picture = ButtonM7PlusDown.Picture
      
    Case "squareup", ButtonM7Up.Tag '▲
      LabelCutArea.Top = LabelCutArea.Top - 1 'Pixel
      Eckpunkt1.Picture = ButtonM7Up.Picture
      Eckpunkt2.Picture = ButtonM7Up.Picture
      Eckpunkt3.Picture = ButtonM7Up.Picture
      Eckpunkt4.Picture = ButtonM7Up.Picture
      
    Case "squaredown", ButtonM7Down.Tag  '▼
      LabelCutArea.Top = LabelCutArea.Top + 1 'Pixel
      Eckpunkt1.Picture = ButtonM7Down.Picture
      Eckpunkt2.Picture = ButtonM7Down.Picture
      Eckpunkt3.Picture = ButtonM7Down.Picture
      Eckpunkt4.Picture = ButtonM7Down.Picture
      
    Case "squareleft", ButtonM7Left.Tag '◀
      LabelCutArea.Left = LabelCutArea.Left - 1 'Pixel
      Eckpunkt1.Picture = ButtonM7Left.Picture
      Eckpunkt2.Picture = ButtonM7Left.Picture
      Eckpunkt3.Picture = ButtonM7Left.Picture
      Eckpunkt4.Picture = ButtonM7Left.Picture
      
    Case "squareright", ButtonM7Right.Tag '▶
      LabelCutArea.Left = LabelCutArea.Left + 1 'Pixel
      Eckpunkt1.Picture = ButtonM7Right.Picture
      Eckpunkt2.Picture = ButtonM7Right.Picture
      Eckpunkt3.Picture = ButtonM7Right.Picture
      Eckpunkt4.Picture = ButtonM7Right.Picture
      
  End Select
  Eckpunkt5Middle.Picture = Eckpunkt1.Picture
  
  CornerPointsToLabelCutAreaONoff(Eckpunkt1.Visible) 'ON-off and Positions
  LabelCutAreaToCornerPoints(Eckpunkt5Middle.Tag)
  LabelPixelWxHScalePicture()
  PaintQuote()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CutAreaSquare() '???xxx
  
  Dim iH, fScaleX, fScaleY As Float
  
  fScaleX = PicBoxPhoto.Picture.Width / PicBoxPhoto.Width
  fScaleY = PicBoxPhoto.Picture.Height / PicBoxPhoto.Height
  iH = Round(LabelCutArea.H * (fScaleY / fScaleX), 0) 
  
  LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, iH, iH)
  
  CornerPointsToLabelCutAreaONoff(Eckpunkt1.Visible) 'ON-off and Positions
  LabelCutAreaToCornerPoints(Eckpunkt5Middle.Tag)
  LabelPixelWxHScalePicture()
  PaintQuote()
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutAreaToCornerPoints(Optional iCornerPoint As Integer = 0)
  
  If F_bEdgeON = True Then
    If iCornerPoint = 5 Then 'center, middle
      LabelCutArea.Move(Eckpunkt5Middle.Left + (Eckpunkt5Middle.W / 2) - (LabelCutArea.W / 2) - PanelGlass.Left, Eckpunkt5Middle.Top + (Eckpunkt5Middle.H / 2) - (LabelCutArea.H / 2) - PanelGlass.Top)
    Else 
      LabelCutArea.Move(Eckpunkt1.Left + Eckpunkt1.Width - PanelGlass.Left, Eckpunkt1.Top + Eckpunkt1.Height - PanelGlass.Top, Eckpunkt2.Left - Eckpunkt1.Left - Eckpunkt1.Width, Eckpunkt3.Top - Eckpunkt1.Top - Eckpunkt1.Height)
    Endif 
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub CornerPointsToLabelCutAreaONoff(Optional bON As Boolean = False) 'show over all, not in PanelGlass
  
  Dim iW, iW2, iH, iH2, iBW, iBH As Integer 'Width, Height, B=Border
  
  If F_pointFUnitCentimeterXY Then Eckpunkt1.Width = F_pointFUnitCentimeterXY.X
  iW = Eckpunkt1.Width
  iW2 = iW / 2
  iH = iW 'LabelEck1.Height  1:1
  iH2 = iW2
  iBW = PanelGlass.Left
  iBH = PanelGlass.Top
  'Check max. Größe
  Eckpunkt1.Move(iBW + LabelCutArea.Left - iW, LabelCutArea.Top - iH + iBH, iW, iH)
  Eckpunkt2.Move(iBW + LabelCutArea.Left + LabelCutArea.Width, iBH + LabelCutArea.Top - iH, iW, iH)
  Eckpunkt3.Move(iBW + LabelCutArea.Left + LabelCutArea.Width, iBH + LabelCutArea.Top + LabelCutArea.Height, iW, iH)
  Eckpunkt4.Move(iBW + LabelCutArea.Left - iW, iBH + LabelCutArea.Top + LabelCutArea.Height, iW, iH)
  Eckpunkt5Middle.Move(iBW + LabelCutArea.Left + (LabelCutArea.W / 2) - iW2, iBH + LabelCutArea.Top + (LabelCutArea.H / 2) - iW2, iW, iW)
  Eckpunkt6.Move(Eckpunkt5Middle.Left, Eckpunkt1.Top, iW, iH)
  Eckpunkt7.Move(Eckpunkt2.Left, Eckpunkt5Middle.Top, iW, iH)
  Eckpunkt8.Move(Eckpunkt5Middle.Left, Eckpunkt4.Top, iW, iH)
  Eckpunkt9.Move(Eckpunkt1.Left, Eckpunkt5Middle.Top, iW, iH)

  
  If ImageView1.Visible = False And PanelFileSaved.Visible = False And PanelQuotes.Visible = False Then bON = False 
  Eckpunkt1.Visible = bON 'True or False
  Eckpunkt2.Visible = bON
  Eckpunkt3.Visible = bON
  Eckpunkt4.Visible = bON
  Eckpunkt5Middle.Visible = bON
  Eckpunkt6.Visible = bON
  Eckpunkt7.Visible = bON
  Eckpunkt8.Visible = bON
  Eckpunkt9.Visible = bON
  
  PicBoxRulerHorizontal.Move(PanelGlass.Left, Eckpunkt4.Top, PanelGlass.W, Eckpunkt4.H)
  PicBoxRulerVertical.Move(Eckpunkt1.Left, PanelGlass.Top, Eckpunkt1.W, PanelGlass.H)
  PicBoxRulerHorizontal.Visible = F_bRulesON
  PicBoxRulerVertical.Visible = F_bRulesON
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageView1_MouseDown()
  
  If ImageView1.Image Then PictureFotoAddUndoSelect(ImageView1.Image)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PictureFotoAddUndoSelect(Optional imgAdd As Image = Null) 
  
  If imgAdd Then 
    If F_ooUndoRedoPhoto Then 
      F_iCVUndoRedoPointer = F_ooUndoRedoPhoto.Find(imgAdd)
      If F_iCVUndoRedoPointer = -1 Then 
        UndoRedoPhotoImageAdd(imgAdd)
      Else 
        UndoRedoPhotosPointer("select")
      Endif 
    Else 
      UndoRedoPhotoImageAdd(imgAdd)
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageView1_KeyPress()
  
  If Key.Code = Key.Down Or Key.Code = Key.Right Or Key.Text = "+" Then
    ZoomHasFocus(True)
  Else If Key.Code = Key.Up Or Key.Code = Key.Left Or Key.Text = "-" Then
    ZoomHasFocus(False)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageViewPhoto_KeyPress()
  
  If Key.Code = Key.Down Or Key.Code = Key.Right Or Key.Text = "+" Then
    ZoomHasFocus(True)
  Else If Key.Code = Key.Up Or Key.Code = Key.Left Or Key.Text = "-" Then
    ZoomHasFocus(False)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageView1_MouseWheel()

  ImageView1.Scroll(Mouse.X, Mouse.Y)
  ZoomHasFocus(Mouse.Forward)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageViewPhoto_MouseWheel()
  
  If F_bZoomLupeON = True Then 
    ' ImageViewPhoto.Alignment = Align.Center
    ImageViewPhoto.Scroll(Mouse.X, Mouse.Y)
    ZoomHasFocus(Mouse.Forward)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutArea_MouseWheel()
  
  If F_bZoomLupeON = True Then 
    ZoomHasFocus(Mouse.Forward)
  Else 
    F_bAreaMoveON = True
    Select Case F_sMovePointsCutArea
      
      Case "movehorizontal"  
        If Mouse.Forward = True Then  
          LabelCutArea.Left = LabelCutArea.Left + 1
        Else 
          LabelCutArea.Left = LabelCutArea.Left - 1
        Endif 
        
      Case "movevertical"
        If Mouse.Forward = True Then  
          LabelCutArea.Top = LabelCutArea.Top + 1
        Else 
          LabelCutArea.Top = LabelCutArea.Top - 1
        Endif 
        
      Case "movelinetop"
        If Mouse.Forward = True Then  
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top + 1, LabelCutArea.W, LabelCutArea.H - 1)
        Else 
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top - 1, LabelCutArea.W, LabelCutArea.H + 1)
        Endif 
        
      Case "movelineright"
        If Mouse.Forward = True Then  
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W + 1, LabelCutArea.H)
        Else 
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W - 1, LabelCutArea.H)
        Endif 
        
      Case "movelinebottom"
        If Mouse.Forward = True Then  
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W, LabelCutArea.H + 1)
        Else 
          LabelCutArea.Move(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W, LabelCutArea.H - 1)
        Endif 

      Case "movelineleft"
        If Mouse.Forward = True Then  
          LabelCutArea.Move(LabelCutArea.Left + 1, LabelCutArea.Top, LabelCutArea.W - 1, LabelCutArea.H)
        Else 
          LabelCutArea.Move(LabelCutArea.Left - 1, LabelCutArea.Top, LabelCutArea.W + 1, LabelCutArea.H)
        Endif 
    End Select
    
    Eckpunkt1.Picture = PicTemplateArrowWheelUD.Picture 'UpDown 'Top-Bottom △▼
    Eckpunkt2.Picture = PicTemplateArrowWheelUD.Picture 
    Eckpunkt3.Picture = PicTemplateArrowWheelLR.Picture 'Left-Right ◁—▶
    Eckpunkt4.Picture = PicTemplateArrowWheelLR.Picture

    If PicBoxGrid.Visible = True Then GridMagnetic()
    If F_bCrossLineON = True Then CrossLinesMove()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxPhoto_MouseWheel()
  
  If F_bZoomLupeON = True Then ZoomHasFocus(Mouse.Forward)
  
  'Alternative:
  'ImageView2.Zoom = ImageView2.Zoom + (Mouse.Delta * (-1))                                'as Float, + Mouse.Forward
  
Catch 
  FMain.ErrorText
  
End

Public Sub ImageViewPhoto_MouseDown()
  
  Dim Img As Image 
  Dim pointXY As Point
  
  If ImageViewPhoto.Image Then 
    If Mouse.Left = True Then 
      pointXY = Point(Mouse.X, Mouse.Y)
      ' ImageViewPhoto.Scroll(ImageViewPhoto.ScrollX, ImageViewPhoto.ScrollY)
      ' pointXY = ImageViewPhoto.ImageToView(pointXY) 'as Point
      pointXY = ImageViewPhoto.ViewToImage(pointXY) 'as Point
      
      Img = PicBoxPhoto.Picture.Image.Copy(pointXY.X - (LabelCutArea.W / 2), pointXY.Y - (LabelCutArea.H / 2), LabelCutArea.W, LabelCutArea.H) 
      PicBoxCutAreaOrig.Picture = Img.Stretch(Img.W * ImageViewPhoto.Zoom, Img.H * ImageViewPhoto.Zoom).Picture
      PicBoxCutPreview.Picture = PicBoxCutAreaOrig.Picture.Copy()
      PaintQuote()
    Endif 
    
    If Mouse.Middle = True Then '/2
      pointXY = Point(Mouse.X - (PicBoxCutPreview.W / 2 * 2), Mouse.Y - (PicBoxCutPreview.H / 2 * 2))
      pointXY = ImageViewPhoto.ViewToImage(pointXY) 'as Point (X,Y)
      Img = PicBoxPhoto.Picture.Image.Copy(pointXY.X, pointXY.Y, PicBoxCutPreview.W / ImageViewPhoto.Zoom * 2, PicBoxCutPreview.H / ImageViewPhoto.Zoom * 2) 
      PicBoxCutAreaOrig.Picture = Img.Stretch(Img.W * ImageViewPhoto.Zoom, Img.H * ImageViewPhoto.Zoom).Picture
      PicBoxCutPreview.Picture = PicBoxCutAreaOrig.Picture.Copy()
      ' LabelCutArea.Move(pointXY.X, pointXY.Y)
      ' LabelPixelWxHScalePicture()
      PaintQuote()
      ' UndoRedoCutArea()
      ' LabelM7.Text = ("Mittel-Klick")
      ' LabelM7b.Text = LabelM7.Text
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ZoomHasFocus(Optional bMouseForward As Boolean = True)
  
  Dim sMinMax As String 
  
  If ImageView1.HasFocus = True Then 
    If ImageView1.Zoom < 1.2 Then 
      If bMouseForward = False Then 
        ImageView1.Zoom = ImageView1.Zoom - 0.1
      Else
        ImageView1.Zoom = ImageView1.Zoom + 0.1
      Endif
    Else 
      If bMouseForward = False Then 
        ImageView1.Zoom = ImageView1.Zoom - 0.5
      Else
        ImageView1.Zoom = ImageView1.Zoom + 0.5
      Endif  
    Endif 
    If ImageView1.Zoom < 0.3 Then sMinMax = Space(1) & ("min")
    If ImageView1.Zoom > 19.5 Then sMinMax = Space(1) & ("max")
    Form15Foto.Window.Title = Application.Name & " - " & ("Zoom") & ": " & Round(ImageView1.Zoom, -1) & sMinMax'Example: 1.2
  Endif 
  
  If ImageViewPhoto.HasFocus = True Then 
    ' pointScrollXY = Point(ImageViewPhoto.ScrollX, ImageViewPhoto.ScrollY)
    ' pointScrollXY = ImageViewPhoto.ViewToImage(pointScrollXY)
    If ImageViewPhoto.Zoom < 1.2 Then 
      If bMouseForward = False Then 
        ImageViewPhoto.Zoom = ImageViewPhoto.Zoom - 0.1
      Else
        ImageViewPhoto.Zoom = ImageViewPhoto.Zoom + 0.1
      Endif
    Else 
      If bMouseForward = False Then 
        ImageViewPhoto.Zoom = ImageViewPhoto.Zoom - 0.5
      Else
        ImageViewPhoto.Zoom = ImageViewPhoto.Zoom + 0.5
      Endif  
    Endif 
    If ImageViewPhoto.Zoom < 0.3 Then sMinMax = Space(1) & ("min")
    If ImageViewPhoto.Zoom > 19.5 Then sMinMax = Space(1) & ("max")
    Form15Foto.Window.Title = Application.Name & " - " & ("Zoom") & ": " & Round(ImageViewPhoto.Zoom, -1) & sMinMax
    LabelM6Scale.Text = ("Zoom") & ": " & Round(ImageViewPhoto.Zoom, -1) & sMinMax
    ' ImageViewPhoto.Scroll(pointScrollXY.X / ImageViewPhoto.Zoom, pointScrollXY.X / ImageViewPhoto.Zoom)
  Endif 
  
  If PicBoxPhoto.HasFocus = True Or LabelCutArea.HasFocus = True Or PicBoxGrid.HasFocus = True Then 
    If F_fZoomFactor < 1.2 Then 
      If bMouseForward = False Then 
        F_fZoomFactor = F_fZoomFactor - 0.1
      Else
        F_fZoomFactor = F_fZoomFactor + 0.1
      Endif
    Else 
      If bMouseForward = False Then 
        F_fZoomFactor = F_fZoomFactor - 0.5
      Else
        F_fZoomFactor = F_fZoomFactor + 0.5
      Endif  
    Endif 
    If F_fZoomFactor < 0.2 Then F_fZoomFactor = 0.2
    If F_fZoomFactor > 20 Then F_fZoomFactor = 20
    If F_fZoomFactor < 0.3 Then sMinMax = Space(1) & ("min")
    If F_fZoomFactor > 19.5 Then sMinMax = Space(1) & ("max")
    Form15Foto.Window.Title = Application.Name & " - " & ("Zoom") & ": " & Round(F_fZoomFactor, -1) & sMinMax
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub IconError_MouseDown()
  
  M01Functions.ErrorMessages()
  
End

Public Sub mnuFehlerMeldungen_Click()
  
  M01Functions.ErrorMessages()
  
End

Public Sub MenuSystemInfo_Click()
  
  M01Functions.SystemControl("systeminfo")
  
Catch
  FMain.ErrorText
  
End

Public Sub SelectQuote()
  
  Dim sKey As String
  
  If ColumnView1.Selection.Max > -1 Then 
    sKey = ColumnView1.Selection.First
    If ColumnView1.Exist(sKey) = True Then 
      F_sQuoteDateText = ColumnView1[sKey].Text 
      F_iQuotePointer = CInteger(sKey) - 1 'Header=0
      PaintQuote()
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Function FileDialogPathReturn(Optional sDirFile As String = "", Optional sOpenSave As String = "open", Optional sStandardPath As String = "") As String 
  
  Dim formDialog As New Form22DialogOpenSave 'see left in this Project, exist Form
  
  If Not sDirFile Then sDirFile = FilePathForm()
  If Not sStandardPath Then sStandardPath = FilePathForm()
  ' sDirFile = M01Functions.FileDialogPathReturn(sDirFile) 'Classic
  formDialog.F_sOpenOrSave = sOpenSave
  formDialog.F_sDirFileMuster = sStandardPath
  formDialog.F_sDirFileInput = sDirFile 
  ' sDirFile = formDialog(sDirFile)
  
  Return formDialog(sDirFile) 'Send to Form (Dialog) and return Value. Null is canceled.
  
Catch 'if Error (Moegliche Fehler abfangen)
  FMain.ErrorText
  
End

Public Sub SaveG()
  
  Dim sPathBefore, sDirFile, sDir, sFile, sJPGQuality As String
  Dim ssFilter As String[]
  
  CheckZoomPhotoOptimal(False)
  
  F_sSaveFormat = Settings[Form15Foto.Name &/ "F_sSaveFormat", "png"]
  F_iSaveQualityJPG = Settings[Form15Foto.Name &/ "F_iSaveQualityJPG", F_iSaveQualityJPG]
  If F_sSaveFormat = "jpg" Then sJPGQuality = Space(1) & ("Komprimierung=") & F_iSaveQualityJPG & "%"
  
  ''Directory:
  sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  
  ''New Name:
  sFile = ("BildschirmFoto") & Format(Now, "yyyy-mm-dd-ddd-hh-nn-ss") & "." & F_sSaveFormat
  sDirFile = sDir &/ sFile '"Bildschirmfoto~.tmp.png"
  sPathBefore = Settings[FMain.Name &/ "sPathFoto", sDirFile]
  
  'Dialog DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  ssFilter = New String[]
  
  ssFilter.Add("*" & "." & F_sSaveFormat) '"" Null > Error
  ssFilter.Add(("Neue Speicherung") & Space(1) & ("mit Name+Uhrzeit") & sJPGQuality) 'Text
  
  ssFilter.Add("*" & File.Name(sPathBefore)) 'Filter
  ssFilter.Add(("letzte Speicherung")) 'Text
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Heute") & Space(1) & Format(Now, "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Day, -1), "yyyy-mm-dd") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Gestern") & Space(1) & Format(DateAdd(Date, gb.Day, -1), "dddd"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Monat") & Space(1) & Format(Now, "mmmm"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(Now, "yyyy-mm-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(Now, "yyyy"))
  
  ssFilter.Add("*" & ("bildschirmfoto") & Format(DateAdd(Date, gb.Year, -1), "yyyy-") & "*" & "." & F_sSaveFormat) 'Filter
  ssFilter.Add(("Jahr") & Space(1) & Format(DateAdd(Date, gb.Year, -1), "yyyy"))
  
  ssFilter.Add("*.jpg;*.jpeg")
  ssFilter.Add(("Format JPG") & sJPGQuality)
  
  ssFilter.Add("*.gif")
  ssFilter.Add(("Format GIF"))
  
  ssFilter.Add("*.bmp")
  ssFilter.Add(("Format BMP"))
  
  ssFilter.Add("*.xpm")
  ssFilter.Add(("Format XPM"))
  
  ssFilter.Add("*.png") 'Filter
  ssFilter.Add(("Format PNG")) 'Text
  'Dialog.Filter = ["*.png", ("Format PNG"), "*.jpeg", "Format JPG", "*.bmp", "Bitmap BMP", "*.gif", "Format GIF", "*.xpm", "Format XPM", "All files(*.*)"]
  Dialog.Filter = ssFilter '(*), All files wird autom. angehängt
  Dialog.Path = sDir &/ File.BaseName(sFile)
  Dialog.Title = (("Bild speichern..."))
  Dialog.AutoExt = True ''needs component: gb.form.dialog ' Datei.xyz xyz-Ext, extension automatically
  If Dialog.SaveFile() = True Then  'Returns True If the user clicked On the Cancel button, And False If the user clicked On the OK button.
    Return ' User pressed Cancel -
  Else 'Gibt Datei-Name zurück
    '=False, nicht abgebrochen
  Endif
  'nicht abgebrochen,  speichern siehe unten  .Picture.Save
  sDirFile = Dialog.Path
  'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  
  '*************************************************
  PicBoxCutAreaOrig.Picture = PicBoxCutPreview.Picture '*Quote-Text
  '*************************************************
  
  If IsDir(File.Dir(sDirFile)) = True And PicBoxCutAreaOrig.Picture Then 'without *Quote-Text
    If LCase(File.Ext(sDirFile)) = "jpg" Then
      PicBoxCutAreaOrig.Picture.Save(sDirFile, F_iSaveQualityJPG) 'only jpg
    Else
      PicBoxCutAreaOrig.Picture.Save(sDirFile)
    Endif
    If Exist(sDirFile) = False Then
      Message.Info(("Fehler. Datei nicht gespeichert"))
    Else
      Settings[FMain.Name &/ "sPathFoto"] = sDirFile '/sDir/File.xyz
      'Kontrollbild ---------------------
      InfoControlPicture(sDirFile)
      'Kontrollbild ---------------------
      LabelPictureSavedPath.Text = "<font color=gray>" & sDirFile & "</font>"
    Endif
  Endif 
  Form15Foto.Window.Raise
  
  ButtonM2Save.Background = Color.Green
  F_iSecondCounter = 0 ' Wait 1 'sichtbarer Ablauf
  ' ButtonM2Save.Background = Color.Default
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub LabelK1htmlCursor()
  
  LabelFileSavedhtml.Cursor = New Cursor(Picture["images/sizeall_64.png"], 32, 32)
  LabelFileSavedhtml.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub InfoControlPicture(Optional sDirFile As String = "")
  
  Dim sJPGQuality, sSize, sToolScreenshot, sFormWindowSystem As String
  Dim img As Image 
  
  sFormWindowSystem = "<font color=gray>" & ("Fenster-System") & ": " & Desktop.Platform & "</font>"
  sToolScreenshot = FMain.F_sScreenshotToolPath
  If Not sToolScreenshot Then sToolScreenshot = ("leer") 
  sToolScreenshot = ("Letzte Bildschirmfotos mit") & ": " & sToolScreenshot
  
  If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "sPathFoto", Null] '/sDir/File.xyz
  ImageView1.Image = Null 'Picture[""] 'entleeren
  
  If Exist(sDirFile) = True Then 
    If String.LCase(File.Ext(sDirFile)) = "jpg" Then 
      sJPGQuality = Space(1) & ("Komprimierung=") & Settings[FMain.Name &/ "F_iSaveQualityJPG", F_iSaveQualityJPG] & "%"
    Endif 
    img = Image.Load(sDirFile)
    If Not img Then img = Picture["images/question-red_32.png"].Image
    ' ImageView1.Image = img
    ImageView1.Update(img)'Gambas3: "Update the view with a new image without resetting the zoom."
    ImageView1.Zoom = ImageView1.H / ImageView1.Image.Height 
    ' ImageView1.ZoomFit()
    sSize = File.FormatSize(Stat(sDirFile).Size, False) 'KiB (*1)
    LabelFileSavedhtml.Text = File.Dir(sDirFile) & "/" & "<font color=darkgreen><b>" & File.Name(sDirFile) & "</b></font><br>" 
    LabelFileSavedhtml.Text &= ("Breite x Höhe") & ": " & Space(1) & ImageView1.Image.Width & " x " & ImageView1.Image.Height & Space(1) & ("px (Pixel)") & "<br>" 
    LabelFileSavedhtml.Text &= ("Größe") & ": " & Space(1) & sSize & sJPGQuality 
    LabelFileSavedhtml.Text &= Space(1) & "<font color=darkgreen><b>" & ("vor") & Space(1) & M01Functions.FileLastModifiedText(sDirFile) & Space(1) & "</b></font>" & sFormWindowSystem & "<br>"
  Else 
    ImageView1.Image = Null
    sSize = "0 Bytes" 'KiB (*1)
    LabelFileSavedhtml.Text = "<font color=blue><b>" & ("Leer. Auf 'Foto' drücken und 'Speichern'.") & "</b></font><br>" 
    LabelFileSavedhtml.Text &= ("Breite x Höhe") & ": " & Space(1) & "0 x 0" & Space(1) & ("px (Pixel)") & "<br>" 
    LabelFileSavedhtml.Text &= ("Größe") & ": " & Space(1) & sSize & sJPGQuality & Space(1) & sFormWindowSystem & "<br>"
  Endif 
  LabelFileSavedhtml.Text &= "<font color=gray>" & sToolScreenshot & "</font>"
  
  LabelFileSavedhtml.ToolTip = LabelFileSavedhtml.Text
  PanelFileSaved.Visible = True
  PanelFileSaved.Raise 'oberste Ebene
  
  ''_________________________________________________________________________________''
  '(*1) .FormatSize() needs component gb.util   False="KB" (1024), True="KiB" (1000)
  
Catch 
  FMain.ErrorText
  
End

Public Sub SpeichernGruppe_Click()
  
  F_iSaveFormatIndex = Last.Tag
  Settings[Form15Foto.Name &/ "F_iSaveFormatIndex"] = F_iSaveFormatIndex
  SaveMenuSelected(F_iSaveFormatIndex)
  SaveG()
  
Catch 
  FMain.ErrorText
  
End

Public Sub KopierenGruppe_Click()
  
  F_iCopyScaleIndex = Last.Tag
  Settings[Form15Foto.Name &/ "F_iCopyScaleIndex"] = F_iCopyScaleIndex
  CopyMenuSelected(F_iCopyScaleIndex)
  Select Case F_iCopyScaleIndex
    Case 9
      ButtonGroupSelect(PicBoxM7ZoomLupe.Tag)
    Case Else 
      CopyButtonG()
  End Select
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub PictureDirectoryOpenG()
  
  Dim sPathFoto, sDir As String
  
  sPathFoto = Settings[FMain.Name &/ "sPathFoto", ""]
  sDir = File.Dir(sPathFoto)
  If Exist(sDir) = False Then sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
  
  If Exist(sPathFoto) = True Then sDir = sPathFoto
  If System.Find("nautilus") Then 
    M01Functions.FileManagerOpen(sDir)
  Else 
    Desktop.Open(sDir)
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub mnuPapierkorb_Click()
  
  Dim bExist As Boolean
  
  bExist = M01Functions.ExternTrash()
  If bExist = False Then mnuPapierkorb.Text = mnuPapierkorb.Text & Space(2) & ("Fehlt")
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelFileSavedhtml_MouseDown()
  
  F_bMovingON = True
  F_fX1 = Form15Foto.ScreenX + Mouse.X
  F_fY1 = Form15Foto.ScreenY + Mouse.Y
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelFileSavedhtml_DblClick()
  
  PanelFileSaved.Move(PanelGlass.Left, PanelGlass.Top)
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelFileSavedhtml_MouseMove() ' move control-window with saved picture (Kontrollfenster bewegen, mit gespeichertem Bild)
  
  If F_bMovingON = True Then
    PanelFileSaved.Move(Mouse.ScreenX - F_fX1, Mouse.ScreenY - F_fY1)
    'kleinen Rand (Labelhöhe) im sichtbaren Bereich lassen, um auch danach verschieben zu können
    If PanelFileSaved.Left < PanelGlass.Left - PanelFileSaved.W + LabelFileSavedhtml.H Then PanelFileSaved.Left = PanelGlass.Left - PanelFileSaved.W + LabelFileSavedhtml.H
    If PanelFileSaved.Top < PanelGlass.Top - LabelFileSavedhtml.H Then PanelFileSaved.Top = PanelGlass.Top - LabelFileSavedhtml.H
    If PanelFileSaved.Left > PanelGlass.Left + PanelGlass.Width - LabelFileSavedhtml.H Then PanelFileSaved.Left = PanelGlass.Left + PanelGlass.Width - LabelFileSavedhtml.H
    If PanelFileSaved.Top > PanelGlass.Top + PanelGlass.Height - LabelFileSavedhtml.H Then PanelFileSaved.Top = PanelGlass.Top + PanelGlass.Height - LabelFileSavedhtml.H
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelFileSavedhtml_MouseUp()
  
  F_bMovingON = False
  
End

Public Sub LabelCutArea_DblClick()
  
  If LabelCutArea.Background = Color.Default Then
    '...
  Else 
    If PicBoxGrid.Visible = True Then GridMagnetic()
    If F_bCrossLineON = True Then CrossLinesMove()
    LabelCutArea.Background = F_iColorGreen220
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutArea_MouseDown()

  If Not F_ooUndoRedoCutArea Then UndoRedoCutArea()
  
  If Mouse.Middle = True And LabelCutArea.Visible = True Then LabelCutArea.Visible = False 
  
  If ButtonM4Full.Foreground <> Color.Default Then 
    ButtonM4FullG() 'Full false (Vollbild ausschalten)
  Else
    LabelCutArea.Border = Border.Plain
    F_bAreaMoveON = True

    F_fX1 = Form15Foto.ScreenX + PanelGlass.Left + Mouse.X 
    F_fY1 = Form15Foto.ScreenY + PanelGlass.Top + Mouse.Y
    
    If Mouse.X < LabelCutArea.W * 0.15 Or Mouse.X > LabelCutArea.W * 0.85 Then 
      F_sMovePointsCutArea = "movehorizontal"
    Else If Mouse.Y < LabelCutArea.H * 0.15 Or Mouse.Y > LabelCutArea.H * 0.85 Then
      F_sMovePointsCutArea = "movevertical"
    Else
      F_sMovePointsCutArea = "move" 
    Endif 
    CornerPointsPicture(F_sMovePointsCutArea)
    ' CornerPointsToLabelCutAreaONoff(False)
    If PicBoxGrid.Visible = True Then GridMagnetic()
    If F_bCrossLineON = True Then CrossLinesMove()
    If F_bFormResizeChanged = True Then CreateRulersG(F_sRulersCMorCMRELorPIXEL)
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutArea_MouseMove()
  Dim fFixLine, fMoveLine As Float
  
  If F_bAreaMoveON = True Then
    Select Case F_sMovePointsCutArea
      Case "move"
        LabelCutArea.Move(Mouse.ScreenX - F_fX1, Mouse.ScreenY - F_fY1)
      Case "movehorizontal"   'Left-Right ◁—▶
        LabelCutArea.Left = Mouse.ScreenX - F_fX1
      Case "movevertical"   'Top-Bottom △▼
        LabelCutArea.Top = Mouse.ScreenY - F_fY1
      Case "movelinetop"
        fMoveLine = Mouse.ScreenY - F_fY1
        fFixLine = LabelCutArea.Top + LabelCutArea.H
        LabelCutArea.Move(LabelCutArea.Left, fMoveLine, LabelCutArea.W, fFixLine - fMoveLine)
      
    End Select
    If PicBoxGrid.Visible = True Then GridMagnetic()
    If F_bCrossLineON = True Then CrossLinesMove()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutArea_MouseUp() '+___+

  LabelCutArea.Background = Color.Default
  LabelCutArea.Border = Border.None
  F_bAreaMoveON = False
  LabelCutAreaCheckMax()
  CornerPointsToLabelCutAreaONoff(True)
  If PicBoxPhoto.Picture = Null Then PhotoScreen()
  ' PhotoCutArea()
  ' CopyButtonG()  'CutArea > Clipboard
  PhotoCutArea()'LabelPixelWxHScalePicture()' CopyButtonG()  'CutArea > Clipboard
  ' ButtonGroupSelect(ButtonM8Copy.Tag)
  If Mouse.Right Then LabelCutArea.Visible = Not LabelCutArea.Visible
  If F_bZoomLupeON = True Then ButtonGroupSelect(PicBoxM7ZoomLupe.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub LabelCutArea_Enter()
  
  LabelCutArea.Background = F_iColorGreen220 '.Border=Plain no Transparent? 
  
End

Public Sub LabelCutArea_Leave()
  ' LabelCutArea.Background = Color.Default
  
End

Public Sub WindowStretch_DblClick()
  
  Form15Foto.Window.Maximized = Not Form15Foto.Window.Maximized 
  If Form15Foto.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseDown()
  
  If Mouse.Left = True Then 
    If Form15Foto.Window.FullScreen = True Or Form15Foto.Window.Maximized = True Then 
      F_bMovingON = False
      Form15Foto.Window.FullScreen = False
      Form15Foto.Window.Maximized = False
      If Form15Foto.Left + Form15Foto.W > Screen.AvailableWidth Then Form15Foto.Move(Form15Foto.Left, Form15Foto.Top, Screen.AvailableWidth - Form15Foto.Left, Screen.AvailableHeight - Form15Foto.Top)
    Else
      F_bMovingON = True
      Form15Foto.Window.FullScreen = False
      Form15Foto.Window.Maximized = False
      WindowStretch.Background = Color.Green
      F_fX1 = Form15Foto.ScreenX + Mouse.X - WindowStretch.W 
      F_fY1 = Form15Foto.ScreenY + Mouse.Y - WindowStretch.H 
      WindowStretch.Move(Form15Foto.ClientW - WindowStretch.W, Form15Foto.ClientH - WindowStretch.H)
    Endif
  Endif
  If Mouse.Right Then Form15Foto.Window.Maximized = True
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseMove()
  
  If F_bMovingON = True Then                                                                   '=> move it
    Form15Foto.W = Mouse.ScreenX - F_fX1
    Form15Foto.H = Mouse.ScreenY - F_fY1
    WindowStretch.Move(Form15Foto.ClientW - WindowStretch.W, Form15Foto.ClientH - WindowStretch.H)
    WindowStretch.Raise
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_MouseUp()
  
  F_bMovingON = False 
  WindowStretch.Move(Form15Foto.ClientW - WindowStretch.W, Form15Foto.ClientH - WindowStretch.H)
  If Mouse.Middle Then 
    Form15Foto.Window.Maximized = Not Form15Foto.Window.Maximized 
    If Form15Foto.Window.Maximized = True Then WindowStretch.Background = Color.DarkGray
  Endif
  Form_Resize
  
Catch 
  FMain.ErrorText
  
End

Public Sub WindowStretch_Enter()                                                          'Cursor inside
  
  WindowStretch.Background = Color.Green
  
End 

Public Sub WindowStretch_Leave()                                                          'Cursor outside
  
  WindowStretch.Background = Color.Default
  If Form15Foto.Window.Maximized Then WindowStretch.Background = Color.DarkGray
  
Catch 
  FMain.ErrorText
  
End 

Public Sub WindowStretchCursor()
  
  WindowStretch.Cursor = New Cursor(Picture["images/stretch-rd-blue_32.png"], 0, 0)
  WindowStretch.Mouse = Mouse.Custom
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBackground_MouseDown()
  
  If Mouse.Right Then MenuSystemMore.Popup(Mouse.X, 0)
  
Catch 
  FMain.ErrorText
  
End

Public Sub PhotoLatestG()
  
  Dim sDirFile, sDir, sFile As String 
  
  ''Exist?
  If Not PicBoxPhotoLatest.Picture Then 
    sDir = Settings[FMain.Name &/ "F_sDirTerminweckerCurrent", FMain.F_sDirTerminweckerCurrent]
    sFile = "photolatest.png"
    sDirFile = sDir &/ sFile
    If Exist(sDirFile) = False Then sDirFile = Settings[FMain.Name &/ "sPathFoto", Null] '/sDir/File.xyz
    If Exist(sDirFile) = True Then PicBoxPhotoLatest.Picture = Picture.Load(sDirFile)
    If Not PicBoxPhotoLatest.Picture Then PicBoxPhotoLatest.Picture = PicTemplateQuestion256.Picture
  Endif 
  
  ''Show
  If PicBoxPhotoLatest.Picture Then 
    PicBoxPhoto.Picture = PicBoxPhotoLatest.Picture.Copy()
    If Not F_ooUndoRedoPhoto Then 
      PictureFotoAddUndoSelect(PicBoxPhotoLatest.Picture.Image)
    Else 
      If PicBoxPhoto.Picture <> PicBoxPhotoLatest.Picture Then 
        If F_ooUndoRedoPhoto.Find(PicBoxPhotoLatest.Picture.Image) = -1 Then PictureFotoAddUndoSelect(PicBoxPhotoLatest.Picture.Image)
      Endif 
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoCutArea()
  
  Dim hRect As Rect
  Dim bUndo As Boolean
     
  hRect = New Rect(LabelCutArea.Left, LabelCutArea.Top, LabelCutArea.W, LabelCutArea.H)
  
  If Not F_ooUndoRedoCutArea Then 
    F_ooUndoRedoCutArea = New Object[]
    hRect = New Rect
    hRect = Rect(PanelGlass.W / 3, PanelGlass.H / 3, PanelGlass.W / 3, PanelGlass.H / 3) 
    F_ooUndoRedoCutArea.Add(hRect)
    hRect = Rect(LabelCutArea.X, LabelCutArea.Y, LabelCutArea.W, LabelCutArea.H) 
    ' F_rectCutAreaUndo = Rect(hRect)
  Endif  
  
  If F_rectCutAreaUndo Then 
    If hRect.X = F_rectCutAreaUndo.X And hRect.Y = F_rectCutAreaUndo.Y And hRect.W = F_rectCutAreaUndo.W And hRect.H = F_rectCutAreaUndo.H Then bUndo = False Else bUndo = True 
  Else 
    hRect = New Rect(PanelGlass.W / 3, PanelGlass.H / 3, PanelGlass.W / 3, PanelGlass.H / 3) 
    bUndo = True 
  Endif 
  
  If bUndo = True Then 
    If Not F_ooUndoRedoCutArea Then F_ooUndoRedoCutArea = New Object[]
    F_ooUndoRedoCutArea.Add(hRect) 
    ListBackupCounter2.Text = F_ooUndoRedoCutArea.Count & Space(1) & ("von") & Space(1) & F_ooUndoRedoCutArea.Count
    ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Ausschnitt-Bereiche")
    F_iUndoRedoCutAreaPointer = F_ooUndoRedoCutArea.Max
  Endif 
  F_rectCutAreaUndo = New Rect(hRect.X, hRect.Y, hRect.W, hRect.H)
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoCutAreaRectangleAdd(Optional hRect As Rect = Null)'xxx???
  
  If Not F_ooUndoRedoCutArea Then 
    F_ooUndoRedoCutArea = New Object[]
    hRect = New Rect
    hRect = Rect(PanelGlass.W / 3, PanelGlass.H / 3, PanelGlass.W / 3, PanelGlass.H / 3) 
    F_ooUndoRedoCutArea.Add(hRect)
    hRect = Rect(LabelCutArea.X, LabelCutArea.Y, LabelCutArea.W, LabelCutArea.H) 
  Endif  
  
  If hRect Then 
    ' If Not F_ooUndoRedoCutArea Then F_ooUndoRedoCutArea = New Object[]
    F_ooUndoRedoCutArea.Add(hRect) '(hRect, 1)

    F_iUndoRedoCutAreaPointer = F_ooUndoRedoCutArea.Max
    
    ListBackupCounter2.Text = Str(F_iUndoRedoCutAreaPointer + 1) & Space(1) & ("von") & Space(1) & Str(F_ooUndoRedoCutArea.Max + 1)
    ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Ausschnitt-Bereiche")
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoCutAreaPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim hRect As Rect 
  
  If Not F_ooUndoRedoCutArea Then 
    F_ooUndoRedoCutArea = New Object[]
    hRect = New Rect
    hRect = Rect(PanelGlass.W / 3, PanelGlass.H / 3, PanelGlass.W / 3, PanelGlass.H / 3) 
    F_ooUndoRedoCutArea.Add(hRect)
    hRect = Rect(LabelCutArea.X, LabelCutArea.Y, LabelCutArea.W, LabelCutArea.H) 
  Endif 
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoCutAreaPointer = F_iUndoRedoCutAreaPointer - 1
      
    Case "r", "redo"
      F_iUndoRedoCutAreaPointer = F_iUndoRedoCutAreaPointer + 1
      
    Case "m", "max"
      F_iUndoRedoCutAreaPointer = F_ooUndoRedoCutArea.Max
      
    Case "s", "select"
      F_iUndoRedoCutAreaPointer = F_iUndoRedoCutAreaPointer
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoCutAreaPointer < -1 Then F_iUndoRedoCutAreaPointer = -1
  If F_iUndoRedoCutAreaPointer > F_ooUndoRedoCutArea.Max Then F_iUndoRedoCutAreaPointer = F_ooUndoRedoCutArea.Max
  
  If F_iUndoRedoCutAreaPointer > -1 Then 
    hRect = F_ooUndoRedoCutArea[F_iUndoRedoCutAreaPointer]
  Endif 
  
  If hRect Then 
    LabelCutArea.Move(hRect.Left, hRect.Top, hRect.W, hRect.H)
    ' PhotoCutArea()
    LabelCutAreaCheckMax()
    If F_iUndoRedoCutAreaPointer < 1 Then 
      LabelCutArea.Background = Color.Transparent
    Else 
      LabelCutArea.Background = F_iColorGreen220  
    Endif 
    LabelCutArea.Border = Border.Plain
    CornerPointsToLabelCutAreaONoff(True)
  Endif 
  
  JumpLabel:
  ListBackupCounter2.Text = Str(F_iUndoRedoCutAreaPointer + 1) & Space(1) & ("von") & Space(1) & Str(F_ooUndoRedoCutArea.Max + 1)
  ListBackupCounter2.Tooltip = ListBackupCounter2.Text & Space(1) & ("Ausschnitt-Bereiche")
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotoImageAdd(Optional Img As Image = Null)
  
  If Img Then 
    If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
    F_ooUndoRedoPhoto.Add(Img) '(Img, 1)
    ListBackupCounter1.Text = F_ooUndoRedoPhoto.Count & Space(1) & ("von") & Space(1) & F_ooUndoRedoPhoto.Count
    ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
    F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub UndoRedoPhotosPointer(Optional sUndoRedoMax As String = "undo")
  
  Dim Img As Image
  
  If Not F_ooUndoRedoPhoto Then F_ooUndoRedoPhoto = New Object[]
  
  Select Case String.LCase(String.Left(sUndoRedoMax, 1))
      
    Case "u", "undo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer - 1
      
    Case "r", "redo"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer + 1
      
    Case "m", "max"
      F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      
    Case "s", "select"
      F_iUndoRedoPhotosPointer = F_iUndoRedoPhotosPointer
  End Select
  
  ''Check Min-Max
  If F_iUndoRedoPhotosPointer < 0 Then F_iUndoRedoPhotosPointer = -1
  If F_iUndoRedoPhotosPointer > F_ooUndoRedoPhoto.Max Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
  
  If F_iUndoRedoPhotosPointer > -1 Then 
    Img = F_ooUndoRedoPhoto[F_iUndoRedoPhotosPointer] 'Object Image
    PicBoxPhoto.Picture = Img.Picture
  Else 
    PicBoxPhoto.Picture = Null
  Endif 
  
  If PicBoxPhoto.Picture Then 
    ImageViewPhoto.Update(Img) 
  Else 
    ImageViewPhoto.Update(PicTemplateQuestion256.Picture.Image.Stretch(Screen.W, Screen.H))
  Endif 
  
  PicBoxZoomLupe.Picture = PicBoxPhoto.Picture
  
  ListBackupCounter1.Text = Str(F_iUndoRedoPhotosPointer + 1) & Space(1) & ("von") & Space(1) & Str(F_ooUndoRedoPhoto.Max + 1)
  ListBackupCounter1.Tooltip = ListBackupCounter1.Text & Space(1) & ("Fotos")
  
Catch 
  FMain.ErrorText
  
End

Public Sub ClipboardImagePaste()
  
  Dim Img As Image
  Dim sPathScreenshot, sMessage As String
  
  'If Clipboard.Type = Clipboard.Image Then 'check, '0=empty, 1=Text, 2=Image, Clipboard.Text for some text, Clipboard.Image for an image.

  If Not Img Then Img = M01Functions.ClipboardImage()  'as Image
  sPathScreenshot = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG]
  If IsDir(File.Dir(sPathScreenshot)) = False Then M01Functions.CheckDirAppName(File.Dir(sPathScreenshot), False)
  If IsDir(File.Dir(sPathScreenshot)) = True And Img Then Img.Save(sPathScreenshot)
  If Not Img And Exist(sPathScreenshot) = True Then Img = Image.Load(F_sPathScreenphotoPNG)
  
  If Img Then 
    PicBoxPhoto.Picture = Img.Picture
    UndoRedoPhotoImageAdd(Img)
    CornerPointsToLabelCutAreaONoff(True)
    PhotoCutArea()
  Else 
    sMessage = "<h3><font color=red>" & ("Ohne Bild") & "</font></h3>"
    sMessage &= "<h3><font color=gray>" & ("Die [Zwischenablage] ist (noch) leer.") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub CutAreaInternalPicturePaste()
  
  Dim Img As Image
  Dim sPathScreenshot, sMessage As String
  
  'If Clipboard.Type = Clipboard.Image Then 'check, '0=empty, 1=Text, 2=Image, Clipboard.Text for some text, Clipboard.Image for an image.
  If PicBoxCutPreview.Picture Then Img = PicBoxCutPreview.Picture.Image
  ' If Not Img Then Img = M01Functions.ClipboardImage()  'as Image
  sPathScreenshot = Settings[FMain.Name &/ "F_sPathScreenphotoPNG", FMain.F_sPathScreenphotoPNG]
  If IsDir(File.Dir(sPathScreenshot)) = False Then M01Functions.CheckDirAppName(File.Dir(sPathScreenshot), False)
  If IsDir(File.Dir(sPathScreenshot)) = True And Img Then Img.Save(sPathScreenshot)
  If Not Img And Exist(sPathScreenshot) = True Then Img = Image.Load(F_sPathScreenphotoPNG)
  
  If Img Then 
    PicBoxPhoto.Picture = Img.Picture
    UndoRedoPhotoImageAdd(Img)
    CornerPointsToLabelCutAreaONoff(True)
    PhotoCutArea()
  Else 
    sMessage = "<h3><font color=red>" & ("Ohne Bild") & "</font></h3>"
    sMessage &= "<h3><font color=gray>" & ("[Ausschnitt] ist (noch) leer?") & "</font></h3>"
    Message.Info(sMessage, ("Abbrechen"))
  Endif
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise() '▲Top-Level▲
  
End

Public Sub PastePictureOpen()
  
  Dim sPathFoto, sFilter1, sFilterText1 As String 
  Dim sPath, sDir As String
  'Beispiel--------------------------
  'Dialog.Filter = ["*.txt", "Nur-Text"]
  'Dialog.Filter = ["*.mid;*.wav;*.ogg;*.mp3", ("Musik-Formate")]
  'Supported formats are JPEG, PNG, BMP, GIF and XPM. .Save(JPG-Datei, Qualität 1 bis 100)
  
  sPathFoto = Settings[FMain.Name &/ "sPathFoto", sPathFoto]
  If Exist(sPathFoto) = True Then 
    sFilter1 = "*" & String.Left(File.BaseName(sPathFoto), 10) & "*." & File.Ext(sPathFoto)
    sFilterText1 = ("letzte Speicherung")
  Endif 
  If Exist(sPathFoto) = False Then 
    sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
    sPathFoto = sDir &/ ("BildDatei.png")
    sFilter1 = "*.png;*.jpg;"
    sFilterText1 = ("Bilder")
  Endif
  sPath = M01Functions.FileDialogOpen(sPathFoto, [sFilter1, sFilterText1, "*.jpeg;*.jpg;*.png;*.bmp;*.xpm;*.svg;", ("Bilder")], ("Einfügen aus Bild-Datei..."))
  If Exist(sPath) = True Then 'Null is Canceled
    PicBoxPhoto.Picture = Picture.Load(sPath)
    If PicBoxPhoto.Picture Then UndoRedoPhotoImageAdd(PicBoxPhoto.Picture.Image)
    PhotoCutArea()
  Endif
  
Catch 
  FMain.ErrorText
  
End

Public Sub PicBoxZoomLupe_MouseDown()
  
  CheckZoomLupeCursor(False) 'Off
  
Catch 
  FMain.ErrorText
  
End

Public Sub PanelColorZoom_MouseDown()
  
  PicBoxZoomLupe_MouseDown()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CrossLineGroup_MouseDown()
  
  If Object.Type(Last) = "PictureBox" Then 
    If Mouse.Right = True Then Menu2.Popup()
    If Mouse.Middle = True Then 
      PicBoxRulerHorizontal.Visible = False 'short temporär
      PicBoxRulerVertical.Visible = False
    Endif
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub CrossLineGroup_Click() 'Menu
  
  Select Case Last.Tag
      
    Case "rulers", MenuRulersONoff.Tag 'On/Off
      F_bRulesON = Not F_bRulesON
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      CheckRulersG()
      ' CreateRulersG(F_sRulersCMorCMRELorPIXEL)
    Case "cm", MenuRulersCentimeter.Tag
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_sRulersCMorCMRELorPIXEL = Last.Tag
      Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL"] = F_sRulersCMorCMRELorPIXEL
      CreateRulersG(F_sRulersCMorCMRELorPIXEL)
      
    Case "cmrelative", MenuRulersCMRelative.Tag
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_sRulersCMorCMRELorPIXEL = Last.Tag
      Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL"] = F_sRulersCMorCMRELorPIXEL
      CreateRulersG(F_sRulersCMorCMRELorPIXEL)
      
    Case "pixel", MenuRulersPixel.Tag
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_sRulersCMorCMRELorPIXEL = Last.Tag
      Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL"] = F_sRulersCMorCMRELorPIXEL
      CreateRulersG(F_sRulersCMorCMRELorPIXEL)
      
      ''............................................................
      
    Case "transparent", MenuRulersTransparent.Tag 'Glas, Transparent
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_iRulersColorBG = 0
      Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      CreateRulersG()
      
    Case "yellow", MenuRulersYellow.Tag 'Glas, Transparent
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_iRulersColorBG = 1
      Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      CreateRulersG()
      
    Case "wood", MenuRulersWood.Tag 'Holz
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_iRulersColorBG = 2
      Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      CreateRulersG()
      
    Case "metal", MenuRulersMetal.Tag 'Aluminium
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_iRulersColorBG = 3
      Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      CreateRulersG()
      
    Case "gray", MenuRulersGray.Tag 'Grau
      F_bRulesON = True 
      Settings[F_sForm &/ "F_bRulesON"] = F_bRulesON
      F_iRulersColorBG = 4
      Settings[F_sForm &/ "F_iRulersColorBG"] = F_iRulersColorBG
      CreateRulersG()
      
    Case "openruler"
      SaveRulerPicture()
      
    Case Else 
      ButtonGroupSelect(Last.Tag)
      
  End Select
  LabelPixelWxHScalePicture()
  
Catch 
  FMain.ErrorText
  
End

Public Sub CreateRulersG(Optional sRulersCMorCMRELorPIXEL As String = "pixel")
  
  Dim n, it, iW, iH As Integer
  Dim U, itF, fLeft, fTop, fWidth, fHeight As Float
  Dim iColorScale, iLong, iMiddle, iShort, iTop, iNumber, iColor As Integer
  Dim pointFUnit As PointF ' Float (x,Y)
  Dim imgHorizontalBG, imgVerticalBG, imgRuler As Image 
  Dim sScale, sPath As String 'sScale cm, Pixel...
  Dim imgRulesBG As Image
  
  F_sRulersCMorCMRELorPIXEL = sRulersCMorCMRELorPIXEL
  If Not F_sRulersCMorCMRELorPIXEL Then F_sRulersCMorCMRELorPIXEL = Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL", F_sRulersCMorCMRELorPIXEL]
  
  ' If Not sLastTag Then sLastTag = Settings[F_sForm &/ "F_sRulersBG", sLastTag]
  
  ' F_bRulesON = True 
  iColorScale = Color.DarkGray
  fLeft = 0
  fTop = 0
  fWidth = Screen.W
  fHeight = Eckpunkt1.H
  iTop = 0'Eckpunkt1.H * 0.1
  iLong = Eckpunkt1.H * 0.5
  iMiddle = Eckpunkt1.H * 0.4
  iShort = Eckpunkt1.H * 0.3
  
  F_iRulersColorBG = Settings[F_sForm &/ "F_iRulersColorBG", 0]
  
  Select Case F_iRulersColorBG
    Case 0
      iColor = Color.Transparent
      imgRulesBG = New Image(PicBackground.W, PicBackground.H, iColor)
      
    Case 1
      iColor = Color.Yellow
      imgRulesBG = New Image(PicBackground.W, PicBackground.H, iColor)
      
    Case 2
      iColor = Color.Transparent
      sPath = "images/bg_holz2.png"
      If Exist(sPath) = True Then imgRulesBG = Image.Load(sPath)
      
    Case 3
      iColor = Color.Transparent
      sPath = "images/bg_aluminium1.png"
      If Exist(sPath) = True Then imgRulesBG = Image.Load(sPath)
      
    Case 4
      iColor = Color.SetAlpha(Color.LightGray, 150)
      imgRulesBG = New Image(PicBackground.W, PicBackground.H, iColor)
      
    Case Else 
      iColor = Color.Transparent
      imgRulesBG = New Image(PicBackground.W, PicBackground.H, iColor)
      
  End Select
  
  If imgRulesBG Then 
    iW = imgRulesBG.W / 4
    iH = imgRulesBG.H / 4
    imgHorizontalBG = imgRulesBG.Copy(iW, iH, iW * 2, iH * 2)
    imgHorizontalBG = imgHorizontalBG.Stretch(PicBoxPhoto.W, Eckpunkt1.H)
    imgVerticalBG = imgHorizontalBG.Stretch(PicBoxPhoto.H, Eckpunkt1.H) 'rotate later
    ' imgHorizontalBG = imgHorizontalBG.Opacity(0.35) '0-1, 0=Transparent
    ' imgVerticalBG = imgVerticalBG.Opacity(0.35)
  Endif
  PicBoxRulerHorizontal.Background = Color.Transparent
  PicBoxRulerVertical.Background = Color.Transparent
  
  ''Scale, Unit for Ruler |....,....| (Einheit fuer Lineal)
  pointFUnit = ScaleUnitpointF(F_sRulersCMorCMRELorPIXEL) 'as PointF
  sScale = F_sScaleUnitText
  
  ''line length rule |....,....|
  ' PicBoxRulerHorizontal.Stretch = False 
  ' PicBoxRulerVertical.Stretch = False 
  
  For it = 0 To 1 '=2x   1xHorizontal + 1xVertical
    If it = 0 Then 
      imgRuler = imgHorizontalBG 
      U = pointFUnit.X
    Else 
      imgRuler = imgVerticalBG
      U = pointFUnit.Y
    Endif 
    If U < 1 Then U = 1
    
    Paint.Begin(imgRuler)
    Paint.AntiAlias = True 
    Paint.LineCap = Paint.LineCapSquare  '■
    iNumber = 0
    n = 0
    For itF = 0 To imgRuler.W Step U
      If n = 0 Or n = 10 Then ''long line ——————
        Paint.MoveTo(itF, iTop)
        Paint.LineTo(itF, iLong)
        
        Paint.LineWidth = U * 0.2  
        Paint.Brush = Paint.Color(iColorScale)
        Paint.Stroke()
        
        Paint.Font.Size = fHeight * 0.25
        Paint.Font.Name = "Ubuntu" 'Default
        If sRulersCMorCMRELorPIXEL = "cm" Then '1:1 cm Raster, Grid
          If iNumber = 0 Then Paint.Text(sScale, itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
          If iNumber > 0 And iNumber Mod 2 = 0 Then Paint.Text(Str(iNumber), itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
        Else If sRulersCMorCMRELorPIXEL = "cmrel" Then 'cm relative
          If iNumber = 0 Then Paint.Text(sScale, itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
          If iNumber > 3 And iNumber Mod 2 = 0 Then Paint.Text(Str(iNumber), itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
        Else If sRulersCMorCMRELorPIXEL = "pixel" Then 'px Screen
          If iNumber = 0 Then Paint.Text(sScale, itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
          If iNumber > 0 And iNumber Mod 2 = 0 Then Paint.Text(Str(iNumber * 100), itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
        Else '"?:?" unknown
          If iNumber = 0 Then Paint.Text(sScale, itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
          If iNumber > 0 And iNumber Mod 2 = 0 Then Paint.Text(Str(iNumber * 100), itF, fHeight * 0.5, U * 10, fHeight * 0.5, Align.Left)
        Endif 
        Paint.Brush = Paint.Color(iColorScale)
        Paint.Fill()
        n = 0 'Reset
        iNumber = iNumber + 1
        
      Else If n = 5 Then ''middle line –———
        Paint.MoveTo(itF, iTop)
        Paint.LineTo(itF, iMiddle)
        Paint.LineWidth = U * 0.15
        Paint.Brush = Paint.Color(iColorScale)
        Paint.Stroke()
      Else
        Paint.MoveTo(itF, iTop) ''short line ——
        Paint.LineTo(itF, iShort)
        Paint.LineWidth = U * 0.1
        Paint.Brush = Paint.Color(iColorScale)
        Paint.Stroke()
      Endif
      n = n + 1
    Next
    Paint.End
    If it = 0 Then PicBoxRulerHorizontal.Picture = imgRuler.Picture
    If it = 1 Then PicBoxRulerVertical.Picture = imgRuler.RotateRight().Picture
  Next 
  PicBoxRulerHorizontal.Move(PanelGlass.Left, Eckpunkt4.Top, PanelGlass.W, Eckpunkt4.H)
  PicBoxRulerVertical.Move(Eckpunkt1.Left, PanelGlass.Top, Eckpunkt1.W, PanelGlass.H)
  PicBoxRulerHorizontal.Visible = F_bRulesON
  PicBoxRulerVertical.Visible = F_bRulesON
  
  PicBoxRulerHorizontal.Stretch = True  
  PicBoxRulerVertical.Stretch = True 
  ' If PicBoxRulerHorizontal.Picture Then PicBoxRulerHorizontal.Picture.Save(Settings[FMain.Name &/ "F_sDirCache", FMain.F_sDirCache] &/ "testrulerscreen_" & Screen.W & "x" & Screen.H & ".png") 
  ' Print F_sRulersCMorCMRELorPIXEL & gb.Tab & F_sScaleUnitText
  F_bFormResizeChanged = False 'Reset
  
Catch
  FMain.ErrorText
  
End

Public Function ScaleUnitpointF(Optional sRulersCMorCMRELorPIXEL As String = "pixel") As PointF
  
  Dim iMM As Integer
  Dim pointFScale, pointFUnit As PointF
  Dim fRelH, fRelV As Float
  Dim sScale As String 
  
  F_sRulersCMorCMRELorPIXEL = sRulersCMorCMRELorPIXEL
  If Not F_sRulersCMorCMRELorPIXEL Then F_sRulersCMorCMRELorPIXEL = Settings[F_sForm &/ "F_sRulersCMorCMRELorPIXEL", F_sRulersCMorCMRELorPIXEL]
  
  pointFUnit = New PointF
  
  Select Case F_sRulersCMorCMRELorPIXEL 
    Case "cm" 'Centimeter (cm)
      pointFScale = M01Functions.Unit1cm() 'as PointF Float
      ' pointFScale = M01Functions.Unit1cmNew() 'as PointF Float
      ' fCentimeter = Desktop.Resolution / 2.54           'Bildschirm-Auflösung in dpi (dots per inch, Punkte pro Zoll), 1 Zoll = 1 inch = 1'' = 2,54 cm
      ' iMM = fCentimeter / 10                          'Sub-ScaleUnit |''''!''''| cm   iMM = 1Millimeter (mm)
      iMM = Round(pointFScale.X / 10)
      If iMM * 10 > pointFScale.X Then iMM = iMM - 1 
      If iMM * 10 < pointFScale.X Then iMM = iMM + 1
      ' cm = iMM * 10  'Sub-ScaleUnit |''''!''''| cm
      pointFUnit.X = iMM 'Horizontal ◀——▷
      
      iMM = Round(pointFScale.Y / 10)
      If iMM * 10 > pointFScale.Y Then iMM = iMM - 1 
      If iMM * 10 < pointFScale.Y Then iMM = iMM + 1
      ' cm = iMM * 10  'Sub-ScaleUnit |''''!''''| cm
      pointFUnit.Y = iMM 'Vertical ▼△
      sScale = Space(1) & "cm"
      
    Case "cmrel" 'cm relative
      pointFScale = M01Functions.Unit1cm() 'as PointF Float 'Desktop.Resolution / 2.54         'Bildschirm-Auflösung in dpi (dots per inch, Punkte pro Zoll), 1 Zoll = 1 inch = 1'' = 2,54 cm
      fRelH = Screen.W / PicBoxPhoto.W
      pointFUnit.X = (pointFScale.X / fRelH) / 10
      ''Sub-ScaleUnit |''''!''''| cm  'Horizontal ◀——▷
      
      fRelV = Screen.H / PicBoxPhoto.H
      pointFUnit.Y = (pointFScale.Y / fRelV) / 10
      'Sub-ScaleUnit |''''!''''| cm 'Vertical ▼△
      
      sScale = Space(1) & ("cm relativ")
      
    Case "pixel" ''Pixel
      pointFScale = PointF(10, 10)
      fRelH = Screen.W / PicBoxPhoto.W
      fRelV = Screen.H / PicBoxPhoto.H
      pointFUnit.X = pointFScale.X / fRelH  'Horizontal ◀——▷
      pointFUnit.Y = pointFScale.Y / fRelV  'Vertical ▼△
      sScale = Space(1) & "Pixel"
      ' 100 px = fUnitH * 10  'Sub-ScaleUnit |''''!''''| px (Pixel)
      
    Case Else '"?:?" ''Pixel
      pointFScale = PointF(10, 10)
      fRelH = Screen.W / PicBoxPhoto.W
      fRelV = Screen.H / PicBoxPhoto.H
      pointFUnit.X = pointFScale.X / fRelH  'Horizontal ◀——▷
      pointFUnit.Y = pointFScale.Y / fRelV  'Vertical ▼△
      sScale = Space(1) & "?:?"
      ' 100 px = fUnitH * 10  'Sub-ScaleUnit |''''!''''| px (Pixel)
  End Select
  
  F_sScaleUnitText = sScale
  F_pointFUnit = pointFUnit 'as PointF, Float (x,y)
  
  Return pointFUnit
  
Catch
  FMain.ErrorText
  
End

Public Sub SaveRulerPicture() 
  
  Dim sPath, sFile, sSize, sPathCache1, sMessagePic, sMessage As String
  Dim hPicture As Picture
  Dim iW, iH As Integer
  Dim fRel As Float
  
  sFile = "temp_" & ("lineal") & "-" & Application.Name & ".png"
  sPath = M01Functions.ProgramDirCache(sFile) '/directory/file.png
  
  If PicBoxRulerHorizontal.Picture Then hPicture = PicBoxRulerHorizontal.Picture  '|....,....|
  
  If hPicture Then 
    sPathCache1 = M01Functions.TempDirFile("1.png") ' Temp() & ".png"
    If hPicture And IsDir(File.Dir(sPathCache1)) = True Then 
      hPicture.Save(sPathCache1)
      fRel = hPicture.W / hPicture.H
    Endif 
    If Exist(sPathCache1) = True Then 
      sMessagePic &= "<img src=" & Quote("file://" & sPathCache1) & " width=" & Round(fRel * 20) & " height=20 >" & Space(1) & ("Aktuelles Lineal") & Space(1)
    Endif 
    sMessage &= "<h3><font color=gray>" & sMessagePic & "</font></h3>"
    
    If Exist(sPathCache1) = False Then 
      sMessage = "<h3><font color=red>" & ("Fehlt") & "</font></h3>"
    Endif 
    iW = hPicture.W
    iH = hPicture.H
    If Exist(sPathCache1) = True Then sSize = M01Functions.FileSizeLongText(Stat(sPathCache1).Size) 
  Endif 
  
  sMessage &= "<h3><font color=darkgreen>" & ("Bild: Lineal") & Space(1) & "|....,....|" & "</font></h3>" 
  sMessage &= "<h4>" & File.Dir(sPath) &/ "<font color=darkgreen>" & File.Name(sPath) & "</font></h4>"
  sMessage &= "<h4><font color=gray>" & iW & " x " & iH & Space(1) & ("Pixel") & ", " & sSize & "</font></h4>"
  sMessage &= "<font color=gray>" & ("Hinweis: Die Maß-Einheiten auf den Linealen richten sich nach dem  Computer-Bildschirm und seiner individuellen Auflösungsdichte mit technischen Bildpunkten.") & "</font>" & "<br>"
  
  sMessage &= "<font color=gray>" 
  sMessage &= ("Bildschirm-Auflösung in dpi (dots per inch, Punkte pro Zoll), 1 Zoll = 1 inch = 1'' = 2,54 cm") & "<br>"
  sMessage &= ("Desktop screen resolution") & ": " & Desktop.Resolution & Space(1) & "dpi (Dots Per Inch)" & "<br>"
  sMessage &= Str(Round(Desktop.Resolution / 2.54, -1)) & Space(1) & ("Bildpunkte pro Zentimeter (cm)") & "<br>"
  ' pointFXY = M01Functions.Unit1cm()
  ' sMessage &= Str(pointFXY.X) & ("dpi horizontal links-rechts x-Achse") & "<br>" 
  ' sMessage &= Str(pointFXY.Y) & ("dpi vertikal oben-unten y-Achse") & "<br>" 
  sMessage &= "</font>" & "<br>"
  
  ''Show:
  Select Case Message.Question(sMessage, ("Bildprogramm..."), ("Ordner..."), ("Abbrechen"))
    Case 1 ''Picture-Program
      If IsDir(File.Dir(sPath)) = True Then hPicture.Save(sPath)
      If Exist(sPath) = False Then 
        sPath = FMain.F_sDirAppName &/ sFile 
        hPicture.Save(sPath)
      Endif 
      Desktop.Open(sPath) 'Standard-Program
      ' M01Functions.ExternStart("gimp", sPath)
    Case 2 ''Directory:
      M01Functions.FileManagerOpen(sPath)
    Case 3 ''Cancel
      '...Leerlauf
  End Select
  
Catch
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Enter()
  
  If Object.Type(Last) = "Button" Then Last.Border = True
  If Object.Type(Last) = "PictureBox" Then Last.Background = F_iColorGreen150
  If Object.Type(Last) = "TextLabel" Then Last.Background = F_iColorGreen150
  
  If PanelSquare.Visible = True Then 
    ButtonM7PanelSquare.Background = Color.Green 
  Else 
    ButtonM7PanelSquare.Background = Color.Default
  Endif 
  ButtonPanelSquareCancel.Background = Color.Green
  ButtonPanelSquareCancel.Border = True 
  
  Select Case String.LCase(Last.Tag)
      
    Case ButtonM1Foto.Tag, PicBoxLED.Tag
      ButtonM1Foto.Background = F_iColorGreen150 
      ButtonM1Foto.Border = True
      
    Case LabelM2Save.Tag, ButtonM2Save.Tag
      LabelM2Save.Background = F_iColorGreen150 
      ButtonM2Save.Background = F_iColorGreen150 
      ButtonM2Save.Border = True
      
    Case LabelM3Program.Tag, ButtonM3Program.Tag
      LabelM3Program.Background = F_iColorGreen150 
      ButtonM3Program.Background = F_iColorGreen150 
      ButtonM3Program.Border = True
      
    Case LabelM4Full.Tag, ButtonM4Full.Tag
      LabelM4Full.Background = F_iColorGreen150 
      ButtonM4Full.Background = F_iColorGreen150 
      ButtonM4Full.Border = True
      
    Case LabelM5Menu.Tag, ButtonM5Menu.Tag
      LabelM5Menu.Background = F_iColorGreen150 
      ButtonM5Menu.Background = F_iColorGreen150 
      ButtonM5Menu.Border = True
      
    Case LabelM6Scale.Tag
      LabelM6Scale.Background = F_iColorGreen150 
      
    Case PicBoxCutPreview.Tag
      PicBoxCutPreview.Background = F_iColorGreen150 
      
    Case ButtonM8Copy.Tag
      ButtonM8Copy.Background = F_iColorGreen150 
      ButtonM8Copy.Border = True
      
    Case PicBoxM7ZoomLupe.Tag
      PicBoxM7ZoomLupe.Background = F_iColorGreen150 
      
    Case ButtonM8Zoom.Tag
      ButtonM8Zoom.Background = F_iColorGreen150 
      ButtonM8Zoom.Border = True
      
    Case ButtonQuotesOnOff.Tag, ButtonQuotesLineOnOff.Tag 
      If F_bQuoteStarON = True Then 
        ButtonQuotesOnOff.Background = Color.Green  
      Else 
        ButtonQuotesOnOff.Background = F_iColorGreen150
      Endif 
      
    Case ButtonQuotesLineOnOff.Tag
      If F_bQuoteStarON = True Then 
        ButtonQuotesLineOnOff.Border = True 
        ButtonQuotesLineOnOff.Background = Color.Green  
      Else 
        ButtonQuotesLineOnOff.Border = True  
        ButtonQuotesLineOnOff.Background = F_iColorGreen150
      Endif 
      
    Case ButtonQuotesDateOnOff.Tag
      If F_bQuoteDateON = True Then 
        ButtonQuotesDateOnOff.Border = True 
        ButtonQuotesDateOnOff.Background = Color.Green  
      Else 
        ButtonQuotesDateOnOff.Border = True  
        ButtonQuotesDateOnOff.Background = F_iColorGreen150
      Endif 
      
    Case ButtonQuotesTimeOnOff.Tag
      If F_bQuoteTimeON = True Then 
        ButtonQuotesTimeOnOff.Border = True 
        ButtonQuotesTimeOnOff.Background = Color.Green  
      Else 
        ButtonQuotesTimeOnOff.Border = True  
        ButtonQuotesTimeOnOff.Background = F_iColorGreen150
      Endif 
      
    Case ButtonQuotesTextOnOff.Tag
      If F_bQuoteTextON = True Then 
        ButtonQuotesTextOnOff.Border = True 
        ButtonQuotesTextOnOff.Background = Color.Green  
      Else 
        ButtonQuotesTextOnOff.Border = True  
        ButtonQuotesTextOnOff.Background = F_iColorGreen150
      Endif 
      
    Case ButtonM10Close.Tag
      ButtonM10Close.Background = F_iColorGreen150 
      ButtonM10Close.Border = True
      
    Case ButtonFileInfo.Tag
      LabelInfoPathG(TextBoxPath.Text)
      
    Case ButtonSaveQuotes.Tag 
      LabelInfoPathG(TextBoxPath.Text)
    
    Case PicBoxTextLeft.Tag, PicBoxTextCenter.Tag, PicBoxTextRight.Tag, PicBoxTextAPlus.Tag
      TextBoxQuoteExample.Background = F_iColorGreen150
      
  End Select
  
  ButtonQuotesLineOnOff.Border = F_bQuoteStarON
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Leave()
  
  If Object.Type(Last) = "Button" Then Last.Border = False
  If Object.Type(Last) = "PictureBox" Then Last.Background = Color.Default
  If Object.Type(Last) = "TextLabel" Then Last.Background = Color.Default
  
  If PanelSquare.Visible = True Then 
    ButtonM7PanelSquare.Background = Color.Green 
    ButtonM7PanelSquare.Border = True 
  Else 
    ButtonM7PanelSquare.Background = Color.Default
  Endif 
  
  Select Case String.LCase(Last.Tag)
      
    Case ButtonM1Foto.Tag, PicBoxLED.Tag
      ButtonM1Foto.Background = Color.Default 
      PicBoxLED.Background = Color.Default 
      ButtonM1Foto.Border = True
      
    Case LabelM2Save.Tag, ButtonM2Save.Tag
      LabelM2Save.Background = Color.Default 
      ButtonM2Save.Background = Color.Default 
      ButtonM2Save.Border = False
      
    Case LabelM3Program.Tag, ButtonM3Program.Tag
      LabelM3Program.Background = Color.Default 
      ButtonM3Program.Background = Color.Default 
      ButtonM3Program.Border = False
      
    Case LabelM4Full.Tag, ButtonM4Full.Tag
      LabelM4Full.Background = Color.Default 
      ButtonM4Full.Background = Color.Default 
      ButtonM4Full.Border = False
      
    Case LabelM5Menu.Tag, ButtonM5Menu.Tag
      LabelM5Menu.Background = Color.Default 
      ButtonM5Menu.Background = Color.Default 
      ButtonM5Menu.Border = False
      
    Case LabelM6Scale.Tag
      LabelM6Scale.Background = Color.Default 
      
    Case PicBoxCutPreview.Tag
      PicBoxCutPreview.Background = Color.Default 
      
    Case ButtonM8Copy.Tag
      ButtonM8Copy.Background = Color.Default 
      ButtonM8Copy.Border = True
      
    Case ButtonQuotesOnOff.Tag, ButtonQuotesLineOnOff.Tag 
      If PanelQuotes.Visible = True Then 
        ButtonQuotesOnOff.Background = F_iColorGreen150 
      Else 
        ButtonQuotesOnOff.Background = Color.Default   
      Endif 
      
    Case ButtonQuotesLineOnOff.Tag
      If F_bQuoteStarON = True Then 
        ButtonQuotesLineOnOff.Border = True 
        ButtonQuotesLineOnOff.Background = Color.Green  
      Else 
        ButtonQuotesLineOnOff.Border = False 
        ButtonQuotesLineOnOff.Background = Color.Default  
      Endif 
      
    Case ButtonQuotesDateOnOff.Tag
      If F_bQuoteDateON = True Then 
        ButtonQuotesDateOnOff.Border = True 
        ButtonQuotesDateOnOff.Background = Color.Green  
      Else 
        ButtonQuotesDateOnOff.Border = False  
        ButtonQuotesDateOnOff.Background = Color.Default 
      Endif 
      
    Case ButtonQuotesTimeOnOff.Tag
      If F_bQuoteTimeON = True Then 
        ButtonQuotesTimeOnOff.Border = True 
        ButtonQuotesTimeOnOff.Background = Color.Green  
      Else 
        ButtonQuotesTimeOnOff.Border = False
        ButtonQuotesTimeOnOff.Background = Color.Default 
      Endif 
      
    Case ButtonQuotesTextOnOff.Tag
      If F_bQuoteTextON = True Then 
        ButtonQuotesTextOnOff.Border = True 
        ButtonQuotesTextOnOff.Background = Color.Green  
      Else 
        ButtonQuotesTextOnOff.Border = False  
        ButtonQuotesTextOnOff.Background = Color.Default 
      Endif 
      
    Case PicBoxM7ZoomLupe.Tag
      If F_bZoomLupeON = True And ImageViewPhoto.Visible = False Then 
        PicBoxM7ZoomLupe.Background = F_iColorGreen150 
        PicBoxM7ZoomLupe.Border = Border.Plain
      Else
        PicBoxM7ZoomLupe.Background = Color.Default 
        PicBoxM7ZoomLupe.Border = Border.None
      Endif 
      
    Case ButtonM8Zoom.Tag
      If ImageViewPhoto.Visible = True Then 
        ButtonM8Zoom.Background = F_iColorGreen150 
        ButtonM8Zoom.Border = True
      Else
        ButtonM8Zoom.Background = Color.Default 
        ButtonM8Zoom.Border = False
      Endif 
      
    Case ButtonM10Close.Tag
      ButtonM10Close.Background = Color.Default 
      ButtonM10Close.Border = False
      
    Case ButtonFileInfo.Tag, LabelInfo.Tag
      LabelInfo.Visible = False
      
    Case ButtonSaveQuotes.Tag 
      LabelInfo.Visible = False
      
    Case PicBoxTextLeft.Tag, PicBoxTextCenter.Tag, PicBoxTextRight.Tag, PicBoxTextAPlus.Tag
      TextBoxQuoteExample.Background = Color.Default 
      
  End Select
  
  ButtonQuotesLineOnOff.Border = F_bQuoteStarON
  LabelClipboardInfo.Visible = False 'Reset
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupLeaveDeafaultG()
  
  If PanelSquare.Visible = True Then 
    ButtonM7PanelSquare.Background = Color.Green 
    ButtonM7PanelSquare.Border = True 
  Else 
    ButtonM7PanelSquare.Background = Color.Default
  Endif 
  
  ButtonM1Foto.Background = Color.Default 
  PicBoxLED.Background = Color.Default 
  ButtonM1Foto.Border = True
  
  LabelM2Save.Background = Color.Default 
  ButtonM2Save.Background = Color.Default 
  ButtonM2Save.Border = False
  
  LabelM3Program.Background = Color.Default 
  ButtonM3Program.Background = Color.Default 
  ButtonM3Program.Border = False
  
  LabelM4Full.Background = Color.Default 
  ButtonM4Full.Background = Color.Default 
  ButtonM4Full.Border = False
  
  LabelM5Menu.Background = Color.Default 
  ButtonM5Menu.Background = Color.Default 
  ButtonM5Menu.Border = False
  
  LabelM6Scale.Background = Color.Default 
  
  PicBoxM7ZoomLupe.Background = Color.Default 
  ButtonM8Zoom.Background = Color.Default 
  ButtonM8Zoom.Border = False 
  
  PicBoxCutPreview.Background = Color.Default 
  
  ButtonM8Copy.Background = Color.Default 
  ButtonM8Copy.Border = False
  
  If PanelQuotes.Visible = True Then 
    ButtonQuotesOnOff.Background = F_iColorGreen150 
  Else 
    ButtonQuotesOnOff.Background = Color.Default   
  Endif 
  
  If F_bQuoteStarON = True Then 
    ButtonQuotesLineOnOff.Border = True 
    ButtonQuotesLineOnOff.Background = Color.Green  
  Else 
    ButtonQuotesLineOnOff.Border = False 
    ButtonQuotesLineOnOff.Background = Color.Default  
  Endif 
  
  If F_bQuoteDateON = True Then 
    ButtonQuotesDateOnOff.Border = True 
    ButtonQuotesDateOnOff.Background = Color.Green  
  Else 
    ButtonQuotesDateOnOff.Border = True  
    ButtonQuotesDateOnOff.Background = Color.Default 
  Endif 
  
  If F_bQuoteTimeON = True Then 
    ButtonQuotesTimeOnOff.Border = True 
    ButtonQuotesTimeOnOff.Background = Color.Green  
  Else 
    ButtonQuotesTimeOnOff.Border = False
    ButtonQuotesTimeOnOff.Background = Color.Default 
  Endif 
  
  If F_bQuoteTextON = True Then 
    ButtonQuotesTextOnOff.Border = True 
    ButtonQuotesTextOnOff.Background = Color.Green  
  Else 
    ButtonQuotesTextOnOff.Border = False
    ButtonQuotesTextOnOff.Background = Color.Default 
  Endif 
  
  If F_bZoomLupeON = True Then 
    PicBoxM7ZoomLupe.Background = F_iColorGreen150 
    PicBoxM7ZoomLupe.Border = Border.Plain
  Else
    PicBoxM7ZoomLupe.Background = Color.Default 
    PicBoxM7ZoomLupe.Border = Border.None
  Endif 
  
  If ImageViewPhoto.Visible = True Then 
    ButtonM8Zoom.Background = F_iColorGreen150 
    ButtonM8Zoom.Border = True
  Else
    ButtonM8Zoom.Background = Color.Default 
    ButtonM8Zoom.Border = False
  Endif 
  
  ButtonM10Close.Background = Color.Default 
  ButtonM10Close.Border = False
  
  LabelInfo.Visible = False
  
  ButtonQuotesLineOnOff.Border = F_bQuoteStarON
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseDown() '> Label
  
  Dim sMouseLMR As String 
  ' If Object.Type(Last) = "TextLabel" Then ButtonGroupSelect(Last.Tag) 'html
  ' If Object.Type(Last) = "Label" Then ButtonGroupSelect(Last.Tag)
  ' If Last.Tag = PicBoxQuoteStarPanel.Tag Then 
  If Mouse.Left = True Then sMouseLMR = "left"
  If Mouse.Middle = True Then sMouseLMR = "middle"
  If Mouse.Right = True Then sMouseLMR = "right"
  ButtonGroupSelect(Last.Tag, sMouseLMR)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_MouseWheel() 'Menu
  
  If Last.Tag = PicBoxTextAPlus.Tag Then 
    If Mouse.Forward Then                                                                  '.Forward as Boolean True/False
      F_fTextSizeAPlus = F_fTextSizeAPlus - 2
    Else  
      F_fTextSizeAPlus = F_fTextSizeAPlus + 2
    Endif
    ''Check Min-Max
    If F_fTextSizeAPlus < 8 Then F_fTextSizeAPlus = 8
    If F_fTextSizeAPlus > 20 Then F_fTextSizeAPlus = 20
    Settings[F_sForm &/ "F_fTextSizeAPlus"] = F_fTextSizeAPlus
    TextBoxQuoteExample.Font.Size = F_fTextSizeAPlus
    LabelCutArea.Font.Size = F_fTextSizeAPlus
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_Click()
  
  If Object.Type(Last) = "Menu" Then ButtonGroupSelect(Last.Tag)
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroup_KeyPress()
  
  If Key.Code = Key.Return Then 
    If Object.Type(Last) = "TextBox" Then 
      ButtonGroupSelect(ButtonNewLine.Tag)
      ButtonGroupSelect(ButtonInput.Tag)
    Endif 
  Endif 
  
Catch 
  FMain.ErrorText
  
End

Public Sub ButtonGroupSelect(Optional sLastTag As String = "", Optional sMouseLMR As String = "L")
  
  Dim sDir, sMessage As String 
  
  F_bESCpressedON = False
  sMouseLMR = String.Left(String.LCase(sMouseLMR), 1) 'l, m, r
  Form15Foto.Window.Title = F_sTitleBasicText
  sLastTag = String.LCase(sLastTag)
  
  Select Case sLastTag
    Case "undophoto"
      If sMouseLMR = "r" Then F_iUndoRedoPhotosPointer = -1
      UndoRedoPhotosPointer("undo")
    Case "redophoto"
      If sMouseLMR = "r" And F_ooUndoRedoPhoto Then F_iUndoRedoPhotosPointer = F_ooUndoRedoPhoto.Max
      UndoRedoPhotosPointer("redo")
    Case "undoredomax"
      UndoRedoPhotosPointer("max")
      
    Case "undocutarea"
      If sMouseLMR = "r" Then F_iUndoRedoCutAreaPointer = -1
      UndoRedoCutAreaPointer("undo")
    Case "redocutarea"
      If sMouseLMR = "r" And F_ooUndoRedoCutArea Then F_iUndoRedoCutAreaPointer = F_ooUndoRedoCutArea.Max
      UndoRedoCutAreaPointer("redo")
    Case "undoredocutareamax"
      UndoRedoCutAreaPointer("max")
      
    Case "dir"
      M01Functions.FileManagerOpen(FilePathForm())
      
    Case "resetform"
      M01Functions.ResetForm(F_sForm)
      
    Case "picturedirectoryopen", ButtonPreviewDir.Tag
      PictureDirectoryOpenG()
      
    Case "fileinfok1", ButtonFileSavedInfo.Tag
      sDir = M01Functions.DirectorySystemDefaultPictures() 'as String 
      Form19FileInfo.Tag = Settings[FMain.Name &/ "sPathFoto", sDir] 'as String 
      Form19FileInfo.Window.Show
      ' Form19FileInfo.Window.Visible = True  'Wayland error?
      
    Case "grid"
      PicBoxGrid.Visible = Not PicBoxGrid.Visible
      CheckGrid(PicBoxGrid.Visible)
      
    Case "helplines"
      F_bCrossLineON = Not F_bCrossLineON
      CreateCrossLine()
      CrossLinesMove()
      SettingsReadSave("save") 
      
    Case "showpanelpreview"
      PanelFileSaved.Visible = Not PanelFileSaved.Visible 
      PanelFileSaved.Raise
      If PanelFileSaved.Visible = True Then 
        PanelFileSaved.Move(PanelGlass.Left, PanelGlass.Top)
        InfoControlPicture()
        If String.InStr(String.LCase(LabelPictureSavedPath.Text), "tool") > 0 Then 
          LabelMessageTool.Text = FMain.F_sErrorMessagesExtra
          LabelMessageTool.Raise
        Endif 
      Endif 
      
    Case "zoomcolorpoint", LabelZoomColorPoint.Tag
      sMessage = "<h2>" & "<font color=#" & Hex(F_iColorPicker, 6) & ">■ </font>" & "<font color=red>■ </font><font color=green>■ </font><font color=blue>■ </font>" & ("Mehr Farb-Details im neuen Fenster?") & "</h2>"
      sMessage &= "<h2><font color=gray>" & ("Foto-Fenster im Vordergrund _minimieren_ in die Startleiste") & "</font></h2>"
      Select Case Message.Question(sMessage, ("Farb-Fenster öffnen..."), ("Nein"), ("Abbrechen"))
        Case 1 
          Form15Foto.Minimized = True 
          Form21Colors.Show()
          Form21Colors.Visible = True 
        Case 2, 3 
          ''...
      End Select

    Case "photobutton", ButtonM1Foto.Tag
      PhotoButtonG()'Complete, Screenshot > Clipboard
      
    Case "copybutton", ButtonM8Copy.Tag
      CopyButtonG()  'CutArea > Clipboard
      ' PhotoCutArea()'LabelPixelWxHScalePicture()
      
    Case "photolatest"
      PhotoLatestG()
      
    Case "save", ButtonM2Save.Tag
      If sMouseLMR = "l" Then
        SaveG()
      Else
        Menu1.Popup(ButtonM2Save.Left, 0)
      Endif
      
    Case "clipboardimagepaste", mnuClipboardImagePaste.Tag 
      ClipboardImagePaste()
      
    Case "cutareainternalpicturepaste", mnuCutAreaInternalPicturePaste.Tag 
      CutAreaInternalPicturePaste()
      
    Case "pastepictureopen", mnuPastePictureOpen.Tag
      PastePictureOpen()
      
    Case "picprogramextern", LabelM3Program.Tag, ButtonM3Program.Tag 
      LabelPixelWxHScalePicture()
      ButtonPicProgramExtern()
      
    Case "picprogramextern2", ButtonExtern.Tag
      LabelPixelWxHScalePicture()
      ButtonPicProgramExtern()
      
    Case "openexternfile"
      ButtonFilePicProgramExtern("file") '/dir/file.png
      
    Case "openexternscreen"
      ButtonFilePicProgramExtern("screen") '/dir/file.png
      
    Case "openexterncut"
      ButtonFilePicProgramExtern("cut") '/dir/file.png —▶ open in picture-program (Default)
      
    Case "fullpicture", ButtonM4Full.Tag
      ButtonM4FullG()
      
    Case "openformnewphoto"
      If Settings[F_sForm &/ "openformwithnewphoto", False] = True Then 
        Settings[F_sForm &/ "openformwithnewphoto"] = False
      Else 
        Settings[F_sForm &/ "openformwithnewphoto"] = True
        PhotoButtonG()
      Endif
      
    Case "menu", ButtonM5Menu.Tag
      ExternStandardProgramNameRefresh()
      Menu1.Popup(ButtonM5Menu.Left, 0)
      
    Case "standardprogramextern" 'mnuStandardprogramExtern.Tag
      M01Functions.SystemStandardApplications()
      
    Case "scale", LabelM6Scale.Tag  'M1:1...
      PhotoCutArea()
      ExternStandardProgramNameRefresh()
      Menu1.Popup(LabelM6Scale.Left, 0)
      
    Case "squarepanel", ButtonM7PanelSquare.Tag
      ImageViewPhoto.Visible = False 
      PanelSquare.Visible = Not PanelSquare.Visible
      If PanelSquare.Visible = False Then CornerPointsSquarePicture("reset")
      PicBoxPanelSquareBG.Background = F_iColorGreen220 'LabelCutArea.Background
      
    Case "square", ButtonM7Square.Tag '□ W=H 1:1
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareminusright", ButtonM7MinusRight.Tag
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareplusright", ButtonM7PlusRight.Tag
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareminusdown", ButtonM7MinusDown.Tag
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareplusdown", ButtonM7PlusDown.Tag
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareup", ButtonM7Up.Tag '▲
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squaredown", ButtonM7Down.Tag  '▼
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareleft", ButtonM7Left.Tag '◀
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "squareright", ButtonM7Right.Tag '▶
      CornerPointsSquarePicture(sLastTag)
      PhotoCutArea()
      
    Case "cutpicture", PicBoxCutPreview.Tag '■
      PhotoCutArea()
      
      ' Case "copybutton", ButtonM8Copy.Tag
      '   CopyButtonG()
      
    Case "colorpoint", MenuColorPoint.Tag
      Form21Colors.Show
      Form21Colors.Visible = True 
      
    Case "quotestarpanel", "quotepanelcancel", ButtonQuotesPanelCancel.Tag
      If PanelQuotes.Visible = False Then 
        QuoteStarG()
        CreatePanelQuote()
        SelectQuote()
        PhotoCutArea()
      Else 
        QuoteStarCheck()
        QuotesStarPanelClose()
      Endif 
      
    Case "quotestaronoff", ButtonQuotesLineOnOff.Tag, ButtonQuotesOnOff.Tag
      QuoteStarOnOff()
      ResizePanelQuotes()
      
    Case "quotesdateonoff", ButtonQuotesDateOnOff.Tag ''Date
      F_bQuoteDateON = Not F_bQuoteDateON
      SelectQuote()
      
    Case "quotestimeonoff", ButtonQuotesTimeOnOff.Tag ''Time
      F_bQuoteTimeON = Not F_bQuoteTimeON
      SelectQuote()
      
    Case "quotestexton", ButtonQuotesTextOnOff.Tag ''Text
      F_bQuoteTextON = Not F_bQuoteTextON
      SelectQuote()
      
    Case "quoteup"
      ColumnViewUpDown("up")
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")    
      
    Case "quotedown"
      ColumnViewUpDown("down")
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")    
      
    Case "newline" ' add +
      ColumnView1.UnselectAll()
      ColumnViewAddAppend()
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")    
      
    Case "inputline"
      ButtonInputG()
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")    
      
    Case "linecut"
      ColumnViewCut()
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")    
      
    Case "savequotes"
      ColumnView3SaveQuotes()  
    
    Case "saveasquotes"
      ColumnView3SaveAsQuotes()  
      
    Case "fileinfo"
      FileInfoG()
      
    Case "cancelpreview", ButtonFileSavedCancel.Tag '×
      PanelFileSaved.Visible = False
      
    Case "photowindow"
      M01Functions.ScreenshotImageAreaForm(Me.ScreenX, Me.ScreenY, Me.W, Me.H)
      
    Case "cancelform", ButtonM10Close.Tag'×
      Form15Foto.Window.Close()
      
    Case "quotesundo"
      UndoRedoTextLines("undo")
      
    Case "quotesredo"
      UndoRedoTextLines("redo")
      
    Case "openquotes"
      ReadFileQuotes()
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")   
      
    Case "openquotesbackup"
      ReadFileQuotes(True)
      F_bQuoteStarListChanged = True
      ColumnView3ListChanged()
      UndoRedoTextLines("save")   
      
    Case "textleft"
      F_iTextLeftCenterRight = Align.BottomLeft
      Settings[F_sForm &/ "F_iTextLeftCenterRight"] = F_iTextLeftCenterRight
      TextBoxQuoteExample.Alignment = F_iTextLeftCenterRight
      LabelCutArea.Alignment = F_iTextLeftCenterRight
      
    Case "textcenter"
      F_iTextLeftCenterRight = Align.Bottom
      Settings[F_sForm &/ "F_iTextLeftCenterRight"] = F_iTextLeftCenterRight
      TextBoxQuoteExample.Alignment = F_iTextLeftCenterRight
      LabelCutArea.Alignment = F_iTextLeftCenterRight
      
    Case "textright"
      F_iTextLeftCenterRight = Align.BottomRight
      Settings[F_sForm &/ "F_iTextLeftCenterRight"] = F_iTextLeftCenterRight
      TextBoxQuoteExample.Alignment = F_iTextLeftCenterRight
      LabelCutArea.Alignment = F_iTextLeftCenterRight
      
    Case "textaplus" 'A+ 
      If sMouseLMR = "l" Then 'l, m, r
        If F_fTextSizeAPlus <= 11 Then 
          F_fTextSizeAPlus = 14
        Else 
          F_fTextSizeAPlus = 10
        Endif 
      Else 
        F_fTextSizeAPlus = 12 'Standard
      Endif 
      Settings[F_sForm &/ "F_fTextSizeAPlus"] = F_fTextSizeAPlus
      TextBoxQuoteExample.Font.Size = F_fTextSizeAPlus
      LabelCutArea.Font.Size = F_fTextSizeAPlus
      
    Case "zoomlupe", PicBoxM7ZoomLupe.Tag
      F_bZoomLupeON = Not F_bZoomLupeON
      If ImageViewPhoto.Visible = True Then 
        ImageViewPhoto.Visible = False 
        PicBoxPhoto.Mouse = Mouse.Cross
      Endif 
      
      If F_bZoomLupeON = True And sMouseLMR = "r" Then 
        ' CheckZoomLupeCursor(F_bZoomLupeON)
        ZoomLupeOnOffMessage()
      Else If F_bZoomLupeON = True And sMouseLMR = "l" Then  
        F_fZoomFactor = 4 'Reset
        CheckZoomLupeCursor(F_bZoomLupeON)
      Else If F_bZoomLupeON = False Then 
        TimerZoomLupe.Stop()
        CheckZoomLupeCursor(F_bZoomLupeON)
      Endif 
      
    Case "zoomoptimal"
      If ImageView1.Zoom = 1 Then 
        ImageView1.ZoomFit() '◀optimal▶
      Else 
        ImageView1.Zoom = 1  '◀original▶  
      Endif 
      
    Case "zoomphotooptimal", ButtonM8Zoom.Tag 
      ' If F_bCutAreaFullScreenON = False Then ButtonM4FullG()
      F_bZoomLupeON = False
      ImageViewPhoto.Visible = Not ImageViewPhoto.Visible
      If ImageViewPhoto.Visible = True Then 
        ImageViewPhoto.Zoom = 2
        PicBoxPhoto.Mouse = Mouse.Cross
      Endif 
      PanelSquare.Visible = False
      CheckZoomPhotoOptimal(ImageViewPhoto.Visible)
      
  End Select
  
  PanelGlass.Visible = Not ImageViewPhoto.Visible
  CornerPointsToLabelCutAreaONoff(PanelGlass.Visible)
  ' ButtonGroupLeaveDeafaultG()
  
Catch 
  FMain.ErrorText
  IconError.Visible = True 
  IconError.Raise()
  
End '..................................




Datei: ..................................................
/home/<USER>/gambas3/terminwecker/.project
hidden=T
realpath=/home/<USER>/gambas3/terminwecker/.project
1,86 KB
# Gambas Project File 3.0
Title=terminwecker
Startup=FMain
Icon=terminwecker.png
Version=3.0.477
Component=gb.args
Component=gb.image
Component=gb.qt5
Component=gb.form
Component=gb.clipper
Component=gb.dbus
Component=gb.debug
Component=gb.desktop
Component=gb.desktop.x11
Component=gb.eval
Component=gb.form.dialog
Component=gb.util
Component=gb.settings
Component=gb.form.stock
Component=gb.gui.trayicon
Component=gb.net
Component=gb.net.curl
Component=gb.mime
Component=gb.qt5.ext
Component=gb.qt5.webkit
Component=gb.sdl2.audio
Description="Terminwecker_3L, \nDate Event alarm Clock, Termine  (*.txt), \nwww.design-cad.de, Open Source (Quelltext lesbar), Freeware (Kostenlos). \nHerstellerseite \"https://www.design-cad.de\".  GUI: QT5"
Authors="https://www.design-cad.de"
TabSize=2
Translate=1
Language=de
CreateShortcut=1
RunAfter=terminwecker
ShowDeprecated=1
SourcePath=/home/<USER>/terminwecker
Maintainer=design-cad.de
Vendor=https://www.design-cad.de
VendorPrefix=de
Address=info@design-cad.de
Url=https://www.design-cad.de
License=General Public License
PackageName=terminwecker-3.0.476
CreateEachDirectory=1
MimeTypes="text/plain","text/html","image/png","image/jpg","image/bmp"
RuntimeVersion="3.8"
Packager=1
Systems=debian,fedora,mageia,suse,ubuntu
SameDependencies=1
SameFiles=1
Menus=debian:"Applications/Editors"
Categories=debian:"Calendar;Text;Utility"
Groups=debian:"editors"
Menus=fedora:"Utility/Clock"
Categories=fedora:"Calendar;Clock;Utility"
Groups=fedora:"Applications/Editors"
Menus=mageia:"More Applications/Editors"
Categories=mageia:"Calendar;TextEditor;Utility"
Groups=mageia:"Office/Utilities"
Menus=suse:"Utility/Clock"
Categories=suse:"Calendar;Clock;TextTools;Utility"
Groups=suse:"Productivity/Text/Utilities"
Menus=ubuntu:"Applications/Editors"
Categories=ubuntu:"Calendar;TextEditor;TextTools;Utility"
Groups=ubuntu:"editors"


CHANGELOG

Fehler-Meldungen: Null object, Form2Bearb.Columnview1EnsureVisible.1777
Korrigiert: Columnview > ColumnView
Korrigiert: If ColumnView1.Keys.Count > 0 Then 'Error  >  If ColumnView1.Current Then

* Mon Jul 07 2025 design-cad.de <info@design-cad.de> 3.0.475 Update Internetseite

* Sun Jun 29 2025 design-cad.de <info@design-cad.de> 3.0.474
* Tue Oct 01 2024 design-cad.de <info@design-cad.de> 3.0.457
* Mon Nov 20 2023 design-cad.de <info@design-cad.de> 3.0.436
* Tue Jul 12 2022 design-cad.de <info@design-cad.de> 3.0.336
* Tue Sep 14 2021 design-cad.de <info@design-cad.de> 3.0.270
- März 2021 Linux-Version 3.0.180, ubuntu20LTS

* Tue Apr 04 2017 design-cad.de <info@design-cad.de> 2.0.15
- ubuntu16LTS,  ubuntu-rot, first Release in 64bit 
Linux-Version 2.0.7, 2012-2013, Dateigröße 0,4 MB, 32bit
Windows-Version 2.0.0.256, 2005-2011, Dateigröße 5,6 MB (ab 2009 im Internet), 32bit



Programm: terminwecker 3.0.477
/home/<USER>/gambas3/terminwecker/text/CHANGELOG   Geändert: 2025-10-07
3.582.351 Schrift-Zeichen
102.738 Zeilen
367 Eigene Bilder, Programm-Icons
1652 Uhr-Muster
501 Dateien
3,59 MB opensourse.txt

Dieses Programm ist kostenlos (Freeware). Free for all humans.
App, Software, Program: terminwecker is Open Source (o), Freeware (f) from www.design-cad.de
This program terminwecker is written in Gambas3.19.5
gambas3-runtime (>= 3.16) (<< 3.99.0)
gambas3 runtime. Interpreter-Version: 3. Thanks (Merci, Danke).
