Git Product home page Git Product logo

winformps's Introduction

WinFormPS

WinFormPS is a PowerShell module to manage and interact with Windows Forms (WinForms) Controls.

If you are among those creating PowerShell Graphical User Interface using tools such as SAPIEN PowerShell Studio, you will realize that you need to dive a lot into the controls and MSDN to find the accurate methods or properties to perform the actions you want.

The goal of this module is to resolve that issue and make it simpler by using a set of functions to control WinForms Controls.

Installation

Download from PowerShell Gallery (PowerShell v5+)

Install-Module -name WinFormPS

Download from GitHub repository

  • Download the repository
  • Unblock the zip file
  • Extract the folder to a module path (e.g. $home\Documents\WindowsPowerShell\Modules)

Usage

# Import the module.
Import-Module -Name WinFormPS

# Get the commands available
Get-Command -Module WinFormPS

# Get help
Get-Help Get-WFForm
Get-Help about_WinFormPS

Help !!

Would love contributors, suggestions, feedback, and other help!

More Information

Notes

  • Thanks to the SAPIEN Inc. team (in particular David Corrales and June Blender) and their great tool PowerShell Studio! Really makes life easier to create, update and manage PowerShell scripts and UI. Some functions in this module are coming from SAPIEN's Team, you will notice in the Comment Based Help a mention for that. They were kind enought to let me use some their code. Thanks Again! You guys rock!

Examples

Set-WFDataGridView

This function allow you to perform different action against a DataGridView alt tag

winformps's People

Contributors

lazywinadmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

winformps's Issues

refact Find-DataGridViewValue()

function Find-DataGridViewValue
{ # https://github.com/lazywinadmin/WinFormPS/blob/master/WinFormPS.psm1
<#
    .SYNOPSIS
        The Find-DataGridViewValue function helps you to find a specific value and select the cell, row or to set a fore and back color.

    .DESCRIPTION
        The Find-DataGridViewValue function helps you to find a specific value and select the cell, row or to set a fore and back color.

    .PARAMETER DataGridView
        Specifies the DataGridView Control to use

    .PARAMETER RowBackColor
        Specifies the back color of the row to use

    .PARAMETER RowForeColor
        Specifies the fore color of the row to use

    .PARAMETER SelectCell
        Specifies to select only the cell when the value is found

    .PARAMETER SelectRow
        Specifies to select the entire row when the value is found

    .PARAMETER Value
        Specifies the value to search

    .EXAMPLE
        PS C:\> Find-DataGridViewValue -DataGridView $datagridview1 -Value $textbox1.Text

        This will find the value and select the cell(s)

    .EXAMPLE
        PS C:\> Find-DataGridViewValue -DataGridView $datagridview1 -Value $textbox1.Text -RowForeColor 'Red' -RowBackColor 'Black'

        This will find the value and color the fore and back of the row
    .EXAMPLE
        PS C:\> Find-DataGridViewValue -DataGridView $datagridview1 -Value $textbox1.Text -SelectRow

        This will find the value and select the entire row

    .NOTES
        Francois-Xavier Cat
        @lazywinadm
        www.lazywinadmin.com
#>
    [CmdletBinding(DefaultParameterSetName = "Cell")]
    PARAM (
        [ValidateNotNull()]
        [Parameter(Mandatory = $true)]
        [System.Windows.Forms.DataGridView]$DataGridView,
        $Value,
        [string[]]$FindingColumns,
        [Parameter(ParameterSetName = "Cell")]
        [Switch]$SelectCell,

        [Parameter(ParameterSetName = "Row")]
        [Switch]$SelectRow,

        #[Parameter(ParameterSetName = "Column")]
        #[Switch]$SelectColumn,
        [Parameter(ParameterSetName = "RowColor")]
        [system.Drawing.Color]$RowForeColor,
        [Parameter(ParameterSetName = "RowColor")]
        [system.Drawing.Color]$RowBackColor
    )

    PROCESS
    {
        $DataGridView.ClearSelection()
        ForEach ($Col in  $DataGridView.Columns) {
            if ($FindingColumns -contains $Col.Name -or !$FindingColumns) {
                ForEach ($Row in $DataGridView.Rows) {
                    $CurrentCell = $dataGridView.Rows[$Row.index].Cells[$Col.index]

                    if ((-not $CurrentCell.Value.Equals([DBNull]::Value)) -and ($CurrentCell.Value.ToString() -like "*$Value*"))
                    {
                        Append-RichtextboxStatus -ComputerName $textboxSocieteName.Text -Source "find" -Message "$($dataGridView.Rows[$Row.index])  $($CurrentCell.Value.ToString()) >> $($row.index) - $($col.index)"
                        # Row Selection
                        IF ($PSBoundParameters['SelectRow'])
                        {
                            $dataGridView.Rows[$Row.index].Selected = $true
                        }

                        # Row Fore Color
                        IF ($PSBoundParameters['RowForeColor'])
                        {
                            $dataGridView.Rows[$Row.index].DefaultCellStyle.ForeColor = $RowForeColor
                        }

                        # Row Back Color
                        IF ($PSBoundParameters['RowBackColor'])
                        {
                            $dataGridView.Rows[$Row.index].DefaultCellStyle.BackColor = $RowBackColor
                        }
                        # Cell Selection
                        ELSEIF (-not ($PSBoundParameters['SelectRow']) -and -not ($PSBoundParameters['RowForeColor']) -and -not ($PSBoundParameters['SelectColumn']))
                        {
                            $CurrentCell.Selected = $true
                        }
                    }#IF not empty and contains value
                }
            }
        }
    }#PROCESS
}#Find-DataGridViewValue

Suggestion: Examples are lacking best practices

The function help examples for the majority of the examples are really hard to follow.
The function help examples should leverage examples that the consumers can easily plug in and visualize the output without having to understand the dependencies from function to function. A good way I like to think of this is as follows. Put yourself in the shoes of someone who has never seen this before, how can they quickly figure out if this module does what they need.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.