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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Mensajes
Páginas: 1 ... 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 [629] 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 ... 1236
6281  Programación / Scripting / Re: Repetir Encabezado delante de lineas que encabeza en: 10 Noviembre 2014, 15:57 pm
En Batch:

Código
  1. @Echo OFF
  2.  
  3. (
  4. For /F "UseBackQ Tokens=1,* Delims=," %%a In ("Archivo.txt") Do (
  5. If "%%~a" EQU "1" (
  6. Set "Header=%%a,%%b"
  7. ) Else (
  8. Call Echo %%Header%% %%a,%%b
  9. )
  10. )
  11. )>".\Nuevo.txt"
  12.  
  13. Pause&Exit /B 0

Saludos
6282  Programación / .NET (C#, VB.NET, ASP) / Re: Picturebox C# en: 9 Noviembre 2014, 13:56 pm
@MHMC777:
Está prohibido el doble post.
Lee las normas del foro, por favor.




Buenas

Me he interesado bastante por el problema que tienes hasta el punto de tomarme la molestia en crear un user-control bastante configurable... ya que realmente me pareció una tarea interesante para pasar el rato xD, el control tiene transparencia (bueno, la basura transparente que ofrece WinForms), se puede elegir entre 3 diseños: Círculo, Triángulo, o Cuadrado/Rectángulo, y por supuesto se puede mover/arrastrar el control al hacer click sobre él, como veo que que las figuras de tu imagen son del mismo tamaño he supuesto que no necesitas redimensionar el control en tiempo de ejecución (aunque es algo fácil de llevar a cabo).

Aquí tienes una demo de las funcionalidades que le añadí a este control:


Por cierto el color de fondo del control (dentro del círculo/cuadrado) lo puedes poner en Transparente (Color.Transparent), se me olvidó mostrarlo en el video-demostración.



El control de usuario lo he desarrollado en VB.Net, puedes referenciar la Class desde C#, puedes compilarlo en un .dll para usarlo en C#, o también puedes convertirlo a C# usando algún conversor online (ej: Telerik converter).

Espero que te sirva, el source:
EDITO: Versión mejorada con un pequeño fallo corregido...
Código
  1. ' ***********************************************************************
  2. ' Author           : Elektro
  3. ' Last Modified On : 11-09-2014
  4. ' ***********************************************************************
  5. ' <copyright file="ElektroShape.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Imports "
  11.  
  12. Imports System.ComponentModel
  13. Imports System.Drawing.Drawing2D
  14. Imports System.Drawing.Text
  15.  
  16. #End Region
  17.  
  18. ''' <summary>
  19. ''' A custom shape control.
  20. ''' </summary>
  21. Public Class ElektroShape : Inherits Control
  22.  
  23. #Region " Properties "
  24.  
  25. #Region " Visible "
  26.  
  27.    ''' <summary>
  28.    ''' Gets the default size of the control.
  29.    ''' </summary>
  30.    ''' <value>The default size.</value>
  31.    Protected Overrides ReadOnly Property DefaultSize As Size
  32.        Get
  33.            Return New Size(100I, 100I)
  34.        End Get
  35.    End Property
  36.  
  37.    ''' <summary>
  38.    ''' Gets or sets the shape figure.
  39.    ''' </summary>
  40.    ''' <value>The shape figure.</value>
  41.    <Browsable(True)>
  42.    <EditorBrowsable(EditorBrowsableState.Always)>
  43.    <Category("Figure")>
  44.    <Description("Indicates the shape figure.")>
  45.    Public Property Figure As Figures
  46.        Get
  47.            Return Me._Figure
  48.        End Get
  49.        Set(ByVal value As Figures)
  50.            Me._Figure = value
  51.            MyBase.Refresh()
  52.        End Set
  53.    End Property
  54.    ''' <summary>
  55.    ''' The shape figure.
  56.    ''' </summary>
  57.    Private _Figure As Figures = Figures.Circle
  58.  
  59.    ''' <summary>
  60.    ''' Gets or sets a value indicating whether this <see cref="ElektroShape"/> is draggable.
  61.    ''' </summary>
  62.    ''' <value><c>true</c> if draggable; otherwise, <c>false</c>.</value>
  63.    <Browsable(True)>
  64.    <EditorBrowsable(EditorBrowsableState.Always)>
  65.    <Category("Figure")>
  66.    <Description("Determines whether this control is draggable.")>
  67.    Public Property Draggable As Boolean
  68.        Get
  69.            Return Me._Draggable
  70.        End Get
  71.        Set(ByVal value As Boolean)
  72.            Me._Draggable = value
  73.        End Set
  74.    End Property
  75.    ''' <summary>
  76.    ''' A value indicating whether this <see cref="ElektroShape"/> is draggable.
  77.    ''' </summary>
  78.    Private _Draggable As Boolean = False
  79.  
  80.    ''' <summary>
  81.    ''' Gets or sets the inner color of this <see cref="ElektroShape"/>.
  82.    ''' </summary>
  83.    ''' <value>The inner color of this <see cref="ElektroShape"/>.</value>
  84.    <Browsable(True)>
  85.    <EditorBrowsable(EditorBrowsableState.Always)>
  86.    <Category("Figure")>
  87.    <Description("The inner color of this shape.")>
  88.    Public Property InnerColor As Color
  89.        Get
  90.            Return Me._InnerColor
  91.        End Get
  92.        Set(ByVal value As Color)
  93.            Me._InnerColor = value
  94.            MyBase.Refresh()
  95.        End Set
  96.    End Property
  97.    ''' <summary>
  98.    ''' The inner color of this <see cref="ElektroShape"/>.
  99.    ''' </summary>
  100.    Private _InnerColor As Color = Control.DefaultBackColor
  101.  
  102.    ''' <summary>
  103.    ''' Gets or sets the border color of this <see cref="ElektroShape"/>.
  104.    ''' </summary>
  105.    ''' <value>The border color of this <see cref="ElektroShape"/>.</value>
  106.    ''' <PermissionSet>
  107.    '''   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
  108.    ''' </PermissionSet>
  109.    <Browsable(True)>
  110.    <EditorBrowsable(EditorBrowsableState.Always)>
  111.    <Category("Figure")>
  112.    <Description("The border color of this shape.")>
  113.    Public Property BorderColor As Color
  114.        Get
  115.            Return Me._BorderColor
  116.        End Get
  117.        Set(ByVal value As Color)
  118.            Me._BorderColor = value
  119.            Me.DoPaint()
  120.        End Set
  121.    End Property
  122.    ''' <summary>
  123.    ''' The border color of this <see cref="ElektroShape"/>.
  124.    ''' </summary>
  125.    Private _BorderColor As Color = Control.DefaultForeColor
  126.  
  127.    ''' <summary>
  128.    ''' Gets or sets the border width of this <see cref="ElektroShape"/>.
  129.    ''' </summary>
  130.    ''' <value>The border width of this <see cref="ElektroShape"/>.</value>
  131.    <Browsable(True)>
  132.    <EditorBrowsable(EditorBrowsableState.Always)>
  133.    <Category("Figure")>
  134.    <Description("The border width of this figure.")>
  135.    Public Property BorderWidth As Integer
  136.        Get
  137.            Return Me._BorderWidth
  138.        End Get
  139.        Set(ByVal value As Integer)
  140.            Me._BorderWidth = value
  141.            Me.DoPaint()
  142.        End Set
  143.    End Property
  144.    ''' <summary>
  145.    ''' The border width of the this <see cref="ElektroShape"/>.
  146.    ''' </summary>
  147.    Private _BorderWidth As Integer = 5I
  148.  
  149.    ''' <summary>
  150.    ''' Gets or sets the interpolation mode of this <see cref="ElektroShape"/>.
  151.    ''' </summary>
  152.    ''' <value>The circle's interpolation mode.</value>
  153.    <Browsable(True)>
  154.    <EditorBrowsable(EditorBrowsableState.Always)>
  155.    <Category("Quality")>
  156.    <Description("The interpolation mode of this shape.")>
  157.    Public Property InterpolationMode As InterpolationMode
  158.        Get
  159.            Return Me._InterpolationMode
  160.        End Get
  161.        Set(ByVal value As InterpolationMode)
  162.            Me._InterpolationMode = value
  163.            Me.DoPaint()
  164.        End Set
  165.    End Property
  166.    ''' <summary>
  167.    ''' The interpolation mode of this <see cref="ElektroShape"/>.
  168.    ''' </summary>
  169.    Private _InterpolationMode As InterpolationMode = Drawing2D.InterpolationMode.Default
  170.  
  171.    ''' <summary>
  172.    ''' Gets or set a value specifying how pixels are offset during rendering this <see cref="ElektroShape"/>.
  173.    ''' </summary>
  174.    ''' <value>The circle's pixel offset mode.</value>
  175.    <Browsable(True)>
  176.    <EditorBrowsable(EditorBrowsableState.Always)>
  177.    <Category("Quality")>
  178.    <Description("A value specifying how pixels are offset during rendering this shape.")>
  179.    Public Property PixelOffsetMode As PixelOffsetMode
  180.        Get
  181.            Return Me._PixelOffsetMode
  182.        End Get
  183.        Set(ByVal value As PixelOffsetMode)
  184.            Me._PixelOffsetMode = value
  185.            Me.DoPaint()
  186.        End Set
  187.    End Property
  188.    ''' <summary>
  189.    ''' A value specifying how pixels are offset during rendering this <see cref="ElektroShape"/>.
  190.    ''' </summary>
  191.    Private _PixelOffsetMode As PixelOffsetMode = Drawing2D.PixelOffsetMode.Default
  192.  
  193.    ''' <summary>
  194.    ''' Gets or sets the rendering quality of this <see cref="ElektroShape"/>.
  195.    ''' </summary>
  196.    ''' <value>The circle's smoothing mode.</value>
  197.    <Browsable(True)>
  198.    <EditorBrowsable(EditorBrowsableState.Always)>
  199.    <Category("Quality")>
  200.    <Description("The rendering quality of this shape.")>
  201.    Public Property SmoothingMode As SmoothingMode
  202.        Get
  203.            Return Me._SmoothingMode
  204.        End Get
  205.        Set(ByVal value As SmoothingMode)
  206.            Me._SmoothingMode = value
  207.            Me.DoPaint()
  208.        End Set
  209.    End Property
  210.    ''' <summary>
  211.    ''' The rendering quality of this <see cref="ElektroShape"/>.
  212.    ''' </summary>
  213.    Private _SmoothingMode As SmoothingMode = Drawing2D.SmoothingMode.Default
  214.  
  215. #End Region
  216.  
  217. #Region " Hidden "
  218.  
  219.    ''' <summary>
  220.    ''' Gets or sets the background color of the control.
  221.    ''' </summary>
  222.    ''' <value>The background color of the control.</value>
  223.    ''' <PermissionSet>
  224.    '''   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
  225.    ''' </PermissionSet>
  226.    <Browsable(False)>
  227.    <EditorBrowsable(EditorBrowsableState.Never)>
  228.    <Bindable(False)>
  229.    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  230.    <Description("The background color of the control.")>
  231.    Public Overrides Property BackColor() As Color
  232.        Get
  233.            Dim currentColor As Color = Color.White
  234.            If MyBase.Parent IsNot Nothing Then
  235.                currentColor = MyBase.Parent.BackColor
  236.            End If
  237.            Return currentColor
  238.        End Get
  239.        Set(ByVal Value As Color)
  240.            MyBase.BackColor = Value
  241.        End Set
  242.    End Property
  243.  
  244.    ''' <summary>
  245.    ''' Gets or sets the foreground color of the control.
  246.    ''' </summary>
  247.    ''' <value>The foreground color of the control.</value>
  248.    ''' <PermissionSet>
  249.    '''   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
  250.    ''' </PermissionSet>
  251.    <Browsable(False)>
  252.    <EditorBrowsable(EditorBrowsableState.Never)>
  253.    <Bindable(False)>
  254.    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  255.    <Description("The foreground color of the control.")>
  256.    Public Overrides Property ForeColor As Color
  257.        Get
  258.            Return MyBase.ForeColor
  259.        End Get
  260.        Set(ByVal value As Color)
  261.            MyBase.ForeColor = value
  262.        End Set
  263.    End Property
  264.  
  265.    ''' <summary>
  266.    ''' Gets or sets the text associated with this control.
  267.    ''' </summary>
  268.    ''' <value>The text associated with this control.</value>
  269.    <Browsable(False)>
  270.    <EditorBrowsable(EditorBrowsableState.Never)>
  271.    <Bindable(False)>
  272.    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  273.    <Category("Figure")>
  274.    <Description("The text associated with this control.")>
  275.    Public Overrides Property Text As String
  276.        Get
  277.            Return MyBase.Text
  278.        End Get
  279.        Set(value As String)
  280.            MyBase.Text = value
  281.        End Set
  282.    End Property
  283.  
  284.    ''' <summary>
  285.    ''' Gets or sets the rendering mode for text associated with this <see cref="ElektroShape"/>.
  286.    ''' </summary>
  287.    ''' <value>The circle's text rendering hint.</value>
  288.    <Browsable(False)>
  289.    <EditorBrowsable(EditorBrowsableState.Never)>
  290.    <Category("Quality")>
  291.    <Description("The rendering mode for text associated with this control.")>
  292.    Public Property TextRenderingHint As TextRenderingHint
  293.        Get
  294.            Return Me._TextRenderingHint
  295.        End Get
  296.        Set(ByVal value As TextRenderingHint)
  297.            Me._TextRenderingHint = value
  298.            Me.DoPaint()
  299.        End Set
  300.    End Property
  301.    ''' <summary>
  302.    ''' The rendering mode for text associated with this <see cref="ElektroShape"/>.
  303.    ''' </summary>
  304.    Private _TextRenderingHint As TextRenderingHint = Drawing.Text.TextRenderingHint.SystemDefault
  305.  
  306. #End Region
  307.  
  308. #End Region
  309.  
  310. #Region " Miscellaneous Objects "
  311.  
  312.    ''' <summary>
  313.    ''' The draggable information to drag the control.
  314.    ''' </summary>
  315.    Private Property draggableInfo As DragInfo = DragInfo.Empty
  316.  
  317. #End Region
  318.  
  319. #Region " Enumerations "
  320.  
  321.    ''' <summary>
  322.    ''' Contains the default figure designs.
  323.    ''' </summary>
  324.    Public Enum Figures As Integer
  325.  
  326.        ''' <summary>
  327.        ''' Circle figure.
  328.        ''' </summary>
  329.        Circle = 0I
  330.  
  331.        ''' <summary>
  332.        ''' Square figure.
  333.        ''' </summary>
  334.        Square = 1I
  335.  
  336.        ''' <summary>
  337.        ''' Triangle figure.
  338.        ''' </summary>
  339.        Triangle = 2I
  340.  
  341.    End Enum
  342.  
  343. #End Region
  344.  
  345. #Region " Types "
  346.  
  347.    ''' <summary>
  348.    ''' Maintains information about a draggable operation.
  349.    ''' </summary>
  350.    Private NotInheritable Class DragInfo
  351.  
  352. #Region " Properties "
  353.  
  354.        ''' <summary>
  355.        ''' Gets or sets the initial mouse coordinates.
  356.        ''' </summary>
  357.        ''' <value>The initial mouse coordinates.</value>
  358.        Friend Property InitialMouseCoords As Point = Point.Empty
  359.  
  360.        ''' <summary>
  361.        ''' Gets or sets the initial location.
  362.        ''' </summary>
  363.        ''' <value>The initial location.</value>
  364.        Friend Property InitialLocation As Point = Point.Empty
  365.  
  366.        ''' <summary>
  367.        ''' Represents a <see cref="T:DragInfo"/> that is <c>Nothing</c>.
  368.        ''' </summary>
  369.        ''' <value><c>Nothing</c></value>
  370.        Friend Shared ReadOnly Property Empty As DragInfo
  371.            Get
  372.                Return Nothing
  373.            End Get
  374.        End Property
  375.  
  376. #End Region
  377.  
  378. #Region " Constructors "
  379.  
  380.        ''' <summary>
  381.        ''' Initializes a new instance of the <see cref="DragInfo"/> class.
  382.        ''' </summary>
  383.        ''' <param name="mouseCoordinates">The current mouse coordinates.</param>
  384.        ''' <param name="location">The current location.</param>
  385.        Public Sub New(ByVal mouseCoordinates As Point, ByVal location As Point)
  386.  
  387.            Me.InitialMouseCoords = mouseCoordinates
  388.            Me.InitialLocation = location
  389.  
  390.        End Sub
  391.  
  392. #End Region
  393.  
  394. #Region " Public Methods "
  395.  
  396.        ''' <summary>
  397.        ''' Return the new location.
  398.        ''' </summary>
  399.        ''' <param name="mouseCoordinates">The current mouse coordinates.</param>
  400.        ''' <returns>The new location.</returns>
  401.        Public Function NewLocation(ByVal mouseCoordinates As Point) As Point
  402.  
  403.            Return New Point(InitialLocation.X + (mouseCoordinates.X - InitialMouseCoords.X),
  404.                             InitialLocation.Y + (mouseCoordinates.Y - InitialMouseCoords.Y))
  405.  
  406.        End Function
  407.  
  408. #End Region
  409.  
  410.    End Class
  411.  
  412. #End Region
  413.  
  414. #Region " Constructors "
  415.  
  416.    ''' <summary>
  417.    ''' Initializes a new instance of the <see cref="ElektroShape"/> class.
  418.    ''' </summary>
  419.    Private Sub New()
  420.  
  421.        Me.New(Figures.Circle)
  422.  
  423.    End Sub
  424.  
  425.    ''' <summary>
  426.    ''' Initializes a new instance of the <see cref="ElektroShape"/> class.
  427.    ''' </summary>
  428.    ''' <param name="figure">The shape figure.</param>
  429.    Public Sub New(ByVal figure As Figures)
  430.  
  431.        With Me
  432.            .DoubleBuffered = True
  433.            _Figure = figure
  434.        End With
  435.  
  436.    End Sub
  437.  
  438. #End Region
  439.  
  440. #Region " Overriden Events "
  441.  
  442.    ''' <summary>
  443.    ''' Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"/> event.
  444.    ''' </summary>
  445.    ''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
  446.    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  447.  
  448.        MyBase.OnMouseDown(e)
  449.        Me.StartDrag()
  450.  
  451.    End Sub
  452.  
  453.    ''' <summary>
  454.    ''' Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"/> event.
  455.    ''' </summary>
  456.    ''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
  457.    Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  458.  
  459.        MyBase.OnMouseMove(e)
  460.        Me.Drag()
  461.  
  462.    End Sub
  463.  
  464.    ''' <summary>
  465.    ''' Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.
  466.    ''' </summary>
  467.    ''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
  468.    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  469.  
  470.        MyBase.OnMouseUp(e)
  471.        Me.StopDrag()
  472.  
  473.    End Sub
  474.  
  475.    ''' <summary>
  476.    ''' Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.
  477.    ''' </summary>
  478.    ''' <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data.</param>
  479.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  480.  
  481.        With e.Graphics
  482.  
  483.            .InterpolationMode = Me._InterpolationMode
  484.            .PixelOffsetMode = Me._PixelOffsetMode
  485.            .SmoothingMode = Me._SmoothingMode
  486.            ' .TextRenderingHint = Me._TextRenderingHint
  487.  
  488.            Select Case Me._Figure
  489.  
  490.                Case Figures.Circle
  491.                    Me.DrawCircle(e.Graphics)
  492.  
  493.                Case Figures.Square
  494.                    Me.DrawSquare(e.Graphics)
  495.  
  496.                Case Figures.Triangle
  497.                    Me.DrawTriangle(e.Graphics)
  498.  
  499.            End Select ' Me._Figure
  500.  
  501.        End With ' e.Graphics
  502.  
  503.        MyBase.OnPaint(e)
  504.  
  505.    End Sub
  506.  
  507. #End Region
  508.  
  509. #Region " Private Methods "
  510.  
  511. #Region " Drag "
  512.  
  513.    ''' <summary>
  514.    ''' Initializes a drag operation.
  515.    ''' </summary>
  516.    Private Sub StartDrag()
  517.  
  518.        If (Me._Draggable) Then
  519.  
  520.            Me.draggableInfo = New DragInfo(MousePosition, MyBase.Location)
  521.  
  522.        End If
  523.  
  524.    End Sub
  525.  
  526.    ''' <summary>
  527.    ''' Drags the control.
  528.    ''' </summary>
  529.    Private Sub Drag()
  530.  
  531.        If (Me._Draggable) AndAlso (Me.draggableInfo IsNot DragInfo.Empty) Then
  532.  
  533.            MyBase.Location = New Point(Me.draggableInfo.NewLocation(MousePosition))
  534.  
  535.        End If
  536.  
  537.    End Sub
  538.  
  539.    ''' <summary>
  540.    ''' Destroys a drag operation.
  541.    ''' </summary>
  542.    Private Sub StopDrag()
  543.  
  544.        Me.draggableInfo = DragInfo.Empty
  545.  
  546.    End Sub
  547.  
  548. #End Region
  549.  
  550. #Region " Paint "
  551.  
  552.    ''' <summary>
  553.    ''' Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event for the specified control.
  554.    ''' </summary>
  555.    Private Sub DoPaint()
  556.  
  557.        Using g As Graphics = MyBase.CreateGraphics
  558.            MyBase.InvokePaint(Me, New PaintEventArgs(g, MyBase.ClientRectangle))
  559.        End Using
  560.  
  561.    End Sub
  562.  
  563.    ''' <summary>
  564.    ''' Gets a <see cref="System.Drawing.Rectangle"/> with the bounds fixed according to the specified <see cref="System.Drawing.Pen.Width"/>.
  565.    ''' </summary>
  566.    ''' <param name="pen">The <see cref="System.Drawing.Pen"/>.</param>
  567.    ''' <returns>The <see cref="System.Drawing.Rectangle"/> with the bounds fixed.</returns>
  568.    Private Function GetFigueRectangle(ByVal pen As Pen) As Rectangle
  569.  
  570.        Return New Rectangle With
  571.                    {
  572.                        .x = 0.0F + (pen.Width / 2.0F),
  573.                        .y = 0.0F + (pen.Width / 2.0F),
  574.                        .width = (CSng(MyBase.Width) - pen.Width),
  575.                        .height = (CSng(MyBase.Height) - pen.Width)
  576.                    }
  577.  
  578.    End Function
  579.  
  580.    ''' <summary>
  581.    ''' Draws a circle on the specified <see cref="System.Drawing.Graphics"/> object.
  582.    ''' </summary>
  583.    ''' <param name="g">The <see cref="System.Drawing.Graphics"/> object to paint.</param>
  584.    Private Sub DrawCircle(ByRef g As Graphics)
  585.  
  586.        With g
  587.  
  588.            Using pen As New Pen(Me._BorderColor, Me._BorderWidth)
  589.  
  590.                Dim rect As Rectangle = Me.GetFigueRectangle(pen)
  591.  
  592.                If Not Me._InnerColor = Color.Transparent Then
  593.  
  594.                    ' Fill circle background.
  595.                    Using brush As New SolidBrush(Me._InnerColor)
  596.                        .FillEllipse(brush, rect)
  597.                    End Using
  598.  
  599.                End If ' Not Me._InnerColor = Color.Transparent
  600.  
  601.                ' Draw the circle figure.
  602.                .DrawEllipse(pen, rect)
  603.  
  604.            End Using ' pen As New Pen(Me._BorderColor, Me._BorderWidth)
  605.  
  606.        End With ' g
  607.  
  608.    End Sub
  609.  
  610.    ''' <summary>
  611.    ''' Draws an square on the specified <see cref="System.Drawing.Graphics"/> object.
  612.    ''' </summary>
  613.    ''' <param name="g">The <see cref="System.Drawing.Graphics"/> object to paint.</param>
  614.    Private Sub DrawSquare(ByRef g As Graphics)
  615.  
  616.        With g
  617.  
  618.            Using pen As New Pen(Me._BorderColor, Me._BorderWidth)
  619.  
  620.                Dim rect As Rectangle = Me.GetFigueRectangle(pen)
  621.  
  622.                If Not Me._InnerColor = Color.Transparent Then
  623.  
  624.                    ' Fill the square background.
  625.                    Using brush As New SolidBrush(Me._InnerColor)
  626.                        .FillRectangle(brush, rect)
  627.                    End Using
  628.  
  629.                End If ' Not Me._InnerColor = Color.Transparent
  630.  
  631.                ' Draw the square figure.
  632.                .DrawRectangle(pen, rect)
  633.  
  634.            End Using ' pen As New Pen(Me._BorderColor, Me._BorderWidth)
  635.  
  636.        End With ' g
  637.  
  638.    End Sub
  639.  
  640.    ''' <summary>
  641.    ''' Draws a triangle on the specified <see cref="System.Drawing.Graphics"/> object.
  642.    ''' </summary>
  643.    ''' <param name="g">The <see cref="System.Drawing.Graphics"/> object to paint.</param>
  644.    Private Sub DrawTriangle(ByRef g As Graphics)
  645.  
  646.        With g
  647.  
  648.            Using pen As New Pen(Me._BorderColor, Me._BorderWidth)
  649.  
  650.                Using path As New GraphicsPath(FillMode.Alternate)
  651.  
  652.                    Dim rect As Rectangle = MyBase.ClientRectangle
  653.  
  654.                    ' Set the triangle path coordinates.
  655.                    Dim trianglePoints As PointF() =
  656.                        {
  657.                            New PointF(CSng(rect.Left + CSng(rect.Width / 2.0F)), CSng(rect.Top + pen.Width)),
  658.                            New PointF(CSng(rect.Right - pen.Width), CSng(rect.Bottom - (pen.Width / 2.0F))),
  659.                            New PointF(CSng(rect.Left + pen.Width), CSng(rect.Bottom - (pen.Width / 2.0F))),
  660.                            New PointF(CSng(rect.Left + CSng(rect.Width / 2.0F)), CSng(rect.Top + pen.Width))
  661.                        }
  662.  
  663.                    path.AddLines(trianglePoints)
  664.                    path.CloseFigure()
  665.  
  666.                    If Not Me._InnerColor = Color.Transparent Then
  667.  
  668.                        ' Fill the triangle background.
  669.                        Using brush As New SolidBrush(Me._InnerColor)
  670.                            .FillPath(brush, path)
  671.                        End Using
  672.  
  673.                    End If ' Not Me._InnerColor = Color.Transparent
  674.  
  675.                    ' Draw the triangle figure.
  676.                    .DrawPath(pen, path)
  677.  
  678.                End Using ' path As New GraphicsPath(FillMode.Alternate)
  679.  
  680.            End Using ' pen As New Pen(Me._BorderColor, Me._BorderWidth)
  681.  
  682.        End With ' g
  683.  
  684.    End Sub
  685.  
  686. #End Region
  687.  
  688. #End Region
  689.  
  690. End Class

EDITO:

Aquí tienes un ejemplo real de uso dinámico en tiempo de ejecución, creación/instanciado de controles y supscripción a eventos del ratón.

Código
  1. Public Class Form1
  2.  
  3.    Private Sub Test() Handles MyBase.Shown
  4.  
  5.        For count As Integer = 0 To 5
  6.  
  7.            Dim shape As New ElektroShape(ElektroShape.Figures.Circle)
  8.            With shape
  9.  
  10.                .Name = String.Format("shape_{0}", CStr(count))
  11.                .Size = New Size(48, 48)
  12.                .Location = New Point(Me.ClientRectangle.Left + (.Size.Width * count) + (10 * count), .Size.Height)
  13.                .Draggable = True
  14.  
  15.                .InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  16.                .PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
  17.                .SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
  18.  
  19.                .BorderWidth = 1I
  20.                .BorderColor = Color.DodgerBlue
  21.                .InnerColor = Color.Thistle
  22.  
  23.                AddHandler shape.Click, AddressOf shape_Click
  24.  
  25.            End With ' shape
  26.  
  27.            Me.Controls.Add(shape)
  28.  
  29.        Next count
  30.  
  31.    End Sub
  32.  
  33.    ''' <summary>
  34.    ''' Handles the Click event of the shape control.
  35.    ''' </summary>
  36.    ''' <param name="sender">The source of the event.</param>
  37.    ''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  38.    Private Sub shape_Click(ByVal sender As Object, ByVal e As EventArgs)
  39.  
  40.        Dim mouseArgs = DirectCast(e, MouseEventArgs)
  41.  
  42.        Dim sb As New System.Text.StringBuilder
  43.        With sb
  44.            .AppendLine("Has hecho 'Click' en una figura !!")
  45.            .AppendLine()
  46.            .AppendFormat("Nombre: {0}", DirectCast(sender, ElektroShape).Name)
  47.            .AppendLine()
  48.            .AppendFormat("Coordenadas internas: {0}", DirectCast(e, MouseEventArgs).Location.ToString)
  49.            .AppendLine()
  50.            .AppendFormat("Coordenadas externas: {0}", MousePosition.ToString)
  51.        End With
  52.  
  53.        MessageBox.Show(sb.ToString, Me.Name, MessageBoxButtons.OK, MessageBoxIcon.Information)
  54.  
  55.    End Sub
  56.  
  57. End Class

C# (conversión al vuelo):
Código
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Diagnostics;
  7. public class Form1
  8. {
  9.  
  10.  
  11. private void Test()
  12. {
  13.  
  14. for (int count = 0; count <= 5; count++) {
  15. ElektroShape shape = new ElektroShape(ElektroShape.Figures.Circle);
  16. var _with1 = shape;
  17.  
  18. _with1.Name = string.Format("shape_{0}", Convert.ToString(count));
  19. _with1.Size = new Size(48, 48);
  20. _with1.Location = new Point(this.ClientRectangle.Left + (_with1.Size.Width * count) + (10 * count), _with1.Size.Height);
  21. _with1.Draggable = true;
  22.  
  23. _with1.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic;
  24. _with1.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality;
  25. _with1.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias;
  26.  
  27. _with1.BorderWidth = 1;
  28. _with1.BorderColor = Color.DodgerBlue;
  29. _with1.InnerColor = Color.Thistle;
  30.  
  31. shape.Click += shape_Click;
  32.  
  33. // shape
  34.  
  35. this.Controls.Add(shape);
  36.  
  37. }
  38.  
  39. }
  40.  
  41. /// <summary>
  42. /// Handles the Click event of the shape control.
  43. /// </summary>
  44. /// <param name="sender">The source of the event.</param>
  45. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  46.  
  47. private void shape_Click(object sender, EventArgs e)
  48. {
  49. dynamic mouseArgs = (MouseEventArgs)e;
  50.  
  51. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  52. var _with2 = sb;
  53. _with2.AppendLine("Has hecho 'Click' en una figura !!");
  54. _with2.AppendLine();
  55. _with2.AppendFormat("Nombre: {0}", ((ElektroShape)sender).Name);
  56. _with2.AppendLine();
  57. _with2.AppendFormat("Coordenadas internas: {0}", ((MouseEventArgs)e).Location.ToString);
  58. _with2.AppendLine();
  59. _with2.AppendFormat("Coordenadas externas: {0}", MousePosition.ToString);
  60.  
  61. MessageBox.Show(sb.ToString, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
  62.  
  63. }
  64. public Form1()
  65. {
  66. Shown += Test;
  67. }
  68.  
  69. }
  70.  
  71. //=======================================================
  72. //Service provided by Telerik (www.telerik.com)
  73. //Conversion powered by NRefactory.
  74. //=======================================================
  75.  

Saludos.
6283  Foros Generales / Foro Libre / Re: De donde eres... ¿Y donde te gustaría viajar? en: 8 Noviembre 2014, 21:34 pm
Citar
De donde eres... ¿Y donde te gustaría viajar?

De La Tierra, y me gustaría viajar a Europa (allá cerca de Júpiter) ::)

PD: Soñar es gratis, viajar no xD.

Saludos!
6284  Programación / .NET (C#, VB.NET, ASP) / Re: [AYUDA]llenar un Combobox c# en: 7 Noviembre 2014, 16:56 pm
No se si lo he entendido bien...

Instancias una lista de la Class Disco, y lo que quieres hacer es llenar un ComboBox que contenga los distintos "Generos" da los items de la lista de Disco?

Entonces solo tienes que seleccionar la propiedad "genero" de cada item Disco, lo puedes hacer con una query de LINQ o con un For:

VB.Net
Código
  1. Imports System.Globalization
  2. Imports System.Threading
  3.  
  4. Public Class Form1
  5.  
  6.    Public Shared listaDisco As New List(Of Disco) From
  7.        {
  8.            New Disco With {.titulo = "a", .genero = "Rock"},
  9.            New Disco With {.titulo = "b", .genero = "Pop"},
  10.            New Disco With {.titulo = "c", .genero = "Dubstep"},
  11.            New Disco With {.titulo = "d", .genero = "dubstep"}
  12.        }
  13.  
  14.    Class Disco
  15.        Public titulo As String
  16.        Public genero As String
  17.        Public año As Integer
  18.        Public autor As String
  19.        Public precio As Double
  20.        Public fecha_registro As DateTime
  21.    End Class
  22.  
  23.    Private Sub test() Handles MyBase.Shown
  24.  
  25.        Dim currentCulture As CultureInfo = Thread.CurrentThread.CurrentCulture
  26.        Dim textInfo As TextInfo = currentCulture.TextInfo()
  27.  
  28.        Dim genres As IEnumerable(Of String) =
  29.            (From disc As Disco In listaDisco
  30.             Select textInfo.ToTitleCase(disc.genero)
  31.             Distinct)
  32.  
  33.        With ComboBox1
  34.            .Sorted = True
  35.            .SuspendLayout()
  36.            .Items.AddRange(genres.ToArray)
  37.            .SelectedIndex = 0
  38.            .ResumeLayout()
  39.        End With
  40.  
  41.    End Sub
  42.  
  43. End Class

CSharp:
Código
  1. using Microsoft.VisualBasic;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Diagnostics;
  7. using System.Globalization;
  8. using System.Threading;
  9.  
  10. public class Form1
  11. {
  12.  
  13. public static List<Disco> listaDisco = new List<Disco> {
  14. new Disco {
  15. titulo = "a",
  16. genero = "Rock"
  17. },
  18. new Disco {
  19. titulo = "b",
  20. genero = "Pop"
  21. },
  22. new Disco {
  23. titulo = "c",
  24. genero = "Dubstep"
  25. },
  26. new Disco {
  27. titulo = "d",
  28. genero = "dubstep"
  29. }
  30.  
  31. };
  32.  
  33. public class Disco
  34. {
  35. public string titulo;
  36. public string genero;
  37. public int año;
  38. public string autor;
  39. public double precio;
  40. public DateTime fecha_registro;
  41. }
  42.  
  43.  
  44. private void test()
  45. {
  46. CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
  47. TextInfo textInfo = currentCulture.TextInfo();
  48.  
  49. IEnumerable<string> genres = (from disc in listaDiscotextInfo.ToTitleCase(disc.genero));
  50.  
  51. var _with1 = ComboBox1;
  52. _with1.Sorted = true;
  53. _with1.SuspendLayout();
  54. _with1.Items.AddRange(genres.ToArray);
  55. _with1.SelectedIndex = 0;
  56. _with1.ResumeLayout();
  57.  
  58. }
  59. public Form1()
  60. {
  61. Shown += test;
  62. }
  63.  
  64. }
  65.  
  66. //=======================================================
  67. //Service provided by Telerik (www.telerik.com)
  68. //Conversion powered by NRefactory.
  69. //=======================================================
  70.  
6285  Foros Generales / Dudas Generales / Re: ¿Que voz TTS femenina es esta? en: 7 Noviembre 2014, 15:15 pm
Eso te pasa por incrédulo, te dije y aseguré que esa voz no estaba en el win7 y aun así ni p.u.t.o caso (parece mentira que te fíes tan poco de mi). Yo sigo pensando que es la voz del win8, ¿lo as descartado por completo con seguridad?.
Saludos...

Songoku


Lo siento simplemente se me olvidó que me dijiste eso por que tengo un lio tremendo con este tema ya... no me acordaba que me dijiste ese comentario sobre Windows 7, de verdad, de lo contrario no habría tenido motivos para ponerme a instalar Windows 7... que da mucho palo, simplemente no me acordaba :S, así que no es para hablar de esa manera y decirme que no confio en ti, por que no tengo motivos para desconfiar de alguien que me intenta ayudar como eres tú.
De todas formas entiendo que te haya podido parecer eso por que ha sido un lapsus tremendo ahora que me doy cuenta, no pasa nada, a veces suelo ser bastante olvidadizo.

Sobre Windows 8, sip, lo tengo instalado en la V.M. y las voces son muy distintas, muy... sosas, la voz castellana tiene un tono bastante grave, nada que ver con la del video que mostré, además, solo hay una voz femenina que hable en Castellano, las otras dos son latinas.
De todas formas debo decir que lo he probado en Windows 8.1, en Windows 8 no, pero no creo que se hayan tomado la molestia y el trabajo de actualizar las voces Españolas en esa actualización del 8 al 8.1 xD, espero que no... vaya

Bueno tendré que salir de dudas... descargaré una ISO del XP, Vista, y otra del 8 (no 8.1), ya editaré este comentario para informar.

EDITO:
Windows Vista en Español solo lleva la voz de Anna, que es inglés.
Windows XP en Español solo lleva la voz de Microsoft Sam, que es inglés, y por cierto, es una completa basura.
Windows 8, todavía no lo he podido probar.

Saludos
6286  Programación / Programación General / MOVIDO: Guardar datos en c++ Urgente!!! en: 7 Noviembre 2014, 14:30 pm
El tema ha sido movido a Programación C/C++.

http://foro.elhacker.net/index.php?topic=424210.0
6287  Foros Generales / Dudas Generales / Re: ¿Que voz TTS femenina es esta? en: 7 Noviembre 2014, 12:24 pm
hola Eleкtro, por favor fíjate en el enlace, supuestamente es la voz que buscas, lo que realmente desconozco si es compatible con diferentes asistentes virtuales, o bien ya integra uno... tambien la misma está para decarga gratuita para plataformas android.

No, el contenido del enlace no es la voz, es un pack de recursos para "diseñar" macros de reconocimiento de voz, en el pack incluyen algunas herramientas como Loquendo junto a unas voces de loquendo (ninguna es la voz que estoy buscando)

De hecho ahora que me fijo mejor en el contenido del enlace, lo has sacado de la descripción de un video de youtube que yo también encontré por casualidad y que NO tiene que ver con el primer video que se publicó de "E.V.A." por el compañero @Bundor, ¿verdad?, es otro video si no recuerdo mal de una persona latina, y el rar no contiene nada respecto a la voz que se usa en el video original del youtuber Español :(.

Gracias de nuevo,
saludos
6288  Foros Generales / Dudas Generales / Re: ¿Que voz TTS femenina es esta? en: 7 Noviembre 2014, 12:07 pm
Pero... es que no entiendo que es eso del sistema jarvis que ya lo han mencionado dos veces.

te refieres a este "JARVIS"?, una especie de asistente virtual como eva?:
http://sourceforge.net/projects/mimodynedla/files/

Pero eso es un software aparte que nada tiene que ver con la obtención/uso de las voces... no se si me explico, hay miles de videos en youtube que utilizan la voz que estoy buscando, esos miles de usuarios no usan jarvis, de algún modo deben haber obtenido esa voz femenina española (castellana) por que parece algo muy común su utilización por todo tipo de personas con menos y más conocimientos informáticos... de hecho me atrevo a decir que esa voz está tan propagada y es tan usada como la voz "Jorge" de Loquendo, así que alguien debe conocer los detalles sobre esto...

es realmente increible que me cueste encontrar el maldito detalle de donde encontrar/usar esta voz... me estoy volviendo loco de tantas voces que ya probé y software que me instalé y máquinas virtuales.

Pensé que sería mucho más facil resolver este asunto, sinceramente, alguien debe saber, o debe tener algún amigo en youtube que haya utilizado esa misma voz o algo... ¿de donde narices puedo sacar esa preciosa voz femenina? :(.

Muchas gracias por tu ayuda, veré si dentro del software del Bot este "EVA" encuentro la voz, o alguna pista.

Saludos
6289  Foros Generales / Dudas Generales / Re: ¿Que voz TTS femenina es esta? en: 7 Noviembre 2014, 07:29 am
Tiene un cierto aire a la voz de E.V.A pero no se cuál és.
En este video el audio sale bastante saturado y se acerca bastante, aunque creo que no es la misma, pero bueno si quereis verlo es entretenido.


Sin duda alguna se trata de LA MISMA voz que estoy buscando.

Pero el autor del software no espeicifca nada sobre los materiales utilizados en su proyecto, así que no se de donde demonios saca esa voz Española TTS y sigo igual que como estaba en un principio :-/

EDITO: Por la falta de información en TODOS los sitios y por el frecuente uso de esta voz por novatos y expertos me da la sensación de que debe ser una Voz Microsoft TTS incluida por defecto en Windows 7... me instalaré Win7 en una V.M. para verificarlo.
EDITO2: Pues tampoco, en windows 7 ultimate español solo viene una voz (Anna) y está en inglés, esto me está desquiziando ya...

Gracias.

Mira a ver si esto te sirve  

Lamentablemente no me sirve ya que ninguna de esas voces es la que estoy buscando.

Gracias.
6290  Programación / .NET (C#, VB.NET, ASP) / Re: [AYUDA]llenar un Combobox c# en: 7 Noviembre 2014, 06:53 am
ComboBox.ObjectCollection.AddRange Method
Adds an array of items to the list of items for a ComboBox.

List(T).ToArray Method
Copies the elements of the List<T> to a new array.

VB.Net
Código
  1. Dim list As New List(Of String) From
  2.    {
  3.        "a",
  4.        "b",
  5.        "c"
  6.    }
  7.  
  8. With ComboBox1
  9.    .DropDownStyle = ComboBoxStyle.DropDownList
  10.    .SuspendLayout()
  11.    .Items.AddRange(list.ToArray)
  12.    .SelectedIndex = 0
  13.    .ResumeLayout()
  14. End With

Csharp
Código
  1. List<string> list = new List<string> {
  2. "a",
  3. "b",
  4. "c"
  5. };
  6.  
  7. var _with1 = ComboBox1;
  8. _with1.DropDownStyle = ComboBoxStyle.DropDownList;
  9. _with1.SuspendLayout();
  10. _with1.Items.AddRange(list.ToArray);
  11. _with1.SelectedIndex = 0;
  12. _with1.ResumeLayout();
  13.  
  14. //=======================================================
  15. //Service provided by Telerik (www.telerik.com)
  16. //=======================================================
Páginas: 1 ... 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 [629] 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines