private void SpacePressed(string inputText)
        {
            if (IsSearchEnabled)
            {
                return;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(inputText))
                {
                    CustomerModels.Label newLabel = CreateLabel(inputText);
                    TagViewModelCollection.Add(new TagControlItemViewModel(newLabel)
                    {
                        IsEditing = false
                    });

                    var editViewModel = TagViewModelCollection.SingleOrDefault(item => item.IsEditing == true);
                    if (editViewModel != null)
                    {
                        (editViewModel.InnerItem as CustomerModels.Label).Name = string.Empty;
                    }

                    var view = CollectionViewSource.GetDefaultView(TagViewModelCollection);
                    view.SortDescriptions.Add(new SortDescription("IsEditing", ListSortDirection.Ascending));
                    view.Refresh();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// удаляем элемент из listview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click_1(object sender, RoutedEventArgs e)
        {
            //if (DeleteRequest != null)
            //{

            //    DeleteRequest.Raise(
            //        new Confirmation()
            //            {
            //                Title = "Remove label?",
            //                Content = "Are you sure you want to delete the note?"
            //            },
            //            (x) =>
            //            {
            //                if (x.Confirmed)
            //                {
            models.Label labelToCombo = (sender as Button).DataContext as models.Label;
            _labelsForCombobox.Add(labelToCombo);
            _labelsForListView.Remove(labelToCombo);
            //}

            _labelCollectionView.Refresh();
            //            }
            //        );
            //}
        }
        private CustomerModels.Label CreateLabel(string name, string description = "description")
        {
            CustomerModels.Label result = new CustomerModels.Label();

            result.Name        = name;
            result.Description = description;

            return(result);
        }
Esempio n. 4
0
        public LabelViewModel(Label item, ICustomerEntityFactory _customerEntityFactory, IFileDialogService fileDialogService)
        {
            _entityFactory = _customerEntityFactory;
            _innerItem = item.DeepClone(_entityFactory as IKnownSerializationTypes);
            _innerItem.PropertyChanged += _innerItem_PropertyChanged;

	        _fileDialogService = fileDialogService;

            CommandsInit();
        }
		private void RaiseEditLabelRequest(Label selectedLabel)
		{
			var itemVM = _labelVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", selectedLabel));
			CommonConfirmRequest.Raise(
				new ConditionalConfirmation(itemVM.InnerItem.Validate)
				{
					Title = "Edit Label",
					Content = itemVM
				},
				(x) =>
				{
					if (x.Confirmed)
					{
						ShowLoadingAnimation = true;
						Task.Factory.StartNew(() =>
						{
							using (var _repository = _repositoryFactory.GetRepositoryInstance())
							{
								var labelForUpdate = _repository.Labels.Where(l => l.LabelId == selectedLabel.LabelId).SingleOrDefault();
								if (labelForUpdate != null)
								{
									OnUIThread(() => labelForUpdate.InjectFrom<CloneInjection>(selectedLabel));
									_repository.UnitOfWork.Commit();
								}
							}
						}).ContinueWith(t =>
						{
							if (t.Exception != null)
							{
								if (t.Exception.InnerExceptions.Count > 0)
								{
									ShowErrorDialog(t.Exception.InnerExceptions[0], string.Format("Error: {0}", t.Exception.InnerExceptions[0].Message));
								}
							}
							else
							{
								var view = CollectionViewSource.GetDefaultView(Items);
								view.Refresh();
							}
							ShowLoadingAnimation = false;
						}, TaskScheduler.FromCurrentSynchronizationContext());
					}
				}
			);
		}
Esempio n. 6
0
        /// <summary>
        /// выбираем элемент в комбобоксе
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbLabels_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            cmbLabels.SelectionChanged -= cmbLabels_SelectionChanged_1;

            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                models.Label addedToListView = (e.AddedItems as IList <object>)[0] as models.Label;
                _labelsForListView.Add(addedToListView);
                _labelsForCombobox.Remove(addedToListView);
                e.Handled = true;

                if (nullItemsAdapter.ItemsSource != null)
                {
                    models.Label nullLabel = nullItemsAdapter.NullItems[0] as models.Label;
                    if (nullLabel != null)
                    {
                        cmbLabels.SelectedItem = nullLabel;
                    }
                }
            }

            cmbLabels.SelectionChanged += cmbLabels_SelectionChanged_1;
        }
		private void RaiseDeleteLabelRequest(Label selectedLabel)
		{
			CommonConfirmRequest.Raise(
				new ConditionalConfirmation
				{
					Title = "Delete confirmation",
					Content = string.Format("Are you sure you want to delete Label '{0}'?", selectedLabel.Name)
				},
				(x) =>
				{
					if (x.Confirmed)
					{
						ShowLoadingAnimation = true;
						Task.Factory.StartNew(() =>
						{
							var labelForDelete = selectedLabel;
							using (var _repository = _repositoryFactory.GetRepositoryInstance())
							{
								_repository.Remove(labelForDelete);
								_repository.UnitOfWork.Commit();
							}
							return labelForDelete;

						}).ContinueWith(t =>
						{
							if (t.Exception != null)
							{
								if (t.Exception.InnerExceptions.Count > 0)
								{
									ShowErrorDialog(t.Exception.InnerExceptions[0], string.Format("Error: {0}", t.Exception.InnerExceptions[0].Message));
								}
							}
							else
							{
								Items.Remove(t.Result);
							}
							ShowLoadingAnimation = false;
						}, TaskScheduler.FromCurrentSynchronizationContext());
					}
				}
			);
		}
		private Label CreateLabel(string name, string imgUrl, string description)
		{
			Label label = new Label();

			label.Name = name;
			label.ImgUrl = imgUrl;
			label.Description = description;

			return label;
		}
	    public void Can_create_labels_to_case_and_contact()
		{

			var client = GetRepository();

			var contactToDb = new Contact();
			contactToDb.FullName = "test";

			var caseToDb = new Case();

			contactToDb.Cases.Add(caseToDb);

			var labelForContact = new Label(){Name = "testName", Description = "testDescription"};

			var labelForCase = new Label() { Name = "testName", Description = "testDescription"};

			caseToDb.Labels.Add(labelForCase);
			
			contactToDb.Labels.Add(labelForContact);

			client.Add(contactToDb);
			client.UnitOfWork.Commit();


			client = GetRepository();

			var contactFromDB =
				client.Members.OfType<Contact>()
					.Where(c => c.MemberId == contactToDb.MemberId)
					.Expand(c => c.Cases)
					.Expand(c => c.Labels).SingleOrDefault();

			Assert.NotNull(contactFromDB);
			Assert.NotNull(contactFromDB.Cases);
			Assert.True(contactFromDB.Labels.Count==1);



			var caseFromDb =
				client.Cases.Where(c => c.CaseId == caseToDb.CaseId).Expand(c => c.Labels).SingleOrDefault();

			Assert.NotNull(caseFromDb);
			Assert.True(caseFromDb.Labels.Count == 1);

		}
        private CustomerModels.Label CreateLabel(string name, string description = "description")
        {
            CustomerModels.Label result=new CustomerModels.Label();

            result.Name = name;
            result.Description = description;

            return result;
        }
		public Label[] GetLabels()
		{

			List<Label> labels = new List<Label>();

			for (int i = 0; i < 15; i++)
			{
				Label lab = new Label() { Name = string.Format("Label {0}", i), Description = string.Format("labelDescription {0}", i) };
				labels.Add(lab);
			}


			return labels.ToArray();

		}