Posts

Share:

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

Download Image From HTML Canvas | Saatody | Amit Padhiyar

Image
Today, The HTML canvas is very useful element for all developers who are creating web games, web controls, and web tools. In this post, I will explain about small use (but very important) of HTML Canvas is Convert HTML canvas (2d shapes and image) to image format and save image output in your device (local memory / hard drive / memory card). See the below three images All images file name is below with its URL. Picture1.png: https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge9MKEaMz95QfnJ9V8_dB0keUqzrRONXVhNMf0Jjd70JCR2y9yD9Y7xhszimwpCjFCjysS3aulEdqXfC7INlU7qxi9B_PYoJ_Qrpf7NWyNtE8sRmjyNI4qoiLlVrQOvKIIxbjAuhx3nom7/s764/Picture1.png Picture2.png:  https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSVJGrvKBqVHFYd0XF6F8qZ-q8upO19r0ApVMTe_A4b6HlD7KAjP2ivvNSzbQbs-oues6kTNaSjphuRYdewEnY20s1QDYRLuf2akkg4p3d2ahYUX8zrBp5EjeyAlyjPdveXVKDMRwtkYX6/s683/Picture2.png Picture3.png:  https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5uvMT6462oSgXFOA6yRA6zXR-iB79VOI...

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

Create UndoRedoManager V1_0_0 For WPF C#

 In post, I will talk about undo and redo manager (UndoRedoManager.cs) for C# (WPF and WindowsForm both). It's works properly in WPF but, I can't take responsibility for WindowsForm. Because this functionality tested in WPF only. So, This is version V1_0_0 and the below is code of UndoRedoManager.cs. using System; using System.Collections.Generic; using System.IO; using System.Windows.Markup; using System.Xml; namespace Saatody { public class UndoRedoManager { public MainWindow Window { set; get; } private int Pointer = 0; private List<string> States = new List<string>(); public void RecordState(object State) { try { States.RemoveRange(Pointer + 1, States.Count - (Pointer + 1)); } catch(Exception Ex) { } States.Add(XamlWriter.Save(State)); Pointer = States.Count - 1; Window.Console.Text = "Record State (" ...

Create AutoScroll V1_0_0 for WPF C# | Saatody | Amit Padhiyar

 Today, I will discuss about AutoScroll algorithm. This is version V1_0_0 of AutoScroll algorithm. First see the algorithm's API. Then we will discuss about connectivity of this API with your program. namespace Saatody.Core.UI { public class AutoScroll { private enum ValueTypes { Increment, Decrement } private enum SpeedLevels { None, Normal, Medium, Extreme } public double None { set; get; } public double Normal { set; get; } public double Medium { set; get; } public double Extreme { set; get; } public double NormalDistance { set; get; } public double MediumDistance { set; get; } public double ExtremeDistance { set; get; } public double Mouse { set; get; } public double Point1 { set; get; } public double Point2 { set; get; } public double Speed ...

Custom Event In C# WPF | Saatody | Amit Padhiyar

 Today I will talk about... How to create custom event in C# WPF. First, We need a class which can contains our properties and events. private double x = 0.0; public double X { set { x = value; OnValueChanged(EventArgs.Empty); } get { return x; } } Here, We have a property in A class. Where OnValueChanged() is protected event method within A class. Follow below code. public EventHandler ValueChanged; protected virtual void OnValueChanged(EventArgs e) { EventHandler handler = ValueChanged; if (handler != null) { handler(this, e); } } Now we invented new event which name is ValueChanged. You can use this event as normal event in other class(es). For example B class. Follow below code. BClass.ValueChanged += (sender, e) => { System.Console.WriteLine("X: " + BClass.X); }; This how we created ValueChanged custom event in C# WPF. Note: Always use 'event' keyword before EventHandler. This how com...