Esempio n. 1
0
        public BasicItemCreatorPresenter(BasicItemCreatorView view, Func <XmlNode, bool> addItemDelegate, Func <IEnumerable <IItem> > items)
        {
            #region Precondizioni
            if (view == null)
            {
                throw new ArgumentNullException("view null");
            }
            if (addItemDelegate == null)
            {
                throw new ArgumentNullException("addItemDelegate");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items null");
            }
            #endregion

            new BasicControlPresenter(view.Control, items);
            _addItemDelegate  = addItemDelegate;
            _bic              = view.Control;
            _addButton        = view.AddButton;
            _addButton.Click += AddButtonHandler;
            _bic.FriendlyNameBox.TextChanged += (obj, e) => CheckButtonStatus();
            _bic.DescriptionBox.TextChanged  += (obj, e) => CheckButtonStatus();
            _bic.IdentifierBox.TextChanged   += (obj, e) => CheckButtonStatus();
            CheckButtonStatus();
        }
Esempio n. 2
0
        public BasicControlPresenter(BasicItemControl control, Func <IEnumerable <IItem> > items, Style style = null)
        {
            #region Precondizioni
            if (control == null)
            {
                throw new ArgumentNullException("control null");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items null");
            }
            #endregion

            _identifierBox = control.IdentifierBox;
            _errorProvider = control.ErrorProvider;
            _items         = items;

            control.ApplyStyle(style);
            control.PriceBox.Minimum             = 0;
            control.FriendlyNameBox.TextChanged += NotNullTextHandler;
            control.DescriptionBox.TextChanged  += NotNullTextHandler;
            _identifierBox.TextChanged          += IdentifierTextChangedHandler;
            IdentifierTextChangedHandler(_identifierBox, EventArgs.Empty);
            NotNullTextHandler(control.FriendlyNameBox, EventArgs.Empty);
            NotNullTextHandler(control.DescriptionBox, EventArgs.Empty);
        }
        public CategorizableItemCreatorPresenter(CategorizableItemCreatorView view, Func <XmlNode, bool> addItemDelegate, Func <IEnumerable <IItem> > items)
        {
            ICategoryCoordinator coord;

            #region Precondizioni
            if (view == null)
            {
                throw new ArgumentNullException("view null");
            }
            if (addItemDelegate == null)
            {
                throw new ArgumentNullException("addItemDelegate null");
            }
            if (items == null)
            {
                throw new ArgumentNullException("items null");
            }
            coord = CoordinatorManager.Instance.CoordinatorOfType <ICategoryCoordinator>();
            if (coord == null)
            {
                throw new InvalidOperationException("non è disponibile un coordinatore delle categorie");
            }
            #endregion

            _addItemDelegate = addItemDelegate;
            _tableLayout     = view.TableLayout;
            _root            = coord.RootCategory;

            new BasicControlPresenter(view.Control, items);
            _addItemDelegate                  = addItemDelegate;
            _bic                              = view.Control;
            _addButton                        = view.AddButton;
            _addButton.BackColor              = SystemColors.Control;
            _addButton.Click                 += AddButtonHandler;
            _bic.FriendlyNameBox.TextChanged += (obj, e) => CheckButtonStatus();
            _bic.DescriptionBox.TextChanged  += (obj, e) => CheckButtonStatus();
            _bic.IdentifierBox.TextChanged   += (obj, e) => CheckButtonStatus();

            _width = DEFAULT_WIDTH;
            // Init tabella
            Style style = new Style();
            style.Font = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold);
            int freeSpace = _tableLayout.Width - IMAGE_SIZE - DEFAULT_WIDTH;
            // image - categoryPicker - value - desc - prezzo
            _tableLayout.ColumnStyles.Clear();
            _tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, IMAGE_SIZE));
            _tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, DEFAULT_WIDTH));
            _tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, Convert.ToInt32(freeSpace * 0.3)));
            _tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, Convert.ToInt32(freeSpace * 0.4)));
            _tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, Convert.ToInt32(freeSpace * 0.3) - SystemInformation.VerticalScrollBarWidth));
            _tableLayout.ColumnCount = _tableLayout.ColumnStyles.Count;
            _tableLayout.RowCount    = 1;
            _tableLayout.Controls.Add(new BorderLabel("", Color.White, Color.White, Color.White, 0, style));
            _tableLayout.Controls.Add(new BorderLabel("Scegli la categoria", Color.Black, Color.White, Color.White, 0, style));
            _tableLayout.Controls.Add(new BorderLabel("Valore", Color.Black, Color.White, Color.White, 0, style));
            _tableLayout.Controls.Add(new BorderLabel("Descrizione", Color.Black, Color.White, Color.White, 0, style));
            _tableLayout.Controls.Add(new BorderLabel("Prezzo", Color.Black, Color.White, Color.White, 0, style));

            AddCategoryInput(removable: false, addable: true);
            CheckButtonStatus();
        }