public NewLoanToKeyWindow(KeyRegister keyRegister, int keyDbId)
     : base(keyRegister, "Add new loan for " + keyRegister.getKeyById(keyDbId).Identifier)
 {
     keyIdEntry.Text      = keyRegister.getKeyById(keyDbId).Identifier;
     keyIdEntry.Sensitive = false;
     keyIdLabel.Text      = "Key identifier (locked)";
     somethingChanged     = false;
 }
Пример #2
0
        public KeyView(KeyRegister kr) : base(kr)
        {
            TreeViewColumn keyDbIdColumn = new TreeViewColumn();

            TreeViewColumn statusColumn = new TreeViewColumn();

            statusColumn.Title = "";

            TreeViewColumn idColumn = new TreeViewColumn();

            idColumn.Title   = "Identifier";
            keyIdColumnIndex = 1;

            TreeViewColumn nameColumn = new TreeViewColumn();

            nameColumn.Title = "Name";

            TreeViewColumn descriptionColumn = new TreeViewColumn();

            descriptionColumn.Title = "Description";

            tree.AppendColumn(keyDbIdColumn);
            tree.AppendColumn(statusColumn);
            tree.AppendColumn(idColumn);
            tree.AppendColumn(nameColumn);
            tree.AppendColumn(descriptionColumn);

            CellRendererText statusCell = new CellRendererText();

            statusColumn.PackStart(statusCell, true);
            CellRendererText identifierCell = new CellRendererText();

            idColumn.PackStart(identifierCell, true);
            CellRendererText nameCell = new CellRendererText();

            nameColumn.PackStart(nameCell, true);
            CellRendererText descriptionCell = new CellRendererText();

            descriptionColumn.PackStart(descriptionCell, true);

            statusColumn.AddAttribute(statusCell, "text", 1);
            idColumn.AddAttribute(identifierCell, "text", 2);
            nameColumn.AddAttribute(nameCell, "text", 3);
            descriptionColumn.AddAttribute(descriptionCell, "text", 4);

            statusColumn.MaxWidth      = 30;
            idColumn.MaxWidth          = 100;
            nameColumn.MaxWidth        = 100;
            descriptionColumn.MaxWidth = 200 - statusColumn.MaxWidth;

            listStore = new ListStore(typeof(int),
                                      typeof(string),
                                      typeof(string),
                                      typeof(string),
                                      typeof(string));
            tree.Model = listStore;
        }
        public OwnScrolledTreeView(KeyRegister kr)
        {
            keyRegister = kr;

            tree = new TreeView();

            tree.RowActivated  += rowDoubleClicked;
            tree.CursorChanged += rowSelected;

            Add(tree);
        }
Пример #4
0
        public LoanView(KeyRegister kr) : base(kr)
        {
            TreeViewColumn loanDbIdColumn = new TreeViewColumn();

            TreeViewColumn keyIdColumn = new TreeViewColumn();

            keyIdColumn.Title = "Key";
            keyIdColumnIndex  = 0;

            TreeViewColumn startDateColumn = new TreeViewColumn();

            startDateColumn.Title = "Start date";

            TreeViewColumn dueDateColumn = new TreeViewColumn();

            dueDateColumn.Title = "Due date";

            TreeViewColumn loanedToColumn = new TreeViewColumn();

            loanedToColumn.Title = "Loaned to";

            tree.AppendColumn(loanDbIdColumn);
            tree.AppendColumn(keyIdColumn);
            tree.AppendColumn(startDateColumn);
            tree.AppendColumn(dueDateColumn);
            tree.AppendColumn(loanedToColumn);

            CellRendererText keyIdCell = new CellRendererText();

            keyIdColumn.PackStart(keyIdCell, true);
            CellRendererText startDateCell = new CellRendererText();

            startDateColumn.PackStart(startDateCell, true);
            CellRendererText dueDateCell = new CellRendererText();

            dueDateColumn.PackStart(dueDateCell, true);
            CellRendererText loanedToCell = new CellRendererText();

            loanedToColumn.PackStart(loanedToCell, true);

            keyIdColumn.AddAttribute(keyIdCell, "text", 1);
            startDateColumn.AddAttribute(startDateCell, "text", 2);
            dueDateColumn.AddAttribute(dueDateCell, "text", 3);
            loanedToColumn.AddAttribute(loanedToCell, "text", 4);

            listStore = new ListStore(typeof(int),
                                      typeof(string),
                                      typeof(string),
                                      typeof(string),
                                      typeof(string));
            tree.Model = listStore;
        }
Пример #5
0
        public SmallWindow(KeyRegister kr, string title) : base(title)
        {
            keyRegister = kr;
            // Setting size of the window.
            SetSizeRequest(400, 500);

            // Do not allow resizing of this window.
            Resizable = false;

            container = new Fixed();

            Add(container);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyRegisterApp.CliApplication"/> class.
 /// </summary>
 public CliApplication()
 {
     settingsHandler = new SettingsHandler();
     if (settingsHandler.Settings["RegisterType"].ToUpper() == "XML")
     {
         keyRegister = new KeyRegisterXml(settingsHandler.Settings["RegisterXmlFileLocation"]);
     }
     else
     {
         throw new SettingsHandler.InvalidSettingValue("Invalid register type '" +
                                                       settingsHandler.Settings["RegisterType"] +
                                                       "' specified");
     }
 }
Пример #7
0
 public EditKeyWindow(KeyRegister keyRegister, string title, Key key) : base(keyRegister, title)
 {
     this.key                       = key;
     this.Title                     = "Edit key " + key.Identifier;
     idEntry.Text                   = key.Identifier;
     nameEntry.Text                 = key.Name;
     descriptionEntry.Text          = key.Description;
     somethingChanged               = false;
     actionButton.Label             = "Modify key";
     actionButton.Sensitive         = false;
     buttonInstructionLabel.Text    = "Nothing modified";
     buttonInstructionLabel.Visible = true;
     container.Move(buttonInstructionLabel, 120, 10 + groupSpacing * 3);
 }
Пример #8
0
        public EditLoanWindow(KeyRegister keyRegister, int loanDbId)
            : base(keyRegister, "Edit loan " + loanDbId)
        {
            Loan loan = keyRegister.getLoanById(loanDbId);

            this.loanDbId = loanDbId;
            string keyIdentifier = keyRegister.getKeyById(loan.KeyId).Identifier;

            keyIdEntry.Text        = keyIdentifier;
            this.Title             = "Edit loan for key " + keyIdentifier;
            keyIdEntry.Sensitive   = false;
            keyIdEntry.TooltipText = "Key identifier cannot be changed. " +
                                     "Issue new loan for new key if you want to transfer loan";
            keyIdLabel.Text = "Key identifier (locked)";

            // Setting calendars.
            dateStartCal.Year  = loan.parseStartDate() [0];
            dateStartCal.Month = loan.parseStartDate() [1] - 1;
            dateStartCal.Day   = loan.parseStartDate() [2];

            if (loan.DateEnd != null)
            {
                noDueDate.Active = false;
                dateDueCal.Year  = loan.parseDueDate() [0];
                dateDueCal.Month = loan.parseDueDate() [1] - 1;
                dateDueCal.Day   = loan.parseDueDate() [2];
            }
            else
            {
                dateDueCal.Date  = dateStartCal.Date;
                noDueDate.Active = true;
            }

            // Setting button text.
            actionButton.Label = "Edit loan";

            // Setting loaner
            loanerEntry.Text = loan.LoanedTo;

            // Setting addInfo
            additionalEntry.Text = loan.AdditionalInformation;

            somethingChanged = false;
        }
Пример #9
0
        public NewKeyWindow(KeyRegister keyRegister, string title) : base(keyRegister, title)
        {
            // Setting deleteEvent.
            DeleteEvent += closeConfirmation;

            // Indentifier entry.
            idLabel = new Label("Identifier (required):");
            idEntry = new Entry();
            idEntry.WidthRequest = entryWidth;
            idEntry.Changed     += onEntryChange;
            container.Put(idLabel, 10, 10 + groupSpacing * 0);
            container.Put(idEntry, 10, 10 + groupSpacing * 0 + labelEntrySpacing);

            // Name entry.
            nameLabel = new Label("Name (required):");
            nameEntry = new Entry();
            nameEntry.WidthRequest = entryWidth;
            nameEntry.Changed     += onEntryChange;
            container.Put(nameLabel, 10, 10 + groupSpacing * 1);
            container.Put(nameEntry, 10, 10 + groupSpacing * 1 + labelEntrySpacing);


            // Description entry.
            descriptionLabel = new Label("Description:");
            descriptionEntry = new Entry();
            descriptionEntry.WidthRequest = entryWidth;
            descriptionEntry.Changed     += onEntryChange;
            container.Put(descriptionLabel, 10, 10 + groupSpacing * 2);
            container.Put(descriptionEntry, 10, 10 + groupSpacing * 2 + labelEntrySpacing);

            // Action button.
            actionButton           = new Button("Add key");
            actionButton.Sensitive = false;
            actionButton.Clicked  += onActionButtonClicked;
            container.Put(actionButton, 10, 10 + groupSpacing * 3);

            // Instruction label.
            buttonInstructionLabel = new Label("Please fill all required fields");
            container.Put(buttonInstructionLabel, 100, 10 + groupSpacing * 3);

            ShowAll();
        }
Пример #10
0
        /////////////////////
        //  OTHER METHODS  //
        /////////////////////

        public void loadSettings()
        {
            // Getting settings.
            this.settingsHandler = new SettingsHandler();

            // Setting KeyRegister object to represent some of the implemented data sources. New
            // sources can be easily added by first inheriting from KeyRegister-class and
            // implementing the required methods. Then adding it here, will make it available.
            //KeyRegister kr;
            if (settingsHandler.Settings["RegisterType"].ToUpper() == "XML")
            {
                this.keyRegister = new KeyRegisterXml(settingsHandler.Settings["RegisterXmlFileLocation"]);
            }
            else
            {
                throw new SettingsHandler.InvalidSettingValue("Invalid register type '" +
                                                              settingsHandler.Settings["RegisterType"] +
                                                              "' specified");
            }
        }
        public KeyDetailsWindow(KeyRegister keyRegister, int keyDbId)
            : base(keyRegister, "Details of key " + keyRegister.getKeyById(keyDbId).Identifier)
        {
            key                        = keyRegister.getKeyByIdentifier(keyRegister.getKeyById(keyDbId).Identifier);
            idEntry.Text               = key.Identifier;
            idEntry.Sensitive          = false;
            nameEntry.Text             = key.Name;
            nameEntry.Sensitive        = false;
            descriptionEntry.Text      = key.Description;
            descriptionEntry.Sensitive = false;

            idLabel.Text   = "Identifier:";
            nameLabel.Text = "Name:";

            // Destroying button and its label becouse they are not needed here.
            actionButton.Destroy();
            buttonInstructionLabel.Destroy();

            // Displaying missing information.
            Label missingInfoLabel = new Label(null);

            if (key.IsMissing)
            {
                missingInfoLabel.Markup = "Key is marked as missing. It cannot be loaned.";
            }
            else
            {
                missingInfoLabel.Markup = "Key is not marked as missing.";
            }
            container.Put(missingInfoLabel, 10, 10 + groupSpacing * 3);

            // Displaying loan information.
            Label loanInfoLabel = new Label(null);

            loanInfoLabel.Markup = "<b>Loan information:</b>";
            container.Put(loanInfoLabel, 10, 10 + groupSpacing * 4 - 40);
            Label loanInfoDescLabel = new Label();

            Loan loan = keyRegister.getActiveLoanByKeyId(key.DbId);

            // If loan object references to null, there is no loan for this key.
            if (loan != null)
            {
                if (loan.LoanedTo.Length > 0)
                {
                    loanInfoDescLabel.Text = "Currently loaned to '" + loan.LoanedTo + "'.";
                }
                else
                {
                    loanInfoDescLabel.Text = "Key is currently loaned. No loaner specified.";
                }
                loanInfoDescLabel.Text += "\n";
                if (loan.DateEnd.Length > 0)
                {
                    loanInfoDescLabel.Text += "Loan due at " + loan.DateEnd + ".";
                }
                else
                {
                    loanInfoDescLabel.Text += "No due date specified.";
                }
            }
            else
            {
                loanInfoDescLabel.Text = "Key is not currently loaned.";
            }
            container.Put(loanInfoDescLabel, 10, 10 + groupSpacing * 4 - 20);

            somethingChanged = false;

            ShowAll();
        }
Пример #12
0
        public NewLoanWindow(KeyRegister keyRegister, string title) : base(keyRegister, title)
        {
            // Setting deleteEvent.
            DeleteEvent += closeConfirmation;

            WidthRequest = 650;

            // Indentifier entry.
            keyIdLabel = new Label("Key identifier (required):");
            keyIdEntry = new Entry();
            keyIdEntry.WidthRequest = entryWidth;
            keyIdEntry.Changed     += onEntryChange;
            container.Put(keyIdLabel, 10, 10 + groupSpacing * 0);
            container.Put(keyIdEntry, 10, 10 + groupSpacing * 0 + labelEntrySpacing);

            // Start date entry.
            Label dateStartLabel = new Label("Loan starting date:");

            dateStartCal = new Calendar();
            dateStartCal.WidthRequest = entryWidth;
            container.Put(dateStartLabel, 10, 10 + groupSpacing * 1);
            container.Put(dateStartCal, 10, 10 + groupSpacing * 1 + labelEntrySpacing);

            // Due date entry.
            Label dateDuetLabel = new Label("Loan due date:");

            dateDueCal = new Calendar();
            dateDueCal.WidthRequest = entryWidth;
            container.Put(dateDuetLabel, 320, 10 + groupSpacing * 1);
            container.Put(dateDueCal, 320, 10 + groupSpacing * 1 + labelEntrySpacing);

            // No due date checkbox
            noDueDate = new CheckButton("No due date");
            //noDueDate.checked += onEntryChange;
            noDueDate.Clicked += onEntryChange;
            container.Put(noDueDate, 320, 10 + groupSpacing * 1 + 205);

            // Loaner entry.
            Label loanerLabel = new Label("Loaner (optional):");

            loanerEntry = new Entry();
            loanerEntry.WidthRequest = entryWidth;
            loanerEntry.Changed     += onEntryChange;
            container.Put(loanerLabel, 10, 10 + groupSpacing * 4 + 20);
            container.Put(loanerEntry, 10, 10 + groupSpacing * 4 + 20 + labelEntrySpacing);

            // Loaner entry.
            Label additionalLabel = new Label("Additional information (optional):");

            additionalEntry = new Entry();
            additionalEntry.WidthRequest = entryWidth;
            additionalEntry.Changed     += onEntryChange;
            container.Put(additionalLabel, 10, 10 + groupSpacing * 5 + 20);
            container.Put(additionalEntry, 10, 10 + groupSpacing * 5 + 20 + labelEntrySpacing);

            // Action button.
            actionButton           = new Button("Add loan");
            actionButton.Sensitive = false;
            actionButton.Clicked  += onActionButtonClicked;
            container.Put(actionButton, 10, 10 + groupSpacing * 6 + 20);

            // Instruction label.
            buttonInstructionLabel = new Label("Please fill all required fields");
            container.Put(buttonInstructionLabel, 105, 10 + groupSpacing * 6 + 20);

            ShowAll();
        }