오픈 소스 코드 라이브러리인 그래픽 winforms 시계 차트에 오신 것을 환영합니다.
이 프로젝트의 주요 목적은 C# 및 VB.NET Winforms 개발자에게 "시계와 유사한" 그래픽 개체를 제공하는 것입니다. 라이브러리는 주로 성과와 관련하여 계산된 데이터를 제공하는 애플리케이션(예: 회사 판매 대시보드)을 위해 설계되었습니다.
각 시계 객체에는 사용자 정의에 사용되는 다양한 속성이 있으며 시계는 새로 고치거나 로드할 때 애니메이션을 포함할 수 있습니다.
최신 버전의 BusinessClocks.dll을 로컬 컴퓨터에 다운로드하세요.
저장소의 마스터 브랜치에서 항상 마지막 버전을 찾을 수 있습니다.
Visual Studio를 사용하여 winforms 프로젝트에 .dll을 로드합니다.
프로젝트에 dll을 로드하는 방법:
Form1
파일 상단에 있는 BusinessClocks.ExecutiveClocks
네임스페이스에 Using
(C#) 문 또는 Imports
(VB.NET) 문을 추가합니다.Form1
클래스에 붙여넣으세요.C# 테스트 예
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BusinessClocks.ExecutiveClocks;
namespace WindowsFormsApplication19
{
public partial class Form1 : Form
{
private BusinessClocks.ExecutiveClocks.CarClock carClock;
private GoalsClock goalsClock;
private WaitClock waitClock;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
carClock = new BusinessClocks.ExecutiveClocks.CarClock(300, 150, 0.8F, true);
carClock.ShowInnerCutForPerformance = false;
carClock.BarBackColor = Color.Pink;
carClock.Create(true);
this.Controls.Add(carClock.ClockPanel);
goalsClock = new GoalsClock(200, 200, 0.8F);
goalsClock.Create(true);
goalsClock.Clock.Location = new Point(0, carClock.ClockPanel.Location.Y + carClock.ClockPanel.Height + 5);
this.Controls.Add(goalsClock.Clock);
waitClock = new WaitClock(150, 150, "Loading...");
waitClock.Clock.Location = new Point(0, goalsClock.Clock.Location.Y + goalsClock.Clock.Height + 5);
waitClock.LoadFont("ARIAL", 8, FontStyle.Regular);
waitClock.SetArrayColors(new Color[] { Color.FromArgb(0, 100, 100), Color.FromArgb(0, 136, 136), Color.FromArgb(0, 170, 170), Color.FromArgb(0, 204, 204) });
waitClock.OuterCircleWeight = 8;
waitClock.InnerCircleWeight = 5;
waitClock.Create(true);
this.Controls.Add(waitClock.Clock);
}
}
}
Visual Basic.NET 테스트 예
Imports BusinessClocks.ExecutiveClocks
Public Class Form1
Private carClock As BusinessClocks.ExecutiveClocks.CarClock
Private goalsClock As GoalsClock
Private waitClock As WaitClock
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' car clock (with precentage bar)
carClock = New BusinessClocks.ExecutiveClocks.CarClock(300, 150, 0.8, True)
carClock.ShowInnerCutForPerformance = False
carClock.BarBackColor = Color.Pink
carClock.Create(True)
Me.Controls.Add(carClock.ClockPanel)
' goals clock
goalsClock = New GoalsClock(200, 200, 0.8)
goalsClock.Create(True)
goalsClock.Clock.Location = New Point(0, carClock.ClockPanel.Location.Y + carClock.ClockPanel.Height + 5)
Me.Controls.Add(goalsClock.Clock)
' waitclock
waitClock = New WaitClock(150, 150, "Loading...")
waitClock.Clock.Location = New Point(0, goalsClock.Clock.Location.Y + goalsClock.Clock.Height + 5)
waitClock.LoadFont("ARIAL", 8, FontStyle.Regular)
waitClock.SetArrayColors(New Color() {Color.FromArgb(0, 100, 100), Color.FromArgb(0, 136, 136) _
, Color.FromArgb(0, 170, 170), Color.FromArgb(0, 204, 204)})
waitClock.OuterCircleWeight = 8
waitClock.InnerCircleWeight = 5
waitClock.Create(True)
Me.Controls.Add(waitClock.Clock)
End Sub
End Class
참고: 모든 시계(현재는 WaitClock 및 CarClock)는 GoalsClock을 상속합니다.
속성:
Clock:
시계를 나타내는 그래픽 객체의 인스턴스로 Create()
호출된 후 초기화됩니다.ClockWidth
: 시계 너비를 가져오거나 설정합니다.ClockHeight
: 시계 높이를 가져오거나 설정합니다.xPos
및 Ypos
: 시계가 포함된 직사각형의 x 또는 y 위치를 가져옵니다.ClockBackGroundColor
: 시계 배경색을 가져오거나 설정합니다.FontColor
: PercentOfGoals
백분율을 설명하는 텍스트의 글꼴 색상을 가져오거나 설정합니다.ClockFont
: PercentOfGoals 백분율을 설명하는 텍스트의 글꼴을 가져오거나 설정합니다. 참고:LoadFont()
함수를 호출하므로 font
속성을 변경하지 않는 것이 좋습니다.LoadFont()
호출할 수 있습니다.InnerCircleColor
: 내부 호의 색상을 가져오거나 설정합니다.InnerCircleWeight
: 내부 호의 픽셀 가중치(너비)를 가져오거나 설정합니다.OuterCircleColor
: 외부 호의 색상을 가져오거나 설정합니다.OuterCircleWeight
: 외부 호의 픽셀 가중치(너비)를 가져오거나 설정합니다.PercentOfGoals
: 시계 값을 가져오거나 설정합니다. 예를 들어 0.1F 값 = 10%, 0.5F 값 = 50%, 1.1F 값 = 110% 등...GoalsPercentDecimalValue
: 시계 십진수 값을 가져옵니다.Animate
(필드): 애니메이션 활성화 여부를 나타내는 값을 가져오거나 설정합니다.AnimationLength
: AnimationLength 열거형을 기준으로 애니메이션 속도(밀리초)를 가져오거나 설정합니다. SuperFast = 1, Fast = 4, ModerateFast = 8, Moderate = 15, ModerateSlow = 28, Slow = 50, SuperSlow = 80.TimerInterval
: 내부 타이머의 틱 간격을 가져오거나 설정합니다. 권장 값은 4(기본값)이며 새로 고침 시간을 단축하기 위해 더 낮은 값을 사용합니다.행동 양식:
Create(ByVal AnimateClock As Boolean)
: 시계 개체를 초기화하며 모든 속성이 설정된 후에 호출해야 합니다(개발자 참고 사항: 이 메서드는 재정의 가능/가상입니다).RefreshClock(ByVal AnimateClock As Boolean)
: 시계 개체의 그래픽을 새로 고치고 다시 그립니다. 속성(예: PercentOfGoals, InnerCircleColor)을 변경한 후 이 메서드를 호출합니다. 대부분의 시계 속성은 해당 값이 변경될 때 이 메서드를 호출합니다. (개발자는 참고하세요: 이 방법은 재정의 가능/가상입니다.)LoadFont()
: 내부 Elgoritem을 사용하여 시계 크기를 기준으로 적절한 글꼴 em 크기와 스타일을 반환합니다.LoadFont()
호출할 수 있습니다.Dispose()
: 메서드는 IDisposable 인터페이스(mscorlib.dll 어셈블리)에서 구현되며, 호출되면 시계 개체가 삭제되고 모든 GDI 개체가 메모리에서 해제됩니다.속성:
ClockPanel
(필드): 텍스트 표시줄이 필요한 경우 Clock
개체 내부를 포함하는 데 사용됩니다. 중요: BaseBar = True
인 경우 시계 아래에 성능 텍스트 막대를 표시하기 위해 Clock
개체가 ClockPanel
내부에 호스팅됩니다.BaseBar = True
인 경우 이 컨트롤(Clock 속성 아님)을 사용하여 텍스트 표시줄이 있는 시계를 가져옵니다.BaseBar = False
이 속성을 절대 사용하지 않으면 초기화되지 않으므로 결과는 NullReferenceException
이 됩니다. (lordofscripts 사용자가 연 issue6을 읽어보십시오: #6). LowPerformance
: 낮은 성능에 대한 표시를 가져오거나 설정합니다. 이 속성은 LowPerFormanceColor 속성에 바인딩되며 해당 값은 LowPerFormanceColor 색상으로 낮은 성능 시계의 그래픽 영역을 설정합니다.
MediumPerformance
: 중간 성능에 대한 표시를 가져오거나 설정합니다. 이 속성은 MediumPerFormanceColor 속성에 바인딩되며 해당 값은 MediumPerFormanceColor 색상을 사용하여 중간 성능 시계의 그래픽 영역을 설정합니다.
HighPerformance
: 고성능에 대한 표시를 가져오거나 설정합니다. 이 속성은 HighPerFormanceColor 속성에 바인딩되며 해당 값은 HighPerFormanceColor 색상을 사용하여 고성능 시계의 그래픽 영역을 설정합니다.
HighPerFormanceColor
: 선택된 색상으로 시계의 그래픽 고성능 영역을 가져오거나 설정합니다( HighPerFormance
속성에 바인딩됨).
MediumPerFormanceColor
: 선택한 색상으로 시계의 그래픽 중간 성능 영역을 가져오거나 설정합니다( MediumPerformance
속성에 바인딩됨).
LowPerFormanceColor
: 선택한 색상으로 시계의 그래픽 저성능 영역을 가져오거나 설정합니다( LowPerformance
속성에 바인딩됨).
NeedleBaseColor
: 바늘(시계바늘) 베이스의 배경색을 가져오거나 설정합니다.
NeedleBaseWeight
: 바늘(시계바늘) 베이스의 픽셀 가중치(두께)를 가져오거나 설정합니다.
NeedleOuterColor
: 바깥쪽 바늘(시계바늘) 영역의 배경색을 가져오거나 설정합니다.
NeedleOuterWeight
: 외부 바늘(시계 바늘) 영역의 픽셀 가중치(두께)를 가져오거나 설정합니다.
NeedleInnerColor
: 안쪽 바늘(시계바늘) 영역의 배경색을 가져오거나 설정합니다.
NeedleInnerWeight
: 안쪽 바늘(시계바늘) 영역의 픽셀 가중치(두께)를 가져오거나 설정합니다.
ShowInnerCutForPerformance
: 성능을 나타내는 시각적 내부 컷(슬래시)이 시계 테두리 중앙에 그려질지 여부를 나타내는 값을 가져오거나 설정합니다.
InnerCutPreformanceColor
: 시계 경계 중앙의 성능을 나타내는 시각적 내부 컷(슬래시)의 색상을 가져오거나 설정합니다.
InnerCutPerformanceWeight
: 시계 경계 중앙에서 성능을 나타내는 내부 컷(슬래시)의 가중치(두께)를 가져오거나 설정합니다.
BarFont
: PercentOfGoals 백분율을 설명하는 텍스트의 글꼴을 가져오거나 설정합니다.
BarBackColor
: 성능 표시줄 배경색을 가져오거나 설정합니다.
BarForeColor
: 성능 막대 글꼴 색상을 가져오거나 설정합니다.
BarValueDigitsForeColor
: 막대의 최대(100%) 및 최소(0%) 라벨의 글꼴 색상을 가져오거나 설정합니다.
BarValueDigitsBackColor
: 막대의 최대(100%) 및 최소(0%) 레이블의 배경색을 가져오거나 설정합니다.
BarValueDigitsFont
: 막대의 최대(100%) 및 최소(0%) 라벨의 글꼴을 가져오거나 설정합니다.
속성:
waitText
: 시계 중간에 있는 텍스트를 가져오거나 설정합니다. 행동 양식:
SetArrayColors(ByVal arrayOfColors() As Color)
: 각 360도 회전 후에 변경되는 일련의 색상을 설정합니다. .dll은 VB.NET으로 작성되었습니다.
C# 프로젝트에서도 사용할 수 있습니다.
C# 및 VB.NET에 대해 두 개의 동일한 예제가 추가되었습니다.
이것은 오픈 소스 프로젝트입니다: 소스 코드
버전 관리를 위해 SemVer를 사용합니다.
GoalsClock 기본 클래스에는 Version
상수 필드가 있습니다. 이를 사용하여 라이브러리의 버전 번호를 확인하세요.
이 구간은 아직 공사중입니다. 단기간에
여기에서는 프로젝트에 참여하고 자신만의 시계 차트를 작성하려는 개발자를 위한 설명과 예제를 찾을 수 있습니다.
WaitClock
개체 표시주석이 포함된 C# 코드 예:
/*
**************************************************************************
* AUTHOR: Jonathan Applebaum *
* DESCRIPTION: An example that describes how to use WaitClock object *
* from another thread in order to execute a long task in the beckground *
* DATE: 06/01/2017 *
* ************************************************************************
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BusinessClocks.ExecutiveClocks;
namespace WindowsFormsApplication19
{
public partial class Form1 : Form
{
private WaitClock waitClock;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// show wait clock on a different thread until LongTask finish executing
System.Threading.Thread waitThread = new System.Threading.Thread(LoadWaitClock);
waitThread.Start();
// start a new thread to execute LongTask() parallel to the waitThread
System.Threading.Thread longTaskThread = new System.Threading.Thread(LongTask);
longTaskThread.Start();
}
// put the code of your task that you want to execute in the background in that method
private void LongTask()
{
// loop to represent a long task
for (int i = 0; i < 10; i++)
{
System.Threading.Thread.Sleep(1000);
}
// the "long task" inside the method finished to execute - dispose the wait clock from the GUI
panel1.Invoke(new Action(waitClock.Dispose));
// promt to screen
label1.Invoke(new Action(NotifyTaskHasFinished));
}
private void LoadWaitClock()
{
// use action delegate to update GUI changes from another thread
panel1.Invoke(new Action(AddClock));
}
private void AddClock()
{
// configure and initilize the clock
waitClock = new WaitClock(120, 120, "Loading...");
waitClock.ClockBackGroundColor = Color.White;
waitClock.FontColor = Color.Black;
waitClock.Clock.Location = new Point(5, 5);
waitClock.LoadFont("ARIAL", 8, FontStyle.Regular);
waitClock.SetArrayColors(new Color[] { Color.FromArgb(0, 100, 100), Color.FromArgb(0, 136, 136), Color.FromArgb(0, 170, 170), Color.FromArgb(0, 204, 204) });
waitClock.OuterCircleWeight = 8;
waitClock.InnerCircleWeight = 5;
waitClock.Create(true);
this.panel1.Controls.Add(waitClock.Clock);
}
private void NotifyTaskHasFinished()
{
label1.Text = "LongTask() method has finished";
}
}
}
주석이 포함된 Visual Basic.NET 코드 예제:
' **************************************************************************
' * AUTHOR: Jonathan Applebaum *
' * DESCRIPTION: An example that describes how To use WaitClock Object *
' * from another thread in order to execute a long task in the beckground *
' * DATE: 06/01/2017 *
' * ************************************************************************
Imports BusinessClocks.ExecutiveClocks
Public Class Form1
Private waitClock As WaitClock
Private Sub Form1_Load_1(sender As Object, e As EventArgs) Handles MyBase.Load
Dim waitThread As System.Threading.Thread = New System.Threading.Thread(AddressOf LoadWaitClock)
waitThread.Start()
Dim longTaskThread As System.Threading.Thread = New System.Threading.Thread(AddressOf LongTask)
longTaskThread.Start()
End Sub
Private Sub LongTask()
For i As Integer = 0 To 9
System.Threading.Thread.Sleep(1000)
Next
Panel1.Invoke(New Action(AddressOf waitClock.Dispose))
Label1.Invoke(New Action(AddressOf NotifyTaskHasFinished))
End Sub
Private Sub LoadWaitClock()
Panel1.Invoke(New Action(AddressOf AddClock))
End Sub
Private Sub AddClock()
waitClock = New WaitClock(120, 120, "Loading...")
waitClock.ClockBackGroundColor = Color.White
waitClock.FontColor = Color.Black
waitClock.Clock.Location = New Point(5, 5)
waitClock.LoadFont("ARIAL", 8, FontStyle.Regular)
waitClock.SetArrayColors(New Color() {Color.FromArgb(0, 100, 100), Color.FromArgb(0, 136, 136), Color.FromArgb(0, 170, 170), Color.FromArgb(0, 204, 204)})
waitClock.OuterCircleWeight = 8
waitClock.InnerCircleWeight = 5
waitClock.Create(True)
Me.Panel1.Controls.Add(waitClock.Clock)
End Sub
Private Sub NotifyTaskHasFinished()
Label1.Text = "LongTask() method has finished"
End Sub
End Class