private void dgvMilitaries_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     PropertyComparer comparer = new PropertyComparer(this.dgvMilitaries.Columns[e.ColumnIndex].DataPropertyName, this.dgvMilitaries.Columns[e.ColumnIndex].DefaultCellStyle.Alignment == DataGridViewContentAlignment.MiddleRight, this.smalltobig);
     this.Militaries.Sort(comparer);
     this.RebindDataSource();
     this.smalltobig = !this.smalltobig;
 }
		internal void AddItem (object item, bool allowSorting)
		{
			int index = ProtectedItems.Count;
			if (allowSorting && Sorters.Count > 0 && !(item is CollectionViewGroup)) {
				var comparer = new PropertyComparer (Sorters);
				for (int i = 0; i < ProtectedItems.Count; i++) {
					if (comparer.Compare (item, ProtectedItems [i]) < 0) {
						index = i;
						break;
					}
				}
			}

			ProtectedItems.Insert (index, item);
			if (!(item is StandardCollectionViewGroup))
				IncrementCount ();
		}
        private void screen_OnMouseLeftDown(Point position)
        {
            if (StaticMethods.PointInRectangle(position, this.ToolDisplayPosition))
            {
                this.xianshiyoucelan  = !this.xianshiyoucelan ;
                if (true) //base.Enabled)
                {
                    if (this.xianshiyoucelan)
                    {
                        this.ToolDisplayTexture = this.ToolSelectedTexture;
                    }
                    else
                    {
                        this.ToolDisplayTexture = this.ToolTexture;
                    }
                }
            }

            if (this.xianshiyoucelan && (this.screen.PeekUndoneWork().Kind == UndoneWorkKind.None) && StaticMethods.PointInRectangle(position, this.RealClient))
            {
                if (position.Y < this.listKindToDisplay.ColumnsTop)
                {
                    Tab tab = this.FindTabByPosition(position);
                    if (tab != null)
                    {
                        tab.Selected = true;
                    }
                }
                else if (position.Y < (this.listKindToDisplay.ColumnsTop + this.columnheaderHeight))
                {
                    Column columnByPosition = this.GetColumnByPosition(position);
                    if (columnByPosition != null)
                    {
                        PropertyComparer comparer = new PropertyComparer(columnByPosition.Name, columnByPosition.IsNumber, columnByPosition.SmallToBig);
                        this.gameObjectList.Sort(comparer);
                        this.listKindToDisplay.ResetAllTextures();
                        columnByPosition.SmallToBig = !columnByPosition.SmallToBig;
                    }
                }
                else
                {
                    GameObject gameObjectByPosition;
                    if (this.ShowCheckBox)
                    {
                        gameObjectByPosition = this.GetGameObjectByPosition(position);
                        if (gameObjectByPosition != null)
                        {
                            if (this.listKindToDisplay.IsInEditableColumn(position))
                            {
                                if ((gameObjectByPosition.Selected || (this.SelectedItemMaxCount <= 0)) || (this.gameObjectList.GetSelectedList().Count < this.SelectedItemMaxCount))
                                {
                                    gameObjectByPosition.Selected = !gameObjectByPosition.Selected;
                                    if (this.MultiSelecting)
                                    {
                                        this.SelectingRows = true;
                                        this.SelectingBool = gameObjectByPosition.Selected;
                                        this.SelectedItemList = this.gameObjectList.GetSelectedList();
                                    }
                                    else
                                    {
                                        this.gameObjectList.SetOtherUnSelected(gameObjectByPosition);
                                    }
                                    this.OKButtonEnabled = this.gameObjectList.HasSelectedItem() || (gameObjectByPosition is Faction);
                                    this.ResetEditableTextures();
                                    if (gameObjectByPosition.Selected)
                                    {
                                        this.SelectedItem = gameObjectByPosition;
                                        if (!(this.MultiSelecting || !GlobalVariables.SingleSelectionOneClick))
                                        {
                                            this.iGameFrame.OK();
                                        }
                                        else
                                        {
                                            this.screen.PlayNormalSound(this.SelectSoundFile);
                                        }
                                    }
                                    else
                                    {
                                        this.SelectedItem = null;
                                    }
                                }
                            }
                            else
                            {
                                if (gameObjectByPosition is Troop)
                                {
                                    if ((this.iTroopDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iTroopDetail.SetPosition(ShowPosition.Center);
                                        this.iTroopDetail.SetTroop(gameObjectByPosition);
                                        this.iTroopDetail.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Troop).Position);
                                }
                                else if (gameObjectByPosition is Person)
                                {
                                    if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson(gameObjectByPosition);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                    if (!(gameObjectByPosition as Person).IsCaptive)
                                    {
                                        this.screen.JumpTo((gameObjectByPosition as Person).Position);
                                    }
                                }
                                else if (gameObjectByPosition is Architecture)
                                {
                                    if ((this.iArchitectureDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iArchitectureDetail.SetPosition(ShowPosition.Center);
                                        this.iArchitectureDetail.SetArchitecture(gameObjectByPosition);
                                        this.iArchitectureDetail.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Architecture).Position);
                                }
                                else if (gameObjectByPosition is Military)
                                {
                                    this.screen.JumpTo((gameObjectByPosition as Military).Position);
                                }
                                else if (gameObjectByPosition is Faction)
                                {
                                    if ((this.iFactionTechniques != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iFactionTechniques.SetArchitecture(null);
                                        this.iFactionTechniques.SetFaction(gameObjectByPosition, false);
                                        this.iFactionTechniques.SetPosition(ShowPosition.Center);
                                        this.iFactionTechniques.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Faction).Leader.Position);
                                }
                                else if (gameObjectByPosition is Captive)
                                {
                                    if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                }
                                else if (gameObjectByPosition is Treasure)
                                {
                                    if ((this.iTreasureDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iTreasureDetail.SetPosition(ShowPosition.Center);
                                        this.iTreasureDetail.SetTreasure(gameObjectByPosition);
                                        this.iTreasureDetail.IsShowing = true;
                                    }
                                    if ((gameObjectByPosition as Treasure).BelongedPerson != null)
                                    {
                                        this.screen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position);
                                    }
                                }
                                if (gameObjectByPosition != null)
                                {
                                    this.TriggerItemClick();
                                }
                            }
                        }
                    }
                    else
                    {
                        gameObjectByPosition = this.GetGameObjectByPosition(position);
                        if (gameObjectByPosition != null)
                        {
                            if (this.listKindToDisplay.SelectedTab.ListMethod != null)
                            {
                                this.PushSubKindByName(this.listKindToDisplay.SelectedTab.ListKind, StaticMethods.GetListMethodValue(gameObjectByPosition, this.listKindToDisplay.SelectedTab.ListMethod) as GameObjectList);
                            }
                            else
                            {
                                if (gameObjectByPosition is Troop)
                                {
                                    if ((this.iTroopDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iTroopDetail.SetPosition(ShowPosition.Center);
                                        this.iTroopDetail.SetTroop(gameObjectByPosition);
                                        this.iTroopDetail.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Troop).Position);
                                }
                                else if (gameObjectByPosition is Person)
                                {
                                    if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson(gameObjectByPosition);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                    if (!(gameObjectByPosition as Person).IsCaptive)
                                    {
                                        this.screen.JumpTo((gameObjectByPosition as Person).Position);
                                    }
                                }
                                else if (gameObjectByPosition is Architecture)
                                {
                                    if ((this.iArchitectureDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iArchitectureDetail.SetPosition(ShowPosition.Center);
                                        this.iArchitectureDetail.SetArchitecture(gameObjectByPosition);
                                        this.iArchitectureDetail.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Architecture).Position);
                                }
                                else if (gameObjectByPosition is Military)
                                {
                                    this.screen.JumpTo((gameObjectByPosition as Military).Position);
                                }
                                else if (gameObjectByPosition is Faction)
                                {
                                    if ((this.iFactionTechniques != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iFactionTechniques.SetArchitecture(null);
                                        this.iFactionTechniques.SetFaction(gameObjectByPosition, false);
                                        this.iFactionTechniques.SetPosition(ShowPosition.Center);
                                        this.iFactionTechniques.IsShowing = true;
                                    }
                                    this.screen.JumpTo((gameObjectByPosition as Faction).Leader.Position);
                                }
                                else if (gameObjectByPosition is Captive)
                                {
                                    if ((this.iPersonDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iPersonDetail.SetPosition(ShowPosition.Center);
                                        this.iPersonDetail.SetPerson((gameObjectByPosition as Captive).CaptivePerson);
                                        this.iPersonDetail.IsShowing = true;
                                    }
                                }
                                else if (gameObjectByPosition is Treasure)
                                {
                                    if ((this.iTreasureDetail != null) && (this.Function != FrameFunction.Jump))
                                    {
                                        this.iTreasureDetail.SetPosition(ShowPosition.Center);
                                        this.iTreasureDetail.SetTreasure(gameObjectByPosition);
                                        this.iTreasureDetail.IsShowing = true;
                                    }
                                    if ((gameObjectByPosition as Treasure).BelongedPerson != null)
                                    {
                                        this.screen.JumpTo((gameObjectByPosition as Treasure).BelongedPerson.Position);
                                    }
                                }
                                if (gameObjectByPosition != null)
                                {
                                    this.TriggerItemClick();
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        private void Sort(Property property, bool ascending)
        {
            // create an array of all the items in the grid
            object[] allObjects = SelectedObjects;

            // create a list of all the objects that are currently selected
            List<object> lastSelectedObjects = new List<object>();
            foreach (int index in m_selectedRows)
            {
                lastSelectedObjects.Add(allObjects[index]);
            }

            // See if the property descriptor we're looking at provides a custom sorting interface
            IComparer comparer = null;
            IPropertyCustomSorter sortingDescriptor = property.Descriptor as IPropertyCustomSorter;
            if (sortingDescriptor != null)
            {
                comparer = sortingDescriptor.GetComparer(ascending);
            }

            // If we didn't get a custom comparitor, just use the default one
            if (comparer == null)
            {
                comparer = new PropertyComparer(property.Descriptor, ascending);
            }

            // apply the sort
            Array.Sort(SelectedObjects, comparer);
            m_lastSortProperty = property;
            m_sortByPropertyName = m_lastSortProperty.Descriptor.Name;
            m_sortByPropertyDirection = ascending ? ListSortDirection.Ascending : ListSortDirection.Descending;

            // create the indexes for the selected objects in the new sort order
            List<int> selectedIndicies = new List<int>();
            foreach (object lastObject in lastSelectedObjects)
            {
                selectedIndicies.Add(Array.IndexOf(allObjects, lastObject));
            }

            // restore the selection
            SelectRange(selectedIndicies, 0);
        }
 public void ReSort()
 {
     PropertyComparer comparer = new PropertyComparer(this.PropertyName, this.IsNumber, this.SmallToBig);
     this.gameObjects.Sort(comparer);
 }
Example #6
0
 private void SortTheKeyColumn()
 {
     if (this.SortColumnID > 0)
     {
         Column columnByID = this.GetColumnByID(this.SortColumnID);
         if (columnByID != null)
         {
             PropertyComparer comparer = new PropertyComparer(columnByID.Name, columnByID.IsNumber, this.SmallToBig);
             this.tabList.gameObjectList.GameObjects.Sort(comparer);
         }
     }
 }
		protected override void InitializePropertiesForViewing()
		{
			using (var _appConfigRepository = _appConfigRepositoryFactory.GetRepositoryInstance())
			{
				SeoKeywords =
					_appConfigRepository.SeoUrlKeywords.Where(
						keyword =>
						keyword.KeywordValue.Equals(InnerItem.Code) && keyword.KeywordType.Equals((int)SeoUrlKeywordTypes.Category))
										.ToList();
			}

			var innerItemCatalog = _parentCatalog as catalogModel.Catalog;
			if (innerItemCatalog == null)
			{
				using (var storeRepository = _storeRepositoryFactory.GetRepositoryInstance())
				{
					var languages =
						storeRepository.Stores.Where(store => store.Catalog == _parentCatalog.CatalogId)
						               .Expand(store => store.Languages).ToList();

					var customComparer = new PropertyComparer<StoreLanguage>("LanguageCode");
					var lang = languages.SelectMany(x => x.Languages).Distinct(customComparer);

					InnerItemCatalogLanguages = new List<string>();
					if (lang.Any())
					{
						foreach (var l in lang)
						{
							InnerItemCatalogLanguages.Add(l.LanguageCode);
						}
					}
				}
			}
			
			InnerItemCatalogLanguages.ForEach(locale =>
			{
				if (!SeoKeywords.Any(keyword => keyword.Language.Equals(locale)))
				{
					SeoKeywords.Add(CreateSeoUrlKeyword(locale));
				}
			});

			// filter values by locale
			SeoLocalesFilterCommand.Execute(_parentCatalog.DefaultLanguage);
		}