/// <summary>
 /// Synchronizes the group descriptions collection to the group descriptors collection.
 /// </summary>
 /// <param name="descriptor">The descriptor that changed</param>
 /// <param name="e">The property change event</param>
 private void HandleGroupDescriptorChanged(GroupDescriptor descriptor, PropertyChangedEventArgs e)
 {
     this._ignoreChanges = true;
     try
     {
         // We have to reset when the collections were not equal before the change
         if (this._sourceCollection.Count != this._descriptionCollection.Count)
         {
             GroupCollectionManager.ResetToGroupDescriptors(this._descriptionCollection, this._sourceCollection);
         }
         else
         {
             int index = this._sourceCollection.IndexOf(descriptor);
             GroupDescription description = GroupCollectionManager.GetDescriptionFromDescriptor(descriptor);
             if (description == null)
             {
                 this._descriptionCollection.RemoveAt(index);
             }
             else
             {
                 this._descriptionCollection[index] = description;
             }
         }
     }
     finally
     {
         this._ignoreChanges = false;
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Private,GroupCategory,IconPath")] GroupDescription groupDescription)
        {
            if (id != groupDescription.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(groupDescription);
                    _db.Save();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupDescriptionExists(groupDescription.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupCategory"] = new SelectList(_db.GetCategories(), "Id", "Name", groupDescription.GroupCategory);
            return(View(groupDescription));
        }
        internal virtual void RefreshGroups()
        {
            if (this.collectionView.IsRefreshDeferred)
            {
                return;
            }

            this.groupsCollection.Clear();

            // For now we use only the first group description
            GroupDescription description = this.GroupDescriptions.FirstOrDefault();

            if (description != null)
            {
                IEnumerable <TimeSlotGroup> groups =
                    from timeSlot in this.collectionView
                    group timeSlot by description.GroupNameFromItem(timeSlot, 1, this.collectionView.Culture)
                    into g
                    select new TimeSlotGroup(g);

                foreach (TimeSlotGroup group in groups)
                {
                    this.groupsCollection.Add(group);
                }
            }
            else
            {
                this.groupsCollection.Add(new TimeSlotGroup(this.collectionView));
            }
        }
Esempio n. 4
0
        internal QueryGroupsEventArgs(
            DataGridVirtualizingCollectionView collectionView,
            DataGridVirtualizingCollectionViewGroup parentGroup,
            GroupDescription childGroupDescription)
        {
            m_dataGridVirtualizingCollectionView = collectionView;
            m_readonlyGroupPath         = parentGroup.GroupPath.AsReadOnly();
            m_childGroupDescription     = childGroupDescription;
            this.ChildGroupPropertyName = DataGridCollectionViewBase.GetPropertyNameFromGroupDescription(childGroupDescription);

            m_sortDirection = SortDirection.None;

            SortDescriptionCollection sortDescriptions = m_dataGridVirtualizingCollectionView.SortDescriptions;

            int sortDescriptionCount = (sortDescriptions == null) ? 0 : sortDescriptions.Count;

            for (int i = 0; i < sortDescriptions.Count; i++)
            {
                SortDescription sortDescription = sortDescriptions[i];

                if (string.Equals(sortDescription.PropertyName, this.ChildGroupPropertyName))
                {
                    m_sortDirection = (sortDescription.Direction == ListSortDirection.Ascending) ? SortDirection.Ascending : SortDirection.Descending;
                    break;
                }
            }

            m_childGroupNameCountPairs = new List <GroupNameCountPair>();
        }
Esempio n. 5
0
        internal void UpdateCategorization(GroupDescription groupDescription, bool isPropertyGridCategorized)
        {
            // Compute Display Order relative to PropertyOrderAttributes on PropertyItem
            // which could be different in Alphabetical or Categorized mode.
            foreach (PropertyItem item in this.Items)
            {
                item.DescriptorDefinition.DisplayOrder = item.DescriptorDefinition.ComputeDisplayOrderInternal(isPropertyGridCategorized);
                item.PropertyOrder = item.DescriptorDefinition.DisplayOrder;
            }

            // Clear view values
            ICollectionView view = this.GetDefaultView();

            using (view.DeferRefresh())
            {
                view.GroupDescriptions.Clear();
                view.SortDescriptions.Clear();

                // Update view values
                if (groupDescription != null)
                {
                    view.GroupDescriptions.Add(groupDescription);
                    SortBy(CategoryOrderPropertyName, ListSortDirection.Ascending);
                    SortBy(CategoryPropertyName, ListSortDirection.Ascending);
                }

                SortBy(PropertyOrderPropertyName, ListSortDirection.Ascending);
                SortBy(DisplayNamePropertyName, ListSortDirection.Ascending);
            }
        }
Esempio n. 6
0
        protected virtual void ExecuteCore(ColumnBase column, int index)
        {
            var groupDescriptions = this.GroupDescriptions;

            if (groupDescriptions == null)
            {
                return;
            }

            GroupDescription groupDescription = this.GetGroupDescription(column);

            if (groupDescription == null)
            {
                groupDescription = new DataGridGroupDescription(this.GetColumnName(column));
            }

            var dataGridGroupDescription = groupDescription as DataGridGroupDescription;

            if ((dataGridGroupDescription != null) && (dataGridGroupDescription.GroupConfiguration == null))
            {
                dataGridGroupDescription.GroupConfiguration = this.GetGroupConfiguration(column);
            }

            if (index < 0)
            {
                groupDescriptions.Add(groupDescription);
            }
            else
            {
                groupDescriptions.Insert(index, groupDescription);
            }
        }
Esempio n. 7
0
        //Manual Get Station Name
        public void LoadFilterParameter()
        {
            //Stations = new ObservableCollection<string>(
            //                await RestAlarmsRepo.GetStationNameAsync());

            // Adding Station ComboBox items
            mstationItems.Add(new Item("All", "StationName"));
            foreach (var Station in RestAlarmsRepo.StationsName)
            {
                mstationItems.Add(new Item(Station.ToString(), "StationName"));
            }

            // Adding Priority ComboBox items
            mpriorityItems.Add(new Item("All", "Priority"));
            foreach (var Priority in RestAlarmsRepo.Priority)
            {
                mpriorityItems.Add(new Item(Priority.ToString(), "Priority"));
            }

            // Adding GoupDescription ComboBox items
            mgroupDescItems.Add(new Item("All", "GroupDescription"));
            foreach (var GroupDescription in RestAlarmsRepo.DeviceType)
            {
                mgroupDescItems.Add(new Item(GroupDescription.ToString(), "GroupDescription"));
            }
        }
Esempio n. 8
0
 internal void Initialize()
 {
     if (topLevelGroupDescription == null)
     {
         topLevelGroupDescription = new TopLevelGroupDescription();
     }
     this.InitializeGroup(this, 0);
 }
Esempio n. 9
0
 private object GetGroupName(object item, GroupDescription groupDescription, int level)
 {
     if (groupDescription != null)
     {
         return(groupDescription.GroupNameFromItem(item, level, this.Culture));
     }
     return(CollectionViewGroupRoot.UseAsItemDirectly);
 }
 internal void Initialize()
 {
     if (CollectionViewGroupRoot._topLevelGroupDescription == null)
     {
         CollectionViewGroupRoot._topLevelGroupDescription = (GroupDescription) new CollectionViewGroupRoot.TopLevelGroupDescription();
     }
     this.InitializeGroup((CollectionViewGroupInternal)this, CollectionViewGroupRoot._topLevelGroupDescription, 0);
 }
        protected override IGroup CreateNewGroup(GroupDescription groupDescription)
        {
            if (groupDescription.Key != null && groupDescription.Key != "Radio")
            {
                throw new ArgumentException("We only know about RadioGroups at present, not: " + groupDescription.Key);
            }

            return(new RadioGroup());
        }
Esempio n. 12
0
        private void Cv_SortChanged(object sender, System.EventArgs e)
        {
            GroupDescription yearGroupDescription    = new GroupDescription("Year");
            GroupDescription quarterGroupDescription = new GroupDescription("Quarter");
            GroupDescription monthGroupDescription   = new GroupDescription("MonthName");

            GroupDescription[] groupDescriptions = new GroupDescription[] { yearGroupDescription, quarterGroupDescription, monthGroupDescription };
            cv.GroupAsync(groupDescriptions);
        }
Esempio n. 13
0
        internal void ClearGroup()
        {
            m_groupDescription    = null;
            m_collectionViewGroup = null;
            m_propertyChanged     = null;

            this.DataGridContext       = null;
            this.GeneratorNode         = null;
            this.GroupLevelDescription = null;
        }
        internal GroupLevelDescription(GroupDescription groupDescription, string fieldName)
        {
            if (groupDescription == null)
            {
                throw new DataGridInternalException("GroupDescription cannot be null.");
            }

            m_groupDescription = groupDescription;
            m_fieldName        = fieldName;
        }
Esempio n. 15
0
        public void GroupBy(string propertyName, GroupDescription description)
        {
            _groupByPropertyName = propertyName;
            _groupDescription    = description;

            if (Loaded)
            {
                SetGrouping();
            }
        }
        /// <summary>
        /// Returns a <see cref="GroupDescriptor"/> equivalent to the specified description
        /// </summary>
        /// <param name="groupDescription">The description to get a descriptor from</param>
        /// <returns>A <see cref="GroupDescriptor"/> equivalent to the specified description</returns>
        /// <exception cref="InvalidOperationException"> is thrown if the description is not a
        /// <see cref="PropertyGroupDescription"/>.
        /// </exception>
        private static GroupDescriptor GetDescriptorFromDescription(GroupDescription groupDescription)
        {
            PropertyGroupDescription propertyGroupDescription = groupDescription as PropertyGroupDescription;

            if (propertyGroupDescription == null)
            {
                throw new InvalidOperationException(DomainDataSourceResources.RequiresPropertyGroupDescription);
            }
            return(new GroupDescriptor(propertyGroupDescription.PropertyName));
        }
Esempio n. 17
0
        public GroupModel FormGroupModel(int groupId, string email)
        {
            GroupDescription group = _groupRepo.GetElement(groupId); // Информация о текущей группе

            if (group == null)
            {
                return(null);
            }

            UserDescription user = _userRepo.GetElementByEmail(email);
            var             part = _participationRepo.GetElement(user.Id, groupId);
            string          role = null;

            if (part == null && !group.Private)
            {
                _participationRepo.Create(new Participation {
                    UserId = user.Id, GroupId = groupId, Role = 0
                });
                _participationRepo.Save();
                role = _roleRepo.GetElement(0).Name;
            }
            else
            {
                role = _roleRepo.GetElement(part.Role).Name;
            }

            List <RequestList>     requests        = _requestListRepo.GetElementsForGroup(groupId); // Список заявок в текущую группу
            List <UserDescription> requested_users = new List <UserDescription>();                  // Пользователи подавшие заявку

            for (int i = 0; i < requests.Count(); i++)
            {
                requested_users.Add(_userRepo.GetElement(requests[i].UserId));
            }

            List <Participation>   users_ids = _participationRepo.GetUsersForGroup(groupId); // список id участников текущей группы
            List <UserDescription> users     = new List <UserDescription>();                 // участники текущей группы

            for (int i = 0; i < users_ids.Count(); i++)
            {
                users.Add(_userRepo.GetElement(users_ids[i].UserId));
                users[i].Role = _roleRepo.GetElement(_participationRepo.GetElement(users[i].Id, groupId).Role).Name;
            }
            List <Files> files = _filesRepo.GetFilesForGroup(groupId);  // загруженные материалы текущей группы

            return(new GroupModel
            {
                Id = group.Id,
                Name = group.Name,
                requests = requested_users,
                members = users,
                files = files,
                Private = group.Private,
                Role = role
            });
        }
Esempio n. 18
0
 public async Task <IActionResult> Create([Bind("Id,Name,Private,GroupCategory,IconPath")] GroupDescription groupDescription)
 {
     if (ModelState.IsValid)
     {
         _db.Create(groupDescription);
         _db.Save();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["GroupCategory"] = new SelectList(_db.GetCategories(), "Id", "Name", groupDescription.GroupCategory);
     return(View(groupDescription));
 }
Esempio n. 19
0
 // get the group name(s) for the given item
 object GetGroupName(object item, GroupDescription groupDescription, int level)
 {
     if (groupDescription != null)
     {
         return(groupDescription.GroupNameFromItem(item, level, Culture));
     }
     else
     {
         return(UseAsItemDirectly);
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Group
        /// </summary>
        /// <param name="name"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public IGroupContainer <T> Group(String name, short row = 0, short column = 0, int?rowspan = null, int?columnspan = null)
        {
            GroupDescription item = new GroupDescription(name, row, column, null, rowspan, columnspan);

            item.ColumnSpan = columnspan;
            item.RowSpan    = rowspan;

            GroupCollection.Groups.Add(item);

            return(new GroupAdapter <T, GroupDescription>(item, item));
        }
        internal void SetSubGroupBy(GroupDescription groupBy)
        {
            bool oldIsBottomLevel = this.IsBottomLevel;

            m_subGroupBy = groupBy;

            if (oldIsBottomLevel != this.IsBottomLevel)
            {
                this.OnPropertyChanged(new PropertyChangedEventArgs("IsBottomLevel"));
            }
        }
Esempio n. 22
0
        public static SubgroupGroupDescriptionComposite convertSubgroupDescription(GroupDescription Gq)
        {
            SubgroupGroupDescription sGroup = (SubgroupGroupDescription)Gq;
            //TODO add error handling here.
            SubgroupGroupDescriptionComposite sGroupComp = new SubgroupGroupDescriptionComposite();

            sGroupComp.P = sGroup.P.ToByteArray();
            sGroupComp.Q = sGroup.Q.ToByteArray();
            sGroupComp.G = sGroup.G.GetEncoded();
            return(sGroupComp);
        }
Esempio n. 23
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (this.LstFields.SelectedItem == null)
            {
                MessageBox.Show("Please select a field from the list.", "select a field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            this._GroupDescription = this.LstFields.SelectedItem as GroupDescription;

            DialogResult = DialogResult.OK;
        }
 /// <summary>
 /// Resets the <paramref name="groupDescriptions"/> collection to match the <paramref name="groupDescriptors"/> collection.
 /// </summary>
 /// <param name="groupDescriptions">The collection to reset</param>
 /// <param name="groupDescriptors">The collection to match</param>
 private static void ResetToGroupDescriptors(ObservableCollection <GroupDescription> groupDescriptions, GroupDescriptorCollection groupDescriptors)
 {
     groupDescriptions.Clear();
     foreach (GroupDescriptor descriptor in groupDescriptors)
     {
         GroupDescription description = GroupCollectionManager.GetDescriptionFromDescriptor(descriptor);
         if (description != null)
         {
             groupDescriptions.Add(description);
         }
     }
 }
Esempio n. 25
0
 private void UpdateGrouping(GroupDescription groupDescription)
 {
     GroupDescriptions.Clear();
     if (groupDescription != null)
     {
         GroupDescriptions.Add(groupDescription);
     }
     if (View != null)
     {
         View.Refresh();
     }
 }
 /// <summary>
 /// Synchronizes the group descriptions collection to the group descriptors collection.
 /// </summary>
 /// <param name="e">The collection change event</param>
 private void HandleGroupDescriptorCollectionChanged(NotifyCollectionChangedEventArgs e)
 {
     this._ignoreChanges = true;
     try
     {
         // We have to reset in a number of situations
         // 1) Resetting the GroupDescriptors
         // 2) Collections were not equal before replacing GroupDescriptors
         // 3) Collections were not equal before removing GroupDescriptors
         // 4) Collections were not equal before adding GroupDescriptors
         if ((e.Action == NotifyCollectionChangedAction.Reset) ||
             ((e.Action == NotifyCollectionChangedAction.Replace) && ((this._sourceCollection.Count + e.OldItems.Count) != (this._descriptionCollection.Count + e.NewItems.Count))) ||
             ((e.Action == NotifyCollectionChangedAction.Remove) && ((this._sourceCollection.Count + e.OldItems.Count) != this._descriptionCollection.Count)) ||
             ((e.Action == NotifyCollectionChangedAction.Add) && (this._sourceCollection.Count != (this._descriptionCollection.Count + e.NewItems.Count))))
         {
             GroupCollectionManager.ResetToGroupDescriptors(this._descriptionCollection, this._sourceCollection);
         }
         else
         {
             if ((e.Action == NotifyCollectionChangedAction.Remove) ||
                 (e.Action == NotifyCollectionChangedAction.Replace))
             {
                 int index = e.OldStartingIndex;
                 if (e.Action == NotifyCollectionChangedAction.Replace) // TODO: This is a DependencyObjectCollection bug!
                 {
                     index = e.NewStartingIndex;
                 }
                 for (int i = 0; i < e.OldItems.Count; i++)
                 {
                     this._descriptionCollection.RemoveAt(index);
                 }
             }
             if ((e.Action == NotifyCollectionChangedAction.Add) ||
                 (e.Action == NotifyCollectionChangedAction.Replace))
             {
                 int index = e.NewStartingIndex;
                 foreach (object item in e.NewItems)
                 {
                     GroupDescription description = GroupCollectionManager.GetDescriptionFromDescriptor((GroupDescriptor)item);
                     if (description != null)
                     {
                         this._descriptionCollection.Insert(index++, description);
                     }
                 }
             }
         }
     }
     finally
     {
         this._ignoreChanges = false;
     }
 }
        /// <summary>
        /// Determines whether the <paramref name="groupDescription"/> and <paramref name="groupDescriptor"/> are equivalent.
        /// </summary>
        /// <param name="groupDescription">The description to compare</param>
        /// <param name="groupDescriptor">The descriptor to compare</param>
        /// <returns><c>true</c> if the two are equivalent</returns>
        private static bool AreEquivalent(GroupDescription groupDescription, GroupDescriptor groupDescriptor)
        {
            Debug.Assert((groupDescription != null) && (groupDescriptor != null), "Both should be non-null.");

            PropertyGroupDescription propertyGroupDescription = groupDescription as PropertyGroupDescription;

            if (propertyGroupDescription == null)
            {
                return(false);
            }

            return(propertyGroupDescription.PropertyName == groupDescriptor.PropertyPath);
        }
Esempio n. 28
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        /// <summary>
        /// Removes an empty group from the PagedCollectionView grouping
        /// </summary>
        /// <param name="group">Empty subgroup to remove</param>
        private static void RemoveEmptyGroup(CollectionViewGroupInternal group)
        {
            CollectionViewGroupInternal parent = group.Parent;

            if (parent != null)
            {
                GroupDescription groupBy = parent.GroupBy;
                int index = parent.ProtectedItems.IndexOf(group);

                // remove the subgroup unless it is one of the explicit groups
                if (index >= groupBy.GroupNames.Count)
                {
                    parent.Remove(group, false);
                }
            }
        }
Esempio n. 29
0
        private void RemoveEmptyGroup(CollectionViewGroupInternal group)
        {
            CollectionViewGroupInternal parent = group.Parent;

            if (parent == null)
            {
                return;
            }
            GroupDescription groupBy = parent.GroupBy;

            if (parent.ProtectedItems.IndexOf((object)group) < groupBy.GroupNames.Count)
            {
                return;
            }
            parent.Remove((object)group, false);
        }
Esempio n. 30
0
        internal DataGridGroupInfo(GroupDescription groupDescription, CollectionViewGroup collectionViewGroup)
        {
            if (groupDescription == null)
            {
                throw new ArgumentNullException("groupDescription");
            }

            if (collectionViewGroup == null)
            {
                throw new ArgumentNullException("collectionViewGroup");
            }

            this.GroupDescription = groupDescription;
            this.PropertyName     = DataGridCollectionViewBase.GetPropertyNameFromGroupDescription(groupDescription);
            this.Value            = collectionViewGroup.Name;
        }
    /// <summary>
    /// Constructs a new SampleDevice instance.
    /// </summary>
    /// <param name="gq">The group construction.</param>
    /// <param name="gd">The device generator.</param>
    public SmartCardDevice(GroupDescription gq, GroupElement gd, SmartCardParams smartCardParam)
    {
      pin = smartCardParam.pin;
      credID = smartCardParam.credID;
      groupID = smartCardParam.groupID;
      proverID = smartCardParam.proverID;
     
      // As SnartCardDevice do not provide a way to lookup card readr names
      // we provide a small potion of logic to lookup a card and cardreader
      List<CardInfo> cardInfoList = SmartCardUtils.GetReaderNames();
      // loop until we find a card with the status of "working mode". if none found
      // throw
      String readerName = null;
      foreach (CardInfo i in cardInfoList)
      {
        if (i.CardMode == (int)CardMode.WORKING)
        {
          readerName = i.ReaderName;
          break;
        }
      }
      if (readerName == null)
      {
        // TODO create a better exception
        throw new Exception("No card founds in working mode");
      }
      bool doTimeProfile = ParseConfigManager.doTimeProfile();
      this.device = new SmartCard(readerName, pin, doTimeProfile);
      // As the group and generator is set from the java init service we will only verify
      // TODO fix to see that group 0 is set on the hw smartcard.
      //if (!this.device.IsGeneratorSet(groupID))
      //{
        // TODO Find better exception
       // throw new Exception("No generator is set on the card to use this group");
      //}

      this.Gq = gq;
      this.Gd = gd;
    }
 public void EndGroup(TestGroup group)
 {
     Dispatcher.BeginInvoke(() =>
     {
         _currentGroup = null;
     });
 }
 public void StartGroup(TestGroup group)
 {
     Dispatcher.BeginInvoke(() =>
     {
         _currentGroup = new GroupDescription { Name = group.Name };
         _groups.Add(_currentGroup);
     });
 }
Esempio n. 34
0
 private object GetGroupName(object item, GroupDescription groupDescription, int level)
 {
     if (groupDescription != null)
     {
         return groupDescription.GroupNameFromItem(item, level, this.Culture);
     }
     return UseAsItemDirectly;
 }
Esempio n. 35
0
 internal void Initialize()
 {
     if (topLevelGroupDescription == null)
     {
         topLevelGroupDescription = new TopLevelGroupDescription();
     }
     this.InitializeGroup(this, 0, null);
 }
Esempio n. 36
0
 public static SubgroupGroupDescriptionComposite convertSubgroupDescription(GroupDescription Gq)
 {
   SubgroupGroupDescription sGroup = (SubgroupGroupDescription)Gq;
   //TODO add error handling here.
   SubgroupGroupDescriptionComposite sGroupComp = new SubgroupGroupDescriptionComposite();
   sGroupComp.P = sGroup.P.ToByteArray();
   sGroupComp.Q = sGroup.Q.ToByteArray();
   sGroupComp.G = sGroup.G.GetEncoded();
   return sGroupComp;
 }
 public async void EndGroup(TestGroup group)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         _currentGroup = null;
     });
 }
 public async void StartGroup(TestGroup group)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         _currentGroup = new GroupDescription { Name = group.Name };
         _groups.Add(_currentGroup);
     });
 }
 public async void StartGroup(TestGroup group)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         currentGroup = new GroupDescription { Name = group.Name };
         groups.Add(currentGroup);
     });
 }
 public async void EndGroup(TestGroup group)
 {
     await Dispatcher.InvokeAsync(() =>
     {
         currentGroup = null;
     });
 }