Наследование: MonoBehaviour
Пример #1
0
 /// <summary>
 /// This is not an actual constructor but the code runs whenever the User Control gets visible.
 /// </summary>
 private void UCBooks_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         UIExtension.ClearSearch(lvSearchAuthor, lvSearchBook, txtSearch, rbtnAuthor, rbtnBook, pnlSearch, drdwnBookSearchBy, txtSearchPlaceholder);
     }
 }
Пример #2
0
        static async Task Main(string[] args)
        {
            _ = new ArgumentException(); // f****n sdk bugs reeeeeeee

            CultureInfo.CurrentCulture = CultureInfo.GetCultureInfoByIetfLanguageTag("en-gb");
            AppDomain.CurrentDomain.UnhandledException   += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;

            buffer = new FrameBuffer(Console.WindowWidth, Console.WindowHeight);

            FrameBufferGraphics graphics = new FrameBufferGraphics(buffer);
            UIExtension         ext      = new UIExtension(buffer);

            buffer.AddDrawExtension(ext);

            SetupUI(buffer, ext);



            buffer.Run();
            await Run(buffer);

            await Task.Yield();

            ext.BeginEventLoop();
        }
Пример #3
0
        private void UpdatelvReturnLoan(IEnumerable <Loan> loanList = null)
        {
            lvReturnLoan.Items.Clear();
            if (loanList == null)
            {
                loanList = form.loanService.CurrentLoans();
            }

            foreach (Loan loan in form.loanService.OrderByDueDateAndBookID(loanList))
            {
                ListViewItem item = new ListViewItem
                {
                    Text = loan.BookCopy.Book.ToString(),
                    Tag  = loan,
                    UseItemStyleForSubItems = false
                };
                item.SubItems.Add(loan.BookCopy.ToString());
                item.SubItems.Add(loan.Member.ToString());
                item.SubItems.Add(loan.DueDate.Value.ToShortDateString());

                if (form.loanService.CalculateDaysOverdue(loan) > 0)
                {
                    item.SubItems[3].ForeColor = Color.Red;
                }

                UIExtension.AddToAlphabeticListViewGroup(lvReturnLoan, item);
                lvReturnLoan.Items.Add(item);
            }
        }
Пример #4
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            ListView    listView;
            UserControl userControl;

            if (UIExtension.loanStatus == UIExtension.Loan.New)
            {
                listView    = lvNewLoan;
                userControl = form.ucLoanBook;
            }
            else
            {
                listView    = lvReturnLoan;
                userControl = form.ucReturnBook;
            }

            if (listView.SelectedItems.Count > 0)
            {
                if (listView.SelectedItems[0].Checked)
                {
                    UIExtension.ShowMessage(messageTimer, lblMessage, "The book is not available for the moment!", Color.Red);
                }
                else
                {
                    UIExtension.currentItem = listView.SelectedItems[0].Tag;
                    UIExtension.ChangeUC(userControl);
                }
            }
            else
            {
                UIExtension.ShowMessage(messageTimer, lblMessage, "You must first select an item in the list!", Color.Red);
            }
        }
Пример #5
0
        // <-- Constructors.

        // Local methods. -->
        private void ClearTextBoxAndButton(TextBox textBox, Button button, string placeholder)
        {
            textBox.Enabled = true;
            button.Enabled  = true;
            textBox.Text    = "";
            UIExtension.ShowPlaceholder(textBox, placeholder);
        }
Пример #6
0
 /// <summary>
 /// This is not an actual constructor but the code runs whenever the User Control gets visible.
 /// </summary>
 private void UCAddBook_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         if (UIExtension.operation == UIExtension.Operation.Add)
         {
             lblTitle.Text = "Add New Book";
             pbNew.Visible = true;
             ClearAuthorFilter();
             UIExtension.ClearTextBoxesInPanel(pnlBookInfo);
             lvBookAuthors.Items.Clear();
             ToggleBookCopyVisibility(false);
             UIExtension.EnableTextbox(txtISBN);
         }
         else if (UIExtension.operation == UIExtension.Operation.Edit)
         {
             currentBook = UIExtension.currentItem as Book;
             StoreTemporaryBook(currentBook);
             lblTitle.Text = $"Edit {currentBook}";
             pbNew.Visible = false;
             ToggleBookCopyVisibility(true);
             InsertAuthors();
             txtISBN.Text        = currentBook.ISBN;
             txtTitle.Text       = currentBook.Title;
             txtYear.Text        = currentBook.Year.ToString();
             txtDescription.Text = currentBook.Description;
             UIExtension.DisableTextbox(txtISBN);
         }
     }
     else
     {
         ClearAuthorFilter(sender, e);
     }
 }
Пример #7
0
        public void Login()
        {
            sap = UIExtension.Login(_data.SAPAccount);
            Guid guid = Guid.NewGuid();

            _file = Path.Combine(_data.WorkFolder, $"{guid.ToString()}.txt");
        }
Пример #8
0
 private void btnReturnLoan_Click(object sender, EventArgs e)
 {
     try
     {
         form.loanService.Return(currentLoan);
         lblMessage.Visible   = true;
         lblMessage.ForeColor = Color.Green;
         lblMessage.Text      = "Loan returned successfully!";
         UpdateLoanInfo();
         lblOnTime.Visible       = true;
         txtOnTime.Visible       = true;
         lblReturned.Visible     = true;
         txtReturned.Visible     = true;
         txtReturned.Text        = currentLoan.DateOfReturn.Value.ToShortDateString();
         lblDebt.Visible         = true;
         txtDebt.Visible         = true;
         txtDebt.Text            = $"{currentLoan.Debt.ToString()} kr";
         txtDebt.ForeColor       = (currentLoan.Debt > 0) ? Color.OrangeRed : Color.Green;
         btnReturnLoan.Enabled   = false;
         btnReturnLoan.BackColor = Color.Gray;
     }
     catch (Exception exception)
     {
         UIExtension.ShowMessage(messageTimer, lblMember, exception.Message, Color.Red);
     }
 }
Пример #9
0
        /// <summary>
        /// This is not an actual constructor but the code runs whenever the User Control gets visible.
        /// </summary>
        private void UCReturnBook_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            {
                currentLoan = UIExtension.currentItem as Loan;
                UIExtension.ClearTextBoxesInPanel(pnlBookInfo);
                UIExtension.ClearTextBoxesInPanel(pnlLoanInfo);

                btnReturnLoan.Enabled   = true;
                btnReturnLoan.BackColor = btnReturnLoanBackColor;
                lblMessage.Visible      = false;

                lblBookTitle.Text = currentLoan.BookCopy.Book.ToString();

                txtISBN.Text        = currentLoan.BookCopy.Book.ISBN;
                txtBookCopy.Text    = currentLoan.BookCopy.ToString();
                txtAuthor.Text      = currentLoan.BookCopy.Book.AuthorsToString();
                txtYear.Text        = currentLoan.BookCopy.Book.Year.ToString();
                txtDescription.Text = currentLoan.BookCopy.Book.Description;

                lblOnTime.Visible   = false;
                txtOnTime.Visible   = false;
                lblReturned.Visible = false;
                txtReturned.Visible = false;
                lblDebt.Visible     = false;
                txtDebt.Visible     = false;
                UpdateLoanInfo();
            }
        }
Пример #10
0
        protected override void DrawDay(PaintEventArgs e, Rectangle rect, DateTime time)
        {
            e.Graphics.FillRectangle(SystemBrushes.Window, rect);

            if (UIExtension.IsHighContrastActive())
            {
                // Draw selection first because it's opaque
                DrawDaySelection(e, rect, time);

                DrawDaySlotSeparators(e, rect, time);
                DrawNonWorkHours(e, rect, time);
                DrawToday(e, rect, time);
                DrawDayAppointments(e, rect, time);
            }
            else
            {
                DrawDaySlotSeparators(e, rect, time);
                DrawNonWorkHours(e, rect, time);
                DrawToday(e, rect, time);
                DrawDayAppointments(e, rect, time);

                // Draw selection last because it's translucent
                DrawDaySelection(e, rect, time);
            }

            DrawDayGripper(e, rect);
        }
Пример #11
0
        // <-- Constructors.

        // Local methods. -->
        private void ClearTextboxes()
        {
            txtFirstName.Text = "";
            txtLastName.Text  = "";
            UIExtension.ShowPlaceholder(txtFirstName, txtFirstNamePlaceholder);
            UIExtension.ShowPlaceholder(txtLastName, txtLastNamePlaceholder);
        }
Пример #12
0
 private void lvSearchBook_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         UIExtension.ClearSearch(lvSearchAuthor, lvSearchBook, txtSearch, rbtnAuthor, rbtnBook, pnlSearch, drdwnBookSearchBy, txtSearchPlaceholder);
     }
 }
Пример #13
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            var node = HitTestPositions(e.Location);

            if (!ReadOnly && (node != null) && !HitTestExpansionButton(node, e.Location))
            {
                var taskItem = RealTaskItem(node);

                if (taskItem != null)
                {
                    Cursor cursor = null;

                    if (taskItem.IsLocked)
                    {
                        cursor = UIExtension.AppCursor(UIExtension.AppCursorType.LockedTask);
                    }
                    else if (TaskHasIcon(taskItem) && HitTestIcon(node, e.Location))
                    {
                        cursor = UIExtension.HandCursor();
                    }

                    if (cursor != null)
                    {
                        Cursor = cursor;
                        return;
                    }
                }
            }

            // all else
            Cursor = Cursors.Arrow;
        }
Пример #14
0
        // <-- Constructors.


        // <-- Constructors.

        // Local methods. -->
        private void LoadNewLoan()
        {
            lblTitle.Text         = "New loan";
            txtSearch.Enabled     = true;
            lblTodaysDate.Visible = false;
            UIExtension.ToggleListViewSearch(lvNewLoan, lvReturnLoan);
            UIExtension.ClearSearch(lvNewLoan, txtSearch, txtSearchPlaceholder, rbtnBook, rbtnMember, false);
        }
Пример #15
0
 /// <summary>
 /// This is not an actual constructor but the code runs whenever the User Control gets visible.
 /// </summary>
 private void UCMembers_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         txtSearch.Text = "";
         UIExtension.ClearSearch(lvMembers, txtSearch, txtSearchPlaceholder);
     }
 }
Пример #16
0
        // <-- Focus events.

        // Key press events.-->
        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                UIExtension.ClearSearch(lvMembers, txtSearch, txtSearchPlaceholder);
                ActiveControl = null;
            }
        }
Пример #17
0
 private void LoadReturnLoan()
 {
     lblTitle.Text         = "Return loan";
     txtSearch.Enabled     = false;
     lblTodaysDate.Visible = true;
     lblTodaysDate.Text    = DateTime.Today.ToShortDateString();
     UIExtension.ToggleListViewSearch(lvReturnLoan, lvNewLoan);
     UIExtension.ClearSearch(lvReturnLoan, txtSearch, txtSearchPlaceholder, rbtnBook, rbtnMember, true);
 }
Пример #18
0
        // <-- Focus events.

        // Key press events.-->
        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                txtSearch.Text = "";
                UIExtension.ShowPlaceholder(txtSearch, txtSearchPlaceholder);
                ActiveControl = null;
            }
        }
Пример #19
0
 private void rbtnBook_CheckedChanged(object sender, EventArgs e)
 {
     if (rbtnBook.Checked)
     {
         ClearTextBoxAndButton(txtSearch, btnSearch, txtSearchPlaceholder);
         drdwnBookSearchBy.Visible = true;
         UIExtension.ToggleListViewSearch(lvSearchBook, lvSearchAuthor, pnlSearch);
     }
 }
Пример #20
0
        // <-- Local methods.

        // Misc. functionality. -->
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (lvBookAuthors.Items.Count == 0 || txtISBN.Text.Trim() == "" || txtTitle.Text.Trim() == "" || txtYear.Text.Trim() == "")
            {
                UIExtension.ShowMessage(messageTimer, lblMessage, $"You must enter values for all required fields!", Color.Red);
            }
            else
            {
                try
                {
                    List <Author> authorList = new List <Author>();

                    foreach (ListViewItem author in lvBookAuthors.Items)
                    {
                        authorList.Add(author.Tag as Author);
                    }

                    if (UIExtension.operation == UIExtension.Operation.Add)
                    {
                        Book book = new Book(txtISBN.Text.Trim(), txtTitle.Text.Trim(), authorList, Convert.ToInt64(txtYear.Text.Trim()), txtDescription.Text.Trim());
                        form.bookService.Add(book);
                        form.bookCopyService.Add(new BookCopy(book));
                        UIExtension.ShowMessage(messageTimer, lblMessage, $"{txtTitle.Text.Trim()} was successfully added to the library!", Color.Green);
                        ClearAuthorFilter(sender, e);
                        UIExtension.ClearTextBoxesInPanel(pnlBookInfo);
                        lvBookAuthors.Items.Clear();
                    }
                    else
                    {
                        currentBook.Authors     = authorList;
                        currentBook.Title       = txtTitle.Text.Trim();
                        currentBook.Year        = Convert.ToInt64(txtYear.Text.Trim());
                        currentBook.Description = txtDescription.Text.Trim();
                        form.bookService.Edit(currentBook);
                        lblTitle.Text = $"Edit {currentBook}";
                        UIExtension.ShowMessage(messageTimer, lblMessage, $"{currentBook} was successfully edited!", Color.Green);
                    }
                }
                catch (FormatException)
                {
                    UIExtension.ShowMessage(messageTimer, lblMessage, $"You need to enter a valid value for Year", Color.Red);
                    if (UIExtension.operation == UIExtension.Operation.Edit)
                    {
                        RestoreBook(currentBook);
                    }
                }
                catch (Exception exception)
                {
                    UIExtension.ShowMessage(messageTimer, lblMessage, exception.Message, Color.Red);
                    if (UIExtension.operation == UIExtension.Operation.Edit)
                    {
                        RestoreBook(currentBook);
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Initialize the User Control
        /// </summary>
        public UCMembers(Form form)
        {
            InitializeComponent();
            this.form = form as LibraryForm;
            this.txtSearchPlaceholder = txtSearch.Text;
            UIExtension.CreateListViewAlphabeticGroups(lvMembers);

            // Subscribes the information fields update methods to run whenever other services are updated in database.
            this.form.memberService.Updated += MemberService_Updated;
        }
Пример #22
0
        /// <summary>
        /// Initialize the User Control.
        /// </summary>
        public UCBook(Form form)
        {
            InitializeComponent();
            this.form = form as LibraryForm;
            this.txtFilterPlaceholder = txtFilter.Text;
            UIExtension.CreateListViewAlphabeticGroups(lvSelectAuthor);

            // Subscribes the information fields update methods to run whenever other services are updated in database.
            this.form.authorService.Updated   += AuthorService_Updated;
            this.form.bookCopyService.Updated += BookCopyService_Updated;
        }
Пример #23
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     if (lvMembers.SelectedItems.Count > 0)
     {
         UIExtension.currentItem = lvMembers.SelectedItems[0].Tag;
         UIExtension.ChangeUC(form.ucViewMember);
     }
     else
     {
         UIExtension.ShowMessage(messageTimer, lblMessage, "You must first select an item to edit!", Color.Red);
     }
 }
Пример #24
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (lvBookAuthors.SelectedItems.Count == 0)
     {
         UIExtension.ShowMessage(messageTimer, lblMessage, "You need to select an author to remove!", Color.Red);
     }
     else
     {
         UIExtension.ShowMessage(messageTimer, lblMessage, $"{lvBookAuthors.SelectedItems[0].Tag.ToString()} was successfully removed from the book!", Color.Green);
         lvBookAuthors.Items.RemoveAt(lvBookAuthors.SelectedIndices[0]);
     }
 }
Пример #25
0
 /// <summary>
 /// This is not an actual constructor but the code runs whenever the User Control gets visible.
 /// </summary>
 private void UCViewMember_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         this.currentMember = UIExtension.currentItem as Member;
         UpdateMemberInformation();
         UpdatelvLoans();
         UIExtension.ClearTextBoxesInPanel(pnlLoanInformation);
         ActiveControl = null;
         pnlLoanInformation.Visible = false;
     }
 }
Пример #26
0
        // Focus events. -->
        private void lvLoans_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvLoans.SelectedItems.Count == 0)
            {
                UIExtension.ClearTextBoxesInPanel(pnlLoanInformation);
            }

            else
            {
                pnlLoanInformation.Visible = true;
                UpdateLoanInformation(sender, e);
            }
        }