# Path: debug.py
# def debug(level,text,DEBUG,bindir):
#     try:
#         if bindir == False or level <= 0:
#             print("DEBUG: %s" % (text))
#             return False
#         bindir = os.getcwd()
#         if bindir.endswith("system32"):
#             if os.path.exists(devdir()):
#                 bindir=devdir()
#             else:
#                 print("DEBUG: %s" % (text))
#                 return False
#         
#         logfile = "%s\\client_debug.log" % (bindir)
#         global DEBUGcount
#         global DEBUGfrombefore
#         
#         if level > LOGLEVEL:
#             if not level in LOGLEVELS:
#                 return False
#         
#         timefromboot = round(time.time() - BOOTTIME,3)
#         tempdebuglist = list()
#         if DEBUGcount > 0 and not DEBUGfrombefore == text:
#             debugstringsht1 = "(%s):(d1) %s (repeat: %s)" % (timefromboot, DEBUGfrombefore,DEBUGcount)
#             debugstringsht2 = "(%s):(d2) %s" % (timefromboot,text)
#             tempdebuglist.append(debugstringsht1)
#             tempdebuglist.append(debugstringsht2)
#             DEBUGcount = 0
#         elif DEBUGcount >= 4096 and DEBUGfrombefore == text:
#             debugstringsht = "(%s):(d3) %s (repeated: %s e2)" % (timefromboot, DEBUGfrombefore,DEBUGcount)
#             tempdebuglist.append(debugstringsht)
#             DEBUGcount = 0
#         elif DEBUGfrombefore == text:
#             DEBUGcount += 1
#             return
#         elif not DEBUGfrombefore == text:
#             debugstringsht = "(%s):(d4) %s"%(timefromboot,text)
#             tempdebuglist.append(debugstringsht)
#         DEBUGfrombefore = text
#         if len(tempdebuglist) > 0:
#             for entry in tempdebuglist:
#                 print(entry)
#                 debug_cache(entry,'add')
#                 if DEBUG == True:
#                     write_debug(level,entry,timefromboot,logfile)
#     except Exception as e:
#         print("[debug.py] debug failed, exception = '%s'" % (e))


from debug import debug
from win32api import GetSystemMetrics, GetModuleHandle, PostQuitMessage, LoadResource
from win32con import CW_USEDEFAULT, IMAGE_ICON, IMAGE_BITMAP, IDI_INFORMATION, IDI_APPLICATION, LR_DEFAULTSIZE, LR_DEFAULTCOLOR, LR_LOADFROMFILE, WM_DESTROY, WS_OVERLAPPED, WS_SYSMENU, WM_USER, RT_ICON
from win32gui import CreateWindow, DestroyWindow, LoadIcon, LoadImage, NIF_ICON, NIF_INFO, NIF_MESSAGE, NIF_TIP, NIM_ADD, NIM_DELETE, NIM_MODIFY, RegisterClass, UnregisterClass, Shell_NotifyIcon, UpdateWindow, WNDCLASS
import os, platform, threading, ctypes
            style = WS_OVERLAPPED | WS_SYSMENU
            self.hwnd = CreateWindow(self.classAtom, "Taskbar", style,0, 0, CW_USEDEFAULT,CW_USEDEFAULT,0, 0, self.hinst, None)
            UpdateWindow(self.hwnd)

            try:
                if WINVER10 == False:
                    raise Exception
                """ https://msdn.microsoft.com/en-us/library/windows/desktop/ms648060(v=vs.85).aspx """
                icon_res = LoadResource(None, RT_ICON, 13)
                hicon = ctypes.windll.user32.CreateIconFromResourceEx(icon_res, len(icon_res), True, 0x00030000, 48, 48, LR_DEFAULTCOLOR)
                debug(1,"[win_notification.py] def send_notify: CreateIconFromResource() #1",DEBUG,True)

            except Exception as e:
                debug(222,"[win_notification.py] def send_notify: CreateIconFromResource() #1 failed, exception = '%s'"%(e),DEBUG,True)

                try:
                    if WINVER10 == False:
                        raise Exception
                    icon_path = False
                    icon_path1 = "%s\\else\\app_icons\\app_icon.ico" % (DEV_DIR)
                    files = [ icon_path1 ]
                    for file in files:
                            if os.path.isfile(file):
                                icon_path = file
                                break
                    if icon_path == False:
                        raise Exception
                    icon_flags = LR_LOADFROMFILE | LR_DEFAULTSIZE
                    """ https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx """
                    hicon = LoadImage(self.hinst, icon_path,IMAGE_ICON, 48, 48, icon_flags)

# Path: debug.py
# def debug(level,text,DEBUG,bindir):
#     try:
#         if bindir == False or level <= 0:
#             print("DEBUG: %s" % (text))
#             return False
#         bindir = os.getcwd()
#         if bindir.endswith("system32"):
#             if os.path.exists(devdir()):
#                 bindir=devdir()
#             else:
#                 print("DEBUG: %s" % (text))
#                 return False
#         
#         logfile = "%s\\client_debug.log" % (bindir)
#         global DEBUGcount
#         global DEBUGfrombefore
#         
#         if level > LOGLEVEL:
#             if not level in LOGLEVELS:
#                 return False
#         
#         timefromboot = round(time.time() - BOOTTIME,3)
#         tempdebuglist = list()
#         if DEBUGcount > 0 and not DEBUGfrombefore == text:
#             debugstringsht1 = "(%s):(d1) %s (repeat: %s)" % (timefromboot, DEBUGfrombefore,DEBUGcount)
#             debugstringsht2 = "(%s):(d2) %s" % (timefromboot,text)
#             tempdebuglist.append(debugstringsht1)
#             tempdebuglist.append(debugstringsht2)
#             DEBUGcount = 0
#         elif DEBUGcount >= 4096 and DEBUGfrombefore == text:
#             debugstringsht = "(%s):(d3) %s (repeated: %s e2)" % (timefromboot, DEBUGfrombefore,DEBUGcount)
#             tempdebuglist.append(debugstringsht)
#             DEBUGcount = 0
#         elif DEBUGfrombefore == text:
#             DEBUGcount += 1
#             return
#         elif not DEBUGfrombefore == text:
#             debugstringsht = "(%s):(d4) %s"%(timefromboot,text)
#             tempdebuglist.append(debugstringsht)
#         DEBUGfrombefore = text
#         if len(tempdebuglist) > 0:
#             for entry in tempdebuglist:
#                 print(entry)
#                 debug_cache(entry,'add')
#                 if DEBUG == True:
#                     write_debug(level,entry,timefromboot,logfile)
#     except Exception as e:
#         print("[debug.py] debug failed, exception = '%s'" % (e))


# Path: win_notification.py
from debug import debug
from win32api import GetSystemMetrics, GetModuleHandle, PostQuitMessage, LoadResource
from win32con import CW_USEDEFAULT, IMAGE_ICON, IMAGE_BITMAP, IDI_INFORMATION, IDI_APPLICATION, LR_DEFAULTSIZE, LR_DEFAULTCOLOR, LR_LOADFROMFILE, WM_DESTROY, WS_OVERLAPPED, WS_SYSMENU, WM_USER, RT_ICON
from win32gui import CreateWindow, DestroyWindow, LoadIcon, LoadImage, NIF_ICON, NIF_INFO, NIF_MESSAGE, NIF_TIP, NIM_ADD, NIM_DELETE, NIM_MODIFY, RegisterClass, UnregisterClass, Shell_NotifyIcon, UpdateWindow, WNDCLASS
import os, platform, threading, ctypes

            style = WS_OVERLAPPED | WS_SYSMENU
            self.hwnd = CreateWindow(self.classAtom, "Taskbar", style,0, 0, CW_USEDEFAULT,CW_USEDEFAULT,0, 0, self.hinst, None)
            UpdateWindow(self.hwnd)

            try:
                if WINVER10 == False:
                    raise Exception
                """ https://msdn.microsoft.com/en-us/library/windows/desktop/ms648060(v=vs.85).aspx """
                icon_res = LoadResource(None, RT_ICON, 13)
                hicon = ctypes.windll.user32.CreateIconFromResourceEx(icon_res, len(icon_res), True, 0x00030000, 48, 48, LR_DEFAULTCOLOR)
                debug(1,"[win_notification.py] def send_notify: CreateIconFromResource() #1",DEBUG,True)

            except Exception as e:
                debug(222,"[win_notification.py] def send_notify: CreateIconFromResource() #1 failed, exception = '%s'"%(e),DEBUG,True)

                try:
                    if WINVER10 == False:
                        raise Exception
                    icon_path = False
                    icon_path1 = "%s\\else\\app_icons\\app_icon.ico" % (DEV_DIR)
                    files = [ icon_path1 ]
                    for file in files:
                            if os.path.isfile(file):
                                icon_path = file
                                break
                    if icon_path == False:
                        raise Exception
                    icon_flags = LR_LOADFROMFILE | LR_DEFAULTSIZE
                    """ https://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx """
                    hicon = LoadImage(self.hinst, icon_path,IMAGE_ICON, 48, 48, icon_flags)

                    debug(1,"[win_notification.py] def send_notify: LoadImage() #2",DEBUG,True)