'物件類別 Class ParentObj_SubCount
Public Class ParentObj_SubCount
Private _ParentObjName As String '父物件名稱
Private _Parentidx As Double '父物件ID
Private _ChildCount As Integer '共有多少子物件
Public aArrary(10) As Double'子物件的ID號碼
'Public aArrary() As Double = New Double() {} '子物件的ID號碼 (也可以先不指定)
Public Property ParentObjName() As String '父物件名稱
Get
Return _ParentObjName
End Get
Set(ByVal value As String)
_ParentObjName = value
End Set
End Property
Public Property Parentidx() As String '父物件ID
Get
Return _Parentidx
End Get
Set(ByVal value As String)
_Parentidx = value
End Set
End Property
Public Property ChildCount() As String '共有多少子物件
Get
Return _ChildCount
End Get
Set(ByVal value As String)
_ChildCount = value
End Set
End Property
End Class
'----------------------------------------------------------------------
程式內引用
'----------------------------------------------------------------------
Dim PosList As New List(Of ParentObj_SubCount)
Dim n As Integer
For n = 0 To 10
Dim Ps As New ParentObj_SubCount
Ps.Parentidx = n + 1
Ps.ParentObjName = "obj" & n.ToString
'ReDim Ps.aArrary(100) 此程式碼可重新指定 陣列大小
Ps.aArrary(0) = 1 '指定值
Ps.aArrary(1) = 2 '指定值
PosList.Add(Ps) '新增入陣列
Next
Debug.Print(PosList(0).aArrary(0))
Debug.Print(PosList(0).aArrary(1))
Debug.Print("--------------------")
Debug.Print(PosList(1).aArrary(1))
Debug.Print(PosList(1).aArrary(2))
2010年9月28日 星期二
VB.net 不規則陣列
'宣告不規則陣列的格式
Dim a()() As String = New String(4)() {}
a(0) = New String() {"A", "B", "C", "D", "E"}
a(1) = New String() {"A", "C", "D"}
a(2) = New String() {"D", "E"}
a(3) = New String() {"F"}
'若要新增一個陣列的[內容]時,可使用以下方式
Dim mylist As New List(Of String)
mylist.Add("ss1")
mylist.Add("ss2")
a(4) = mylist.ToArray
'讀取不規則陣列
'以For Next
For i = 0 To a.Length - 1
For j = 0 To a(i).Length - 1
Debug.Print(a(i)(j))
Next
Next
'以For Each
Dim achild ()
Dim ChildStr As String
For Each achild In a
For Each ChildStr In achild
Debug.Print( ChildStr )
Next
Next
'若一開始 不指定 陣列大小,動態處理則....
Dim a()() As String = New String()() {}
ReDim a(3)
'若一開始沒有ReDim 陣列大小,會發生問題,若資料增加後才發現陣列不夠,請加上Preserve辜關鍵字,如下
ReDim Preserve a(3)
Dim a()() As String = New String(4)() {}
a(0) = New String() {"A", "B", "C", "D", "E"}
a(1) = New String() {"A", "C", "D"}
a(2) = New String() {"D", "E"}
a(3) = New String() {"F"}
'若要新增一個陣列的[內容]時,可使用以下方式
Dim mylist As New List(Of String)
mylist.Add("ss1")
mylist.Add("ss2")
a(4) = mylist.ToArray
'讀取不規則陣列
'以For Next
For i = 0 To a.Length - 1
For j = 0 To a(i).Length - 1
Debug.Print(a(i)(j))
Next
Next
'以For Each
Dim achild ()
Dim ChildStr As String
For Each achild In a
For Each ChildStr In achild
Debug.Print( ChildStr )
Next
Next
'若一開始 不指定 陣列大小,動態處理則....
Dim a()() As String = New String()() {}
ReDim a(3)
'若一開始沒有ReDim 陣列大小,會發生問題,若資料增加後才發現陣列不夠,請加上Preserve辜關鍵字,如下
ReDim Preserve a(3)
2010年9月27日 星期一
WPF 圖片載入的問題 [找不到關於此像素格式的資訊]
暫時無解
DD.Source = Imgbmp '為何此行取消,就會有問題?
DD是一個既有的標籤物件。程式碼若不加上這一行,就會出現[找不到關於此像素格式的資訊]
Sub GenTelphone()
'讀取 BitmapImage
Dim Imgbmp As BitmapImage = New BitmapImage()
Dim ImgBrh As ImageBrush = New ImageBrush()
Imgbmp = New BitmapImage(New Uri("\image\mobile.gif", UriKind.RelativeOrAbsolute))
DD.Source = Imgbmp '為何此行取消,就會有問題?
Dim i As Integer
For i = 1 To 9
Dim Tb As New TextBlock
Dim img As New Image
img.Source = Imgbmp
img.Name = "Img" & i.ToString
Tb.Name = "Tbk" & i.ToString
Tb.TextAlignment = TextAlignment.Center '字型置中
Tb.Inlines.Add(img)
'在第一個段落後 增加 段落字元
Tb.Inlines.InsertAfter(Tb.Inlines.FirstInline, New LineBreak)
Tb.Inlines.Add(New Run("顯示資訊" & i.ToString))
Canvas.SetLeft(Tb, 50 * i)
Canvas.SetTop(Tb, 50 * i)
Canvas.SetZIndex(Tb, 25) '數字愈大,愈上層
Canvas.SetZIndex(Ln, 20)
'Canvas.SetLeft(img, 50 * i)
'Canvas.SetTop(img, 50 * i)
Tb.ToolTip = "我的NAME是 " & vbCrLf & vbCrLf & Tb.Name
MYCS.Children.Add(Tb)
Next
End Sub
DD.Source = Imgbmp '為何此行取消,就會有問題?
DD是一個既有的標籤物件。程式碼若不加上這一行,就會出現[找不到關於此像素格式的資訊]
Sub GenTelphone()
'讀取 BitmapImage
Dim Imgbmp As BitmapImage = New BitmapImage()
Dim ImgBrh As ImageBrush = New ImageBrush()
Imgbmp = New BitmapImage(New Uri("\image\mobile.gif", UriKind.RelativeOrAbsolute))
DD.Source = Imgbmp '為何此行取消,就會有問題?
Dim i As Integer
For i = 1 To 9
Dim Tb As New TextBlock
Dim img As New Image
img.Source = Imgbmp
img.Name = "Img" & i.ToString
Tb.Name = "Tbk" & i.ToString
Tb.TextAlignment = TextAlignment.Center '字型置中
Tb.Inlines.Add(img)
'在第一個段落後 增加 段落字元
Tb.Inlines.InsertAfter(Tb.Inlines.FirstInline, New LineBreak)
Tb.Inlines.Add(New Run("顯示資訊" & i.ToString))
Canvas.SetLeft(Tb, 50 * i)
Canvas.SetTop(Tb, 50 * i)
Canvas.SetZIndex(Tb, 25) '數字愈大,愈上層
Canvas.SetZIndex(Ln, 20)
'Canvas.SetLeft(img, 50 * i)
'Canvas.SetTop(img, 50 * i)
Tb.ToolTip = "我的NAME是 " & vbCrLf & vbCrLf & Tb.Name
MYCS.Children.Add(Tb)
Next
End Sub
2010年9月24日 星期五
WPF (經驗談) 標籤內嵌事件與 AddHandler 之問題
若出現事件出現問題,若該事件是內嵌在XAML內,不妨取消。改以AddHandler 載入試試看。
例如以下Slider標籤,ValueChanged事件,將無法執行
若改以在WindowLoaded事件載入,就可以正常運作
AddHandler slider.ValueChanged, AddressOf slider_ValueChanged
Private Sub slider_ValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Double))
Dim i As Integer
scaleTransform1.ScaleX = e.NewValue
scaleTransform1.ScaleY = e.NewValue
Dim centerOfViewport = New Point(scrollViewer.ViewportWidth / 2, scrollViewer.ViewportHeight / 2)
lastCenterPositionOnTarget = scrollViewer.TranslatePoint(centerOfViewport, grid)
例如以下Slider標籤,ValueChanged事件,將無法執行
若改以在WindowLoaded事件載入,就可以正常運作
AddHandler slider.ValueChanged, AddressOf slider_ValueChanged
Private Sub slider_ValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Double))
Dim i As Integer
scaleTransform1.ScaleX = e.NewValue
scaleTransform1.ScaleY = e.NewValue
Dim centerOfViewport = New Point(scrollViewer.ViewportWidth / 2, scrollViewer.ViewportHeight / 2)
lastCenterPositionOnTarget = scrollViewer.TranslatePoint(centerOfViewport, grid)
WPF Drag-to-Scroll in WPF改寫為VBCode
資料來源
http://blogs.vertigo.com/personal/swarren/Blog/archive/2007/05/30/drag-to-scroll-in-wpf.aspx
改寫VBCODE如下
Xaml
---------------------------
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300" Loaded="Window_Loaded" PreviewMouseDown="Window_PreviewMouseDown" PreviewMouseMove="Window_PreviewMouseMove" PreviewMouseUp="Window_PreviewMouseUp">
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
>
Code
---------------------------
Partial Public Class Window2
Private mouseDragStartPoint As Point
Private scrollStartOffset As Point
Private Sub Window_PreviewMouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
mouseDragStartPoint = e.GetPosition(Me)
scrollStartOffset.X = myScrollViewer.HorizontalOffset
scrollStartOffset.Y = myScrollViewer.VerticalOffset
' Update the cursor if scrolling is possible
'this.Cursor = (myScrollViewer.ExtentWidth > myScrollViewer.ViewportWidth) ||
' (myScrollViewer.ExtentHeight > myScrollViewer.ViewportHeight) ?
' Cursors.ScrollAll : Cursors.Arrow;
Me.CaptureMouse()
MyBase.OnPreviewMouseDown(e)
End Sub
Private Sub Window_PreviewMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
If (Me.IsMouseCaptured) Then
' Get the new mouse position.
Dim mouseDragCurrentPoint As Point = e.GetPosition(Me)
'Determine the new amount to scroll.
Dim delta As New Point
If mouseDragCurrentPoint.X > Me.mouseDragStartPoint.X Then
delta.X = -(mouseDragCurrentPoint.X - Me.mouseDragStartPoint.X)
Else
delta.X = Me.mouseDragStartPoint.X - mouseDragCurrentPoint.X
End If
If mouseDragCurrentPoint.Y > Me.mouseDragStartPoint.Y Then
delta.Y = -(mouseDragCurrentPoint.Y - Me.mouseDragStartPoint.Y)
Else
delta.Y = Me.mouseDragStartPoint.Y - mouseDragCurrentPoint.Y
End If
'Scroll to the new position.
myScrollViewer.ScrollToHorizontalOffset(Me.scrollStartOffset.X + delta.X)
myScrollViewer.ScrollToVerticalOffset(Me.scrollStartOffset.X + delta.Y)
End If
MyBase.OnPreviewMouseMove(e)
End Sub
Private Sub Window_PreviewMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If (Me.IsMouseCaptured) Then
Me.Cursor = Cursors.Arrow
Me.ReleaseMouseCapture()
End If
MyBase.OnPreviewMouseUp(e)
End Sub
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
''center the label initially
myLabel.SetValue(Canvas.LeftProperty, ((myScrollViewer.ExtentWidth / 2) - (myLabel.ActualWidth / 2)))
myLabel.SetValue(Canvas.TopProperty, ((myScrollViewer.ExtentHeight / 2) - (myLabel.ActualHeight / 2)))
myScrollViewer.ScrollToHorizontalOffset((myScrollViewer.ExtentWidth / 2) - (myScrollViewer.ViewportWidth / 2))
myScrollViewer.ScrollToVerticalOffset((myScrollViewer.ExtentHeight / 2) - (myScrollViewer.ViewportHeight / 2))
End Sub
End Class
http://blogs.vertigo.com/personal/swarren/Blog/archive/2007/05/30/drag-to-scroll-in-wpf.aspx
改寫VBCODE如下
Xaml
---------------------------
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300" Loaded="Window_Loaded" PreviewMouseDown="Window_PreviewMouseDown" PreviewMouseMove="Window_PreviewMouseMove" PreviewMouseUp="Window_PreviewMouseUp">
VerticalScrollBarVisibility="Hidden"
>
Code
---------------------------
Partial Public Class Window2
Private mouseDragStartPoint As Point
Private scrollStartOffset As Point
Private Sub Window_PreviewMouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
mouseDragStartPoint = e.GetPosition(Me)
scrollStartOffset.X = myScrollViewer.HorizontalOffset
scrollStartOffset.Y = myScrollViewer.VerticalOffset
' Update the cursor if scrolling is possible
'this.Cursor = (myScrollViewer.ExtentWidth > myScrollViewer.ViewportWidth) ||
' (myScrollViewer.ExtentHeight > myScrollViewer.ViewportHeight) ?
' Cursors.ScrollAll : Cursors.Arrow;
Me.CaptureMouse()
MyBase.OnPreviewMouseDown(e)
End Sub
Private Sub Window_PreviewMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
If (Me.IsMouseCaptured) Then
' Get the new mouse position.
Dim mouseDragCurrentPoint As Point = e.GetPosition(Me)
'Determine the new amount to scroll.
Dim delta As New Point
If mouseDragCurrentPoint.X > Me.mouseDragStartPoint.X Then
delta.X = -(mouseDragCurrentPoint.X - Me.mouseDragStartPoint.X)
Else
delta.X = Me.mouseDragStartPoint.X - mouseDragCurrentPoint.X
End If
If mouseDragCurrentPoint.Y > Me.mouseDragStartPoint.Y Then
delta.Y = -(mouseDragCurrentPoint.Y - Me.mouseDragStartPoint.Y)
Else
delta.Y = Me.mouseDragStartPoint.Y - mouseDragCurrentPoint.Y
End If
'Scroll to the new position.
myScrollViewer.ScrollToHorizontalOffset(Me.scrollStartOffset.X + delta.X)
myScrollViewer.ScrollToVerticalOffset(Me.scrollStartOffset.X + delta.Y)
End If
MyBase.OnPreviewMouseMove(e)
End Sub
Private Sub Window_PreviewMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If (Me.IsMouseCaptured) Then
Me.Cursor = Cursors.Arrow
Me.ReleaseMouseCapture()
End If
MyBase.OnPreviewMouseUp(e)
End Sub
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
''center the label initially
myLabel.SetValue(Canvas.LeftProperty, ((myScrollViewer.ExtentWidth / 2) - (myLabel.ActualWidth / 2)))
myLabel.SetValue(Canvas.TopProperty, ((myScrollViewer.ExtentHeight / 2) - (myLabel.ActualHeight / 2)))
myScrollViewer.ScrollToHorizontalOffset((myScrollViewer.ExtentWidth / 2) - (myScrollViewer.ViewportWidth / 2))
myScrollViewer.ScrollToVerticalOffset((myScrollViewer.ExtentHeight / 2) - (myScrollViewer.ViewportHeight / 2))
End Sub
End Class
WPF 滑鼠滾輪事件MouseWheel 圖片放大縮小
MouseWheel的事件是寫在 WINDOW內,也可以寫在Image (但沒成功,可能要利用事件傳遞來完成!)
XAML
****************************************************
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" MouseWheel="Image_MouseWheel" >
Code
****************************************************
Private Sub Image_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseWheelEventArgs)
If e.Delta > 0 Then
imageScale.ScaleX = imageScale.ScaleX * 1.2
imageScale.ScaleY = imageScale.ScaleY * 1.2
Else
imageScale.ScaleX = imageScale.ScaleX * 0.8
imageScale.ScaleY = imageScale.ScaleY * 0.8
End If
End Sub
XAML
****************************************************
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" MouseWheel="Image_MouseWheel" >
Code
****************************************************
Private Sub Image_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseWheelEventArgs)
If e.Delta > 0 Then
imageScale.ScaleX = imageScale.ScaleX * 1.2
imageScale.ScaleY = imageScale.ScaleY * 1.2
Else
imageScale.ScaleX = imageScale.ScaleX * 0.8
imageScale.ScaleY = imageScale.ScaleY * 0.8
End If
End Sub
WPF 滑鼠滾輪事件MouseWheel
請注意,若有ScrollViewer此事件會被吸收掉。
XAML
'===================================================
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" MouseWheel="Window_MouseWheel" >
程式碼
'===================================================
Private Sub Window_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseWheelEventArgs)
If e.Delta > 0 Then
Me.Title = "往上滾動"
Else
Me.Title = "往下滾動"
End If
End Sub
XAML
'===================================================
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" MouseWheel="Window_MouseWheel" >
程式碼
'===================================================
Private Sub Window_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseWheelEventArgs)
If e.Delta > 0 Then
Me.Title = "往上滾動"
Else
Me.Title = "往下滾動"
End If
End Sub
WPF 滑鼠移動事件
假設已經動態產生以下物件,並指定事件
'設定當滑鼠指標移入 Ellipse 物件上方時所要執行的事件處理常式。
AddHandler Elp.MouseLeftButtonDown, AddressOf Elp_MouseDown
AddHandler Elp.MouseMove, AddressOf Elp_MouseMove
AddHandler Elp.MouseLeftButtonUp, AddressOf Elp_MouseUP
滑鼠事件: 按下
'-----------------------------
Private Sub Elp_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
gloOriPos = e.GetPosition(Me.MYCS) '對哪一個物件取座標位置!
'偵測來源 sender 物件 並進行轉換
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
gloSelObjName = Selobj.Name
Dim idx As Integer = 2
'改變顏色
Selobj.Fill = New SolidColorBrush(Color.FromRgb(ToRGB(idx).R, ToRGB(idx).G, ToRGB(idx).B))
'********** 以目前選取的物件 補捉滑鼠 ********** 這裡很重要
Selobj.CaptureMouse()
Case "System.Windows.Controls.TextBlock"
End Select
End Sub
滑鼠事件: 移動
'-----------------------------
Private Sub Elp_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
'偵測滑鼠左鍵是否仍然被按下
If e.LeftButton = MouseButtonState.Pressed Then
Dim NowPos As Point ' = e.GetPosition(Me.MYCS) '對哪一個物件取座標位置!
NowPos = e.GetPosition(Me.MYCS)
'滑鼠 移動量()
Dim dx As Double = NowPos.X - gloOriPos.X
Dim dy As Double = NowPos.Y - gloOriPos.Y
'Me.Title = e.GetPosition(Me.MYCS).X & "," & e.GetPosition(Me.MYCS).Y
'偵測來源物件並轉型
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
Canvas.SetLeft(Selobj, NowPos.X - (gloEllipseWidth / 2))
Canvas.SetTop(Selobj, NowPos.Y - (gloEllipseWidth / 2))
gloSelObjName = Selobj.Name
'呼叫移動線段的程式碼(假設該目標有好幾個線段連結)
Call LineMove("EL", Selobj)
Case "System.Windows.Controls.TextBlock"
End Select
'紀錄上次的位置
gloOriPos.X = NowPos.X
gloOriPos.Y = NowPos.Y
End If
End Sub
滑鼠事件:放開
'-----------------------------
Private Sub Elp_MouseUP(ByVal sender As Object, ByVal e As MouseEventArgs)
'偵測來源物件並進行轉型
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
gloSelObjName = Selobj.Name
'釋放滑鼠事件
Selobj.ReleaseMouseCapture()
'恢復原來的顏色
Dim idx As Integer = 1
Selobj.Fill = New SolidColorBrush(Color.FromRgb(ToRGB(idx).R, ToRGB(idx).G, ToRGB(idx).B))
Case "System.Windows.Controls.TextBlock"
End Select
End Sub
'設定當滑鼠指標移入 Ellipse 物件上方時所要執行的事件處理常式。
AddHandler Elp.MouseLeftButtonDown, AddressOf Elp_MouseDown
AddHandler Elp.MouseMove, AddressOf Elp_MouseMove
AddHandler Elp.MouseLeftButtonUp, AddressOf Elp_MouseUP
滑鼠事件: 按下
'-----------------------------
Private Sub Elp_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
gloOriPos = e.GetPosition(Me.MYCS) '對哪一個物件取座標位置!
'偵測來源 sender 物件 並進行轉換
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
gloSelObjName = Selobj.Name
Dim idx As Integer = 2
'改變顏色
Selobj.Fill = New SolidColorBrush(Color.FromRgb(ToRGB(idx).R, ToRGB(idx).G, ToRGB(idx).B))
'********** 以目前選取的物件 補捉滑鼠 ********** 這裡很重要
Selobj.CaptureMouse()
Case "System.Windows.Controls.TextBlock"
End Select
End Sub
滑鼠事件: 移動
'-----------------------------
Private Sub Elp_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
'偵測滑鼠左鍵是否仍然被按下
If e.LeftButton = MouseButtonState.Pressed Then
Dim NowPos As Point ' = e.GetPosition(Me.MYCS) '對哪一個物件取座標位置!
NowPos = e.GetPosition(Me.MYCS)
'滑鼠 移動量()
Dim dx As Double = NowPos.X - gloOriPos.X
Dim dy As Double = NowPos.Y - gloOriPos.Y
'Me.Title = e.GetPosition(Me.MYCS).X & "," & e.GetPosition(Me.MYCS).Y
'偵測來源物件並轉型
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
Canvas.SetLeft(Selobj, NowPos.X - (gloEllipseWidth / 2))
Canvas.SetTop(Selobj, NowPos.Y - (gloEllipseWidth / 2))
gloSelObjName = Selobj.Name
'呼叫移動線段的程式碼(假設該目標有好幾個線段連結)
Call LineMove("EL", Selobj)
Case "System.Windows.Controls.TextBlock"
End Select
'紀錄上次的位置
gloOriPos.X = NowPos.X
gloOriPos.Y = NowPos.Y
End If
End Sub
滑鼠事件:放開
'-----------------------------
Private Sub Elp_MouseUP(ByVal sender As Object, ByVal e As MouseEventArgs)
'偵測來源物件並進行轉型
Select Case sender.GetType.ToString
Case "System.Windows.Shapes.Ellipse"
Dim Selobj As Ellipse = TryCast(sender, Ellipse)
gloSelObjName = Selobj.Name
'釋放滑鼠事件
Selobj.ReleaseMouseCapture()
'恢復原來的顏色
Dim idx As Integer = 1
Selobj.Fill = New SolidColorBrush(Color.FromRgb(ToRGB(idx).R, ToRGB(idx).G, ToRGB(idx).B))
Case "System.Windows.Controls.TextBlock"
End Select
End Sub
WPF 新增image於TextBlock內
' 讀取 BitmapImage
Dim Imgbmp As BitmapImage = New BitmapImage()
Dim ImgBrh As ImageBrush = New ImageBrush()
Imgbmp = New BitmapImage(New Uri("\image\mobile.gif", UriKind.RelativeOrAbsolute))
Dim i As Integer
For i = 1 To 5
Dim tb As New TextBlock
Dim img As New Image
img.Source = Imgbmp
img.Name = "IMG_" & i.ToString
tb.Name = "tb_" & i.ToString
'加入textblock元件內
tb.Inlines.Add(img)
tb.Inlines.Add(New Run("想要顯示的識別名稱"))
Canvas.SetLeft(tb, 50 * i)
Canvas.SetTop(tb, 50 * i)
tb.ToolTip = "我的NAME是 " & vbCrLf & vbCrLf & tb.Name
AddHandler tb.MouseMove, AddressOf Elp_MouseMove
AddHandler tb.MouseLeftButtonDown, AddressOf Elp_MouseDown
AddHandler tb.MouseLeftButtonUp, AddressOf Elp_MouseUP
MYCS.Children.Add(tb)
Next
Dim Imgbmp As BitmapImage = New BitmapImage()
Dim ImgBrh As ImageBrush = New ImageBrush()
Imgbmp = New BitmapImage(New Uri("\image\mobile.gif", UriKind.RelativeOrAbsolute))
Dim i As Integer
For i = 1 To 5
Dim tb As New TextBlock
Dim img As New Image
img.Source = Imgbmp
img.Name = "IMG_" & i.ToString
tb.Name = "tb_" & i.ToString
'加入textblock元件內
tb.Inlines.Add(img)
tb.Inlines.Add(New Run("想要顯示的識別名稱"))
Canvas.SetLeft(tb, 50 * i)
Canvas.SetTop(tb, 50 * i)
tb.ToolTip = "我的NAME是 " & vbCrLf & vbCrLf & tb.Name
AddHandler tb.MouseMove, AddressOf Elp_MouseMove
AddHandler tb.MouseLeftButtonDown, AddressOf Elp_MouseDown
AddHandler tb.MouseLeftButtonUp, AddressOf Elp_MouseUP
MYCS.Children.Add(tb)
Next
2010年9月16日 星期四
燒錄簡體檔名 ConvertZ軟體使用
下載位置
http://reg.softking.com.tw/freeware/download.asp?fid3=1763
http://ftp.isu.edu.tw/pub/Windows/softking/soft/cn/c/convertz802.zip
ConvertZ 批次幫檔案、資料夾名稱執行「繁/簡轉換」!
http://briian.com/?p=5784
將整個目錄下面的檔案簡體檔名轉用ConvertZ 轉換OK後,再拖到燒錄軟體內處理即可
http://reg.softking.com.tw/freeware/download.asp?fid3=1763
http://ftp.isu.edu.tw/pub/Windows/softking/soft/cn/c/convertz802.zip
ConvertZ 批次幫檔案、資料夾名稱執行「繁/簡轉換」!
http://briian.com/?p=5784
將整個目錄下面的檔案簡體檔名轉用ConvertZ 轉換OK後,再拖到燒錄軟體內處理即可
2010年9月15日 星期三
JavaScript TextArea 顯示段落符號的問題
引用文章
http://bshadow.pixnet.net/blog/post/23012030
此問題,不是從資料庫內擷取,再將
符號轉換成 \n
若資料是從cookies內讀取出來,要將 \n轉為 \r 或 \r\n
xxx.replace(/\n/g,'\r')
if ($.cookie(ThisA)!='') {
var XXX=$.cookie(ThisA);
XXX =XXX.replace(/\n/g,'\r'); // textarea 回車符號
$("#LoginView1_FormView1_txtContent").text(XXX);
}
http://bshadow.pixnet.net/blog/post/23012030
此問題,不是從資料庫內擷取,再將
符號轉換成 \n
若資料是從cookies內讀取出來,要將 \n轉為 \r 或 \r\n
xxx.replace(/\n/g,'\r')
if ($.cookie(ThisA)!='') {
var XXX=$.cookie(ThisA);
XXX =XXX.replace(/\n/g,'\r'); // textarea 回車符號
$("#LoginView1_FormView1_txtContent").text(XXX);
}
2010年9月8日 星期三
訂閱:
文章 (Atom)