Friday, June 24, 2022

c# - How get important system informations

Sometimes you need for example width of the standard scrollbar. For getting it you can use SystemInformation class (WinForms). Here is a list of supported properties and their values.
Type t = typeof( System.Windows.Forms.SystemInformation );            
PropertyInfo[] property = t.GetProperties();

for( int i = 0; i < property.Length; i++ )
  richTextBox1.Text += property[ i ].Name + " = " + 
  property[ i ].GetValue( null, null ).ToString() + "\n";        
Output:
DragFullWindows = True
HighContrast = False
MouseWheelScrollLines = 3
PrimaryMonitorSize = {Width=1920, Height=1080}
VerticalScrollBarWidth = 17
HorizontalScrollBarHeight = 17
CaptionHeight = 23
BorderSize = {Width=1, Height=1}
FixedFrameBorderSize = {Width=3, Height=3}
VerticalScrollBarThumbHeight = 17
HorizontalScrollBarThumbWidth = 17
IconSize = {Width=32, Height=32}
CursorSize = {Width=32, Height=32}
MenuFont = [Font: Name=Segoe UI, Size=12, Units=0, GdiCharSet=1, GdiVerticalFont=False]
MenuHeight = 20
PowerStatus = System.Windows.Forms.PowerStatus
WorkingArea = {X=0,Y=0,Width=1920,Height=1080}
KanjiWindowHeight = 0
MousePresent = True
VerticalScrollBarArrowHeight = 17
HorizontalScrollBarArrowWidth = 17
DebugOS = False
MouseButtonsSwapped = False
MinimumWindowSize = {Width=136, Height=39}
CaptionButtonSize = {Width=36, Height=22}
FrameBorderSize = {Width=4, Height=4}
MinWindowTrackSize = {Width=136, Height=39}
DoubleClickSize = {Width=4, Height=4}
DoubleClickTime = 500
IconSpacingSize = {Width=75, Height=75}
RightAlignedMenus = False
PenWindows = False
DbcsEnabled = False
MouseButtons = 8
Secure = False
Border3DSize = {Width=2, Height=2}
MinimizedWindowSpacingSize = {Width=160, Height=28}
SmallIconSize = {Width=16, Height=16}
ToolWindowCaptionHeight = 23
ToolWindowCaptionButtonSize = {Width=22, Height=22}
MenuButtonSize = {Width=19, Height=19}
ArrangeStartingPosition = Hide
ArrangeDirection = Left
MinimizedWindowSize = {Width=160, Height=28}
MaxWindowTrackSize = {Width=1940, Height=1100}
PrimaryMonitorMaximizedWindowSize = {Width=1936, Height=1096}
Network = True
TerminalServerSession = False
BootMode = Normal
DragSize = {Width=4, Height=4}
ShowSounds = False
MenuCheckSize = {Width=15, Height=15}
MidEastEnabled = False
NativeMouseWheelSupport = True
MouseWheelPresent = True
VirtualScreen = {X=0,Y=0,Width=1920,Height=1080}
MonitorCount = 1
MonitorsSameDisplayFormat = True
ComputerName = WZ1G89XBX
UserDomainName = LYZ
UserInteractive = True
UserName = pirklj
IsDropShadowEnabled = True
IsFlatMenuEnabled = True
IsFontSmoothingEnabled = True
FontSmoothingContrast = 1200
FontSmoothingType = 2
IconHorizontalSpacing = 75
IconVerticalSpacing = 75
IsIconTitleWrappingEnabled = True
MenuAccessKeysUnderlined = False
KeyboardDelay = 1
IsKeyboardPreferred = False
KeyboardSpeed = 31
MouseHoverSize = {Width=4, Height=4}
MouseHoverTime = 400
MouseSpeed = 10
IsSnapToDefaultEnabled = False
PopupMenuAlignment = Right
IsMenuFadeEnabled = True
MenuShowDelay = 400
IsComboBoxAnimationEnabled = True
IsTitleBarGradientEnabled = True
IsHotTrackingEnabled = True
IsListBoxSmoothScrollingEnabled = True
IsMenuAnimationEnabled = True
IsSelectionFadeEnabled = True
IsToolTipAnimationEnabled = True
UIEffectsEnabled = True
IsActiveWindowTrackingEnabled = False
ActiveWindowTrackingDelay = 0
IsMinimizeRestoreAnimationEnabled = False
BorderMultiplierFactor = 1
CaretBlinkTime = 530
CaretWidth = 1
MouseWheelScrollDelta = 120
VerticalFocusThickness = 1
HorizontalFocusThickness = 1
VerticalResizeBorderThickness = 4
HorizontalResizeBorderThickness = 4
ScreenOrientation = Angle0
SizingBorderWidth = 1
SmallCaptionButtonSize = {Width=22, Height=22}
MenuBarButtonSize = {Width=19, Height=19}

Thursday, June 9, 2022

c# - How to format interpolated strings

This example writes double value with two decimal places.
double zoom = this.ZoomFactor * 100.0;
LStatusZoom.Text = $"Zoom: {zoom:0.##} %";
Output:
Zoom: 80.25 %

Monday, June 6, 2022

win os - How to copy all files defined by mask in all subdirectories into one directory

Copy all *.mobi files in current directory and all subdirectories into c:\temp\mobi directory. 
The destination directory must exists.
find . -name \*.mobi -exec cp {} c:/temp/mobi/ \;