Ejemplo n.º 1
0
        public PostView(AnalyzedPost post)
        {
            this.post = post;
            Vertical_GridLayout_Builder mainBuilder  = new Vertical_GridLayout_Builder();
            Vertical_GridLayout_Builder titleBuilder = new Vertical_GridLayout_Builder();

            // post title
            foreach (AnalyzedString component in post.TitleComponents)
            {
                Label label = new Label();
                if (component.Score > 0)
                {
                    label.TextColor = Color.Green;
                }
                else
                {
                    if (component.Score < 0)
                    {
                        label.TextColor = Color.Red;
                    }
                    else
                    {
                        label.TextColor = Color.White;
                    }
                }
                label.BackgroundColor = Color.Black;
                TextblockLayout textBlockLayout = new TextblockLayout(label, 16, false, true);
                textBlockLayout.setText(component.Text);
                titleBuilder.AddLayout(textBlockLayout);
            }
            this.starButton = new Button();
            this.updateStarButton();
            this.starButton.Clicked += SaveButton_Clicked;

            GridLayout topGrid = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.WithRatios(new List <double>()
            {
                5, 1
            }), LayoutScore.Zero);

            topGrid.AddLayout(titleBuilder.BuildAnyLayout());
            topGrid.AddLayout(new ButtonLayout(this.starButton));
            mainBuilder.AddLayout(topGrid);

            this.linkLayout = new TextblockLayout(post.Interaction.Post.Source, 16, false, true);
            this.linkLayout.setBackgroundColor(Color.Black);
            this.updateLinkColor();
            mainBuilder.AddLayout(this.linkLayout);

            Button openButton = new Button();

            mainBuilder.AddLayout(new ButtonLayout(openButton, "Open", 16));
            openButton.Clicked += OpenButton_Clicked;

            this.SubLayout = mainBuilder.BuildAnyLayout();
        }
Ejemplo n.º 2
0
        public AnalyzedPost SubmitPostAnalysis(Post post, BotAction action)
        {
            if (Config.I.CurrentRunMode == BotRunMode.Simulated)
            {
                return(new AnalyzedPost()
                {
                });
            }
            using (var context = new ServerDataContext(Config.I.ServerConnectionString))
            {
                var analyzedPost = new AnalyzedPost
                {
                    PostID          = post.Id,
                    AnalysisTimeUTC = DateTime.UtcNow,
                    BotAction       = (int)action
                };
                context.AnalyzedPosts.InsertOnSubmit(analyzedPost);
                context.SubmitChanges();

                return(analyzedPost);
            }
        }