Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports System.Reflection
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Imports DevExpress.XtraEditors
Imports DevExpress.Utils
Namespace DevExpress.XtraCharts.Demos.Modules
Public NotInheritable Class Utils
Private Const path As String = "DevExpress.XtraCharts.Demos.Images."
Private Sub New()
End Sub
Public Shared Function GetRelativePath(ByVal name As String) As String
name = "Data\" & name
Dim path As String = System.Windows.Forms.Application.StartupPath
Dim s As String = "\"
For i As Integer = 0 To 10
If System.IO.File.Exists(path & s & name) Then
Return (path & s & name)
Else
s &= "..\"
End If
Next i
path = Environment.CurrentDirectory
s = "\"
For i As Integer = 0 To 10
If System.IO.File.Exists(path & s & name) Then
Return (path & s & name)
Else
s &= "..\"
End If
Next i
Return ""
End Function
Public Shared Sub SetConnectionString(ByVal oleDbConnection As System.Data.OleDb.OleDbConnection, ByVal path As String)
oleDbConnection.ConnectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source={0};Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False", path)
End Sub
Public Shared Function GetImage(ByVal name As String) As Image
Dim stream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(name)
If stream IsNot Nothing Then
Return Image.FromStream(stream)
End If
Return Nothing
End Function
Public Shared Function GetCursor(ByVal name As String) As Cursor
Return ResourceImageHelper.CreateCursorFromResources(name, System.Reflection.Assembly.GetExecutingAssembly())
End Function
End Class
Public NotInheritable Class PieExplodingHelper
Private Sub New()
End Sub
Private Shared Function CreateFilter(ByVal mode As String) As SeriesPointFilter
Return New SeriesPointFilter(SeriesPointKey.Argument, DataFilterCondition.Equal, mode)
End Function
Private Shared Sub ApplyFilterMode(ByVal view As PieSeriesViewBase, ByVal mode As String)
view.ExplodedPointsFilters.Clear()
view.ExplodedPointsFilters.Add(CreateFilter(mode))
view.ExplodeMode = PieExplodeMode.UseFilters
End Sub
Public Const None As String = "None"
Public Const All As String = "All"
Public Const MinValue As String = "Min Value"
Public Const MaxValue As String = "Max Value"
Public Const Custom As String = "Custom"
Public Shared Function CreateModeList(ByVal points As SeriesPointCollection, ByVal supportCustom As Boolean) As List(Of String)
Dim list As New List(Of String)()
list.Add(None)
list.Add(All)
list.Add(MinValue)
list.Add(MaxValue)
For Each point As SeriesPoint In points
list.Add(point.Argument)
Next point
If supportCustom Then
list.Add(Custom)
End If
Return list
End Function
Public Shared Sub ApplyMode(ByVal view As PieSeriesViewBase, ByVal mode As String)
Select Case mode
Case Custom
Case None
view.ExplodeMode = PieExplodeMode.None
Case All
view.ExplodeMode = PieExplodeMode.All
Case MinValue
view.ExplodeMode = PieExplodeMode.MinValue
Case MaxValue
view.ExplodeMode = PieExplodeMode.MaxValue
Case Else
ApplyFilterMode(view, mode)
End Select
End Sub
End Class
End Namespace