Esempio n. 1
0
        public TextModel(int id, Brush fillColor, Brush borderColor)
        {
            _clickModel = new ClickModel(id, fillColor, borderColor, this);

            Border border = new Border();

            border.Width           = Width;
            border.Height          = Height;
            border.CornerRadius    = CornerRadius;
            border.Background      = FillColor;
            border.BorderBrush     = BorderColor;
            border.BorderThickness = BorderThickness;

            TextBox textBox = new TextBox();

            textBox.FontSize        = FontSize;
            textBox.Foreground      = FontColor;
            textBox.CaretBrush      = FontColor;
            textBox.Background      = Brushes.Transparent;
            textBox.BorderThickness = new Thickness(0);
            textBox.AcceptsReturn   = true;
            textBox.ContextMenu     = null;
            textBox.DataContext     = this;

            textBox.SetBinding(System.Windows.Controls.TextBox.TextProperty, new Binding("Text")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });

            border.Child = textBox;

            _textBox = border;
        }
Esempio n. 2
0
        public async Task <ClickModel> InsertClicks(ClickModel click)
        {
            this.context.UserClick.Add(click);
            await this.context.SaveChangesAsync();

            return(click);
        }
Esempio n. 3
0
        public async Task <ClickModel> RecordClicks(ClickModel data)
        {
            data.ID = Guid.NewGuid();
            var result = this._repo.InsertClicks(data);

            return(await result);
        }
Esempio n. 4
0
        public ActionResult Click(ClickModel model)
        {
            if (model.X < 0 || model.Y < 0)
            {
                return(JsonError("点击的坐标不能小于 0"));
            }

            try
            {
                _gesture.Click(model.X, model.Y);
            }
            catch (Exception)
            {
                // ignored
            }

            return(JsonSuccess());
        }
Esempio n. 5
0
        public DragModel(int startId, Brush startFill, Brush startBorder, int endId, Brush endFill, Brush endBorder)
        {
            _startClickModel = new ClickModel(startId, startFill, startBorder, this);
            _startClickModel.Settings.ClickType = ClickType.DragStart;

            Line dragPath = new Line();

            dragPath.DataContext = this;
            dragPath.SetBinding(Shape.StrokeProperty, new Binding("BorderColor")
            {
                Source = _startClickModel,
                Mode   = BindingMode.TwoWay
            });
            dragPath.StrokeThickness = LineThickness;
            _dragPath = dragPath;

            _endClickModel = new ClickModel(endId, endFill, endBorder, this);
            _endClickModel.Settings.ClickType = ClickType.DragEnd;
        }
 public async Task <IActionResult> CreateClicks([FromBody] ClickModel value)
 {
     return(Ok(await this.vm.RecordClicks(value)));
 }
 public ClickModelSettings(ClickModel clickModel)
 {
     Parent      = clickModel;
     ContextMenu = new ClickContextMenu(this);
 }
Esempio n. 8
0
        public async Task <ClickResponseModel> Click(ClickModel clickModel, Guid userId)
        {
            var errors   = new List <string>();
            var response = new ClickResponseModel(errors);

            using var transaction = context.Database.BeginTransaction(IsolationLevel.RepeatableRead);
            var now = DateTime.UtcNow;
            Tag?tag = null;

            if (Guid.TryParse(clickModel.TagId, out Guid tagGuid))
            {
                tag = await context.Tags.Include(x => x.User).SingleOrDefaultAsync(x => x.Id == tagGuid);

                if (tag == null)
                {
                    errors.Add(InvalidTagIdError);
                }
            }
            else
            {
                tag = await context.Tags.Include(x => x.User).SingleOrDefaultAsync(x => x.User.Username == clickModel.TagId);

                if (tag == null)
                {
                    errors.Add(InvlaidUsernameError);
                }
            }
            if (tag == null)
            {
                errors.Add(NoUsernameOrTagId);
            }
            var user = await context.Users.SingleAsync(x => x.Id == userId);

            if (user.Balance <= 0 && user.Repurchase && !string.IsNullOrWhiteSpace(user.BillingId) && !string.IsNullOrWhiteSpace(user.CardId) && !string.IsNullOrWhiteSpace(user.RepurchaseAmount))
            {
                await purchaseManager.Purchase(new PurchaseModel
                {
                    Amount   = user.RepurchaseAmount,
                    Refill   = true,
                    UseSaved = true,
                }, user);
            }
            if (!errors.Any() && user.Balance <= 0)
            {
                errors.Add(InsufficientFundsError);
            }
            if (errors.Any())
            {
                await transaction.RollbackAsync();

                return(response);
            }
            user.Balance       -= 1;
            tag !.User.Balance += 1;
            context.Clicks.Add(new Click
            {
                Id        = Guid.NewGuid(),
                TagId     = tag !.Id,
                UserId    = userId,
                Timestamp = now,
                ViewId    = clickModel.viewId,
                PageId    = clickModel.PageId,
                Page      = clickModel.Page,
                Referrer  = clickModel.Referrer
            });
Esempio n. 9
0
 public async Task <ClickResponseModel> Click(ClickModel clickModel)
 {
     return(await clickManager.Click(clickModel, NanrUser !.Id));
 }
Esempio n. 10
0
        public XElement WriteToXml()
        {
            XElement clickModel = ClickModel.WriteToXml();

            return(new XElement("TextClick", new XAttribute("text", Text ?? ":EMPTY:"), clickModel.Elements()));
        }