Posts

Showing posts with the label WPF
Share:

DependencyProperty C# | WPF | Saatody | Amit Padhiyar

All property added. private static object DefaultValue = null; private static FrameworkPropertyMetadataOptions Flags = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault; private static PropertyChangedCallback PropertyChangedCallback = OnPropertyChanged; private static CoerceValueCallback CoerceValueCallback = OnCoerceValue; private static bool IsAnimationProhibited = false; private static UpdateSourceTrigger Trigger = UpdateSourceTrigger.PropertyChanged; private static FrameworkPropertyMetadata PropertyMetadata = new FrameworkPropertyMetadata(DefaultValue, Flags, PropertyChangedCallback, CoerceValueCallback, IsAnimationProhibited, Trigger); private static string Name = "XYZ"; private static Type PropertyType = typeof(object); private static Type OwnerType = typeof(object); private static FrameworkPropertyMetadata FrameworkPropertyMetadata = PropertyMetadata; private static ValidateValueCallback ValidateValueCallback = OnValidateValue; public static readonly DependencyPro

Example of ColorPicker and ColorPalette

Here is the example. XAML (.xaml) <gui:ColorPicker x:Name="ColorPicker"/> <gui:ColorPalette x:Name="ColorPalette"/> C# (.cs) private bool IsLockedPickerAndPalette = false; private void Event() { this.Loaded += (sender, e) => { ColorPalette.ImportColorPalette(); }; ColorPicker.SelectedColorChanged += (sender, e) => { if (IsLockedPickerAndPalette == false) { IsLockedPickerAndPalette = true; ColorPalette.CurrentColor = ColorPicker.SelectedColor; IsLockedPickerAndPalette = false; } }; ColorPalette.CurrentColorChanged += (sender, e) => { if (IsLockedPickerAndPalette == false) { IsLockedPickerAndPalette = true; ColorPicker.SelectedColor = ColorPalette.CurrentColor; IsLockedPickerAndPalette = false; } }; this.Closing += (sender, e) => { ColorPalette.ExportColorPalette();

ColorPicker API | WPF | C# | Saatody | Amit Padhiyar

This is color picker widget fully created in WPF C#. Here is the full API of ColorPicker widget. ColorPicker Class API Properties Syntax public Color SelectedColor Constructors This is one and default constructor. Syntax public ColorPicker() Events Syntax public event EventHandler SelectedColorChanged; ColorPickerTabItem Class API Properties Syntax public Color SelectedColor Constructors This is one and default constructor. Syntax public ColorPickerTabItem() Events Syntax public event EventHandler SelectedColorChanged; StandardColorsTabItem Class API Properties Syntax public Color SelectedColor Constructors This is one and default constructor. Syntax public StandardColorsTabItem() Events Syntax public event EventHandler SelectedColorChanged; Point7ColorPicker Class API Properties Syntax public double SelectedOffset Constructors This is one and default constructor. Syntax public Point7ColorPicker() Events Syntax public event EventHandler SelectedOffsetChanged; Point4ColorPicker Class AP

ProcessBox API | WPF | C# | Saatody | Amit Padhiyar

ProcessBox Class API Small widget which show current process with responsive UI.  Constructure  This is one and default constructor. Syntax public ProcessBox() Properties Syntax public ProcessBoxTypes Type public string Description public ProcessBoxOptions Option Methods Syntax public void SetCurrentProcess(string Status) public void SetCurrentProcess(string Status, int Percentage) public static void Show(ProcessBox ProcessBox) public static void Close(ProcessBox ProcessBox) PredictableProcessUI Class API Constructure  This is one and default constructor. Syntax public PredictableProcessUI() Properties Syntax public int Process Methods Syntax public async Task LoadUI() public async Task UnloadUI() UnpredictableProcessUI Class API Constructure  This is one and default constructor. Syntax public UnpredictableProcessUI() Methods Syntax public async Task LoadUI() public async Task UnloadUI() ProcessBoxTypes Enum API ProcessBoxOptions Enum API Example GUI.ProcessBox ProcessBox = new GUI.Pro

All widgets | WPF | C# | Saatody | Amit Padhiyar

 All widgets with API. DialogBox MessageBox ProcessBox NSSlider SelectionTool ColorPicker ColorPalette ColorEffect EffectPalette

MessageBox API | WPF | C# | Saatody | Amit Padhiyar

MessageBox Class API Standard message box for normal, error, warning, and success types with some options OK, OKCancel, YesNo, YesNoCancel and some results None, Ok, Yes, No, Cancel.  Constructure  This is one and default constructor. Syntax public MessageBox() Properties Syntax public MessageBoxTypes Type {set; get;} public string Description {set; get;} public string Code {set; get;} public MessageBoxOptions Option {set; get;} public MessageBoxResults Result {set; get;} Methods System public static MessageBoxResults Show(MessageBox MessageBox) public static MessageBoxResults Show(Window Owner, string Title, MessageBoxTypes Type, string Description, string Code, MessageBoxOptions Option) public static MessageBoxResults Show(Window Owner, MessageModel Model, MessageBoxOptions Option) MessageBoxOptions enum API MessageBoxResults enum API MessageBoxTypes enum API MessageModel Class API Properties Syntax public string Title = null; public MessageTypes Type = MessageTypes.Normal; public st

DialogBox API | WPF | C# | Saatody | Amit Padhiyar

DialogBox Class API DialogBox API is providing small widget to create custom dialog box. Constructure  This is one and default constructor.  Syntax public DialogBox() Show (DialogBox DialogBox) Methods Show dialog box by calling this method. Syntax public static void Show(DialogBox DialogBox) Close (DialogBox DialogBox) Methods Close dialog box by calling this method.  Syntax public static void Close(DialogBox DialogBox) Example XAML <gui:DialogBox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Custom Box" Width="800" Height="700"> <Grid> </Grid> </gui:DialogBox>  C# using GUI = Example.Commons.GUI; namespace Example { public partial class CustomBox : GUI.DialogBox { public CustomBox() { InitializeComponent(); this.Closing += (sender, e) => {

SelectionTool in C# | WPF | Saatody | Amit Padhiyar

SelectionTool is used for array group selection like select odd values or select even values from particular numbers range. This also select groups like 2, 3, 4, 1 etc... SelectionTool Class API SelectionTool class is main class of SelectionTool. This class provides rich options to select all, deselect all, select left half, select right half, select left half from already selected values, select right half from already selected values. Add custom group selection using 'Add' button. Properties Here in SelectionTool class has only two properties. The 'Range' used to define 'from value' to 'to value'. The 'SelectedRange' gives list of selected values from 'Range' value. Syntax public Range Range public List<int> SelectedRange Constructors This is one and default constructor. Syntax public SelectionTool() Events Here only one event 'SelectedRangeChanged' which fire when selected range changed from any source. For examples: Sele

NSSlider in C# | WPF | Saatody | Amit Padhiyar

NSSlider is WPF slider's alternative. Here NS means N-North and S-South. So, NSSlider is vertical slider in WPF. In this post, I will show reference API of this UI. NSSlider Class API NSSlider has one class and this is main class. NSSlider provides Minimum, Maximum, Change, Format, Value and Caption properties with one event which is ValueChanged event. Properties Here basic commons properties with syntax is below. Syntax public decimal Minimum public decimal Maximum public decimal Change public string Format public decimal Value public string Caption  Constructors This is one and default constructor. Syntax public NSSlider() Events Here is only an event ValueChanged. This event fire when Value property value being changed. Syntax public event EventHandler ValueChanged;  Example Of NSSlider <gui:NSSlider x:Name="NS1" Minimum="-50" Maximum="20" Change="0.1" Format="00.00$" Value="5" Caption="Demo"/> NS1.

Color Palette In C# | WPF | Saatody | Amit Padhiyar

There are three class(es) in color palette tool. 1] ColorPalette, 2] ColorCell, 3] AddColorCell. Today, I will write reference and example about color palette. This tool is available for private use only. And the API is written in WPF C#. 1] ColorPalette Class API This is a main class of my color palette tool. This class provides functionalities for set current color, add new cell, remove exist cell, and remove all exist cells. Also has an event fire while current color change. We also set functionalities of importing and exporting ColorPalette. Properties This property stores color and also fire an event CurrentColorChanged. Syntax public Color CurrentColor Constructors This is one and default constructor. Syntax public ColorPalette() Methods These methods are used for adding and removing ColorCell from the ColorPalette. Also used for importing and exporting ColorPalette. Syntax public void AddColorCell(ColorCell ColorCell) public void RemoveColorCell(ColorCell ColorCell) public void

Async Task In C# | Async And Await Keywords | Saatody | Amit Padhiyar

Today we will discuss about async and await keyword. And will know some examples about Task. private async void MyTask() { await Task.Run(() => { // Code Here }); } Avoid use of void. use Task or Task<return_type>. private async Task MyTask() { await Task.Run(() => { // Code Here }); } It can use for non return value. private async Task<int> MyTask() { await Task.Run(() => { // Code Here }); return int; } Returns int values.

Number Validation In TextBox WPF | C# | Amit Padhiyar | Saatody

I will create number validation in TextBox. This algorithm only allow numbers while user press any key. TB.PreviewTextInput += (sender, e) => { if (e.Text != "0" && e.Text != "1" && e.Text != "2" && e.Text != "3" && e.Text != "4" && e.Text != "5" && e.Text != "6" && e.Text != "7" && e.Text != "8" && e.Text != "9") { e.Handled = true; } }; Here is little demo on PreviewTextInput. I am researching on validations for TextBox. In future, I will create more detail about it.

Millions Of Objects Performance In C# WPF | Amit Padhiyar | Saatody

This is little experiment about memory management and time management in WPF while we create millions of objects in small amount of time. Let's see first example while we create one simple class with no properties (empty class). Before we start, we must define some properties in MainWindow. private readonly int TotalObjects = 10000000; private int i = 0; private List<PointClass> Objs = new List<PointClass>(); private Stopwatch Timer = new Stopwatch(); private TimeSpan TS = new TimeSpan(); TotalObjects is variable. And this number used in loop for repeating same process. It means we will create PointClass's object in each cycle and store in Objs List<>. The 'i' is index for loop. Using Stopwatch we will calculate the time and store elapsed time in TimeSpan TS. This experiment uses two loop; 1] for loop and 2] while loop. public class PointClass { } First create empty class. This class hasn't any property. See the below example to see How much time

Create Custom Shaped Window C# WPF | Saatody | Amit Padhiyar

First we need to set some properties for window. The property WindowStyle will be None. Property AllowsTransparency will be true. WindowStartupLocation property will be CenterScreen. And The Background will be Transparent. Now you need to use Clip property for window reshape. <Window x:Class="Saatody.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Saatody" Title="MainWindow" Height="500" Width="500" WindowStyle="None" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Background="Transparent"> <Window.Clip> <PathGeometry>

Get Color From Pixel C# WPF | Saatody | Amit Padhiyar

Image
Today I will show you, How to get pixel color from particular UIElement. Here we need two main class(es). RenderTargetBitmap and CroppedBitmap. MainWindow.xaml <Window x:Class="Pixel.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Pixel" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="300"/> <RowDefinition Height="30"/> <RowDefinition Height="30"/> </Grid.RowDefinitions> <Border Name="Pi

Create Sinewave Using C# | Saatody | Amit Padhiyar

Image
Welcome again, Today I will create sinewave on slider using C# WPF. Here I need to use Math.sin(angle). First I want to show using little demo of sinewave. This is example of sinewave. Here sin() function always give output between -1 to 1 range. The x-axis is known as frequency(time) and the y-axis known as amplitude. Here The angles 0, 180 and 360 gives output 0. But angle 90 gives +1 value while angle 270 gives -1 value in output. We can manipulate range instead of -1 to 1. For example: 0 to 255 or -255 to 255. Let's start coding with two different scenarios. First we need to make common structure using C#. First create slider using WPF XAML. <Slider Name="Slider" Value="0" Minimum="-2" Maximum="2" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Center"/> <Label Name="Value" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/> Now create

DevExpress WPF GridControl | Q&A | Saatody | Amit Padhiyar

 How to hide group panel from table view of GridControl? You can hide group panel (filter panel or filter search panel) using ShowGroupPanel property. Set the value ShowGroupPanel = false will hide group panel from table view of GridControl. ShowGroupPanel = false How to add dynamic columns in GridControl? You can add, remove and clear columns using Grid.Columns. For adding new column, You should use Grid,Columns.Add(new GridColumn()). For better understanding you can see the below first example: Grid.Columns.Add(new GridColumn { FieldName = "Name", Visible = true }); Grid.Columns.Add(new GridColumn { FieldName = "Mobile", Visible = false }); Grid.Columns.Add(new GridColumn { FieldName = "Email", Visible = false }); Grid.Columns.Add(new GridColumn { FieldName = "Address", Visible = false }); Grid.Columns.Add(new GridColumn { FieldName = "Company", Visible = false }); Now if you want remove particular column then you should use Grid.Colu

Example Of UndoRedoManager V1_0_0 WPF C#

According to my  previous post , today I will give you an example of UndoRedoManager API. In this post, I created little WPF form. You can follow code from MainWindow.xaml And MainWindow.xaml.cs. MainWindow.xaml In MainWindow.xaml, I designed simple form that you can see in example. Here is Canvas2D which contain a rectangle with some default style (color, size, transformation). Where at right side of the canvas, I created some textbox(es) and label(s) as propeties for rectangle manupulation. These properties are... X Y Width Height Rotation Fill R (Red) Fill G (Green) Fill B (Blue) Fill A (Alpha OR Transparent OR Opacity) Stroke R (Red) Stroke G (Green) Stroke B (Blue) Stroke A (Alpha OR Transparent OR Opacity) Stroke Width (Thickness) <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Saatody" x:Class="Saatody.MainWindow"