Пример #1
0
        //Showing or Hiding the search controls and fields depending on received Enum
        private void ShowAndHideSearchFields(eShowOrHide showHide)
        {
            //Creating the Array of elements for simple handling of GUI,
            //instead of passing to GuiChanges class Methods each one of the controls,
            //pass only one array variable. Simple and Effective
            UIElement[] searchControls = { lblName,          txtName,  lblAuthor,       txtAuthor,
                                           lblIssue,         txtIssue, lblBaseCategory, cmbBaseCategory,
                                           lblInnerCategory, cmbInnerCategory };

            //Switch depending on enum
            switch (showHide)
            {
            //Show the search controls
            case eShowOrHide.Show:

                //Show the elements from the created array
                GuiChanges.Show(searchControls);

                //Fill the ComboBox of Base category
                GuiChanges.FillComboWithBaseCategory(cmbBaseCategory);

                //If no selection of Base Category made
                if (cmbBaseCategory.SelectedItem == null)
                {
                    //Hide the inner Category ComboBox
                    GuiChanges.Hide(lblInnerCategory, cmbInnerCategory);
                }

                break;

            //Hide the search controls
            case eShowOrHide.Hide:

                //Hide the elements from the created array
                GuiChanges.Hide(searchControls);

                //Search for the text fields in elements array
                foreach (UIElement item in searchControls)
                {
                    //If the Control is Text Box
                    if (item is TextBox)
                    {
                        //Clear the contents of the Text Box, so
                        //this way there's no interfear with feauture search options
                        //when the fields will be enabled and visible again
                        ((TextBox)item).Text = string.Empty;
                    }
                }

                //Clean the Combo Boxes of Base and Inner Categories
                cmbBaseCategory.ItemsSource = cmbInnerCategory.ItemsSource = null;

                break;
            }
        }
Пример #2
0
        //Ctor for add new Item window
        public AddNewItem()
        {
            InitializeComponent();

            //Hide the labels and the text boxes ubtil user chooses Item Type
            GuiChanges.Hide(lblIssue, lblAuthor, txtIssue, txtAuthor);

            //Obvously understandable by function name
            GuiChanges.FillComboWithBaseCategory(cmbBaseCat);

            //Untill user choose the BaseCategory - disable inner
            GuiChanges.Disable(cmbInnerCat);
        }
Пример #3
0
        //Multiple Search CheckBox Checked Event
        private void chkMultiSearch_Checked(object sender, RoutedEventArgs e)
        {
            //Show the search options
            ShowAndHideSearchFields(eShowOrHide.Show);

            //Cancel regular search option
            chkSearch.IsChecked = false;

            //Hide relative controls which not valid for the multiple search
            GuiChanges.Hide(lblAuthor, txtAuthor, lblIssue, txtIssue);

            //Raise the flag of multiple search
            IsMultiSearch = true;
        }
Пример #4
0
        //Update the fields from current Item
        public void UpdateFromItem()
        {
            //creating the arrays for easy handling the Journal controls
            UIElement[] issue = { lblIssue, txtIssue };

            //creating the arrays for easy handling the Book controls
            UIElement[] author = { lblAuthor, txtAuthor };

            //-------------- Updating the fields from Current Item -------------//
            lblISBN.Text = $"ISBN: {CurrentItem.ISBN}";

            lblTypeOf.Text = CurrentItem.ItemType;

            chkBorrowed.IsChecked = CurrentItem.IsBorrowed;

            GuiChanges.FillComboWithBaseCategory(cmbBaseCat);

            cmbBaseCat.SelectedItem = CurrentItem.BaseCategory;

            txtName.Text = CurrentItem.Name;

            dtPick.SelectedDate = CurrentItem.PrintDate;

            switch (CurrentItem.ItemType)
            {
            case "Book":
                GuiChanges.Hide(issue);
                GuiChanges.Show(author);
                txtAuthor.Text = ((Book)CurrentItem).Author;
                break;

            case "Journal":
                GuiChanges.Hide(author);
                GuiChanges.Show(issue);
                txtIssue.Text = ((Journal)CurrentItem).IssueNumber.ToString();
                break;
            }
            //-------------- Updating the fields from Current Item -------------//
        }
Пример #5
0
        //init all elements depending on current working state
        private void InitEditItemWindow()
        {
            this.WindowStyle = WindowStyle.SingleBorderWindow;

            this.ResizeMode = ResizeMode.NoResize;

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            lblISBN.TextAlignment = TextAlignment.Center;

            if (!EditMode) //showing details mode
            {
                this.Title = "Item Details";

                //Show check button for Telling to the user if the item is borrowed or not
                GuiChanges.Show(chkBorrowed);

                //Disable all the controls because we're in "Show Details" mode
                foreach (UIElement item in this.grdWindowGrid.Children)
                {
                    GuiChanges.Disable(item);
                }

                //Button caption changed to "Exit"
                btnSaveExit.Content = "Exit";

                //After all controls being disabled because of "Show Details" mode,
                //Enable the Exit button
                GuiChanges.Enable(btnSaveExit);
            }
            else //editing Item Mode
            {
                //Button caption changed to "Save Changes"
                btnSaveExit.Content = "Save Changes";

                //Hide "Item is Borrowed" indicator CheckBox
                GuiChanges.Hide(chkBorrowed);
            }
        }
Пример #6
0
        //Fills the Inner Category ComboBox or hides it -
        //depending on user input
        private void FillInner()
        {
            //Creating an array for easy hiding and showing
            //the Inner Category controls
            UIElement[] inner = { lblInnerCategory, cmbInnerCategory };

            //If there's any choice from the User on the Base Category ComboBox
            if (cmbBaseCategory.SelectedItem != null)
            {
                //Then fill the Inner Category ComboBox
                GuiChanges.FillComboWithInnerCategory
                    (cmbInnerCategory, cmbBaseCategory.SelectedItem);

                //And show the Inner ComboBox to the user
                GuiChanges.Show(inner);
            }
            //If there's no choice from the User on Base Category ComboBox
            else
            {
                //if so - hide the Inner Category ComboBox
                GuiChanges.Hide(inner);
            }
        }
Пример #7
0
        //Hide and show related elements when user chooses the Item type
        private void rdChecked(object sender, RoutedEventArgs e)
        {
            var rdValue = sender as RadioButton;

            //Creating array of the GUI elements for easy manipulation with the Journal
            UIElement[] issue = { lblIssue, txtIssue };

            //Creating array of the GUI elements for easy manipulation with the Book
            UIElement[] author = { lblAuthor, txtAuthor };
            switch (rdValue.Name)
            {
            case "rdBook":
                CurrentItem = ItemType.Book;
                GuiChanges.Hide(issue);
                GuiChanges.Show(author);
                break;

            case "rdJournal":
                CurrentItem = ItemType.Journal;
                GuiChanges.Hide(author);
                GuiChanges.Show(issue);
                break;
            }
        }