Exemplo n.º 1
0
        private void OnTagRemoved(TagRemovedMessage msg)
        {
            var tag = AllTags.FirstOrDefault(t => t.Model == msg.Tag);

            AllTags.Remove(tag);
            Tags.Remove(tag);
        }
Exemplo n.º 2
0
 void OnEnable()
 {
     if (!AllTags.Contains(this))
     {
         AllTags.Add(this);
     }
 }
Exemplo n.º 3
0
        public TodoViewModel(Todo todo)
        {
            MessengerInstance.Register <TagAddedMessage>(this, OnTagAdded);
            MessengerInstance.Register <TagRemovedMessage>(this, OnTagRemoved);

            TodoRepo = new TodoRepository(App.Session);
            Model    = todo;
            _Done    = Model.Done;

            if (Model?.Project?.Tags != null)
            {
                AllTags = new ObservableCollection <TodoTagViewModel>(Model.Project.Tags.Select(t => new TodoTagViewModel(t)
                {
                    IsSelected = Model.Tags.Contains(t)
                }));
            }
            else
            {
                AllTags = new ObservableCollection <TodoTagViewModel>();
            }

            foreach (var t in AllTags)
            {
                t.Selected   += Tag_Selected;
                t.Deselected += Tag_Deselected;
            }

            Tags = new ObservableCollection <TodoTagViewModel>(AllTags.Where(t => t.IsSelected));
        }
Exemplo n.º 4
0
        public IActionResult ShowPopUpTags()
        {
            AllTags mw = new AllTags();

            mw.user_tags = repo.GetUserTags(Current_idUser);
            mw.pop_tags  = repo.GetPopularTags(10);
            return(View(mw));
        }
Exemplo n.º 5
0
        public IList <Note> GetNotesByTags(params string[] args)
        {
            var tags   = AllTags.Where(m => args.Contains(m.Name)).Select(m => m.Guid).ToList();
            var filter = new NoteFilter {
                TagGuids = tags
            };
            var notes = Note.FindNotes(filter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX);

            return(notes.Notes.OrderBy(m => m.Title).ToList());
        }
Exemplo n.º 6
0
        private void AddNewTag()
        {
            if (TagSearchDataContext.FullSearchText.Length > 20)
            {
                MessageBox.Show("Tag name cannot be longer than 20 characters (including space).", "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error, MessageBoxResult.OK);
                return;
            }

            // Check if this tag has been deleted before, then prompt the user to see if we should restore or replace it.
            var newTag = DeletedTags.SingleOrDefault(t => t.Name == TagSearchDataContext.FullSearchText);

            if (newTag == null)
            {
                newTag = Context.Tags.SingleOrDefault(t => t.DateDeleted != null && t.Name == TagSearchDataContext.FullSearchText);
            }

            if (newTag != null)
            {
                var result =
                    MessageBox.Show($"The tag [{newTag.Name}] was previously deleted. You can either restore this tag and all Omni associations, " +
                                    "or replace the deleted tag with a brand new one.\n\nWhen this tag is undeleted, do you want to restore " +
                                    "Omni associations?", "Confirm Restore", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                else if (result == MessageBoxResult.No)
                {
                    newTag.Omnis.Clear();
                    Context.Tags.Remove(newTag);
                    newTag = null;
                }
                DeletedTags.Remove(newTag);
            }

            if (newTag == null)
            {
                newTag = new Tag
                {
                    Name = TagSearchDataContext.FullSearchText,
                };
                AddedTags.Add(newTag);
            }

            newTag.DateDeleted      = null;
            newTag.LastModifiedDate = DateTime.Now;
            newTag.IsVerified       = true;
            newTag.ManuallyVerified = true;

            AllTags.Add(newTag);
            TagSearchDataContext.FullSearchText = String.Empty;
            SelectedTag = newTag;
            ChangesMade = true;
        }
Exemplo n.º 7
0
    /// <summary>
    /// Add new tag.
    /// </summary>
    public async void AddTagAsync()
    {
        TagEditViewModel viewModel = await DialogService.ShowCustomLocalizedMessageAsync <TagEditView, TagEditViewModel>("NewTag");

        if (viewModel.DialogResultOk)
        {
            viewModel.Tag.ID = await tagService.CreateAsync(viewModel.Tag);

            AllTags.Add(viewModel.Tag);
        }
    }
Exemplo n.º 8
0
        private void AddExistingToCurrent()
        {
            if (SelectedExisting == null)
            {
                return;
            }

            var tmp = SelectedExisting;

            AllTags.Remove(tmp);
            CurrentList.Add(tmp);
        }
Exemplo n.º 9
0
 private void UpdateFiltered()
 {
     if (searchBox.Text.Any())
     {
         var list   = AllTags.Where(i => i.Contains(searchBox.Text, StringComparison.OrdinalIgnoreCase)).ToList();
         var sorted = list.OrderByDescending(i => i.StartsWith(searchBox.Text, StringComparison.OrdinalIgnoreCase)).ToList();
         PopulateFiltered(sorted);
     }
     else
     {
         PopulateFiltered(AllTags);
     }
 }
Exemplo n.º 10
0
 public SettlementTemplatePresenter([NotNull] ApplicationPresenter applicationPresenter, [NotNull] SettlementTemplateView view,
                                    [NotNull] SettlementTemplate template) : base(view, "ThisTemplate.HeaderString", template, applicationPresenter)
 {
     _hhdIntensity = new EnergyIntensityConverter.EnergyIntensityForDisplay(EnergyIntensityType.EnergyIntensive, "Energy Intensive");
     _template     = template;
     RefreshGeneratedSettlements();
     RefreshGeneratedHouses();
     foreach (var tag in Sim.HouseholdTags.It)
     {
         var te = new TagEntry(tag, false);
         AllTags.Add(te);
     }
     RefreshTraits();
 }
Exemplo n.º 11
0
 private void AddTag()
 {
     if (String.IsNullOrWhiteSpace(NewTag))
     {
         return;
     }
     if (!AllTags.Any(t => t.Name == NewTag))
     {
         AllTags.Add(new Tag()
         {
             Name = NewTag
         });
     }
     Tags.Add(AllTags.First(t => t.Name == NewTag));
     NewTag = String.Empty;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Get Unity tagPaths by logic and tags.
        /// </summary>
        /// <param name="tagLogic">The tag logic.</param>
        /// <param name="tags">The tags.</param>
        public IEnumerable <IEnumerable <string> > GetTagPathMatches(TagLogic tagLogic, params string[] tags)
        {
            IEnumerable <IEnumerable <string> > baseTagPaths = AllTagPaths;
            IEnumerable <string> splitTags        = tags.SelectMany(t => t.Split('/'));
            IEnumerable <string> regexTagPatterns = splitTags.Where(p => Regex.Match(p, @"[*+?^\\{}\[\]$<>:]").Success);
            IEnumerable <string> regexTags        = regexTagPatterns.SelectMany(p => AllTags.Where(t => Regex.Match(t, p).Success));
            IEnumerable <string> findTags         = splitTags.Except(regexTagPatterns).Concat(regexTags).Distinct();

            IEnumerable <IEnumerable <string> > resultTagPaths = null; // Enumerable.Empty<IEnumerable<string>>();

            foreach (IEnumerable <IEnumerable <string> > tagPaths in findTags.Select(t => AllTagPaths.Where(p => ExpandTagGroups(p).Contains(t))))
            {
                resultTagPaths = GetTagPathMatches(tagLogic, tagPaths, resultTagPaths);
            }
            return(resultTagPaths ?? Enumerable.Empty <IEnumerable <string> >());
        }
Exemplo n.º 13
0
        private void SearchTag()
        {
            if (TagSearchDataContext.FullSearchText.IsEmpty())
            {
                return;
            }

            if (!AllTags.Any(t => t.Name.EqualsIgnoreCase(TagSearchDataContext.FullSearchText)))
            {
                AddNewTag();
            }
            else
            {
                SelectedTag = AllTags.Single(t => t.Name == TagSearchDataContext.FullSearchText);
                TagSearchDataContext.FullSearchText = String.Empty;
            }
        }
Exemplo n.º 14
0
        public bool CreateAllTags()
        {
            var entity = new AllTags()
            {
                ListOfAllTags = "",
            };

            using (var ctx = new ApplicationDbContext())
            {
                if (ctx.AllTags.Count() == 0)
                {
                    ctx.AllTags.Add(entity);
                    return(ctx.SaveChanges() == 1);
                }
                return(false);
            }
        }
Exemplo n.º 15
0
 private Tag CreateTagIfNeeded(INoteStore note, string name, string parent = null)
 {
     if (AllTags.Any(m => m.Name == name) == false)
     {
         Tag newTag = new Tag {
             Name = name
         };
         if (parent != null)
         {
             newTag.ParentGuid = parent;
         }
         newTag = note.CreateTag(newTag);
         allTags.Add(newTag);
         return(newTag);
     }
     return(AllTags.First(m => m.Name == name));
 }
Exemplo n.º 16
0
        private void RemoveFromCurrent()
        {
            //Need to reassign as Remove will set SelectedCurrent to null

            var tmp = SelectedCurrent;

            if (tmp == null)
            {
                return;
            }

            bool removed = CurrentList.Remove(tmp);

            if (removed && tmp.ID > 0)
            {
                AllTags.Add(tmp);
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Rewrites the whole file with the text assigned to it.
 /// </summary>
 /// <param name="tags"></param>
 public static void Write(AllTags tags)
 {
     try
     {
         // serialize JSON directly to a file. Overwrites the file.
         using StreamWriter file = new StreamWriter($"{AppDomain.CurrentDomain.BaseDirectory}{pathJSONFile}", false);
         JsonSerializer serializer = new JsonSerializer();
         serializer.Serialize(file, tags);
     }
     catch (IOException)
     {
         Messages.ErrorSaving();
     }
     catch (JsonException)
     {
         Messages.ErrorParsing();
     }
 }
Exemplo n.º 18
0
        public object Get(AllTags request)
        {
            List <Tag> result = new List <Tag>();

            using (TagsDBUser user = new TagsDBUser(request.Test))
            {
                var readIf = GetReadInterface(user, request);
                foreach (var tagForLanguage in readIf.GetAllTags())
                {
                    var tag = new Tag {
                        Name = tagForLanguage.Name, Category = tagForLanguage.Category
                    };
                    SetResponseOptions(request, tag, user);
                    result.Add(tag);
                }
                return(CreateHttpResponse(request, CreateItemResponse <AllTagsResponse, List <Tag> >(request, result, user)));
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns the macro found with the given name on macroName.
        /// </summary>
        /// <returns></returns>
        private Macro GetMacro()
        {
            if (pressedAndpersand && !string.IsNullOrWhiteSpace(macroName))
            {
                AllTags allTags = JSONUtilities.Read();
                foreach (Tag tag in allTags.Tags)
                {
                    foreach (Macro macro in tag.Macros)
                    {
                        if (macro.Name.ToUpperInvariant().Trim().Equals(macroName.ToUpperInvariant().Trim()))
                        {
                            return(macro);
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Executed when create new tag button is clicked.
        /// Adds an EvernoteTagItem to the collection and puts it in edit mode.
        /// </summary>
        void createBtn_Click(object sender, RoutedEventArgs e)
        {
            if (ItemsSource != null)
            {
                var used = SelectedTags.ToList();
                AllTags.Clear();
                AllTags.AddRange(_originalAllTags.Where(t => !used.Select(u => u.Id).Contains(t.Id)).ToList());
            }

            if (AllTags.Count == 0)
            {
                return;
            }
            var newItem = CreateTagItem(new Tag());

            newItem.IsEditing = true;
            AddTag(newItem);
            this.SelectedItem = newItem;
            this.IsEditing    = true;
        }
Exemplo n.º 21
0
        private void DeleteSelectedTag()
        {
            var result = MessageBox.Show($"Are you sure you want to delete the [{SelectedTag.Name}] tag? It will be disassociated from any Omnis.",
                                         $"Delete Tag [{SelectedTag.Name}]",
                                         MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            if (!AddedTags.Remove(SelectedTag))
            {
                DeletedTags.Add(SelectedTag);
            }
            SelectedTag.DateDeleted = DateTime.Now;
            AllTags.Remove(SelectedTag);
            SelectedTag = null;
            ChangesMade = true;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Returns a full list of the user's tags along with the number of times they were used.
        /// </summary>
        /// <returns>List of tags and their counts</returns>
        public Task <AllTags> Get()
        {
            var url = TagsURL.AppendPathSegment("get");

            return(MakeRequestAsync <AllTags>(url, (content) =>
            {
                var allTagCounts = JsonConvert.DeserializeObject <IDictionary <string, int> >(content);

                var allTags = new AllTags();
                foreach (KeyValuePair <string, int> kv in allTagCounts)
                {
                    allTags.Add(new TagCount
                    {
                        Tag = kv.Key,
                        Count = kv.Value
                    });
                }

                return allTags;
            }));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Reads the JSON file and returns it as a list of tags.
        /// </summary>
        /// <returns></returns>
        public static AllTags Read()
        {
            AllTags tags = null;

            try
            {
                // deserialize JSON directly from a file
                using StreamReader file = File.OpenText($"{AppDomain.CurrentDomain.BaseDirectory}{pathJSONFile}");
                JsonSerializer serializer = new JsonSerializer();
                tags = (AllTags)serializer.Deserialize(file, typeof(AllTags));
            }
            catch (IOException)
            {
                Messages.ErrorSaving();
            }
            catch (JsonException)
            {
                Messages.ErrorParsing();
            }
            return(tags);
        }
Exemplo n.º 24
0
        //AllTags
        public async Task <string> EditTags(AllTags model)
        {
            string              strModel = JsonConvert.SerializeObject(model);
            HttpContent         content  = new StringContent(strModel, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await _httpClient.PutAsync($"{APIUrl}AllTags/", content);

            if (response.IsSuccessStatusCode)
            {
                return("true");
            }
            List <string> message = response.Content.ReadAsStringAsync().Result.Split('"').ToList();

            foreach (var phrase in message)
            {
                if (phrase.Contains("Tag"))
                {
                    Console.WriteLine(phrase);
                    return("tag");
                }
            }
            return("error");
        }
Exemplo n.º 25
0
        /// <summary>Gets hold of the selected tag and figures out the approximate file name.</summary>
        private static void LoadSelected()
        {
            // Get the tag name:
            string  name = Tags[SelectedTagIndex];
            Element inst = Instances[SelectedTagIndex];

            // Get the actual handler:
            AllTags.TryGetValue(name, out SelectedTag);

            if (SelectedTag == null)
            {
                TagName      = "";
                TagNamespace = "";
                return;
            }

            string[] pieces = name.Split(':');

            TagNamespace = pieces[0];
            TagName      = pieces[1];
            NonStandard  = inst.NonStandard;
        }
Exemplo n.º 26
0
 /// <summary>
 /// Gets all tags from the JSON file.
 /// </summary>
 /// <returns></returns>
 public AllTags ReadTags()
 {
     AllTags = JSONUtilities.Read();
     return(AllTags);
 }
Exemplo n.º 27
0
        public EditInstrumentViewModel(Instrument model, IDataClient client, IClosableView view, IDialogCoordinator dialogCoordinator) : base(model, new InstrumentValidator())
        {
            _view             = view;
            DialogCoordinator = dialogCoordinator;
            if (model.Sessions == null)
            {
                model.Sessions = new List <InstrumentSession>();
            }
            if (model.Tags == null)
            {
                model.Tags = new List <Tag>();
            }

            foreach (var session in model.Sessions)
            {
                Sessions.Add(new SessionViewModel(session));
            }

            ContractMonths = new ObservableCollection <KeyValuePair <int, string> >();
            //fill the continuous futures contrat month combobox
            for (int i = 1; i < 10; i++)
            {
                ContractMonths.Add(new KeyValuePair <int, string>(i, MyUtils.Ordinal(i) + " Contract"));
            }

            Load = ReactiveCommand.CreateFromTask(async _ =>
            {
                var tags              = client.GetTags();
                var sessionTemplates  = client.GetSessionTemplates();
                var exchanges         = client.GetExchanges();
                var underlyingSymbols = client.GetUnderlyingSymbols();
                var datasources       = client.GetDatasources();

                await Task.WhenAll(tags, sessionTemplates, exchanges, underlyingSymbols, datasources).ConfigureAwait(true);

                var responses = new ApiResponse[] { tags.Result, sessionTemplates.Result, exchanges.Result, underlyingSymbols.Result, datasources.Result };
                if (await responses.DisplayErrors(this, DialogCoordinator).ConfigureAwait(true))
                {
                    return;
                }

                foreach (var tag in tags.Result.Result.Select(x => new CheckBoxTag(x, model.Tags.Contains(x))))
                {
                    AllTags.Add(tag);
                    tag.PropertyChanged += Tag_PropertyChanged;
                }

                Exchanges.AddRange(exchanges.Result.Result);

                foreach (var template in sessionTemplates.Result.Result)
                {
                    SessionTemplates.Add(template);
                }
                foreach (var us in underlyingSymbols.Result.Result)
                {
                    UnderlyingSymbols.Add(us);
                }
                foreach (var ds in datasources.Result.Result)
                {
                    Datasources.Add(ds);
                }
            });

            //Sessions
            AddNewSession = ReactiveCommand.Create(() => AddSession());
            RemoveSession = ReactiveCommand.Create <SessionViewModel>(ExecRemoveSession);

            //Save
            var saveCanExecute = this
                                 .WhenAnyValue(x => x.HasErrors)
                                 .Select(x => !x);

            Save = ReactiveCommand.CreateFromTask(async _ =>
            {
                if (model.ID == null || model.ID <= 0)
                {
                    //adding a new instrument
                    return(await client.AddInstrument(model).ConfigureAwait(true));
                }
                else
                {
                    //updating an existing one
                    return(await client.UpdateInstrument(model).ConfigureAwait(true));
                }
            }
                                                  , saveCanExecute);
            Save.Subscribe(async result =>
            {
                var errors = await result.DisplayErrors(this, DialogCoordinator).ConfigureAwait(true);
                if (!errors)
                {
                    AddedInstrument = result.Result;
                    _view.Close();
                }
            });

            this.Validate();
        }
Exemplo n.º 28
0
 /// <summary>
 /// Get if a specified tag exist.
 /// </summary>
 /// <param name="_tag">Tag to check existence.</param>
 /// <returns>Returns true if it exist, false otherwise.</returns>
 public static bool DoesTagExist(string _tag)
 {
     return(AllTags.Any(t => t.Name == _tag));
 }
Exemplo n.º 29
0
        /// <summary>
        /// Formats the <see cref="AllTags"/> to insert inside an array initializer like [];
        /// </summary>
        public string JavascriptArrayForAllTags()
        {
            IEnumerable <string> allTags = AllTags.OrderBy(x => x.Name).Select(t => t.Name);

            return("\"" + string.Join("\", \"", allTags) + "\"");
        }
Exemplo n.º 30
0
 void OnDisable()
 {
     AllTags.Remove(this);
 }