Hey Leute
ich habe ja schon ein Skript zu einem Taschenrechner gepostet.
Jetzt wollte ich den Graphenzeichner von Stayawayknight einfügen aber so ganz klappt das noch nicht:(
Spoiler anzeigen
#include<GuiConstantsEx.au3>
#include<WindowsConstants.au3>
#include<EditConstants.au3>
#include<ButtonConstants.au3>
#include<SliderConstants.au3>
#include<GuiSlider.au3>
#include<Misc.au3>
#include<GDIPlus.au3>
#include<SliderConstants.au3>
#include<GuiListView.au3>
#include<Array.au3>
Dim $Control[39]
Global $speichervar
$Taschenrechner = GUICreate("Taschenrechner",580,370,-1,-1,$WS_POPUP)
GUISetBkColor(0x000000)
$verschiebungscontrol=GUICtrlCreateLabel("",0,0,520,40,"",$GUI_WS_EX_PARENTDRAG)
$bClose = GUICtrlCreateButton("X",550,10,20,20)
$bMinimize = GUICtrlCreateButton("_",520,10,20,20)
$input = GUICtrlCreateInput("",10,40,560,50)
GUICtrlSetFont($input,30,1000)
GUICtrlSetBkColor($input,0xFFFFAA)
$Control[1] = GUICtrlCreateButton("GTR",10,100,130,95)
$Control[3] = GUICtrlCreateButton("ASin",150,100,60,40)
$Control[4] = GUICtrlCreateButton("ACos",220,100,60,40)
$Control[5] = GUICtrlCreateButton("AC",300,100,60,40)
$Control[6] = GUICtrlCreateButton("(-)",370,100,60,40)
$Control[7] = GUICtrlCreateButton("÷",440,100,60,40)
$Control[8] = GUICtrlCreateButton("x",510,100,60,40)
$Control[11] = GUICtrlCreateButton("ATan",150,155,60,40)
$Control[12] = GUICtrlCreateButton("%",220,155,60,40)
$Control[13] = GUICtrlCreateButton("7",300,155,60,40)
$Control[14] = GUICtrlCreateButton("8",370,155,60,40)
$Control[15] = GUICtrlCreateButton("9",440,155,60,40)
$Control[16] = GUICtrlCreateButton("-",510,155,60,40)
$Control[17] = GUICtrlCreateButton("(",10,210,60,40)
$Control[18] = GUICtrlCreateButton(")",80,210,60,40)
$Control[19] = GUICtrlCreateButton("Sqrt",150,210,60,40)
$Control[20] = GUICtrlCreateButton("Sqrt³",220,210,60,40)
$Control[21] = GUICtrlCreateButton("4",300,210,60,40)
$Control[22] = GUICtrlCreateButton("5",370,210,60,40)
$Control[23] = GUICtrlCreateButton("6",440,210,60,40)
$Control[24] = GUICtrlCreateButton("+",510,210,60,40)
$Control[25] = GUICtrlCreateButton("x²",10,265,60,40)
$Control[26] = GUICtrlCreateButton("x³",80,265,60,40)
$Control[27] = GUICtrlCreateButton("xª",150,265,60,40)
$Control[28] = GUICtrlCreateButton("Pi",220,265,60,40)
$Control[29] = GUICtrlCreateButton("1",300,265,60,40)
$Control[30] = GUICtrlCreateButton("2",370,265,60,40)
$Control[31] = GUICtrlCreateButton("3",440,265,60,40)
$Control[32] = GUICtrlCreateButton("=",510,265,60,95)
$Control[33] = GUICtrlCreateButton("Sin",10,320,60,40)
$Control[34] = GUICtrlCreateButton("Cos",80,320,60,40)
$Control[35] = GUICtrlCreateButton("Tan",150,320,60,40)
$Control[36] = GUICtrlCreateButton("Ans",220,320,60,40)
$Control[37] = GUICtrlCreateButton("0",300,320,130,40)
$Control[38] = GUICtrlCreateButton(",",440,320,60,40)
For $i=1 To 38 Step 1
GUICtrlSetFont($Control[$i],20,800)
Next
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
While 1
$inputRead1 = GUICtrlRead($input)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $bClose
Exit
Case $bMinimize
GUISetState(@SW_MINIMIZE)
Case $Control[1]
GTR()
Case $Control[3]
_setdata("ASin(")
Case $Control[4]
_setdata("ACos(")
Case $Control[5]
GUICtrlSetData($input,"")
Case $Control[6]
GUICtrlSetData($input,"-"&$inputRead1)
Case $Control[8]
_setdata("*")
Case $Control[7]
_setdata("/")
Case $Control[11]
_setdata("ATan(")
Case $Control[12]
$zwischenvar = Execute(GUICtrlRead($input)/100)
GUICtrlSetData($input,$zwischenvar)
Case $Control[13]
_setdata("7")
Case $Control[14]
_setdata("8")
Case $Control[15]
_setdata("9")
Case $Control[16]
_setdata("-")
Case $Control[17]
_setdata("(")
Case $Control[18]
_setdata(")")
Case $Control[19]
_setdata("sqrt(")
Case $Control[20]
_setdata(" ^ (1/3)")
Case $Control[21]
_setdata("4")
Case $Control[22]
_setdata("5")
Case $Control[23]
_setdata("6")
Case $Control[24]
_setdata("+")
Case $Control[25]
_setdata("^2")
Case $Control[26]
_setdata("^3")
Case $Control[27]
_setdata(" ^ ")
Case $Control[28]
_setdata("3,1416")
Case $Control[29]
_setdata("1")
Case $Control[30]
_setdata("2")
Case $Control[31]
_setdata("3")
Case $Control[32]
_rechnen()
Case $Control[33]
_setdata("sin(")
Case $Control[34]
_setdata("Cos(")
Case $Control[35]
_setdata("Tan(")
Case $Control[36]
_setdata($speichervar)
Case $Control[37]
_setdata("0")
Case $Control[38]
_setdata(".")
EndSwitch
WEnd
Func _rechnen()
$output = Execute(GUICtrlRead($input))
$speichervar = $output
GUICtrlSetData($input,"="&$output)
EndFunc
Func _setdata($data1)
GUICtrlSetData($input,$inputRead1&$data1)
EndFunc
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode, $nID
$nNotifyCode = BitShift($wParam, 16)
$nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case $input
Switch $nNotifyCode
Case $EN_SETFOCUS
GUICtrlSendMsg($input, $EM_SETSEL, 0, -1)
GUICtrlSetState($input, $GUI_FOCUS)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func GTR()
GUIDelete($Taschenrechner)
;###User Options Start
$sCoordfarbe = "0xFF800000" ;Gitterfarbe in ARGB
$sGridColor = "0xFF99FFFF" ;Koordinatensystemfarbe in ARGB
$sBackgroundcolor = "0x000000" ;Hintergrundfarbe in RGB
$sXColor = "0xFFFFFFFF" ;Farbe der X, die beim Klicken erscheinen in ARGB
$iLineWidth = 6 ;Graphenlinienbreite
;###User Options Ende
;###Options Start
Opt("GuiOnEventMode", 1)
HotKeySet("{ESC}", "ende")
OnAutoItExitRegister("ende")
Const $iNullx = Round((@DesktopWidth - 200) / 2)
Const $iNully = Round((@DesktopHeight - 200) / 2)
$sTitle = "Funktionsgraph"
$sTitle2 = "Einstellungsmenü"
$bDrawed = False
;###Options Ende
;###Gui Start
$hGui = GUICreate($sTitle, @DesktopWidth - 200, @DesktopHeight - 200, 100, 100)
GUISetBkColor($sBackgroundcolor, $hGui)
GUISetState(@SW_SHOW, $hGui)
;Neue Gui:
$hSettings = GUICreate($sTitle2, 350, 280, @DesktopWidth - 350, @DesktopHeight - 280, BitOR($WS_CAPTION, $WS_GROUP), $WS_EX_TOPMOST, $hGui)
GUISetBkColor(0xFFFFFF, $hSettings)
$cMousePos = GUICtrlCreateLabel("MousePos:", 0, 0, 300, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$cCGrid = GUICtrlCreateCheckbox("Grid", 0, 25, 50, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
GUICtrlSetState(-1, $GUI_CHECKED)
$cCUnitCircle = GUICtrlCreateCheckbox("Unit Circle", 52, 25, 85, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$cCScale = GUICtrlCreateCheckbox("Scale", 140, 25, 60, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateButton("Generate", 202, 25, 80, 20)
GUICtrlSetOnEvent(-1, "generate")
GUICtrlCreateButton("Add function", 0, 60, 90, 20)
GUICtrlSetOnEvent(-1, "addfunc")
GUICtrlCreateButton("Delete function", 95, 60, 100, 20)
GUICtrlSetOnEvent(-1, "deletefunc")
GUICtrlCreateButton("Quit", 200, 60, 100, 20)
GUICtrlSetOnEvent(-1, "ende")
$cObjektlist = GUICtrlCreateListView("Objekttyp |Wert |Farbe ", 0, 82, 300, 140)
$cZoom = GUICtrlCreateSlider(310, 55, 25, 165, $TBS_VERT)
GUICtrlSetLimit(-1, 200, 1)
GUICtrlSetData($cZoom, 20)
$cZoomlabel = GUICtrlCreateLabel("Zoom:" & @CRLF & GUICtrlRead($cZoom), 296, 0, 40, 60)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
For $i = 10 To 200 Step 10
_GUICtrlSlider_SetTic($cZoom, $i)
Next
$cButtonBk = GUICtrlCreateButton("Background", 0, 230, 60, 20)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $sBackgroundcolor)
GUICtrlSetOnEvent(-1, "setbk")
$cButtonSystem = GUICtrlCreateButton("System", 65, 230, 40, 20)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, StringReplace($sCoordfarbe, "0xFF", "0x"))
GUICtrlSetOnEvent(-1, "setsystem")
$cButtonGrid = GUICtrlCreateButton("Grid", 110, 230, 30, 20)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, StringReplace($sGridColor, "0xFF", "0x"))
GUICtrlSetOnEvent(-1, "setgrid")
$cButtonMark = GUICtrlCreateButton("Mark", 145, 230, 30, 20)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, StringReplace($sXColor, "0xFF", "0x"))
GUICtrlSetOnEvent(-1, "setmark")
ControlFocus($sTitle2, "", $cObjektlist)
GUISetState(@SW_SHOW, $hSettings)
;###Gui Ende
;###GDIPlus Start
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
$Pen2 = _GDIPlus_PenCreate($sGridColor, 1)
$Pen1 = _GDIPlus_PenCreate($sCoordfarbe, 1)
$Pen3 = _GDIPlus_PenCreate($sXColor, 1)
$Brush1 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
;###GDIPlus Ende
While 1
$aPos = GUIGetCursorInfo($hGui)
$iZoom = GUICtrlRead($cZoom) ;Zoom
$iAbstand = Round((@DesktopHeight-200) / $iZoom)
GUICtrlSetData($cMousePos, "Mousepos: (" & Round(($aPos[0] - $iNullx) / $iAbstand, 2) & "|" & Round(calcytocoords($aPos[1]) / $iAbstand, 2) & ")")
If _IsPressed(01) Then
drawX()
Do
Until Not _IsPressed(01)
EndIf
GUICtrlSetData($cZoomlabel, "Zoom:" & @CRLF & GUICtrlRead($cZoom))
Sleep(100)
WEnd
ende()
Func generate()
GUISetBkColor($sBackgroundcolor, $hGui)
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
If GUICtrlRead($cCGrid) = $GUI_CHECKED Then
$bGrid = True
Else
$bGrid = False
EndIf
If GUICtrlRead($cCScale) = $GUI_CHECKED Then
$bScale = True
Else
$bScale = False
EndIf
If GUICtrlRead($cCUnitCircle) = $GUI_CHECKED Then
$bEinheitskreis = True
Else
$bEinheitskreis = False
EndIf
;###Netz erstellen Start
For $i = 1 To (@DesktopWidth - 200) / $iAbstand ;Beschriftung
If $bGrid = True Then
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx + $iAbstand * $i, 0, $iNullx + $iAbstand * $i, (@DesktopHeight - 200), $Pen2) ;x rechts
_GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully - $iAbstand * $i, (@DesktopWidth - 200), $iNully - $iAbstand * $i, $Pen2);y oben
_GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully + $iAbstand * $i, (@DesktopWidth - 200), $iNully + $iAbstand * $i, $Pen2);y unten
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - $iAbstand * $i, 0, $iNullx - $iAbstand * $i, (@DesktopWidth - 200), $Pen2);x links
EndIf
If $bScale = True Then
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx + $iAbstand * $i, $iNully - 10, $iNullx + $iAbstand * $i, $iNully + 10, $Pen1) ;x rechts
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - 10, $iNully - $iAbstand * $i, $iNullx + 10, $iNully - $iAbstand * $i, $Pen1);y oben
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - 10, $iNully + $iAbstand * $i, $iNullx + 10, $iNully + $iAbstand * $i, $Pen1);y unten
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx - $iAbstand * $i, $iNully - 10, $iNullx - $iAbstand * $i, $iNully + 10, $Pen1);x links
EndIf
Next
_GDIPlus_GraphicsDrawLine($hGraphics, 0, $iNully, (@DesktopWidth - 200), $iNully, $Pen1) ;x-Achse
_GDIPlus_GraphicsDrawLine($hGraphics, $iNullx, 0, $iNullx, (@DesktopHeight - 200), $Pen1);y-Achse
If $bEinheitskreis = True Then
_GDIPlus_GraphicsDrawEllipse($hGraphics, $iNullx - ($iAbstand * 1), $iNully - ($iAbstand * 1), $iAbstand * 2, $iAbstand * 2, $Pen1)
EndIf
GUISetState(@SW_DISABLE, $hSettings)
Sleep(1000)
;###Netz erstellen Ende
For $i = 0 To _GUICtrlListView_GetItemCount($cObjektlist) - 1
Local $sY = _GUICtrlListView_GetItemTextString($cObjektlist, $i)
Local $aSplitted = StringSplit($sY, "|")
If $aSplitted[1] = "Function" Then
draw($aSplitted[2], $aSplitted[3])
Else
Local $aSplitted2 = StringSplit($aSplitted[2], "/")
$aSplitted2[1] = StringReplace($aSplitted2[1], "(", "")
$aSplitted2[2] = StringReplace($aSplitted2[2], ")", "")
drawX(Round(($aSplitted2[1] * $iAbstand) + $iNullx), Round((($aSplitted2[2] * (-1)) * $iAbstand) + $iNully))
EndIf
Next
GUISetState(@SW_ENABLE, $hSettings)
ToolTip("Done!")
Sleep(2000)
ToolTip("")
EndFunc ;==>generate
Func draw($sFunktion, $sColor)
Local $Brush1 = _GDIPlus_BrushCreateSolid($sColor)
$sFunktion = StringReplace($sFunktion, "x", "($i / $iAbstand)")
ToolTip(StringReplace(StringReplace($sFunktion, "$i", "x"), " / xAbstand", ""))
Sleep(2000)
For $i = -((@DesktopWidth - 200) / 2) To (@DesktopWidth -200) / 2
ToolTip("i = " & $i & "; X = " & Round(Calcxtocoords($i)) & "; Y = " & Round(calcytocoords(Execute($sFunktion))) & "; Funktionswert = " & Execute($sFunktion))
_GDIPlus_GraphicsFillEllipse($hGraphics, Round(Calcxtocoords($i) - ($iLineWidth / 2)), Round(calcytocoords(Execute($sFunktion) * ($iAbstand)) - ($iLineWidth / 2)), $iLineWidth, $iLineWidth, $Brush1)
Next
$bDrawed = True
EndFunc ;==>draw
Func drawX($iMousePosx = -1, $iMousePosy = -1)
If $bDrawed = False Then Return
If $iMousePosx = -1 And $iMousePosy = -1 Then
If WinGetState($sTitle2, "") = 8 Then Return
If _MousePosCheck() = 1 Then Return
Local $aPos = GUIGetCursorInfo($hGui)
$iMousePosx = $aPos[0]
$iMousePosy = $aPos[1]
_GDIPlus_GraphicsDrawLine($hGraphics, $aPos[0] - 7, $aPos[1] - 7, $aPos[0] + 7, $aPos[1] + 7, $Pen3)
_GDIPlus_GraphicsDrawLine($hGraphics, $aPos[0] + 7, $aPos[1] - 7, $aPos[0] - 7, $aPos[1] + 7, $Pen3)
GUICtrlCreateListViewItem("Mark|(" & Round(($aPos[0] - $iNullx) / $iAbstand, 2) & "/" & Round(calcytocoords($aPos[1]) / $iAbstand, 2) & ")|" & $sXColor, $cObjektlist)
Else
_GDIPlus_GraphicsDrawLine($hGraphics, $iMousePosx - 7, $iMousePosy - 7, $iMousePosx + 7, $iMousePosy + 7, $Pen3)
_GDIPlus_GraphicsDrawLine($hGraphics, $iMousePosx + 7, $iMousePosy - 7, $iMousePosx - 7, $iMousePosy + 7, $Pen3)
EndIf
EndFunc ;==>drawX
Func addfunc()
$bDrawed = False
Do
Local $sInputFunktion = InputBox("Function", "Enter a function, please!" & @CRLF & "Use x for the variable!" & @CRLF & "Y=", Default, Default, Default, Default, Default, Default, $hGui)
Until $sInputFunktion <> "" Or @error
If @error Then Return
Do
Local $sColor = _ChooseColor(2, 0x990000, Default, $hGui)
Until $sColor <> -1 Or @error
If @error Then Return
Local $sColor2 = StringReplace($sColor, "0x", "0xFF")
GUICtrlSetBkColor(GUICtrlCreateListViewItem("Function|" & $sInputFunktion & "|" & $sColor2, $cObjektlist), $sColor)
EndFunc ;==>addfunc
Func _MousePosCheck()
Local $aPos = WinGetPos($sTitle2)
$x_check = $aPos[0]
$y_check = $aPos[1]
$x_size = $aPos[2]
$y_size = $aPos[3]
If MouseGetPos(0) >= $x_check And MouseGetPos(0) <= $x_check + $x_size And MouseGetPos(1) >= $y_check And MouseGetPos(1) <= $y_check + $y_size Then
Return (1)
Else
Return (0)
EndIf
EndFunc ;==>_MousePosCheck
Func deletefunc()
_GUICtrlListView_DeleteItemsSelected($cObjektlist)
EndFunc ;==>deletefunc
Func setbk()
$sBackgroundcolor = _ChooseColor(2, 0x000000)
GUICtrlSetBkColor($cButtonBk, $sBackgroundcolor)
EndFunc ;==>setbk
Func setmark()
$sXColor = StringReplace(_ChooseColor(2, 0x000000), "0x", "0xFF")
GUICtrlSetBkColor($cButtonMark, $sXColor)
EndFunc ;==>setmark
Func setgrid()
$sGridColor = StringReplace(_ChooseColor(2, 0x000000), "0x", "0xFF")
GUICtrlSetBkColor($cButtonGrid, $sGridColor)
EndFunc ;==>setgrid
Func setsystem()
$sCoordfarbe = StringReplace(_ChooseColor(2, 0x000000), "0x", "0xFF")
GUICtrlSetBkColor($cButtonSystem, $sCoordfarbe)
EndFunc ;==>setsystem
Func calcxtocoords($iX)
Return $iX + $iNullx
EndFunc ;==>calcxtocoords
Func calcytocoords($iY)
Return (-$iY + $iNully)
EndFunc ;==>calcytocoords
Func ende()
_GDIPlus_PenDispose($Pen1)
_GDIPlus_PenDispose($Pen2)
_GDIPlus_PenDispose($Pen3)
_GDIPlus_BrushDispose($Brush1)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>ende
EndFunc
Ich hoffe ihr könnt mir helfen
Danke DFPWare