#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Leo.ico #AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\LeoNota.exe #AutoIt3Wrapper_Res_Comment=Manage and Create Notes, Nouvelle Génération. #AutoIt3Wrapper_Res_Description=Manage and Create Notes, Nouvelle Génération. #AutoIt3Wrapper_Res_Fileversion=1.0.6.5 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_ProductName=Leo Nota #AutoIt3Wrapper_Res_ProductVersion=1.0.5.2 #AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares #AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares #AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "MetroGUI-UDF\MetroGUI_UDF.au3" #include "Extensions.au3" GetSoftDetails(@AutoItExe,"BETA") #cs Tyleo Software Project Base v1 Created With CNP and DevTools Base Folder All Softwares created with this base are Free and Open Sourced. Join our Guilded Server ! https://www.guilded.gg/i/2DRlM7Mp #ce $ext = ".nota" #Region ; Localisation par défault et configuration INI $defaultbaseloc = @MyDocumentsDir & "\My Notes" if FileExists($defaultbaseloc) Then $defaultbaseloc = $defaultbaseloc Else DirCreate($defaultbaseloc) DirCreate($defaultbaseloc & "\Archives") EndIf $cfgdir = @AppDataDir & "\Leo Notes" $cfgfile = $cfgdir & "\general.cfg" if FileExists($cfgdir) Then ; Else DirCreate($cfgdir) EndIf if FileExists($cfgfile) Then ; Else IniWrite($cfgfile,"configuration","fontface","Segoe UI Light") IniWrite($cfgfile,"configuration","font color","0x000000") IniWrite($cfgfile,"configuration","font size","10") IniWrite($cfgfile,"configuration","font weight","400") IniWrite($cfgfile,"configuration","background color","0xFFFFFF") IniWrite($cfgfile,"configuration","database location",$defaultbaseloc) EndIf #EndRegion $fontface = IniRead($cfgfile,"configuration","fontface","Segoe UI Light") $fontsize = IniRead($cfgfile,"configuration","font size","10") $fontweight = IniRead($cfgfile,"configuration","font weight","400") $fontcolor = IniRead($cfgfile,"configuration","font color","0x000000") $backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") $baseloc = IniRead($cfgfile,"configuration","database location",$defaultbaseloc) if FileExists($baseloc & "\Archived") Then ; Else DirCreate($baseloc & "\Archived") EndIf #include #include #include #include #include "_Zip.au3" #include "Outlook.au3" #include #include #include #include #Region ### START Koda GUI section ### Form=C:\Users\Tyleo\Nextcloud2\Tyleo\Dev\My NotePad\Form1.kxf Global $GUI = GUICreate("Leo Nota v" & $CurrentVersion, 866, 670, 274, 128) GUISetBkColor($CurrentAccent,$GUI) GUISetFont(9.5,"","","Segoe UI Light") Global $Files = GUICtrlCreateMenu("Files") Global $Files_Import = GUICtrlCreateMenu("Import",$Files) Global $Files_Import_TXT = GUICtrlCreateMenuItem("Text File" & @TAB & "*.txt",$Files_Import) Global $Files_Import_MD = GUICtrlCreateMenuItem("Markdown File" & @TAB & "*.md",$Files_Import) Global $Edit = GUICtrlCreateMenu("Edition") Global $Edit_CopyAll = GUICtrlCreateMenuItem("Copy all to Clipboard",$Edit) Global $Edit_PasteAppend = GUICtrlCreateMenuItem("Paste" & @TAB & "Next To Current Data",$Edit) Global $Edit_PasteReplace = GUICtrlCreateMenuItem("Paste" & @TAB & "Replace Current Data",$Edit) Global $Config = GUICtrlCreateMenu("Configuration") Global $Config_Personnalize = GUICtrlCreateMenu("Customize UI") Global $Config_Font = GUICtrlCreateMenuItem("Change FontFace",$Config_Personnalize) Global $Config_Fk = GUICtrlCreateMenuItem("Font Color",$Config_Personnalize) Global $Config_Bk = GUICtrlCreateMenuItem("Background Color",$Config_Personnalize) Global $Config_Bk_acc = GUICtrlCreateMenuItem("Accent as Background",$Config_Personnalize) Global $Config_Loc = GUICtrlCreateMenu("Advanced",$Config) Global $Config_ChangeDatabaseLoc = GUICtrlCreateMenuItem("Change Note Database Location" & @TAB & $baseloc,$Config_Loc) Global $Archive = GUICtrlCreateMenu("Archive") Global $Archive_Open = GUICtrlCreateMenuItem("Open Archives" & @TAB & $baseloc & "\Archived",$Archive) Global $Archive_Export = GUICtrlCreateMenuItem("Backup Archives as ZIP" & @TAB & "EXPERIMENTAL",$Archive) Global $Version = GUICtrlCreateMenu("Version") Global $Version_About = GUICtrlCreateMenuItem("About",$Version) Global $Version_Site = GUICtrlCreateMenuItem("Website" & @TAB & "tyleodev.fr",$Version) Global $Group1 = GUICtrlCreateGroup(" Title ", 8, 8, 849, 41) Global $NoteTitle = GUICtrlCreateInput("", 16, 24, 833, 21) GUICtrlSetBkColor(-1,$backcolor) GUICtrlSetColor(-1,$fontcolor) GUICtrlSetFont(-1, "9.5", $fontweight, "", $fontface, 2) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group2 = GUICtrlCreateGroup(" Note Content ", 8, 56, 849, 313) Global $NoteContent = GUICtrlCreateEdit("", 16, 72, 833, 289) GUICtrlSetBkColor(-1,$backcolor) GUICtrlSetColor(-1,$fontcolor) GUICtrlSetFont(-1, $fontsize, $fontweight, "", $fontface, 2) GUICtrlSetData(-1, "") GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group3 = GUICtrlCreateGroup(" Management ", 8, 376, 89, 265) Global $Open = GUICtrlCreateButton("Open", 16, 392, 73, 17) GUICtrlSetCursor(-1,0) Global $Save = GUICtrlCreateButton("Save", 16, 408, 73, 17) GUICtrlSetCursor(-1,0) Global $Rename = GUICtrlCreateButton("Rename", 16, 424, 73, 17) GUICtrlSetCursor(-1,0) Global $Delete = GUICtrlCreateButton("Delete", 16, 440, 73, 17) GUICtrlSetCursor(-1,0) Global $ArchiveIt = GUICtrlCreateButton("Archive", 16, 456, 73, 17) GUICtrlSetCursor(-1,0) Global $ToMD = GUICtrlCreateButton("Export MD", 16, 488, 73, 17) GUICtrlSetCursor(-1,0) Global $ToTXT = GUICtrlCreateButton("Export TXT", 16, 504, 73, 17) GUICtrlSetCursor(-1,0) Global $ToRTF = GUICtrlCreateButton("Export RTF", 16, 520, 73, 17) GUICtrlSetCursor(-1,0) Global $ToPDF = GUICtrlCreateButton("Export PDF", 16, 536, 73, 17) GUICtrlSetCursor(-1,0) GUICtrlSetState(-1,$GUI_DISABLE) Global $DBOpen = GUICtrlCreateButton("Open DB", 16, 584, 73, 17) GUICtrlSetCursor(-1,0) Global $DBClose = GUICtrlCreateButton("Close DB", 16, 600, 73, 17) GUICtrlSetCursor(-1,0) Global $DBRefresh = GUICtrlCreateButton("Refresh DB", 16, 616, 73, 17) GUICtrlSetCursor(-1,0) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $Group4 = GUICtrlCreateGroup(" Note Database ", 104, 376, 753, 265) Global $NoteDB = GUICtrlCreateList("", 112, 392, 737, 240) GUICtrlSetBkColor(-1,$backcolor) GUICtrlSetColor(-1,$fontcolor) GUICtrlSetFont(-1, "9.5", $fontweight, "", $fontface, 2) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### DBRefresh() DateGet() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Version_Site ShellExecute("https://tyleodev.fr") Case $Open $Selected = GUICtrlRead($NoteDB) $Opened = FileOpen($baseloc & "\" & $Selected & ".nota") $Read = FileRead($Opened) GUICtrlSetData($NoteContent,$Read) GUICtrlSetData($NoteTitle,$Selected) Case $NoteDB $Selected = GUICtrlRead($NoteDB) $Opened = FileOpen($baseloc & "\" & $Selected & ".nota") $Read = FileRead($Opened) GUICtrlSetData($NoteContent,$Read) GUICtrlSetData($NoteTitle,$Selected) Case $Save $NoteName = GUICtrlRead($NoteTitle) $wData = GUICtrlRead($NoteContent) $dPool = FileOpen($baseloc & "\" & $NoteName & ".nota",2) FileWrite($dPool,$wData) DBRefresh() Case $Delete $Selected = GUICtrlRead($NoteDB) $Confirm = MsgBox(4,"Confirm Deletion","Confirm deletion. This action are not undoable (Secure Delete)") if $Confirm = 6 Then FileDelete($baseloc & "\" & $Selected & ".nota") EndIf DBRefresh() Case $ToTXT $Selected = GUICtrlRead($NoteDB) $SrcData = GUICtrlRead($NoteContent) $ExportTarget = _WinAPI_SaveFileDlg("Export as TXT",@MyDocumentsDir,"*.txt","",$Selected,".txt",$OFN_PATHMUSTEXIST) $File = FileOpen($ExportTarget,2) FileWrite($File,$SrcData) Case $ToMD $Selected = GUICtrlRead($NoteDB) $SrcData = GUICtrlRead($NoteContent) $ExportTarget = _WinAPI_SaveFileDlg("Export as MD",@MyDocumentsDir,"*.md","",$Selected,".md",$OFN_PATHMUSTEXIST) $File = FileOpen($ExportTarget,2) FileWrite($File,$SrcData) Case $ToRTF $Selected = GUICtrlRead($NoteDB) $SrcData = GUICtrlRead($NoteContent) $ExportTarget = _WinAPI_SaveFileDlg("Export as RTF",@MyDocumentsDir,"*.rtf","",$Selected,".rtf",$OFN_PATHMUSTEXIST) $File = FileOpen($ExportTarget,2) FileWrite($File,$SrcData) Case $Edit_PasteAppend $Clipboard_Data = ClipGet() $CurrentData = GUICtrlRead($NoteContent) $FormattedData = $CurrentData & @CRLF & $Clipboard_Data GUICtrlSetData($NoteContent,$FormattedData) Case $Rename $Selected = GUICtrlRead($NoteDB) $NewName = InputBox("New Name ?","Enter a new name",$Selected) FileMove($baseloc & "\" & $Selected & ".nota",$baseloc & "\" & $NewName & ".nota") DBRefresh() Case $ArchiveIt $Selected = GUICtrlRead($NoteDB) FileMove($baseloc & "\" & $Selected & ".nota",$baseloc & "\Archived\" & $Selected & ".nota") DBRefresh() Case $Edit_PasteReplace $Confirm = MsgBox(4,"Confirm Replace","This action replace all the note content case with your clipboard content." & @CRLF & "Confirm by selecting Yes/Oui") if $Confirm = 6 Then $Clipboard_Data = ClipGet() GUICtrlSetData($NoteContent,$Clipboard_Data) EndIf Case $Edit_CopyAll $NoteCopy1 = GUICtrlRead($NoteTitle) $NoteCopy2 = GUICtrlRead($NoteContent) $NoteAuthor = @UserName ClipPut($NoteCopy1 & @CRLF & "---------------------------------" & @CRLF & $NoteCopy2 & @CRLF & "---------------------------------" & @CRLF & "By " & $NoteAuthor & " using Leo Notes" & @CRLF) Case $DBOpen ShellExecute($baseloc) Case $Archive_Open ShellExecute($baseloc & "\Archived") Case $Version_About TyleoAbout("Leo Nota " & $CurrentVersion) Case $DBRefresh DBRefresh() Case $Files_Import_TXT $selectfile = _WinAPI_OpenFileDlg("Select TextFile(TXT) file to import as Note",@MyDocumentsDir,"*.txt","","","") ; FileOpenDialog("Select TXT file to import as Note",@MyDocumentsDir,"*.txt",1+2+4,"",$GUI) if @error Then ; Else For $file In $selectfile ; ConsoleWrite($files & @CRLF) FileCopy($file,$baseloc) Next $db_files_a = _FileListToArray($baseloc,"*.txt",1,False) for $dfile In $db_files_a $dPool = FileOpen($dfile,0) StringTrimRight($dfile,4) FileWrite($baseloc & "\" & $dfile & $ext,$dPool) Next for $tFile In $db_files_a FileDelete($baseloc & "\" & $tFile) Next EndIf Case $Files_Import_MD $selectfile = _WinAPI_OpenFileDlg("Select MarkDown(MD) file to import as Note",@MyDocumentsDir,"*.md","","","") ; FileOpenDialog("Select MarkDown(MD) file to import as Note",@MyDocumentsDir,"*.txt",1+2+4,"",$GUI) if @error Then ; Else For $file In $selectfile ; ConsoleWrite($files & @CRLF) FileCopy($file,$baseloc) Next $db_files_a = _FileListToArray($baseloc,"*.md",1,False) for $dfile In $db_files_a $dPool = FileOpen($dfile,0) StringTrimRight($dfile,4) FileWrite($baseloc & "\" & $dfile & $ext,$dPool) Next for $tFile In $db_files_a FileDelete($baseloc & "\" & $tFile) Next EndIf Case $Config_Font _Metro_MsgBox(0,"Choose your font","Only Font Name, Font Size and Font Weight are saved. Color must be set using the another feature in menu.") $selectfont = _ChooseFont($fontface,$fontsize,$fontcolor,$fontweight,"","","",$GUI) ; Output Reference ; "Font : $selectfont[2] ; "Size : $selectfont[3] ; "Weight : $selectfont[4] ;--------------------------- if @error Then ; Else IniWrite($cfgfile,"configuration","fontface",$selectfont[2]) IniWrite($cfgfile,"configuration","font size",$selectfont[3]) IniWrite($cfgfile,"configuration","font weight",$selectfont[4]) EndIf $fontface = IniRead($cfgfile,"configuration","fontface","Segoe UI") $fontsize = IniRead($cfgfile,"configuration","font size","10") $fontweight = IniRead($cfgfile,"configuration","font weight","400") GUICtrlSetFont($NoteContent,$fontsize,$fontweight,"",$fontface) GUICtrlSetFont($NoteTitle,"9.5",$fontweight,"",$fontface) GUICtrlSetFont($NoteDB,"9.5",$fontweight,"",$fontface) Case $Config_Bk $selectcolor = _ChooseColor(2,$backcolor,2,$GUI) IniWrite($cfgfile,"configuration","background color",$selectcolor) $backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") GUICtrlSetBkColor($NoteContent,$backcolor) GUICtrlSetBkColor($NoteTitle,$backcolor) GUICtrlSetBkColor($NoteDB,$backcolor) Case $Config_Bk_acc IniWrite($cfgfile,"configuration","background color",$CurrentAccent) $backcolor = IniRead($cfgfile,"configuration","background color","0xFFFFFF") GUICtrlSetBkColor($NoteContent,$backcolor) GUICtrlSetBkColor($NoteTitle,$backcolor) GUICtrlSetBkColor($NoteDB,$backcolor) Case $Config_Fk $selectcolor = _ChooseColor(2,$fontcolor,2,$GUI) IniWrite($cfgfile,"configuration","font color",$selectcolor) $fontcolor = IniRead($cfgfile,"configuration","font color","0xFFFFFF") GUICtrlSetColor($NoteContent,$fontcolor) GUICtrlSetColor($NoteTitle,$fontcolor) GUICtrlSetColor($NoteDB,$fontcolor) Case $Config_ChangeDatabaseLoc $selectdb = _WinAPI_BrowseForFolderDlg("","Select new DB location (move everything)",$BIF_USENEWUI,"","",$GUI) $sCheck = DirIsEmpty($selectdb) if $sCheck = 0 Then MsgBox(0+16,"Error","The folder is not empty." & @CRLF & "Select or create a new folder for that.") Else if $selectdb = @MyDocumentsDir or $selectdb = @AppDataDir or $selectdb = @LocalAppDataDir or $selectdb = @UserProfileDir Then MsgBox(0+16,"Error","The folder is a System/User PATH folder. It cannot be used for this purpose." & @CRLF & "Select or create a new folder for that.") Else If $sCheck = -1 Then DirCreate($selectdb) EndIf $db = $selectdb IniWrite($cfgfile,"configuration","database location",$db) FileCopy($baseloc,$db,1) Sleep(250) FileDelete($baseloc & "\*") MsgBox(0,"Success","Restarting Software...",3,$GUI) Run(@AutoItExe) Exit(0) EndIf EndIf Case $Archive_Export $target = _WinAPI_BrowseForFolderDlg("","Choose export location, Data are zipped using the current date-time") DateGet() $zipfile = $target & "\archive_" & @UserName & "_" & $CurrentTimeFormated & "_" & $CurrentDateFormated & ".zip" _Zip_Create($zipfile) $ArchivedNotes = _FileListToArray($baseloc & "\Archived","*.nota",1,False) for $Note in $ArchivedNotes _Zip_AddItem($zipfile,$baseloc & "\Archived\" & $Note,$target) Next EndSwitch WEnd Func DirIsEmpty($Dir) Local $Search, $i, $File If StringRight($Dir,1) <> "\" then $Dir = $Dir & "\" $Search = FileFindFirstFile($Dir & "*.*") If $Search = -1 Then Return -1 While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop $i= $i + 1 If $i > 2 then ExitLoop WEnd FileClose($Search) If $i = 2 then Return 1 EndFunc Func DBRefresh() GUICtrlSetData($NoteDB,"") Sleep(0.5) $db_notes = _FileListToArray($baseloc,"*.nota",1) _ArrayTrim($db_notes,5,1) $sdb_notes = _ArrayToString($db_notes) if $sdb_notes = "-1" Or $sdb_notes = -1 Then $sdb_notes = "" EndIf GUICtrlSetData($NoteDB,$sdb_notes) EndFunc Func DateGet() Global $CurrentTimeFormated,$CurrentDateFormated $CurrentTime = _NowTime(5) $CurrentTimeFormated = StringReplace($CurrentTime,":","-") $CurrentDate = _NowCalcDate() $CurrentDateFormated = StringReplace($CurrentDate,"/","-") EndFunc