mod(x*3;(x*3)-1)=
eğer x sıfırdan büyükse sonuç=1 değilse sonuç=0 olur
(=if x greater zero then result=1 else result=0)
t=O time
yani süper zamanlı hesaplanan bi fonksiyon.
(x*3) mod ((x*3)-1) = (1 or 0)
Cuma, Temmuz 24, 2009
Pazartesi, Temmuz 20, 2009
Modular Base Converter
Convert fonksiyonu onluk düzene göre gönderilen M sayısı N tabanına çevirir. burdaki N > 0 ve N < 10 için. gelişmişi bende saklı..
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim base As Integer = CInt(TextBox3.Text)
TextBox2.Text = Convert(CInt(TextBox1.Text), base)
End Sub
Function Convert(ByVal M As Double, ByVal N As Integer) As String
If M < N Then
Return ("" & Math.Floor(M).ToString)
Exit Function
Else
Return Convert(Math.Floor(M / N), N) & ("" & (M Mod N).ToString)
End If
End Function
End Class
Perşembe, Haziran 04, 2009
Using SyntaxHighlighter on BLOGGER
http://developertips.blogspot.com/2007/08/syntaxhighlighter-on-blogger.html
http://alexgorbatchev.com/
http://alexgorbatchev.com/
Salı, Haziran 02, 2009
Textbox on focus
kolaymış gibi görünüyo ama beni 12 saat uğraştırdı bu focus, eğer imleç treeview node u içinde edit durumundaysa treeview_beforelabeledit subunun içine e.CancelEdit = true yazmak gerekiyomuş. yoksa textboxa focuslanamıyo.
Private Sub treeView1_BeforeLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles treeView1.BeforeLabelEdit
If e.Node.ImageIndex = 1 Then
RemoveHandler treeView1.AfterLabelEdit, AddressOf treeView1_AfterLabelEdit
e.CancelEdit = True
AddDoubleEdit(e)
End If
End Sub
Public Sub AddDoubleEdit(ByVal e As NodeLabelEditEventArgs)
RemoveHandler treeView1.BeforeLabelEdit, AddressOf treeView1_BeforeLabelEdit
treeView1.Controls.Add(DoubleEdit1)
DoubleEdit1.Bounds = e.Node.Bounds
'DoubleEdit1.TabIndex = 0
transNode = e.Node
DoubleEdit1.Name = "DoubleEdit1"
treeView1.LabelEdit = False
Me.Focus()
Me.Select()
End Sub
Sub DoubleEdit1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DoubleEdit1.Leave
treeView1.LabelEdit = True
AddHandler treeView1.BeforeLabelEdit, AddressOf treeView1_BeforeLabelEdit
AddHandler treeView1.AfterLabelEdit, AddressOf treeView1_AfterLabelEdit
transNode.Name = DoubleEdit1.Text
transNode.Text = DoubleEdit1.Text
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
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
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)