public class Calendar { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Hangi yılın takvimini istersiniz?: "); int istenilenyıl = input.nextInt();
System.out.format(" " + year + " %n"); for (int t = 1; t <= 3; t++) { leftAlignFormat = "| %-7s | | %-7s | | %-7s | | %-7s |%n"; System.out.format("+----------------------------------+ +----------------------------------+ +----------------------------------+ +----------------------------------+%n"); System.out.format(leftAlignFormat, months[mCounter++], months[mCounter++], months[mCounter++], months[mCounter++]); System.out.format("|----------------------------------| |----------------------------------| |----------------------------------| |----------------------------------|%n"); System.out.format("| Pt | Sa | Ça | Pe | Cu | Ct | Pa | | Pt | Sa | Ça | Pe | Cu | Ct | Pa | | Pt | Sa | Ça | Pe | Cu | Ct | Pa | | Pt | Sa | Ça | Pe | Cu | Ct | Pa |%n");
if (t == 1) { a = start; b = (a + 3) % 7; c = dOfMonths[1] == 28 ? b : (b + 1) % 7; d = (c + 3) % 7; start = (d + 2) % 7; } else if (t == 2) { a = start; b = (a + 3) % 7; c = (b + 2) % 7; d = (c + 3) % 7; start = (d + 3) % 7; } else { a = start; b = (a + 2) % 7; c = (b + 3) % 7; d = (c + 2) % 7; }
int[] sM = {a, b, c, d}; int[] sW = {1, 1, 1, 1};
String[] x = new String[28];
int row = 5; for (int i = 0; i < 4; i++) { if (dOfMonths[4 * (t - 1) + i ] > (28 + (7 - sM[i]))) { row = 6; break; }
}
for (int i = 1; i <= row; i++) { System.out.format("|----+----+----+----+----+----+----| |----+----+----+----+----+----+----| |----+----+----+----+----+----+----| |----+----+----+----+----+----+----| %n");
int xCounter = 0;
for (int k = 0; k < 4; k++) { for (int j = 0; j < 7; j++) { if (i == 1 && j < sM[k] % 7) x[xCounter++] = ""; else if (sW[k] > dOfMonths[4 * (t - 1) + k]) x[xCounter++] = ""; else x[xCounter++] = "" + sW[k]++; } }
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Windows.Data; using System.Windows.Input;
} public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value is Data data && tatiller.Any(z => z.Item1 == data.Ay && z.Item2 == data.Gün);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); }
public class YarımGünTatilConverter : IValueConverter { private readonly List<Tuple<string, int>> tatiller = new List<Tuple<string, int>>();
public YarımGünTatilConverter() => tatiller.Add(new Tuple<string, int>("Ekim", 28)); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value is Data data && tatiller.Any(z => z.Item1 == data.Ay && z.Item2 == data.Gün);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException(); }
public class RelayCommand : ICommand { private readonly Func<object, bool> canExecute;
public bool CanExecute(object parameter) => canExecute == null || canExecute(parameter);
public void Execute(object parameter) => execute(parameter); }
public abstract class InpcBase : INotifyPropertyChanged, INotifyPropertyChanging { public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangingEventHandler PropertyChanging;
protected virtual void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected virtual void OnPropertyChanging(string propertyName) => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName)); }
public class Data : InpcBase { private int gün; private string günAdı; private string ay; private int offset;
public int Gün { get => gün; set { if (gün != value) { gün = value; OnPropertyChanged(nameof(Gün)); } } }
public string Ay { get { return ay; }
set { if (ay != value) { ay = value; OnPropertyChanged(nameof(Ay)); } } } public string GünAdı { get { return günAdı; } set { if (günAdı != value) { günAdı = value; OnPropertyChanged(nameof(GünAdı)); } } }
public int Offset { get { return offset; }
set { if (offset != value) { offset = value; OnPropertyChanged(nameof(Offset)); } } } }
public class MainViewModel : InpcBase { private ObservableCollection<Data> günler; public ObservableCollection<Data> Günler { get { return günler; }
set { if (günler != value) { günler = value; OnPropertyChanged(nameof(Günler)); } } }
private int seçiliYıl = DateTime.Now.Year; private int bugünIndex = DateTime.Today.DayOfYear - 1;
public int SeçiliYıl { get { return seçiliYıl; }
set { if (seçiliYıl != value) { seçiliYıl = value; TakvimOluştur(); OnPropertyChanged(nameof(SeçiliYıl)); } } }
public int BugünIndex { get { return bugünIndex; }
set { if (bugünIndex != value) { bugünIndex = value; OnPropertyChanged(nameof(BugünIndex)); } } }
public MainViewModel() { TakvimOluştur(); Geri = new RelayCommand(parameter => SeçiliYıl--, parameter => SeçiliYıl > 1); İleri = new RelayCommand(parameter => SeçiliYıl++, parameter => SeçiliYıl < 9999); }
public ICommand Geri { get; } public ICommand İleri { get; }
private void TakvimOluştur() { Günler = new ObservableCollection<Data>(); for (int i = 1; i <= 12; i++) { for (int j = 1; j <= 31; j++) { string tarih = $"{SeçiliYıl}-{i}-{j}"; if (DateTime.TryParse(tarih, out _)) { var data = new Data { GünAdı = DateTime.Parse(tarih).ToString("ddd"), Gün = DateTime.Parse(tarih).Day, Ay = DateTime.Parse(tarih).ToString("MMMM"), Offset = (int)(DateTime.Parse(tarih).DayOfWeek) }; Günler.Add(data); } } } } } }
< Resime gitmek için tıklayın >
20.02.2024
< Resime gitmek için tıklayın >
< Resime gitmek için tıklayın >
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye Ol Şimdi DeğilÜye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.
< Bu mesaj bu kişi tarafından değiştirildi Anjal -- 29 Şubat 2024; 15:9:51 >
Bu mesajda bahsedilenler: @burak jr