コード例 #1
0
ファイル: TagFactory.cs プロジェクト: zhuowp/SMS.Client
        public TagBase Create(ITagModel tagModel)
        {
            TagBase tag = null;

            switch (tagModel.Type)
            {
            case TagType.Text:
                tag = CreateTextTag(tagModel);
                break;

            case TagType.Icon:
                tag = CreateIconTag(tagModel);
                break;

            case TagType.Area:
                tag = CreateAreaTag(tagModel);
                break;

            case TagType.Vector:
                tag = CreateVectorTag(tagModel);
                break;
            }

            if (tag != null)
            {
                tag.Id          = tagModel.Id;
                tag.DataContext = tagModel;
            }

            return(tag);
        }
コード例 #2
0
 public static TagViewModel ConvertModelToViewModel(ITagModel tag)
 {
     return(new TagViewModel()
     {
         Id = tag.Id, Name = tag.Name
     });
 }
コード例 #3
0
 public void Create(ITagModel tag)
 {
     if (tag != null)
     {
         var dto = ModelConverter.ConvertTagModelToDto(tag);
         DalFactory.TagHandler.Create(dto);
     }
 }
コード例 #4
0
 public void Edit(ITagModel tag)
 {
     if (tag != null)
     {
         TagDto dto = ModelConverter.ConvertTagModelToDto(tag);
         DalFactory.TagHandler.Update(dto);
     }
 }
コード例 #5
0
        public static TagDto ConvertTagModelToDto(ITagModel model)
        {
            _tagDto = new TagDto()
            {
                Id   = model.Id,
                Name = model.Name
            };

            return(_tagDto);
        }
コード例 #6
0
ファイル: TagFactory.cs プロジェクト: zhuowp/SMS.Client
        private VectorTag CreateVectorTag(ITagModel tagModel)
        {
            VectorTag tag = new VectorTag();

            SetTagBasePropertyBinding(tag);
            SetLineTextTagBasePropertyBindings(tag);
            SetVectorTagPropertyBindings(tag);

            return(tag);
        }
コード例 #7
0
ファイル: TagFactory.cs プロジェクト: zhuowp/SMS.Client
        private AreaTag CreateAreaTag(ITagModel tagModel)
        {
            AreaTag tag = new AreaTag();

            SetTagBasePropertyBinding(tag);
            SetLineTextTagBasePropertyBindings(tag);
            SetAreaTagPropertyBindings(tag);

            return(tag);
        }
コード例 #8
0
ファイル: TagFactory.cs プロジェクト: zhuowp/SMS.Client
        private IconTag CreateIconTag(ITagModel tagModel)
        {
            tagModel.TagNameVisibility = Visibility.Collapsed;
            IconTag tag = new IconTag();

            SetTagBasePropertyBinding(tag);
            SetIconTagPropertyBindings(tag);

            return(tag);
        }
コード例 #9
0
ファイル: TagContainer.cs プロジェクト: zhuowp/SMS.Client
        private void TagModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Location")
            {
                ITagModel tagModel = sender as ITagModel;

                if (_tagCacheDict.TryGetValue(tagModel.Id, out TagBase tagBase))
                {
                    TagLocationChanged?.Invoke(tagBase, tagModel);
                }
            }
        }
コード例 #10
0
 public ViewModelConverter(ITagModel tag)
 {
     _tag = tag;
 }
コード例 #11
0
 public static TagTableStorageEntity Create(ITagModel model)
 {
     return(model.ToStorageModel <TagTableStorageEntity>());
 }
コード例 #12
0
ファイル: TagContainer.cs プロジェクト: zhuowp/SMS.Client
        private void RemoveTagDisplay(ConcurrentDictionary <string, TagBase> tagCacheDict, ITagModel removeTagModel)
        {
            if (tagCacheDict.TryRemove(removeTagModel.Id, out TagBase tagBase))
            {
                tagBase.Click -= Tag_Click;
                tagBase.PreviewMouseRightButtonUp -= Tag_PreviewMouseRightButtonUp;

                tagBase.PreviewMouseLeftButtonDown -= Tag_PreviewMouseLeftButtonDown;
                tagBase.PreviewMouseMove           -= Tag_PreviewMouseMove;
                tagBase.PreviewMouseLeftButtonUp   -= Tag_PreviewMouseLeftButtonUp;

                _canvasTags.Children.Remove(tagBase);

                if (tagBase.DataContext is ITagModel tagModel)
                {
                    tagModel.PropertyChanged -= TagModel_PropertyChanged;
                }
            }
        }
コード例 #13
0
ファイル: TagContainer.cs プロジェクト: zhuowp/SMS.Client
        private void UpdateTagDisplay(ConcurrentDictionary <string, TagBase> tagCacheDict, ITagModel updateTagModel)
        {
            if (tagCacheDict.TryGetValue(updateTagModel.Id, out TagBase tagBase))
            {
                if (tagBase.DataContext is ITagModel oldTagModel)
                {
                    oldTagModel.PropertyChanged -= TagModel_PropertyChanged;
                }

                tagBase.DataContext             = updateTagModel;
                updateTagModel.PropertyChanged += TagModel_PropertyChanged;
            }
        }
コード例 #14
0
ファイル: TagContainer.cs プロジェクト: zhuowp/SMS.Client
        private void AddTagDisplay(ConcurrentDictionary <string, TagBase> tagCacheDict, ITagModel addTagModel)
        {
            addTagModel.PropertyChanged += TagModel_PropertyChanged;
            TagBase tag = TagFactory.Instance.Create(addTagModel);

            tag.Click += Tag_Click;
            tag.PreviewMouseRightButtonUp += Tag_PreviewMouseRightButtonUp;

            tag.PreviewMouseLeftButtonDown += Tag_PreviewMouseLeftButtonDown;
            tag.PreviewMouseMove           += Tag_PreviewMouseMove;
            tag.PreviewMouseLeftButtonUp   += Tag_PreviewMouseLeftButtonUp;

            _canvasTags.Children.Add(tag);
            tagCacheDict.AddOrUpdate(addTagModel.Id, tag, (k, v) => tag);
        }
コード例 #15
0
 private void TagContainer_TagLocationChanged(TagBase arg1, ITagModel arg2)
 {
 }