--setFont when changed in options menu
function setFont()
    message:SetFont(Media:Fetch("font", KillingBlowAnnouncer:GetFont(info)), KillingBlowAnnouncer:GetFontSize(info), KillingBlowAnnouncer:GetOutline(info))
end

--setColors when changed in options menu
function setColors()
    if (KillingBlowAnnouncer:EnableSnap(info) == true) then
        message:Clear()
        message:AddMessage(KillingBlowAnnouncer:GetKillingMessage(info),KillingBlowAnnouncer:GetRed(info),KillingBlowAnnouncer:GetGreen(info),KillingBlowAnnouncer:GetBlue(info))
    end
end

--setTime when changed in options menu
function setTime()
    if (KillingBlowAnnouncer:EnableSnap(info) == false) then
        message:SetTimeVisible(KillingBlowAnnouncer:GetVisibleTime(info))
        message:SetFadeDuration(KillingBlowAnnouncer:GetFadeTime(info))
    end
end

--setKillingMsg when changed in options menu
function setKillingMsg()
    if (KillingBlowAnnouncer:EnableSnap(info) == true) then
        message:Clear()
        message:AddMessage(KillingBlowAnnouncer:GetKillingMessage(info),KillingBlowAnnouncer:GetRed(info),KillingBlowAnnouncer:GetGreen(info),KillingBlowAnnouncer:GetBlue(info))
    end
end

--Snap killing blow message frame to window when enabled and when disabled clear and set timevisible back to normal
function snapMessage()
    --EnableSnap is false then set back to database value else if edit mode is true then set time to 10000
    if (KillingBlowAnnouncer:EnableSnap(info) == false) then
        message:SetTimeVisible(KillingBlowAnnouncer:GetVisibleTime(info))
        message:Clear()
    else
        message:SetTimeVisible(10000)
        message:AddMessage(KillingBlowAnnouncer:GetKillingMessage(info),KillingBlowAnnouncer:GetRed(info),KillingBlowAnnouncer:GetGreen(info),KillingBlowAnnouncer:GetBlue(info))
    end

end

--Method for fading the killing blow message in and out
function fade()
    --set duration it takes to finish the fade in and fade out
    i = KillingBlowAnnouncer:GetFadeInTime(info)
    if(i == 0) then
        i = 0.1
    end

    o = KillingBlowAnnouncer:GetFadeOutTime(info)
    if(o == 0) then
        o = 0.1
    end

    alphaIn:SetDuration(i)
    alphaOut:SetDuration(o)

    --set delay for waiting when fadein ends
    alphaIn:SetEndDelay(KillingBlowAnnouncer:GetEndDelay(info))

    imageAnimationIn:SetScript("OnPlay", function(self)
        image:Show();
    end)

    alphaIn:SetScript("OnPlay", function(self)
        alphaIn:SetFromAlpha(0)
        alphaIn:SetToAlpha(1)
    end)

    alphaOut:SetScript("OnPlay", function(self)
        alphaOut:SetFromAlpha(1)
        alphaOut:SetToAlpha(0)
    end)

    imageAnimationIn:SetScript("OnFinished", function(self)
        imageObj:SetAlpha(1)
        imageAnimationOut:Play();
    end)

    imageAnimationOut:SetScript("OnFinished", function(self)
        imageObj:SetAlpha(-1)
        image:Hide();

        if(KillingBlowAnnouncer:GetKBIDebug(info) == true) then
            fade();
        end
    end)

    imageAnimationIn:Play();
end

function resizeKBIImage(w,h)
    image:SetSize(w,h)
end

function resizeKBMMessage(w,h)
    message:SetSize(w,h)
end

--lock or unlock kbtracker based on options
function lockMessageFrame()
    if (KillingBlowAnnouncer:EnableMessageDrag(info) == true) then
        message:SetScript("OnDragStart", message.StartMoving)
        message:SetScript("OnDragStop", message.StopMovingOrSizing)
        message:SetScript('OnLeave', function() 
            point, relativeTo, relativePoint, xOffset, yOffset = message:GetPoint();

            KillingBlowAnnouncer:SetKBMPoint(nil, point);
            KillingBlowAnnouncer:SetKBMRelTo(nil, relativeTo);
            KillingBlowAnnouncer:SetKBMRelPoint(nil, relativePoint);
            KillingBlowAnnouncer:SetKBMXOffset(nil, xOffset);
            KillingBlowAnnouncer:SetKBMYOffset(nil, yOffset);
         end)
    else
        message:SetScript("OnDragStart", nil)
        message:SetScript("OnDragStop", nil)
    end
end

--lock or unlock kbtracker based on options
function lockImageFrame()
    if (KillingBlowAnnouncer:EnableImageDrag(info) == true) then
        image:SetScript("OnDragStart", image.StartMoving)
        image:SetScript("OnDragStop", image.StopMovingOrSizing)
        image:SetScript('OnLeave', function() 
            point, relativeTo, relativePoint, xOffset, yOffset = image:GetPoint();

            KillingBlowAnnouncer:SetKBIPoint(nil, point);
            KillingBlowAnnouncer:SetKBIRelTo(nil, relativeTo);
            KillingBlowAnnouncer:SetKBIRelPoint(nil, relativePoint);
            KillingBlowAnnouncer:SetKBIXOffset(nil, xOffset);
            KillingBlowAnnouncer:SetKBIYOffset(nil, yOffset);
         end)
    else
        image:SetScript("OnDragStart", nil)
        image:SetScript("OnDragStop", nil)
    end
end