Private Sub treeView1_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles treeView1.AfterLabelEdit
If e.CancelEdit = True Then
Return
End If
If e.Label Is Nothing Or e.Label.Length < 1 Then
e.CancelEdit = True
Return
End If
Dim label As System.Xml.XmlNode = currentNode 'seçili xmlnode
If label.NodeType = XmlNodeType.Element Then
Dim TmpXmlNode As XmlNode = doc.CreateElement(e.Label)
TmpXmlNode.InnerXml = label.InnerXml
If Not label.Attributes Is Nothing Then
For Each a As XmlAttribute In label.Attributes
TmpXmlNode.Attributes.Append(a.Clone)
Next
End If
label.ParentNode.ReplaceChild(TmpXmlNode, label)
doc.Save(XmlFileName)
End If
End Sub
Pazar, Mayıs 31, 2009
Editing xmlnode element name on treeview
Bunuda 2 gündür bulamadım, sonunda yine kendim yaptım
Cuma, Mayıs 29, 2009
Saving Treeview State
treview node larının expand durumunun reloading vb olaylarından sonra tekrar yüklenmesiyle ilgili örnek
google da aradım adam gibi yapan birini bulamadım yok dictionary kullananlar hash yapanlar 12 saatimi aldı. Oturdum 15 dakkada kendim yaptım, bu da ayrı bi delirme nedeni.
vb, visual basic
google da aradım adam gibi yapan birini bulamadım yok dictionary kullananlar hash yapanlar 12 saatimi aldı. Oturdum 15 dakkada kendim yaptım, bu da ayrı bi delirme nedeni.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim SendTree As New TreeNode
SendTree.Nodes.Clear()
CopyExpandeds(SendTree.Nodes, treeView1.Nodes)
'... reloading code u ...
SendExpandeds(treeView1.Nodes, SendTree.Nodes)
'SendExpandeds(treeView1.Nodes, SendTree.Nodes(0))
Dim tmpNode As New TreeNode
SendTree = tmpNode
End Sub
Private Sub CopyExpandeds(ByVal CopyTree As TreeNodeCollection, ByVal SourceTree As TreeNodeCollection)
If SourceTree Is Nothing Then
Exit Sub
End If
For Each Sn As TreeNode In SourceTree
Dim n As New TreeNode
n.Name = Sn.Name
If Sn.IsExpanded Then
n.Expand()
' T ve F ler şart değil, T and F not require
'Kopyalama ve test amaçlı
n.Text = "T"
Else
n.Collapse()
n.Text = "F"
End If
CopyTree.Add(n)
CopyExpandeds(n.Nodes, Sn.Nodes)
Next
End Sub
Sub SendExpandeds(ByVal TargetTree As TreeNodeCollection, ByVal sourcetree As TreeNodeCollection)
If sourcetree Is Nothing Then
Exit Sub
End If
For Each Sn As TreeNode In sourcetree
If Sn.IsExpanded Then
TargetTree.Item(Sn.Index).Expand()
Else
'TargetTree.Item(Sn.Index).Collapse()
End If
SendExpandeds(TargetTree.Item(Sn.Index).Nodes, Sn.Nodes)
Next
End Sub
vb, visual basic
Pazartesi, Mayıs 18, 2009
Ekrandaki bir pixelin rengini okuma ve mouse simulate
Function GetScreenPixel(ByVal pt As Point) As Color
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(pt, Point.Empty, New Size(1, 1))
Return bmp.GetPixel(0, 0)
End Using
End Using
End Function
...
GetScreenPixel(Cursor.Position)
...
Mouse simulasyonu
public class form1
Declare Auto Sub mouse_event Lib "user32" (ByVal dwFlags As Int32, ByVal dx As Int32, ByVal dy As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As IntPtr)
Dim dest_x As Single
Dim dest_y As Single
Const MOUSEEVENTF_MOVE As Int32 = &H1 ' mouse move
Const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP As Int32 = &H4 ' left button up
Const MOUSEEVENTF_RIGHTDOWN As Int32 = &H8 ' right button down
Const MOUSEEVENTF_RIGHTUP As Int32 = &H10 ' right button up
Const MOUSEEVENTF_MIDDLEDOWN As Int32 = &H20 ' middle button down
Const MOUSEEVENTF_MIDDLEUP As Int32 = &H40 ' middle button up
Const MOUSEEVENTF_ABSOLUTE As Int32 = &H8000 ' absolute move
Const MOUSEEVENTF_WHEEL As Int32 = &H800 ' wheel button rolled
...
mouse_event(MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE + MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, dest_x, dest_y, 0, 0)
...
Kaydol:
Kayıtlar (Atom)