public void AddItemToList(object input)
        {
            RegexOptions options = RegexOptions.None;
            Regex        regex   = new Regex("[ ]{2,}", options);

            // 1. Make sure the item is not blank
            if (Item == null || String.IsNullOrWhiteSpace(Item))
            {
                return;
            }

            // 2. Format the item
            Item = Item.Trim();
            Item = regex.Replace(Item, " ");

            // 3. Make sure the Listbox doesn't already contain the item
            if (ItemsSource.Contains(Item))
            {
                return;
            }

            // 4. Add item to collection
            ItemsSource.Add(Item);

            // 5. Reset the item
            Item = null;
        }
예제 #2
0
        /// <summary>
        /// Add range of items into collection and save it
        /// </summary>
        /// <param name="itemList">List of imported items</param>
        /// <param name="reloadSource">Reload source if null</param>
        /// <returns>True, if action was succesfull</returns>
        public virtual async Task <bool> AddItemRange(List <T> itemList, bool reloadSource = true, bool CheckItems = true)
        {
            bool res = true;

            if (!reloadSource && ItemsSource == null)
            {
                ItemsSource    = new ObservableCollection <T>();
                ItemsSourceAll = new ObservableCollection <T>();
            }

            foreach (var item in itemList)
            {
                if (CheckItems)
                {
                    res &= await AddItem(item, false);
                }
                else
                {
                    ItemsSourceAll.Add(item);
                    ItemsSource.Add(item);
                }
            }

            await SaveDataAsync();

            return(res);
        }
예제 #3
0
        public PickerCellTestViewModel()
        {
            for (var i = 0; i < 30; i++)
            {
                ItemsSource.Add(new Person()
                {
                    Name = $"Name{i}",
                    Age  = 30 - i
                });
                ItemsSource2.Add(i);
            }

            DisplayMember.Value  = "Name";
            DisplayMember2.Value = "";

            OwnAccentColor.Value        = AccentColor;
            PageTitle.Value             = PageTitles[0];
            MaxSelectedNumber.Value     = MaxSelectedNumbers[0];
            KeepSelected.Value          = bools[0];
            SelectedItemsOrderKey.Value = DisplayMembers[0];
            ChangeSelectedItems();

            SelectedCommand.Subscribe(obj => {
                var list = obj as ObservableCollection <Person>;
                System.Diagnostics.Debug.WriteLine(list);
            });
        }
예제 #4
0
        async Task RefreshAsync()
        {
            CurrentPageNumber = 0;

            var realm = Realm.GetInstance();

            var currentThread = realm.All <SettingsRealmObject>().First().CurrentNode.CurrentThread;

            MaxPageNumber = await currentThread.UpdateAsync();

            ItemsSource.Clear();
            var comments = currentThread.Comments.OrderByDescending(o => o.CommentDateTime).ToList();

            System.Diagnostics.Debug.WriteLine("Comments count: " + comments.Count);
            realm.Write(() =>
            {
                for (var i = 0; i < comments.Count(); i++)
                {
                    var comment     = comments[i];
                    comment.IsFirst = false;
                    comment.IsLast  = false;
                    if (i == 0)
                    {
                        comment.IsFirst = true;
                    }
                    if (i == comments.Count() - 1)
                    {
                        comment.IsLast = true;
                    }
                    ItemsSource.Add(comment);
                }
            });
        }
예제 #5
0
        private void AddVertexLabel(ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            int index    = SatrtWayPointId;
            var polyline = geometry as Polyline;

            if (polyline != null)
            {
                Dictionary <MapPoint, int> wayPointIdMap = GetWayPointId(geometry);
                foreach (MapPoint item in polyline.Paths.FirstOrDefault())
                {
                    Shape dynamicShape = new Shape(Const.ConstWayPoint);
                    var   textSymbol   = new TextSymbol()
                    {
                        OffsetX = DefaultWayPointOffsetX, OffsetY = DefaultWayPointOffsetY, FontSize = DefaultWayPointFontSize, Foreground = DefaultWayPointForeground
                    };
                    if (wayPointIdMap.ContainsKey(item))
                    {
                        index = wayPointIdMap[item];
                    }
                    else
                    {
                        index++;
                    }
                    textSymbol.Text       = DefaultWayPointPrefix + index.ToString();
                    dynamicShape.Geometry = item;
                    dynamicShape.Symbol   = textSymbol;
                    _vertexGraphicList.Add(dynamicShape);
                    ItemsSource.Add(dynamicShape);
                }
            }
        }
예제 #6
0
        public SettingsViewPageViewModel(INavigationService navigationService, IPageDialogService pageDlg)
        {
            InputText = new ReactiveProperty <string>().SetValidateAttribute(() => this.InputText);

            InputError = InputText.ObserveErrorChanged
                         .Select(x => x?.Cast <string>()?.FirstOrDefault())
                         .ToReadOnlyReactiveProperty();

            SectionToggleCommand = InputText.ObserveHasErrors.Select(x => !x).ToAsyncReactiveCommand();
            SectionToggleCommand.Subscribe(async _ => {
                InputSectionVisible.Value = !InputSectionVisible.Value;
                await Task.Delay(250);
            });

            ToProfileCommand.Subscribe(async _ => {
                await navigationService.NavigateAsync("DummyPage");
            });

            foreach (var item in languages)
            {
                ItemsSource.Add(new Person()
                {
                    Name = item,
                    Age  = 1
                });
            }

            SelectedItems.Add(ItemsSource[1]);
            SelectedItems.Add(ItemsSource[2]);
            SelectedItems.Add(ItemsSource[3]);
        }
예제 #7
0
파일: Measurements.cs 프로젝트: xj0229/gsf
        private void Searcher_MatchesFound(object sender, EventArgs <IEnumerable <DataModels.Measurement> > e)
        {
            try
            {
                foreach (DataModels.Measurement measurement in e.Argument)
                {
                    ItemsKeys.Add(measurement.SignalID);
                }

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (ItemsSource.Count == 0)
                    {
                        Load();
                    }
                    else
                    {
                        if (ItemsSource.Count < ItemsPerPage)
                        {
                            e.Argument.Take(ItemsPerPage - ItemsSource.Count).ToList()
                            .ForEach(measurement => ItemsSource.Add(measurement));
                        }

                        GeneratePages();
                    }
                }));
            }
            catch (Exception ex)
            {
                CommonFunctions.LogException(null, "Search " + DataModelName, ex);
            }
        }
예제 #8
0
        private void OnComplete(ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            var shapeId = ServiceLocator.Current.GetInstance <IMissionSource>().GenerateTaskId();

            if (ItemsSource != null && DrawMode != DrawMode.None)
            {
                geometry.SpatialReference = new SpatialReference(Esri.GCS_WGS_1984);
                ItemsSource.Add(new Shape
                {
                    Geometry = geometry,
                    ID       = shapeId
                });
                var geo = geometry as Polyline;
                if (geo != null)
                {
                    var points    = geo.Paths.ToList()[0];
                    var pointList = points.Select(point => new Point(point.X, point.Y)).ToList();

                    Messenger.Default.Send(new MapWaypointMessenger
                    {
                        Points = pointList,
                        TaskId = shapeId
                    });
                }
            }
        }
예제 #9
0
        private void PopupListBoxOnSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            if (_popupListBox.SelectedItem != null)
            {
                if (CheckExist != null)
                {
                    if (!CheckExist(ItemsSource, _popupListBox.SelectedItem))
                    {
                        ItemsSource.Add(_popupListBox.SelectedItem);
                    }
                    else
                    {
                    }
                }
                else
                {
                    ItemsSource.Add(_popupListBox.SelectedItem);
                }

                _completeBox.Text          = "";
                _popupListBox.SelectedItem = null;
                var e = _popupListBox.ItemsSource as IList;
                if (e != null)
                {
                    e.Clear();
                }
            }

            _isFocusFromPopup = true;
        }
예제 #10
0
        async Task LoadMoreNewerAsync()
        {
            await DetectThreadService.LogAsync();

            if (CurrentPageNumber < MaxPageNumber)
            {
                var realm = Realm.GetInstance();

                var currentThread = realm.All <SettingsRealmObject>().First().CurrentNode.CurrentThread;

                var lastCommentId = ItemsSource.Last().CommentId;
                MaxPageNumber = await currentThread.UpdateAsync(++CurrentPageNumber);

                var newItemsSource          = currentThread.Comments.OrderByDescending(o => o.CommentDateTime).ToList();
                var lastComment             = newItemsSource.Where(o => o.CommentId == lastCommentId).First();
                var newItemSourceBeginIndex = newItemsSource.IndexOf(lastComment) + 1;
                System.Diagnostics.Debug.WriteLine("newItemSourceBeginIndex: " + newItemSourceBeginIndex);
                await Device.InvokeOnMainThreadAsync(() =>
                {
                    for (var i = newItemSourceBeginIndex; i < newItemsSource.Count; i++)
                    {
                        if (i < newItemsSource.Count)
                        {
                            ItemsSource.Add(newItemsSource[i]);
                        }
                    }
                });

                System.Diagnostics.Debug.WriteLine("New Page: " + CurrentPageNumber);
                System.Diagnostics.Debug.WriteLine("New ItemsSource.Count: " + ItemsSource.Count);
            }
        }
예제 #11
0
        private void AddRow_Click(object sender, RoutedEventArgs e)
        {
            ScoreRow newRow = new ScoreRow(numTotalQuestions, CommonConst.EmptyString);

            ItemsSource.Add(newRow);
            ScoreDataGrid.Height = (ItemsSource.Count * 50) + 60;
        }
예제 #12
0
        internal void Select(TEntityAction entityAction)
        {
            // DATA IN:
            // action.CollectionAction.ModelCollection

            entityAction.ThrowNull();

            //Registrations.Clear ();
            ItemsSource.Clear();

            var gadgets = new Collection <TActionComponent> ();

            TActionConverter.Collection(TCategory.Registration, gadgets, entityAction);

            foreach (var model in gadgets)
            {
                ItemsSource.Add(model.Models.GadgetRegistrationModel);
            }

            //foreach (var gadget in action.CollectionAction.GadgetRegistrationCollection) {
            //  if (action.CollectionAction.ModelCollection.ContainsKey (gadget.Id)) {
            //    var modelAction = action.CollectionAction.ModelCollection [gadget.Id];
            //    modelAction.GadgetRegistrationModel.CopyFrom (gadget);

            //    action.ModelAction.CopyFrom (modelAction);

            //    var item = TComponentModelItem.Create (action);

            //    Registrations.Add (item);
            //    RegistrationItemsSource.Add (item);
            //  }
            //}

            SelectedIndex = ItemsSource.Any() ? 0 : -1;
        }
 public virtual async Task LoadMoreItems()
 {
     foreach (var item in await LoadItems().ConfigureAwait(false))
     {
         ItemsSource.Add(item);
     }
 }
예제 #14
0
        /// <summary>
        /// Add item into collection and save it, when required
        /// </summary>
        /// <param name="item">New item</param>
        /// <param name="saveData">Save data after adding item into collection</param>
        /// <returns>True, if action was succesfull</returns>
        public virtual async Task <bool> AddItem(T item, bool saveData = true)
        {
            T NewItem = item;

            NewItem.Encrypted = false;
            NewItem.ManagerID = ID;

            if (ItemsSource == null)
            {
                await GetItemsAsync();
            }

            if (NewItem.ID == -1)
            {
                if (ItemsSource != null)
                {
                    NewItem.ID = GetID();
                }
                else
                {
                    NewItem.ID = 0;
                }

                ItemsSource.Add(NewItem);
            }
            else
            {
                int Index = ItemsSource.IndexOf(ItemsSource.FirstOrDefault(x => x.ID == NewItem.ID));
                if (Index == -1)
                {
                    Index = IndexOfItem(NewItem);
                }

                if (Index == -1)
                {
                    return(false);
                }

                ItemsSource.RemoveAt(Index);

                ItemsSource.Insert(Index, NewItem);
            }

            if (!AddItemAdditionCheck(item))
            {
                return(false);
            }

            if (saveData)
            {
                await SaveDataAsync();
            }
            else
            {
                ItemsSourceAll.Add(NewItem);
            }

            return(true);
        }
예제 #15
0
        public void Open(string FileName)
        {
            FormatHandler schema;

            schema = FormatHandler.LoadFromFile(FileName);
            ItemsSource.Add(schema);
            SelectedItem = schema;
        }
예제 #16
0
 public void Add(T item)
 {
     using (BeginChanging())
     {
         ItemsSource.Add(ReverseMap(item));
         Items.Add(item);
     }
 }
예제 #17
0
 protected override void AddItem_Execute(object parameter)
 {
     if (parameter is Type viewModelType && viewModelType.GetConstructor(Type.EmptyTypes).Invoke(null) is ViewModelBase viewModel)
     {
         ItemsSource.Add(viewModel);
         SelectedItem = viewModel;
     }
 }
예제 #18
0
        private void AddItemsModel(object o)
        {
            var model = new MeshDataModel();

            model.Geometry  = SphereModel;
            model.Material  = GreenMaterial;
            model.Transform = new Media3D.TranslateTransform3D(0, -(ItemsSource.Count) * 2, 0);
            ItemsSource.Add(model);
        }
예제 #19
0
        private void AddNewTag(string tag)
        {
            var tagLower = tag.ToLower();

            if (ItemsSource.FirstOrDefault(x => x.ToLower() == tagLower) != null)
            {
                return;
            }
            ItemsSource.Add(tag);
        }
예제 #20
0
        public void SwitchC()
        {
            ItemsSource.Add(new ValueObject()
            {
                Libelle = $"Libelé {inc}",
                Value   = inc++,
            });

            NotifyOfPropertyChange("ItemsSource");
        }
        private void OnAddItemCommand()
        {
            if (string.IsNullOrEmpty(AddItemText))
            {
                return;
            }

            ItemsSource.Add(AddItemText);
            AddItemText = string.Empty;
        }
예제 #22
0
 protected override void OnInitialized()
 {
     for (var i = 0; i < 4; i++)
     {
         var itemViewModel = GetViewModel <ItemViewModel>();
         itemViewModel.Name = "Default item";
         ItemsSource.Add(itemViewModel);
     }
     SelectedItem = ItemsSource[0];
 }
예제 #23
0
 public PropertiesWindow(ObservableCollection <DataFormListEntry> entries, DataFormListEntry selectedItem)
 {
     InitializeComponent();
     DoSetup();
     foreach (DataFormListEntry entry in entries)
     {
         ItemsSource.Add(entry);
     }
     this.SelectedItem = selectedItem;
 }
예제 #24
0
 public MultiSelectorAttSampleVM()
 {
     for (int i = 0; i < 20; ++i)
     {
         ItemsSource.Add(new MultiSelectorAttSampleItemVM()
         {
             Name = string.Format("item{0}", i)
         });
     }
 }
예제 #25
0
 public void ReplaceTag(string oldValue, string newValue)
 {
     if (ItemsSource.Contains(oldValue))
     {
         ItemsSource[ItemsSource.IndexOf(oldValue)] = newValue;
     }
     else
     {
         ItemsSource.Add(newValue);
     }
 }
        public async void Initialize()
        {
            ItemsSource.Clear();
            DatabasePath = DatabaseConfig.DbPath;
            var products = await _productService.Get();

            foreach (var p in products)
            {
                ItemsSource.Add(p);
            }
        }
예제 #27
0
        /// <summary>
        /// Add new activity to collection and save it
        /// </summary>
        /// <param name="Item">New activity</param>
        /// <returns>Result of add action. True = successful</returns>
        public async Task <bool> AddActivity(Activity Item)
        {
            Activity NewActivity = Item;

            if (NewActivity.ID == -1)
            {
                if (ItemsSource != null)
                {
                    NewActivity.ID = GetID();
                }
                else
                {
                    NewActivity.ID = 0;
                }

                ItemsSource.Add(NewActivity);
            }
            else
            {
                int Index = ItemsSource.IndexOf(NewActivity);
                if (Index == -1)
                {
                    Index = IndexOfTask(NewActivity);
                }

                if (Index == -1)
                {
                    return(false);
                }

                ItemsSource[Index] = NewActivity;
            }

            if (Item.NotifyDays.Count == 0)
            {
                Item.NotifyDays = new ObservableCollection <DayOfWeek>
                {
                    DayOfWeek.Monday,
                    DayOfWeek.Tuesday,
                    DayOfWeek.Wednesday,
                    DayOfWeek.Thursday,
                    DayOfWeek.Friday,
                    DayOfWeek.Saturday,
                    DayOfWeek.Sunday
                }
            }
            ;

            await SaveDataAsync();

            return(true);

            //UpdatePhraseList();
        }
예제 #28
0
        public void CreateNew()
        {
            FormatHandler schema;

            schema = new FormatHandler()
            {
                Name = "New format handler"
            };
            ItemsSource.Add(schema);
            SelectedItem = schema;
        }
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            ItemsSource.Add(AddStringBox.Text);
            AddStringBox.Clear( );
            object o = this.DataContext;

            if (!(o is INotifyCollectionChanged))
            {
                this.DataContext = null;
                this.DataContext = o;
            }
        }
예제 #30
0
        private void AddCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            AddItemEventArgs e2;

            e2 = new AddItemEventArgs();

            AddItem?.Invoke(this, e2);
            if (e2.AddedItem != null)
            {
                SelectedItem = ItemsSource.Add(e2.AddedItem);
            }
        }