以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- [求助]请问这个代码在全局代码中应该怎么修改呢 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=189904)
|
-- 作者:81538475
-- 发布时间:2024/1/3 23:32:00
-- [求助]请问这个代码在全局代码中应该怎么修改呢
Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
Me.Opacity -= opacityStep
If Me.Opacity <= 0.0 Then
opacityTimer.Stop()
Me.Close()
End If
End Sub
|
-- 作者:有点蓝
-- 发布时间:2024/1/4 8:40:00
--
如果只有单独这个函数,没有办法改,也用不了。如果是放到class里面的,请把整个class的代码一起发上来
|
-- 作者:81538475
-- 发布时间:2024/1/4 9:18:00
--
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Public Class MainForm
Inherits Form
Private WithEvents opacityTimer As Timer
Private opacityStep As Double = 0.1
Private fadeInterval As Integer = 100
Public Sub New()
Me.Text = "绘制SP图案"
Me.Size = New Size(500, 300)
Me.FormBorderStyle = FormBorderStyle.None \' 禁用窗口边框
Dim path As New GraphicsPath()
Dim radius As Integer = 50 \' 增加圆角的半径
Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90) \' 左上角
path.AddArc(rect.Width - radius, rect.Y, radius, radius, 270, 90) \' 右上角
path.AddArc(rect.Width - radius, rect.Height - radius, radius, radius, 0, 90) \' 右下角
path.AddArc(rect.X, rect.Height - radius, radius, radius, 90, 90) \' 左下角
path.CloseFigure()
Me.Region = New Region(path)
opacityTimer = New Timer()
opacityTimer.Interval = fadeInterval
opacityTimer.Start()
End Sub
Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
Dim graphics = e.Graphics
graphics.SmoothingMode = SmoothingMode.AntiAlias \' 启用抗锯齿
graphics.Clear(Color.White) \' 设置窗口背景颜色
End Sub
Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
Me.Opacity -= opacityStep
If Me.Opacity <= 0.0 Then
opacityTimer.Stop()
Me.Close()
End If
End Sub
Public Shared Sub Main()
Application.Run(New MainForm())
End Sub
End Class
|
-- 作者:有点蓝
-- 发布时间:2024/1/4 9:40:00
--
去掉前面3个Imports的行 ,其它代码照搬到全局代码,补齐里面的命名空间即可
|
-- 作者:81538475
-- 发布时间:2024/1/4 10:49:00
--
贴上去提示这个了
[此贴子已经被作者于2024/1/4 10:49:06编辑过]
|
-- 作者:有点蓝
-- 发布时间:2024/1/4 10:58:00
--
完整代码?
|
-- 作者:81538475
-- 发布时间:2024/1/4 11:00:00
--
Public Class MainForm
’ Inherits Form
Private WithEvents opacityTimer As Timer
Private opacityStep As Double = 0.1
Private fadeInterval As Integer = 100
Public Sub New()
Me.Text = "绘制SP图案"
Me.Size = New Size(500, 300)
Me.FormBorderStyle = FormBorderStyle.None \' 禁用窗口边框
Dim path As New GraphicsPath()
Dim radius As Integer = 50 \' 增加圆角的半径
Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)
path.AddArc(rect.X, rect.Y, radius, radius, 180, 90) \' 左上角
path.AddArc(rect.Width - radius, rect.Y, radius, radius, 270, 90) \' 右上角
path.AddArc(rect.Width - radius, rect.Height - radius, radius, radius, 0, 90) \' 右下角
path.AddArc(rect.X, rect.Height - radius, radius, radius, 90, 90) \' 左下角
path.CloseFigure()
Me.Region = New Region(path)
opacityTimer = New Timer()
opacityTimer.Interval = fadeInterval
opacityTimer.Start()
End Sub
Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
Dim graphics = e.Graphics
graphics.SmoothingMode = SmoothingMode.AntiAlias \' 启用抗锯齿
graphics.Clear(Color.White) \' 设置窗口背景颜色
End Sub
Private Sub OpacityTimer_Tick(sender As Object, e As EventArgs) Handles opacityTimer.Tick
Me.Opacity -= opacityStep
If Me.Opacity <= 0.0 Then
opacityTimer.Stop()
Me.Close()
End If
End Sub
Public Shared Sub Main()
Application.Run(New MainForm())
End Sub
End Class
|
-- 作者:有点蓝
-- 发布时间:2024/1/4 11:00:00
--
这句不能注释掉啊,这才是关键的功能
|
-- 作者:linyunu
-- 发布时间:2024/1/4 11:01:00
--
System.Drawing.Rectangle 补齐命名空间
|
-- 作者:81538475
-- 发布时间:2024/1/4 11:23:00
--
好了,可以了。在弱弱的问一句,这个应该怎么调用呀
|