Feladat2 done
This commit is contained in:
32
Feladat1/UI/MainWindow/LineDrawer.cs
Normal file
32
Feladat1/UI/MainWindow/LineDrawer.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Gdk;
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Feladat1.UI.MainWindow;
|
||||||
|
|
||||||
|
public partial class MainWindow
|
||||||
|
{
|
||||||
|
private DrawingArea canvas;
|
||||||
|
private const string canvasId = "canvas";
|
||||||
|
|
||||||
|
private Adjustment lineWidthAdjustment;
|
||||||
|
private const string lineWidthAdjustmentId = "adjustment";
|
||||||
|
|
||||||
|
private double[] pointX = { 100, 100 };
|
||||||
|
private double[] pointY = {200, 200};
|
||||||
|
private double lineWidth = 5;
|
||||||
|
|
||||||
|
private void Draw(DrawingArea drawingArea, Cairo.Context cr, int width, int height)
|
||||||
|
{
|
||||||
|
cr.SetSourceRgb(1, 1, 1);
|
||||||
|
|
||||||
|
cr.Arc(pointX[0], pointX[1], 10, 0, 2 * Math.PI);
|
||||||
|
cr.Arc(pointY[0], pointY[1], 10, 0, 2 * Math.PI);
|
||||||
|
cr.Fill();
|
||||||
|
|
||||||
|
cr.LineWidth = lineWidth;
|
||||||
|
cr.MoveTo(pointX[0], pointX[1]);
|
||||||
|
cr.LineTo(pointY[0], pointY[1]);
|
||||||
|
|
||||||
|
cr.Stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
using Adw;
|
using Adw;
|
||||||
|
using Gtk;
|
||||||
using Logic;
|
using Logic;
|
||||||
using Models;
|
using Models;
|
||||||
|
|
||||||
namespace Feladat1.UI.MainWindow;
|
namespace Feladat1.UI.MainWindow;
|
||||||
|
|
||||||
public class MainWindow
|
public partial class MainWindow
|
||||||
{
|
{
|
||||||
private ToastOverlay toastOverlay;
|
private ToastOverlay toastOverlay;
|
||||||
private const string toastOverlayId = "toast_overlay";
|
private const string toastOverlayId = "toast_overlay";
|
||||||
@@ -12,7 +13,7 @@ public class MainWindow
|
|||||||
private IUserService userService;
|
private IUserService userService;
|
||||||
private const string windowId = "main_window";
|
private const string windowId = "main_window";
|
||||||
|
|
||||||
public Window Window;
|
public Adw.Window Window;
|
||||||
|
|
||||||
private Gtk.Button saveBtn;
|
private Gtk.Button saveBtn;
|
||||||
private const string saveBtnId = "save_btn";
|
private const string saveBtnId = "save_btn";
|
||||||
@@ -35,12 +36,36 @@ public class MainWindow
|
|||||||
private PasswordEntryRow passwordLabel;
|
private PasswordEntryRow passwordLabel;
|
||||||
private const string passwordLabelId = "passwordLabel";
|
private const string passwordLabelId = "passwordLabel";
|
||||||
|
|
||||||
|
private Button leftUpArrow;
|
||||||
|
private const string leftUpArrowId = "leftUpArrow";
|
||||||
|
|
||||||
|
private Button rightUpArrow;
|
||||||
|
private const string rightUpArrowId = "rightUpArrow";
|
||||||
|
|
||||||
|
private Button leftDownArrow;
|
||||||
|
private const string leftDownArrowId = "leftDownArrow";
|
||||||
|
|
||||||
|
private Button rightDownArrow;
|
||||||
|
private const string rightDownArrowId = "rightDownArrow";
|
||||||
|
|
||||||
|
private Button leftLeftArrow;
|
||||||
|
private const string leftLeftArrowId = "leftLeftArrow";
|
||||||
|
|
||||||
|
private Button rightLeftArrow;
|
||||||
|
private const string rightLeftArrowId = "rightLeftArrow";
|
||||||
|
|
||||||
|
private Button leftRightArrow;
|
||||||
|
private const string leftRightArrowId = "leftRightArrow";
|
||||||
|
|
||||||
|
private Button rightRightArrow;
|
||||||
|
private const string rightRightArrowId = "rightRightArrow";
|
||||||
|
|
||||||
public MainWindow(IUserService userService)
|
public MainWindow(IUserService userService)
|
||||||
{
|
{
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
var builder = new Gtk.Builder("Feladat1.UI.MainWindow.MainWindow.ui.xml");
|
var builder = new Gtk.Builder("Feladat1.UI.MainWindow.MainWindow.ui.xml");
|
||||||
|
|
||||||
Window = builder.GetObject(windowId) as Window;
|
Window = builder.GetObject(windowId) as Adw.Window;
|
||||||
if (Window == null)
|
if (Window == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Failed to load embedded resource MainWindow.ui.xml");
|
throw new Exception("Failed to load embedded resource MainWindow.ui.xml");
|
||||||
@@ -96,6 +121,112 @@ public class MainWindow
|
|||||||
{
|
{
|
||||||
throw new NullReferenceException(toastOverlayId);
|
throw new NullReferenceException(toastOverlayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canvas = builder.GetObject(canvasId) as DrawingArea;
|
||||||
|
if (canvas == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(canvasId);
|
||||||
|
}
|
||||||
|
canvas.SetDrawFunc(Draw);
|
||||||
|
|
||||||
|
lineWidthAdjustment = builder.GetObject(lineWidthAdjustmentId) as Adjustment;
|
||||||
|
if (lineWidthAdjustment == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(lineWidthAdjustmentId);
|
||||||
|
}
|
||||||
|
lineWidthAdjustment.OnValueChanged += (sender, args) =>
|
||||||
|
{
|
||||||
|
lineWidth = lineWidthAdjustment.Value;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
leftUpArrow = builder.GetObject(leftUpArrowId) as Button;
|
||||||
|
if (leftUpArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(leftUpArrowId);
|
||||||
|
}
|
||||||
|
leftUpArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointX[1] -= 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
rightUpArrow = builder.GetObject(rightUpArrowId) as Button;
|
||||||
|
if (rightUpArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(rightUpArrowId);
|
||||||
|
}
|
||||||
|
rightUpArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointY[1] -= 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
leftDownArrow = builder.GetObject(leftDownArrowId) as Button;
|
||||||
|
if (leftDownArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(leftDownArrowId);
|
||||||
|
}
|
||||||
|
leftDownArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointX[1] += 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
rightDownArrow = builder.GetObject(rightDownArrowId) as Button;
|
||||||
|
if (rightDownArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(rightDownArrowId);
|
||||||
|
}
|
||||||
|
rightDownArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointY[1] += 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
leftLeftArrow = builder.GetObject(leftLeftArrowId) as Button;
|
||||||
|
if (leftLeftArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(leftLeftArrowId);
|
||||||
|
}
|
||||||
|
leftLeftArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointX[0] -= 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
rightLeftArrow = builder.GetObject(rightLeftArrowId) as Button;
|
||||||
|
if (rightLeftArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(rightLeftArrowId);
|
||||||
|
}
|
||||||
|
rightLeftArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointY[0] -= 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
leftRightArrow = builder.GetObject(leftRightArrowId) as Button;
|
||||||
|
if (leftRightArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(leftRightArrowId);
|
||||||
|
}
|
||||||
|
leftRightArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointX[0] += 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
rightRightArrow = builder.GetObject(rightRightArrowId) as Button;
|
||||||
|
if (rightRightArrow == null)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException(rightRightArrowId);
|
||||||
|
}
|
||||||
|
rightRightArrow.OnClicked += (sender, args) =>
|
||||||
|
{
|
||||||
|
pointY[0] += 5;
|
||||||
|
canvas.QueueDraw();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
catch (NullReferenceException e)
|
catch (NullReferenceException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,111 +1,231 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<object class="AdwWindow" id="main_window">
|
<object class="GtkAdjustment" id="adjustment">
|
||||||
<property name="width-request">300</property>
|
<property name="upper">20</property>
|
||||||
<property name="height-request">300</property>
|
<property name="lower">1</property>
|
||||||
<property name="default-width">400</property>
|
<property name="value">5</property>
|
||||||
<property name="default-height">400</property>
|
<property name="step-increment">0.1</property>
|
||||||
<property name="content">
|
<property name="page-increment">1</property>
|
||||||
<object class="AdwToastOverlay" id="toast_overlay">
|
</object>
|
||||||
<property name="child">
|
<object class="AdwWindow" id="main_window">
|
||||||
<object class="AdwToolbarView">
|
<property name="width-request">300</property>
|
||||||
<child type="top">
|
<property name="height-request">300</property>
|
||||||
<object class="AdwHeaderBar" id="header_bar">
|
<property name="default-width">400</property>
|
||||||
<property name="title-widget">
|
<property name="default-height">400</property>
|
||||||
<object class="AdwViewSwitcher">
|
<property name="content">
|
||||||
<property name="stack">stack</property>
|
<object class="AdwToastOverlay" id="toast_overlay">
|
||||||
<property name="policy">wide</property>
|
<property name="child">
|
||||||
</object>
|
<object class="AdwToolbarView">
|
||||||
</property>
|
<child type="top">
|
||||||
</object>
|
<object class="AdwHeaderBar" id="header_bar">
|
||||||
</child>
|
<property name="title-widget">
|
||||||
<property name="content">
|
<object class="AdwViewSwitcher">
|
||||||
<object class="AdwViewStack" id="stack">
|
<property name="stack">stack</property>
|
||||||
<property name="enable-transitions">True</property>
|
<property name="policy">wide</property>
|
||||||
<child>
|
</object>
|
||||||
<object class="AdwViewStackPage">
|
</property>
|
||||||
<property name="name">save</property>
|
</object>
|
||||||
<property name="icon-name">document-save-as-symbolic</property>
|
</child>
|
||||||
<property name="title">Save</property>
|
<property name="content">
|
||||||
<property name="child">
|
<object class="AdwViewStack" id="stack">
|
||||||
<object class="AdwPreferencesPage">
|
<property name="enable-transitions">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwViewStackPage">
|
||||||
<child>
|
<property name="name">save</property>
|
||||||
<object class="AdwEntryRow" id="email">
|
<property name="icon-name">document-save-as-symbolic</property>
|
||||||
<property name="title">Email</property>
|
<property name="title">Save</property>
|
||||||
</object>
|
<property name="child">
|
||||||
</child>
|
<object class="AdwPreferencesPage">
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwEntryRow" id="username">
|
<object class="AdwPreferencesGroup">
|
||||||
<property name="title">Felhasználónév</property>
|
<child>
|
||||||
</object>
|
<object class="AdwEntryRow" id="email">
|
||||||
</child>
|
<property name="title">Email</property>
|
||||||
<child>
|
</object>
|
||||||
<object class="AdwPasswordEntryRow" id="password">
|
</child>
|
||||||
<property name="title">Jelszó</property>
|
<child>
|
||||||
</object>
|
<object class="AdwEntryRow" id="username">
|
||||||
</child>
|
<property name="title">Felhasználónév</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="save_btn">
|
<object class="AdwPasswordEntryRow" id="password">
|
||||||
<style>
|
<property name="title">Jelszó</property>
|
||||||
<class name="suggested-action" />
|
</object>
|
||||||
</style>
|
</child>
|
||||||
<property name="label">Exportálás</property>
|
</object>
|
||||||
<property name="valign">center</property>
|
</child>
|
||||||
<property name="halign">center</property>
|
<child>
|
||||||
</object>
|
<object class="GtkButton" id="save_btn">
|
||||||
</child>
|
<style>
|
||||||
</object>
|
<class name="suggested-action" />
|
||||||
</property>
|
</style>
|
||||||
</object>
|
<property name="label">Exportálás</property>
|
||||||
</child>
|
<property name="valign">center</property>
|
||||||
<child>
|
<property name="halign">center</property>
|
||||||
<object class="AdwViewStackPage">
|
</object>
|
||||||
<property name="name">load</property>
|
</child>
|
||||||
<property name="title">Load</property>
|
</object>
|
||||||
<property name="icon-name">document-open-symbolic</property>
|
</property>
|
||||||
<property name="child">
|
</object>
|
||||||
<object class="AdwPreferencesPage">
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup">
|
<object class="AdwViewStackPage">
|
||||||
<child>
|
<property name="name">load</property>
|
||||||
<object class="AdwEntryRow" id="emailLabel">
|
<property name="title">Load</property>
|
||||||
<property name="title">Email</property>
|
<property name="icon-name">document-open-symbolic</property>
|
||||||
<property name="editable">False</property>
|
<property name="child">
|
||||||
</object>
|
<object class="AdwPreferencesPage">
|
||||||
</child>
|
<child>
|
||||||
<child>
|
<object class="AdwPreferencesGroup">
|
||||||
<object class="AdwEntryRow" id="usernameLabel">
|
<child>
|
||||||
<property name="title">Felhasználónév</property>
|
<object class="AdwEntryRow" id="emailLabel">
|
||||||
<property name="editable">False</property>
|
<property name="title">Email</property>
|
||||||
<property name="activatable">False</property>
|
<property name="editable">False</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPasswordEntryRow" id="passwordLabel">
|
<object class="AdwEntryRow" id="usernameLabel">
|
||||||
<property name="title">Jelszó</property>
|
<property name="title">Felhasználónév</property>
|
||||||
<property name="editable">False</property>
|
<property name="editable">False</property>
|
||||||
</object>
|
<property name="activatable">False</property>
|
||||||
</child>
|
</object>
|
||||||
</object>
|
</child>
|
||||||
</child>
|
<child>
|
||||||
</object>
|
<object class="AdwPasswordEntryRow" id="passwordLabel">
|
||||||
</property>
|
<property name="title">Jelszó</property>
|
||||||
</object>
|
<property name="editable">False</property>
|
||||||
</child>
|
</object>
|
||||||
</object>
|
</child>
|
||||||
</property>
|
</object>
|
||||||
<child type="bottom">
|
</child>
|
||||||
<object class="AdwViewSwitcherBar" id="switcher_bar">
|
</object>
|
||||||
<property name="stack">stack</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
<child>
|
||||||
</property>
|
<object class="AdwViewStackPage">
|
||||||
</object>
|
<property name="name">lines</property>
|
||||||
</property>
|
<property name="title">Lines</property>
|
||||||
</object>
|
<property name="icon-name">function-linear-symbolic</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkDrawingArea" id="canvas">
|
||||||
|
<property name="width-request">250</property>
|
||||||
|
<property name="height-request">250</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="leftUpArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">↑</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="leftLeftArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">←</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="leftDownArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">↓</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="leftRightArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">→</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="rightUpArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">↑</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="rightLeftArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">←</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="rightDownArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">↓</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="rightRightArrow">
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label">→</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkScale" id="scale_plain">
|
||||||
|
<property name="draw-value">0</property>
|
||||||
|
<property name="adjustment">adjustment</property>
|
||||||
|
<property name="margin-start">50</property>
|
||||||
|
<property name="margin-end">50</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
</layout>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<child type="bottom">
|
||||||
|
<object class="AdwViewSwitcherBar" id="switcher_bar">
|
||||||
|
<property name="stack">stack</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
Reference in New Issue
Block a user