Otwórz Visual Studio 2022.
Kliknij Create a new project.
Wybierz Windows Forms App (.NET Framework) i kliknij Next.
Nazwij projekt, np. MojePortfolio i kliknij Create.
Wybierz wersję .NET Framework (np. 4.8) i kliknij Create.
Form1.cs będzie naszym ekranem rejestracji.
Otwórz Toolbox (z menu View > Toolbox, jeśli nie jest widoczny).
Przeciągnij na formę następujące kontrolki:
Label dla „Imię i nazwisko”
TextBox obok etykiety, nazwij go txtName
Label dla „Opis”
TextBox poniżej, nazwij go txtDescription
PictureBox do wczytania zdjęcia, nazwij go pictureBox
Button o nazwie btnUploadImage i tekstem „Załaduj zdjęcie”
Button o nazwie btnSubmit z tekstem „Przejdź do portfolio”
Ustaw odpowiednio kontrolki na formularzu, aby stworzyć prosty formularz rejestracji.
Kliknij dwukrotnie przycisk btnUploadImage, aby otworzyć kod, i dodaj kod, który pozwala użytkownikowi wczytać zdjęcie:
private void btnUploadImage_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
pictureBox.Image = Image.FromFile(openFileDialog.FileName);
}
}
Kliknij dwukrotnie przycisk btnSubmit i dodaj kod, który przekaże dane do drugiego formularza:
public static string UserName;
public static string UserDescription;
public static Image UserImage;
private void btnSubmit_Click(object sender, EventArgs e)
{
UserName = txtName.Text;
UserDescription = txtDescription.Text;
UserImage = pictureBox.Image;
PortfolioForm portfolioForm = new PortfolioForm();
portfolioForm.Show();
this.Hide();
}
Kod ten zapisuje dane w zmiennych statycznych, aby były dostępne w drugim formularzu i otwiera drugi formularz.
W Solution Explorer kliknij prawym przyciskiem na projekt, wybierz Add > Windows Form… i nazwij formularz PortfolioForm.cs.
Na nowym formularzu PortfolioForm przeciągnij na formę:
Label dla wyświetlenia imienia i nazwiska, nazwij go lblName
Label dla opisu, nazwij go lblDescription
PictureBox dla zdjęcia, nazwij go pictureBox
Button z tekstem „Powrót”, nazwij go btnBack
Ułóż kontrolki w przyjaznym układzie, aby użytkownik mógł zobaczyć podsumowanie swojego profilu.
Kliknij dwukrotnie formularz PortfolioForm i w metodzie PortfolioForm_Load dodaj kod, który pobierze dane z pierwszego formularza i wyświetli je:
private void PortfolioForm_Load(object sender, EventArgs e)
{
lblName.Text = Form1.UserName;
lblDescription.Text = Form1.UserDescription;
pictureBox.Image = Form1.UserImage;
}
Kliknij dwukrotnie przycisk btnBack i dodaj kod, który pozwala użytkownikowi wrócić do ekranu rejestracji:
private void btnBack_Click(object sender, EventArgs e)
{
Form1 registrationForm = new Form1();
registrationForm.Show();
this.Close();
}
W Solution Explorer otwórz Form1.cs (nasz formularz rejestracji).
Dodaj kod, aby otworzyć drugi formularz po kliknięciu btnSubmit:
PortfolioForm portfolioForm = new PortfolioForm();
portfolioForm.Show();
Kliknij Start (zielona strzałka w Visual Studio) lub naciśnij F5, aby uruchomić aplikację.
Wprowadź dane w formularzu rejestracji, załaduj zdjęcie, a następnie kliknij „Przejdź do portfolio”.
Powinien otworzyć się drugi ekran z podsumowaniem wprowadzonych danych.
Stylizacja – dostosuj kolory, rozmiary i czcionki, aby aplikacja wyglądała atrakcyjnie.
Obsługa wyjątków – np. sprawdzenie, czy wszystkie pola są wypełnione przed przejściem do ekranu portfolio.
Dodanie funkcji resetu – przycisk, który pozwoli użytkownikowi wyczyścić formularz rejestracji.
Funkcja Calculate została stworzona do obliczania matematycznego wyrażenia wpisanego przez użytkownika w polu tekstowym. Działa w oparciu o kilka kroków:
string expression = wynik.Text.Replace("mod", "%")
.Replace(" ", "")
.Replace(",", ".");
Co robi ten kod?
Odczytuje wyrażenie wpisane w polu wynik (np. 4,2 + 3 mod 2).
Zamienia tekst mod na %, ponieważ % to operator reszty z dzielenia w C#.
Usuwa wszystkie zbędne spacje – aby obliczenia działały poprawnie.
Zamienia przecinki , na kropki . – w obliczeniach komputerowych kropki są używane jako separator dziesiętny.
Dlaczego to robimy?
Aby wyrażenie było w formacie, który program może zrozumieć i poprawnie obliczyć.
if (!IsExpressionValid(expression))
{
wynik.Text = "Błąd w nawiasach";
return;
}
Co robi ten kod?
Funkcja IsExpressionValid sprawdza, czy wszystkie nawiasy w wyrażeniu są poprawnie użyte. Liczy liczbę otwierających i zamykających nawiasów:
Gdy otwieramy nawias (, zwiększa licznik.
Gdy zamykamy nawias ), zmniejsza licznik.
Jeśli w dowolnym momencie licznik stanie się ujemny (np. więcej zamknięć niż otwarć), oznacza to błąd.
Na końcu sprawdza, czy licznik wynosi 0. Jeśli tak, nawiasy są poprawne.
Dlaczego to robimy?
Aby uniknąć błędów podczas obliczeń, gdy użytkownik wprowadzi złe wyrażenie, np. ((2+3)*4.
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
var result = new DataTable().Compute(expression, "");
wynik.Text = result.ToString();
Co robi ten kod?
CurrentCulture: Ustawia format liczb, tak aby program akceptował kropki jako separator dziesiętny.
DataTable().Compute:
Oblicza wyrażenie przekazane w zmiennej expression.
Na przykład:
4.2 + 3.2 → wynik to 7.4.
(2 + 3) * 4 → wynik to 20.
Wynik jest zamieniany na tekst i wyświetlany w polu tekstowym wynik.
Dlaczego to robimy?
Aby użytkownik otrzymał wynik wpisanego wyrażenia matematycznego.
catch
{
wynik.Text = "Błąd";
}
Co robi ten kod?
Jeśli w trakcie obliczeń wystąpi błąd (np. użytkownik wpisał niepoprawne wyrażenie, jak 5+*2), kod przechwyci ten błąd i wyświetli komunikat Błąd w polu tekstowym.
Dlaczego to robimy?
Aby aplikacja nie przestała działać w przypadku błędów użytkownika.
private bool IsExpressionValid(string expression)
{
int parenthesesCount = 0;
foreach (char c in expression)
{
if (c == '(') parenthesesCount++;
if (c == ')') parenthesesCount--;
if (parenthesesCount < 0) return false; // Za dużo zamykających nawiasów
}
return parenthesesCount == 0; // Wszystkie nawiasy sparowane
}
Co robi ta funkcja?
Przegląda wyrażenie znak po znaku.
Sprawdza, czy każdy otwierający nawias ma odpowiadający zamykający nawias.
Dlaczego to robimy?
Aby upewnić się, że wyrażenie jest poprawne i może być obliczone.
Użytkownik wpisuje wyrażenie w pole tekstowe, np. (4,2 + 3,2) * 2.
Program:
Oczyszcza wyrażenie (np. usuwa spacje, zamienia przecinki na kropki, mod na %).
Sprawdza poprawność nawiasów.
Oblicza wynik za pomocą DataTable.Compute.
Wynik jest wyświetlany w polu tekstowym.
Jeśli wystąpi błąd, np. niepoprawne nawiasy, użytkownik widzi komunikat Błąd.
Form1.cs.
using System;
using System.Data;
using System.Windows.Forms;
namespace kalk
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Obsługa kliknięcia przycisku (numery lub operatory)
private void ButtonClick(object sender, EventArgs e)
{
Button button = sender as Button;
wynik.Text += button.Text;
}
// Obsługa obliczeń
private void Calculate(object sender, EventArgs e)
{
try
{
// Usuń zbędne spacje i zamień "mod" na "%"
string expression = wynik.Text.Replace("mod", "%")
.Replace(" ", "")
.Replace(",", ".");
// Sprawdź poprawność nawiasów
if (!IsExpressionValid(expression))
{
wynik.Text = "Błąd w nawiasach";
return;
}
// Wymuś kulturę InvariantCulture
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
// Oblicz wyrażenie
var result = new DataTable().Compute(expression, "");
wynik.Text = result.ToString();
}
catch
{
wynik.Text = "Błąd";
}
}
// Funkcja sprawdzająca poprawność nawiasów
private bool IsExpressionValid(string expression)
{
int parenthesesCount = 0;
foreach (char c in expression)
{
if (c == '(') parenthesesCount++;
if (c == ')') parenthesesCount--;
if (parenthesesCount < 0) return false; // Zamykający nawias bez otwierającego
}
return parenthesesCount == 0; // Wszystkie nawiasy muszą być sparowane
}
private void ClearText(object sender, EventArgs e)
{
wynik.Text = ""; // Czyści pole tekstowe
}
private void Backspace(object sender, EventArgs e)
{
if (wynik.Text.Length > 0) // Sprawdza, czy pole nie jest puste
{
wynik.Text = wynik.Text.Substring(0, wynik.Text.Length - 1); // Usuwa ostatni znak
}
}
private void wynik_TextChanged(object sender, EventArgs e)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Windows.Forms;
namespace NotatnikApp2
{
public partial class Form1 : Form
{
private const string NotesListFile = "notes_list.txt";
private string currentNoteFilePath = string.Empty;
private Dictionary<string, string> notesDictionary = new Dictionary<string, string>();
private Font defaultFont = new Font("Verdana", 12);
public Form1()
{
InitializeComponent();
LoadNotesList();
richTextBoxContent.Enabled = false;
richTextBoxContent.Font = defaultFont;
}
private void LoadNotesList()
{
if (File.Exists(NotesListFile))
{
var lines = File.ReadAllLines(NotesListFile);
foreach (var line in lines)
{
var parts = line.Split('|');
if (parts.Length == 2)
{
notesDictionary[parts[0]] = parts[1];
listBoxNotes.Items.Add(parts[0]);
}
}
}
}
private void SaveNotesList()
{
var lines = new List<string>();
foreach (var kvp in notesDictionary)
{
lines.Add($"{kvp.Key}|{kvp.Value}");
}
File.WriteAllLines(NotesListFile, lines);
}
private void ButtonAddNote_Click(object sender, EventArgs e)
{
richTextBoxContent.Clear();
richTextBoxContent.Enabled = true;
currentNoteFilePath = string.Empty;
}
private void ToolStripButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(currentNoteFilePath))
{
using (SaveFileDialog saveDialog = new SaveFileDialog())
{
saveDialog.Filter = "Pliki tekstowe (*.txt)|*.txt";
if (saveDialog.ShowDialog() == DialogResult.OK)
{
currentNoteFilePath = saveDialog.FileName;
SaveCurrentNote();
string noteName = Path.GetFileNameWithoutExtension(currentNoteFilePath);
if (!notesDictionary.ContainsKey(noteName))
{
notesDictionary[noteName] = currentNoteFilePath;
listBoxNotes.Items.Add(noteName);
SaveNotesList();
}
}
}
}
else
{
SaveCurrentNote();
}
}
private void SaveCurrentNote()
{
File.WriteAllText(currentNoteFilePath, richTextBoxContent.Text);
}
private void ListBoxNotes_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName && notesDictionary.TryGetValue(noteName, out string filePath) && File.Exists(filePath))
{
richTextBoxContent.Text = File.ReadAllText(filePath);
currentNoteFilePath = filePath;
richTextBoxContent.Enabled = true;
}
}
private void ButtonOpenNote_Click(object sender, EventArgs e)
{
using (OpenFileDialog openDialog = new OpenFileDialog())
{
openDialog.Filter = "Pliki tekstowe (*.txt)|*.txt";
if (openDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openDialog.FileName;
richTextBoxContent.Text = File.ReadAllText(filePath);
currentNoteFilePath = filePath;
string noteName = Path.GetFileNameWithoutExtension(filePath);
if (!notesDictionary.ContainsKey(noteName))
{
notesDictionary[noteName] = filePath;
listBoxNotes.Items.Add(noteName);
SaveNotesList();
}
}
}
}
private void DeleteNoteFromList_Click(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName && notesDictionary.ContainsKey(noteName))
{
notesDictionary.Remove(noteName);
listBoxNotes.Items.Remove(noteName);
SaveNotesList();
MessageBox.Show($"Notatka '{noteName}' została usunięta z listy.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void DeleteNoteFromDisk_Click(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName && notesDictionary.TryGetValue(noteName, out string filePath) && File.Exists(filePath))
{
notesDictionary.Remove(noteName);
listBoxNotes.Items.Remove(noteName);
SaveNotesList();
File.Delete(filePath);
MessageBox.Show($"Notatka '{noteName}' została usunięta z dysku.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void ToolStripButtonColor_Click(object sender, EventArgs e)
{
using (ColorDialog dialog = new ColorDialog())
{
if (dialog.ShowDialog() == DialogResult.OK)
{
richTextBoxContent.SelectionColor = dialog.Color;
}
}
}
private void ToolStripButtonFont_Click(object sender, EventArgs e)
{
using (FontDialog fontDialog = new FontDialog())
{
fontDialog.Font = richTextBoxContent.SelectionFont ?? richTextBoxContent.Font;
if (fontDialog.ShowDialog() == DialogResult.OK)
{
if (richTextBoxContent.SelectionLength > 0)
{
richTextBoxContent.SelectionFont = fontDialog.Font;
}
else
{
richTextBoxContent.Font = fontDialog.Font;
}
}
}
}
private void ToolStripButtonAlignLeft_Click(object sender, EventArgs e) => richTextBoxContent.SelectionAlignment = HorizontalAlignment.Left;
private void ToolStripButtonAlignCenter_Click(object sender, EventArgs e) => richTextBoxContent.SelectionAlignment = HorizontalAlignment.Center;
private void ToolStripButtonAlignRight_Click(object sender, EventArgs e) => richTextBoxContent.SelectionAlignment = HorizontalAlignment.Right;
private void ToolStripButtonPrint_Click(object sender, EventArgs e)
{
using (PrintDialog printDialog = new PrintDialog())
{
PrintDocument printDocument = new PrintDocument();
printDocument.PrintPage += PrintDocument_PrintPage;
printDialog.Document = printDocument;
if (printDialog.ShowDialog() == DialogResult.OK)
{
printDocument.Print();
}
}
}
private void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString(richTextBoxContent.Text, richTextBoxContent.Font, Brushes.Black, e.MarginBounds, StringFormat.GenericTypographic);
}
private void ToolStripButtonBold_Click(object sender, EventArgs e) => ToggleFontStyle(FontStyle.Bold);
private void ToolStripButtonItalic_Click(object sender, EventArgs e) => ToggleFontStyle(FontStyle.Italic);
private void ToolStripButtonUnderline_Click(object sender, EventArgs e) => ToggleFontStyle(FontStyle.Underline);
private void ToggleFontStyle(FontStyle style)
{
if (richTextBoxContent.SelectionFont != null)
{
FontStyle newStyle = richTextBoxContent.SelectionFont.Style;
if (richTextBoxContent.SelectionFont.Style.HasFlag(style))
newStyle &= ~style;
else
newStyle |= style;
richTextBoxContent.SelectionFont = new Font(richTextBoxContent.SelectionFont, newStyle);
}
}
private void ToolStripButton2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
private void ToolStripButton3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("mspaint.exe");
}
private void ToolStripButton1_Click(object sender, EventArgs e)
{
using (MonthCalendar calendar = new MonthCalendar())
{
Form calendarForm = new Form
{
Text = "Kalendarz",
Size = new Size(400, 300)
};
calendar.Dock = DockStyle.Fill;
calendar.DateSelected += (s, ev) => MessageBox.Show($"Wybrano datę: {ev.Start.ToShortDateString()}", "Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
calendarForm.Controls.Add(calendar);
calendarForm.ShowDialog();
}
}
}
}
Menu kontekstowe to obiekt ContextMenuStrip. Możesz go utworzyć w kodzie lub dodać za pomocą projektanta Visual Studio.
Kod:
ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
Każda opcja w menu to obiekt ToolStripMenuItem. Możesz go utworzyć i dodać do ContextMenuStrip.
Kod:
ToolStripMenuItem deleteMenuItem = new ToolStripMenuItem("Usuń notatkę");
deleteMenuItem.Click += DeleteNoteFromList_Click; // Przypisanie metody obsługi
ToolStripMenuItem openMenuItem = new ToolStripMenuItem("Otwórz notatkę");
openMenuItem.Click += OpenNote_Click; // Przypisanie metody obsługi
ToolStripMenuItem renameMenuItem = new ToolStripMenuItem("Zmień nazwę notatki");
renameMenuItem.Click += RenameNote_Click; // Przypisanie metody obsługi
// Dodanie elementów do menu
contextMenuStrip.Items.Add(deleteMenuItem);
contextMenuStrip.Items.Add(openMenuItem);
contextMenuStrip.Items.Add(renameMenuItem);
Menu kontekstowe można przypisać do dowolnej kontrolki, np. do listBoxNotes.
Kod:
listBoxNotes.ContextMenuStrip = contextMenuStrip;
Metody obsługi (np. DeleteNoteFromList_Click) definiują, co się stanie po kliknięciu opcji w menu.
Kod:
private void DeleteNoteFromList_Click(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName && notesDictionary.ContainsKey(noteName))
{
notesDictionary.Remove(noteName);
listBoxNotes.Items.Remove(noteName);
SaveNotesList();
MessageBox.Show($"Notatka '{noteName}' została usunięta.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void OpenNote_Click(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName && notesDictionary.TryGetValue(noteName, out string filePath))
{
MessageBox.Show($"Otwieranie notatki: {filePath}");
// Kod otwierania notatki
}
}
private void RenameNote_Click(object sender, EventArgs e)
{
if (listBoxNotes.SelectedItem is string noteName)
{
string newName = Prompt.ShowDialog("Podaj nową nazwę:", "Zmień nazwę notatki");
if (!string.IsNullOrEmpty(newName) && !notesDictionary.ContainsKey(newName))
{
string filePath = notesDictionary[noteName];
notesDictionary.Remove(noteName);
notesDictionary[newName] = filePath;
int index = listBoxNotes.Items.IndexOf(noteName);
listBoxNotes.Items[index] = newName;
SaveNotesList();
MessageBox.Show($"Notatka została przemianowana na '{newName}'.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
Możesz dodawać separatory i grupować opcje.
Kod:
contextMenuStrip.Items.Add(new ToolStripSeparator()); // Separator
ToolStripMenuItem exitMenuItem = new ToolStripMenuItem("Wyjdź");
exitMenuItem.Click += (s, e) => Close(); // Wyjdź z aplikacji
contextMenuStrip.Items.Add(exitMenuItem);
Po kliknięciu prawym przyciskiem myszy na listBoxNotes, pojawi się menu z opcjami:
Usuń notatkę
Otwórz notatkę
Zmień nazwę notatki
(Separator)
Wyjdź
#FORM1.cs
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace afreshstartApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.Focus();
richTextBox1.Font = new Font("Arial", 12);
richTextBox1.Focus();
}
private void kolorToolStripMenuItem_Click(object sender, EventArgs e)
{
using (ColorDialog colorDialog = new ColorDialog())
{
if (colorDialog.ShowDialog() == DialogResult.OK)
{
richTextBox1.SelectionColor = colorDialog.Color;
}
}
}
private void nowyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void otwórzToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Pliki tekstowe (*.txt)|*.txt|Pliki RTF (*.rtf)|*.rtf|Wszystkie pliki (*.*)|*.*"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
if (openFileDialog.FileName.EndsWith(".rtf"))
richTextBox1.LoadFile(openFileDialog.FileName, RichTextBoxStreamType.RichText);
else
richTextBox1.Text = File.ReadAllText(openFileDialog.FileName);
}
}
private void zapiszToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog
{
Filter = "Pliki tekstowe (*.txt)|*.txt|Pliki RTF (*.rtf)|*.rtf"
};
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (saveFileDialog.FileName.EndsWith(".rtf"))
richTextBox1.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.RichText);
else
File.WriteAllText(saveFileDialog.FileName, richTextBox1.Text);
}
}
private void kopiujToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void wklejToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void wytnijToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void usuToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectedText = string.Empty;
}
private void WygladCzcionkiToolStripMenuItem_Click(object sender, EventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox1.SelectionFont = fontDialog1.Font;
}
}
private void prawaToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Right;
}
private void lewaToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
}
private void środekToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
}
private void zawijajWierszeToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.WordWrap = !richTextBox1.WordWrap;
zawijajWierszeToolStripMenuItem.Checked = richTextBox1.WordWrap;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
// Obsługa zmiany tekstu (opcjonalnie)
}
private void oMnieToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void siticoneButton2_Click(object sender, EventArgs e)
{
}
private void siticoneButton5_Click(object sender, EventArgs e)
{
}
}
}
#FORM1.DESIGNER.cs
using System;
using System.Windows.Forms;
namespace afreshstartApp
{
partial class Form1
{
/// <summary>
/// Wymagana zmienna projektanta.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Wyczyść wszystkie używane zasoby.
/// </summary>
/// <param name="disposing">prawda, jeżeli zarządzane zasoby powinny zostać zlikwidowane; Fałsz w przeciwnym wypadku.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Kod generowany przez Projektanta formularzy systemu Windows
/// <summary>
/// Metoda wymagana do obsługi projektanta — nie należy modyfikować
/// jej zawartości w edytorze kodu.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.menuStrip2 = new System.Windows.Forms.MenuStrip();
this.plikToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.nowyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.otwórzToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.zapiszToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.zamknijToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.edycjaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.kopiujToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wklejToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wytnijToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.usuToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.formatowanieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.WygladCzcionkiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wyrównanieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.prawaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lewaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.środekToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.justowanieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.kolorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.widokToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.zawijajWierszeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.oMnieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.fontDialog1 = new System.Windows.Forms.FontDialog();
this.siticoneButton_B = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_I = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_U = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_Druk = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_PDF = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_P = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_L = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_S = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_W = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_K = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_Tab = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.siticoneButton_Kal = new Siticone.Desktop.UI.WinForms.SiticoneButton();
this.menuStrip2.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip1.Location = new System.Drawing.Point(0, 33);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(745, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// menuStrip2
//
this.menuStrip2.BackColor = System.Drawing.Color.LightSalmon;
this.menuStrip2.Font = new System.Drawing.Font("Segoe UI", 9F);
this.menuStrip2.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
this.menuStrip2.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.plikToolStripMenuItem,
this.edycjaToolStripMenuItem,
this.formatowanieToolStripMenuItem,
this.widokToolStripMenuItem,
this.oMnieToolStripMenuItem});
this.menuStrip2.Location = new System.Drawing.Point(0, 0);
this.menuStrip2.Name = "menuStrip2";
this.menuStrip2.Size = new System.Drawing.Size(745, 33);
this.menuStrip2.TabIndex = 1;
this.menuStrip2.Text = "menuStrip2";
//
// plikToolStripMenuItem
//
this.plikToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.nowyToolStripMenuItem,
this.otwórzToolStripMenuItem,
this.zapiszToolStripMenuItem,
this.zamknijToolStripMenuItem});
this.plikToolStripMenuItem.Name = "plikToolStripMenuItem";
this.plikToolStripMenuItem.Size = new System.Drawing.Size(60, 29);
this.plikToolStripMenuItem.Text = " Plik";
//
// nowyToolStripMenuItem
//
this.nowyToolStripMenuItem.Name = "nowyToolStripMenuItem";
this.nowyToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.nowyToolStripMenuItem.Text = "Nowy";
this.nowyToolStripMenuItem.Click += new System.EventHandler(this.nowyToolStripMenuItem_Click);
//
// otwórzToolStripMenuItem
//
this.otwórzToolStripMenuItem.Name = "otwórzToolStripMenuItem";
this.otwórzToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.otwórzToolStripMenuItem.Text = "Otwórz";
this.otwórzToolStripMenuItem.Click += new System.EventHandler(this.otwórzToolStripMenuItem_Click);
//
// zapiszToolStripMenuItem
//
this.zapiszToolStripMenuItem.Name = "zapiszToolStripMenuItem";
this.zapiszToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.zapiszToolStripMenuItem.Text = "Zapisz";
this.zapiszToolStripMenuItem.Click += new System.EventHandler(this.zapiszToolStripMenuItem_Click);
//
// zamknijToolStripMenuItem
//
this.zamknijToolStripMenuItem.Name = "zamknijToolStripMenuItem";
this.zamknijToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.zamknijToolStripMenuItem.Text = "Zamknij";
//
// edycjaToolStripMenuItem
//
this.edycjaToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.kopiujToolStripMenuItem,
this.wklejToolStripMenuItem,
this.wytnijToolStripMenuItem,
this.usuToolStripMenuItem});
this.edycjaToolStripMenuItem.Name = "edycjaToolStripMenuItem";
this.edycjaToolStripMenuItem.Size = new System.Drawing.Size(83, 29);
this.edycjaToolStripMenuItem.Text = " Edycja";
//
// kopiujToolStripMenuItem
//
this.kopiujToolStripMenuItem.Name = "kopiujToolStripMenuItem";
this.kopiujToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.kopiujToolStripMenuItem.Text = "Kopiuj";
this.kopiujToolStripMenuItem.Click += new System.EventHandler(this.kopiujToolStripMenuItem_Click);
//
// wklejToolStripMenuItem
//
this.wklejToolStripMenuItem.Name = "wklejToolStripMenuItem";
this.wklejToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.wklejToolStripMenuItem.Text = "Wklej";
this.wklejToolStripMenuItem.Click += new System.EventHandler(this.wklejToolStripMenuItem_Click);
//
// wytnijToolStripMenuItem
//
this.wytnijToolStripMenuItem.Name = "wytnijToolStripMenuItem";
this.wytnijToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.wytnijToolStripMenuItem.Text = "Wytnij";
this.wytnijToolStripMenuItem.Click += new System.EventHandler(this.wytnijToolStripMenuItem_Click);
//
// usuToolStripMenuItem
//
this.usuToolStripMenuItem.Name = "usuToolStripMenuItem";
this.usuToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.usuToolStripMenuItem.Text = "Usuń";
//
// formatowanieToolStripMenuItem
//
this.formatowanieToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.WygladCzcionkiToolStripMenuItem,
this.wyrównanieToolStripMenuItem,
this.kolorToolStripMenuItem});
this.formatowanieToolStripMenuItem.Name = "formatowanieToolStripMenuItem";
this.formatowanieToolStripMenuItem.Size = new System.Drawing.Size(146, 29);
this.formatowanieToolStripMenuItem.Text = " Formatowanie";
//
// WygladCzcionkiToolStripMenuItem
//
this.WygladCzcionkiToolStripMenuItem.Name = "WygladCzcionkiToolStripMenuItem";
this.WygladCzcionkiToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.WygladCzcionkiToolStripMenuItem.Text = "Wygląd czcionki";
this.WygladCzcionkiToolStripMenuItem.Click += new System.EventHandler(this.WygladCzcionkiToolStripMenuItem_Click);
//
// wyrównanieToolStripMenuItem
//
this.wyrównanieToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.prawaToolStripMenuItem,
this.lewaToolStripMenuItem,
this.środekToolStripMenuItem,
this.justowanieToolStripMenuItem});
this.wyrównanieToolStripMenuItem.Name = "wyrównanieToolStripMenuItem";
this.wyrównanieToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.wyrównanieToolStripMenuItem.Text = "Wyrównanie";
this.wyrównanieToolStripMenuItem.Click += new System.EventHandler(this.wyrównanieToolStripMenuItem_Click);
//
// prawaToolStripMenuItem
//
this.prawaToolStripMenuItem.Name = "prawaToolStripMenuItem";
this.prawaToolStripMenuItem.Size = new System.Drawing.Size(198, 34);
this.prawaToolStripMenuItem.Text = "prawa";
this.prawaToolStripMenuItem.Click += new System.EventHandler(this.prawaToolStripMenuItem_Click);
//
// lewaToolStripMenuItem
//
this.lewaToolStripMenuItem.Name = "lewaToolStripMenuItem";
this.lewaToolStripMenuItem.Size = new System.Drawing.Size(198, 34);
this.lewaToolStripMenuItem.Text = "lewa";
this.lewaToolStripMenuItem.Click += new System.EventHandler(this.lewaToolStripMenuItem_Click);
//
// środekToolStripMenuItem
//
this.środekToolStripMenuItem.Name = "środekToolStripMenuItem";
this.środekToolStripMenuItem.Size = new System.Drawing.Size(198, 34);
this.środekToolStripMenuItem.Text = "środek";
this.środekToolStripMenuItem.Click += new System.EventHandler(this.środekToolStripMenuItem_Click);
//
// justowanieToolStripMenuItem
//
this.justowanieToolStripMenuItem.Name = "justowanieToolStripMenuItem";
this.justowanieToolStripMenuItem.Size = new System.Drawing.Size(198, 34);
this.justowanieToolStripMenuItem.Text = "justowanie";
this.justowanieToolStripMenuItem.Click += new System.EventHandler(this.justowanieToolStripMenuItem_Click);
//
// kolorToolStripMenuItem
//
this.kolorToolStripMenuItem.Name = "kolorToolStripMenuItem";
this.kolorToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.kolorToolStripMenuItem.Text = "Kolor ";
this.kolorToolStripMenuItem.Click += new System.EventHandler(this.kolorToolStripMenuItem_Click);
//
// widokToolStripMenuItem
//
this.widokToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.zawijajWierszeToolStripMenuItem});
this.widokToolStripMenuItem.Name = "widokToolStripMenuItem";
this.widokToolStripMenuItem.Size = new System.Drawing.Size(85, 29);
this.widokToolStripMenuItem.Text = " Widok";
//
// zawijajWierszeToolStripMenuItem
//
this.zawijajWierszeToolStripMenuItem.Name = "zawijajWierszeToolStripMenuItem";
this.zawijajWierszeToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
this.zawijajWierszeToolStripMenuItem.Text = "Zawijaj wiersze";
this.zawijajWierszeToolStripMenuItem.Click += new System.EventHandler(this.zawijajWierszeToolStripMenuItem_Click);
//
// oMnieToolStripMenuItem
//
this.oMnieToolStripMenuItem.Name = "oMnieToolStripMenuItem";
this.oMnieToolStripMenuItem.Size = new System.Drawing.Size(78, 29);
this.oMnieToolStripMenuItem.Text = " Autor";
this.oMnieToolStripMenuItem.Click += new System.EventHandler(this.oMnieToolStripMenuItem_Click);
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.Color.Linen;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.richTextBox1.Location = new System.Drawing.Point(0, 57);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(745, 435);
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// siticoneButton_B
//
this.siticoneButton_B.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_B.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_B.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_B.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_B.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.siticoneButton_B.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_B.ForeColor = System.Drawing.Color.White;
this.siticoneButton_B.Location = new System.Drawing.Point(12, 41);
this.siticoneButton_B.Name = "siticoneButton_B";
this.siticoneButton_B.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_B.TabIndex = 3;
this.siticoneButton_B.Text = "B";
//
// siticoneButton_I
//
this.siticoneButton_I.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_I.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_I.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_I.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_I.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.siticoneButton_I.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_I.ForeColor = System.Drawing.Color.White;
this.siticoneButton_I.Location = new System.Drawing.Point(67, 41);
this.siticoneButton_I.Name = "siticoneButton_I";
this.siticoneButton_I.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_I.TabIndex = 4;
this.siticoneButton_I.Text = "I";
this.siticoneButton_I.Click += new System.EventHandler(this.siticoneButton2_Click);
//
// siticoneButton_U
//
this.siticoneButton_U.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_U.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_U.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_U.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_U.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
this.siticoneButton_U.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_U.ForeColor = System.Drawing.Color.White;
this.siticoneButton_U.Location = new System.Drawing.Point(122, 41);
this.siticoneButton_U.Name = "siticoneButton_U";
this.siticoneButton_U.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_U.TabIndex = 5;
this.siticoneButton_U.Text = "U";
//
// siticoneButton_Druk
//
this.siticoneButton_Druk.Animated = true;
this.siticoneButton_Druk.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Druk.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Druk.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_Druk.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_Druk.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
this.siticoneButton_Druk.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_Druk.ForeColor = System.Drawing.Color.White;
this.siticoneButton_Druk.Location = new System.Drawing.Point(484, 2);
this.siticoneButton_Druk.Name = "siticoneButton_Druk";
this.siticoneButton_Druk.Size = new System.Drawing.Size(119, 31);
this.siticoneButton_Druk.TabIndex = 6;
this.siticoneButton_Druk.Text = "Drukuj";
//
// siticoneButton_PDF
//
this.siticoneButton_PDF.Animated = true;
this.siticoneButton_PDF.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_PDF.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_PDF.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_PDF.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_PDF.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
this.siticoneButton_PDF.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_PDF.ForeColor = System.Drawing.Color.White;
this.siticoneButton_PDF.Location = new System.Drawing.Point(609, 0);
this.siticoneButton_PDF.Name = "siticoneButton_PDF";
this.siticoneButton_PDF.Size = new System.Drawing.Size(121, 30);
this.siticoneButton_PDF.TabIndex = 7;
this.siticoneButton_PDF.Text = "PDF";
this.siticoneButton_PDF.Click += new System.EventHandler(this.siticoneButton5_Click);
//
// siticoneButton_P
//
this.siticoneButton_P.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_P.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_P.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_P.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_P.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.siticoneButton_P.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_P.ForeColor = System.Drawing.Color.White;
this.siticoneButton_P.Location = new System.Drawing.Point(299, 41);
this.siticoneButton_P.Name = "siticoneButton_P";
this.siticoneButton_P.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_P.TabIndex = 8;
this.siticoneButton_P.Text = "P";
this.siticoneButton_P.Click += new System.EventHandler(this.prawaToolStripMenuItem_Click);
//
// siticoneButton_L
//
this.siticoneButton_L.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_L.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_L.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_L.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_L.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.siticoneButton_L.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_L.ForeColor = System.Drawing.Color.White;
this.siticoneButton_L.Location = new System.Drawing.Point(189, 41);
this.siticoneButton_L.Name = "siticoneButton_L";
this.siticoneButton_L.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_L.TabIndex = 9;
this.siticoneButton_L.Text = "L";
this.siticoneButton_L.Click += new System.EventHandler(this.lewaToolStripMenuItem_Click);
//
// siticoneButton_S
//
this.siticoneButton_S.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_S.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_S.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_S.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_S.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.siticoneButton_S.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_S.ForeColor = System.Drawing.Color.White;
this.siticoneButton_S.Location = new System.Drawing.Point(244, 41);
this.siticoneButton_S.Name = "siticoneButton_S";
this.siticoneButton_S.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_S.TabIndex = 10;
this.siticoneButton_S.Text = "Ś";
this.siticoneButton_S.Click += new System.EventHandler(this.środekToolStripMenuItem_Click);
//
// siticoneButton_W
//
this.siticoneButton_W.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_W.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_W.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_W.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_W.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.siticoneButton_W.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_W.ForeColor = System.Drawing.Color.White;
this.siticoneButton_W.Location = new System.Drawing.Point(354, 41);
this.siticoneButton_W.Name = "siticoneButton_W";
this.siticoneButton_W.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_W.TabIndex = 11;
this.siticoneButton_W.Text = "W";
this.siticoneButton_W.Click += new System.EventHandler(this.justowanieToolStripMenuItem_Click);
//
// siticoneButton_K
//
this.siticoneButton_K.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_K.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_K.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_K.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_K.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.siticoneButton_K.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_K.ForeColor = System.Drawing.Color.White;
this.siticoneButton_K.Location = new System.Drawing.Point(409, 41);
this.siticoneButton_K.Name = "siticoneButton_K";
this.siticoneButton_K.Size = new System.Drawing.Size(49, 26);
this.siticoneButton_K.TabIndex = 12;
this.siticoneButton_K.Text = "K";
this.siticoneButton_K.Click += new System.EventHandler(this.kolorToolStripMenuItem_Click);
//
// siticoneButton_Tab
//
this.siticoneButton_Tab.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Tab.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Tab.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_Tab.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_Tab.FillColor = System.Drawing.Color.Olive;
this.siticoneButton_Tab.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_Tab.ForeColor = System.Drawing.Color.White;
this.siticoneButton_Tab.Location = new System.Drawing.Point(484, 41);
this.siticoneButton_Tab.Name = "siticoneButton_Tab";
this.siticoneButton_Tab.Size = new System.Drawing.Size(119, 26);
this.siticoneButton_Tab.TabIndex = 13;
this.siticoneButton_Tab.Text = "Tabela";
//
// siticoneButton_Kal
//
this.siticoneButton_Kal.DisabledState.BorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Kal.DisabledState.CustomBorderColor = System.Drawing.Color.DarkGray;
this.siticoneButton_Kal.DisabledState.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(169)))), ((int)(((byte)(169)))), ((int)(((byte)(169)))));
this.siticoneButton_Kal.DisabledState.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(141)))), ((int)(((byte)(141)))));
this.siticoneButton_Kal.Font = new System.Drawing.Font("Segoe UI", 9F);
this.siticoneButton_Kal.ForeColor = System.Drawing.Color.White;
this.siticoneButton_Kal.Location = new System.Drawing.Point(611, 41);
this.siticoneButton_Kal.Name = "siticoneButton_Kal";
this.siticoneButton_Kal.Size = new System.Drawing.Size(119, 26);
this.siticoneButton_Kal.TabIndex = 14;
this.siticoneButton_Kal.Text = "Kalkulator";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(745, 492);
this.Controls.Add(this.siticoneButton_Kal);
this.Controls.Add(this.siticoneButton_Tab);
this.Controls.Add(this.siticoneButton_K);
this.Controls.Add(this.siticoneButton_W);
this.Controls.Add(this.siticoneButton_S);
this.Controls.Add(this.siticoneButton_L);
this.Controls.Add(this.siticoneButton_P);
this.Controls.Add(this.siticoneButton_PDF);
this.Controls.Add(this.siticoneButton_Druk);
this.Controls.Add(this.siticoneButton_U);
this.Controls.Add(this.siticoneButton_I);
this.Controls.Add(this.siticoneButton_B);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.menuStrip2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Notatnik";
this.Load += new System.EventHandler(this.Form1_Load);
this.menuStrip2.ResumeLayout(false);
this.menuStrip2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
private void justowanieToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(richTextBox1.SelectedText))
{
string selectedText = richTextBox1.SelectedRtf;
// Dodaj kod RTF dla justowania
selectedText = selectedText.Replace(@"\pard", @"\pard\qj"); // \qj oznacza justowanie
richTextBox1.SelectedRtf = selectedText;
}
else
{
MessageBox.Show("Zaznacz tekst, aby zastosować justowanie.", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void wyrównanieToolStripMenuItem_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.MenuStrip menuStrip2;
private System.Windows.Forms.ToolStripMenuItem plikToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem nowyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem otwórzToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem zapiszToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem zamknijToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem edycjaToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem kopiujToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem wklejToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem wytnijToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem formatowanieToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem WygladCzcionkiToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem wyrównanieToolStripMenuItem;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.FontDialog fontDialog1;
private System.Windows.Forms.ToolStripMenuItem prawaToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem lewaToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem środekToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem justowanieToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem kolorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem widokToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem zawijajWierszeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem usuToolStripMenuItem;
private ToolStripMenuItem oMnieToolStripMenuItem;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_B;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_I;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_U;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_Druk;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_PDF;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_P;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_L;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_S;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_W;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_K;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_Tab;
private Siticone.Desktop.UI.WinForms.SiticoneButton siticoneButton_Kal;
}
}
form.designer
namespace WorldClock
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label lblLondon;
private System.Windows.Forms.Label lblBeijing;
private System.Windows.Forms.Label lblTokyo;
private System.Windows.Forms.Label lblNewYork;
private System.Windows.Forms.Label lblRio;
private System.Windows.Forms.Label lblWarsaw;
private System.Windows.Forms.Label lblSydney;
private System.Windows.Forms.Label lblGoiania;
private System.Windows.Forms.Label lblJohannesburg;
private System.Windows.Forms.Label lblMoscow;
private System.Windows.Forms.Label lblUserLocation;
private System.Windows.Forms.Label lblDateTime;
private System.Windows.Forms.PictureBox pictureBox1;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
timer1 = new System.Windows.Forms.Timer(components);
lblLondon = new Label();
lblBeijing = new Label();
lblTokyo = new Label();
lblNewYork = new Label();
lblRio = new Label();
lblWarsaw = new Label();
lblSydney = new Label();
lblGoiania = new Label();
lblJohannesburg = new Label();
lblMoscow = new Label();
lblUserLocation = new Label();
lblDateTime = new Label();
pictureBox1 = new PictureBox();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
// timer1
//
timer1.Interval = 1000;
timer1.Tick += Timer1_Tick;
//
// lblLondon
//
lblLondon.BackColor = Color.Transparent;
lblLondon.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblLondon.Location = new Point(371, 305);
lblLondon.Name = "lblLondon";
lblLondon.Size = new Size(145, 19);
lblLondon.TabIndex = 0;
lblLondon.Text = "London:";
//
// lblBeijing
//
lblBeijing.BackColor = Color.Transparent;
lblBeijing.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblBeijing.Location = new Point(635, 320);
lblBeijing.Name = "lblBeijing";
lblBeijing.Size = new Size(145, 22);
lblBeijing.TabIndex = 1;
lblBeijing.Text = "Beijing:";
//
// lblTokyo
//
lblTokyo.BackColor = Color.Transparent;
lblTokyo.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblTokyo.Location = new Point(726, 355);
lblTokyo.Name = "lblTokyo";
lblTokyo.Size = new Size(145, 22);
lblTokyo.TabIndex = 2;
lblTokyo.Text = "Tokyo:";
//
// lblNewYork
//
lblNewYork.BackColor = Color.Transparent;
lblNewYork.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblNewYork.Location = new Point(180, 336);
lblNewYork.Name = "lblNewYork";
lblNewYork.Size = new Size(174, 19);
lblNewYork.TabIndex = 3;
lblNewYork.Text = "New York:";
//
// lblRio
//
lblRio.BackColor = Color.Transparent;
lblRio.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblRio.Location = new Point(249, 424);
lblRio.Name = "lblRio";
lblRio.Size = new Size(199, 19);
lblRio.TabIndex = 4;
lblRio.Text = "Rio de Janeiro:";
//
// lblWarsaw
//
lblWarsaw.BackColor = Color.Transparent;
lblWarsaw.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblWarsaw.Location = new Point(401, 346);
lblWarsaw.Name = "lblWarsaw";
lblWarsaw.Size = new Size(145, 19);
lblWarsaw.TabIndex = 5;
lblWarsaw.Text = "Warsaw:";
//
// lblSydney
//
lblSydney.BackColor = Color.Transparent;
lblSydney.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblSydney.Location = new Point(770, 439);
lblSydney.Name = "lblSydney";
lblSydney.Size = new Size(145, 22);
lblSydney.TabIndex = 6;
lblSydney.Text = "Sydney:";
//
// lblGoiania
//
lblGoiania.BackColor = Color.Transparent;
lblGoiania.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblGoiania.Location = new Point(52, 421);
lblGoiania.Name = "lblGoiania";
lblGoiania.Size = new Size(177, 22);
lblGoiania.TabIndex = 7;
lblGoiania.Text = "Goiânia:";
//
// lblJohannesburg
//
lblJohannesburg.BackColor = Color.Transparent;
lblJohannesburg.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblJohannesburg.Location = new Point(469, 443);
lblJohannesburg.Name = "lblJohannesburg";
lblJohannesburg.Size = new Size(209, 18);
lblJohannesburg.TabIndex = 8;
lblJohannesburg.Text = "Johannesburg:";
//
// lblMoscow
//
lblMoscow.BackColor = Color.Transparent;
lblMoscow.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblMoscow.Location = new Point(509, 324);
lblMoscow.Name = "lblMoscow";
lblMoscow.Size = new Size(145, 18);
lblMoscow.TabIndex = 9;
lblMoscow.Text = "Moscow:";
//
// lblUserLocation
//
lblUserLocation.BackColor = Color.Transparent;
lblUserLocation.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblUserLocation.Location = new Point(12, 83);
lblUserLocation.Name = "lblUserLocation";
lblUserLocation.Size = new Size(182, 146);
lblUserLocation.TabIndex = 10;
lblUserLocation.Text = "Weather in your location:";
//
// lblDateTime
//
lblDateTime.BackColor = Color.Transparent;
lblDateTime.Font = new Font("Segoe UI", 9F, FontStyle.Bold);
lblDateTime.Location = new Point(12, 9);
lblDateTime.Name = "lblDateTime";
lblDateTime.Size = new Size(182, 58);
lblDateTime.TabIndex = 11;
lblDateTime.Text = "Date and Time:";
//
// pictureBox1
//
pictureBox1.Dock = DockStyle.Fill;
pictureBox1.Image = Properties.Resources.mapa12;
pictureBox1.Location = new Point(0, 0);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(927, 643);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.TabIndex = 12;
pictureBox1.TabStop = false;
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(927, 643);
Controls.Add(lblLondon);
Controls.Add(lblBeijing);
Controls.Add(lblTokyo);
Controls.Add(lblNewYork);
Controls.Add(lblRio);
Controls.Add(lblWarsaw);
Controls.Add(lblSydney);
Controls.Add(lblGoiania);
Controls.Add(lblJohannesburg);
Controls.Add(lblMoscow);
Controls.Add(lblUserLocation);
Controls.Add(lblDateTime);
Controls.Add(pictureBox1);
Name = "Form1";
Text = "World Clock";
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
ResumeLayout(false);
}
}
}
###########################
Form1.cs
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WorldClock
{
public partial class Form1 : Form
{
private static readonly HttpClient httpClient = new HttpClient();
private const string openWeatherMapApiKey = "204b273b0d7ec4bb3ba3cf56dc03cc98"; // Twój klucz API OpenWeatherMap
private const string newsApiKey = "b183fe14e9a0444dbf1258b2b4ef769d"; // Twój klucz API NewsAPI
private float originalWidth;
private float originalHeight;
private Panel infoPanel; // Panel dla informacji o miastach
private TableLayoutPanel infoTable;
public Form1()
{
InitializeComponent();
InitializeInfoPanel();
timer1.Interval = 1000; // Aktualizacja co sekundę
timer1.Tick += Timer1_Tick;
timer1.Start();
originalWidth = this.Width;
originalHeight = this.Height;
this.Resize += Form1_Resize;
// Dodaj zdarzenia kliknięcia dla miast
lblLondon.Click += CityLabel_Click;
lblBeijing.Click += CityLabel_Click;
lblTokyo.Click += CityLabel_Click;
lblNewYork.Click += CityLabel_Click;
lblRio.Click += CityLabel_Click;
lblWarsaw.Click += CityLabel_Click;
lblSydney.Click += CityLabel_Click;
lblGoiania.Click += CityLabel_Click;
lblJohannesburg.Click += CityLabel_Click;
lblMoscow.Click += CityLabel_Click;
// Wczytaj dane pogodowe dla Działdowa
LoadWeatherData();
}
private void Timer1_Tick(object sender, EventArgs e)
{
lblLondon.Text = "London: " + TimeInCity("GMT Standard Time");
lblBeijing.Text = "Beijing: " + TimeInCity("China Standard Time");
lblTokyo.Text = "Tokyo: " + TimeInCity("Tokyo Standard Time");
lblNewYork.Text = "New York: " + TimeInCity("Eastern Standard Time");
lblRio.Text = "Rio de Janeiro: " + TimeInCity("E. South America Standard Time");
lblWarsaw.Text = "Warsaw: " + TimeInCity("Central European Standard Time");
lblSydney.Text = "Sydney: " + TimeInCity("AUS Eastern Standard Time");
lblGoiania.Text = "Goiânia: " + TimeInCity("E. South America Standard Time");
lblJohannesburg.Text = "Johannesburg: " + TimeInCity("South Africa Standard Time");
lblMoscow.Text = "Moscow: " + TimeInCity("Russian Standard Time");
lblDateTime.Text = "Date: " + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss");
}
private string TimeInCity(string timeZoneId)
{
try
{
var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
var timeInCity = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, timeZone);
return timeInCity.ToString("HH:mm:ss");
}
catch
{
return "Time zone not found";
}
}
private async void LoadWeatherData()
{
try
{
string userCity = "Działdowo"; // Wymuszenie Działdowa
string weatherData = await GetWeatherData(userCity);
// Wyświetlanie szczegółowych danych pogodowych
lblUserLocation.Text = weatherData;
}
catch (Exception ex)
{
lblUserLocation.Text = "Weather data not available";
Console.WriteLine($"Error in LoadWeatherData: {ex.Message}");
}
}
private async Task<string> GetWeatherData(string city)
{
try
{
string url = $"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={openWeatherMapApiKey}&units=metric";
HttpResponseMessage response = await httpClient.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
using var json = JsonDocument.Parse(responseBody);
JsonElement root = json.RootElement;
// Pobranie szczegółowych danych pogodowych
string location = root.GetProperty("name").GetString();
double temperature = root.GetProperty("main").GetProperty("temp").GetDouble();
double feelsLike = root.GetProperty("main").GetProperty("feels_like").GetDouble();
int humidity = root.GetProperty("main").GetProperty("humidity").GetInt32();
double windSpeed = root.GetProperty("wind").GetProperty("speed").GetDouble();
// Komponowanie danych pogodowych
return $"Weather in {location}:\n" +
$"Temperature: {temperature}°C (feels like {feelsLike}°C)\n" +
$"Humidity: {humidity}%\n" +
$"Wind Speed: {windSpeed} m/s";
}
catch (Exception ex)
{
Console.WriteLine($"Error in GetWeatherData: {ex.Message}");
return "Weather data not available";
}
}
private async Task<List<string>> GetCityNews(string city)
{
string url = $"https://newsapi.org/v2/everything?q={city}&apiKey={newsApiKey}";
try
{
HttpResponseMessage response = await httpClient.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"API Response for {city}: {responseBody}"); // Debugowanie odpowiedzi
using var json = JsonDocument.Parse(responseBody);
// Sprawdzamy, czy odpowiedź zawiera artykuły
if (json.RootElement.TryGetProperty("articles", out JsonElement articles) && articles.GetArrayLength() > 0)
{
List<string> news = new List<string>();
foreach (var article in articles.EnumerateArray())
{
if (article.TryGetProperty("title", out JsonElement title))
{
news.Add(title.GetString());
}
if (news.Count >= 5) break; // Pobierz maksymalnie 5 wiadomości
}
return news;
}
Console.WriteLine("No articles found in the API response.");
return new List<string> { "No news available" };
}
catch (Exception ex)
{
Console.WriteLine($"Error in GetCityNews: {ex.Message}");
return new List<string> { "No news available" };
}
}
private async void ShowCityInfo(string city)
{
try
{
string weatherData = await GetWeatherData(city);
List<string> news = await GetCityNews(city);
if (news.Count == 0 || (news.Count == 1 && news[0] == "No news available"))
{
Console.WriteLine($"No news found for city: {city}");
}
else
{
Console.WriteLine($"News found for city: {city}");
}
UpdateInfoPanel(city, weatherData, news);
}
catch (Exception ex)
{
Console.WriteLine($"Error loading data for {city}: {ex.Message}");
}
}
private void InitializeInfoPanel()
{
infoPanel = new Panel
{
Size = new Size(this.Width / 2, 200), // Maksymalnie 50% szerokości okna
Location = new Point(this.Width / 4, 20), // Wyśrodkowanie w poziomie
BackColor = Color.FromArgb(128, 255, 255, 255), // Półprzezroczysty biały
BorderStyle = BorderStyle.FixedSingle,
AutoScroll = true // Dodanie przewijania
};
infoTable = new TableLayoutPanel
{
Dock = DockStyle.Fill,
ColumnCount = 2,
AutoSize = true
};
infoTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
infoTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
infoPanel.Controls.Add(infoTable);
Controls.Add(infoPanel);
infoPanel.BringToFront();
}
private void UpdateInfoPanel(string city, string weather, List<string> news)
{
infoTable.Controls.Clear();
// Dodaj informacje o mieście i pogodzie
AddRowToTable("City", city);
AddRowToTable("Weather", weather);
// Dodaj wiadomości lokalne
if (news.Count == 1 && news[0] == "No news available")
{
AddRowToTable("Local News", "No news available");
}
else
{
AddRowToTable("Local News", string.Join("\n- ", news));
}
infoPanel.Visible = true;
}
private void AddRowToTable(string label, string value)
{
infoTable.Controls.Add(new Label
{
Text = label,
Font = new Font("Segoe UI", 10F, FontStyle.Bold),
AutoSize = true
});
infoTable.Controls.Add(new Label
{
Text = value,
Font = new Font("Segoe UI", 10F),
AutoSize = true
});
}
private void Form1_Resize(object sender, EventArgs e)
{
float widthRatio = this.Width / originalWidth;
float heightRatio = this.Height / originalHeight;
foreach (Control control in Controls)
{
if (control is Label && control != lblUserLocation && control != lblDateTime)
{
control.Left = (int)(control.Left * widthRatio);
control.Top = (int)(control.Top * heightRatio);
control.Width = (int)(control.Width * widthRatio);
control.Height = (int)(control.Height * heightRatio);
}
}
originalWidth = this.Width;
originalHeight = this.Height;
}
private void CityLabel_Click(object sender, EventArgs e)
{
if (sender is Label lblCity)
{
string city = lblCity.Text.Split(':')[0];
Console.WriteLine($"City clicked: {city}");
ShowCityInfo(city);
}
}
}
}