Tuesday, August 7, 2012

Query to know identity column in your database MSSQL



Query to know identity column in your database MSSQL

select COLUMN_NAME, TABLE_NAME
from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'dbo'
and COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 order by TABLE_NAME

Wednesday, April 20, 2011

code for swap Silverlight xap in html


  <script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
        var IsLSC = true;
      // function create Object block inside Div tag
        function CreateSilverlightMenuTree(XapPath) {
            var userDetails = "";
            var objectValue = Silverlight.createObject(
                "/ClientBin/" + XapPath,  // source
               null,  // parent element
                "slPlugin",  // id for generated object element
                {
                width: "100%", height: "100%", background: "transparent", windowless: "true",
                version: "5.0.60401.0"
            }, { onError: onCustomError, onLoad: onCustomLoad },
              "userData=" + userDetails,
            "context"    // context helper for onLoad handler.
            );
            var divObj = document.getElementById("silverlightControlHost");
            divObj.innerHTML = objectValue;
        }
        function onCustomError() {
            window.status += " Error in loading window";
        }
        function onCustomLoad() {
            window.status += " Window loaded";
        }
//function  swap between two xap file dynamically 
        function SwitchXap() {
            var paramObj= "";
            if (IsLSC) {
                paramObj = "LSC.xap";
                IsLSC = false;
              }
            else {
                paramObj = "SilverlightNetwork.xap";
                IsLSC = true;
            }
            CreateSilverlightMenuTree(paramObj);
        }
    </script>

</head>
<body>
    <form id="form1" runat="server" style="height:100%">
    <input id="Button1" type="button" value="Swap" onclick="SwitchXap()" />
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
 <param id="paramXap" name="source" value="ClientBin/SilverlightNetwork.xap"/>
 <param name="onError" value="onSilverlightError" />
 <param name="background" value="white" />
 <param name="minRuntimeVersion" value="5.0.60401.0" />
 <param name="autoUpgrade" value="true" />

Wednesday, March 2, 2011

Call Scriptable Methods from JavaScript with Silverlight

Here is code snippet  to be written on html page










and here is code snippet to be written on xmal Page code behind

Thursday, December 9, 2010

Creating and merging two Images in C#

//Creating new Image
var bitmap1 = new Bitmap(1, 1);
var font = new Font("Arial", 25);
Graphics graphics = Graphics.FromImage(bitmap1);
int width1 = (int)graphics.MeasureString("hello world this is custome image", font).Width;
int height1 = (int)graphics.MeasureString("hello world this is custome image", font).Height;
bitmap1 = new Bitmap(bitmap1, new Size(width1, height1));
graphics = Graphics.FromImage(bitmap1);
graphics.Clear(Color.Gray);
graphics.DrawString("hello world this is custome image", font, new SolidBrush(Color.DarkGray), 0, 0);
graphics.Flush();

//accessing existing Image
var fileStream = new FileStream(Server.MapPath("//images//sky.jpg"), FileMode.Open);
var bytes1 = new byte[fileStream.Length];
fileStream.Read(bytes1, 0, bytes1.Length);
fileStream.Close();
var bitmap3 = new Bitmap(new MemoryStream(bytes1));

int width = bitmap3.Width;
int height = bitmap3.Height + height1;
var finalImage = new Bitmap(width, height);

//merging two images
//get a graphics object from the image so we can draw on it

var images = new List{bitmap3,bitmap1};
using (graphics = Graphics.FromImage(finalImage))
{
//set background color
graphics.Clear(Color.Transparent);

//go through each image and draw it on the final image
int offset = 0;
foreach (Bitmap image in images)
{
graphics.DrawImage(image,
new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
}
}

// save on memory
var memoryStream = new MemoryStream();
finalImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] bytes = memoryStream.ToArray();

// throwing on web
HttpContext.Current.Response.ContentType = "image/jpeg";
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End();

Wednesday, December 8, 2010

Rotate any control in silverlight

Rotate any control in silverlight

var messageTextBlock = new TextBlock
{
Text = "Messages",
Margin = new Thickness(5,20,0,0),
//FontWeight = FontWeights.Bold,
Foreground = new SolidColorBrush(Colors.White),
VerticalAlignment = VerticalAlignment.Top,
Width = 70,
Height=20,
TextWrapping = TextWrapping.Wrap,
};
RotateTransform r = new RotateTransform();
messageTextBlock.RenderTransform = r;
r.CenterX = 0;
r.CenterY = 0;
r.Angle = 90;

Tuesday, August 10, 2010

FluidMoveBehavior


Learn to create applications that change layout and visual appearance using smooth, dynamic and visually rich transitions without writing code. Come see new features in Expression Blend that raise the bar, making it even easier to create amazing applications that will delight users

Tuesday, May 18, 2010

custom drag drop in silverlight

custom drag drop in silverlight
#region custom Drag Drop

double _horizDrag = 0;
double _vertDrag = 0;
double _mouseVerticalPosition;
double _mouseHorizontalPosition;
bool _captured = false;
bool _isDragStart = false;
private void EndDragPopupMouseLeftUp()
{

_horizDrag = _vertDrag = 0;
_captured = false;
popupContent.Content = null;
popupContent.ContentTemplate = null;
//popup1.ReleaseMouseCapture();
_mouseVerticalPosition = -1;
_mouseHorizontalPosition = -1;
var ts = new ThreadStart(DragHold);
// create new thread
var thrd = new Thread(ts);
// start thread
thrd.Start();
}
public void DragHold()
{
// makes the main thread sleep - let sub thread to run
Thread.Sleep(100);
//if (!IsOver)
_isDragStart = false;
}
private void MoveDragPopupMouseMove(MouseEventArgs e)
{
if (_captured)
{

// Calculate the current position of the object.
double deltaV = e.GetPosition(null).Y - _mouseVerticalPosition;
double deltaH = e.GetPosition(null).X - _mouseHorizontalPosition;
_horizDrag += deltaH;
_vertDrag += deltaV;
double newTop = deltaV + (double)popup1.VerticalOffset;
double newLeft = deltaH + (double)popup1.HorizontalOffset;

// Set new position of object.
popup1.VerticalOffset = newTop;
popup1.HorizontalOffset = newLeft;


// Update position global variables.
_mouseVerticalPosition = e.GetPosition(null).Y;
_mouseHorizontalPosition = e.GetPosition(null).X;
var temBor = popupContent.Content as Border;
var lbl = temBor.Child as Label;
lbl.Content = "Selected to Drop (X=" + _mouseVerticalPosition + ",Y=" + _mouseHorizontalPosition + ")";
}
}
private void StartDragMouseLeftDown(MouseEventArgs e,object tag)
{
Thread.Sleep(350);

var myEffect = new DropShadowEffect
{
Color = Colors.Black,
BlurRadius = 5,
Direction = 280,
Opacity = 0.7,
ShadowDepth = 5,
};

var borde = new Border
{
BorderThickness = new Thickness(2),
BorderBrush = new SolidColorBrush(Colors.White),
Effect = myEffect,
Opacity = .7,
Tag = tag,
};
var lbl = new Label
{
Content = "Selected to Drop",
Foreground = new SolidColorBrush(Colors.Blue),
Background = new SolidColorBrush(Colors.DarkGray),
//BorderBrush = new SolidColorBrush(Colors.Orange),
BorderThickness = new Thickness(0)
};

borde.Child = lbl;
popupContent.Content = borde;
//popup1.CaptureMouse();
_captured = true;
_mouseVerticalPosition = e.GetPosition(null).Y;
_mouseHorizontalPosition = e.GetPosition(null).X;
popup1.HorizontalOffset = _mouseHorizontalPosition;
popup1.VerticalOffset = _mouseVerticalPosition;
_isDragStart = true;
}
private void GetDragDropElement()
{
if (_isDragStart)
{
MessageBox.Show("dropd on me");
_isDragStart = false;
}

}
//on .xaml file
/*
*/
#endregion