Esempio n. 1
0
        public BadgeToolBar(Patron patron, ApplicationPresenter presenter)
        {
            _patron = patron;
            _presenter = presenter;
            InitializeComponent();
            PrintedName.Text = patron.CurrentCard.Name;

            EligibleCard prompt = new EligibleCard();
            prompt.CardName = "Select Badge";
            TemplateCombo.Items.Add(prompt);

            foreach (XmlCardDefinition def in LoginPresenter.DefinitionsList)
            {
                if (def.TemplateType.Equals("BADGE"))
                {
                    if (def.CardFields.Count > 0)
                    {
                        foreach (CardFields project in def.CardFields)
                        {
                            EligibleCard ec = new EligibleCard();
                            ec.CardProject = def.TemplateFileName;
                            ec.CardProject = ec.CardProject.Substring(0, ec.CardProject.IndexOf("."));
                            ec.CardName = project.CardName;
                            ec.CardType = "BADGE";
                            ec.ExpireMonths = def.ExpireMonths;
                            ec.CardFields = def.CardFields.Find(x => x.CardName == ec.CardName);
                            TemplateCombo.Items.Add(ec);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void showCardPreview(EligibleCard def)
        {
            var CardRole = def.CardFields.CardField.Find(x => x.Name.Equals("__Role"));
            if (CardRole != null)
            {
                if (Role.Text == "")
                {
                    MessageBox.Show("You need to enter a Role for this badge.");
                    return;
                }
                else
                    CardRole.Value = Role.Text;
            }

            var CardExp = def.CardFields.CardField.Find(x => x.Name.Equals("__ExpirationDate"));
            if (CardExp != null)
            {
                if (ExpirationDate.ToString() == "")
                {
                    MessageBox.Show("You need to enter an Expiration Date for this badge.");
                    return;
                }
                else
                    CardExp.Value = ExpirationDate.Text;
            }

            IntPtr handle = new WindowInteropHelper(_presenter.View).Handle;
            Task t = new Task(() =>
            {
                ApplicationPresenter.Manager.ShowCardPreview(def, _patron, handle);
            });
            t.Start();
        }