elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 ... 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 ... 58 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 480,098 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #360 en: 12 Enero 2014, 09:30 am »

Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Created  : 01-12-2014
  4. ' Modified : 01-12-2014
  5. ' ***********************************************************************
  6. ' <copyright file="FormBorderManager.vb" company="Elektro Studios">
  7. '     Copyright (c) Elektro Studios. All rights reserved.
  8. ' </copyright>
  9. ' ***********************************************************************
  10.  
  11. #Region " Usage Examples "
  12.  
  13. 'Public Class Form1
  14.  
  15. '    ' Disable resizing on all border edges.
  16. '    Private FormBorders As New FormBorderManager(Me) With
  17. '            {
  18. '                .Edges = New FormBorderManager.FormEdges With
  19. '                         {
  20. '                             .Top = FormBorderManager.WindowHitTestRegions.TitleBar,
  21. '                             .Left = FormBorderManager.WindowHitTestRegions.TitleBar,
  22. '                             .Right = FormBorderManager.WindowHitTestRegions.TitleBar,
  23. '                             .Bottom = FormBorderManager.WindowHitTestRegions.TitleBar,
  24. '                             .TopLeft = FormBorderManager.WindowHitTestRegions.TitleBar,
  25. '                             .TopRight = FormBorderManager.WindowHitTestRegions.TitleBar,
  26. '                             .BottomLeft = FormBorderManager.WindowHitTestRegions.TitleBar,
  27. '                             .BottomRight = FormBorderManager.WindowHitTestRegions.TitleBar
  28. '                         }
  29. '            }
  30.  
  31. '    Private Shadows Sub Load(sender As Object, e As EventArgs) Handles MyBase.Load
  32.  
  33. '        ' Disables the moving on all border edges.
  34. '        FormBorders.SetAllEdgesToNonMoveable()
  35.  
  36. '    End Sub
  37.  
  38. 'End Class
  39.  
  40. #End Region
  41.  
  42. #Region " Imports "
  43.  
  44. Imports System.ComponentModel
  45.  
  46. #End Region
  47.  
  48. #Region " FormBorderManager "
  49.  
  50. ''' <summary>
  51. ''' Class FormBorderManager.
  52. ''' Manages each Form border to indicate their Hit-Region.
  53. ''' </summary>
  54. <Description("Manages each Form border to indicate their Hit-Region")>
  55. Public Class FormBorderManager : Inherits NativeWindow : Implements IDisposable
  56.  
  57. #Region " Members "
  58.  
  59. #Region " Miscellaneous "
  60.  
  61.    ''' <summary>
  62.    ''' The form to manage their borders.
  63.    ''' </summary>
  64.    Private WithEvents form As Form = Nothing
  65.  
  66. #End Region
  67.  
  68. #Region " Properties "
  69.  
  70.    ''' <summary>
  71.    ''' Gets or sets the Hit-Region of the edges.
  72.    ''' </summary>
  73.    ''' <value>The Form edges.</value>
  74.    Public Property Edges As New FormEdges
  75.  
  76.    ''' <summary>
  77.    ''' The Edges of the Form.
  78.    ''' </summary>
  79.    Partial Public NotInheritable Class FormEdges
  80.  
  81.        ''' <summary>
  82.        ''' Gets or sets the Hit-Region of the Top form border.
  83.        ''' </summary>
  84.        Public Property Top As WindowHitTestRegions = WindowHitTestRegions.TopSizeableBorder
  85.  
  86.        ''' <summary>
  87.        ''' Gets or sets the Hit-Region of the Left form border.
  88.        ''' </summary>
  89.        Public Property Left As WindowHitTestRegions = WindowHitTestRegions.LeftSizeableBorder
  90.  
  91.        ''' <summary>
  92.        ''' Gets or sets the Hit-Region of the Right form border.
  93.        ''' </summary>
  94.        Public Property Right As WindowHitTestRegions = WindowHitTestRegions.RightSizeableBorder
  95.  
  96.        ''' <summary>
  97.        ''' Gets or sets the Hit-Region of the Bottom form border.
  98.        ''' </summary>
  99.        Public Property Bottom As WindowHitTestRegions = WindowHitTestRegions.BottomSizeableBorder
  100.  
  101.        ''' <summary>
  102.        ''' Gets or sets the Hit-Region of the Top-Left form border.
  103.        ''' </summary>
  104.        Public Property TopLeft As WindowHitTestRegions = WindowHitTestRegions.TopLeftSizeableCorner
  105.  
  106.        ''' <summary>
  107.        ''' Gets or sets the Hit-Region of the Top-Right form border.
  108.        ''' </summary>
  109.        Public Property TopRight As WindowHitTestRegions = WindowHitTestRegions.TopRightSizeableCorner
  110.  
  111.        ''' <summary>
  112.        ''' Gets or sets the Hit-Region of the Bottom-Left form border.
  113.        ''' </summary>
  114.        Public Property BottomLeft As WindowHitTestRegions = WindowHitTestRegions.BottomLeftSizeableCorner
  115.  
  116.        ''' <summary>
  117.        ''' Gets or sets the Hit-Region of the Bottom-Right form border.
  118.        ''' </summary>
  119.        Public Property BottomRight As WindowHitTestRegions = WindowHitTestRegions.BottomRightSizeableCorner
  120.  
  121.    End Class
  122.  
  123. #End Region
  124.  
  125. #Region " Enumerations "
  126.  
  127.    ''' <summary>
  128.    ''' Known Windows Message Identifiers.
  129.    ''' </summary>
  130.    <Description("Messages to process in WndProc")>
  131.    Private Enum KnownMessages As Integer
  132.  
  133.        ''' <summary>
  134.        ''' Sent to a window in order to determine what part of the window corresponds to a particular screen coordinate.
  135.        ''' This can happen, for example, when the cursor moves, when a mouse button is pressed or released,
  136.        ''' or in response to a call to a function such as WindowFromPoint.
  137.        ''' If the mouse is not captured, the message is sent to the window beneath the cursor.
  138.        ''' Otherwise, the message is sent to the window that has captured the mouse.
  139.        ''' <paramref name="WParam" />
  140.        ''' This parameter is not used.
  141.        ''' <paramref name="LParam" />
  142.        ''' The low-order word specifies the x-coordinate of the cursor.
  143.        ''' The coordinate is relative to the upper-left corner of the screen.
  144.        ''' The high-order word specifies the y-coordinate of the cursor.
  145.        ''' The coordinate is relative to the upper-left corner of the screen.
  146.        ''' </summary>
  147.        WM_NCHITTEST = &H84
  148.  
  149.    End Enum
  150.  
  151.    ''' <summary>
  152.    ''' Indicates the position of the cursor hot spot.
  153.    ''' Options available when a form is tested for mose positions with 'WM_NCHITTEST' message.
  154.    ''' </summary>
  155.    <Description("Return value of the 'WM_NCHITTEST' message")>
  156.    Public Enum WindowHitTestRegions
  157.  
  158.        ''' <summary>
  159.        ''' HTERROR: On the screen background or on a dividing line between windows.
  160.        ''' (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error).
  161.        ''' </summary>
  162.        [Error] = -2
  163.  
  164.        ''' <summary>
  165.        ''' HTTRANSPARENT: In a window currently covered by another window in the same thread.
  166.        ''' (the message will be sent to underlying windows in the same thread
  167.        ''' until one of them returns a code that is not HTTRANSPARENT).
  168.        ''' </summary>
  169.        TransparentOrCovered = -1
  170.  
  171.        ''' <summary>
  172.        ''' HTNOWHERE: On the screen background or on a dividing line between windows.
  173.        ''' </summary>
  174.        NoWhere = 0
  175.  
  176.        ''' <summary>
  177.        ''' HTCLIENT: In a client area.
  178.        ''' </summary>
  179.        ClientArea = 1
  180.  
  181.        ''' <summary>
  182.        ''' HTCAPTION: In a title bar.
  183.        ''' </summary>
  184.        TitleBar = 2
  185.  
  186.        ''' <summary>
  187.        ''' HTSYSMENU: In a window menu or in a Close button in a child window.
  188.        ''' </summary>
  189.        SystemMenu = 3
  190.  
  191.        ''' <summary>
  192.        ''' HTGROWBOX: In a size box (same as HTSIZE).
  193.        ''' </summary>
  194.        GrowBox = 4
  195.  
  196.        ''' <summary>
  197.        ''' HTMENU: In a menu.
  198.        ''' </summary>
  199.        Menu = 5
  200.  
  201.        ''' <summary>
  202.        ''' HTHSCROLL: In a horizontal scroll bar.
  203.        ''' </summary>
  204.        HorizontalScrollBar = 6
  205.  
  206.        ''' <summary>
  207.        ''' HTVSCROLL: In the vertical scroll bar.
  208.        ''' </summary>
  209.        VerticalScrollBar = 7
  210.  
  211.        ''' <summary>
  212.        ''' HTMINBUTTON: In a Minimize button.
  213.        ''' </summary>
  214.        MinimizeButton = 8
  215.  
  216.        ''' <summary>
  217.        ''' HTMAXBUTTON: In a Maximize button.
  218.        ''' </summary>
  219.        MaximizeButton = 9
  220.  
  221.        ''' <summary>
  222.        ''' HTLEFT: In the left border of a resizable window.
  223.        ''' (the user can click the mouse to resize the window horizontally).
  224.        ''' </summary>
  225.        LeftSizeableBorder = 10
  226.  
  227.        ''' <summary>
  228.        ''' HTRIGHT: In the right border of a resizable window.
  229.        ''' (the user can click the mouse to resize the window horizontally).
  230.        ''' </summary>
  231.        RightSizeableBorder = 11
  232.  
  233.        ''' <summary>
  234.        ''' HTTOP: In the upper-horizontal border of a window.
  235.        ''' </summary>
  236.        TopSizeableBorder = 12
  237.  
  238.        ''' <summary>
  239.        ''' HTTOPLEFT: In the upper-left corner of a window border.
  240.        ''' </summary>
  241.        TopLeftSizeableCorner = 13
  242.  
  243.        ''' <summary>
  244.        ''' HTTOPRIGHT: In the upper-right corner of a window border.
  245.        ''' </summary>
  246.        TopRightSizeableCorner = 14
  247.  
  248.        ''' <summary>
  249.        ''' HTBOTTOM: In the lower-horizontal border of a resizable window.
  250.        ''' (the user can click the mouse to resize the window vertically).
  251.        ''' </summary>
  252.        BottomSizeableBorder = 15
  253.  
  254.        ''' <summary>
  255.        ''' HTBOTTOMLEFT: In the lower-left corner of a border of a resizable window.
  256.        ''' (the user can click the mouse to resize the window diagonally).
  257.        ''' </summary>
  258.        BottomLeftSizeableCorner = 16
  259.  
  260.        ''' <summary>
  261.        ''' HTBOTTOMRIGHT: In the lower-right corner of a border of a resizable window.
  262.        ''' (the user can click the mouse to resize the window diagonally).
  263.        ''' </summary>
  264.        BottomRightSizeableCorner = 17
  265.  
  266.        ''' <summary>
  267.        ''' HTBORDER: In the border of a window that does not have a sizing border.
  268.        ''' </summary>
  269.        NonSizableBorder = 18
  270.  
  271.        ' ''' <summary>
  272.        ' ''' HTOBJECT: Not implemented.
  273.        ' ''' </summary>
  274.        ' [Object] = 19
  275.  
  276.        ''' <summary>
  277.        ''' HTCLOSE: In a Close button.
  278.        ''' </summary>
  279.        CloseButton = 20
  280.  
  281.        ''' <summary>
  282.        ''' HTHELP: In a Help button.
  283.        ''' </summary>
  284.        HelpButton = 21
  285.  
  286.        ''' <summary>
  287.        ''' HTSIZE: In a size box (same as HTGROWBOX).
  288.        ''' (Same as GrowBox).
  289.        ''' </summary>
  290.        SizeBox = GrowBox
  291.  
  292.        ''' <summary>
  293.        ''' HTREDUCE: In a Minimize button.
  294.        ''' (Same as MinimizeButton).
  295.        ''' </summary>
  296.        ReduceButton = MinimizeButton
  297.  
  298.        ''' <summary>
  299.        ''' HTZOOM: In a Maximize button.
  300.        ''' (Same as MaximizeButton).
  301.        ''' </summary>
  302.        ZoomButton = MaximizeButton
  303.  
  304.    End Enum
  305.  
  306. #End Region
  307.  
  308. #End Region
  309.  
  310. #Region " Constructor "
  311.  
  312.    ''' <summary>
  313.    ''' Initializes a new instance of the <see cref="FormBorderManager"/> class.
  314.    ''' </summary>
  315.    ''' <param name="form">The form to assign.</param>
  316.    Public Sub New(ByVal form As Form)
  317.  
  318.        ' Assign the Formulary.
  319.        Me.form = form
  320.  
  321.        ' Assign the form handle.
  322.        Me.SetFormHandle()
  323.  
  324.    End Sub
  325.  
  326. #End Region
  327.  
  328. #Region " Event Handlers "
  329.  
  330.    ''' <summary>
  331.    ''' Assign the handle of the target form to this NativeWindow,
  332.    ''' necessary to override WndProc.
  333.    ''' </summary>
  334.    Private Sub SetFormHandle() _
  335.    Handles Form.HandleCreated, Form.Load, Form.Shown
  336.  
  337.        Try
  338.            If Not MyBase.Handle.Equals(Me.form.Handle) Then
  339.                MyBase.AssignHandle(Me.form.Handle)
  340.            End If
  341.        Catch ' ex As InvalidOperationException
  342.        End Try
  343.  
  344.    End Sub
  345.  
  346.    ''' <summary>
  347.    ''' Releases the Handle.
  348.    ''' </summary>
  349.    Private Sub OnHandleDestroyed() _
  350.    Handles Form.HandleDestroyed
  351.  
  352.        MyBase.ReleaseHandle()
  353.  
  354.    End Sub
  355.  
  356. #End Region
  357.  
  358. #Region " WndProc "
  359.  
  360.    ''' <summary>
  361.    ''' Invokes the default window procedure associated with this window to process messages for this Window.
  362.    ''' </summary>
  363.    ''' <param name="m">
  364.    ''' A <see cref="T:System.Windows.Forms.Message" /> that is associated with the current Windows message.
  365.    ''' </param>
  366.    Protected Overrides Sub WndProc(ByRef m As Message)
  367.  
  368.        MyBase.WndProc(m)
  369.  
  370.        Select Case m.Msg
  371.  
  372.            Case KnownMessages.WM_NCHITTEST
  373.  
  374.                Select Case CType(m.Result, WindowHitTestRegions)
  375.  
  376.                    Case WindowHitTestRegions.TopSizeableBorder ' The mouse hotspot is pointing to Top border.
  377.                        m.Result = New IntPtr(Edges.Top)
  378.  
  379.                    Case WindowHitTestRegions.LeftSizeableBorder ' The mouse hotspot is pointing to Left border.
  380.                        m.Result = New IntPtr(Edges.Left)
  381.  
  382.                    Case WindowHitTestRegions.RightSizeableBorder ' The mouse hotspot is pointing to Right border.
  383.                        m.Result = New IntPtr(Edges.Right)
  384.  
  385.                    Case WindowHitTestRegions.BottomSizeableBorder ' The mouse hotspot is pointing to Bottom border.
  386.                        m.Result = New IntPtr(Edges.Bottom)
  387.  
  388.                    Case WindowHitTestRegions.TopLeftSizeableCorner ' The mouse hotspot is pointing to Top-Left border.
  389.                        m.Result = New IntPtr(Edges.TopLeft)
  390.  
  391.                    Case WindowHitTestRegions.TopRightSizeableCorner ' The mouse hotspot is pointing to Top-Right border.
  392.                        m.Result = New IntPtr(Edges.TopRight)
  393.  
  394.                    Case WindowHitTestRegions.BottomLeftSizeableCorner ' The mouse hotspot is pointing to Bottom-Left border.
  395.                        m.Result = New IntPtr(Edges.BottomLeft)
  396.  
  397.                    Case WindowHitTestRegions.BottomRightSizeableCorner ' The mouse hotspot is pointing to Bottom-Right border.
  398.                        m.Result = New IntPtr(Edges.BottomRight)
  399.  
  400.                End Select
  401.  
  402.        End Select
  403.  
  404.    End Sub
  405.  
  406. #End Region
  407.  
  408. #Region " Public Methods "
  409.  
  410.    ''' <summary>
  411.    ''' Disables the resizing on all border edges.
  412.    ''' </summary>
  413.    Public Sub SetAllEdgesToNonResizable()
  414.  
  415.        DisposedCheck()
  416.  
  417.        Me.Edges.Top = WindowHitTestRegions.TitleBar
  418.        Me.Edges.Left = WindowHitTestRegions.TitleBar
  419.        Me.Edges.Right = WindowHitTestRegions.TitleBar
  420.        Me.Edges.Bottom = WindowHitTestRegions.TitleBar
  421.        Me.Edges.TopLeft = WindowHitTestRegions.TitleBar
  422.        Me.Edges.TopRight = WindowHitTestRegions.TitleBar
  423.        Me.Edges.BottomLeft = WindowHitTestRegions.TitleBar
  424.        Me.Edges.BottomRight = WindowHitTestRegions.TitleBar
  425.  
  426.    End Sub
  427.  
  428.    ''' <summary>
  429.    ''' Enables the resizing on all border edges.
  430.    ''' </summary>
  431.    Public Sub SetAllEdgesToResizable()
  432.  
  433.        DisposedCheck()
  434.  
  435.        Me.Edges.Top = WindowHitTestRegions.TopSizeableBorder
  436.        Me.Edges.Left = WindowHitTestRegions.LeftSizeableBorder
  437.        Me.Edges.Right = WindowHitTestRegions.RightSizeableBorder
  438.        Me.Edges.Bottom = WindowHitTestRegions.BottomSizeableBorder
  439.        Me.Edges.TopLeft = WindowHitTestRegions.TopLeftSizeableCorner
  440.        Me.Edges.TopRight = WindowHitTestRegions.TopRightSizeableCorner
  441.        Me.Edges.BottomLeft = WindowHitTestRegions.BottomLeftSizeableCorner
  442.        Me.Edges.BottomRight = WindowHitTestRegions.BottomRightSizeableCorner
  443.  
  444.    End Sub
  445.  
  446.    ''' <summary>
  447.    ''' Enabled the moving on all border edges.
  448.    ''' </summary>
  449.    Public Sub SetAllEdgesToMoveable()
  450.  
  451.        DisposedCheck()
  452.  
  453.        Me.Edges.Top = WindowHitTestRegions.TopSizeableBorder
  454.        Me.Edges.Left = WindowHitTestRegions.LeftSizeableBorder
  455.        Me.Edges.Right = WindowHitTestRegions.RightSizeableBorder
  456.        Me.Edges.Bottom = WindowHitTestRegions.BottomSizeableBorder
  457.        Me.Edges.TopLeft = WindowHitTestRegions.TopLeftSizeableCorner
  458.        Me.Edges.TopRight = WindowHitTestRegions.TopRightSizeableCorner
  459.        Me.Edges.BottomLeft = WindowHitTestRegions.BottomLeftSizeableCorner
  460.        Me.Edges.BottomRight = WindowHitTestRegions.BottomRightSizeableCorner
  461.  
  462.    End Sub
  463.  
  464.    ''' <summary>
  465.    ''' Disables the moving on all border edges.
  466.    ''' </summary>
  467.    Public Sub SetAllEdgesToNonMoveable()
  468.  
  469.        DisposedCheck()
  470.  
  471.        Me.Edges.Top = WindowHitTestRegions.NoWhere
  472.        Me.Edges.Left = WindowHitTestRegions.NoWhere
  473.        Me.Edges.Right = WindowHitTestRegions.NoWhere
  474.        Me.Edges.Bottom = WindowHitTestRegions.NoWhere
  475.        Me.Edges.TopLeft = WindowHitTestRegions.NoWhere
  476.        Me.Edges.TopRight = WindowHitTestRegions.NoWhere
  477.        Me.Edges.BottomLeft = WindowHitTestRegions.NoWhere
  478.        Me.Edges.BottomRight = WindowHitTestRegions.NoWhere
  479.  
  480.    End Sub
  481.  
  482. #End Region
  483.  
  484. #Region " Hidden methods "
  485.  
  486.    ' These methods and properties are purposely hidden from Intellisense just to look better without unneeded methods.
  487.    ' NOTE: The methods can be re-enabled at any-time if needed.
  488.  
  489.    ''' <summary>
  490.    ''' Assigns the handle.
  491.    ''' </summary>
  492.    <EditorBrowsable(EditorBrowsableState.Never)>
  493.    Public Shadows Sub AssignHandle()
  494.    End Sub
  495.  
  496.    ''' <summary>
  497.    ''' Creates the handle.
  498.    ''' </summary>
  499.    <EditorBrowsable(EditorBrowsableState.Never)>
  500.    Public Shadows Sub CreateHandle()
  501.    End Sub
  502.  
  503.    ''' <summary>
  504.    ''' Creates the object reference.
  505.    ''' </summary>
  506.    <EditorBrowsable(EditorBrowsableState.Never)>
  507.    Public Shadows Sub CreateObjRef()
  508.    End Sub
  509.  
  510.    ''' <summary>
  511.    ''' Definitions the WND proc.
  512.    ''' </summary>
  513.    <EditorBrowsable(EditorBrowsableState.Never)>
  514.    Public Shadows Sub DefWndProc()
  515.    End Sub
  516.  
  517.    ''' <summary>
  518.    ''' Destroys the window and its handle.
  519.    ''' </summary>
  520.    <EditorBrowsable(EditorBrowsableState.Never)>
  521.    Public Shadows Sub DestroyHandle()
  522.    End Sub
  523.  
  524.    ''' <summary>
  525.    ''' Equalses this instance.
  526.    ''' </summary>
  527.    <EditorBrowsable(EditorBrowsableState.Never)>
  528.    Public Shadows Sub Equals()
  529.    End Sub
  530.  
  531.    ''' <summary>
  532.    ''' Gets the hash code.
  533.    ''' </summary>
  534.    <EditorBrowsable(EditorBrowsableState.Never)>
  535.    Public Shadows Sub GetHashCode()
  536.    End Sub
  537.  
  538.    ''' <summary>
  539.    ''' Gets the lifetime service.
  540.    ''' </summary>
  541.    <EditorBrowsable(EditorBrowsableState.Never)>
  542.    Public Shadows Sub GetLifetimeService()
  543.    End Sub
  544.  
  545.    ''' <summary>
  546.    ''' Initializes the lifetime service.
  547.    ''' </summary>
  548.    <EditorBrowsable(EditorBrowsableState.Never)>
  549.    Public Shadows Sub InitializeLifetimeService()
  550.    End Sub
  551.  
  552.    ''' <summary>
  553.    ''' Releases the handle associated with this window.
  554.    ''' </summary>
  555.    <EditorBrowsable(EditorBrowsableState.Never)>
  556.    Public Shadows Sub ReleaseHandle()
  557.    End Sub
  558.  
  559.    ''' <summary>
  560.    ''' Gets the handle for this window.
  561.    ''' </summary>
  562.    <EditorBrowsable(EditorBrowsableState.Never)>
  563.    Public Shadows Property Handle()
  564.  
  565. #End Region
  566.  
  567. #Region " IDisposable "
  568.  
  569.    ''' <summary>
  570.    ''' To detect redundant calls when disposing.
  571.    ''' </summary>
  572.    Private IsDisposed As Boolean = False
  573.  
  574.    ''' <summary>
  575.    ''' Prevent calls to methods after disposing.
  576.    ''' </summary>
  577.    ''' <exception cref="System.ObjectDisposedException"></exception>
  578.    Private Sub DisposedCheck()
  579.        If Me.IsDisposed Then
  580.            Throw New ObjectDisposedException(Me.GetType().FullName)
  581.        End If
  582.    End Sub
  583.  
  584.    ''' <summary>
  585.    ''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  586.    ''' </summary>
  587.    Public Sub Dispose() Implements IDisposable.Dispose
  588.        Dispose(True)
  589.        GC.SuppressFinalize(Me)
  590.    End Sub
  591.  
  592.    ''' <summary>
  593.    ''' Releases unmanaged and - optionally - managed resources.
  594.    ''' </summary>
  595.    ''' <param name="IsDisposing">
  596.    ''' <c>true</c> to release both managed and unmanaged resources;
  597.    ''' <c>false</c> to release only unmanaged resources.
  598.    ''' </param>
  599.  
  600.    Protected Sub Dispose(IsDisposing As Boolean)
  601.  
  602.        If Not Me.IsDisposed Then
  603.  
  604.            If IsDisposing Then
  605.                Me.form = Nothing
  606.                MyBase.ReleaseHandle()
  607.                MyBase.DestroyHandle()
  608.            End If
  609.  
  610.        End If
  611.  
  612.        Me.IsDisposed = True
  613.  
  614.    End Sub
  615.  
  616. #End Region
  617.  
  618. End Class
  619.  
  620. #End Region


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #361 en: 13 Enero 2014, 17:46 pm »

Una Helper Class con utilidades variadas relacionadas con los colores:

Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Created  : 01-13-2014
  4. ' Modified : 01-13-2014
  5. ' ***********************************************************************
  6.  
  7. ' --------------
  8. ' Public Methods
  9. ' --------------
  10. '
  11. ' Screen.GetPixelColor
  12. ' Screen.GetPixelBrush
  13. ' Screen.GetPixelPen
  14. '
  15. ' ColorConvert.ColorToBrush
  16. ' ColorConvert.ColorToPen
  17. ' ColorConvert.BrushToColor
  18. ' ColorConvert.PentoColor
  19. '
  20. ' StringConvert.ColorToString
  21. ' StringConvert.BrushToString
  22. ' StringConvert.PenToString
  23. ' StringConvert.StringToColor
  24. ' StringConvert.StringToBrush
  25. ' StringConvert.StringToPen
  26. ' StringConvert.StringToString
  27. '
  28. ' RandomGenerators.ARGB
  29. ' RandomGenerators.RGB
  30. ' RandomGenerators.QB
  31. ' RandomGenerators.ConsoleColor
  32. ' RandomGenerators.Brush
  33. ' RandomGenerators.Pen

La Class no cabe en un post, aquí la pueden ver ~> http://pastebin.com/88Q0wGPf

Ejemplos de uso:

Código
  1. ' Gets the color of the pixel at the 50,100 coordinates:
  2. Dim c As Color = ColorTools.Screen.GetPixelColor(50, 100)
  3.  
  4. ' Generates a random Brush
  5. Dim br As SolidBrush = ColorTools.RandomGenerators.Brush
  6.  
  7. ' Converts a SolidBrush to a Color:
  8. Dim c As Color = ColorTools.ColorConvert.BrushToColor(New SolidBrush(Color.Red))
  9.  
  10. ' Converts an HTML Color-String to a Color:
  11. PictureBox1.BackColor = ColorTools.StringConvert.StringToColor("#FF00FFFF",
  12.                                                                ColorTools.StringConvert.ValueFormat.HTML,
  13.                                                                ColorTools.StringConvert.StringSyntax.None)
  14.  
  15. ' Converts an Hex Color-String to a Color:
  16. MsgBox(ColorTools.StringConvert.StringToColor("0x003399",
  17.                                               ColorTools.StringConvert.ValueFormat.Hexadecimal,
  18.                                               ColorTools.StringConvert.StringSyntax.None))
  19.  
  20. ' Converts a Byte Color-String with VisyalStudio's property grid syntax to a Color:
  21. MsgBox(ColorTools.StringConvert.StringToColor("255; 255; 255; 255",
  22.                                               ColorTools.StringConvert.ValueFormat.Byte,
  23.                                               ColorTools.StringConvert.StringSyntax.VisualStudioPropertyGrid).
  24.                                               Name)
  25.  
  26. ' Converts a HEX Color-String with VB.NET syntax to a Color:
  27. MsgBox(ColorTools.StringConvert.StringToColor("Color.FromArgb(&HFF, &H5F, &HEC, &H12)",
  28.                                               ColorTools.StringConvert.ValueFormat.Hexadecimal,
  29.                                               ColorTools.StringConvert.StringSyntax.VBNET).
  30.                                               ToString)
  31.  
  32. ' Converts an HTML Color-String with C# Syntax to a Brush:
  33. Dim br As Brush = ColorTools.StringConvert.StringToBrush("ColorTranslator.FromHtml(""#F71608"");",
  34.                                                          ColorTools.StringConvert.ValueFormat.HTML,
  35.                                                          ColorTools.StringConvert.StringSyntax.VBNET)
  36.  
  37. ' Converts a Color-String to other Color-String:
  38. MsgBox(ColorTools.StringConvert.StringToString("ColorTranslator.FromHtml(""#AF0CCAFE"");",
  39.                                                ColorTools.StringConvert.ValueFormat.HTML,
  40.                                                ColorTools.StringConvert.StringSyntax.CSharp,
  41.                                                ColorTools.StringConvert.ValueFormat.Byte,
  42.                                                ColorTools.StringConvert.StringSyntax.None,
  43.                                                True))





« Última modificación: 13 Enero 2014, 18:02 pm por Eleкtro » En línea

CatadorDeVeneno

Desconectado Desconectado

Mensajes: 38


Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #362 en: 13 Enero 2014, 18:11 pm »

A mi no me deja descargar, ¿me podrias facilitar un enlace por MP?
Muy buen aporte!!
Muchas gracias!!
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #363 en: 13 Enero 2014, 18:35 pm »

A mi no me deja descargar, ¿me podrias facilitar un enlace por MP?

Hola,
He actualizado el enlace en la primera página ~> http://www.mediafire.com/download/ms5r82x12y32p8a/My%20Code%20Snippets.rar

Saludos!
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #364 en: 15 Enero 2014, 22:38 pm »

Una forma muy, muy sencilla de implementar una evaluación Trial del programa, usando la librería CryptoLicensing.

NOTA: El tipo de protección y checkeos, ya sea una evaluación trial, un límite de máquinas o un límite de usos, o una comprobación hardware-id ...todo se genera desde la aplicación de CryptoLicensing y queda registrado en la propiedad "LicenseCode"... mi ayudante está pensado para una evaluación muy sencilla y básica sin posibilidad de validar, es decir, no está pensado para evaluar licencias válidas ...sinó más bien para restringir la aplicación a un máximo de usos y/o duración de ejecución y/o dias, todavía no he indagado mucho en el modo de uso de la librería.

Código
  1. ' CryptoLicense Helper
  2. ' ( By Elektro )
  3. '
  4. ' Usage Examples:
  5. ' Dim MyLicense As New Licenser
  6.  
  7. #Region " Imports "
  8.  
  9. Imports LogicNP.CryptoLicensing
  10. Imports System.Windows.Forms
  11.  
  12. #End Region
  13.  
  14. ''' <summary>
  15. ''' Manages the license of this Application.
  16. ''' </summary>
  17. Public Class Licenser
  18.  
  19. #Region " Members "
  20.  
  21.    ''' <summary>
  22.    ''' The license object.
  23.    ''' </summary>
  24.    Public WithEvents License As CryptoLicense =
  25.        New CryptoLicense() With
  26.        {
  27.            .ValidationKey = "AMAAMACSde6/zo6beBTzxAC5D9qrf6OyReAJwGB30gMr5ViI1/+ZXRzwt7M+KnraMKNkaREDAAEAAQ==",
  28.            .LicenseCode = "FgCAABguQrc4Es8BAQETTsmKhj/OGCuTbJzExXb9GO7sx3yR6wQIGynJ76g7DyxOU0zgSZ82lYtuIa8r9m8="
  29.        }
  30.  
  31.    ''' <summary>
  32.    ''' The license message to display on a MessageBox.
  33.    ''' </summary>
  34.    Private LicenseMessage As String = String.Empty
  35.  
  36. #End Region
  37.  
  38. #Region " Constructor "
  39.  
  40.    ''' <summary>
  41.    ''' Initializes a new instance of the <see cref="Licenser"/> class.
  42.    ''' </summary>
  43.    Public Sub New()
  44.  
  45.        Select Case License.Status
  46.  
  47.            Case LicenseStatus.Valid
  48.                OnValid()
  49.  
  50.            Case LicenseStatus.InValid
  51.                OnInvalid()
  52.  
  53.            Case LicenseStatus.Expired
  54.                OnExpired()
  55.  
  56.            Case LicenseStatus.UsageDaysExceeded
  57.                OnUsageDaysExceeded()
  58.  
  59.            Case LicenseStatus.ExecutionsExceeded
  60.                OnExecutionsExceeded()
  61.  
  62.        End Select
  63.  
  64.    End Sub
  65.  
  66. #End Region
  67.  
  68. #Region " Methods "
  69.  
  70.    ''' <summary>
  71.    ''' Called when license status is valid.
  72.    ''' </summary>
  73.    Private Sub OnValid()
  74.  
  75.        If License.RemainingUsageDays <> Short.MaxValue Then
  76.  
  77.            LicenseMessage = String.Format("{0} days remaining.",
  78.                                           CStr(License.RemainingUsageDays))
  79.            ShowLicenseMessage(False)
  80.  
  81.        End If
  82.  
  83.    End Sub
  84.  
  85.    ''' <summary>
  86.    ''' Called when license status is invalid.
  87.    ''' </summary>
  88.    Private Sub OnInvalid()
  89.  
  90.        LicenseMessage = "Invalid License."
  91.        ShowLicenseMessage(True)
  92.        Terminate()
  93.  
  94.    End Sub
  95.  
  96.    ''' <summary>
  97.    ''' Called when license status expired.
  98.    ''' </summary>
  99.    Private Sub OnExpired()
  100.  
  101.        LicenseMessage = String.Format("License has expired on {0}.",
  102.                                       CStr(License.DateExpires))
  103.        ShowLicenseMessage(True)
  104.        Terminate()
  105.  
  106.    End Sub
  107.  
  108.    ''' <summary>
  109.    ''' Called when license status usage days exceeded.
  110.    ''' </summary>
  111.    Private Sub OnUsageDaysExceeded()
  112.  
  113.        LicenseMessage = String.Format("This software is limited to 7 days, this is the {0} day.",
  114.                                       CStr(License.CurrentUsageDays))
  115.        ShowLicenseMessage(True)
  116.        Terminate()
  117.  
  118.    End Sub
  119.  
  120.    ''' <summary>
  121.    ''' Called when license status executions exceeded.
  122.    ''' </summary>
  123.    Private Sub OnExecutionsExceeded()
  124.  
  125.        LicenseMessage = String.Format("This software is limited to 5 executions, this is the {0} execution.",
  126.                                       CStr(License.CurrentExecutions))
  127.        ShowLicenseMessage(True)
  128.        Terminate()
  129.  
  130.    End Sub
  131.  
  132. #End Region
  133.  
  134. #Region " Miscellaneous Methods "
  135.  
  136.    ''' <summary>
  137.    ''' Shows the license message on a MessageBox.
  138.    ''' </summary>
  139.    Private Sub ShowLicenseMessage(Optional ByVal ShowBuyComment As Boolean = False)
  140.  
  141.        LicenseMessage = String.Format("{0}{1}",
  142.                                       LicenseMessage,
  143.                                       If(ShowBuyComment,
  144.                                          Environment.NewLine & "Please buy this software.",
  145.                                          Nothing))
  146.  
  147.        MessageBox.Show(LicenseMessage, "License Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  148.  
  149.    End Sub
  150.  
  151.    ''' <summary>
  152.    ''' Terminates the application.
  153.    ''' </summary>
  154.    Private Sub Terminate()
  155.  
  156.        Application.Exit() ' Terminate the application.
  157.  
  158.    End Sub
  159.  
  160. #End Region
  161.  
  162. #Region " Event Handlers "
  163.  
  164.    ''' <summary>
  165.    ''' Handles the RunTimeExceeded event of the License.
  166.    ''' </summary>
  167.    ''' <param name="sender">The source of the event.</param>
  168.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  169.    Private Sub License_RunTimeExceeded(ByVal sender As Object, e As EventArgs) _
  170.    Handles License.RunTimeExceeded
  171.  
  172.        LicenseMessage = "Maximum usage time exceeded."
  173.        ShowLicenseMessage(True)
  174.        Terminate()
  175.  
  176.    End Sub
  177.  
  178. #End Region
  179.  
  180. End Class
« Última modificación: 15 Enero 2014, 22:42 pm por Eleкtro » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #365 en: 19 Enero 2014, 01:54 am »

Determina si el ratón está dentro del rango de pixels de un Control.

Código
  1.    ' Mouse Is Over Control?
  2.    ' ( By Elektro )
  3.    '
  4.    ' Usage Examples:
  5.    ' MsgBox(MouseIsOverControl(PictureBox1))
  6.    '
  7.    ''' <summary>
  8.    ''' Determinates whether the mouse pointer is over a pixel range of a specified control.
  9.    ''' </summary>
  10.    ''' <param name="Control">The control.</param>
  11.    ''' <returns>
  12.    ''' <c>true</c> if mouse is inside the pixel range, <c>false</c> otherwise.
  13.    ''' </returns>
  14.    Private Function MouseIsOverControl(ByVal [Control] As Control) As Boolean
  15.  
  16.        Return [Control].ClientRectangle.Contains([Control].PointToClient(MousePosition))
  17.  
  18.    End Function



 Crea un Bitmap y lo rellena con un color específico.

Código
  1.    ' Create Solid Bitmap
  2.    ' ( By Elektro )
  3.    '
  4.    ' Usage Examples:
  5.    ' PictureBox1.BackgroundImage = CreateSolidBitmap(New Size(16, 16), Color.Red)
  6.    '
  7.    ''' <summary>
  8.    ''' Creates a bitmap filled with a solid color.
  9.    ''' </summary>
  10.    ''' <param name="FillColor">Color to fill the Bitmap.</param>
  11.    ''' <returns>A Bitmap filled with the specified color.</returns>
  12.    Private Function CreateSolidBitmap(ByVal [Size] As Size,
  13.                                       ByVal FillColor As Color) As Bitmap
  14.  
  15.        ' Create a bitmap.
  16.        Dim bmp As New Bitmap([Size].Width, [Size].Height)
  17.  
  18.        ' Create a graphics object.
  19.        Using g As Graphics = Graphics.FromImage(bmp)
  20.  
  21.            ' Create a brush using the specified color.
  22.            Using br As New SolidBrush(FillColor)
  23.  
  24.                ' Fill the graphics object with the brush.
  25.                g.FillRectangle(br, 0, 0, bmp.Width, bmp.Height)
  26.  
  27.            End Using ' br
  28.  
  29.        End Using ' g
  30.  
  31.        Return bmp
  32.  
  33.    End Function



 Crea una serie de ToolStripItems en tiempo de ejecución.

Código
  1.    ' Create ToolStripItems at execution-time.
  2.    ' ( By Elektro )
  3.    '
  4.    ''' <summary>
  5.    ''' Handles the MouseEnter event of the ToolStripMenuItem control.
  6.    ''' </summary>
  7.    ''' <param name="sender">The source of the event.</param>
  8.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  9.    Private Sub ToolStripMenuItem1_MouseEnter(sender As Object, e As EventArgs) _
  10.    Handles ToolStripMenuItem1.MouseEnter
  11.  
  12.        ' Cast the Sender object.
  13.        Dim MenuItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
  14.  
  15.        ' Remove previous Item handlers.
  16.        For Each Item As ToolStripItem In MenuItem.DropDown.Items
  17.            RemoveHandler Item.Click, AddressOf DropDownItems_Click
  18.        Next Item
  19.  
  20.        ' Clear previous items.
  21.        MenuItem.DropDown.Items.Clear()
  22.  
  23.        ' Set the DropDown Backcolor.
  24.        MenuItem.DropDown.BackColor = MenuItem.BackColor
  25.  
  26.        ' Create new items.
  27.        For X As Integer = 0 To 5
  28.  
  29.            ' Add the Item and set the Text, Image, and OnClick event handler.
  30.            Dim Item As ToolStripItem =
  31.                MenuItem.DropDown.Items.Add([Enum].Parse(GetType(ConsoleColor), X).ToString,
  32.                                            New Bitmap(1, 1),
  33.                                            AddressOf DropDownItems_Click)
  34.  
  35.            ' Set other item properties.
  36.            With Item
  37.                .Tag = X
  38.            End With
  39.  
  40.        Next X
  41.  
  42.    End Sub
  43.  
  44.    ''' <summary>
  45.    ''' Handles the Click event of the DropDownItems.
  46.    ''' </summary>
  47.    ''' <param name="sender">The source of the event.</param>
  48.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  49.    Private Sub DropDownItems_Click(sender As Object, e As EventArgs)
  50.  
  51.        MsgBox(String.Format("Item clicked: {0} | {1}", CStr(sender.Tag), CStr(sender.Text)))
  52.  
  53.    End Sub
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #366 en: 19 Enero 2014, 02:01 am »

Unos Snippets que he escrito para algunos de los controles de usuario de DotNetBar.

Ejemplo de como crear y mostrar un Ballon.

Código
  1.    ' DotNetBar [Ballon] Example to create a new Ballon.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.  
  7.    ''' <summary>
  8.    ''' The DotNetBar Ballon object.
  9.    ''' </summary>
  10.    Private WithEvents BallonTip As Balloon = Nothing
  11.  
  12.    ''' <summary>
  13.    ''' Handles the MouseEnter event of the TextBox1 control.
  14.    ''' </summary>
  15.    ''' <param name="sender">The source of the event.</param>
  16.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  17.    Private Sub TextBox1_MouseEnter(ByVal sender As Object, ByVal e As EventArgs) _
  18.    Handles TextBox1.MouseEnter
  19.  
  20.        BallonTip = New Balloon()
  21.  
  22.        ' Set the properties to customize the Ballon.
  23.        With BallonTip
  24.  
  25.            .Owner = Me
  26.            .Style = eBallonStyle.Balloon
  27.            .AutoCloseTimeOut = 5 ' In seconds.
  28.  
  29.            .BorderColor = Color.YellowGreen
  30.            .BackColor = Color.FromArgb(80, 80, 80)
  31.            .BackColor2 = Color.FromArgb(40, 40, 40)
  32.            .BackColorGradientAngle = 90
  33.  
  34.            .CaptionIcon = Nothing
  35.            .CaptionImage = Nothing
  36.            .CaptionText = "I'm a BallonTip"
  37.            .CaptionFont = .Owner.Font
  38.            .CaptionColor = Color.YellowGreen
  39.  
  40.            .Text = "I'm the BallonTip text"
  41.            .ForeColor = Color.WhiteSmoke
  42.  
  43.            .AutoResize() ' Autoresize the Ballon, after setting the text.
  44.            .Show(sender, False) ' Show it.
  45.  
  46.        End With
  47.  
  48.    End Sub
  49.  
  50.    ''' <summary>
  51.    ''' Handles the MouseLeave event of the TextBox1 control.
  52.    ''' </summary>
  53.    ''' <param name="sender">The source of the event.</param>
  54.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  55.    Private Sub DisposeBallon(ByVal sender As Object, ByVal e As EventArgs) _
  56.    Handles TextBox1.MouseLeave
  57.  
  58.        If BallonTip IsNot Nothing AndAlso BallonTip.Visible Then
  59.            BallonTip.Dispose()
  60.        End If
  61.  
  62.    End Sub




Muestra un SuperTooltipInfo en unas coordenadas específicas.

Código
  1.    ' DotNetBar [SuperTooltipInfo] Show SuperTooltipInfo at MousePosition
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.    ' 2. Add a 'SuperToolTip' control in the Designer.
  7.    '
  8.    ' Usage Examples:
  9.    ' ShowSuperTooltipInfo(SuperTooltip1,
  10.    '                      "I'm the Header", "I'm the Body", , "I'm the Footer", ,
  11.    '                      eTooltipColor.Blue, MousePosition, 2, False)
  12.    '
  13.    ''' <summary>
  14.    ''' Shows a SuperTooltipInfo on the specified location.
  15.    ''' </summary>
  16.    ''' <param name="SuperToolTip">Indicates the SuperTooltip control.</param>
  17.    ''' <param name="HeaderText">Indicates the header text.</param>
  18.    ''' <param name="BodyText">Indicates the body text.</param>
  19.    ''' <param name="BodyImage">Indicates the body image.</param>
  20.    ''' <param name="FooterText">Indicates the footer text.</param>
  21.    ''' <param name="FooterImage">Indicates the footer image.</param>
  22.    ''' <param name="BackColor">Indicates the Tooltip background color.</param>
  23.    ''' <param name="Location">Indicates the location where to show the Tooltip.</param>
  24.    ''' <param name="Duration">Indicates the Tooltip duration.</param>
  25.    ''' <param name="PositionBelowControl">If set to <c>true</c> the tooltip is shown below the control.</param>
  26.    Private Sub ShowSuperTooltip(ByVal SuperToolTip As SuperTooltip,
  27.                                 Optional ByVal HeaderText As String = "",
  28.                                 Optional ByVal BodyText As String = "",
  29.                                 Optional ByVal BodyImage As Image = Nothing,
  30.                                 Optional ByVal FooterText As String = "",
  31.                                 Optional ByVal FooterImage As Image = Nothing,
  32.                                 Optional ByVal BackColor As eTooltipColor = eTooltipColor.System,
  33.                                 Optional ByVal Location As Point = Nothing,
  34.                                 Optional ByVal Duration As Integer = 2,
  35.                                 Optional ByVal PositionBelowControl As Boolean = False)
  36.  
  37.        ' Save the current SuperToolTip contorl properties to restore them at end.
  38.        Dim CurrentProp_IgnoreFormActiveState As Boolean = SuperToolTip.IgnoreFormActiveState
  39.        Dim CurrentProp_PositionBelowControl As Boolean = SuperToolTip.PositionBelowControl
  40.  
  41.        ' Create an invisible Form.
  42.        Dim TooltipForm As New Form
  43.        With TooltipForm
  44.            .Size = New Size(0, 0)
  45.            .Opacity = 0
  46.            .Location = Location ' Move the Form to the specified location.
  47.        End With
  48.  
  49.        ' Create a SuperTooltipInfo.
  50.        Dim MySuperTooltip As New SuperTooltipInfo()
  51.        With MySuperTooltip
  52.            .HeaderText = HeaderText
  53.            .BodyText = BodyText
  54.            .BodyImage = BodyImage
  55.            .FooterText = FooterText
  56.            .FooterImage = FooterImage
  57.            .Color = BackColor
  58.        End With
  59.  
  60.        ' Set the Supertooltip properties.
  61.        With SuperToolTip
  62.            .IgnoreFormActiveState = True ' Ignore the form state to display the tooltip.
  63.            .PositionBelowControl = PositionBelowControl
  64.            .TooltipDuration = Duration
  65.            .SetSuperTooltip(TooltipForm, MySuperTooltip) ' Assign the SuperTooltip to the invisible form.
  66.            .ShowTooltip(TooltipForm) ' Show the SuperTooltipInfo on the form.
  67.        End With
  68.  
  69.        ' Restore the SuperTooltip properties.
  70.        With SuperToolTip
  71.            .IgnoreFormActiveState = CurrentProp_IgnoreFormActiveState
  72.            .PositionBelowControl = CurrentProp_PositionBelowControl
  73.        End With
  74.  
  75.        ' Dispose the invisible Form.
  76.        TooltipForm.Dispose()
  77.  
  78.    End Sub



 Ejemplo de como añadir soporte para mover un SideBar usando la rueda del ratón.

Código
  1.    ' DotNetBar [SideBar] Scroll SideBar using MouseWheel.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Reference 'DevComponents.DotNetBar.dll'.
  6.    ' 2. Add a 'SideBar' control (with panel and buttons inside).
  7.  
  8.    ''' <summary>
  9.    ''' Handles the MouseMove event of the SideBar1 control.
  10.    ''' </summary>
  11.    ''' <param name="sender">The source of the event.</param>
  12.    ''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
  13.    Private Sub SideBar1_MouseMove(sender As Object, e As MouseEventArgs) _
  14.    Handles SideBar1.MouseMove
  15.  
  16.        SideBar1.Focus()
  17.  
  18.    End Sub
  19.  
  20.    ''' <summary>
  21.    ''' Handles the MouseWheel event of the SideBar control.
  22.    ''' </summary>
  23.    ''' <param name="sender">The source of the event.</param>
  24.    ''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
  25.    Private Sub SideBar1_MouseWheel(sender As Object, e As MouseEventArgs) _
  26.    Handles SideBar1.MouseWheel
  27.  
  28.        Dim TopItemIndex As Integer = sender.ExpandedPanel.TopItemIndex
  29.        Dim ItemCount As Integer = sender.ExpandedPanel.SubItems.Count
  30.  
  31.        Select Case e.Delta
  32.  
  33.            Case Is < 0
  34.                If TopItemIndex < ItemCount - 1 Then
  35.                    TopItemIndex += 1
  36.                End If
  37.  
  38.            Case Else
  39.                If TopItemIndex > 0 Then
  40.                    TopItemIndex -= 1
  41.                End If
  42.  
  43.        End Select
  44.  
  45.    End Sub



Ejemplo de como crear y o eliminar tabs de un SuperTabControl en tiempo de ejecución.

Código
  1.    ' DotNetBar [Ballon] Example to create a new Ballon.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.    ' 2. Add a 'SuperTabControl' control.
  7.  
  8.    Private Sub Test(sender As Object, e As EventArgs) Handles MyBase.Shown
  9.  
  10.        ' Create a new Tab.
  11.        Dim tab As SuperTabItem = SuperTabControl1.CreateTab("New Tab")
  12.  
  13.        ' Create a new Tab-Panel.
  14.        Dim tabpanel As SuperTabControlPanel = DirectCast(tab.AttachedControl, SuperTabControlPanel)
  15.  
  16.        ' Create a random control.
  17.        Dim wbr As New WebBrowser() With {.Dock = DockStyle.Fill}
  18.        wbr.Navigate("google.com")
  19.  
  20.        'Add the control to the Tab-Panel.
  21.        tabpanel.Controls.Add(wbr)
  22.  
  23.        ' Remove the Tab.
  24.        ' SuperTabControl1.Tabs.Remove(tab)
  25.  
  26.        ' And remember to dispose the Tab-Panel and the added Controls.
  27.        ' tabpanel.Dispose()
  28.        ' wbr.Dispose()
  29.  
  30.    End Sub



Ejemplo de como crear una Bar en tiempo de ejecución.

Código
  1.    ' DotNetBar [DotNetBarManager] Example to create a new Bar at execution-time.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.    ' 2. Add a 'DotNetBarManager' control.
  7.  
  8.    Private Sub Test(sender As Object, e As EventArgs) Handles MyBase.Shown
  9.  
  10.        Dim bar As Bar
  11.        Dim menu As ButtonItem
  12.        Dim submenu As ButtonItem
  13.  
  14.        bar = New Bar("My Menu Bar")
  15.  
  16.        bar.ColorScheme.DockSiteBackColor = Color.YellowGreen
  17.        bar.ColorScheme.DockSiteBackColor2 = Color.YellowGreen
  18.  
  19.        bar.ColorScheme.MenuBarBackground = Color.FromArgb(80, 80, 80)
  20.        bar.ColorScheme.MenuBarBackground2 = Color.FromArgb(40, 40, 40)
  21.  
  22.        bar.ColorScheme.MenuSide = Color.Silver
  23.        bar.ColorScheme.MenuSide2 = Color.FromArgb(80, 80, 80)
  24.  
  25.        bar.ColorScheme.ItemText = Color.Black
  26.        bar.ColorScheme.ItemBackground = Color.Silver
  27.        bar.ColorScheme.ItemBackground2 = Color.Silver
  28.  
  29.        bar.ColorScheme.ItemHotText = Color.Black
  30.        bar.ColorScheme.ItemHotBackground = Color.YellowGreen
  31.        bar.ColorScheme.ItemHotBackground2 = Color.YellowGreen
  32.  
  33.        bar.MenuBar = True
  34.        bar.Stretch = True
  35.  
  36.        DotNetBarManager1.UseGlobalColorScheme = False
  37.        DotNetBarManager1.Bars.Add(bar)
  38.        bar.DockSide = eDockSide.Top
  39.  
  40.        menu = New ButtonItem("bFile", "&File")
  41.        bar.Items.Add(menu)
  42.  
  43.        submenu = New ButtonItem("bOpen", "&Open")
  44.        menu.SubItems.Add(submenu)
  45.  
  46.        submenu = New ButtonItem("bClose", "&Close")
  47.        menu.SubItems.Add(submenu)
  48.  
  49.        submenu = New ButtonItem("bExit", "&Exit")
  50.  
  51.        submenu.BeginGroup = True
  52.        menu.SubItems.Add(submenu)
  53.  
  54.        menu = New ButtonItem("bEdit", "&Edit")
  55.        bar.Items.Add(menu)
  56.  
  57.        submenu = New ButtonItem("bCut", "&Cut")
  58.        menu.SubItems.Add(submenu)
  59.  
  60.        submenu = New ButtonItem("bCopy", "&Copy")
  61.        menu.SubItems.Add(submenu)
  62.  
  63.        submenu = New ButtonItem("bPaste", "&Paste")
  64.        menu.SubItems.Add(submenu)
  65.  
  66.        submenu = New ButtonItem("bClear", "&Clear")
  67.  
  68.        submenu.BeginGroup = True
  69.        menu.SubItems.Add(submenu)
  70.  
  71.        bar.RecalcLayout()
  72.  
  73.    End Sub




Ejemplo de como crear y asignar un SuperTooltipInfo

Código
  1.        ' DotNetBar [SuperTooltipInfo] Example to create a new SuperTooltipInfo.
  2.        ' ( By Elektro )
  3.        '
  4.        ' Instructions:
  5.        ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.        ' 2. Add a 'SuperToolTip' control in the Designer.
  7.  
  8.        ' SuperTooltipInfo type describes Super-Tooltip
  9.        Dim superTooltip As New SuperTooltipInfo()
  10.  
  11.        With superTooltip
  12.  
  13.            .HeaderText = "Header text"
  14.            .BodyText = "Body text with <strong>text-markup</strong> support. Header and footer support text-markup too."
  15.            .FooterText = "My footer text"
  16.  
  17.        End With
  18.  
  19.        ' Assign tooltip to a control or DotNetBar component
  20.        SuperTooltip1.SetSuperTooltip(TextBox1, superTooltip)
  21.  
  22.        ' To remove tooltip from a control or component use
  23.        '  SuperTooltip1.SetSuperTooltip(TextBox1, Nothing)



Ejemplo de como crear y mostrar un ContextMenu.

Código
  1.    ' DotNetBar [ContextMenuBar] Create a new ContextMenu.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  6.  
  7.    Private Sub Test() Handles MyBase.Shown
  8.  
  9.        ' Create context menu item that is assigned to controls or items
  10.        Dim ContextMenu As New ButtonItem("myContextMenuItemName")
  11.  
  12.        ' Create a Context MenuItem
  13.        Dim MenuItem As New ButtonItem("MenuItemName1")
  14.        MenuItem.Text = "Context MenuItem 1"
  15.        AddHandler MenuItem.Click, AddressOf MenuItemClick
  16.  
  17.        ' Add item to Context Menu
  18.        ContextMenu.SubItems.Add(MenuItem)
  19.  
  20.        ' Create second Context MenuItem
  21.        MenuItem = New ButtonItem("MenuItemName2", "Context MenuItem 2")
  22.        AddHandler MenuItem.Click, AddressOf MenuItemClick
  23.  
  24.        ' Add item to Context Menu
  25.        ContextMenu.SubItems.Add(MenuItem)
  26.  
  27.        ' Add Context Menu to Context MenuBar
  28.        ContextMenuBar1.Items.Add(ContextMenu)
  29.  
  30.        ' Assign context menu to text-box
  31.        ContextMenuBar1.SetContextMenuEx(TextBox1, ContextMenu)
  32.  
  33.    End Sub
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #367 en: 19 Enero 2014, 02:02 am »

Otro snippet para los controles de DotNetBar, para el 'KeyboardControl' en concreto.

Ejemplo de como crear una un Layout personalizado del teclado.

Código
  1.    ' DotNetBar [KeyboardControl] Example to create a Keyboard Layout at execution-time.
  2.    '
  3.    ' Instructions:
  4.    ' 1. Add a reference to 'DevComponents.DotNetBar.dll'.
  5.    ' 2. Add a 'KeyboardControl' control.
  6.  
  7.    Private Sub Test(sender As Object, e As EventArgs) Handles MyBase.Shown
  8.  
  9.        ' Set the new Keyboard Layout
  10.        KeyboardControl1.Keyboard = CreateDefaultKeyboard()
  11.  
  12.    End Sub
  13.  
  14.    ''' <summary>
  15.    ''' Creates the default keyboard.
  16.    ''' </summary>
  17.    ''' <returns>Keyboard.</returns>
  18.    Public Shared Function CreateDefaultKeyboard() As Keyboard
  19.        Dim keyboard As New Keyboard
  20.  
  21.        ' Actually there are 4 layout objects,
  22.        ' but for code simplicity this variable is reused for creating each of them.
  23.        Dim kc As LinearKeyboardLayout
  24.  
  25.        '#Region "Normal style configuration (no modifier keys pressed)"
  26.  
  27.        kc = New LinearKeyboardLayout()
  28.        keyboard.Layouts.Add(kc)
  29.  
  30.        kc.AddKey("q")
  31.        kc.AddKey("w")
  32.        kc.AddKey("e")
  33.        kc.AddKey("r")
  34.        kc.AddKey("t")
  35.        kc.AddKey("y")
  36.        kc.AddKey("u")
  37.        kc.AddKey("i")
  38.        kc.AddKey("o")
  39.        kc.AddKey("p")
  40.        kc.AddKey("Backspace", info:="{BACKSPACE}", width:=21)
  41.  
  42.        kc.AddLine()
  43.        kc.AddSpace(4)
  44.  
  45.        kc.AddKey("a")
  46.        kc.AddKey("s")
  47.        kc.AddKey("d")
  48.        kc.AddKey("f")
  49.        kc.AddKey("g")
  50.        kc.AddKey("h")
  51.        kc.AddKey("j")
  52.        kc.AddKey("k")
  53.        kc.AddKey("l")
  54.        kc.AddKey("'")
  55.        kc.AddKey("Enter", info:="{ENTER}", width:=17)
  56.  
  57.        kc.AddLine()
  58.  
  59.        kc.AddKey("Shift", info:="", style:=KeyStyle.Dark, layout:=1)
  60.        kc.AddKey("z")
  61.        kc.AddKey("x")
  62.        kc.AddKey("c")
  63.        kc.AddKey("v")
  64.        kc.AddKey("b")
  65.        kc.AddKey("n")
  66.        kc.AddKey("m")
  67.        kc.AddKey(",")
  68.        kc.AddKey(".")
  69.        kc.AddKey("?")
  70.        kc.AddKey("Shift", info:="", style:=KeyStyle.Dark, layout:=1)
  71.  
  72.        kc.AddLine()
  73.  
  74.        kc.AddKey("Ctrl", info:="", style:=KeyStyle.Dark, layout:=2)
  75.        kc.AddKey("&123", info:="", style:=KeyStyle.Dark, layout:=3)
  76.        kc.AddKey(":-)", info:=":-{)}", style:=KeyStyle.Dark)
  77.        'kc.AddKey("Alt", info: "%", style: KeyStyle.Dark);
  78.        kc.AddKey(" ", width:=76)
  79.        kc.AddKey("<", info:="{LEFT}", style:=KeyStyle.Dark)
  80.        kc.AddKey(">", info:="{RIGHT}", style:=KeyStyle.Dark)
  81.  
  82.        '#End Region
  83.  
  84.        '#Region "Shift modifier pressed"
  85.  
  86.        kc = New LinearKeyboardLayout()
  87.        keyboard.Layouts.Add(kc)
  88.  
  89.        kc.AddKey("Q", layout:=KeyboardLayout.PreviousLayout)
  90.        kc.AddKey("W", layout:=KeyboardLayout.PreviousLayout)
  91.        kc.AddKey("E", layout:=KeyboardLayout.PreviousLayout)
  92.        kc.AddKey("R", layout:=KeyboardLayout.PreviousLayout)
  93.        kc.AddKey("T", layout:=KeyboardLayout.PreviousLayout)
  94.        kc.AddKey("Y", layout:=KeyboardLayout.PreviousLayout)
  95.        kc.AddKey("U", layout:=KeyboardLayout.PreviousLayout)
  96.        kc.AddKey("I", layout:=KeyboardLayout.PreviousLayout)
  97.        kc.AddKey("O", layout:=KeyboardLayout.PreviousLayout)
  98.        kc.AddKey("P", layout:=KeyboardLayout.PreviousLayout)
  99.        kc.AddKey("Backspace", info:="{BACKSPACE}", width:=21)
  100.  
  101.        kc.AddLine()
  102.        kc.AddSpace(4)
  103.  
  104.        kc.AddKey("A", layout:=KeyboardLayout.PreviousLayout)
  105.        kc.AddKey("S", layout:=KeyboardLayout.PreviousLayout)
  106.        kc.AddKey("D", layout:=KeyboardLayout.PreviousLayout)
  107.        kc.AddKey("F", layout:=KeyboardLayout.PreviousLayout)
  108.        kc.AddKey("G", layout:=KeyboardLayout.PreviousLayout)
  109.        kc.AddKey("H", layout:=KeyboardLayout.PreviousLayout)
  110.        kc.AddKey("J", layout:=KeyboardLayout.PreviousLayout)
  111.        kc.AddKey("K", layout:=KeyboardLayout.PreviousLayout)
  112.        kc.AddKey("L", layout:=KeyboardLayout.PreviousLayout)
  113.        kc.AddKey("""", layout:=KeyboardLayout.PreviousLayout)
  114.        kc.AddKey("Enter", info:="{ENTER}", width:=17)
  115.  
  116.        kc.AddLine()
  117.  
  118.        kc.AddKey("Shift", info:="", style:=KeyStyle.Pressed, layout:=0, layoutEx:=4)
  119.        kc.AddKey("Z", layout:=KeyboardLayout.PreviousLayout)
  120.        kc.AddKey("X", layout:=KeyboardLayout.PreviousLayout)
  121.        kc.AddKey("C", layout:=KeyboardLayout.PreviousLayout)
  122.        kc.AddKey("V", layout:=KeyboardLayout.PreviousLayout)
  123.        kc.AddKey("B", layout:=KeyboardLayout.PreviousLayout)
  124.        kc.AddKey("N", layout:=KeyboardLayout.PreviousLayout)
  125.        kc.AddKey("M", layout:=KeyboardLayout.PreviousLayout)
  126.        kc.AddKey(";", layout:=KeyboardLayout.PreviousLayout)
  127.        kc.AddKey(":", layout:=KeyboardLayout.PreviousLayout)
  128.        kc.AddKey("!", layout:=KeyboardLayout.PreviousLayout)
  129.        kc.AddKey("Shift", info:="", style:=KeyStyle.Pressed, layout:=0, layoutEx:=4)
  130.  
  131.        kc.AddLine()
  132.  
  133.        kc.AddKey("Ctrl", info:="", style:=KeyStyle.Dark, layout:=2)
  134.        kc.AddKey("&123", info:="", style:=KeyStyle.Dark, layout:=3)
  135.        kc.AddKey(":-)", info:=":-{)}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  136.        kc.AddKey(" ", width:=76, layout:=KeyboardLayout.PreviousLayout)
  137.        kc.AddKey("<", info:="+{LEFT}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  138.        kc.AddKey(">", info:="+{RIGHT}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  139.  
  140.        '#End Region
  141.  
  142.        '#Region "Ctrl modifier pressed"
  143.  
  144.        kc = New LinearKeyboardLayout()
  145.        keyboard.Layouts.Add(kc)
  146.  
  147.        kc.AddKey("q", info:="^q", layout:=KeyboardLayout.PreviousLayout)
  148.        kc.AddKey("w", info:="^w", layout:=KeyboardLayout.PreviousLayout)
  149.        kc.AddKey("e", info:="^e", layout:=KeyboardLayout.PreviousLayout)
  150.        kc.AddKey("r", info:="^r", layout:=KeyboardLayout.PreviousLayout)
  151.        kc.AddKey("t", info:="^t", layout:=KeyboardLayout.PreviousLayout)
  152.        kc.AddKey("y", info:="^y", layout:=KeyboardLayout.PreviousLayout)
  153.        kc.AddKey("u", info:="^u", hint:="Underline", layout:=KeyboardLayout.PreviousLayout)
  154.        kc.AddKey("i", info:="^i", hint:="Italic", layout:=KeyboardLayout.PreviousLayout)
  155.        kc.AddKey("o", info:="^o", layout:=KeyboardLayout.PreviousLayout)
  156.        kc.AddKey("p", info:="^p", layout:=KeyboardLayout.PreviousLayout)
  157.        kc.AddKey("Backspace", info:="^{BACKSPACE}", width:=21, layout:=KeyboardLayout.PreviousLayout)
  158.  
  159.        kc.AddLine()
  160.        kc.AddSpace(4)
  161.  
  162.        kc.AddKey("a", info:="^a", hint:="Select all", layout:=KeyboardLayout.PreviousLayout)
  163.        kc.AddKey("s", info:="^s", layout:=KeyboardLayout.PreviousLayout)
  164.        kc.AddKey("d", info:="^d", layout:=KeyboardLayout.PreviousLayout)
  165.        kc.AddKey("f", info:="^f", layout:=KeyboardLayout.PreviousLayout)
  166.        kc.AddKey("g", info:="^g", layout:=KeyboardLayout.PreviousLayout)
  167.        kc.AddKey("h", info:="^h", layout:=KeyboardLayout.PreviousLayout)
  168.        kc.AddKey("j", info:="^j", layout:=KeyboardLayout.PreviousLayout)
  169.        kc.AddKey("k", info:="^k", layout:=KeyboardLayout.PreviousLayout)
  170.        kc.AddKey("l", info:="^l", layout:=KeyboardLayout.PreviousLayout)
  171.        kc.AddKey("'", info:="^'", layout:=KeyboardLayout.PreviousLayout)
  172.        kc.AddKey("Enter", info:="^{ENTER}", width:=17, layout:=KeyboardLayout.PreviousLayout)
  173.  
  174.        kc.AddLine()
  175.  
  176.        kc.AddKey("Shift", info:="", layout:=1)
  177.        kc.AddKey("z", info:="^z", hint:="Undo", layout:=KeyboardLayout.PreviousLayout)
  178.        kc.AddKey("x", info:="^x", hint:="Cut", layout:=KeyboardLayout.PreviousLayout)
  179.        kc.AddKey("c", info:="^c", hint:="Copy", layout:=KeyboardLayout.PreviousLayout)
  180.        kc.AddKey("v", info:="^v", hint:="Paste", layout:=KeyboardLayout.PreviousLayout)
  181.        kc.AddKey("b", info:="^b", hint:="Bold", layout:=KeyboardLayout.PreviousLayout)
  182.        kc.AddKey("n", info:="^n", layout:=KeyboardLayout.PreviousLayout)
  183.        kc.AddKey("m", info:="^m", layout:=KeyboardLayout.PreviousLayout)
  184.        kc.AddKey(",", info:="^,", layout:=KeyboardLayout.PreviousLayout)
  185.        kc.AddKey(".", info:="^.", layout:=KeyboardLayout.PreviousLayout)
  186.        kc.AddKey("?", info:="^?", layout:=KeyboardLayout.PreviousLayout)
  187.        kc.AddKey("Shift", info:="", layout:=1)
  188.  
  189.        kc.AddLine()
  190.  
  191.        kc.AddKey("Ctrl", info:="", style:=KeyStyle.Pressed, layout:=KeyboardLayout.PreviousLayout)
  192.        kc.AddKey("&123", info:="", style:=KeyStyle.Dark, layout:=3)
  193.        kc.AddKey(":-)", info:="^:-{)}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  194.        kc.AddKey(" ", info:="^ ", width:=76, layout:=KeyboardLayout.PreviousLayout)
  195.        kc.AddKey("<", info:="^{LEFT}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  196.        kc.AddKey(">", info:="^{RIGHT}", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  197.  
  198.        '#End Region
  199.  
  200.        '#Region "Symbols and numbers (&123) modifier pressed"
  201.  
  202.        kc = New LinearKeyboardLayout()
  203.        keyboard.Layouts.Add(kc)
  204.  
  205.        kc.AddKey("!")
  206.        kc.AddKey("@")
  207.        kc.AddKey("#")
  208.        kc.AddKey("$")
  209.        kc.AddKey("½")
  210.        kc.AddKey("-")
  211.        kc.AddKey("+", info:="{+}")
  212.  
  213.        kc.AddSpace(5)
  214.  
  215.        kc.AddKey("1", style:=KeyStyle.Light)
  216.        kc.AddKey("2", style:=KeyStyle.Light)
  217.        kc.AddKey("3", style:=KeyStyle.Light)
  218.  
  219.        kc.AddSpace(5)
  220.  
  221.        kc.AddKey("Bcks", info:="{BACKSPACE}", style:=KeyStyle.Dark)
  222.  
  223.        kc.AddLine()
  224.  
  225.        ' second line
  226.        kc.AddKey(";")
  227.        kc.AddKey(":")
  228.        kc.AddKey("""")
  229.        kc.AddKey("%", info:="{%}")
  230.        kc.AddKey("&")
  231.        kc.AddKey("/")
  232.        kc.AddKey("*")
  233.  
  234.        kc.AddSpace(5)
  235.  
  236.        kc.AddKey("4", style:=KeyStyle.Light)
  237.        kc.AddKey("5", style:=KeyStyle.Light)
  238.        kc.AddKey("6", style:=KeyStyle.Light)
  239.  
  240.        kc.AddSpace(5)
  241.  
  242.        kc.AddKey("Enter", info:="{ENTER}", style:=KeyStyle.Dark)
  243.  
  244.        kc.AddLine()
  245.  
  246.        ' third line
  247.        kc.AddKey("(", info:="{(}")
  248.        kc.AddKey(")", info:="{)}")
  249.        kc.AddKey("[", info:="{[}")
  250.        kc.AddKey("]", info:="{]}")
  251.        kc.AddKey("_")
  252.        kc.AddKey("\")
  253.        kc.AddKey("=")
  254.  
  255.        kc.AddSpace(5)
  256.  
  257.        kc.AddKey("7", style:=KeyStyle.Light)
  258.        kc.AddKey("8", style:=KeyStyle.Light)
  259.        kc.AddKey("9", style:=KeyStyle.Light)
  260.  
  261.        kc.AddSpace(5)
  262.  
  263.        kc.AddKey("Tab", info:="{TAB}", style:=KeyStyle.Dark)
  264.  
  265.        kc.AddLine()
  266.  
  267.        ' forth line
  268.        kc.AddKey("...", style:=KeyStyle.Dark, layout:=KeyboardLayout.PreviousLayout)
  269.        kc.AddKey("&123", info:="", style:=KeyStyle.Pressed, layout:=KeyboardLayout.PreviousLayout)
  270.        kc.AddKey(":-)", info:=":-{)}", style:=KeyStyle.Dark)
  271.        kc.AddKey("<", info:="{LEFT}", style:=KeyStyle.Dark)
  272.        kc.AddKey(">", info:="{RIGHT}", style:=KeyStyle.Dark)
  273.        kc.AddKey("Space", info:="^ ", width:=21)
  274.  
  275.        kc.AddSpace(5)
  276.  
  277.        kc.AddKey("0", style:=KeyStyle.Light, width:=21)
  278.        kc.AddKey(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, style:=KeyStyle.Dark)
  279.  
  280.        kc.AddSpace(5)
  281.  
  282.        kc.AddLine()
  283.  
  284.        '#End Region
  285.  
  286.        '#Region "Shift modifier toggled"
  287.  
  288.        kc = New LinearKeyboardLayout()
  289.        keyboard.Layouts.Add(kc)
  290.  
  291.        kc.AddKey("Q")
  292.        kc.AddKey("W")
  293.        kc.AddKey("E")
  294.        kc.AddKey("R")
  295.        kc.AddKey("T")
  296.        kc.AddKey("Y")
  297.        kc.AddKey("U")
  298.        kc.AddKey("I")
  299.        kc.AddKey("O")
  300.        kc.AddKey("P")
  301.        kc.AddKey("Backspace", info:="{BACKSPACE}", width:=21)
  302.  
  303.        kc.AddLine()
  304.        kc.AddSpace(4)
  305.  
  306.        kc.AddKey("A")
  307.        kc.AddKey("S")
  308.        kc.AddKey("D")
  309.        kc.AddKey("F")
  310.        kc.AddKey("G")
  311.        kc.AddKey("H")
  312.        kc.AddKey("J")
  313.        kc.AddKey("K")
  314.        kc.AddKey("L")
  315.        kc.AddKey("'")
  316.        kc.AddKey("Enter", info:="{ENTER}", width:=17)
  317.  
  318.        kc.AddLine()
  319.  
  320.        kc.AddKey("Shift", info:="", style:=KeyStyle.Toggled, layout:=0)
  321.        kc.AddKey("Z")
  322.        kc.AddKey("X")
  323.        kc.AddKey("C")
  324.        kc.AddKey("V")
  325.        kc.AddKey("B")
  326.        kc.AddKey("N")
  327.        kc.AddKey("M")
  328.        kc.AddKey(",")
  329.        kc.AddKey(".")
  330.        kc.AddKey("?")
  331.        kc.AddKey("Shift", info:="", style:=KeyStyle.Toggled, layout:=0)
  332.  
  333.        kc.AddLine()
  334.  
  335.        kc.AddKey("Ctrl", info:="", style:=KeyStyle.Dark, layout:=2)
  336.        kc.AddKey("&123", info:="", style:=KeyStyle.Dark, layout:=3)
  337.        kc.AddKey(":-)", info:=":-{)}", style:=KeyStyle.Dark)
  338.        kc.AddKey(" ", width:=76)
  339.        kc.AddKey("<", info:="+{LEFT}", style:=KeyStyle.Dark)
  340.        kc.AddKey(">", info:="+{RIGHT}", style:=KeyStyle.Dark)
  341.  
  342.        '#End Region
  343.  
  344.        Return keyboard
  345.  
  346.    End Function
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #368 en: 19 Enero 2014, 06:18 am »

RecycleBin Manager (Versión mejorada ...y acabada)

Un ayudante para obtener información sobre la papelera de reciclaje principal o el resto de papeleras así como de los elementos eliminados,
además de realizar otras operaciones como eliminar permanentemente o deshacer la eliminación (invocando verbos).

Aquí pueden ver el código ~> http://pastebin.com/eRync5pA


Índice de miembros públicos:
Código
  1. ' ----------
  2. ' Properties
  3. ' ----------
  4. '
  5. ' MainBin.Files
  6. ' MainBin.Folders
  7. ' MainBin.Items
  8. ' MainBin.ItemsCount
  9. ' MainBin.LastDeletedFile
  10. ' MainBin.LastDeletedFolder
  11. ' MainBin.LastDeletedItem
  12. ' MainBin.Size
  13.  
  14. ' -------
  15. ' Methods
  16. ' -------
  17. '
  18. ' MainBin.Empty()
  19. ' MainBin.RefreshIcon()
  20. '
  21. ' Tools.Empty()
  22. ' Tools.GetSize()
  23. ' Tools.GetDeletedFiles()
  24. ' Tools.GetDeletedFolders()
  25. ' Tools.GetDeletedItems()
  26. ' Tools.GetItemsCount()
  27. ' Tools.GetLastDeletedFile()
  28. ' Tools.GetLastDeletedFolder()
  29. ' Tools.GetLastDeletedItem()
  30. ' Tools.DeleteItem
  31. ' Tools.UndeleteItem
  32. ' Tools.InvokeItemVerb


Ejemplos de uso:

1.
Código
  1.    ' Empties all the Recycle Bins.
  2.    RecycleBinManager.MainBin.Empty()
  3.  
  4.    ' Empties the Recycle Bin of the "E" drive.
  5.    RecycleBinManager.Tools.Empty("E", RecycleBinManager.Tools.RecycleBinFlags.DontShowConfirmation)
  6.  
  7.    ' Updates the Main Recycle Bin icon.
  8.    RecycleBinManager.MainBin.RefreshIcon()
  9.  
  10.  
  11.    ' Gets the accumulated size (in bytes) of the Main Recycle Bin.
  12.    Dim RecycledSize As Long = RecycleBinManager.MainBin.Size
  13.  
  14.    ' Gets the accumulated size (in bytes) of the Recycle Bin on "E" drive.
  15.    Dim RecycledSizeE As Long = RecycleBinManager.Tools.GetSize("E")
  16.  
  17.  
  18.    ' Gets the total deleted items count of the Main recycle bin.
  19.    Dim RecycledItemsCount As Long = RecycleBinManager.MainBin.ItemsCount
  20.  
  21.    ' Gets the total deleted items count of the Recycle Bin on "E" drive.
  22.    Dim RecycledItemsCountE As Long = RecycleBinManager.Tools.GetDeletedItems("E").Count
  23.  
  24.  
  25.    ' Get all the deleted items inside the Main Recycle Bin.
  26.    Dim RecycledItems As ShellObject() = RecycleBinManager.MainBin.Items
  27.  
  28.    ' Get all the deleted files inside the Main Recycle Bin.
  29.    Dim RecycledFiles As ShellFile() = RecycleBinManager.MainBin.Files
  30.  
  31.    ' Get all the deleted folders inside the Main Recycle Bin.
  32.    Dim RecycledFolders As ShellFolder() = RecycleBinManager.MainBin.Folders
  33.  
  34.  
  35.    ' Get all the deleted items inside the Recycle Bin on "E" drive.
  36.    Dim RecycledItemsE As ShellObject() = RecycleBinManager.Tools.GetDeletedItems("E")
  37.  
  38.    ' Get all the deleted files inside the Recycle Bin on "E" drive.
  39.    Dim RecycledFilesE As ShellFile() = RecycleBinManager.Tools.GetDeletedFiles("E")
  40.  
  41.    ' Get all the deleted folders inside the Recycle Bin on "E" drive.
  42.    Dim RecycledFoldersE As ShellFolder() = RecycleBinManager.Tools.GetDeletedFolders("E")
  43.  
  44.  
  45.    ' Gets the Last deleted Item inside the Main Recycle Bin.
  46.    MsgBox(RecycleBinManager.MainBin.LastDeletedItem.Name)
  47.  
  48.    ' Gets the Last deleted Item inside the Recycle Bin on "E" drive
  49.    MsgBox(RecycleBinManager.Tools.GetLastDeletedItem("E").Name)
  50.  
  51.  
  52.    ' Undeletes an item.
  53.    RecycleBinManager.Tools.UndeleteItem(RecycleBinManager.MainBin.LastDeletedItem)
  54.  
  55.    ' Permanently deletes an item.
  56.    RecycleBinManager.Tools.DeleteItem(RecycleBinManager.MainBin.LastDeletedItem)
  57.  
  58.    ' Invokes an Item-Verb
  59.    RecycleBinManager.Tools.InvokeItemVerb(RecycleBinManager.MainBin.LastDeletedItem, "properties")

2.
Código
  1.    Private Sub Test() Handles MyBase.Shown
  2.  
  3.        Dim sb As New System.Text.StringBuilder
  4.  
  5.        ' Get all the deleted items inside all the Recycle Bins.
  6.        Dim RecycledItems As ShellObject() = RecycleBinManager.MainBin.Items
  7.  
  8.        ' Loop through the deleted Items (Ordered by las deleted).
  9.        For Each Item As ShellFile In (From itm In RecycledItems
  10.                                       Order By itm.Properties.GetProperty("System.Recycle.DateDeleted").ValueAsObject
  11.                                       Descending)
  12.  
  13.            ' Append the property bags information.
  14.            sb.AppendLine(String.Format("Full Name....: {0}",
  15.                                        Item.Name))
  16.  
  17.            sb.AppendLine(String.Format("Item Name....: {0}",
  18.                                        Item.Properties.System.ItemNameDisplay.Value))
  19.  
  20.            sb.AppendLine(String.Format("Deleted From.: {0}",
  21.                                        Item.Properties.GetProperty("System.Recycle.DeletedFrom").ValueAsObject))
  22.  
  23.            sb.AppendLine(String.Format("Item Type....: {0}",
  24.                                       Item.Properties.System.ItemTypeText.Value))
  25.  
  26.            sb.AppendLine(String.Format("Item Size....: {0}",
  27.                                        CStr(Item.Properties.System.Size.Value)))
  28.  
  29.            sb.AppendLine(String.Format("Attributes...: {0}",
  30.                                        [Enum].Parse(GetType(IO.FileAttributes),
  31.                                                     Item.Properties.System.FileAttributes.Value).ToString))
  32.  
  33.            sb.AppendLine(String.Format("Date Deleted.: {0}",
  34.                                        Item.Properties.GetProperty("System.Recycle.DateDeleted").ValueAsObject))
  35.  
  36.            sb.AppendLine(String.Format("Date Modified: {0}",
  37.                                        CStr(Item.Properties.System.DateModified.Value)))
  38.  
  39.            sb.AppendLine(String.Format("Date Created.: {0}",
  40.                                        CStr(Item.Properties.System.DateCreated.Value)))
  41.  
  42.            MsgBox(sb.ToString)
  43.            sb.Clear()
  44.  
  45.        Next Item
  46.  
  47.    End Sub
« Última modificación: 19 Enero 2014, 06:22 am por Eleкtro » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Compartan aquí sus snippets)
« Respuesta #369 en: 19 Enero 2014, 16:59 pm »

Dado una colección de números, devuelve todos los números que no están dentro de un rango especificado.

Código
  1.    ' Get Numbers Not In Range.
  2.    ' ( By Elektro )
  3.    '
  4.    ' Usage Examples:
  5.    '
  6.    ' MsgBox(String.Join(", ", GetNumbersNotInRange({1, 3, 5, 7, 9}, 0, 10).ToArray)) ' Result: 0, 2, 4, 6, 8, 10
  7.    '
  8.    ''' <summary>
  9.    ''' Given a numeric collection, gets all the numbers which are not in a specified range.
  10.    ''' </summary>
  11.    ''' <param name="NumbersInRange">Indicates the numbers collection which are in range.</param>
  12.    ''' <param name="MinRange">Indicates the minimum range.</param>
  13.    ''' <param name="MaxRange">Indicates the maximum range.</param>
  14.    ''' <returns>System.Collections.Generic.IEnumerable(Of System.Int32).</returns>
  15.    Private Function GetNumbersNotInRange(ByVal NumbersInRange As IEnumerable(Of Integer),
  16.                                          ByVal MinRange As Integer,
  17.                                          ByVal MaxRange As Integer) As IEnumerable(Of Integer)
  18.  
  19.        Return From Number As Integer
  20.               In Enumerable.Range(MinRange, MaxRange + 1)
  21.               Where Not NumbersInRange.Contains(Number)
  22.  
  23.    End Function
« Última modificación: 19 Enero 2014, 17:12 pm por Eleкtro » En línea

Páginas: 1 ... 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [37] 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 ... 58 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines