Наследование: SmartCmdArgs.Helper.PropertyChangedBase
Пример #1
0
        // CRUD Operations
        public CmdArgItem AddNewItem(string command, bool enabled = true)
        {
            CmdArgItem item = new CmdArgItem() {
                Id = Guid.NewGuid(),
                Command = command,
                Enabled = enabled};

            DataCollection.Add(item);
            return item;
        }
        // CRUD Operations
        public CmdArgItem AddNewItem(string command, bool enabled = true)
        {
            CmdArgItem item = new CmdArgItem()
            {
                Id      = Guid.NewGuid(),
                Command = command,
                Enabled = enabled
            };

            DataCollection.Add(item);
            return(item);
        }
        internal void ToogleEnabledForItem(CmdArgItem item, bool exclusiveMode)
        {
            bool newState = !item.Enabled;

            // If exclusiveMode is true only one item at a time should be enabled
            if (exclusiveMode)
            {
                using (DataCollection.OpenBulkChange())
                {
                    int enabledCount = 0;
                    foreach (var cmdArgItem in DataCollection)
                    {
                        if (cmdArgItem.Enabled)
                        {
                            enabledCount++;
                        }

                        cmdArgItem.Enabled = false;
                    }

                    // If more than one items are enabled disable all, but not 'item'
                    if (enabledCount > 1)
                    {
                        newState = true;
                    }

                    item.Enabled = newState;
                }
            }
            // If item is selected set enable state of all selected items
            else if (SelectedItems.Contains(item))
            {
                using (DataCollection.OpenBulkChange())
                {
                    foreach (CmdArgItem i in SelectedItems)
                    {
                        i.Enabled = newState;
                    }
                }
            }
            // Just toggle the item
            else
            {
                item.Enabled = newState;
            }
        }
Пример #4
0
        internal void ToogleEnabledForItem(CmdArgItem item, bool exclusiveMode)
        {
            bool newState = !item.Enabled;

            // If exclusiveMode is true only one item at a time should be enabled
            if (exclusiveMode)
            {
                using (DataCollection.OpenBulkChange())
                {
                    int enabledCount = 0;
                    foreach (var cmdArgItem in DataCollection)
                    {
                        if (cmdArgItem.Enabled)
                            enabledCount++;

                        cmdArgItem.Enabled = false;
                    }

                    // If more than one items are enabled disable all, but not 'item'
                    if (enabledCount > 1)
                        newState = true;

                    item.Enabled = newState;
                }
            }
            // If item is selected set enable state of all selected items
            else if (SelectedItems.Contains(item))
            {
                using (DataCollection.OpenBulkChange())
                {
                    foreach (CmdArgItem i in SelectedItems)
                    {
                        i.Enabled = newState;
                    }
                }
            }
            // Just toggle the item
            else
            {
                item.Enabled = newState;
            }
        }