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

 

 


Tema destacado: Introducción a Git (Primera Parte)


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

Mensajes: 9.874



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

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.874



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

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 pm por Eleкtro (aliviado) » En línea



Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.874



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

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 am por Eleкtro » En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



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

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 am por **Aincrad** » En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



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


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: 682



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

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 pm por **Aincrad** » En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



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

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 pm por **Aincrad** » En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



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

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 pm por **Aincrad** » En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



Ver Perfil WWW
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #548 en: 9 Junio 2021, 01:19 am »

Defender Watcher

Monitoriza la desactivacion em tiempo real del Windows Defender.

( click en la imagen para ir código fuente en Github)




Codigo Fuente

DefenderWatcher.vb

Código
  1. ' ***********************************************************************
  2. ' Author   : Destroyer
  3. ' Modified : 8-June-2021
  4. ' Github   : https://github.com/DestroyerDarkNess
  5. ' Twitter  : https://twitter.com/Destroy06933000
  6. ' ***********************************************************************
  7. ' <copyright file="DefenderWatcher.vb" company="S4Lsalsoft">
  8. '     Copyright (c) S4Lsalsoft. All rights reserved.
  9. ' </copyright>
  10. ' ***********************************************************************
  11.  
  12. #Region " Usage Examples "
  13.  
  14. ' ''' <summary>
  15. ' ''' The DefenderWatcher instance to monitor Windows Defender Realtime Status Changed.
  16. ' ''' </summary>
  17. 'Friend WithEvents DefenderMon As New DefenderWatcher
  18.  
  19. ' ''' ----------------------------------------------------------------------------------------------------
  20. ' ''' <summary>
  21. ' ''' Handles the <see cref="DefenderWatcher.DefenderStatusChanged"/> event of the <see cref="DefenderMon"/> instance.
  22. ' ''' </summary>
  23. ' ''' ----------------------------------------------------------------------------------------------------
  24. ' ''' <param name="sender">
  25. ' ''' The source of the event.
  26. ' ''' </param>
  27. ' '''
  28. ' ''' <param name="e">
  29. ' ''' The <see cref="DefenderWatcher.DefenderStatusChangedEventArgs"/> instance containing the event data.
  30. ' ''' </param>
  31. ' ''' ----------------------------------------------------------------------------------------------------
  32. 'Private Sub DefenderMon_DefenderStatusChanged(ByVal sender As Object, ByVal e As DefenderWatcher.DefenderStatusChangedEventArgs) Handles DefenderMon.DefenderStatusChanged
  33. '    Dim sb As New System.Text.StringBuilder
  34. '    sb.AppendLine(" Defender Configuration change -  Windows Defender RealtimeMonitoring")
  35. '    sb.AppendLine(String.Format("DisableRealtimeMonitoring......: {0}", e.TargetInstance.ToString))
  36. '    sb.AppendLine(String.Format("Old Value......................: {0}", e.PreviousInstance.ToString))
  37. '    Me.BeginInvoke(Sub()
  38. '                       TextBox1.Text += (sb.ToString) & Environment.NewLine & Environment.NewLine
  39. '                   End Sub)
  40. 'End Sub
  41.  
  42. #End Region
  43.  
  44. #Region " Imports "
  45.  
  46. Imports System.ComponentModel
  47. Imports System.Management
  48. Imports System.Windows.Forms
  49.  
  50. #End Region
  51.  
  52. Namespace Core.Engine.Watcher
  53.  
  54.    Public Class DefenderWatcher : Inherits NativeWindow : Implements IDisposable
  55.  
  56. #Region " Constructor "
  57.  
  58.        ''' ----------------------------------------------------------------------------------------------------
  59.        ''' <summary>
  60.        ''' Initializes a new instance of <see cref="DefenderWatcher"/> class.
  61.        ''' </summary>
  62.        ''' ----------------------------------------------------------------------------------------------------
  63.        <DebuggerStepThrough>
  64.        Public Sub New()
  65.  
  66.            Me.events = New EventHandlerList
  67.  
  68.        End Sub
  69.  
  70. #End Region
  71.  
  72. #Region " Properties "
  73.  
  74.        ''' ----------------------------------------------------------------------------------------------------
  75.        ''' <summary>
  76.        ''' Gets a value that determines whether the monitor is running.
  77.        ''' </summary>
  78.        ''' ----------------------------------------------------------------------------------------------------
  79.        Public ReadOnly Property IsRunning As Boolean
  80.            <DebuggerStepThrough>
  81.            Get
  82.                Return Me.isRunningB
  83.            End Get
  84.        End Property
  85.        Private isRunningB As Boolean
  86.  
  87. #End Region
  88.  
  89.        Private Scope As New ManagementScope("root\Microsoft\Windows\Defender")
  90.        Private WithEvents DefenderState As ManagementEventWatcher = New ManagementEventWatcher(Scope, New WqlEventQuery("SELECT * FROM __InstanceModificationEvent WITHIN 5 WHERE TargetInstance ISA 'MSFT_MpPreference' AND TargetInstance.DisableRealtimeMonitoring=True"))
  91.  
  92. #Region " Events "
  93.  
  94.  
  95.        ''' ----------------------------------------------------------------------------------------------------
  96.        ''' <summary>
  97.        ''' A list of event delegates.
  98.        ''' </summary>
  99.        ''' ----------------------------------------------------------------------------------------------------
  100.        Private ReadOnly events As EventHandlerList
  101.  
  102.        Public Custom Event DefenderStatusChanged As EventHandler(Of DefenderStatusChangedEventArgs)
  103.  
  104.            <DebuggerNonUserCode>
  105.            <DebuggerStepThrough>
  106.            AddHandler(ByVal value As EventHandler(Of DefenderStatusChangedEventArgs))
  107.                Me.events.AddHandler("DefenderStatusChangedEvent", value)
  108.            End AddHandler
  109.  
  110.            <DebuggerNonUserCode>
  111.            <DebuggerStepThrough>
  112.            RemoveHandler(ByVal value As EventHandler(Of DefenderStatusChangedEventArgs))
  113.                Me.events.RemoveHandler("DefenderStatusChangedEvent", value)
  114.            End RemoveHandler
  115.  
  116.            <DebuggerNonUserCode>
  117.            <DebuggerStepThrough>
  118.            RaiseEvent(ByVal sender As Object, ByVal e As DefenderStatusChangedEventArgs)
  119.                Dim handler As EventHandler(Of DefenderStatusChangedEventArgs) =
  120.                    DirectCast(Me.events("DefenderStatusChangedEvent"), EventHandler(Of DefenderStatusChangedEventArgs))
  121.  
  122.                If (handler IsNot Nothing) Then
  123.                    handler.Invoke(sender, e)
  124.                End If
  125.            End RaiseEvent
  126.  
  127.        End Event
  128.  
  129. #End Region
  130.  
  131.        '   Dim oInterfaceType As String = TIBase?.Properties("DisableRealtimeMonitoring")?.Value.ToString() ' Prevent Defender Disable
  132.  
  133.        Public Sub DefenderState_EventArrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs) Handles DefenderState.EventArrived
  134.            Dim DefenderTargetInstance As Boolean = Nothing
  135.            Dim DefenderPreviousInstance As Boolean = Nothing
  136.  
  137.            Using TIBase = CType(e.NewEvent.Properties("TargetInstance").Value, ManagementBaseObject)
  138.                DefenderTargetInstance = CBool(TIBase.Properties("DisableRealtimeMonitoring").Value)
  139.            End Using
  140.  
  141.            Using PIBase = CType(e.NewEvent.Properties("PreviousInstance").Value, ManagementBaseObject)
  142.                DefenderPreviousInstance = CBool(PIBase.Properties("DisableRealtimeMonitoring").Value)
  143.            End Using
  144.  
  145.            Me.OnDefenderStatusChanged(New DefenderStatusChangedEventArgs(DefenderTargetInstance, DefenderPreviousInstance))
  146.  
  147.        End Sub
  148.  
  149. #Region " Event Invocators "
  150.  
  151.        <DebuggerStepThrough>
  152.        Protected Overridable Sub OnDefenderStatusChanged(ByVal e As DefenderStatusChangedEventArgs)
  153.  
  154.            RaiseEvent DefenderStatusChanged(Me, e)
  155.  
  156.        End Sub
  157.  
  158. #End Region
  159.  
  160. #Region " Events Data "
  161.  
  162.        Public NotInheritable Class DefenderStatusChangedEventArgs : Inherits EventArgs
  163.  
  164. #Region " Properties "
  165.  
  166.            Private ReadOnly TargetInstanceB As Boolean
  167.            Public ReadOnly Property TargetInstance As Boolean
  168.                <DebuggerStepThrough>
  169.                Get
  170.                    Return Me.TargetInstanceB
  171.                End Get
  172.            End Property
  173.  
  174.            Private ReadOnly PreviousInstanceB As Boolean
  175.            Public ReadOnly Property PreviousInstance As Boolean
  176.                <DebuggerStepThrough>
  177.                Get
  178.                    Return Me.PreviousInstanceB
  179.                End Get
  180.            End Property
  181.  
  182. #End Region
  183.  
  184. #Region " Constructors "
  185.  
  186.            <DebuggerNonUserCode>
  187.            Private Sub New()
  188.            End Sub
  189.  
  190.            <DebuggerStepThrough>
  191.            Public Sub New(ByVal TI As Boolean, ByVal PI As Boolean)
  192.  
  193.                Me.TargetInstanceB = TI
  194.                Me.PreviousInstanceB = PI
  195.  
  196.            End Sub
  197.  
  198. #End Region
  199.  
  200.        End Class
  201.  
  202. #End Region
  203.  
  204. #Region " Public Methods "
  205.  
  206.        ''' ----------------------------------------------------------------------------------------------------
  207.        ''' <summary>
  208.        ''' Starts monitoring.
  209.        ''' </summary>
  210.        ''' ----------------------------------------------------------------------------------------------------
  211.        ''' <exception cref="Exception">
  212.        ''' Monitor is already running.
  213.        ''' </exception>
  214.        ''' ----------------------------------------------------------------------------------------------------
  215.        <DebuggerStepThrough>
  216.        Public Overridable Sub Start()
  217.  
  218.            If (Me.Handle = IntPtr.Zero) Then
  219.                MyBase.CreateHandle(New CreateParams)
  220.                DefenderState.Start()
  221.                 Me.isRunningB = True
  222.  
  223.            Else
  224.                Throw New Exception(message:="Monitor is already running.")
  225.  
  226.            End If
  227.  
  228.        End Sub
  229.  
  230.        ''' ----------------------------------------------------------------------------------------------------
  231.        ''' <summary>
  232.        ''' Stops monitoring.
  233.        ''' </summary>
  234.        ''' ----------------------------------------------------------------------------------------------------
  235.        ''' <exception cref="Exception">
  236.        ''' Monitor is already stopped.
  237.        ''' </exception>
  238.        ''' ----------------------------------------------------------------------------------------------------
  239.        <DebuggerStepThrough>
  240.        Public Overridable Sub [Stop]()
  241.  
  242.            If (Me.Handle <> IntPtr.Zero) Then
  243.                DefenderState.Stop()
  244.                MyBase.DestroyHandle()
  245.                Me.isRunningB = False
  246.  
  247.            Else
  248.                Throw New Exception(message:="Monitor is already stopped.")
  249.  
  250.            End If
  251.  
  252.        End Sub
  253.  
  254. #End Region
  255.  
  256. #Region " IDisposable Implementation "
  257.  
  258.        ''' ----------------------------------------------------------------------------------------------------
  259.        ''' <summary>
  260.        ''' To detect redundant calls when disposing.
  261.        ''' </summary>
  262.        ''' ----------------------------------------------------------------------------------------------------
  263.        Private isDisposed As Boolean
  264.  
  265.        ''' ----------------------------------------------------------------------------------------------------
  266.        ''' <summary>
  267.        ''' Releases all the resources used by this instance.
  268.        ''' </summary>
  269.        ''' ----------------------------------------------------------------------------------------------------
  270.        <DebuggerStepThrough>
  271.        Public Sub Dispose() Implements IDisposable.Dispose
  272.  
  273.            Me.Dispose(isDisposing:=True)
  274.            GC.SuppressFinalize(obj:=Me)
  275.  
  276.        End Sub
  277.  
  278.        ''' ----------------------------------------------------------------------------------------------------
  279.        ''' <summary>
  280.        ''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  281.        ''' Releases unmanaged and - optionally - managed resources.
  282.        ''' </summary>
  283.        ''' ----------------------------------------------------------------------------------------------------
  284.        ''' <param name="isDisposing">
  285.        ''' <see langword="True"/>  to release both managed and unmanaged resources;
  286.        ''' <see langword="False"/> to release only unmanaged resources.
  287.        ''' </param>
  288.        ''' ----------------------------------------------------------------------------------------------------
  289.        <DebuggerStepThrough>
  290.        Protected Overridable Sub Dispose(ByVal isDisposing As Boolean)
  291.  
  292.            If (Not Me.isDisposed) AndAlso (isDisposing) Then
  293.  
  294.                Me.events.Dispose()
  295.                Me.Stop()
  296.  
  297.            End If
  298.  
  299.            Me.isDisposed = True
  300.  
  301.        End Sub
  302.  
  303. #End Region
  304.  
  305.    End Class
  306.  
  307. End Namespace
  308.  
  309.  



En línea



**Aincrad**


Desconectado Desconectado

Mensajes: 682



Ver Perfil WWW
Re: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
« Respuesta #549 en: 29 Enero 2023, 21:10 pm »


FastArgumentParser

Parsea Argumentos de manera rapida y sencilla.

( click en la imagen para ir código fuente en Github)




Codigo Fuente

FastArgumentParser.vb

Código
  1. ' ***********************************************************************
  2. ' Author   : Destroyer
  3. ' Github   : https://github.com/DestroyerDarkNess
  4. ' Modified : 26-1-2023
  5. ' ***********************************************************************
  6. ' <copyright file="FastArgumentParser.vb" company="S4lsalsoft">
  7. '     Copyright (c) S4lsalsoft. All rights reserved.
  8. ' </copyright>
  9. ' ***********************************************************************
  10.  
  11. #Region " Usage Examples "
  12.  
  13. ''Commandline Arguments
  14. '' This contains the following:
  15. '' -file "d3d9.h" -silent 0x146 H&146
  16. 'Dim CommandLineArgs As String() = Environment.GetCommandLineArgs
  17.  
  18. 'Dim FastArgumentParser As Core.FastArgumentParser = New Core.FastArgumentParser()
  19.  
  20. '' Optional Config
  21. '' FastArgumentParser.ArgumentDelimiter = "-"
  22.  
  23. '' Set your Arguments
  24. 'Dim FileA As IArgument = FastArgumentParser.Add("file").SetDescription("file name")
  25. 'Dim SilentA As IArgument = FastArgumentParser.Add("silent").SetDescription("start silent")
  26.  
  27. '' Parse Arguments
  28. 'FastArgumentParser.Parse(CommandLineArgs)
  29. '' Or
  30. '' FastArgumentParser.Parse(CommandLineArgs, " ") ' To config Parameters Delimiter
  31.  
  32.  
  33. '' Get Arguments Values
  34. 'Console.WriteLine("Argument " & FileA.Name & " Value is: " & FileA.Value)
  35. 'Console.WriteLine("Argument " & SilentA.Name & " Value is: " & SilentA.Value)
  36.  
  37. #End Region
  38.  
  39. #Region " Imports "
  40.  
  41. Imports System.Collections.Specialized
  42.  
  43. #End Region
  44.  
  45. Namespace Core
  46.  
  47.    Public Class FastArgumentParser
  48.  
  49.        Private Property ArgumentList As List(Of IArgument)
  50.        Public Property ArgumentDelimiter As String = "-"
  51.  
  52.        Private UnknownArgs As New List(Of IArgument)
  53.        Public ReadOnly Property UnknownArguments As List(Of IArgument)
  54.            Get
  55.                Return UnknownArgs
  56.            End Get
  57.        End Property
  58.  
  59.        Public ReadOnly Property Count As Integer
  60.            Get
  61.                Return ArgumentList.Count()
  62.            End Get
  63.        End Property
  64.  
  65.        Public Sub New()
  66.            ArgumentList = New List(Of IArgument)
  67.        End Sub
  68.  
  69.        Public Function Add(ByVal name As String) As IArgument
  70.            If name.StartsWith(ArgumentDelimiter) = False Then name = ArgumentDelimiter & name
  71.            Dim ArgHandler As IArgument = New IArgument() With {.Name = name}
  72.            ArgumentList.Add(ArgHandler)
  73.            Return ArgHandler
  74.        End Function
  75.  
  76.        Public Sub Parse(ByVal args As String(), Optional ByVal ParameterDelimiter As String = " ")
  77.            Dim argCol As StringCollection = New StringCollection()
  78.            argCol.AddRange(args)
  79.  
  80.            Dim strEnum As StringEnumerator = argCol.GetEnumerator()
  81.  
  82.            Dim CountRequiredArg As Integer = 0
  83.  
  84.            Dim LastArg As IArgument = Nothing
  85.  
  86.            While strEnum.MoveNext()
  87.  
  88.                If strEnum.Current.StartsWith(ArgumentDelimiter) Then
  89.                    Dim GetArg As IArgument = GetArgCommand(strEnum.Current)
  90.                    LastArg = GetArg
  91.  
  92.                    If GetArg Is Nothing Then
  93.                        Dim UnknownA As IArgument = New IArgument With {.Name = strEnum.Current}
  94.                        UnknownArgs.Add(UnknownA)
  95.                    End If
  96.  
  97.                Else
  98.                    If LastArg IsNot Nothing Then
  99.                        If Not LastArg.Value = String.Empty Then LastArg.Value += ParameterDelimiter
  100.                        LastArg.Value += strEnum.Current
  101.                        Continue While
  102.                    End If
  103.                End If
  104.  
  105.            End While
  106.  
  107.        End Sub
  108.  
  109.        Private Function GetArgCommand(ByVal NameEx As String) As IArgument
  110.            For Each item In ArgumentList
  111.                If NameEx.Equals(item.Name) Then Return item
  112.            Next
  113.            Return Nothing
  114.        End Function
  115.  
  116.  
  117.    End Class
  118.  
  119.    Public Class IArgument
  120.        Public Property Name As String = String.Empty
  121.        Public Property Description As String = String.Empty
  122.        Public Property Value As String = String.Empty
  123.  
  124.        Public Function SetDescription(ByVal _text As String) As IArgument
  125.            Me.Description = _text
  126.            Return Me
  127.        End Function
  128.    End Class
  129.  
  130. End Namespace
  131.  
  132.  

Ejemplo de Uso:

Código
  1. 'Commandline Arguments
  2.        ' This contains the following:
  3.        ' -file "d3d9.h" -silent 0x146 H&146
  4.        Dim CommandLineArgs As String() = Environment.GetCommandLineArgs
  5.  
  6.        Dim FastArgumentParser As Core.FastArgumentParser = New Core.FastArgumentParser()
  7.  
  8.        ' Optional Config
  9.        ' FastArgumentParser.ArgumentDelimiter = "-"
  10.  
  11.        ' Set your Arguments
  12.        Dim FileA As IArgument = FastArgumentParser.Add("file").SetDescription("file name")
  13.        Dim SilentA As IArgument = FastArgumentParser.Add("silent").SetDescription("start silent")
  14.  
  15.        ' Parse Arguments
  16.        FastArgumentParser.Parse(CommandLineArgs)
  17.        ' Or
  18.        ' FastArgumentParser.Parse(CommandLineArgs, " ") ' To config Parameters Delimiter
  19.  
  20.  
  21.        ' Get Arguments Values
  22.        Console.WriteLine("Argument " & FileA.Name & " Value is: " & FileA.Value)
  23.        Console.WriteLine("Argument " & SilentA.Name & " Value is: " & SilentA.Value)
  24.  
En línea



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

Ir a:  

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