Пример #1
0
        public EventEditorPanel(IPanel caller, EventFull @event, bool draft = false)
        {
            this.draft  = draft;
            this.caller = caller;

            InitializeComponent();

            Text             = "Edit event";
            this.@event      = @event;
            headerLabel.Text = "Edit event information";

            FillInSports();
            FillInBoxes();
            FillInPhotos();

            UserAccount acc = Program.UserDataManager.UserAccount;

            if (draft)
            {
                finishButton.Text        = "Create";
                finishButton.Click      += CreateEvent;
                deleteEventButton.Text   = "Save as draft";
                deleteEventButton.Click += SaveDraft;

                if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
                {
                    finishButton.Visible = false;
                }
            }
            else
            {
                finishButton.Text           = "Save";
                finishButton.Click         += EditEvent;
                deleteEventButton.Text      = "Delete event";
                deleteEventButton.Click    += DeleteEvent;
                deleteEventButton.BackColor = Color.Tomato;

                if (@event.Author == acc.Id)
                {
                    if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
                    {
                        finishButton.Visible = false;
                    }
                }
                else
                {
                    if (!acc.Can((uint)Permissions.EDIT_OTHER_EVENTS))
                    {
                        finishButton.Visible = false;
                    }
                    if (!acc.Can((uint)Permissions.DELETE_OTHER_EVENTS))
                    {
                        deleteEventButton.Visible = false;
                    }
                }
            }

            // Set maps button image
            checkAddressButton.BackgroundImage = Properties.Resources.MapsButton;
        }
Пример #2
0
        public EventEditorPanel(IPanel caller)
        {
            this.draft  = false;
            this.caller = caller;

            InitializeComponent();
            FillInSports();
            FillInPhotos();
            headerLabel.Text    = "Create event";
            finishButton.Text   = "Create";
            finishButton.Click += CreateEvent;

            deleteEventButton.Text   = "Save as draft";
            deleteEventButton.Click += SaveDraft;

            UserAccount acc = Program.UserDataManager.UserAccount;

            if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
            {
                finishButton.Visible = false;
            }

            // Set maps button image
            checkAddressButton.BackgroundImage = Properties.Resources.MapsButton;
        }
Пример #3
0
        public void ShowAccount()
        {
            if (selectedAccount == null)
            {
                accountInfoPanel.Visible = false;
                return;
            }

            accountInfoPanel.Visible = true;
            usernameLabel.Text       = selectedAccount.Username;

            UserAccount user = Program.UserDataManager.UserAccount;

            if (!user.Can((uint)Permissions.SILENCE_ACCOUNTS))
            {
                silenceButton.Visible = false;
            }
            if (!user.Can((uint)Permissions.BAN_ACCOUNTS))
            {
                banButton.Visible = false;
            }
            if (!user.Can((uint)Permissions.DELETE_ACCOUNTS))
            {
                deleteButton.Visible = false;
            }

            if (selectedAccount.Can((uint)Permissions.SEND_CHAT_MESSAGES))
            {
                silenceButton.Text = "Silence";
            }
            else
            {
                silenceButton.Text = "Unsilence";
            }

            if (!selectedAccount.Can((uint)Permissions.BANNED))
            {
                banButton.Text = "Ban";
            }
            else
            {
                banButton.Text = "Unban";
            }
        }
Пример #4
0
        private void silenceButton_Click(object sender, EventArgs e)
        {
            if (selectedAccount == null)
            {
                return;
            }

            if (selectedAccount.Can((uint)Permissions.SEND_CHAT_MESSAGES))
            {
                Program.Client.SilenceAccount(selectedAccount.Id);
                silenceButton.Text = "Unsilence";
            }
            else
            {
                Program.Client.UnsilenceAccount(selectedAccount.Id);
                silenceButton.Text = "Silence";
            }

            LoadAccounts();
            accountInfoPanel.Visible = false;
            mainForm.FitCurrentPanel();
        }
Пример #5
0
        public UiEventDisplayPanel(int eventId, IPanel caller)
        {
            // Get full event data from database
            List <EventFull> events = Program.Client.SelectEventsFull(eventId);

            try
            {
                @event = events[0];
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine($"ERROR: Event with id {eventId} not found");
                throw;
            }

            UserAccount acc = Program.UserDataManager.UserAccount;

            this.caller = caller;

            InitializeComponent();

            // Set return button image
            returnButton.BackgroundImage = Properties.Resources.BackButtonGreen;

            // Enforce permissions
            if (!acc.Can((uint)Permissions.CREATE_REPORTS))
            {
                reportButton.Visible = false;
            }
            if (acc.Can((uint)Permissions.SET_EVENT_VISIBILITY))
            {
                setVisibilityButton.Visible = true;
                if ([email protected])
                {
                    setVisibilityButton.BackColor = Color.FromArgb(109, 168, 135);
                    setVisibilityButton.Text      = "Make visible";
                }
                else
                {
                    setVisibilityButton.BackColor = Color.Tomato;
                    setVisibilityButton.Text      = "Make invisible";
                }
            }
            if (!acc.Can((uint)Permissions.SEND_CHAT_MESSAGES))
            {
                if (acc.Id == -1)
                {
                    chatMessageTextBox.PlaceholderText = "Log in to comment";
                    chatMessageTextBox.Enabled         = false;
                }
                else
                {
                    chatMessageTextBox.PlaceholderText = "You don't have the permission to comment";
                    chatMessageTextBox.Enabled         = false;
                }
            }

            // Title
            eventName.Text = @event.Name;

            // Sports
            foreach (var sport in @event.Sports)
            {
                Label sportLabel = new Label();
                sportLabel.AutoSize  = true;
                sportLabel.Text      = sport;
                sportLabel.BackColor = Color.FromArgb(230, 230, 230);
                sportLabel.Font      = new Font("Arial", 12, FontStyle.Bold);
                //sportDisplayBar.Controls.Add(sportLabel);
            }

            // Distance
            UserData user     = Program.UserDataManager.GetData();
            double   distance = MathSupplement.Distance(@event.Latitude, @event.Longitude, user.Latitude, user.Longitude);

            if (distance < 1000.0)
            {
                distanceLabel.Text = $"{distance:0}m";
            }
            else
            {
                distanceLabel.Text = $"{distance / 1000.0:0.0}km";
            }

            // Distance and address separator
            Size distanceLabelSize = Helper.CalculateLabelSize(distanceLabel, 100);

            separatorPanel1.Location = new Point(distanceLabel.Location.X + distanceLabelSize.Width, separatorPanel1.Location.Y);

            // Address
            addressLabel.Location = new Point(distanceLabel.Location.X + distanceLabelSize.Width + 10, addressLabel.Location.Y);
            addressLabel.Text     = @event.Address.ToStringNormal();

            // Show map button
            Size addressLabelSize = Helper.CalculateLabelSize(addressLabel, 500);

            showMapsButton.Location        = new Point(addressLabel.Location.X + addressLabelSize.Width + 5, showMapsButton.Location.Y);
            showMapsButton.BackgroundImage = Properties.Resources.MapsButton;

            // Load images
            List <string> imageLinks = @event.Images;
            int           counter    = 0;

            foreach (var image in @event.Images)
            {
                int IMAGE_WIDTH  = 180;
                int IMAGE_HEIGHT = 180;
                int MARGINS      = 10;

                PictureBox picture = new PictureBox();
                picture.Size        = new Size(IMAGE_WIDTH, IMAGE_HEIGHT);
                picture.Location    = new Point((IMAGE_WIDTH + MARGINS) * counter, 0);
                picture.BorderStyle = BorderStyle.None;

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, e) =>
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            Stream stream = client.OpenRead(image);
                            Bitmap bitmap = new Bitmap(stream);

                            picture.Image = Helper.ScaleBitmap(bitmap, IMAGE_WIDTH, IMAGE_HEIGHT, 1.0f);

                            stream.Flush();
                            stream.Close();
                        }
                    }
                    catch { }
                };
                worker.RunWorkerAsync();

                picturePanel.Controls.Add(picture);
                counter++;
            }

            picturePanel.VerticalScroll.Maximum   = 0;
            picturePanel.AutoScroll               = false;
            picturePanel.HorizontalScroll.Visible = false;
            picturePanel.AutoScroll               = true;

            // Description
            descriptionLabel.Text = @event.Description;
            Size descriptionLabelSize = Helper.CalculateLabelSize(descriptionLabel, descriptionLabel.MaximumSize.Width);

            // Description and comment separator
            separatorPanel4.Location = new Point(separatorPanel4.Location.X, descriptionLabel.Location.Y + descriptionLabelSize.Height + 28);

            // Show reports
            List <Report> reports = Program.Client.SelectReports(eventId);

            int height = 0;

            if (reports.Count > 0)
            {
                reportsPanel.Visible   = true;
                reportsPanel.Location  = new Point(reportsPanel.Location.X, separatorPanel4.Location.Y + 10);
                reportsPanel.BackColor = Color.FromArgb(255, 200, 200);

                reportsPanel.HorizontalScroll.Maximum = 0;
                reportsPanel.AutoScroll             = false;
                reportsPanel.VerticalScroll.Visible = false;
                reportsPanel.AutoScroll             = true;

                height = 20;

                foreach (var report in reports)
                {
                    Label reportType = new Label();
                    reportType.Text      = report.Type;
                    reportType.Font      = new Font("Arial", 12, FontStyle.Bold);
                    reportType.ForeColor = Color.FromArgb(64, 64, 64);
                    reportType.Location  = new Point(0, 0);
                    reportType.AutoSize  = false;
                    reportType.Size      = new Size(940, 26);
                    reportType.TextAlign = ContentAlignment.MiddleLeft;

                    Label reportComment = new Label();
                    reportComment.Text      = report.Comment;
                    reportComment.Font      = new Font("Arial", 12);
                    reportComment.ForeColor = Color.FromArgb(64, 64, 64);
                    reportComment.Location  = new Point(0, 26);
                    reportComment.AutoSize  = false;
                    Size reportSize = Helper.CalculateLabelSize(reportComment, 940);
                    reportComment.Size      = new Size(940, reportSize.Height);
                    reportComment.TextAlign = ContentAlignment.MiddleLeft;

                    Panel reportPanel = new Panel();
                    reportPanel.Size     = new Size(940, 26 + reportComment.Size.Height);
                    reportPanel.Location = new Point(20, height);

                    height += reportPanel.Size.Height + 20;

                    reportPanel.Controls.Add(reportType);
                    reportPanel.Controls.Add(reportComment);
                    reportsPanel.Controls.Add(reportPanel);
                }

                if (height > 150)
                {
                    height = 150;
                }

                reportsPanel.Size = new Size(reportsPanel.Size.Width, height);
            }

            // Comments panel
            commentsPanel.Location = new Point(commentsPanel.Location.X, separatorPanel4.Location.Y + 10 + height + 10 * (height > 0 ? 1 : 0));

            // New comment
            chatMessageTextBox.Location = new Point(0, 0);

            // Submit new comment
            sendMessageButton.Location = new Point(sendMessageButton.Location.X, chatMessageTextBox.Location.Y + chatMessageTextBox.Size.Height + 6);

            // Chat panel
            chatPanel.Location = new Point(chatPanel.Location.X, sendMessageButton.Location.Y + sendMessageButton.Size.Height + 6);

            // Load comments
            List <Backend.Message> messages = Program.Client.SelectEventComments(@event.Id);

            messages.Reverse();

            /*
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi" +
             *  "lietuva hujon eina o algos tai irgi po jevrejo nebekyla, o vat maisto kainos tai ojojoj" +
             *  "kaip i virsu skuodzia ir va kaip man uz minimuma pragyvent blyat kai reika nauja telef" +
             *  "ona pirk kiekviena meta nu blet negerai cia",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 1,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 2,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 3,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             */

            height = 0;
            if (messages.Count > 0)
            {
                chatPanel.Controls.Clear();

                height = 20;

                foreach (var msg in messages)
                {
                    string username = Program.Client.SelectAccountUsername(msg.Sender);

                    Label senderInfoLabel = new Label();
                    senderInfoLabel.Text      = $"By {username} at {msg.SendTime:yyyy-MM-dd HH:mm}";
                    senderInfoLabel.Font      = new Font("Arial", 10, FontStyle.Italic);
                    senderInfoLabel.ForeColor = Color.Gray;
                    senderInfoLabel.Location  = new Point(0, 0);
                    senderInfoLabel.AutoSize  = false;
                    senderInfoLabel.Size      = new Size(920, 20);
                    senderInfoLabel.TextAlign = ContentAlignment.MiddleLeft;

                    Label commentLabel = new Label();
                    commentLabel.Text      = msg.Content;
                    commentLabel.Font      = new Font("Arial", 12);
                    commentLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    commentLabel.BackColor = Color.White;
                    commentLabel.Location  = new Point(0, 20);
                    commentLabel.Padding   = new Padding(10);
                    commentLabel.AutoSize  = false;
                    Size reportSize = Helper.CalculateLabelSize(commentLabel, 920);
                    commentLabel.Size      = new Size(920, reportSize.Height + 20);
                    commentLabel.TextAlign = ContentAlignment.MiddleLeft;

                    Panel commentPanel = new Panel();
                    commentPanel.Size     = new Size(920, 20 + commentLabel.Size.Height);
                    commentPanel.Location = new Point(20, height);

                    height += commentPanel.Size.Height + 20;

                    commentPanel.Controls.Add(senderInfoLabel);
                    commentPanel.Controls.Add(commentLabel);
                    chatPanel.Controls.Add(commentPanel);
                }

                chatPanel.Size = new Size(chatPanel.Size.Width, height);
            }
            commentsPanel.Size = new Size(commentsPanel.Size.Width, chatPanel.Location.Y + chatPanel.Size.Height);

            mainPanel.Size = new Size(1000, commentsPanel.Location.Y + commentsPanel.Size.Height + 20);

            // Chat
            chatMessageTextBox.KeyPress += new KeyPressEventHandler(Key_Press);

            // Start chat
            //chatManager = new ChatManager();
            //chatManager.Connect(@event.Id, chatPanel);

            // Links
            //List<string> links = @event.Links;
            //for (int i = 0; i < links.Count; i++)
            //{
            //    string[] linkSplit = links[i].Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
            //    if (linkSplit.Length != 2) continue;

            //    LinkLabel linkText = new LinkLabel();
            //    linkText.Text = linkSplit[1];
            //    linkText.LinkClicked += (sender, e) =>
            //    {
            //        Process.Start(new ProcessStartInfo("cmd", $"/c start {linkSplit[0]}"));
            //    };
            //    linkText.Location = new Point(426, 370 + (i * 20));

            //    Controls.Add(linkText);
            //}
        }
Пример #6
0
        public void DrawBanner()
        {
            UserAccount acc = Program.UserDataManager.UserAccount;

            bannerPanel.Size = new Size(ClientSize.Width, BANNER_HEIGHT);

            // Create banner buttons
            Button currentEventsButton = new Button();

            currentEventsButton.Text      = "SYL";
            currentEventsButton.Font      = new Font("Arial", 50.0f, FontStyle.Bold);
            currentEventsButton.ForeColor = Color.LightGray;
            currentEventsButton.TextAlign = ContentAlignment.MiddleCenter;
            currentEventsButton.FlatStyle = FlatStyle.Flat;
            currentEventsButton.FlatAppearance.BorderSize = 0;
            currentEventsButton.Location = new Point(0, 0);
            currentEventsButton.Size     = new Size(200, BANNER_HEIGHT);
            currentEventsButton.Click   += (e, s) =>
            {
                ShowPanel(new MainEventListPanel(this));
            };

            Button eventManagerButton = new Button();

            eventManagerButton.Text      = "EVENT MANAGER";
            eventManagerButton.Font      = new Font("Arial", 20.0f, FontStyle.Bold);
            eventManagerButton.ForeColor = Color.White;
            eventManagerButton.TextAlign = ContentAlignment.MiddleCenter;
            eventManagerButton.FlatStyle = FlatStyle.Flat;
            eventManagerButton.FlatAppearance.BorderSize = 0;
            eventManagerButton.Location = new Point(200, 0);
            eventManagerButton.Size     = new Size(200, BANNER_HEIGHT);
            eventManagerButton.Click   += (e, s) =>
            {
                ShowPanel(new MainEventManagerPanel());
            };

            bannerPanel.Controls.Clear();
            bannerPanel.Controls.Add(currentEventsButton);
            //bannerPanel.Controls.Add(eventManagerButton);

            if (loggedIn)
            {
                userMenuPanel.Visible = false;

                // Create login info label
                Label loginInfoLabel = new Label();
                loginInfoLabel.Font      = new Font("Arial", 11, FontStyle.Italic);
                loginInfoLabel.ForeColor = Color.FromArgb(64, 64, 64);
                loginInfoLabel.AutoSize  = false;
                loginInfoLabel.Size      = new Size(200, 30);
                loginInfoLabel.Location  = new Point(ClientSize.Width - BANNER_HEIGHT - 215, (BANNER_HEIGHT - loginInfoLabel.Size.Height) / 2);
                loginInfoLabel.Text      = $"Logged in as {Program.UserDataManager.UserAccount.Username}";
                loginInfoLabel.TextAlign = ContentAlignment.MiddleRight;

                // Create menu panel open/close button
                PictureBox menuButtonPicture = new PictureBox();
                menuButtonPicture.Location    = new Point(ClientSize.Width - BANNER_HEIGHT, 0);
                menuButtonPicture.Size        = new Size(BANNER_HEIGHT, BANNER_HEIGHT);
                menuButtonPicture.Image       = Properties.Resources.UserMenuIcon;
                menuButtonPicture.MouseEnter += (e, s) =>
                {
                    menuButtonPicture.Image = Properties.Resources.UserMenuIconHover;
                };
                menuButtonPicture.MouseLeave += (e, s) =>
                {
                    if (!menuOpened)
                    {
                        menuButtonPicture.Image = Properties.Resources.UserMenuIcon;
                    }
                };
                menuButtonPicture.Click += (e, s) =>
                {
                    if (!menuOpened)
                    {
                        OpenMenu();
                    }
                    else
                    {
                        CloseMenu();
                    }
                };

                bannerPanel.Controls.Add(loginInfoLabel);
                bannerPanel.Controls.Add(menuButtonPicture);

                // Set separator images
                menuSeparatorPicture1.Image = Properties.Resources.MenuSeparator;

                // Add administrator menu options
                if (acc.Can((uint)Permissions.VIEW_ACCOUNTS) ||
                    acc.Can((uint)Permissions.DELETE_ACCOUNTS) ||
                    acc.Can((uint)Permissions.SILENCE_ACCOUNTS) ||
                    acc.Can((uint)Permissions.BAN_ACCOUNTS))
                {
                    menuSeparatorPicture1.Location = new Point(0, 135);
                    logoutButton.Location          = new Point(0, 150);

                    userMenuPanel.Controls.Add(menuSeparatorPicture2);
                    userMenuPanel.Controls.Add(accountManagerButton);
                }
                else
                {
                    menuSeparatorPicture1.Location = new Point(0, 90);
                    logoutButton.Location          = new Point(0, 105);

                    userMenuPanel.Controls.Remove(menuSeparatorPicture2);
                    userMenuPanel.Controls.Remove(accountManagerButton);
                }

                // Set menu panel height
                int height = 0;
                foreach (var control in userMenuPanel.Controls)
                {
                    height += ((Control)control).Height;
                }
                userMenuPanel.Size = new Size(userMenuPanel.Width, height + 5);
            }
            else
            {
                // Create login/register buttons
                Button loginButton = new Button();
                loginButton.Text      = "Login";
                loginButton.Font      = new Font("Arial", 12, FontStyle.Bold);
                loginButton.ForeColor = Color.White;
                loginButton.BackColor = Color.FromArgb(109, 168, 135);
                loginButton.TextAlign = ContentAlignment.MiddleCenter;
                loginButton.FlatStyle = FlatStyle.Flat;
                loginButton.FlatAppearance.BorderSize  = 1;
                loginButton.FlatAppearance.BorderColor = Color.White;
                loginButton.Location = new Point(ClientSize.Width - 250, 25);
                loginButton.Size     = new Size(100, 50);
                loginButton.Click   += (e, s) =>
                {
                    ShowPanel(new LoginPanel());
                };

                // Create login/register buttons
                Button registerButton = new Button();
                registerButton.Text      = "Sign up";
                registerButton.Font      = new Font("Arial", 12, FontStyle.Bold);
                registerButton.ForeColor = Color.FromArgb(109, 168, 135);
                registerButton.BackColor = Color.White;
                registerButton.TextAlign = ContentAlignment.MiddleCenter;
                registerButton.FlatStyle = FlatStyle.Flat;
                registerButton.FlatAppearance.BorderSize  = 1;
                registerButton.FlatAppearance.BorderColor = Color.White;
                registerButton.Location = new Point(ClientSize.Width - 125, 25);
                registerButton.Size     = new Size(100, 50);
                registerButton.Click   += (e, s) =>
                {
                    ShowPanel(new RegistrationPanel());
                };

                bannerPanel.Controls.Add(loginButton);
                bannerPanel.Controls.Add(registerButton);
            }
        }
Пример #7
0
        public void LoadMyEvents()
        {
            UserAccount acc = Program.UserDataManager.UserAccount;

            eventsPanel.Controls.Clear();

            // Add create event button
            Button createEventButton = new Button();

            createEventButton.BackColor = Color.FromArgb(109, 168, 135);
            createEventButton.FlatStyle = FlatStyle.Flat;
            createEventButton.FlatAppearance.BorderSize = 0;
            createEventButton.Location  = new Point(0, 0);
            createEventButton.Size      = new Size(ITEM_WIDTH, ITEM_HEIGHT);
            createEventButton.Font      = new Font("Arial Rounded", 15.0f, FontStyle.Bold);
            createEventButton.ForeColor = Color.White;
            createEventButton.Text      = "+ Create new event";
            createEventButton.TextAlign = ContentAlignment.MiddleCenter;
            createEventButton.Click    += createEventButton_Click;
            eventsPanel.Controls.Add(createEventButton);

            if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
            {
                createEventButton.Enabled = false;
                createEventButton.Text    = "Event creation disabled";
            }

            // Get all events
            List <EventBrief> events = Program.DataProvider.GetEventsBrief(new EventOptions());

            if (!acc.Can((uint)Permissions.EDIT_OTHER_EVENTS))
            {
                events = events.Where(item => item.Author == acc.Id).ToList();
            }
            else if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
            {
                events = new List <EventBrief>();
            }

            // Add events to display
            int counter = 1;

            foreach (var @event in events)
            {
                Panel eventPanel = new Panel();
                eventPanel.Location = new Point(0, counter * (ITEM_HEIGHT + MARGINS));
                eventPanel.Size     = new Size(ITEM_WIDTH, ITEM_HEIGHT);

                Label eventName = new Label();
                eventName.Font      = new Font("Arial Rounded", 15.0f, FontStyle.Bold);
                eventName.Text      = @event.Name;
                eventName.AutoSize  = false;
                eventName.Location  = new Point(0, 0);
                eventName.Size      = new Size(ITEM_WIDTH, ITEM_HEIGHT);
                eventName.Padding   = new Padding(10, 0, 0, 0);
                eventName.TextAlign = ContentAlignment.MiddleLeft;
                //eventName.BackColor = Color.FromArgb(109, 168, 135);
                eventName.BackColor   = Color.FromArgb(230, 230, 230);
                eventName.MouseEnter += (s, e) =>
                {
                    eventName.BackColor = Color.FromArgb(210, 210, 210);
                };
                eventName.MouseLeave += (s, e) =>
                {
                    eventName.BackColor = Color.FromArgb(230, 230, 230);
                };

                eventName.Click += (sender, e) =>
                {
                    // Get full event data from database
                    List <EventFull> eventData = Program.Client.SelectEventsFull(@event.Id);
                    //Program.DataManager.Read(new DatabaseReader($"select from events_full id {@event.Id}"), out eventData);
                    try
                    {
                        mainForm.ShowPanel(new EventEditorPanel(this, eventData[0], false));
                        //new EventEditorPanel(this, eventData[0], true).Show();
                    }
                    catch (InvalidCastException)
                    {
                        Console.WriteLine($"ERROR: Event \"{@event.Name}\" can't be opened (invalid data)");
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        Console.WriteLine($"ERROR: No events with id '{@event.Id}' retrieved from database");
                    }
                    catch (NullReferenceException)
                    {
                        Console.WriteLine($"ERROR: database reader returned null");
                    }
                };

                eventPanel.Controls.Add(eventName);
                eventsPanel.Controls.Add(eventPanel);
                counter++;
            }

            eventsPanel.Size = new Size(400, (ITEM_HEIGHT + MARGINS) * (events.Count + 1));
        }