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


 


Tema destacado: Personaliza-Escoge el diseño del foro que más te guste.


+  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 1 Visitante están viendo este tema.
Páginas: 1 ... 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [55] Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 309,599 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.700



Ver Perfil
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #540 en: 19 Febrero 2019, 15:55 »

HardwareStress

( click en la imagen para descargar la librería o el código fuente )


HardwareStress es una biblioteca .NET que proporciona un mecanismo para estresar los recursos de hardware, como la CPU, disco o memoria RAM.

Como cualquier otro software enfocado para estresar  los recursos de hardware, usted debe usarlo bajo su propio riesgo. No me responsabilizo de un error de hardware.



Donaciones

Cualquier código dentro del espacio de nombres "DevCase" se distribuye libremente como parte del código fuente comercial de "DevCase for .NET Framework".

Tal vez te gustaría considerar comprar este conjunto de bibliotecas para apoyarme. Puede hacer un montón de cosas con mis bibliotecas para una gran cantidad de temáticas diversas, no solo relacionadas con hardware, etc.

Aquí hay un enlace a la página de compra:

Muchas gracias.



Uso

El uso es muy simple, hay 3 clases: CpuStress, DiskStress y MemoryStress que proporciona un método Allocate() para comenzar a estresar los recursos, y un método Deallocate() para detenerlo.



Ejemplos de uso

CPU Stress
Código
  1. Using cpuStress As New CpuStress()
  2.    Dim percentage As Single = 20.5F 20.50%
  3.  
  4.    Console.WriteLine("Allocating CPU usage percentage...")
  5.    cpuStress.Allocate(percentage)
  6.    Thread.Sleep(TimeSpan.FromSeconds(5))
  7.    Console.WriteLine("Instance CPU average usage percentage: {0:F2}%", cpuStress.InstanceCpuPercentage)
  8.    Console.WriteLine("Process  CPU average usage percentage: {0:F2}%", cpuStress.ProcessCpuPercentage)
  9.    Console.WriteLine()
  10.  
  11.    Console.WriteLine("Deallocating CPU usage percentage...")
  12.    cpuStress.Deallocate()
  13.    Thread.Sleep(TimeSpan.FromSeconds(5))
  14.    Console.WriteLine("Instance CPU average usage percentage: {0:F2}%", cpuStress.InstanceCpuPercentage)
  15.    Console.WriteLine("Process  CPU average usage percentage: {0:F2}%", cpuStress.ProcessCpuPercentage)
  16. End Using


Disk Stress
Código
  1. Using diskStress As New DiskStress()
  2.    Console.WriteLine("Allocating disk I/O read and write operations...")
  3.    diskStress.Allocate(fileSize:=1048576) 1 MB
  4.  
  5.    Thread.Sleep(TimeSpan.FromSeconds(10))
  6.  
  7.    Console.WriteLine("Stopping disk I/O read and write operations...")
  8.    diskStress.Deallocate()
  9.  
  10.    Console.WriteLine()
  11.    Console.WriteLine("Instance disk I/O read operations count: {0} (total of files read)", diskStress.InstanceReadCount)
  12.    Console.WriteLine("Process  disk I/O read operations count: {0}", diskStress.ProcessReadCount)
  13.    Console.WriteLine()
  14.    Console.WriteLine("Instance disk I/O read data (in bytes): {0} ({1:F2} GB)", diskStress.InstanceReadBytes, (diskStress.InstanceReadBytes / 1024.0F ^ 3))
  15.    Console.WriteLine("Process  disk I/O read data (in bytes): {0} ({1:F2} GB)", diskStress.ProcessReadBytes, (diskStress.ProcessReadBytes / 1024.0F ^ 3))
  16.    Console.WriteLine()
  17.    Console.WriteLine("Instance disk I/O write operations count: {0} (total of files written)", diskStress.InstanceWriteCount)
  18.    Console.WriteLine("Process  disk I/O write operations count: {0}", diskStress.ProcessWriteCount)
  19.    Console.WriteLine()
  20.    Console.WriteLine("Instance disk I/O written data (in bytes): {0} ({1:F2} GB)", diskStress.InstanceWriteBytes, (diskStress.InstanceWriteBytes / 1024.0F ^ 3))
  21.    Console.WriteLine("Process  disk I/O written data (in bytes): {0} ({1:F2} GB)", diskStress.ProcessWriteBytes, (diskStress.ProcessWriteBytes / 1024.0F ^ 3))
  22. End Using


Memory Stress
Código
  1. Using memStress As New MemoryStress()
  2.    Dim memorySize As Long = 1073741824 1 GB
  3.  
  4.    Console.WriteLine("Allocating physical memory size...")
  5.    memStress.Allocate(memorySize)
  6.    Console.WriteLine("Instance Physical Memory Size (in bytes): {0} ({1:F2} GB)", memStress.InstancePhysicalMemorySize, (memStress.InstancePhysicalMemorySize / 1024.0F ^ 3))
  7.    Console.WriteLine("Process  Physical Memory Size (in bytes): {0} ({1:F2} GB)", memStress.ProcessPhysicalMemorySize, (memStress.ProcessPhysicalMemorySize / 1024.0F ^ 3))
  8.    Console.WriteLine()
  9.    Console.WriteLine("Deallocating physical memory size...")
  10.    memStress.Deallocate()
  11.    Console.WriteLine("Instance Physical Memory Size (in bytes): {0}", memStress.InstancePhysicalMemorySize)
  12.    Console.WriteLine("Process  Physical Memory Size (in bytes): {0} ({1:F2} MB)", memStress.ProcessPhysicalMemorySize, (memStress.ProcessPhysicalMemorySize / 1024.0F ^ 2))
  13. End Using


En línea


Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.700



Ver Perfil
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #541 en: 19 Febrero 2019, 22:04 »

Generador aleatorio de párrafos

Código
  1. Private Shared rng As New Random(Seed:=Environment.TickCount)

Código
  1. ''' ----------------------------------------------------------------------------------------------------
  2. ''' <summary>
  3. ''' Generates a random paragraph using the specified set of words.
  4. ''' </summary>
  5. ''' ----------------------------------------------------------------------------------------------------
  6. ''' <param name="words">
  7. ''' The words that will be used to build paragraphs.
  8. ''' </param>
  9. '''
  10. ''' <param name="numberOfParagraphs">
  11. ''' The number of paragraphs to generate.
  12. ''' </param>
  13. '''
  14. ''' <param name="htmlFormatting">
  15. ''' Specifies whether or not to format paragraphs for HTML.
  16. ''' </param>
  17. ''' ----------------------------------------------------------------------------------------------------
  18. ''' <returns>
  19. ''' The resulting paragraph(s).
  20. ''' </returns>
  21. ''' ----------------------------------------------------------------------------------------------------
  22. <DebuggerStepThrough>
  23. Public Shared Function RandomParagraphGenerator(ByVal words As String(),
  24.                                                ByVal numberOfParagraphs As Integer,
  25.                                                ByVal htmlFormatting As Boolean) As String
  26.  
  27.    Dim sb As New StringBuilder()
  28.  
  29.    Dim nextWord As String
  30.    Dim nextWordIndex As Integer
  31.    Dim lastWordIndex As Integer
  32.  
  33.    For paragraphIndex As Integer = 0 To (numberOfParagraphs - 1)
  34.  
  35.        Dim phraseLen As Integer = rng.Next(2, 10)
  36.        For phraseIndex As Integer = 0 To (phraseLen - 1)
  37.  
  38.            If (phraseIndex = 0) AndAlso (htmlFormatting) Then
  39.                sb.Append("<p>")
  40.            End If
  41.  
  42.            Dim wordLen As Integer = rng.Next(3, 15)
  43.            Dim addComma As Boolean = (rng.NextDouble() < 50 / 100.0) ' 50% probability to add a comma in a phrase.
  44.            Dim commaAmount As Integer = rng.Next(1, (wordLen - 1) \ 2)
  45.            Dim commaIndices As New HashSet(Of Integer)
  46.            For i As Integer = 0 To (commaAmount - 1)
  47.                commaIndices.Add(rng.Next(1, (wordLen - 1)))
  48.            Next i
  49.  
  50.            For wordIndex As Integer = 0 To (wordLen - 1)
  51.  
  52.                Do Until (nextWordIndex <> lastWordIndex)
  53.                    nextWordIndex = rng.Next(0, words.Length)
  54.                Loop
  55.                lastWordIndex = nextWordIndex
  56.                nextWord = words(nextWordIndex)
  57.  
  58.                If (wordIndex = 0) Then
  59.                    sb.Append(Char.ToUpper(nextWord(0)) & nextWord.Substring(1))
  60.                    Continue For
  61.                End If
  62.                sb.Append(" " & words(rng.Next(0, words.Length)))
  63.  
  64.                If (commaIndices.Contains(wordIndex)) AndAlso (addComma) Then
  65.                    sb.Append(","c)
  66.                End If
  67.  
  68.                If (wordIndex = (wordLen - 1)) Then
  69.                    If (phraseIndex <> (phraseLen - 1)) Then
  70.                        sb.Append(". ")
  71.                    Else
  72.                        sb.Append(".")
  73.                    End If
  74.                End If
  75.            Next wordIndex
  76.  
  77.        Next phraseIndex
  78.  
  79.        If (htmlFormatting) Then
  80.            sb.Append("</p>")
  81.        End If
  82.  
  83.        sb.AppendLine(Environment.NewLine)
  84.  
  85.    Next paragraphIndex
  86.  
  87.    Return sb.ToString()
  88. End Function
  89.  

Modo de empleo:
Código
  1. Dim words As String() = {
  2.    "a", "ability", "able", "about", "above", "accept", "according", "account", "across",
  3.    "act", "action", "activity", "actually", "add", "address", "administration", "admit",
  4.    "adult", "affect", "after", "again", "against", "age", "agency", "agent", "ago", "agree",
  5.    "agreement", "ahead", "air", "all", "allow", "almost", "alone", "along", "already", "also",
  6.    "although", "always", "American", "among", "amount", "analysis", "and", "animal", "another",
  7.    "answer", "any", "anyone", "anything", "appear", "apply", "approach", "area", "argue", "arm",
  8.    "around", "arrive", "art", "article", "artist", "as", "ask", "assume", "at", "attack", "attention",
  9.    "attorney", "audience", "author", "authority", "available", "avoid", "away", "baby", "back",
  10.    "bed", "before", "begin", "behavior", "behind", "believe", "benefit", "best", "better", "between",
  11.    "both", "box", "boy", "break", "bring", "brother", "budget", "build", "building", "business", "but",
  12.    "buy", "by", "call", "camera", "campaign", "can", "cancer", "candidate", "capital", "car", "card",
  13.    "care", "career", "carry", "case", "catch", "cause", "cell", "center", "central", "century", "certain",
  14.    "choice", "choose", "church", "citizen", "city", "civil", "claim", "class", "clear", "clearly",
  15.    "close", "coach", "cold", "collection", "college", "color", "come", "commercial", "common", "community",
  16.    "consumer", "contain", "continue", "control", "cost", "could", "country", "couple", "course", "court",
  17.    "cover", "create", "crime", "cultural", "culture", "cup", "current", "customer", "cut", "dark",
  18.    "data", "daughter", "day", "dead", "deal", "death", "debate", "decade", "decide", "decision", "deep",
  19.    "defense", "degree", "Democrat", "democratic", "describe", "design", "despite", "detail",
  20.    "direction", "director", "discover", "discuss", "discussion", "disease", "do", "doctor", "dog",
  21.    "door", "down", "draw", "dream", "drive", "drop", "drug", "during", "each", "early", "east", "easy",
  22.    "eat", "economic", "economy", "edge", "education", "effect", "effort", "eight", "either", "election",
  23.    "environmental", "especially", "establish", "even", "evening", "event", "ever", "every", "everybody",
  24.    "everyone", "everything", "evidence", "exactly", "example", "executive", "exist", "expect",
  25.    "experience", "expert", "explain", "eye", "face", "fact", "factor", "fail", "fall", "family",
  26.    "fill", "film", "final", "finally", "financial", "find", "fine", "finger", "finish", "fire",
  27.    "firm", "first", "fish", "five", "floor", "fly", "focus", "follow", "food", "foot", "for",
  28.    "force", "foreign", "forget", "form", "former", "forward", "four", "free", "friend", "from",
  29.    "front", "full", "fund", "future", "game", "garden", "gas", "general", "generation", "get",
  30.    "girl", "give", "glass", "go", "goal", "good", "government", "great", "green", "ground",
  31.    "group", "grow", "growth", "guess", "gun", "guy", "hair", "half", "hand", "hang", "happen",
  32.    "happy", "hard", "have", "he", "head", "health", "hear", "heart", "heat", "heavy", "help",
  33.    "her", "here", "herself", "high", "him", "himself", "his", "history", "hit", "hold", "home",
  34.    "hope", "hospital", "hot", "hotel", "hour", "house", "how", "however", "huge", "human", "hundred",
  35.    "husband", "I", "idea", "identify", "if", "image", "imagine", "impact", "important", "improve",
  36.    "in", "include", "including", "increase", "indeed", "indicate", "individual", "industry",
  37.    "information", "inside", "instead", "institution", "interest", "interesting", "international",
  38.    "interview", "into", "investment", "involve", "issue", "it", "item", "its", "itself", "job",
  39.    "join", "just", "keep", "key", "kid", "kill", "kind", "kitchen", "know", "knowledge", "land",
  40.    "language", "large", "last", "late", "later", "laugh", "law", "lawyer", "lay", "lead", "leader",
  41.    "learn", "least", "leave", "left", "leg", "legal", "less", "let", "letter", "level", "lie", "life",
  42.    "light", "like", "likely", "line", "list", "listen", "little", "live", "local", "long", "look",
  43.    "lose", "loss", "lot", "love", "low", "machine", "magazine", "main", "maintain", "major", "majority",
  44.    "make", "man", "manage", "management", "manager", "many", "market", "marriage", "material", "matter",
  45.    "may", "maybe", "me", "mean", "measure", "media", "medical", "meet", "meeting", "member",
  46.    "memory", "mention", "message", "method", "middle", "might", "military", "million", "mind",
  47.    "minute", "miss", "mission", "model", "modern", "moment", "money", "month", "more", "morning",
  48.    "most", "mother", "mouth", "move", "movement", "movie", "Mr", "Mrs", "much", "music", "must",
  49.    "my", "myself", "name", "nation", "national", "natural", "nature", "near", "nearly", "necessary",
  50.    "need", "network", "never", "new", "news", "newspaper", "next", "nice", "night", "no", "none", "nor",
  51.    "north", "not", "note", "nothing", "notice", "now", "number", "occur", "of", "off", "offer",
  52.    "office", "officer", "official", "often", "oh", "oil", "ok", "old", "on", "once", "one", "only",
  53.    "onto", "open", "operation", "opportunity", "option", "or", "order", "organization", "other",
  54.    "others", "our", "out", "outside", "over", "own", "owner", "page", "pain", "painting", "paper",
  55.    "parent", "part", "participant", "particular", "particularly", "partner", "party", "pass",
  56.    "past", "patient", "pattern", "pay", "peace", "people", "per", "perform", "performance",
  57.    "perhaps", "period", "person", "personal", "phone", "physical", "pick", "picture",
  58.    "piece", "place", "plan", "plant", "play", "player", "PM", "point", "police", "policy",
  59.    "political", "politics", "poor", "popular", "population", "position", "positive",
  60.    "possible", "power", "practice", "prepare", "present", "president", "pressure",
  61.    "pretty", "prevent", "price", "private", "probably", "problem", "process", "produce",
  62.    "product", "production", "professional", "professor", "program", "project", "property", "protect",
  63.    "prove", "provide", "public", "pull", "purpose", "push", "put", "quality", "question", "quickly",
  64.    "quite", "race", "radio", "raise", "range", "rate", "rather", "reach", "read", "ready", "real",
  65.    "reality", "realize", "really", "reason", "receive", "recent", "recently", "recognize", "record",
  66.    "red", "reduce", "reflect", "region", "relate", "relationship", "religious", "remain", "remember",
  67.    "remove", "report", "represent", "Republican", "require", "research", "resource", "respond", "response",
  68.    "responsibility", "rest", "result", "return", "reveal", "rich", "right", "rise", "risk", "road",
  69.    "rock", "role", "room", "rule", "run", "safe", "same", "save", "say", "scene", "school", "science",
  70.    "scientist", "score", "sea", "season", "seat", "second", "section", "security", "see", "seek",
  71.    "seem", "sell", "send", "senior", "sense", "series", "serious", "serve", "service", "set", "seven",
  72.    "show", "side", "sign", "significant", "similar", "simple", "simply", "since", "sing", "single",
  73.    "sister", "sit", "site", "situation", "six", "size", "skill", "skin", "small", "smile", "so",
  74.    "social", "society", "soldier", "some", "somebody", "someone", "something", "sometimes", "son",
  75.    "specific", "speech", "spend", "sport", "spring", "staff", "stage", "stand", "standard", "star",
  76.    "start", "state", "statement", "station", "stay", "step", "still", "stock", "stop", "store",
  77.    "story", "strategy", "street", "strong", "structure", "student", "study", "stuff", "style",
  78.    "subject", "success", "successful", "such", "suddenly", "suffer", "suggest", "summer", "support",
  79.    "sure", "surface", "system", "table", "take", "talk", "task", "tax", "teach", "teacher", "team",
  80.    "technology", "television", "tell", "ten", "tend", "term", "test", "than", "thank", "that", "the",
  81.    "their", "them", "themselves", "then", "theory", "there", "these", "they", "thing", "think",
  82.    "third", "this", "those", "though", "thought", "thousand", "threat", "three", "through", "throughout",
  83.    "throw", "thus", "time", "to", "today", "together", "tonight", "too", "top", "total", "tough",
  84.    "toward", "town", "trade", "traditional", "training", "travel", "treat", "treatment", "tree",
  85.    "trial", "trip", "trouble", "true", "truth", "try", "turn", "TV", "two", "type", "under", "understand",
  86.    "unit", "until", "up", "upon", "us", "use", "usually", "value", "various", "very", "victim",
  87.    "view", "violence", "visit", "voice", "vote", "wait", "walk", "wall", "want", "war", "watch", "water",
  88.    "way", "we", "weapon", "wear", "week", "weight", "well", "west", "western", "what", "whatever",
  89.    "when", "where", "whether", "which", "while", "white", "who", "whole", "whom", "whose", "why",
  90.    "wide", "wife", "will", "win", "wind", "window", "wish", "with", "within", "without", "woman",
  91.    "wonder", "word", "work", "worker", "world", "worry", "would", "write", "writer", "wrong", "yard",
  92.    "yeah", "year", "yes", "yet", "you", "young", "your", "yourself"}
  93.  
  94. Dim paragraphs As String = RandomParagraphGenerator(words, numberOfParagraphs:=4, htmlFormatting:=False)
  95. Console.WriteLine(paragraphs)

Citar
Finish at, raise, movie exist page, including there, yard ground why, information everyone. Life full those finger instead simple central those scientist. Force road of pick your student social. Prevent plan heart site. Anyone door, explain control.

Process interest we high human occur agree page put. Left education according thus, structure fine second professor rather relationship guess instead maybe radio. Second process reason on, create west. Forget victim wrong may themselves out where occur sometimes. Wide candidate, newspaper, if purpose at assume draw month, American physical create. Sea sign describe white though want minute type to medical. Explain girl their most upon.

Suddenly drug writer follow must. Right choose, option one capital risk. Administration forget practice anything. Notice people take movie, dark, yes only. Inside either recent movement during particular wear husband particularly those legal. Suffer drug establish work. Guess two have garden value property realize dog people friend, hospital that.

Person movie north wrong thing group. Write exist church daughter up, why appear ahead growth, wife news protect. Save smile, impact improve direction trouble tax, scene, north nation, maybe hang face history. Cause lawyer true worker season, more.



Generador aleatorio de texto 'Lorem Ipsum'

( ESTA FUNCIÓN SIMPLEMENTA HACE UNA LLAMADA AL GENERADOR DE PÁRRAFOS QUE HE PUBLICADO ARRIBA. )

Código
  1. ''' ----------------------------------------------------------------------------------------------------
  2. ''' <summary>
  3. ''' Generates a random 'Lorem Ipsum' paragraph.
  4. ''' </summary>
  5. ''' ----------------------------------------------------------------------------------------------------
  6. ''' <remarks>
  7. ''' Wikipedia article: <see href="https://en.wikipedia.org/wiki/Lorem_ipsum"/>
  8. ''' </remarks>
  9. ''' ----------------------------------------------------------------------------------------------------
  10. ''' <param name="numberOfParagraphs">
  11. ''' The number of paragraphs to generate.
  12. ''' </param>
  13. '''
  14. ''' <param name="htmlFormatting">
  15. ''' Specifies whether or not to format paragraphs for HTML.
  16. ''' </param>
  17. ''' ----------------------------------------------------------------------------------------------------
  18. ''' <returns>
  19. ''' The resulting 'Lorem Ipsum' paragraph(s).
  20. ''' </returns>
  21. ''' ----------------------------------------------------------------------------------------------------
  22. <DebuggerStepThrough>
  23. Public Shared Function GenerateLoremIpsumText(ByVal numberOfParagraphs As Integer,
  24.                                              ByVal htmlFormatting As Boolean) As String
  25.  
  26.    Dim words As String() = {
  27.        "abhorreant", "accommodare", "accumsan", "accusam", "accusamus", "accusata", "ad",
  28.        "adhuc", "adipisci", "adipiscing", "admodum", "adolescens", "adversarium", "aeque",
  29.        "aeterno", "affert", "agam", "albucius", "alia", "alienum", "alii", "aliquam",
  30.        "aliquando", "aliquid", "aliquip", "alterum", "amet", "an", "ancillae", "animal",
  31.        "antiopam", "apeirian", "aperiam", "aperiri", "appareat", "appellantur", "appetere",
  32.        "argumentum", "assentior", "assueverit", "assum", "at", "atomorum", "atqui", "audiam",
  33.        "audire", "augue", "autem", "blandit", "bonorum", "brute", "case", "causae", "cetero",
  34.        "ceteros", "choro", "cibo", "civibus", "clita", "commodo", "commune", "complectitur",
  35.        "comprehensam", "conceptam", "concludaturque", "conclusionemque", "congue", "consectetuer",
  36.        "consequat", "consequuntur", "consetetur", "constituam", "constituto", "consul", "consulatu",
  37.        "contentiones", "convenire", "copiosae", "corpora", "corrumpit", "cotidieque", "cu", "cum",
  38.        "debet", "debitis", "decore", "definiebas", "definitionem", "definitiones", "delectus",
  39.        "delenit", "deleniti", "delicata", "delicatissimi", "democritum", "denique", "deseruisse",
  40.        "deserunt", "deterruisset", "detracto", "detraxit", "diam", "dicam", "dicant", "dicat",
  41.        "diceret", "dicit", "dico", "dicta", "dictas", "dicunt", "dignissim", "discere", "disputando",
  42.        "disputationi", "dissentias", "dissentiet", "dissentiunt", "docendi", "doctus", "dolor",
  43.        "dolore", "dolorem", "dolores", "dolorum", "doming", "duis", "duo", "ea", "eam", "efficiantur",
  44.        "efficiendi", "ei", "eirmod", "eius", "elaboraret", "electram", "eleifend", "eligendi", "elit",
  45.        "elitr", "eloquentiam", "enim", "eos", "epicurei", "epicuri", "equidem", "erant", "erat",
  46.        "eripuit", "eros", "errem", "error", "erroribus", "eruditi", "esse", "essent", "est", "et",
  47.        "etiam", "eu", "euismod", "eum", "euripidis", "everti", "evertitur", "ex", "exerci", "expetenda",
  48.        "expetendis", "explicari", "fabellas", "fabulas", "facer", "facete", "facilis", "facilisi",
  49.        "facilisis", "falli", "fastidii", "ferri", "feugait", "feugiat", "fierent", "forensibus",
  50.        "fugit", "fuisset", "gloriatur", "graece", "graeci", "graecis", "graeco", "gubergren", "habemus",
  51.        "habeo", "harum", "has", "hendrerit", "hinc", "his", "homero", "honestatis", "id", "idque",
  52.        "ignota", "iisque", "illud", "illum", "impedit", "imperdiet", "impetus", "in", "inani", "inciderint",
  53.        "incorrupte", "indoctum", "inermis", "inimicus", "insolens", "instructior", "integre", "intellegam",
  54.        "intellegat", "intellegebat", "interesset", "interpretaris", "invenire", "invidunt", "ipsum",
  55.        "iracundia", "iriure", "iudicabit", "iudico", "ius", "iusto", "iuvaret", "justo", "labitur",
  56.        "laboramus", "labore", "labores", "laoreet", "latine", "laudem", "legendos", "legere", "legimus",
  57.        "liber", "liberavisse", "libris", "lobortis", "lorem", "lucilius", "ludus", "luptatum", "magna",
  58.        "maiestatis", "maiorum", "malis", "malorum", "maluisset", "mandamus", "mazim", "mea", "mediocrem",
  59.        "mediocritatem", "mei", "meis", "mel", "meliore", "melius", "menandri", "mentitum", "minim",
  60.        "minimum", "mnesarchum", "moderatius", "modo", "modus", "molestiae", "molestie", "mollis", "movet",
  61.        "mucius", "mundi", "munere", "mutat", "nam", "natum", "ne", "nec", "necessitatibus", "neglegentur",
  62.        "nemore", "nibh", "nihil", "nisl", "no", "nobis", "noluisse", "nominati", "nominavi", "nonumes",
  63.        "nonumy", "noster", "nostro", "nostrud", "nostrum", "novum", "nulla", "nullam", "numquam", "nusquam",
  64.        "oblique", "ocurreret", "odio", "offendit", "officiis", "omittam", "omittantur", "omnes", "omnesque",
  65.        "omnis", "omnium", "oporteat", "oportere", "option", "oratio", "ornatus", "partem", "partiendo",
  66.        "patrioque", "paulo", "per", "percipit", "percipitur", "perfecto", "pericula", "periculis", "perpetua",
  67.        "persecuti", "persequeris", "persius", "pertinacia", "pertinax", "petentium", "phaedrum", "philosophia",
  68.        "placerat", "platonem", "ponderum", "populo", "porro", "posidonium", "posse", "possim", "possit",
  69.        "postea", "postulant", "praesent", "pri", "prima", "primis", "principes", "pro", "probatus", "probo",
  70.        "prodesset", "prompta", "propriae", "purto", "putant", "putent", "quaeque", "quaerendum", "quaestio",
  71.        "qualisque", "quando", "quas", "quem", "qui", "quidam", "quis", "quo", "quod", "quodsi", "quot",
  72.        "rationibus", "rebum", "recteque", "recusabo", "referrentur", "reformidans", "regione", "reprehendunt",
  73.        "reprimique", "repudiandae", "repudiare", "reque", "ridens", "sadipscing", "saepe", "sale", "salutandi",
  74.        "salutatus", "sanctus", "saperet", "sapientem", "scaevola", "scribentur", "scripserit", "scripta",
  75.        "scriptorem", "sea", "sed", "semper", "senserit", "sensibus", "sententiae", "signiferumque", "similique",
  76.        "simul", "singulis", "sint", "sit", "soleat", "solet", "solum", "soluta", "sonet", "splendide", "stet",
  77.        "suas", "suavitate", "summo", "sumo", "suscipiantur", "suscipit", "tacimates", "tale", "tamquam", "tantas",
  78.        "tation", "te", "tempor", "temporibus", "theophrastus", "tibique", "timeam", "tincidunt", "tollit",
  79.        "torquatos", "tota", "tractatos", "tritani", "ubique", "ullamcorper", "ullum", "unum", "urbanitas", "usu",
  80.        "ut", "utamur", "utinam", "utroque", "vel", "velit", "veniam", "verear", "veri", "veritus", "vero",
  81.        "verterem", "vide", "viderer", "vidisse", "vidit", "vim", "viris", "virtute", "vis", "vitae", "vituperata",
  82.        "vituperatoribus", "vivendo", "vivendum", "vix", "vocent", "vocibus", "volumus", "voluptaria",
  83.        "voluptatibus", "voluptatum", "voluptua", "volutpat", "vulputate", "wisi", "zril"}
  84.  
  85.    Dim str As String = RandomParagraphGenerator(words, numberOfParagraphs, htmlFormatting)
  86.  
  87.    If (htmlFormatting) Then
  88.        Return str.Insert(3, "Lorem ipsum dolor sit amet. ")
  89.    Else
  90.        Return str.Insert(0, "Lorem ipsum dolor sit amet. ")
  91.    End If
  92.  
  93. End Function

Modo de empleo:

Código
  1. Dim loremIpsum As String = GenerateLoremIpsumText(numberOfParagraphs:=4, htmlFormatting:=True)
  2. Console.WriteLine(loremIpsum)

Citar
<p>Lorem ipsum dolor sit amet. Placerat vulputate tollit cum vivendo adipiscing nemore duo salutandi mollis. Fabellas malis, eros solet rationibus. Assum suas inermis, at veri prompta modo scaevola, ad. Percipitur ceteros semper vituperata feugait disputationi cotidieque soluta. Efficiendi facilisi zril percipit putant quando id quas nobis civibus natum. Pertinax maluisset vidisse oratio autem eripuit repudiandae ea suas eros illum oratio aliquid. Fabulas porro, integre oportere.</p>

<p>Virtute mediocritatem, vim erant nisl. Legendos postea saperet postea putent nihil facilisi nominati omnis. Facilisis persequeris scaevola alterum probatus vulputate denique pericula ullamcorper eloquentiam oporteat purto mediocritatem.</p>

<p>Veniam petentium delectus delicatissimi malis voluptua mentitum dissentias interpretaris verear quis utamur albucius verear. Quo reformidans, definitiones facilis. Conclusionemque quaestio voluptaria populo delicata sit viris mediocrem vulputate voluptatum eloquentiam. Quas an, bonorum cibo audiam commune volutpat. Vis ullamcorper scriptorem omnis facilisis sententiae hendrerit. Oporteat atomorum prompta suavitate idque accommodare ius oblique graece graecis interpretaris nemore. Meliore albucius commune qui suscipit definitiones vidit docendi facilisi forensibus quis. Equidem dolore expetendis iudico, delectus viderer timeam. Mediocrem molestie timeam, recteque, maluisset evertitur delicata.</p>

<p>Similique neglegentur temporibus alienum ad legimus scriptorem bonorum et appetere vide molestie. Mentitum feugait voluptatum illum detracto, tamquam vel ponderum mei illud, omnis paulo, ignota. Malorum lorem consul molestie interpretaris aperiri vituperatoribus, soluta enim vituperatoribus.</p>


« Última modificación: 19 Febrero 2019, 22:14 por Eleкtro (aliviado) » En línea


Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.700



Ver Perfil
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #542 en: 2 Marzo 2019, 23:25 »

ConsoleRectangle

Esto es el equivalente a la clase System.Drawing.Rectangle, para representar la posición y tamaño de un rectángulo (dibujable) en el búfer de salida de una consola.





Decisiones (o limitaciones) de diseño:
  • Las propiedades son de solo lectura (para quitarme de lios). Es decir, para hacer cambios en el tamaño o posición del rectángulo, hay que crear una nueva instancia. - ya no lo son
  • No permite la asignación de coordenadas negativas (puesto que tampoco lo permite el método Console.SetCursorPos()), ni un tamaño (anchura ni altura) igual a cero, aunque esto último no se tiene en cuenta si se usa el constructor por defecto.

EDITO: implementación extendida.
Código:
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Stores a set of four integers that represent the location and size of a (printable) rectangle on a console output buffer.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<ComVisible(True)>
<Serializable>
Public Structure ConsoleRectangle

#Region " Properties "

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the location of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The location of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public Property Location As Point
        Get
            Return Me.location_
        End Get
        Set(value As Point)
            Me.UpdateLocation(value)
        End Set
    End Property
    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' ( Backing field of <see cref="ConsoleRectangle.Location"/> property. )
    ''' <para></para>
    ''' The location of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    Private location_ As Point

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the x-coordinate of the upper-left corner of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The x-coordinate of the upper-left corner of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public ReadOnly Property X As Integer
        Get
            Return Me.Location.X
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the y-coordinate of the upper-left corner of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The y-coordinate of the upper-left corner of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public ReadOnly Property Y As Integer
        Get
            Return Me.Location.Y
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the y-coordinate of the top edge of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The y-coordinate of the top edge of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public ReadOnly Property Top As Integer
        Get
            Return Me.Y
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the x-coordinate of the left edge of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The x-coordinate of the left edge of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public ReadOnly Property Left As Integer
        Get
            Return Me.X
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the y-coordinate that is the sum of the <see cref="ConsoleRectangle.Y"/>
    ''' and <see cref="ConsoleRectangle.Height"/> property values of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The y-coordinate that is the sum of the <see cref="ConsoleRectangle.Y"/>
    ''' and <see cref="ConsoleRectangle.Height"/> property values of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public ReadOnly Property Bottom As Integer
        Get
            Return (Me.Y + Me.Height)
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the x-coordinate that is the sum of <see cref="ConsoleRectangle.X"/>
    ''' and <see cref="ConsoleRectangle.Width"/> property values of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The x-coordinate that is the sum of <see cref="ConsoleRectangle.X"/>
    ''' and <see cref="ConsoleRectangle.Width"/> property values of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public ReadOnly Property Right As Integer
        Get
            Return (Me.X + Me.Width)
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the size of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The size of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public Property Size As Size
        Get
            Return Me.size_
        End Get
        Set(value As Size)
            Me.UpdateSize(value)
        End Set
    End Property
    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' ( Backing field of <see cref="ConsoleRectangle.Size"/> property. )
    ''' <para></para>
    ''' The size of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    Private size_ As Size

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the width of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The width of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public ReadOnly Property Width As Integer
        Get
            Return Me.Size.Width
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets the height of this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The height of this <see cref="ConsoleRectangle"/>.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public ReadOnly Property Height As Integer
        Get
            Return Me.Size.Height
        End Get
    End Property

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the character to print the left border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The character to print the left border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public Property CharLeft As Char

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the character to print the top border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The character to print the top border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public Property CharTop As Char

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the character to print the right border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The character to print the right border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public Property CharRight As Char

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Gets or sets the character to print the bottom border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' The character to print the bottom border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(True)>
    Public Property CharBottom As Char

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Tests whether all numeric properties of this System.Drawing.Rectangle have values of zero.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <value>
    ''' This property returns <see langword="True"/> if the
    ''' <see cref="ConsoleRectangle.Width"/>, <see cref="ConsoleRectangle.Height"/>,
    ''' <see cref="ConsoleRectangle.X"/>, and <see cref="ConsoleRectangle.Y"/> properties
    ''' of this <see cref="ConsoleRectangle"/> all have values of zero;
    ''' otherwise, <see langword="False"/>
    ''' </value>
    ''' ----------------------------------------------------------------------------------------------------
    <Browsable(False)>
    Public ReadOnly Property IsEmpty As Boolean
        Get
            Return (Me.Location = Point.Empty) AndAlso (Me.Size = Size.Empty)
        End Get
    End Property

#End Region

#Region " Constructors "

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Initializes a new instance of the <see cref="ConsoleRectangle"/> structure.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' A <see cref="Rectangle"/> that contains the location and size for this <see cref="ConsoleRectangle"/>.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub New(ByVal rect As Rectangle)
        Me.New(rect.Location, rect.Size, "▌"c, "▀"c, "▐"c, "▄"c)
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Initializes a new instance of the <see cref="ConsoleRectangle"/> structure.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' A <see cref="Rectangle"/> that contains the location and size for this <see cref="ConsoleRectangle"/>.
    ''' </param>
    '''
    ''' <param name="charLeft">
    ''' The character to print the left border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charTop">
    ''' The character to print the top border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charRight">
    ''' The character to print the right border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charBottom">
    ''' The character to print the bottom border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub New(ByVal rect As Rectangle,
                   ByVal charLeft As Char, ByVal charTop As Char,
                   ByVal charRight As Char, ByVal charBottom As Char)

        Me.New(rect.Location, rect.Size, charLeft, charTop, charRight, charBottom)

    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Initializes a new instance of the <see cref="ConsoleRectangle"/> structure.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="location">
    ''' The location for this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="size">
    ''' The size for this <see cref="ConsoleRectangle"/>.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub New(ByVal location As Point, ByVal size As Size)
        Me.New(location, size, "▌"c, "▀"c, "▐"c, "▄"c)
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Initializes a new instance of the <see cref="ConsoleRectangle"/> structure.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="location">
    ''' The location for this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="size">
    ''' The size for this <see cref="ConsoleRectangle"/>.
    ''' </param>
    '''
    ''' <param name="charLeft">
    ''' The character to print the left border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charTop">
    ''' The character to print the top border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charRight">
    ''' The character to print the right border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    '''
    ''' <param name="charBottom">
    ''' The character to print the bottom border of this <see cref="ConsoleRectangle"/> on a console output buffer.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <exception cref="ArgumentNullException">
    ''' </exception>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub New(ByVal location As Point, ByVal size As Size,
                   ByVal charLeft As Char, ByVal charTop As Char,
                   ByVal charRight As Char, ByVal charBottom As Char)

        Me.UpdateLocation(location)
        Me.UpdateSize(size)

        Me.CharLeft = charLeft
        Me.CharTop = charTop
        Me.CharRight = charRight
        Me.CharBottom = charBottom

    End Sub

#End Region

#Region " Public Methods "

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Writes the bounds of this <see cref="ConsoleRectangle"/> on the current console output buffer.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub Write()
        For row As Integer = 0 To (Me.Height - 1)
            For column As Integer = 0 To (Me.Width - 1)
                If (row = 0) Then
                    Console.SetCursorPosition((Me.X + column), (Me.Y + row))
                    Console.Write(Me.CharTop)

                ElseIf (row = (Me.Height - 1)) Then
                    Console.SetCursorPosition((Me.X + column), (Me.Y + row))
                    Console.Write(Me.CharBottom)

                End If
            Next column

            Console.SetCursorPosition(Me.X, (Me.Y + row))
            Console.Write(Me.CharLeft)
            Console.SetCursorPosition(Me.X + (Me.Width - 1), (Me.Y + row))
            Console.Write(Me.CharRight)
        Next row
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Enlarges this <see cref="ConsoleRectangle"/> by the specified amount.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="width">
    ''' The amount to inflate this <see cref="ConsoleRectangle"/> horizontally.
    ''' </param>
    '''
    ''' <param name="height">
    ''' The amount to inflate this <see cref="ConsoleRectangle"/> vertically.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub Inflate(ByVal width As Integer, ByVal height As Integer)
        Dim rc As Rectangle = Me
        rc.Inflate(width, height)
        Me.Size = rc.Size
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Enlarges this <see cref="ConsoleRectangle"/> by the specified amount.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="size">
    ''' The amount to inflate this <see cref="ConsoleRectangle"/>.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub Inflate(ByVal size As Size)
        Me.Inflate(size.Width, size.Height)
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Adjusts the location of this <see cref="ConsoleRectangle"/> by the specified amount.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="x">
    ''' The horizontal offset.
    ''' </param>
    '''
    ''' <param name="y">
    ''' The vertical offset.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub Offset(ByVal x As Integer, ByVal y As Integer)
        Dim rc As Rectangle = Me
        rc.Offset(x, y)
        Me.Location = rc.Location
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Adjusts the location of this <see cref="ConsoleRectangle"/> by the specified amount.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="location">
    ''' The amount to offset the location.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Sub Offset(ByVal location As Point)
        Me.Offset(location.X, location.Y)
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Returns a <see cref="String"/> that represents this <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' A <see cref="String"/> that represents this <see cref="ConsoleRectangle"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Overrides Function ToString() As String

        If (Me.Width = 1) AndAlso (Me.Height = 1) Then
            Return Me.CharLeft

        ElseIf (Me.Height = 1) Then
            Dim sb As New StringBuilder()
            Dim lastColumnIndex As Integer = (Me.Width - 1)
            For column As Integer = 0 To lastColumnIndex
                Select Case column
                    Case 0
                        sb.Append(Me.CharLeft)
                    Case lastColumnIndex
                        sb.Append(Me.CharRight)
                    Case Else
                        sb.Append(Me.CharTop)
                End Select
            Next column
            Return sb.ToString()

        ElseIf (Me.Width = 1) Then
            Dim sb As New StringBuilder()
            For row As Integer = 0 To (Me.Height - 1)
                sb.Append(Me.CharLeft)
                sb.AppendLine()
            Next row
            Return sb.ToString()

        Else
            Dim sb As New StringBuilder()
            Dim lastRowIndex As Integer = (Me.Height - 1)
            For row As Integer = 0 To lastRowIndex
                Select Case row
                    Case 0
                        sb.Append(Me.CharLeft)
                        sb.Append(New String(Me.CharTop, Math.Max((Me.Width - 2), 1)))
                        sb.Append(Me.CharRight)
                    Case lastRowIndex
                        sb.Append(Me.CharLeft)
                        sb.Append(New String(Me.CharBottom, Math.Max((Me.Width - 2), 1)))
                        sb.Append(Me.CharRight)
                    Case Else
                        sb.Append(Me.CharLeft)
                        sb.Append(New String(" "c, Math.Max((Me.Width - 2), 1)))
                        sb.Append(Me.CharRight)
                End Select
                sb.AppendLine()
            Next row
            Return sb.ToString()

        End If

    End Function

#End Region

#Region " Operators "

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Performs an implicit conversion from <see cref="ConsoleRectangle"/> to <see cref="Rectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' The source <see cref="ConsoleRectangle"/>.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' The resulting <see cref="Rectangle"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Widening Operator CType(ByVal rect As ConsoleRectangle) As Rectangle
        Return New Rectangle(rect.Location, rect.Size)
    End Operator

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Performs an implicit conversion from <see cref="Rectangle"/> to <see cref="ConsoleRectangle"/>.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' The source <see cref="Rectangle"/>.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' The resulting <see cref="ConsoleRectangle"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Widening Operator CType(rect As Rectangle) As ConsoleRectangle
        Return New ConsoleRectangle(rect)
    End Operator

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Tests whether two <see cref="Rectangle"/> and <see cref="ConsoleRectangle"/> structures have equal location and size.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' The <see cref="Rectangle"/> to compare with the <see cref="ConsoleRectangle"/> structure.
    ''' </param>
    '''
    ''' <param name="consoleRect">
    ''' The <see cref="ConsoleRectangle"/> to compare with the <see cref="Rectangle"/> structure.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' <see langword="True"/> if the two <see cref="Rectangle"/> and <see cref="ConsoleRectangle"/> structures have equal location and size;
    ''' otherwise, <see langword="False"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Operator =(rect As Rectangle, consoleRect As ConsoleRectangle) As Boolean
        Return (rect.Location = consoleRect.Location) AndAlso (rect.Size = consoleRect.Size)
    End Operator

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Determine whether two <see cref="Rectangle"/> and <see cref="ConsoleRectangle"/> structures differ in location or size.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="rect">
    ''' The <see cref="Rectangle"/> to compare with the <see cref="ConsoleRectangle"/> structure.
    ''' </param>
    '''
    ''' <param name="consoleRect">
    ''' The <see cref="ConsoleRectangle"/> to compare with the <see cref="Rectangle"/> structure.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' <see langword="True"/> if the two <see cref="Rectangle"/> and <see cref="ConsoleRectangle"/> structures differ in location or size;
    ''' otherwise, <see langword="False"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Operator <>(rect As Rectangle, consoleRect As ConsoleRectangle) As Boolean
        Return Not (rect = consoleRect)
    End Operator

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Tests whether two <see cref="ConsoleRectangle"/> structures have equal location, size and characters.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="left">
    ''' The <see cref="ConsoleRectangle"/> structure that is to the left of the equality operator.
    ''' </param>
    '''
    ''' <param name="right">
    ''' The <see cref="ConsoleRectangle"/> structure that is to the right of the equality operator.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' <see langword="True"/> if the two <see cref="ConsoleRectangle"/> structures have equal location, size and characters;
    ''' otherwise, <see langword="False"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Operator =(left As ConsoleRectangle, right As ConsoleRectangle) As Boolean
        Return (left.Location = right.Location) AndAlso
               (left.Size = right.Size) AndAlso
               (left.CharLeft = right.CharLeft) AndAlso
               (left.CharTop = right.CharTop) AndAlso
               (left.CharRight = right.CharRight) AndAlso
               (left.CharBottom = right.CharBottom)
    End Operator

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Tests whether two <see cref="ConsoleRectangle"/> structures differ in location, size or characters.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="left">
    ''' The <see cref="ConsoleRectangle"/> structure that is to the left of the equality operator.
    ''' </param>
    '''
    ''' <param name="right">
    ''' The <see cref="ConsoleRectangle"/> structure that is to the right of the equality operator.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <returns>
    ''' <see langword="True"/> if if any of the two <see cref="ConsoleRectangle"/> structures differ in location, size or characters;
    ''' otherwise, <see langword="False"/>.
    ''' </returns>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Public Shared Operator <>(left As ConsoleRectangle, right As ConsoleRectangle) As Boolean
        Return Not (left = right)
    End Operator

#End Region

#Region " Private Methods "

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Updates the location value specified in <see cref="ConsoleRectangle.Location"/> property.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="newLocation">
    ''' The new location.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <exception cref="ArgumentException">
    ''' Positive value is required for coordinate.
    ''' </exception>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Private Sub UpdateLocation(ByVal newLocation As Point)
        If (Me.location_ = newLocation) Then
            Exit Sub
        End If

        If (newLocation.X < 0) Then
            Throw New ArgumentException(paramName:=NameOf(newLocation),
                                        message:=String.Format("Positive value is required for '{0}' coordinate.", NameOf(newLocation.X)))

        ElseIf (newLocation.Y < 0) Then
            Throw New ArgumentException(paramName:=NameOf(newLocation),
                                        message:=String.Format("Positive value is required for '{0}' coordinate.", NameOf(newLocation.Y)))

        End If

        Me.location_ = newLocation
    End Sub

    ''' ----------------------------------------------------------------------------------------------------
    ''' <summary>
    ''' Updates the size value specified in <see cref="ConsoleRectangle.Size"/> property.
    ''' </summary>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <param name="newSize">
    ''' The new size.
    ''' </param>
    ''' ----------------------------------------------------------------------------------------------------
    ''' <exception cref="ArgumentException">
    ''' Value greather than zero is required.
    ''' </exception>
    ''' ----------------------------------------------------------------------------------------------------
    <DebuggerStepThrough>
    Private Sub UpdateSize(ByVal newSize As Size)
        If (Me.size_ = newSize) Then
            Exit Sub
        End If

        If (newSize.Width <= 0) Then
            Throw New ArgumentException(paramName:=NameOf(Size),
                                        message:=String.Format("Value greather than zero is required for '{0}'", NameOf(newSize.Width)))

        ElseIf (newSize.Height <= 0) Then
            Throw New ArgumentException(paramName:=NameOf(Size),
                                        message:=String.Format("Value greather than zero is required for '{0}'", NameOf(newSize.Height)))

        End If

        Me.size_ = newSize
    End Sub

#End Region

End Structure

Ejemplo de uso:
Código:
Public Module Module1

    Public Sub Main()
        Dim rc1Pos As New Point(2, Console.CursorTop + 2)
        Dim rc1 As New ConsoleRectangle(rc1Pos, New Size(32, 4), "▌"c, "▀"c, "▐"c, "▄"c)
        rc1.Write()

        Dim rc2Pos As New Point(2, Console.CursorTop + 2)
        Dim rc2 As New ConsoleRectangle(rc2Pos, New Size(32, 4), "X"c, "X"c, "X"c, "X"c)
        rc2.Write()

        Dim rc3Pos As New Point(2, Console.CursorTop + 2)
        Dim rc3 As New ConsoleRectangle(rc3Pos, New Size(11, 5), "▌"c, "▀"c, "▐"c, "▄"c)
        rc3.Write()

        Dim rc4Pos As New Point(rc3Pos.X + (rc3.Width \ 2), rc3Pos.Y + +(rc3.Height \ 2))
        Dim rc4 As New ConsoleRectangle(rc4Pos, rc3.Size, "X"c, "X"c, "X"c, "X"c)
        rc4.Write()

        Console.SetCursorPosition(rc1.X + 9, rc1.Y)
        Console.Write(" Hello World ")
        Console.SetCursorPosition(rc1.X + 6, rc1.Y + 2)
        Console.Write(" By ElektroStudios ")

        Console.CursorVisible = False
        Console.ReadKey(intercept:=True)
    End Sub

End Module
« Última modificación: 3 Marzo 2019, 01:17 por Eleкtro » En línea


**Aincrad**


Desconectado Desconectado

Mensajes: 492



Ver Perfil
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #543 en: 11 Mayo 2019, 00:51 »

VM Detector class

Una Pequeña class que codee para detectar la ejecución en maquinas virtuales.


 

Link (Actualizado) : AntiVM Class



Como usar ?

Agregar 1 Timer

Código
  1. Public ProtectVM As AntiVM = New AntiVM
  2.  
  3.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  4.        ProtectVM.VM_Start()
  5.        Anti_VM_Timer.Enabled = True
  6.    End Sub
  7.  
  8.    Private Sub Anti_VM_Timer_Tick(sender As Object, e As EventArgs) Handles Anti_VM_Timer.Tick
  9.        Dim Detection As Boolean = ProtectVM.IsVirtualMachinePresent
  10.        Dim Description As String = ProtectVM.DescriptcionVM
  11.  
  12.        If Detection = True Then
  13.           msgbox("VM detectada : " & Description)
  14.        End If
  15.  
  16.    End Sub
  17.  
« Última modificación: 11 Agosto 2019, 02:33 por **Aincrad** » En línea


**Aincrad**


Desconectado Desconectado

Mensajes: 492



Ver Perfil
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #544 en: 26 Marzo 2020, 18:54 »


Listar los Modulos de un Proceso. (Incluyendo su MainModule)

Código
  1. Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As UInt32, ByVal bInheritHandle As Int32, ByVal dwProcessId As UInt32) As IntPtr
  2.  
  3.        Public Shared Function GetProcessModules(ByVal Process_Name As String) As String
  4.            Dim DataS As New StringBuilder
  5.            Dim pc As Process() = Process.GetProcessesByName(Process_Name)
  6.  
  7.            Dim hndProc As IntPtr = OpenProcess(&H2 Or &H8 Or &H10 Or &H20 Or &H400, 1, CUInt(pc(0).Id))
  8.            If hndProc = IntPtr.Zero Then
  9.                Return "Error"
  10.            End If
  11.  
  12.            Dim ModulesCount As Integer = pc(0).Modules.Count - 1
  13.            For index As Integer = 0 To ModulesCount
  14.                DataS.Append(pc(0).Modules(index).FileName & vbNewLine)
  15.            Next
  16.  
  17.            Return DataS.ToString
  18.        End Function

Modo de Empleo :

Código
  1. TextBox1.Text = GetProcessModules("ProcessName")


En línea


**Aincrad**


Desconectado Desconectado

Mensajes: 492



Ver Perfil
[VB] DLL Injector Class
« Respuesta #545 en: 26 Marzo 2020, 19:00 »

Mi Vieja Clase para Injectar DLLs .



DestroyerInjector.vb

Código
  1. 'Hack Trainer | Private SDK
  2. 'Made by Destroyer | Discord : Destroyer#3527
  3. 'Creation date : 4/02/2017
  4. 'Last Update : 26/06/2019  - Minimal Update
  5.  
  6. Namespace DestroyerSDK
  7.  
  8.    Public Class Injector
  9.  
  10. #Region " Declare's "
  11.  
  12.        Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As UInt32, ByVal bInheritHandle As Int32, ByVal dwProcessId As UInt32) As IntPtr
  13.        Declare Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As Int32
  14.        Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, ByVal buffer As Byte(), ByVal size As UInt32, ByRef lpNumberOfBytesWritten As IntPtr) As Boolean
  15.        Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As IntPtr, ByVal methodName As String) As IntPtr
  16.        Declare Function GetModuleHandleA Lib "kernel32" (ByVal moduleName As String) As IntPtr
  17.        Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As IntPtr, ByVal flAllocationType As UInteger, ByVal flProtect As UInteger) As IntPtr
  18.        Declare Function CreateRemoteThread Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpThreadAttribute As IntPtr, ByVal dwStackSize As IntPtr, ByVal lpStartAddress As IntPtr, ByVal lpParameter As IntPtr, ByVal dwCreationFlags As UInteger, ByVal lpThreadId As IntPtr) As IntPtr
  19.        Declare Function GetPrivateProfileStringA Lib "kernel32" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As System.Text.StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  20.        Declare Function WritePrivateProfileStringA Lib "kernel32" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
  21.  
  22. #End Region
  23.  
  24. #Region " Method's "
  25.  
  26.        Private Shared Function CreateRemoteThread(ByVal procToBeInjected As Process, ByVal sDllPath As String) As Boolean
  27.            Dim lpLLAddress As IntPtr = IntPtr.Zero
  28.            Dim hndProc As IntPtr = OpenProcess(&H2 Or &H8 Or &H10 Or &H20 Or &H400, 1, CUInt(procToBeInjected.Id))
  29.            If hndProc = IntPtr.Zero Then
  30.                Return False
  31.            End If
  32.            lpLLAddress = GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA")
  33.            If lpLLAddress = CType(0, IntPtr) Then
  34.                Return False
  35.            End If
  36.            Dim lpAddress As IntPtr = VirtualAllocEx(hndProc, CType(Nothing, IntPtr), CType(sDllPath.Length, IntPtr), CUInt(&H1000) Or CUInt(&H2000), CUInt(&H40))
  37.            If lpAddress = CType(0, IntPtr) Then
  38.                Return False
  39.            End If
  40.            Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(sDllPath)
  41.            Dim ipTmp As IntPtr = IntPtr.Zero
  42.            WriteProcessMemory(hndProc, lpAddress, bytes, CUInt(bytes.Length), ipTmp)
  43.            If ipTmp = IntPtr.Zero Then
  44.                Return False
  45.            End If
  46.            Dim ipThread As IntPtr = CreateRemoteThread(hndProc, CType(Nothing, IntPtr), IntPtr.Zero, lpLLAddress, lpAddress, 0, CType(Nothing, IntPtr))
  47.            If ipThread = IntPtr.Zero Then
  48.                Return False
  49.            End If
  50.            Return True
  51.        End Function
  52.  
  53.        Public Shared Function InjectDLL(ByVal ProcessName As String, ByVal sDllPath As String) As Boolean
  54.            Dim p As Process() = Process.GetProcessesByName(ProcessName)
  55.            If p.Length <> 0 Then
  56.                If Not CreateRemoteThread(p(0), sDllPath) Then
  57.                    If p(0).MainWindowHandle <> CType(0, IntPtr) Then
  58.                        CloseHandle(p(0).MainWindowHandle)
  59.                    End If
  60.                    Return False
  61.                End If
  62.                Return True
  63.            End If
  64.            Return False
  65.        End Function
  66.  
  67. #End Region
  68.  
  69.    End Class
  70.  
  71. End Namespace
  72.  
  73.  


Modo de uso :


Código
  1.  Dim InjectDll As Boolean = InjectDLL("ProcessGame", "DLL_Path")





« Última modificación: 26 Marzo 2020, 19:25 por **Aincrad** » En línea


**Aincrad**


Desconectado Desconectado

Mensajes: 492



Ver Perfil
Re: [VB] Adf.ly Clicker
« Respuesta #546 en: 26 Marzo 2020, 19:22 »

Un Control Recién salido del Horno , Literalmente lo hice ayer.

Adf.ly Clicker


Tal como dice el titulo, Con ella puedes generas visitas a tu Link Adf.ly ..


Código
  1. ---------------------------------------Parchado
  2.  
Bueno Fue bueno mientras duro. pero ya fue Parchado el code. osea que ia no sirve, y no voy a actualizar.




« Última modificación: 12 Abril 2020, 18:47 por **Aincrad** » En línea


**Aincrad**


Desconectado Desconectado

Mensajes: 492



Ver Perfil
Re: WinMauseHelpersCore | Algunas funciones utiles para Cheats....
« Respuesta #547 en: 10 Julio 2020, 22:34 »

Bueno Comparto algunas funciones útiles por si creas algún Cheat en vb.net . las necesitaras.

Características :

  • GetCursorPosition ' De tipo Point , Devuelve la Posicion del Puntero del mause en el Escritorio
  • GetClientPosition  ' De tipo Point , Devuelve la Posicion de Alguna venta en el Escritorio [Juego / Applicacion]
  • GetClientCursorPosition ' De tipo Point , Devuelve la Posicion del Puntero del mause desde el Cliente  [Juego / Applicacion]
  • ShowCursor ' De tipo Bool , Muestra o Oculta el Cursor del mause
  • GetProcessHandle ' De tipo IntPtr , Obtienes el Handle de algun Proceso, By Elektro

Class WinMauseHelpersCore

Código
  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class WinMauseHelpersCore
  4.  
  5.  
  6. #Region " Pinvoke "
  7.  
  8.    <DllImport("user32.dll")> _
  9.    Private Shared Function GetCursorPos(<[In](), Out()> ByRef pt As System.Drawing.Point) As Boolean
  10.    End Function
  11.    <DllImport("user32.dll", SetLastError:=True)> _
  12.    Private Shared Function ScreenToClient(ByVal hWnd As IntPtr, ByRef lpPoint As System.Drawing.Point) As Boolean
  13.    End Function
  14.    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
  15.    Private Shared Function GetClientRect(ByVal hWnd As System.IntPtr, ByRef lpRECT As RECT) As Integer
  16.    End Function
  17.    <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
  18.    Public Shared Function ShowCursor(ByVal bShow As Boolean) As Integer
  19.    End Function
  20.  
  21. #Region " Structures "
  22.  
  23.    <StructLayout(LayoutKind.Sequential)> _
  24.    Public Structure RECT
  25.        Private _Left As Integer, _Top As Integer, _Right As Integer, _Bottom As Integer
  26.  
  27.        Public Sub New(ByVal Rectangle As Rectangle)
  28.            Me.New(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom)
  29.        End Sub
  30.        Public Sub New(ByVal Left As Integer, ByVal Top As Integer, ByVal Right As Integer, ByVal Bottom As Integer)
  31.            _Left = Left
  32.            _Top = Top
  33.            _Right = Right
  34.            _Bottom = Bottom
  35.        End Sub
  36.  
  37.        Public Property X As Integer
  38.            Get
  39.                Return _Left
  40.            End Get
  41.            Set(ByVal value As Integer)
  42.                _Right = _Right - _Left + value
  43.                _Left = value
  44.            End Set
  45.        End Property
  46.        Public Property Y As Integer
  47.            Get
  48.                Return _Top
  49.            End Get
  50.            Set(ByVal value As Integer)
  51.                _Bottom = _Bottom - _Top + value
  52.                _Top = value
  53.            End Set
  54.        End Property
  55.        Public Property Left As Integer
  56.            Get
  57.                Return _Left
  58.            End Get
  59.            Set(ByVal value As Integer)
  60.                _Left = value
  61.            End Set
  62.        End Property
  63.        Public Property Top As Integer
  64.            Get
  65.                Return _Top
  66.            End Get
  67.            Set(ByVal value As Integer)
  68.                _Top = value
  69.            End Set
  70.        End Property
  71.        Public Property Right As Integer
  72.            Get
  73.                Return _Right
  74.            End Get
  75.            Set(ByVal value As Integer)
  76.                _Right = value
  77.            End Set
  78.        End Property
  79.        Public Property Bottom As Integer
  80.            Get
  81.                Return _Bottom
  82.            End Get
  83.            Set(ByVal value As Integer)
  84.                _Bottom = value
  85.            End Set
  86.        End Property
  87.        Public Property Height() As Integer
  88.            Get
  89.                Return _Bottom - _Top
  90.            End Get
  91.            Set(ByVal value As Integer)
  92.                _Bottom = value + _Top
  93.            End Set
  94.        End Property
  95.        Public Property Width() As Integer
  96.            Get
  97.                Return _Right - _Left
  98.            End Get
  99.            Set(ByVal value As Integer)
  100.                _Right = value + _Left
  101.            End Set
  102.        End Property
  103.        Public Property Location() As Point
  104.            Get
  105.                Return New Point(Left, Top)
  106.            End Get
  107.            Set(ByVal value As Point)
  108.                _Right = _Right - _Left + value.X
  109.                _Bottom = _Bottom - _Top + value.Y
  110.                _Left = value.X
  111.                _Top = value.Y
  112.            End Set
  113.        End Property
  114.        Public Property Size() As Size
  115.            Get
  116.                Return New Size(Width, Height)
  117.            End Get
  118.            Set(ByVal value As Size)
  119.                _Right = value.Width + _Left
  120.                _Bottom = value.Height + _Top
  121.            End Set
  122.        End Property
  123.  
  124.        Public Shared Widening Operator CType(ByVal Rectangle As RECT) As Rectangle
  125.            Return New Rectangle(Rectangle.Left, Rectangle.Top, Rectangle.Width, Rectangle.Height)
  126.        End Operator
  127.        Public Shared Widening Operator CType(ByVal Rectangle As Rectangle) As RECT
  128.            Return New RECT(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom)
  129.        End Operator
  130.        Public Shared Operator =(ByVal Rectangle1 As RECT, ByVal Rectangle2 As RECT) As Boolean
  131.            Return Rectangle1.Equals(Rectangle2)
  132.        End Operator
  133.        Public Shared Operator <>(ByVal Rectangle1 As RECT, ByVal Rectangle2 As RECT) As Boolean
  134.            Return Not Rectangle1.Equals(Rectangle2)
  135.        End Operator
  136.  
  137.        Public Overrides Function ToString() As String
  138.            Return "{Left: " & _Left & "; " & "Top: " & _Top & "; Right: " & _Right & "; Bottom: " & _Bottom & "}"
  139.        End Function
  140.  
  141.        Public Overloads Function Equals(ByVal Rectangle As RECT) As Boolean
  142.            Return Rectangle.Left = _Left AndAlso Rectangle.Top = _Top AndAlso Rectangle.Right = _Right AndAlso Rectangle.Bottom = _Bottom
  143.        End Function
  144.        Public Overloads Overrides Function Equals(ByVal [Object] As Object) As Boolean
  145.            If TypeOf [Object] Is RECT Then
  146.                Return Equals(DirectCast([Object], RECT))
  147.            ElseIf TypeOf [Object] Is Rectangle Then
  148.                Return Equals(New RECT(DirectCast([Object], Rectangle)))
  149.            End If
  150.  
  151.            Return False
  152.        End Function
  153.    End Structure
  154.  
  155. #End Region
  156.  
  157.    Public Function GetCursorPosition() As System.Drawing.Point
  158.        Dim CursorPos As New System.Drawing.Point
  159.        GetCursorPos(CursorPos)
  160.        Return CursorPos
  161.    End Function
  162.  
  163.    Public Function GetClientPosition(ByVal hWnd As IntPtr) As System.Drawing.Point
  164.        Dim ClientPos As New System.Drawing.Point
  165.        ScreenToClient(hWnd, ClientPos)
  166.        Return ClientPos
  167.    End Function
  168.  
  169.    Public Function GetClientCursorPosition(ByVal hWnd As IntPtr) As System.Drawing.Point
  170.        Dim ClientCursorPos As New System.Drawing.Point
  171.        Dim CursorPos As System.Drawing.Point = GetCursorPosition()
  172.        Dim ClientPos As System.Drawing.Point = GetClientPosition(hWnd)
  173.        ClientCursorPos = New System.Drawing.Point(CursorPos.X + ClientPos.X, CursorPos.Y + ClientPos.Y)
  174.        Return ClientCursorPos
  175.    End Function
  176.  
  177.    Public Function GetProcessHandle(ByVal ProcessName As String) As IntPtr
  178.        If ProcessName.ToLower.EndsWith(".exe") Then ProcessName = ProcessName.Substring(0, ProcessName.Length - 4)
  179.        Dim ProcessArray = Process.GetProcessesByName(ProcessName)
  180.        If ProcessArray.Length = 0 Then Return Nothing Else Return ProcessArray(0).MainWindowHandle
  181.    End Function
  182.  
  183. #End Region
  184.  
  185. End Class
  186.  

« Última modificación: 10 Julio 2020, 22:36 por **Aincrad** » En línea


Páginas: 1 ... 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [55] Ir Arriba Respuesta Imprimir 

Ir a:  

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