Cerita Kuliah | Tanggal 01 – 11 – 2013

Diposting oleh Unknown Senin, 04 November 2013

Cerita Kuliah   |   Tanggal  01 – 11 – 2013


Pada hari ini kita akan mempelajari tentang .Net Class and Silverlight, didalam windows phone ini terdapat .Net Class Library yang dibuat oleh microsoft dalam silverlight ini sebagai framework, dalam fomat game biasanya .xne maka kita akan mengenal apa itu .Net Class and Silverlight. Dalam pertemuan kemarin kita sudah belajar bagaimana membuat class, dalam project DateTime adalah class yang sudah disediakan oleh Microsoft.


DateTime myBirthday = new Datetime(1992, 11, 28);
//datetime mybirthday  =  datetime.parse(“12/7/1990”);
Timespan myage = datetime.now.subtract (mybirthday);
//mytextblock.text  = string.format(“{0} hari”, myage.days);
//mytextblock.text = relativetimeago(myage);

Timespan postime = datetime.now.subtract (datetime.now.addminutes(-5));
String newstring = string.format(“{0}”, “hello”);
Mytextblock.text = relativetimeago(postime);
/*
Keterangan
Using system.globalization;
/*

//datetime datetimevalue = datetime.now;
//cultureinfo cultureinfo = new cultureinfo(“id-ID”);
//mytextblock.text = datetimevalue.tostring(“dddd, dd mmmm yyyy hh:mm:ss”, cultureinfo);

}
Private string relativetimeago(timespan timespan)
{
                Const int second = 1;
                                Const int minute = 60*second;
                                Const int hour = 60*minute;
                                Const int day = 24*hour;
                                Const int month = 30*day;

dari script diatas adalah sistem class yang sudah disediakan oleh microsoft windows phone

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Globalization;

namespace DateAndTime
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void ShowTime_Click(object sender, RoutedEventArgs e)
        {
            DateTime ShowTimeBt = DateTime.Now;
            //TimeTextBlock.Text = ShowTime.ToString();
            //TimeTextBlock.Text = String.Format("Date{0}, Time{1}", ShowTimeBt.ToShortDateString(), ShowTimeBt.ToShortTimeString());
            //TimeTextBlock.Text = String.Format("Date{0}, Time{1}", ShowTimeBt.ToShortDateString(), ShowTimeBt.ToShortTimeString());

            //TimeTextBlock.Text = DateTime.Now.AddDays(5).ToString();
            //TimeTextBlock.Text = DateTime.Now.AddDays(5).ToString();

            //TimeTextBlock.Text = DateTime.Now.Month.ToString();

            //CultureInfo cultureinfo = new CultureInfo("id-ID");
            //TimeTextBlock.Text = ShowTimeBt.ToString("dddd, dd MMMM yyyy hh:mm:ss", cultureinfo);

            DateTime = myBirthday = new DateTime(1993, 11, 28);
            TimeSpan timespan = DateTime.Now.Subtract(myBirthday);
            TimeTextBlock.Text = String.Format("{0} hari {1} jam {2} detik", timespan.Days, timespan.Hours, timespan.Seconds);
        }
    }
}




Kita coba melakukan beberapa percobaan:
button mynewbutton = new button();
mynewbutton.name = "newbutton";
mynewbutton.height = 100;
mynewbutton.width = 200;
mynewbutton.content = "new button";
mynewbutton.margin = new thickness(100.0, 100.0, 100.0);
mynewbutton.horizontalalignment = horizontalalignment.stretch;
mynewbutton.verticalalignment = verticalalignment.stretch;

contentgrid.children.add(mynewbutton);

textbox mytextbox = new textbox();
mytextbox.name = "newtextbox";
mytextbox.height = 72;
mytextbox.weight = 456;
mytextbox.margin = new thickness(14, 170, 0, 0);
mytextbox.textwrapping = textwrapping.wrap;
mytextbox.text = "new textbox";
mytextbox.verticalalignment = verticalalignment.top;

contentgrid.children.add(mytextbox);





<!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

<!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Time Show " Height="72" HorizontalAlignment="Left" Margin="6,6,0,0" Name="ShowTimeBt" VerticalAlignment="Top" Width="220" Click="ShowTime_Click" />
            <TextBlock Height="99" HorizontalAlignment="Left" Margin="9,84,0,0" Name="TimeTextBlock" Text="" VerticalAlignment="Top" Width="441" TextWrapping="Wrap" />
        </Grid>
    </Grid>







ini tampilannya apabila telah didebug atau dieksekusi

0 komentar

Posting Komentar