コード例 #1
0
        async void HandleCurrentPageChanged(object sender, EventArgs e)
        {
            var thing = SelectedItem;

            if (SelectedItem.Equals(ItemsSource.Cast <int>().First()) && ActiveMonthNumber > 2)
            {
                ActiveMonthNumber--;
                await Task.Run(() =>
                {
                    ((ObservableCollection <int>)ItemsSource).RemoveAt(((ObservableCollection <int>)ItemsSource).Count() - 1);
                });

                await Task.Run(() =>
                {
                    ((ObservableCollection <int>)ItemsSource).Insert(0, ActiveMonthNumber - 1);
                });
            }
            else if (SelectedItem.Equals(ItemsSource.Cast <int>().Last()) && ActiveMonthNumber < 11)
            {
                ActiveMonthNumber++;
                await Task.Run(() =>
                {
                    ((ObservableCollection <int>)ItemsSource).RemoveAt(0);
                });

                await Task.Run(() =>
                {
                    ((ObservableCollection <int>)ItemsSource).Add(ActiveMonthNumber + 1);
                });
            }
        }
コード例 #2
0
        private string GetRowStyle(TItem item)
        {
            if (SelectedItem == null)
            {
                return(string.Empty);
            }

            return(SelectedItem.Equals(item) ? "table-selected-row" : string.Empty);
        }
コード例 #3
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var oldSelectedItem = SelectedItem;

            base.RowSelected(tableView, indexPath);
            if (SelectedItem.Equals(oldSelectedItem))
            {
                // if same item is selected, de-select
                SelectedItem = String.Empty;
            }

            TableView.ReloadData();
        }
コード例 #4
0
 public override bool HandleInput(FrameworkElement originalTarget, ConsoleKeyInfo keyInfo)
 {
     if ((this.Items?.Count() ?? 0) > 0)
     {
         if (this.SelectedItem == null)
         {
             this.SelectedItem = this.Items.First();
             return(true);
         }
         else if (keyInfo.Key == ConsoleKey.UpArrow)
         {
             var  iterator        = Items.GetEnumerator();
             T    previousElement = default;
             bool wasFound        = false;
             foreach (var item in Items)
             {
                 if (SelectedItem.Equals(item))
                 {
                     if (wasFound)
                     {
                         SelectedItem = previousElement;
                         return(true);
                     }
                     return(false);
                 }
                 previousElement = item;
                 wasFound        = true;
             }
             return(false);
         }
         else if (keyInfo.Key == ConsoleKey.DownArrow)
         {
             bool wasFound = false;
             foreach (var item in Items)
             {
                 if (wasFound)
                 {
                     SelectedItem = item;
                     return(true);
                 }
                 if (SelectedItem.Equals(item))
                 {
                     wasFound = true;
                 }
             }
             return(false);
         }
     }
     return(base.HandleInput(originalTarget, keyInfo));
 }
コード例 #5
0
        private void SetItemSourceAndReload()
        {
            SetNeedsReloadData();

            if (SelectedItem != null && Source.Items.OfType <object>().None(item => SelectedItem.Equals(item)))
            {
                ResetSelection();
            }

            this.SetContentOffset(new PointF(0, 0), false);

            // This is required to ensure that the list will notify its
            // parents that its size may change because of some of its items.
            SetSuperviewNeedsLayout();

            ObserveCollectionChanged();
        }
コード例 #6
0
    /// <summary>
    /// Remove the equivalent item from the inventory.
    /// </summary>
    public static void RemoveItem(InventoryItem prefab)
    {
        if (SelectedItem != null && SelectedItem.Equals(prefab))
        {
            ClearSelection();
        }

        foreach (InventorySlot slot in Slots)
        {
            if (slot.ItemEquals(prefab))
            {
                slot.Clear();
                CollapseItems(Slots.IndexOf(slot));
                break;
            }
        }
    }
コード例 #7
0
ファイル: PropertyBox.cs プロジェクト: dryftr/Legends-Viewer
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            Graphics g = CreateGraphics();

            Width = (int)g.MeasureString(Text, Font).Width + 20;
            g.Dispose();

            if (!SelectedItem.Equals(""))
            {
                SelectedProperty = SelectedItem as SearchProperty;
            }
            else
            {
                SelectedProperty = null;
            }

            if (Child != null)
            {
                PropertyBox temp = Child;
                Child = null;
                temp.Remove();
            }

            //if listproperties only and subproperties contains other lists or !list
            if (!ListPropertiesOnly && SelectedProperty != null && (!ListPropertiesOnly && SelectedProperty.SubProperties.Any() || ListPropertiesOnly && SelectedProperty.SubProperties.Count(property => property.SubProperties.Count > 0) > 0))
            {
                Child = new PropertyBox
                {
                    _parentProperty    = this,
                    ParentType         = (SelectedItem as SearchProperty).Type,
                    ListPropertiesOnly = ListPropertiesOnly,
                    Location           = new Point(Right + 0, Top)
                };
                Parent.Controls.Add(Child);
            }
            if (Parent.GetType() == typeof(CriteriaLine))
            {
                (Parent as CriteriaLine).GetComparers();
                (Parent as CriteriaLine).ValueSelect.ResetText();
                (Parent as CriteriaLine).GetValueOptions();
                (Parent as CriteriaLine).ResizeSelf();
            }

            base.OnSelectedIndexChanged(e);
        }
コード例 #8
0
        void OnSelectedItemChanged()
        {
            if (SelectedItem == null)
            {
                ClearSelectedRow();
                _selectedRow = null;
                return;
            }

            var records = ItemsSource as IEnumerable;

            if (records == null)
            {
                return;
            }

            var rowIndex = 0;

            foreach (var record in records)
            {
                if (SelectedItem.Equals(record))
                {
                    SelectedItem = record;
                    break;
                }

                rowIndex++;
            }

            var childs = _tbody.GetLogicalChilderen();

            if (childs.Count <= rowIndex)
            {
                return;
            }

            var tr = childs[rowIndex];

            MarkSelectedRow(tr);
        }
コード例 #9
0
        /// <summary>
        /// Method executes when the SelectionChanged command is invoked.
        /// The parameter <paramref name="p"/> can be an array of objects
        /// containing objects of the <seealso cref="IFolderItemViewModel"/> type
        /// or p can also be string.
        ///
        /// Each parameter item that adheres to the above types results in
        /// a OnCurrentPathChanged event being fired with the folder path
        /// as parameter.
        ///
        /// This mwthod can typically be invoked by:
        /// 1> Edit the text portion + Enter in the control or
        /// 2> By selecting an entry from the drop down list of the combobox.
        /// </summary>
        /// <param name="p"></param>
        private async Task SelectionChanged_ExecutedAsync(object p)
        {
            if (p == null)
            {
                return;
            }

            // Check if the given parameter is a string, fire a corresponding event if so...
            if (p is string)
            {
                IPathModel param = null;
                try
                {
                    param = PathFactory.Create(p as string);
                }
                catch
                {
                    return;   // Control will refuse to select an unknown/non-existing item
                }

                // This breaks a possible recursion, if a new view is requested even though its
                // already available, because this could, otherwise, change the SelectedItem
                // which in turn could request another PopulateView(...) -> SelectedItem etc ...
                if (SelectedItem != null)
                {
                    if (SelectedItem.Equals(param))
                    {
                        return;
                    }
                }

                if (param != null)
                {
                    var request = new BrowseRequest(param);
                    await InternalPopulateViewAsync(request, true);
                }
            }
            else
            {
                if (p is object[])
                {
                    var param = p as object[];

                    if (param != null)
                    {
                        if (param.Length > 0)
                        {
                            var newPath = param[param.Length - 1] as IFolderItemViewModel;

                            if (newPath != null)
                            {
                                IPathModel location          = null;
                                IPathModel selectedItemModel = null;
                                try
                                {
                                    location          = PathFactory.Create(newPath.ItemPath, newPath.ItemType);
                                    selectedItemModel = PathFactory.Create(SelectedItem.ItemPath, SelectedItem.ItemType);
                                }
                                catch
                                {
                                }

                                if (location == null || selectedItemModel == null)
                                {
                                    return;
                                }

                                // This breaks a possible recursion, if a new view is requested even though its
                                // already available, because this could, otherwise, change the SelectedItem
                                // which in turn could request another PopulateView(...) -> SelectedItem etc ...
                                if (location.Equals(selectedItemModel))
                                {
                                    return;
                                }

                                var request = new BrowseRequest(location);
                                await InternalPopulateViewAsync(request, true);
                            }
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: ApiTesterUIHelper.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Gets the post data for corporation API methods.
        /// </summary>
        /// <returns></returns>
        private static string GetCorporationAPIMethodsPostData()
        {
            if (SelectedItem == null)
            {
                return(String.Empty);
            }

            if (UseInternalInfo)
            {
                if (SelectedCharacter == null)
                {
                    return(String.Empty);
                }

                // Find associated API key
                Character character = (Character)SelectedCharacter;
                APIKey    apiKey    = character.Identity.FindAPIKeyWithAccess((CCPAPICorporationMethods)SelectedItem);

                // No API key found
                if (apiKey == null)
                {
                    // Post data for simple corporation sheet
                    if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationSheet))
                    {
                        return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataCorporationIDOnly,
                                             character.CorporationID));
                    }
                    return(NoAPIKeyWithAccess);
                }

                // Post data for corporation location
                if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationLocations))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndIDS,
                                         apiKey.ID, apiKey.VerificationCode, character.CharacterID, IDOrNameText));
                }

                // Post data for extended corporation member tracking
                if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationMemberTrackingExtended))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithExtendedParameter,
                                         apiKey.ID, apiKey.VerificationCode));
                }

                // Post data for corporation starbase details
                if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationStarbaseDetails))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithItemID,
                                         apiKey.ID, apiKey.VerificationCode, IDOrNameText));
                }

                // Generic post data
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataBase,
                                     apiKey.ID, apiKey.VerificationCode));
            }

            // Post data for simple corporation sheet
            if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationSheet) &&
                (KeyID.Length == 0 || VCode.Length == 0))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataCorporationIDOnly,
                                     CharID));
            }

            // Post data for corporation location
            if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationLocations))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndIDS,
                                     KeyID, VCode, CharID, IDOrNameText));
            }

            // Post data for extended corporation member tracking
            if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationMemberTrackingExtended))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithExtendedParameter,
                                     KeyID, VCode));
            }

            // Post data for corporation starbase details
            if (SelectedItem.Equals(CCPAPICorporationMethods.CorporationStarbaseDetails))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithItemID,
                                     KeyID, VCode, IDOrNameText));
            }

            // Generic post data
            return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataBase,
                                 KeyID, VCode));
        }
コード例 #11
0
ファイル: ApiTesterUIHelper.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Gets the post data for character API methods.
        /// </summary>
        /// <returns></returns>
        private static string GetCharacterAPIMethodsPostData()
        {
            if (SelectedItem == null)
            {
                return(String.Empty);
            }

            if (UseInternalInfo)
            {
                if (SelectedCharacter == null)
                {
                    return(String.Empty);
                }

                // Find associated API key
                Character character = (Character)SelectedCharacter;
                APIKey    apiKey    = character.Identity.FindAPIKeyWithAccess((CCPAPICharacterMethods)SelectedItem);

                // No API key found
                if (apiKey == null)
                {
                    return(NoAPIKeyWithAccess);
                }

                // Post data for character calendarEventAttendees, locations, mailBodies, notificationTexts
                if (SelectedItem.Equals(CCPAPICharacterMethods.CalendarEventAttendees) ||
                    SelectedItem.Equals(CCPAPICharacterMethods.Locations) ||
                    SelectedItem.Equals(CCPAPICharacterMethods.MailBodies) ||
                    SelectedItem.Equals(CCPAPICharacterMethods.NotificationTexts))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndIDS,
                                         apiKey.ID, apiKey.VerificationCode, character.CharacterID, IDOrNameText));
                }

                // Generic post data
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharID,
                                     apiKey.ID, apiKey.VerificationCode, character.CharacterID));
            }

            // Post data for character info
            if (SelectedItem.Equals(CCPAPICharacterMethods.CharacterInfo) &&
                (KeyID.Length == 0 || VCode.Length == 0))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataCharacterIDOnly,
                                     CharID));
            }

            // Post data for character calendarEventAttendees, locations, mailBodies, notificationTexts
            if (SelectedItem.Equals(CCPAPICharacterMethods.CalendarEventAttendees) ||
                SelectedItem.Equals(CCPAPICharacterMethods.Locations) ||
                SelectedItem.Equals(CCPAPICharacterMethods.MailBodies) ||
                SelectedItem.Equals(CCPAPICharacterMethods.NotificationTexts))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndIDS,
                                     KeyID, VCode, CharID, IDOrNameText));
            }

            // Generic post data
            return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharID,
                                 KeyID, VCode, CharID));
        }
コード例 #12
0
ファイル: ApiTesterUIHelper.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Gets the post data for the supplemental API methods.
        /// </summary>
        /// <returns></returns>
        private static string SupplementalAPIMethodsPostData()
        {
            if (SelectedItem == null)
            {
                return(String.Empty);
            }

            if (UseInternalInfo)
            {
                if (SelectedCharacter == null)
                {
                    return(String.Empty);
                }

                Character character = (Character)SelectedCharacter;
                APIKey    apiKey    = null;

                // Find associated API key for corporation contracts
                if (SelectedItem.ToString().StartsWith("CorporationContract", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICorporationMethods.CorporationContracts);
                }

                // Find associated API key for corporation industry jobs history
                if (SelectedItem.ToString().StartsWith("CorporationIndustryJobsHistory", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICorporationMethods.CorporationIndustryJobs);
                }

                // Find associated API key for corporation blueprints
                if (SelectedItem.ToString().StartsWith("CorporationBlueprints", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICorporationMethods.CorporationAssetList);
                }

                // Find associated API key for character contracts
                if (SelectedItem.ToString().StartsWith("Contract", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.Contracts);
                }

                // Find associated API key for character industry jobs history
                if (SelectedItem.ToString().StartsWith("IndustryJobsHistory", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.IndustryJobs);
                }

                // Find associated API key for character planetary interaction
                if (SelectedItem.ToString().StartsWith("Planetary", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.AssetList);
                }

                // Find associated API key for character blueprints
                if (SelectedItem.ToString().StartsWith("Blueprints", StringComparison.Ordinal))
                {
                    apiKey = character.Identity.FindAPIKeyWithAccess(CCPAPICharacterMethods.AssetList);
                }

                // No API key found
                if (apiKey == null)
                {
                    return(NoAPIKeyWithAccess);
                }

                // Post data for contract items
                if (SelectedItem.Equals(CCPAPIGenericMethods.ContractItems) ||
                    SelectedItem.Equals(CCPAPIGenericMethods.CorporationContractItems))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndContractID,
                                         apiKey.ID, apiKey.VerificationCode, character.CharacterID, IDOrNameText));
                }

                // Post data for planetary colonies
                if (SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryColonies))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharID,
                                         apiKey.ID, apiKey.VerificationCode, character.CharacterID, IDOrNameText));
                }

                // Post data for planetary pins, routes, and links
                if (SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryPins) ||
                    SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryRoutes) ||
                    SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryLinks))
                {
                    return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndPlanetID,
                                         apiKey.ID, apiKey.VerificationCode, character.CharacterID, IDOrNameText));
                }

                // Generic post data
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharID,
                                     apiKey.ID, apiKey.VerificationCode, character.CharacterID));
            }

            // Post data for contract items
            if (SelectedItem.Equals(CCPAPIGenericMethods.ContractItems) ||
                SelectedItem.Equals(CCPAPIGenericMethods.CorporationContractItems))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndContractID,
                                     KeyID, VCode, CharID, IDOrNameText));
            }

            // Post data for planetary pins, routes, and links
            if (SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryPins) ||
                SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryRoutes) ||
                SelectedItem.Equals(CCPAPIGenericMethods.PlanetaryLinks))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharIDAndPlanetID,
                                     KeyID, VCode, CharID, IDOrNameText));
            }

            // Generic post data
            return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataWithCharID,
                                 KeyID, VCode, CharID));
        }
コード例 #13
0
ファイル: ApiTesterUIHelper.cs プロジェクト: henrikja/EVEMon
        /// <summary>
        /// Gets the post data for generic API methods.
        /// </summary>
        /// <returns></returns>
        private static string GetPostDataForGenericAPIMethods()
        {
            if (SelectedItem == null)
            {
                return(String.Empty);
            }

            // Post data for character name, type name
            if (SelectedItem.Equals(CCPAPIGenericMethods.CharacterName) ||
                SelectedItem.Equals(CCPAPIGenericMethods.TypeName) ||
                SelectedItem.Equals(CCPAPIGenericMethods.CharacterAffiliation))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataIDsOnly, IDOrNameText));
            }

            // Post data for character id
            if (SelectedItem.Equals(CCPAPIGenericMethods.CharacterID) ||
                SelectedItem.Equals(CCPAPIGenericMethods.OwnerID))
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataNamesOnly, IDOrNameText));
            }

            // Post data for supplemental API methods
            if (APIMethods.AllSupplementalMethods.Contains(SelectedItem))
            {
                return(SupplementalAPIMethodsPostData());
            }

            // Post data for non account generic API methods
            if (APIMethods.NonAccountGenericMethods.Contains(SelectedItem))
            {
                return(String.Empty);
            }

            if (UseInternalInfo)
            {
                if (SelectedCharacter == null)
                {
                    return(String.Empty);
                }

                // Find associated API key
                Character character = (Character)SelectedCharacter;
                APIKey    apiKey    = character.Identity.APIKeys.FirstOrDefault(key => key.IsCharacterOrAccountType);

                // No API key found else generic post data
                return(apiKey == null
                    ? NoAPIKeyWithAccess
                    : String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataBase,
                                    apiKey.ID, apiKey.VerificationCode));
            }

            // Generic post data
            if (UseExternalInfo)
            {
                return(String.Format(CultureConstants.InvariantCulture, NetworkConstants.PostDataBase,
                                     KeyID, VCode));
            }

            return(String.Empty);
        }