Skip to content

Instantly share code, notes, and snippets.

View sphingu's full-sized avatar
:dependabot:
Focusing

Sumit Hingu sphingu

:dependabot:
Focusing
View GitHub Profile
@sphingu
sphingu / WebBrowser.cs
Last active October 12, 2022 13:04
Using WebBrowser in WPF
----------------------------------------------------
// Using WebBrowser for Crowling in WPF
----------------------------------------------------
<WebBrowser Cursor="Arrow" Name="MyBrowser" LoadCompleted="MyBrowser_OnLoadCompleted" />
----------------------------------------------------
// useful methods of WebBrowser
----------------------------------------------------
MyBrowser.Navigate(new Uri("http://google.com"));
private void MyBrowser_OnLoadCompleted(object sender,NavigationEventArgs e)
@sphingu
sphingu / App.xaml
Last active December 18, 2015 12:10
Processbar Style in WPF
// App.xaml in Root folder of project
<Application>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ProcessStyle.xaml"/>
</ResourceDictionary.mergedDictionaries>
</ResourceDictionary>
</Application.Resources>
@sphingu
sphingu / MainWindow.xaml.cs
Last active December 18, 2015 12:10
ProcessBar use in WPF
-------------------------------------------
//How To use Processbar in WPF
-------------------------------------------
<ProgressBar Name="PbMain" Margin="3" Height="30" Width="400" />
-------------------------------------------
//Code Behind
-------------------------------------------
public partial class MainWindow
{
//Create a Delegate that matches the Signature of the ProgressBar's SetValue method
@sphingu
sphingu / DirecoryCopy.cs
Created June 14, 2013 11:53
Directory Copy in C#
/// <summary>
/// Function to copy all files from one directory to another( if destination dir not exist then create it )
/// </summary>
/// <param name="sourceDirName">path of source directory</param>
/// <param name="destDirName">path of destination directory</param>
/// <param name="copySubDirs">want to copy sub directories or not</param>
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
@sphingu
sphingu / AddTask.cs
Created June 14, 2013 11:56
Add Schedular to TaskSchedular in C#
using Microsoft.Win32.TaskScheduler;
private void AddTask()
{
// Get the service on the local machine
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Tesing Schedule";
@sphingu
sphingu / DoProcess.cs
Last active December 18, 2015 12:10
Open Folder / Start .exe With arguments
//Process For Get Backup of Your Database
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "OSQL.exe";
myProcess.StartInfo.WorkingDirectory = @"C:\";
myProcess.StartInfo.Arguments = "-Usa -PmyPasword -n -Q \"BACKUP DATABASE msdb TO DISK = > 'c:\\msdb.dat_bak'\"";
myProcess.Start()
//Open Folder
public void OpenFolder(string dir)
@sphingu
sphingu / MainWindow.xaml
Created June 14, 2013 11:58
Watermark Textbox in WPF
<Window x:Class="temp.MainWindow"
xmlns:water="clr-namespace:temp" ... >
<Grid>
<TextBox Name="txtName" >
<water:WatermarkService.Watermark>
<TextBlock Text="Enter Your Name"/>
</water:WatermarkService.Watermark>
</TextBox>
</Grid>
@sphingu
sphingu / Window.xaml
Created June 14, 2013 12:00
Style, Radio Button, DataGrid in WPF
// How to set Style to All Same Type of Controls
<Window.Resources>
//GroupBox,TextBox,Button,Grid
//Set background Black of all GroupBox in current Window
<Style TargetType="{x:Type GroupBox}">
<Setter Property="Background" Value="Black"/>
</Style>
</Window.Resources>
//Use of Radio Button
@sphingu
sphingu / BackUp_Restore.cs
Last active December 18, 2015 12:59
Generate Table Create Script Code Behind in C#
private void btnBackupWin_Click(object sender, RoutedEventArgs e)
{
try
{
if (_conSource != null && dgSource.Visibility==Visibility.Visible)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog
{
Description = @"Select Folder to store backup file : "
};
@sphingu
sphingu / NumericComparer.cs
Created June 15, 2013 07:19
Numeric Comparer for Sorting array numerically
public class NumericComparer : System.Collections.IComparer
{
public NumericComparer()
{ }
public int Compare(object x, object y)
{
if ((x is string) && (y is string))
{
return StringLogicalComparer.Compare((string)x, (string)y);