TEMEL KONTROLLER
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="100*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
<RowDefinition Height="100*"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Background="Black">
<Grid x:Name="LayoutRoot">
<TextBox Background="Red" Height="30" Name="textBox1" Width="180" Foreground="White" FontWeight="Bold" BorderThickness="3" FontFamily="Comic Sans MS" FontSize="12" />
</Grid>
</Border>
<Border Grid.Column="1" Grid.Row="0" Background="Black">
<Grid x:Name="LayoutRoot2">
<TextBox Background="Red" Height="30" Name="textBox2" Width="180" Foreground="White" FontWeight="Bold" BorderThickness="3" FontFamily="Comic Sans MS" FontSize="12" TextChanged="textBox2_TextChanged" />
</Grid>
</Border>
<Border Grid.Column="2" Grid.Row="0" Background="Black">
<Calendar Name="calendar1" DisplayDate="7/1/2013" IsTodayHighlighted="True" SelectionMode="MultipleRange" FirstDayOfWeek="Monday" SelectedDatesChanged="calendar1_SelectedDatesChanged" />
</Border>
<Border Grid.Column="0" Grid.Row="1" Background="Black">
<DatePicker HorizontalAlignment="Left" Margin="10,76,0,0" Name="datePicker1" VerticalAlignment="Top" SelectedDateFormat="Long" IsDropDownOpen="True" Width="152" SelectedDateChanged="datePicker1_SelectedDateChanged"/>
</Border>
<Border Grid.Column="1" Grid.Row="1" Background="Black">
<Slider Name="slider1" Maximum="10" Minimum="1" Width="100" Height="30" ValueChanged="slider1_ValueChanged" />
</Border>
<Border Grid.Column="2" Grid.Row="1" Background="Black">
<Button Content="TIKLA" Height="40" Name="button1" Width="100" Click="button1_Click" />
</Border>
</Grid>
KODLAR
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DateTime tarih = new DateTime();
calendar1.IsTodayHighlighted = false;
calendar1.DisplayMode = CalendarMode.Month;
calendar1.SelectionMode = CalendarSelectionMode.MultipleRange;
tarih = DateTime.Parse("5/7/2013");
calendar1.SelectedDates.Add(tarih);
tarih = DateTime.Parse("8/7/2013");
calendar1.SelectedDates.Add(tarih);
tarih = DateTime.Parse("10/7/2013");
calendar1.SelectedDates.Add(tarih);
//________________________________________________________________________________________________________
datePicker1.IsDropDownOpen = true;
datePicker1.IsTodayHighlighted = false;
CalendarDateRange aralik = new CalendarDateRange(DateTime.Parse("8/7/2013"),DateTime.Parse("15/7/2013"));
datePicker1.BlackoutDates.Add(aralik);
//________________________________________________________________________________________________________
slider1.Value = 1;
//________________________________________________________________________________________________________
button1.Width = 120;
button1.Height = 40;
button1.Content = "GİRİŞ";
button1.IsEnabled = false;
}
private SolidColorBrush newSolidColorBrush()
{
throw new NotImplementedException();
}
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox2.Text == "WWW")
{
textBox2.Background = new SolidColorBrush(Colors.Green);
}
else
{
textBox2.Background = new SolidColorBrush(Colors.Black);
}
}
private void calendar1_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
string gun = calendar1.SelectedDate.Value.DayOfWeek.ToString();
if (gun == "Saturday" || gun == "Sunday")
{
MessageBox.Show("Seçtiğiniz tarihe randevu verilemez!");
}
else
{
MessageBox.Show("Randevu talebiniz kabul edilmiştir.");
}
}
private void datePicker1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
DateTime kayitbas = new DateTime(2013, 8, 15);
DateTime kayitson = new DateTime(2013, 8, 31);
if (datePicker1.SelectedDate >= kayitbas &&
datePicker1.SelectedDate <= kayitson)
{
MessageBox.Show("Seçtiğiniz tarihte kayıt yapılabilir!");
}
else
{
MessageBox.Show("Seçtiğiniz tarihte kayıt yapılamaz!");
}
}
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
textBox1.Text = slider1.Value.ToString();
slider1.Value = Convert.ToInt32(slider1.Value);
//Sürgünün oniki kademeli olması için Value özelliğinin
//ondalıklı kısmı atılarak tekrar Value özelliğine atanıyor.
int ay = Convert.ToInt32(slider1.Value);
//Sürgü değeri ay değişkenine alınıyor
string tarih = "1/" + ay + "/2013";
//ay değişkeni tarih içine yerleştiriliyor.
calendar1.DisplayDate = DateTime.Parse(tarih);
//Takvimde tarih değişkeninin belirttiği tarihgörüntüleniyor.
}
private void button1_Click(object sender, RoutedEventArgs e)
{
CalendarDateRange tarih = new CalendarDateRange(datePicker1.SelectedDate.Value);
calendar1.BlackoutDates.Add(tarih);
MessageBox.Show("Seçtiğiniz tarih iptal edilmiştir!");
}
}
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="100*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100*"/>
<RowDefinition Height="100*"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Background="Black">
<Grid x:Name="LayoutRoot">
<TextBox Background="Red" Height="30" Name="textBox1" Width="180" Foreground="White" FontWeight="Bold" BorderThickness="3" FontFamily="Comic Sans MS" FontSize="12" />
</Grid>
</Border>
<Border Grid.Column="1" Grid.Row="0" Background="Black">
<Grid x:Name="LayoutRoot2">
<TextBox Background="Red" Height="30" Name="textBox2" Width="180" Foreground="White" FontWeight="Bold" BorderThickness="3" FontFamily="Comic Sans MS" FontSize="12" TextChanged="textBox2_TextChanged" />
</Grid>
</Border>
<Border Grid.Column="2" Grid.Row="0" Background="Black">
<Calendar Name="calendar1" DisplayDate="7/1/2013" IsTodayHighlighted="True" SelectionMode="MultipleRange" FirstDayOfWeek="Monday" SelectedDatesChanged="calendar1_SelectedDatesChanged" />
</Border>
<Border Grid.Column="0" Grid.Row="1" Background="Black">
<DatePicker HorizontalAlignment="Left" Margin="10,76,0,0" Name="datePicker1" VerticalAlignment="Top" SelectedDateFormat="Long" IsDropDownOpen="True" Width="152" SelectedDateChanged="datePicker1_SelectedDateChanged"/>
</Border>
<Border Grid.Column="1" Grid.Row="1" Background="Black">
<Slider Name="slider1" Maximum="10" Minimum="1" Width="100" Height="30" ValueChanged="slider1_ValueChanged" />
</Border>
<Border Grid.Column="2" Grid.Row="1" Background="Black">
<Button Content="TIKLA" Height="40" Name="button1" Width="100" Click="button1_Click" />
</Border>
</Grid>
KODLAR
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DateTime tarih = new DateTime();
calendar1.IsTodayHighlighted = false;
calendar1.DisplayMode = CalendarMode.Month;
calendar1.SelectionMode = CalendarSelectionMode.MultipleRange;
tarih = DateTime.Parse("5/7/2013");
calendar1.SelectedDates.Add(tarih);
tarih = DateTime.Parse("8/7/2013");
calendar1.SelectedDates.Add(tarih);
tarih = DateTime.Parse("10/7/2013");
calendar1.SelectedDates.Add(tarih);
//________________________________________________________________________________________________________
datePicker1.IsDropDownOpen = true;
datePicker1.IsTodayHighlighted = false;
CalendarDateRange aralik = new CalendarDateRange(DateTime.Parse("8/7/2013"),DateTime.Parse("15/7/2013"));
datePicker1.BlackoutDates.Add(aralik);
//________________________________________________________________________________________________________
slider1.Value = 1;
//________________________________________________________________________________________________________
button1.Width = 120;
button1.Height = 40;
button1.Content = "GİRİŞ";
button1.IsEnabled = false;
}
private SolidColorBrush newSolidColorBrush()
{
throw new NotImplementedException();
}
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox2.Text == "WWW")
{
textBox2.Background = new SolidColorBrush(Colors.Green);
}
else
{
textBox2.Background = new SolidColorBrush(Colors.Black);
}
}
private void calendar1_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
{
string gun = calendar1.SelectedDate.Value.DayOfWeek.ToString();
if (gun == "Saturday" || gun == "Sunday")
{
MessageBox.Show("Seçtiğiniz tarihe randevu verilemez!");
}
else
{
MessageBox.Show("Randevu talebiniz kabul edilmiştir.");
}
}
private void datePicker1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
DateTime kayitbas = new DateTime(2013, 8, 15);
DateTime kayitson = new DateTime(2013, 8, 31);
if (datePicker1.SelectedDate >= kayitbas &&
datePicker1.SelectedDate <= kayitson)
{
MessageBox.Show("Seçtiğiniz tarihte kayıt yapılabilir!");
}
else
{
MessageBox.Show("Seçtiğiniz tarihte kayıt yapılamaz!");
}
}
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
textBox1.Text = slider1.Value.ToString();
slider1.Value = Convert.ToInt32(slider1.Value);
//Sürgünün oniki kademeli olması için Value özelliğinin
//ondalıklı kısmı atılarak tekrar Value özelliğine atanıyor.
int ay = Convert.ToInt32(slider1.Value);
//Sürgü değeri ay değişkenine alınıyor
string tarih = "1/" + ay + "/2013";
//ay değişkeni tarih içine yerleştiriliyor.
calendar1.DisplayDate = DateTime.Parse(tarih);
//Takvimde tarih değişkeninin belirttiği tarihgörüntüleniyor.
}
private void button1_Click(object sender, RoutedEventArgs e)
{
CalendarDateRange tarih = new CalendarDateRange(datePicker1.SelectedDate.Value);
calendar1.BlackoutDates.Add(tarih);
MessageBox.Show("Seçtiğiniz tarih iptal edilmiştir!");
}
}
Yorumlar
Yorum Gönder