Wednesday, June 27, 2018

sql server Row number / Zeilen nummer

select ROW_NUMBER() OVER (ORDER by ColumnDefinition) as rownumber, *
 from sb.RowDefinition  order by ColumnDefinition

Tuesday, June 26, 2018

posh-git power shell erweiterung

auf github posh-git repro runterladen:
git clone https://github.com/dahlbyk/posh-git.git

Power shell Profile Script anlegen wenn noch nicht vorhanden (autoexec):
New-Item -ItemType File -Path $Profile -Force

%HOMEPATH%/Documents/WindowsPowerShell\Microsoft.PowerShell_profile (z.b. C:\Users\xxx\Documents\WindowsPowerShell )

im profile hinzufügen:

$installDir = "D:\github\posh-git"
Import-Module $installDir\src\posh-git.psd1
Add-PoshGitToProfile -WhatIf:$WhatIf -Force:$Force -Verbose:$Verbose

Friday, June 22, 2018

xaml basics (Binding ...)

Element.Eigenschaftsschreibweise

normalerweise werden Attribute (Eigenschaften) als String angegebeen:
<Button Width="100" Background="blue"> (parser creiert Button und setzt dessen Background Eigenschaft vom Typ Brush auf einen Solid...Brush den er aus einem StringToColorConverter erzeugt)

<Button Width="100">
<Button.Background>
<LinearGradientBrush>
<GradientStop Color="RoyalBlue" Offset="0.0" />
<GradientStop Color="White" Offset="1.0" />
</LinearGradientBrush>
</Button.Background>
</Button>

Markup Erweiterungen

system.Windows.Data.Binding, StaticResource, DynamicResource x

Binding:

Quellen: DataContext, Source, RelativSource, Elementname

Default mäßig genügt es eine Eigenschaft des Datacontextes anzugeben (und damit aufs Viewmodel=Datacontext zu binden, dieses wird solange im Baum aufwärts gesucht bis irgendein DataContext gefunden wird):

{Binding MyDatacontextProperty}

 - es ist aber auch möglich auf Eigenschaften von GUI Elemente zu binden mittels der Eigenschaft Elementname:
Text="{Binding MyText, ElementName=MyUserControl}"

<Binding Path ="Foreground" RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType=UserControl}"/>

Parent: {RelativeSource AncestorType=ContentControl}

multiBinding:



                            <TextBlock.Foreground>
                                <MultiBinding Converter="{StaticResource ColorStringToBrush}">
                                    <Binding Path="FgColor" />
                                    <Binding Path ="Foreground, Elementname=Root"/>
                                </MultiBinding>
                            </TextBlock.Foreground>


Default Brushes:


_textbox.SystemColors.WindowTextBrush

_textbox.Background = SystemColors.WindowBrush;

c# if (x is Brush brush)

type abfrage gleich in variable

Thursday, June 21, 2018

Wpf Converter with DependendyProperty



    public class ColorStringToBrushConverter : DependencyObject, IValueConverter
    {
        public static readonly DependencyProperty DefaultBrush_PROPERTY = DependencyProperty.Register("DefaultBrush", typeof(Brush), typeof(ColorStringToBrushConverter));

        public Brush DefaultBrush
        {
            get => (Brush)GetValue(DefaultBrush_PROPERTY);
            set => SetValue(DefaultBrush_PROPERTY, value);
        }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            var brush = DefaultBrush;
            string colorString = value as string;

            if (string.IsNullOrEmpty(colorString)) //use parameter if value not set
                colorString = parameter as string;

            if (!string.IsNullOrEmpty(colorString))
            {
                var colorObject = ColorConverter.ConvertFromString(colorString);
                if (null != colorObject)
                {
                    var color = (Color)colorObject;
                    brush = new SolidColorBrush(color);
                }

            }

            return brush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Tuesday, June 19, 2018

linux hibernate / Ruhezustand

systemctl suspend
sudo pm-suspend

.net colors

            var c1 = System.Drawing.Color.Aqua;
            var c2 = SystemColors.ActiveBorderBrush;
            var c3 = System.Windows.Media.Color.FromRgb(3, 0, 0);

in Wpf gibts vordefinierte Brushes:
System.Windows.Media.Brushes ... eine Liste von SolidColorBrushes

Monday, June 18, 2018

BIOS / Bootmenu

Marke: BIOS / Bootmenu:

Lenovo: F1 / F12

Thursday, June 07, 2018

android debug bridge adb, shell basics Samsung



adb reboot bootloader

adb installieren und starten

entweder android Studio oder sdk installieren, adb.exe ist in
C:\Program Files (x86)\Android\android-sdk\platform-tools

adb befehle

adb devices //listet alle verbundenen geräte auf
adb shell //linux shell auf android gerät aufmachen

Adb Shell

partitionen

cat /proc/partitions
df

Wednesday, June 06, 2018

power shell parameter example cmdlet

<#

    .SYNOPSIS

    Upload a ConfigFile over Default Configuration

 



    .DESCRIPTION

    Uploads File with given Path over Default Configuration (is overwritten !!!)

    of a Database (default Db) of a sql SERVERINSTANCE (default localhost\sqlexpress)



    .EXAMPLE

        .\UploadConfigFile.ps1 D:\temp\Configuration.

            uploads the file Configuration. over the Default Configuration

    .EXAMPLE

        .\UploadConfigFile.ps1 D:\temp\Configuration. -ServerInstance myserver -Database db1

            uploads the file Configuration. over the Default Configuration on Database db1 of Sql Server myserver



    .PARAMETER FilePath

        mandatory, file to be uploaded over the default  configuration

    .PARAMETER Database

        optional, name of Database (default=Db)

    .PARAMETER ServerInstance

        optional, name of Sql Server Instance (default localhost/sqlexpress)







     

#>

[CmdletBinding()]

param

(

    [Parameter(Mandatory=$true)]

    [string]$FilePath,

    [string]$Database="Db",

    [string]$ServerInstance="localhost\sqlexpress"

)



$sqlCmd="exec UpdateConfigFile '$FilePath'"

Write-Debug "invoke-SqlCmd: $sqlcmd"

Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $sqlCmd -QueryTimeout 65000

Write-Host "File uploaded over Default Configuration !"

Monday, June 04, 2018

mysql auf raspi

login von cmd:
mysql -u root -p

show databases;