Search This Blog

Mind freaker Stuff

Please Visit my new blog http://www.mindfreakerstuff.com for new articles related to web and mobile designing.

Sunday, December 11, 2011

Get Current theme Image folder ULR : WordPress



To Get Image Folder URL In WordPress
The bloginfo(‘template_directory’) function will return the current theme path. We just need to append image folder name  and Image name to it. 
<img src="<?php bloginfo('template_directory'); ?>/images/myImage.jpg" title="" alt="" />
U cab Also Get Home Page url from 
<?php echo home_url(); ?>
Cheers...

Sunday, November 27, 2011

Number (Numeric) Input Field : Flash Action Script 2

Add following code to flash Action Script will restrict user to input only Numeric Values 

textField_IntanceName.restrict = "0-9"


 following code allows A-Z except R and K:

textField_IntanceName.restrict = "A-Z^RK";


// Example 1: Allow only uppercase A-Z, spaces, and digits 0-9.
my_ti.restrict = "A-Z 0-9";


 // Example 3: Allow only digits 0-9, dash (-), ^, and \
my_ti.restrict = "0-9\\-\\^\\\\";


//Example 1: Allow only uppercase A-Z, spaces, and digits 0-9.
my_ti.restrict = "A-Z 0-9";

Vertical Text Alignment for Dynamic Text Field Flash Action script 2

This is a simple Hack for flash Dynamic Text Field  With AS2 Where  Vertical Text Align is not supported.
Instated of setting Text Vertically  align we can position Text Field vertically Center by Y axis Position  .

Steps : Add Follwing code in on layer action

//To get Empty text field height 
blank_height  = TextField_instance._height;


//Setting Text to text field 
TextField_instance.text = "This text is vertically align";

//Adding autosize to text field  
TextField_instance.autoSize = "center";


//for Vertical Alignment
TextField_instance._y = TextField_instance._y + (blank_height  -TextField_instance._height) / 2;

Thanks,
Cheers....  :)

Set Focus to Dynamic Textfeild and Tab Index in Flash Action Script 2



To Set Focus 

Selection.setFocus(textfeild_Instrance_name);

Adding Tab Index To flash Form


textfeild_Instrance_name.tabIndex = 1;
textfeild_Instrance_name2.tabIndex = 2;

Wednesday, November 23, 2011

Clear float without extra tag with CSS


CSS for all browsers  --------------------------------------------


.clearfix:before,
.clearfix:after {
  display: table;
  line-height: 0;
  content: " ";
}

.clearfix:after {
  clear: both;
}



CSS for IE 6, 7 ----------------------------------------------

 .clearfix {
    *zoom: 1;     /* triggers hasLayout */
    display: block;     /* resets display for IE/Win */
 }  

HTML (For IE 6,7)--------------------------------------------

<!--[if lte IE 7]>
<link href="css/ie.css" rel="stylesheet" type="text/css" />
<![endif]-->

Friday, November 18, 2011

Blank " href " alternative javascript code ( href=" " )

<a href="JavaScript:void(0);" onclick="alert('Well done!')">Click Me!</a> 

To avoid page refresh for blank herf="";

Friday, November 4, 2011

CSS Reset From Eric Meyer and Yahoo

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
 margin: 0;
 padding: 0;
 border: 0;
 font-size: 100%;
 font: inherit;
 vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
 display: block;
}
body {
 line-height: 1;
}
ol, ul {
 list-style: none;
}
blockquote, q {
 quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
 content: '';
 content: none;
}
table {
 border-collapse: collapse;
 border-spacing: 0;
}
 
 
CSS Reset from Yahoo

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { 
 margin:0;
 padding:0;
}
table {
 border-collapse:collapse;
 border-spacing:0;
}
fieldset,img { 
 border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
 font-style:normal;
 font-weight:normal;
}
ol,ul {
 list-style:none;
}
caption,th {
 text-align:left;
}
h1,h2,h3,h4,h5,h6 {
 font-size:100%;
 font-weight:normal;
}
q:before,q:after {
 content:'';
}
abbr,acronym { border:0;
}
  

Friday, October 21, 2011

How to get My Cart Quantity : Magento


 <?php $Mycart =Mage::getModel('checkout/cart')->getItemsQty(); ?>
   <?php if($Mycart ){  ?>

    <div > <?php echo $Mycart  ?></div>

    <?php } else { ?>

          <div > <?php echo $this->__('Cart is Empty.') ?></div>


   <?php } ?>

Monday, October 17, 2011

Creating Simple Blank Theme for Magento


1)      Create Copy of  \skin\frontend\default \  “Blank” folder and rename to your theme name “mytheme”

2)      Copy  “app\design\frontend\base\default” folder to “app\design\frontend\default\”  folder with your theme Name “mytheme”.

3)      Go to Admin Panel > System> Design > Add Design Changes > Select your theme 

Saturday, October 15, 2011

SEO "Use Web Server Rewrites" 404 Error : Magento

Admin Path:

System > Configuration > Web > Search Engines Optimization >  'Use Web Server Rewrites' > Yes

 Error: 

404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Solution : 

Magento can use more human looking and search engine friendly addresses for it's pages if you switch on 'Use Web Server Rewrites'. This relies on two things.
  1. Apache's mod_rewrite module. All our servers have this installed and enabled.
  2. A .htaccess file in the same folder as your Magento install. Magento comes with a .htaccess file for you to use that should work as is.
If you switch on 'Use Web Server Rewrites' and get 404 errors then check that the .htaccess file is installed.
Some FTP programs may not show .htaccess files or upload them without switching on an option to show 'hidden' files. On UNIX based operating systems, files beginning with a period such as .htaccess are not shown in listings with the usual ls command. You can view them on the command line with 'ls -a' to show all files.


Ref- http://aegishosting.co.uk/support/knowledgebase/7/Using-Web-Server-Rewrites.html

Wednesday, October 12, 2011

customize Email template with variable : Magento

PHP file Code

function sendTestMail($emailId,$VariableName,$name)
{
        $mailer = Mage::getModel('core/email_template_mailer');
        $emailInfo = Mage::getModel('core/email_info');
        $emailInfo->addTo($emailId, $name);
        if ($copyTo && $copyMethod == 'bcc') {
            // Add bcc to customer email
            foreach ($copyTo as $email) {
                $emailInfo->addBcc($email);
            }
        }
        $mailer->addEmailInfo($emailInfo);

        // Email copies are sent as separated emails if their copy method is 'copy'
        if ($copyTo && $copyMethod == 'copy') {
            foreach ($copyTo as $email) {
                $emailInfo = Mage::getModel('core/email_info');
                $emailInfo->addTo($email);
                $mailer->addEmailInfo($emailInfo);
            }
        }

        // Set all required params and send emails
        $mailer->setSender(Mage::getStoreConfig('sales_email/order/identity', $storeId));
        $mailer->setStoreId($storeId);
        $mailer->setTemplateId(1);   //"1" is email Template ID
        $mailer->setTemplateParams(array(
                'customer_name'        => $name,
                'VariableName'        => $VariableValue
            )
        );
      
        $mailer->send();
        return;
    }


Code Inside Email Template
Magento Admin >System >  Transnational Emails > Select Email Template > Template Content

- {{var VariableName}}

eg. <span>{{var VariableName}} </span>








Add www to your website link (Missing www in website name)


for  Linux Server Only

Open ".htaccess" fiile from root and add or modify following content

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursitename.com [NC]
RewriteRule ^(.*)$ http://www.yoursitename.com/$1 [L,R=301] 


It  will convert  http://yoursitename.com to  http://www.yoursitename.com




---- Enjoy

Monday, October 3, 2011

Remove (Did You Know Image) and PayPal logo: Magento

To Remove Did You Know Image


You will  find  Image block is being added onto your Magento install via catalog.xml
Got to
app/design/frontend/*/*/layout/catalog.xml

Commnet Flolloing Tags

<action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>




 To Remove Paypal Logo

 1. Login to your Admin Panel of your Store. Go to System -> Configuration and click on  PayPal logo from the options on the left  side.
2. Then you will get the whole settings of Paypal in your Magento Store. Click on the Tab “Front end Experience settings
3. Select “No Logo” from the drop down list of the PayPal Product Logo field.



for ref- http://haijerome.wordpress.com/2010/11/26/magento-remove-paypal-logo/



Magento : 1.4,1.5,....

Show Block on Home Page only :Mageto (Phtml File changes)

 <?php if( Mage::getSingleton('cms/page')->getIdentifier() == 'home'  && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
                            {?>  
                         <div class="static_blocks">
                                <!--Your Content Here-->
                         </div>
<?php }?>

Friday, September 30, 2011

Editing the Footer in a stock magento build

The items in the footer area are in two different locations. One part is a static block created within the magento admin area (CMS > Static Block). The other part is held in the related .phtml / .php / .xml files within the design files.
First off, the XML files

app/design/frontend/*/*/layout/page.xml
Here you will find some footer reference:
<block type="page/html_footer" name="footer" as="footer" 
template="page/html/footer.phtml">
<block type="page/switch" name="store_switcher" 
as="store_switcher" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" 
as="footer_links" template="page/template/links.phtml"/>
</block>
app/design/frontend/*/*/layout/cms.xml
<reference name="footer">
<block type="cms/block" name="cms_footer_links" before="footer_links">
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
</reference>
You can see that the footer area of each page (page.xml) adds footer links via:
app/design/frontend/*/*/template/page/html/footer.phtml
This file (footer.phtml) contains a method to get it’s children HTML as referenced in the page.xml file – ($this->getChildHtml();)
-app/design/frontend/*/*/template/page/switch.phtml
-app/design/frontend/*/*/template/page/template/links.phtml
footer.phtml is basically a “shell” which includes the “report bugs to magento” text. It also calls the getChildHtml method to get the rest in there.
One important part of the footer’s children HTML are the links:
The .phtml file , however, grabs links from the method “$this->getLinks()” found in the Block .php file controlling the template…. so the hunt begins.
The Block file controlling this template is:
app/code/core/mage/page/Template/Links.php
However, here you will find that this only has generic code for entering links! Where, then, are these links coming from? Well…a lot of places :(


<!--contacts.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="contacts" 
ifconfig="contacts/contacts/enabled"><label>Contact Us</label>
<url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
</reference>

<!--rss.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="rss" 
ifconfig="rss/config/active"><label>RSS</label><url>rss</url>
<title>RSS testing</title><prepare>true</prepare><urlParams/>
<position/><li/><a>class="link-feed"</a></action>
</reference>

<!--catalogsearch.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" 
module="catalogsearch" ifconfig="catalog/seo/search_terms">
<label>Search Terms
</label><url helper="catalogsearch/getSearchTermUrl" />
<title>Search Terms</title></action>
<action method="addLink" translate="label title" 
module="catalogsearch"><label>Advanced Search</label>
<url helper="catalogsearch/getAdvancedSearchUrl" /><
title>Advanced Search</title></action>
</reference>

<!--catalog.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="catalog" 
ifconfig="catalog/seo/site_map"><label>Site Map</label>
<url helper="catalog/map/getCategoryUrl" /><title>Site Map</title></action>
</reference>


Now, as for the other links (About Us and Customer Service) they are 
merely created in the Admin section as mentioned. Admin > CMS > 
Static Blocks.

They are referenced in cms.xml as shown above. You can use this method to
 show static blocks creating in the CMS area of the admin section anywhere (the
 much-repeated emphasis on being able to use PHP code to do the job of 
the XML (or visa versa) is handy to add a static block somewhere in your
 code instead of using xml).
 
 
 
For More Details
 
ref - 


http://www.exploremagento.com/magento /editing-the-footer-in-a-stock-magento-build.php

Magento: Add Javascript or CSS to Home Page Only (Or Any CMS Page)

CMS pages in Magento allow you to modify the layout XML specific to that page. So, all you need to do is open up the CMS page in Magento that you want to add the javascript to, click on the “Custom Design” tab on the left, and in the “Layout Update XML” field add the following:



“Custom Design” tab on the left, and in the “Layout Update XML” field add the following:
<reference name="head">
  <action method="addItem">
    <type>skin_js</type><script>yourfile.js</script>
  </action>
</reference>
 
Or, if you want to just put the javascript in the /js/ directory of your app, you can change the “skin_js” to just “js”.

Ref - http://prattski.com/2010/03/08/magento-add-javascript-to-home-page-only-or-any-cms-page/

Thursday, September 29, 2011

Alternatives to innerHTML

the focus of this article will be to show you ways of doing things commonly reserved for innerHTML with only DOM methods. In each example, the innerHTML method will be shown, followed by its DOM based alternative.

What's wrong with innerHTML?

A few things:
  • It's not a standard. It's a proprietary property that Microsoft introduced (along with the less popular outerHTML) that the other browser makers picked up.
  • Since it's not a standard, it isn't terribly future proof. It's not supposed to work under the application/xhtml+xml MIME type that XHTML documents are supposed to be served under. (Firefox 1.5 changed this by allowing it for some reason)
  • innerHTML is a string. The DOM is not a string, it's a hierarchal object structure. Shoving a string into an object is impure and similar to wrapping a spaghetti noodle around an orange and calling it lunch.
  • It makes for some nearly illegible code in a lot of instances, with escaped quotes and plus signs all over the place appending data to the string, which in my opinion makes it difficult to maintain.

Ok...anything good about it?

Sure. Don't get me wrong, I had a long and productive love affair with innerHTML, using it in everything from favelets to games.
  • It's faster than DOM methods. By a lot. [ http://www.quirksmode.org/dom/innerhtml.html ]
  • It's less verbose than DOM methods.
  • It allows you to take arbitrary chunks of markup and drop them into a document without having to parse them.
It was when my favelets stopped working for people when they were invoked on application/xhtml+xml sites that I decided to wash my hands of it (and do a lot of re-coding).

Example One

[1a] Creating an element.

This example introduces three DOM methods. The first is createElement, a method of the document object. It does exactly that - creates an element. It's argument is the name of the element you want created.
The second is the setAttribute method. This method is the equivalent of object.attributeName = "value";.
The last is the appendChild method. This method will append your newly created element to the element it is invoked on. The element will be the newest child of the parent element, and appear last in the element.
innerHTML

document.getElementById("mContainer").innerHTML = "<div id=\"myDiv\"></div>";
DOM

// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myDiv");
// append your newly created DIV element to an already existing element.
document.getElementById("mContainer").appendChild(eDIV);
	

[1b] Creating an Element with Text

In this example you'll use the createTextNode method of the document object. This method will -- you guessed it -- create a text node. It's important to note that a text node is just that: text. Any markup that you pass to createTextNode will be rendered as text, not as HTML.
innerHTML

document.getElementById("mContainer").innerHTML = "<div id=\"myDiv\">hello world</div>";
DOM

// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myDiv");
// add the text "hello world" to the div with createTextNode
eDIV.appendChild(document.createTextNode("hello world"));
// append your newly created DIV element to an already existing element.
document.getElementById("mContainer").appendChild(eDIV);
	

[1c] Creating an Element Containing Hyperlinked Text

In this example, you'll create two elements. The div element as you did before, in addition to an anchor element. You'll then append the text node ("hello world") to the anchor element rather than the div element since that's the text you want hyperlinked (the text node is a child of the anchor) and finally you'll append the anchor to the div.
innerHTML

document.getElementById("mContainer").innerHTML = "<div id=\"myDiv\"><a href=\"http://slayeroffice.com\">hello world</a></div>";
DOM

// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myDiv");
 // create your anchor element
eAnchor = document.createElement("a");
// set its href attribute with the setAttribute method
eAnchor.setAttribute("href","http://slayeroffice.com");
// add the text "hello world" to the anchor element
eAnchor.appendChild(document.createTextNode("hello world"));
 // append your newly created anchor element to the div
eDIV.appendChild(eAnchor);
// append your newly created DIV element to an already existing element.
document.getElementById("mContainer").appendChild(eDIV);
	

[1d] Creating an Element Containing Hyperlinked Text and an Event Handler

innerHTML

document.getElementById("mContainer").innerHTML = "<div id=\"myDiv\"><a href=\"http://slayeroffice.com\" onmouseover="doStuff();">hello world</a></div>";
DOM

// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myDiv");
 // create your anchor element
eAnchor = document.createElement("a");
// set its href attribute with the setAttribute method
eAnchor.setAttribute("href","http://slayeroffice.com");
// add our event handler to the anchors mouseover event
eAnchor.onmouseover = doStuff;
// add the text "hello world" to the anchor element
eAnchor.appendChild(document.createTextNode("hello world"));
 // append your newly created anchor element to the div
eDIV.appendChild(eAnchor);
// append your newly created DIV element to an already existing element.
document.getElementById("mContainer").appendChild(eDIV);
	

[1e] Creating an Element Containing Hyperlinked Text and an Event Handler that Takes an Argument

innerHTML

document.getElementById("mContainer").innerHTML = "<div id=\"myDiv\"><a href=\"http://slayeroffice.com\" onmouseover=\"doStuff('foo');\">hello world</a></div>";
DOM

// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myDiv");
 // create your anchor element
eAnchor = document.createElement("a");
// set its href attribute with the setAttribute method
eAnchor.setAttribute("href","http://slayeroffice.com");
// add our event handler to the anchors mouseover event
eAnchor.onmouseover = function() { doStuff("foo") };
// add the text "hello world" to the anchor element
eAnchor.appendChild(document.createTextNode("hello world"));
 // append your newly created anchor element to the div
eDIV.appendChild(eAnchor);
// append your newly created DIV element to an already existing element.
document.getElementById("mContainer").appendChild(eDIV);
	
Note: Simon Willison points out that the above example is a circular reference that will cause memory leaks in Internet Explorer. See this article by Mark Wubben for one solution, and be sure to unattach your event handlers when your document unloads

Wednesday, September 21, 2011

Web Safe Fonts

Serif Fonts

font-family Example text
Georgia, serif

This is a heading

This is a paragraph
"Palatino Linotype", "Book Antiqua", Palatino, serif

This is a heading

This is a paragraph
"Times New Roman", Times, serif

This is a heading

This is a paragraph

Sans-Serif Fonts

font-family Example text
Arial, Helvetica, sans-serif

This is a heading

This is a paragraph
Arial Black, Gadget, sans-serif

This is a heading

This is a paragraph
"Comic Sans MS", cursive, sans-serif

This is a heading

This is a paragraph
Impact, Charcoal, sans-serif

This is a heading

This is a paragraph
"Lucida Sans Unicode", "Lucida Grande", sans-serif

This is a heading

This is a paragraph
Tahoma, Geneva, sans-serif

This is a heading

This is a paragraph
"Trebuchet MS", Helvetica, sans-serif

This is a heading

This is a paragraph
Verdana, Geneva, sans-serif

This is a heading

This is a paragraph

Tuesday, September 20, 2011

Contentpresenter Foreground, Font-Size, Font-Family Change inside Style (WPF / XAML)

To change Font Size, Foreground or Font Family

1) Directly Assign Property to Content-presenter 
 - XAML
<ContentPresenter TextBlock.FontFamily="Tahoma"
                  TextBlock.FontWeight="Bold"
                  TextBlock.Foreground="Red"
                  VerticalAlignment="Center"
                  RecognizesAccessKey="True" />
 
  OR

2)Adding Setter To the Style-
                      <Trigger Property="IsSelected" Value="true">
     <Setter Property="TextBlock.Foreground" TargetName="TabHeadetText"     Value="white"/>
     <Setter Property="TextBlock.FontFamily" TargetName="TabHeadetText"     Value="Tahoma"/>
</Trigger>


Friday, September 16, 2011

How to Disable the default Dashed Focus Rectangle on WPF Controls

When a WPF control gains the focus, it displays a dashed box around itself to indicate that it has the focus. In some cases, the focus rectangle can detract from the design of the program.

To disable this box, add the attribute FocusVisualStyle="{x:Null}" to a control.

To re-enable it, set that attribute to a Style of your choice.
example:
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
</Style>


-------- nJoy :-)

Thursday, August 25, 2011

RotateTransform Animation with Ease wpf C#



In CS file


using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace simple_animation
{
       /// <summary>
       /// Interaction logic for MainWindow.xaml
       /// </summary>
       public partial class MainWindow : Window
       {
              public MainWindow()
              {
                     this.InitializeComponent();

                     // Insert code required on object creation below this point.
              }

              private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
              {
                     // TODO: Add event handler implementation here.
                     var ease = new PowerEase { EasingMode = EasingMode.EaseOut };

                     //DoubleAnimation(FromValue. ToValue, Duration)
                     DoubleAnimation myanimation = new DoubleAnimation
                             (0, 360, new Duration(TimeSpan.FromSeconds(3)));

                     //Adding Power ease to the animation
                     myanimation.EasingFunction = ease;
           
                     RotateTransform rt = new RotateTransform();
                                 
                     //  "img" is Image added in XAML
                     img.RenderTransform = rt;
                     img.RenderTransformOrigin = new Point(0.5, 0.5);
                     rt.BeginAnimation(RotateTransform.AngleProperty, myanimation );

              }
       }
}



XAML



<Window
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                x:Class="simple_animation.MainWindow"
                x:Name="Window"
                Title="MainWindow"
                Width="640" Height="480">

                <Grid x:Name="LayoutRoot">
                                <Image x:Name="img" Height="128" Source="sync.png" Stretch="Fill"    VerticalAlignment="Top" Margin="287,68,217,0"/>
                                <Button Content="Button" HorizontalAlignment="Left" Height="49" Margin="24,84,0,0" VerticalAlignment="Top" Width="117" Click="Button_Click"/>
                </Grid>
</Window>



===========================================================================

For animating button width Property

// Animate the Button's Width.
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 75;
            myDoubleAnimation.To = 300;
            myDoubleAnimation.Duration =  new Duration(TimeSpan.FromSeconds(5));
            myDoubleAnimation.AutoReverse = true;
            myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Apply the animation to the button's Width property.
            aButton.BeginAnimation(Button.WidthProperty, myDoubleAnimation);       

Monday, August 8, 2011

C# Find Prime Numbers from Array (Console Application)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace prime_number
{
    class findPrime
    {

        int[] num = new int[5]; /*Creating array for numbers*/
        int i, j;
        bool isprime,noprime = true;
        public findPrime()
        {
            Console.WriteLine("Please enter 5 numbers: ");
            for(i = 0; i < 5; i++)
                num[i] = Int16.Parse(Console.ReadLine());  /* add Numbers to the Array*/
          
            for(i = 0; i < 5; i++)
            {
                isprime = true; /* initialize Current number as prime Number is "true"*/
                for (j = 2; j <= (num[i] / 2); j++) 
                     /* for Diving numbers for Remainder "0" from 2 to the half of the Number*/
                {
                    if (num[i] % j == 0)
                    {
                        isprime = false
                        /*if  Remainder "0" Found set Current Number as prime is "false" and break the loop */
                        break;
                    }
                }

                if (isprime) /*if  no Remainder "0"  Display current Number as Prime Number*/
                {
                    noprime = false;
                    Console.WriteLine(num[i] + " is a Prime Number");
                }
            }
            if (noprime)
                Console.WriteLine("There is no a Prime number in  the list");
        }
    }
   
    class Program
    {
        static void Main(string[] args)
        {
            findPrime pn = new findPrime(); /* Create object of the class */
            Console.ReadLine();
        }
    }
}



Wednesday, August 3, 2011

C# (H.A.)Find Biggest number from 2d array

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
       
        static void Main(string[] args)
        {
            int[,] a = new int[3,3];
            int i, j,result = 0;
            Console.WriteLine("Please enter 9 numbers ");
            for (i=0; i < 3; i++)
            {
                for (j = 0; j < 3; j++)
                {
                    a[i,j] = Int16.Parse(Console.ReadLine());
                }
            }
            Console.WriteLine("Entered numbers");
            result = a[0, 0];
            for (i = 0; i < 3; i++)
            {
                for (j = 0; j < 3; j++)
                {
                    Console.Write(a[i, j] + " ");
                    if (a[i, j] >= result)
                    {
                        result = a[i, j];
                    }
                }
                Console.WriteLine();
            }
           Console.WriteLine(result + " is a biggest number");
           Console.ReadLine();
        }
      
    }
}