Sign in to follow this  
Followers 0
EvAsion

Dynamic Timetable

13 posts in this topic

Its a dynamic timetable!

You can modify classes, class times, guisize, colours, its all easy - and it will allways look sexy!

Timetable.au3

#include <GUIConstants.au3>
#include <Array.au3>
#include <_ControlHover.au3>
#include <GuiDateTimePicker.au3>
#include <GuiReBar.au3>
#include <GuiConstantsEx.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#Include <GuiImageList.au3>
$guiheight = 525
$guiwidth = 707
$day = @WDAY
dim $weekarray[8]
dim $max[8]
dim $min[8]
dim $most[8]
Dim $daycontrol[8]
$weekarray[1] = "Sunday"
$weekarray[2] = "Monday"
$weekarray[3] = "Tuesday"
$weekarray[4] = "Wednesday"
$weekarray[5] = "Thursday"
$weekarray[6] = "Friday"
$weekarray[7] = "Saturday"
$change = 0
For $i = 2 to 6
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$i],"Time",""),",")
    ;_ArrayDisplay($Split)
    $min[$i] = _ArrayMin($Split,1,1) 
    ;msgbox(0,"",$min[$i])
    $max[$i] = _ArrayMax($Split,1,1)
    $most[$i] = $Split[0]
Next
For $i = 1 to UBound($min) - 1
    If $min[$i] = "" Then $min[$i] = 9999
Next
$EarliestStart = _ArrayMin($min,1,1)
$LatestFinish = _ArrayMax($max,1)
$MaxLines = _ArrayMax($most,1)

Dim $ClassSplit[100]
Dim $Ctrl[100][100]
;msgbox(0,"","Early: "&$EarliestStart & " Late:" & $LatestFinish & @CRLF & $MaxLines)
$AForm1 = GUICreate("Class Timetable - Today is "&$weekarray[$day] &", "&@MDAY&"/"&@MON&"/"&@YEAR, $guiwidth, $guiheight, -1, -1,-1)
$spacing = ((707-28)/5)-(1*5)
For $d = 2 to 6
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Time",""),",")
    $ClassSplit = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Order",""),",")
    Dim $split2[$Split[0] + 1]
    ;_ArrayDisplay($split)
    For $i = 1 to $MaxLines
        If $i = ($split[0]) then ExitLoop
        $Conversion = StringSplit($split[$i],".")
        ;_ArrayDisplay($Conversion)
        $convertedtime = ($Conversion[2]/60)*100
        ;msgbox(0,"",$split[$i] & "  "&$convertedtime)
        ;msgbox(0,"",$split[$i] & "  "&($Conversion[1]&"."&Round($convertedtime,0)))
        $split2[$i] = $Conversion[1]&"."&StringReplace($convertedtime,".","")
        
        $Conversion = StringSplit($split[$i+1],".")
        ;_ArrayDisplay($Conversion)
        $convertedtime = ($Conversion[2]/60)*100
        ;msgbox(0,"",$split[$i] & "  "&$convertedtime)
        ;msgbox(0,"",$split[$i] & "  "&($Conversion[1]&"."&Round($convertedtime,0)))
        $split2[$i+1] = $Conversion[1]&"."&StringReplace($convertedtime,".","")
        
        
        $y = Gen_Abs_Pix_y($split2[$i],$LatestFinish,$EarliestStart,$guiheight-45)
        $y2 = Gen_Abs_Pix_y($split2[($i+1)],$LatestFinish,$EarliestStart,$guiheight-45)
        
    
        $classheight = $y2 - $y
        
        ;msgbox(0,"",$classheight)
        ;$y3 = Gen_Abs_Pix_y($classheight,$LatestFinish,$EarliestStart,$guiheight-10)
        ;msgbox(0,"",$y & "  " & $y2 & @CRLF & $classheight & @CRLF & $y3)
        ;_ArrayDisplay($split)
        ;GUICtrlCreateGraphic(($spacing*$d)-($spacing*2)+(3*$d),$y,$spacing, $classheight)
        ;If $i <> ($split[0]) Then
        ;msgbox(0,"",$i)
        $Classlabel = $ClassSplit[$i]
        $Classname = IniRead("Classes.ini","Class"&$Classlabel,"Name",$Classlabel)
        $colour = IniRead("Classes.ini","Class"&$Classlabel,"Colour","0xFFFFFF")
        $textcolour = IniRead("Classes.ini","Class"&$Classlabel,"TextCol","0x000000")
        $daycontrol[$d] = GUICtrlCreateLabel($weekarray[$d],($spacing*$d)-($spacing*2)+(3*$d)+48,32,$spacing-40,18,BitOR($SS_CENTER,$WS_BORDER))
        If $d = $day Then GUICtrlSetBkColor(-1,0xFFDEAD)
        
        GUICtrlCreateLabel($split[$i],0,$y-5+40,28,12)
        $Ctrl[$i][$d] = GUICtrlCreateLabel($Classname,($spacing*$d)-($spacing*2)+(3*$d)+28,$y+40,$spacing, $classheight,BitOR($SS_CENTER,$WS_BORDER))
        _ControlHover (2, "", $Ctrl[$i][$d])
        ;Execute("$Ctrli"&$i&"d"&$d&" = GUICtrlCreateLabel($Classname,($spacing*$d)-($spacing*2)+(3*$d)+28,$y,$spacing, $classheight,BitOR($SS_CENTER,$WS_BORDER))")
        ;Execute("_ControlHover (2, "", $Ctrli"&$i&"d"&$d)
        GUICtrlSetFont(-1, 9, 800, 0, "Arial")
        GUICtrlSetColor(-1, $textcolour)
        GUICtrlSetBkColor(-1, $colour)
        ;GUICtrlSetBkColor(-1, 0xA0FFA0)
        GUISetState()
    Next    
Next


$GUI = GUICreate("AForm1", 241, 98, -1, -1, BitOR($WS_POPUPWINDOW, $WS_SYSMENU), -1, $AForm1)
GUISetBkColor(0xFFFFDD)
GUICtrlCreateGraphic(0, 0, 241, 29)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0x000000)
$WTITLE = GUICtrlCreateLabel("WTITLE", 8, 5, 226, 18)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)
$WDATA = GUICtrlCreateEdit("", 1, 29, 238, 194, BitOR($ES_READONLY, $ES_WANTRETURN), 0)
GUICtrlSetBkColor(-1, 0xFFFFDD)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)
;GUISetState(@SW_SHOW)

WinSetTrans($GUI, "", 242)
GUISetState(@SW_HIDE, $GUI)
Global $LastPos[2] = [0, 0]



#cs
; create the rebar control
    $hReBar = _GUICtrlReBar_Create($AForm1, BitOR($WS_BORDER, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($AForm1, 0, 0, 120)
; add band with date time picker
    ;_GUICtrlReBar_AddBand($hReBar, $hDTP, 120)


Dim Enum $id1 = 1000, $id2

$hGUI = GUICreate("Toolbar", 400, 300)
$hToolbar = _GUICtrlToolbar_Create($hGUI, BitOR($WS_BORDER, $RBS_AUTOSIZE, $RBS_BANDBORDERS),$TBSTYLE_EX_DRAWDDARROWS)

$hImage = _GUIImageList_Create(16, 16, 5, 3)

;$hToolTip = _GUIToolTip_Create($hToolbar, $TTS_ALWAYSTIP)
;_GUICtrlToolbar_SetToolTips($hToolbar, $hToolTip)

_GUIImageList_AddIcon($hImage,"PeriodicTable.ico")
;_GUIImageList_AddIcon($hImage, @AutoItExe, 0)
_GUIImageList_AddIcon($hImage, @AutoItExe, 1)

_GUICtrlToolbar_SetImageList($hToolbar, $hImage)

;$String1 = _GUICtrlToolbar_AddString($hToolbar, "Periodic Table")
;$String2 = _GUICtrlToolbar_AddString($hToolbar, "Close")

$button = _GUICtrlToolbar_AddButton($hToolbar, $id1, 0);,$String1)
_GUICtrlToolbar_AddButton($hToolbar, $id2, 1)
;_GUICtrlToolbar_AddButtonSep($hToolbar, 6)


 ;_GUICtrlToolbar_SetStyleFlat($hToolBar, True)

_GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar, "", 0)
_GUICtrlRebar_SetBandStyleBreak($hReBar, 1)
;_GUICtrlReBar_AddBand($hReBar, $button)
_GUICtrlReBar_AddBand($hReBar, $hDTP,120,Default,"",-1)
#ce



While 1
    $MousePos = MouseGetPos()
    $Over = _ControlHover (0, $AForm1)
    If $Over = 1 Then
        $tempID = @extended ;d = 2 to 6 i = 1 to 20
        If $tempID = 0 Then
            ;$tima = TimerInit()
            ;If $tima <> -1 and TimerDiff($tima) > 200 Then
            GUISetState(@SW_HIDE, $GUI)
            ;EndIf
        ElseIf $tempID = $Ctrl[1][2] Then
            $tima = -1
            _SetData(1,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][2] Then
            _SetData(2,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][2] Then
            _SetData(3,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][2] Then
            _SetData(4,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][2] Then
            _SetData(5,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][2] Then
            _SetData(6,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][2] Then
            _SetData(7,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][2] Then
            _SetData(8,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][2] Then
            _SetData(9,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][2] Then
            _SetData(10,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][2] Then
            _SetData(11,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][2] Then
            _SetData(12,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][3] Then
            _SetData(1,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][3] Then
            _SetData(2,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][3] Then
            _SetData(3,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][3] Then
            _SetData(4,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][3] Then
            _SetData(5,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][3] Then
            _SetData(6,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][3] Then
            _SetData(7,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][3] Then
            _SetData(8,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][3] Then
            _SetData(9,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][3] Then
            _SetData(10,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][3] Then
            _SetData(11,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][3] Then
            _SetData(12,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][4] Then
            _SetData(1,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][4] Then
            _SetData(2,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][4] Then
            _SetData(3,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][4] Then
            _SetData(4,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][4] Then
            _SetData(5,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][4] Then
            _SetData(6,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][4] Then
            _SetData(7,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][4] Then
            _SetData(8,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][4] Then
            _SetData(9,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][4] Then
            _SetData(10,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][4] Then
            _SetData(11,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][4] Then
            _SetData(12,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][5] Then
            _SetData(1,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][5] Then
            _SetData(2,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][5] Then
            _SetData(3,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][5] Then
            _SetData(4,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][5] Then
            _SetData(5,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][5] Then
            _SetData(6,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][5] Then
            _SetData(7,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][5] Then
            _SetData(8,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][5] Then
            _SetData(9,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][5] Then
            _SetData(10,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][5] Then
            _SetData(11,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][5] Then
            _SetData(12,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][6] Then
            _SetData(1,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][6] Then
            _SetData(2,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][6] Then
            _SetData(3,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][6] Then
            _SetData(4,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][6] Then
            _SetData(5,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][6] Then
            _SetData(6,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][6] Then
            _SetData(7,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][6] Then
            _SetData(8,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][6] Then
            _SetData(9,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][6] Then
            _SetData(10,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][6] Then
            _SetData(11,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][6] Then
            _SetData(12,6)
            GUISetState(@SW_SHOWNA, $GUI)
        Else
            GUISetState(@SW_HIDE, $GUI)
        EndIf
    EndIf
    If ($LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1]) Then
        WinMove($GUI, "", $MousePos[0] + 15, $MousePos[1] + 15)
        $LastPos[0] = $MousePos[0]
        $LastPos[1] = $MousePos[1]
        ;Sleep(10)
    EndIf
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exitloop
    EndSelect
WEnd


Func _SetData($i,$d)
    ;Global $tima = -1
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Time",""),",")
    $ClassSplit = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Order",""),",")
    If $i <= $ClassSplit[0] Then
        $Classlabel = $ClassSplit[$i]
        $Classname = IniRead("Classes.ini","Class"&$Classlabel,"Name",$Classlabel)
    ;If $change = 0 Then WinMove($Gui,"",Default,Default,241,98)
    GUICtrlSetData($WTITLE, $Classname)
    GUICtrlSetData($WDATA, "Teacher: "&IniRead("Classes.ini","Class"&$Classlabel,"Teacher","")&@CRLF&"Description: "&IniRead("Classes.ini","Class"&$Classlabel,"Description",""))
    EndIf

EndFunc   ;==>_SetElementData

func Gen_Abs_Pix_x($x,$low,$high,$width)
    $out = (($width/($high-$low))*(($high-$low)*(($x-$low)/($high-$low))))
    Return $out
EndFunc
func Gen_Abs_Pix_y($y,$low,$high,$height)
    $out = ($height - (($height/($high-$low))*(($high-$low)*(($y-$low)/($high-$low)))))
    Return $out
EndFunc

#cs
Func AddLink($path,$icon)
    ;Allow for custom links (internet explorer, whatever) definable in ini
EndFunc
#ce

Ini file(Classes.ini):

[Monday]
Time=8.40,9.25,10.10,10.55,11.15,12.00,12.15,13.00,13.40,14.25,15.10,17.00
Order=A,B,C,Recess,D,SG,E,Lunch,F,G,Executive Cool Time
[Tuesday]
Time=8.40,9.40,10.40,11.00,12.00,13.00,13.40,14.40,15.40,17.00
Order=F,D,Recess,C,B,Lunch,G,E,Staff Meeting Time
[Wednesday]
Time=8.40,9.40,10.40,11.00,12.00,13.00,13.40,14.40,15.40
Order=B,F,Recess,D,G,Lunch,C,A
[Thursday]
Time=8.40,9.40,10.40,11.00,12.00,13.00,13.40,15.40
Order=G,E,Recess,A,D,Lunch,H
[Friday]
Time=8.40,9.40,10.40,11.00,12.00,13.00,13.40,14.40,15.40
Order=C,A,Recess,E,F,Lunch,B,Staff Admin Time
[ClassA]
Colour=0xC0FFFF
Name = Mega Maths 1
Teacher = Mr Rofl
Assessment = RandomOral,12/7/08;Test,31/7/08
Description = Mega Maths 1, T package Double Majoring
[ClassB]
Colour=0xEEEEEE
Teacher = 
Name = Free Line
[ClassC]
Colour=0xFF6666
Name = Intro English
Teacher = Ms Lawl
Description = Minoring, cause i suck at english
[ClassD]
Colour=0xA0FFA0
Name = Introductory Chemistry
Teacher = Mr Science Nerd
Description = Topping, cause i own
[ClassE]
Colour=0xFFBFFF
Name = Mega Maths 5
Teacher = Mr Maths
Description = Mega Maths 5, T package Double Majorin
[ClassF]
Colour=0xFFFF99
Name = Cad
Teacher = Ms Doughy
Description = 2.7 z score in test, i win.
[ClassG]
Colour=0xFF99CC
Name = Intro Physics
Teacher = Mr Optics
Description = 2nd, fail train.
[ClassH]
Colour=0xEEEEEE
Name = Free Line
Teacher = 
Description = 
[ClassExecutive Cool Time]
Colour=0xFFFFFF
Name = Executive Cool Time
[ClassStaff Meeting Time]
Colour=0xFFFFFF
Name = Staff Meeting Time
[ClassStaff Admin Time]
Colour=0xFFFFFF
Name = Staff Admin Time
[ClassRecess]
Colour=0x000000
TextCol=0xFFFFFF
Name = Recess
[ClassLunch]
Colour=0x000000
TextCol=0xFFFFFF
Name = Lunch

Screenshot:

Posted Image

Share this post


Link to post
Share on other sites



nice

Share this post


Link to post
Share on other sites

Nice breakout from the periodic table.. LOL Good idea..

Share this post


Link to post
Share on other sites

Any plans to add a GUI to update/edit/change the ini like an appointment book or alendar of events?

Share this post


Link to post
Share on other sites

Any plans to add a GUI to update/edit/change the ini like an appointment book or alendar of events?

That was my original plan, but i realised that the MonthCal control isn't very dynamic. I'm going to try and develop my own calendar system where i can highlight dates, etc. etc.

Share this post


Link to post
Share on other sites

Sounds great! Hope to see it when your done? :)

Share this post


Link to post
Share on other sites

And where to get _ControlHover.au3?

Share this post


Link to post
Share on other sites

I did a "Forums" search on the word ControlHover, and many results came up. >Here is the only one I briefly looked at, it might be what you are after, but in any case, you have plenty of others to check.

Remembering of course, that the program you are interested in, may have issues with later versions of AutoIt etc.

Going back that far in time, you may have great difficulty getting things to work now, unless you know what you are doing, but someone on GH&S may be able to help you, if so.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

>This might be a better place to get it? wrong UDF

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Okay, this works...

#include <GUIConstants.au3>
#include <Array.au3>

; added the following code
;#include <_ControlHover.au3>
#include "_ControlHover.au3"
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
;

#include <GuiDateTimePicker.au3>
#include <GuiReBar.au3>
#include <GuiConstantsEx.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#Include <GuiImageList.au3>
$guiheight = 525
$guiwidth = 707
$day = @WDAY
dim $weekarray[8]
dim $max[8]
dim $min[8]
dim $most[8]
Dim $daycontrol[8]
$weekarray[1] = "Sunday"
$weekarray[2] = "Monday"
$weekarray[3] = "Tuesday"
$weekarray[4] = "Wednesday"
$weekarray[5] = "Thursday"
$weekarray[6] = "Friday"
$weekarray[7] = "Saturday"
$change = 0
For $i = 2 to 6
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$i],"Time",""),",")
    ;_ArrayDisplay($Split)
    $min[$i] = _ArrayMin($Split,1,1)
    ;msgbox(0,"",$min[$i])
    $max[$i] = _ArrayMax($Split,1,1)
    $most[$i] = $Split[0]
Next
For $i = 1 to UBound($min) - 1
    If $min[$i] = "" Then $min[$i] = 9999
Next
$EarliestStart = _ArrayMin($min,1,1)
$LatestFinish = _ArrayMax($max,1)
$MaxLines = _ArrayMax($most,1)

Dim $ClassSplit[100]
Dim $Ctrl[100][100]
;msgbox(0,"","Early: "&$EarliestStart & " Late:" & $LatestFinish & @CRLF & $MaxLines)
$AForm1 = GUICreate("Class Timetable - Today is "&$weekarray[$day] &", "&@MDAY&"/"&@MON&"/"&@YEAR, $guiwidth, $guiheight, -1, -1,-1)
$spacing = ((707-28)/5)-(1*5)
For $d = 2 to 6
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Time",""),",")
    $ClassSplit = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Order",""),",")
    Dim $split2[$Split[0] + 1]
    ;_ArrayDisplay($split)
    For $i = 1 to $MaxLines
        If $i = ($split[0]) then ExitLoop
        $Conversion = StringSplit($split[$i],".")
        ;_ArrayDisplay($Conversion)
        $convertedtime = ($Conversion[2]/60)*100
        ;msgbox(0,"",$split[$i] & "  "&$convertedtime)
        ;msgbox(0,"",$split[$i] & "  "&($Conversion[1]&"."&Round($convertedtime,0)))
        $split2[$i] = $Conversion[1]&"."&StringReplace($convertedtime,".","")

        $Conversion = StringSplit($split[$i+1],".")
        ;_ArrayDisplay($Conversion)
        $convertedtime = ($Conversion[2]/60)*100
        ;msgbox(0,"",$split[$i] & "  "&$convertedtime)
        ;msgbox(0,"",$split[$i] & "  "&($Conversion[1]&"."&Round($convertedtime,0)))
        $split2[$i+1] = $Conversion[1]&"."&StringReplace($convertedtime,".","")


        $y = Gen_Abs_Pix_y($split2[$i],$LatestFinish,$EarliestStart,$guiheight-45)
        $y2 = Gen_Abs_Pix_y($split2[($i+1)],$LatestFinish,$EarliestStart,$guiheight-45)


        $classheight = $y2 - $y

        ;msgbox(0,"",$classheight)
        ;$y3 = Gen_Abs_Pix_y($classheight,$LatestFinish,$EarliestStart,$guiheight-10)
        ;msgbox(0,"",$y & "  " & $y2 & @CRLF & $classheight & @CRLF & $y3)
        ;_ArrayDisplay($split)
        ;GUICtrlCreateGraphic(($spacing*$d)-($spacing*2)+(3*$d),$y,$spacing, $classheight)
        ;If $i <> ($split[0]) Then
        ;msgbox(0,"",$i)
        $Classlabel = $ClassSplit[$i]
        $Classname = IniRead("Classes.ini","Class"&$Classlabel,"Name",$Classlabel)
        $colour = IniRead("Classes.ini","Class"&$Classlabel,"Colour","0xFFFFFF")
        $textcolour = IniRead("Classes.ini","Class"&$Classlabel,"TextCol","0x000000")
        $daycontrol[$d] = GUICtrlCreateLabel($weekarray[$d],($spacing*$d)-($spacing*2)+(3*$d)+48,32,$spacing-40,18,BitOR($SS_CENTER,$WS_BORDER))
        If $d = $day Then GUICtrlSetBkColor(-1,0xFFDEAD)

        GUICtrlCreateLabel($split[$i],0,$y-5+40,28,12)
        $Ctrl[$i][$d] = GUICtrlCreateLabel($Classname,($spacing*$d)-($spacing*2)+(3*$d)+28,$y+40,$spacing, $classheight,BitOR($SS_CENTER,$WS_BORDER))
        _ControlHover (2, "", $Ctrl[$i][$d])
        ;Execute("$Ctrli"&$i&"d"&$d&" = GUICtrlCreateLabel($Classname,($spacing*$d)-($spacing*2)+(3*$d)+28,$y,$spacing, $classheight,BitOR($SS_CENTER,$WS_BORDER))")
        ;Execute("_ControlHover (2, "", $Ctrli"&$i&"d"&$d)
        GUICtrlSetFont(-1, 9, 800, 0, "Arial")
        GUICtrlSetColor(-1, $textcolour)
        GUICtrlSetBkColor(-1, $colour)
        ;GUICtrlSetBkColor(-1, 0xA0FFA0)
        GUISetState()
    Next
Next


$GUI = GUICreate("AForm1", 241, 98, -1, -1, BitOR($WS_POPUPWINDOW, $WS_SYSMENU), -1, $AForm1)
GUISetBkColor(0xFFFFDD)
GUICtrlCreateGraphic(0, 0, 241, 29)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0x000000)
$WTITLE = GUICtrlCreateLabel("WTITLE", 8, 5, 226, 18)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)
$WDATA = GUICtrlCreateEdit("", 1, 29, 238, 194, BitOR($ES_READONLY, $ES_WANTRETURN), 0)
GUICtrlSetBkColor(-1, 0xFFFFDD)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)
;GUISetState(@SW_SHOW)

WinSetTrans($GUI, "", 242)
GUISetState(@SW_HIDE, $GUI)
Global $LastPos[2] = [0, 0]



#cs
; create the rebar control
    $hReBar = _GUICtrlReBar_Create($AForm1, BitOR($WS_BORDER, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($AForm1, 0, 0, 120)
; add band with date time picker
    ;_GUICtrlReBar_AddBand($hReBar, $hDTP, 120)


Dim Enum $id1 = 1000, $id2

$hGUI = GUICreate("Toolbar", 400, 300)
$hToolbar = _GUICtrlToolbar_Create($hGUI, BitOR($WS_BORDER, $RBS_AUTOSIZE, $RBS_BANDBORDERS),$TBSTYLE_EX_DRAWDDARROWS)

$hImage = _GUIImageList_Create(16, 16, 5, 3)

;$hToolTip = _GUIToolTip_Create($hToolbar, $TTS_ALWAYSTIP)
;_GUICtrlToolbar_SetToolTips($hToolbar, $hToolTip)

_GUIImageList_AddIcon($hImage,"PeriodicTable.ico")
;_GUIImageList_AddIcon($hImage, @AutoItExe, 0)
_GUIImageList_AddIcon($hImage, @AutoItExe, 1)

_GUICtrlToolbar_SetImageList($hToolbar, $hImage)

;$String1 = _GUICtrlToolbar_AddString($hToolbar, "Periodic Table")
;$String2 = _GUICtrlToolbar_AddString($hToolbar, "Close")

$button = _GUICtrlToolbar_AddButton($hToolbar, $id1, 0);,$String1)
_GUICtrlToolbar_AddButton($hToolbar, $id2, 1)
;_GUICtrlToolbar_AddButtonSep($hToolbar, 6)


 ;_GUICtrlToolbar_SetStyleFlat($hToolBar, True)

_GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar, "", 0)
_GUICtrlRebar_SetBandStyleBreak($hReBar, 1)
;_GUICtrlReBar_AddBand($hReBar, $button)
_GUICtrlReBar_AddBand($hReBar, $hDTP,120,Default,"",-1)
#ce



While 1
    $MousePos = MouseGetPos()
    $Over = _ControlHover (0, $AForm1)
    If $Over = 1 Then
        $tempID = @extended ;d = 2 to 6 i = 1 to 20
        If $tempID = 0 Then
            ;$tima = TimerInit()
            ;If $tima <> -1 and TimerDiff($tima) > 200 Then
            GUISetState(@SW_HIDE, $GUI)
            ;EndIf
        ElseIf $tempID = $Ctrl[1][2] Then
            $tima = -1
            _SetData(1,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][2] Then
            _SetData(2,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][2] Then
            _SetData(3,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][2] Then
            _SetData(4,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][2] Then
            _SetData(5,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][2] Then
            _SetData(6,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][2] Then
            _SetData(7,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][2] Then
            _SetData(8,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][2] Then
            _SetData(9,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][2] Then
            _SetData(10,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][2] Then
            _SetData(11,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][2] Then
            _SetData(12,2)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][3] Then
            _SetData(1,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][3] Then
            _SetData(2,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][3] Then
            _SetData(3,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][3] Then
            _SetData(4,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][3] Then
            _SetData(5,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][3] Then
            _SetData(6,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][3] Then
            _SetData(7,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][3] Then
            _SetData(8,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][3] Then
            _SetData(9,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][3] Then
            _SetData(10,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][3] Then
            _SetData(11,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][3] Then
            _SetData(12,3)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][4] Then
            _SetData(1,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][4] Then
            _SetData(2,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][4] Then
            _SetData(3,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][4] Then
            _SetData(4,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][4] Then
            _SetData(5,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][4] Then
            _SetData(6,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][4] Then
            _SetData(7,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][4] Then
            _SetData(8,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][4] Then
            _SetData(9,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][4] Then
            _SetData(10,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][4] Then
            _SetData(11,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][4] Then
            _SetData(12,4)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][5] Then
            _SetData(1,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][5] Then
            _SetData(2,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][5] Then
            _SetData(3,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][5] Then
            _SetData(4,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][5] Then
            _SetData(5,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][5] Then
            _SetData(6,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][5] Then
            _SetData(7,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][5] Then
            _SetData(8,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][5] Then
            _SetData(9,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][5] Then
            _SetData(10,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][5] Then
            _SetData(11,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][5] Then
            _SetData(12,5)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[1][6] Then
            _SetData(1,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[2][6] Then
            _SetData(2,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[3][6] Then
            _SetData(3,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[4][6] Then
            _SetData(4,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[5][6] Then
            _SetData(5,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[6][6] Then
            _SetData(6,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[7][6] Then
            _SetData(7,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[8][6] Then
            _SetData(8,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[9][6] Then
            _SetData(9,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[10][6] Then
            _SetData(10,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[11][6] Then
            _SetData(11,6)
            GUISetState(@SW_SHOWNA, $GUI)
        ElseIf $tempID = $Ctrl[12][6] Then
            _SetData(12,6)
            GUISetState(@SW_SHOWNA, $GUI)
        Else
            GUISetState(@SW_HIDE, $GUI)
        EndIf
    EndIf
    If ($LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1]) Then
        WinMove($GUI, "", $MousePos[0] + 15, $MousePos[1] + 15)
        $LastPos[0] = $MousePos[0]
        $LastPos[1] = $MousePos[1]
        ;Sleep(10)
    EndIf
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exitloop
    EndSelect
WEnd


Func _SetData($i,$d)
    ;Global $tima = -1
    $Split = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Time",""),",")
    $ClassSplit = StringSplit(IniRead("Classes.ini",$weekarray[$d],"Order",""),",")
    If $i <= $ClassSplit[0] Then
        $Classlabel = $ClassSplit[$i]
        $Classname = IniRead("Classes.ini","Class"&$Classlabel,"Name",$Classlabel)
    ;If $change = 0 Then WinMove($Gui,"",Default,Default,241,98)
    GUICtrlSetData($WTITLE, $Classname)
    GUICtrlSetData($WDATA, "Teacher: "&IniRead("Classes.ini","Class"&$Classlabel,"Teacher","")&@CRLF&"Description: "&IniRead("Classes.ini","Class"&$Classlabel,"Description",""))
    EndIf

EndFunc   ;==>_SetElementData

func Gen_Abs_Pix_x($x,$low,$high,$width)
    $out = (($width/($high-$low))*(($high-$low)*(($x-$low)/($high-$low))))
    Return $out
EndFunc
func Gen_Abs_Pix_y($y,$low,$high,$height)
    $out = ($height - (($height/($high-$low))*(($high-$low)*(($y-$low)/($high-$low)))))
    Return $out
EndFunc

#cs
Func AddLink($path,$icon)
    ;Allow for custom links (internet explorer, whatever) definable in ini
EndFunc
#ce

But you need to download >_ControlHover.au3

EDIT, plus you need the classes.ini from the OP

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0