Exemple #1
0
 /// <summary>
 /// Called when Commands property has changed.
 /// </summary>
 /// <param name="oldValue">Old property value</param>
 /// <param name="newValue">New property value</param>
 protected virtual void OnCommandsChanged(MetroBillCommands oldValue, MetroBillCommands newValue)
 {
     if (newValue != null)
     {
         newClientTile.Command  = newValue.ClientCommands.New;
         newInvoiceTile.Command = newValue.InvoiceCommands.New;
         appViewTile.Command    = newValue.ToggleStartControl;
         devCoTile.Command      = newValue.DevComponents;
         reportTile.Command     = newValue.NotImplemented;
         unpaidTile.Command     = newValue.NotImplemented;
         ytdTile.Command        = newValue.NotImplemented;
         helpTile.Command       = newValue.GettingStartedCommand;
     }
     else
     {
         newClientTile.Command  = null;
         newInvoiceTile.Command = null;
         appViewTile.Command    = null;
         devCoTile.Command      = null;
         reportTile.Command     = null;
         unpaidTile.Command     = null;
         ytdTile.Command        = null;
         helpTile.Command       = null;
     }
 }
        MetroBillCommands _Commands = null; // All application commands
        public MainForm()
        {
            InitializeComponent();

            // Prepare commands
            _Commands = new MetroBillCommands();

            _Commands.ToggleStartControl           = new Command(components);
            _Commands.ToggleStartControl.Executed += new EventHandler(ToggleStartControlExecuted);

            // Initialize Client related commands
            _Commands.ClientCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.ClientCommands.New.Executed    += NewClientExecuted;
            _Commands.ClientCommands.Cancel           = new Command(components);
            _Commands.ClientCommands.Cancel.Executed += CancelClientExecuted;
            _Commands.ClientCommands.Save             = new Command(components);
            _Commands.ClientCommands.Save.Executed   += SaveClientExecuted;
            // Invoice related commands
            _Commands.InvoiceCommands.New              = new Command(components); // We pass in components from Form so the command gets disposed automatically when form is disposed
            _Commands.InvoiceCommands.New.Executed    += NewInvoiceExecuted;
            _Commands.InvoiceCommands.Cancel           = new Command(components);
            _Commands.InvoiceCommands.Cancel.Executed += CancelInvoiceExecuted;
            _Commands.InvoiceCommands.Save             = new Command(components);
            _Commands.InvoiceCommands.Save.Executed   += SaveInvoiceExecuted;
            // General commands
            _Commands.ChangeMetroTheme      = new Command(components, new EventHandler(ChangeMetroThemeExecuted));
            _Commands.NotImplemented        = new Command(components, new EventHandler(NotImplementedExecuted));
            _Commands.DevComponents         = new Command(components, new EventHandler(DevComponentsExecuted));
            _Commands.GettingStartedCommand = new Command(components, new EventHandler(GettingStartedExecuted));

            this.SuspendLayout();
            _StartControl          = new StartControl();
            _StartControl.Commands = _Commands;
            this.Controls.Add(_StartControl);
            _StartControl.BringToFront();
            _StartControl.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;
            _StartControl.Click    += new EventHandler(StartControl_Click);
            this.ResumeLayout(false);

            // Assign commands to toolbar buttons
            newInvoiceButton.Command = _Commands.InvoiceCommands.New;
            newClientButton.Command  = _Commands.ClientCommands.New;

            // Add metro color themes
            MetroColorGeneratorParameters[] metroThemes = MetroColorGeneratorParameters.GetAllPredefinedThemes();
            foreach (MetroColorGeneratorParameters mt in metroThemes)
            {
                ButtonItem theme = new ButtonItem(mt.ThemeName, mt.ThemeName);
                theme.Command          = _Commands.ChangeMetroTheme;
                theme.CommandParameter = mt;
                colorThemeButton.SubItems.Add(theme);
            }

            AddSampleData();
        }
Exemple #3
0
 /// <summary>
 /// Called when Commands property has changed.
 /// </summary>
 /// <param name="oldValue">Old property value</param>
 /// <param name="newValue">New property value</param>
 protected virtual void OnCommandsChanged(MetroBillCommands oldValue, MetroBillCommands newValue)
 {
     if (newValue != null)
     {
         saveButton.Command   = newValue.ClientCommands.Save;
         cancelButton.Command = newValue.ClientCommands.Cancel;
     }
     else
     {
         saveButton.Command   = null;
         cancelButton.Command = null;
     }
 }