public TimelineView(BohemianArtifact bbshelf, Vector3 p, Vector3 s)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            position = p;
            size = s;
            font = bookshelf.Content.Load<SpriteFont>("Kootenay");
            lineBookTable = new Hashtable();

            CreateLinesFromBooks();

            cross1 = new SelectableLine(new Vector3(0, 0.2f, 0), new Vector3(0, 0.9f, 0), Color.Blue, 10);
            cross2 = new SelectableLine(new Vector3(1, 0.2f, 0), new Vector3(1, 0.9f, 0), Color.Red, 10);

            titleText = new SelectableText(font, "Timeline View", new Vector3(0.4f, 0, 0), bookshelf.GlobalTextColor, Color.White);
            titleText.InverseScale(0.5f, size.X, size.Y);

            topBar = new SelectableQuad(new Vector2(0, 0.1f), new Vector2(1, 0.1f), Color.LightGray);
            bookshelf.SelectableObjects.AddObject(topBar);
            bottomBar = new SelectableQuad(new Vector2(0, 0.9f), new Vector2(1, 0.1f), Color.LightGray);
            bookshelf.SelectableObjects.AddObject(bottomBar);

            topOffset = 0;
            bottomOffset = 1;
        }
Esempio n. 2
0
        public TimelineView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            this.position = position;
            this.size = size;

            // create left and right white fadeouts
            leftWhiteVertices = new VertexPositionColor[6];
            leftWhiteVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.White);
            leftWhiteVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            leftWhiteVertices[2] = new VertexPositionColor(new Vector3(0.005f, 0, 0), Color.Transparent);
            leftWhiteVertices[3] = new VertexPositionColor(new Vector3(0.005f, 1, 0), Color.Transparent);
            leftWhiteVertices[4] = new VertexPositionColor(new Vector3(0, 1, 0), Color.White);
            leftWhiteVertices[5] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.White);
            rightWhiteVertices = new VertexPositionColor[6];
            rightWhiteVertices[0] = new VertexPositionColor(new Vector3(1 - 0.005f, 0, 0), Color.Transparent);
            rightWhiteVertices[1] = new VertexPositionColor(new Vector3(1, 0, 0), Color.White);
            rightWhiteVertices[2] = new VertexPositionColor(new Vector3(3, 0, 0), Color.White);
            rightWhiteVertices[3] = new VertexPositionColor(new Vector3(3, 1, 0), Color.White);
            rightWhiteVertices[4] = new VertexPositionColor(new Vector3(1, 1, 0), Color.White);
            rightWhiteVertices[5] = new VertexPositionColor(new Vector3(1 - 0.005f, 1, 0), Color.Transparent);
            hexWhiteIndices = new int[12];
            hexWhiteIndices[0] = 0;
            hexWhiteIndices[1] = 1;
            hexWhiteIndices[2] = 4;
            hexWhiteIndices[3] = 4;
            hexWhiteIndices[4] = 5;
            hexWhiteIndices[5] = 0;
            hexWhiteIndices[6] = 1;
            hexWhiteIndices[7] = 2;
            hexWhiteIndices[8] = 3;
            hexWhiteIndices[9] = 3;
            hexWhiteIndices[10] = 4;
            hexWhiteIndices[11] = 1;
            // create left and right black quads
            leftBlackVertices = new VertexPositionColor[4];
            leftBlackVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.Black);
            leftBlackVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
            leftBlackVertices[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Black);
            leftBlackVertices[3] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.Black);
            rightBlackVertices = new VertexPositionColor[4];
            rightBlackVertices[0] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Black);
            rightBlackVertices[1] = new VertexPositionColor(new Vector3(3, 0, 0), Color.Black);
            rightBlackVertices[2] = new VertexPositionColor(new Vector3(3, 1, 0), Color.Black);
            rightBlackVertices[3] = new VertexPositionColor(new Vector3(1, 1, 0), Color.Black);
            quadBlackIndices = new int[6];
            quadBlackIndices[0] = 0;
            quadBlackIndices[1] = 1;
            quadBlackIndices[2] = 2;
            quadBlackIndices[3] = 2;
            quadBlackIndices[4] = 3;
            quadBlackIndices[5] = 0;

            titleText = new SelectableText(XNA.Font, "Timeline", new Vector3(0.4f, 0, 0), bookshelf.GlobalTextColor, Color.White);
            titleText.InverseScale(0.8f, size.X, size.Y);

            // arrays to hold tick marks for each timeline
            catalogTicks = new List<TimelineYearTick>();
            useTicks = new List<TimelineYearTick>();
            manufactureTicks = new List<TimelineYearTick>();

            // create a line for each timeline, these will not be interactive elements
            catalogLine = new SelectableLine(new Vector3(0, catalogLineHeight, 0), new Vector3(1, catalogLineHeight, 0), Color.LightGray, lineThickness);
            useLine = new SelectableLine(new Vector3(0, useLineHeight, 0), new Vector3(1, useLineHeight, 0), Color.LightGray, lineThickness);
            manufactureLine = new SelectableLine(new Vector3(0, manufactureLineHeight, 0), new Vector3(1, manufactureLineHeight, 0), Color.LightGray, lineThickness);

            // underneath each timeline, there are three widgets to control zooming and traversing
            catalogWidgets = new SelectableLine[3];
            useWidgets = new SelectableLine[3];
            manufactureWidgets = new SelectableLine[3];
            for (int i = 0; i < 3; i++)
            {
                // create interactive elements and add them to the object manager
                catalogWidgets[i] = new SelectableLine(new Vector3((float)i / 3, catalogLineHeight, 0), new Vector3((float)(i + 1) / 3, catalogLineHeight, 0), new Color(i * 255 / 2, 0, 0), lineThickness * 2);
                useWidgets[i] = new SelectableLine(new Vector3((float)i / 3, useLineHeight, 0), new Vector3((float)(i + 1) / 3, useLineHeight, 0), new Color(0, i * 255 / 2, 0), lineThickness * 2);
                manufactureWidgets[i] = new SelectableLine(new Vector3((float)i / 3, manufactureLineHeight, 0), new Vector3((float)(i + 1) / 3, manufactureLineHeight, 0), new Color(0, 0, i * 255 / 2), lineThickness * 2);
                catalogWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                useWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                manufactureWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                bookshelf.SelectableObjects.AddObject(catalogWidgets[i]);
                bookshelf.SelectableObjects.AddObject(useWidgets[i]);
                bookshelf.SelectableObjects.AddObject(manufactureWidgets[i]);
            }

            // the circles are test objects to show how the timeline range is being manipulated
            catalogCircles = new SelectableEllipse[2];
            useCircles = new SelectableEllipse[2];
            manufactureCircles = new SelectableEllipse[2];
            // these arrays store the left/right for each timeline, along with a left/right offset that is used as a temp variable
            // the order is: L_RANGE, L_OFFSET, R_RANGE, R_OFFSET
            catalogTimelineRange = new float[4] { 0, 0, 1, 1 };
            useTimelineRange = new float[4] { 0, 0, 1, 1 };
            manufactureTimelineRange = new float[4] { 0, 0, 1, 1 };
            catalogCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            catalogCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            useCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            useCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            manufactureCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            manufactureCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);

            topSorted = new List<KeyValuePair<TimelineContainer, float>>();
            bottomSorted = new List<KeyValuePair<TimelineContainer, float>>();

            timelineArtifactList = new List<TimelineContainer>();
            lineArtifactDictionary = new Dictionary<SelectableLine, TimelineContainer>();
            selectedContainer = null;
            highlightedContainer = null;
            relatedContainers = new List<TimelineContainer>();
            InitializeTimelineList();

            animationTimer = new Timer(0.5f);
            animationTimer.FinishEvent += new TimerFinished(AnimationTimerFinished);
        }
Esempio n. 3
0
            public RoundedBoundingBox(Vector3 topleft, Vector3 bottomright, Color c, float thickness, DetailsView view)
            {
                this.view = view;
                color = c;
                this.thickness = thickness;

                float topRatio = view.Size.X / view.Size.Y;
                float sideRatio = 1 / topRatio;
                if (topRatio > 1) topRatio = 1;
                if (sideRatio > 1) sideRatio = 1;

                float percentBuffer = 0.07f; // how "rounded" the corner is
                float topBuffer = percentBuffer * (bottomright.X - topleft.X) * topRatio;
                float sideBuffer = percentBuffer * (bottomright.Y - topleft.Y) * sideRatio;
                sideBuffer = topBuffer; // makes the corners look more natural

                top = new SelectableLine(new Vector3(topleft.X, topleft.Y, 0), new Vector3(bottomright.X - topBuffer, topleft.Y, 0), c, thickness * topRatio);
                left = new SelectableLine(new Vector3(topleft.X, topleft.Y, 0), new Vector3(topleft.X, bottomright.Y - sideBuffer, 0), c, thickness * sideRatio);
                right = new SelectableLine(new Vector3(bottomright.X, topleft.Y + sideBuffer, 0), new Vector3(bottomright.X, bottomright.Y - sideBuffer, 0), c, thickness * sideRatio);
                bottom = new SelectableLine(new Vector3(topleft.X + topBuffer, bottomright.Y, 0), new Vector3(bottomright.X - topBuffer, bottomright.Y, 0), c, thickness * topRatio);

                corners = new List<SelectableLine>();

                //corners.AddRange(makeRoundedCorner(top.LinePoints[0].Position, left.LinePoints[0].Position)); // top left
                corners.AddRange(makeRoundedCorner(bottom.LinePoints[0].Position, left.LinePoints[1].Position, topRatio, sideRatio)); // bottom left
                corners.AddRange(makeRoundedCorner(top.LinePoints[1].Position, right.LinePoints[0].Position, topRatio, sideRatio)); // top right
                corners.AddRange(makeRoundedCorner(bottom.LinePoints[1].Position, right.LinePoints[1].Position, topRatio, sideRatio)); // bottom right
            }
Esempio n. 4
0
 public BoundingBox(Vector3 topleft, Vector3 bottomright, Color c, float thickness)
 {
     top = new SelectableLine(topleft, new Vector3(topleft.X, bottomright.Y, 0), c, thickness);
     left = new SelectableLine(topleft, new Vector3(bottomright.X, topleft.Y, 0), c, thickness);
     right = new SelectableLine(new Vector3(topleft.X, bottomright.Y, 0), bottomright, c, thickness);
     bottom = new SelectableLine(new Vector3(bottomright.X, topleft.Y, 0), bottomright, c, thickness);
 }
        private void CreateLinesFromBooks()
        {
            // we will have two lines per book
            lines = new SelectableLine[bookshelf.Library.Books.Count * 2];

            int i = 0;
            foreach(Book book in bookshelf.Library.Books)
            {
                // create two lines for each book
                lines[i] = new SelectableLine(new Vector3(0, lineYStart, 0), new Vector3(0, lineYEnd, 0), Color.Gray, 0.01f);
                lines[i].Color = Color.Black;
                lineBookTable.Add(lines[i], book);
                bookshelf.SelectableObjects.AddObject(lines[i]);

                lines[i + 1] = new SelectableLine(new Vector3(0, lineYStart, 0), new Vector3(0, lineYEnd, 0), Color.Gray, 0.01f);
                lines[i + 1].Color = Color.Black;
                lineBookTable.Add(lines[i + 1], book);
                bookshelf.SelectableObjects.AddObject(lines[i + 1]);
                i += 2;

                // and update the pubyear range and the subject year range
                if (book.PubYear < pubYearLimit[MIN])
                {
                    pubYearLimit[MIN] = book.PubYear;
                }
                if (pubYearLimit[MAX] < book.PubYear)
                {
                    pubYearLimit[MAX] = book.PubYear;
                }

                if (book.SubjectTime[0] < subjectYearLimit[MIN])
                {
                    subjectYearLimit[MIN] = book.SubjectTime[0];
                }
                if (subjectYearLimit[MAX] < book.SubjectTime[1])
                {
                    subjectYearLimit[MAX] = book.SubjectTime[1];
                }

                // set the padding levels for both zoom ranges
                pubYearLimit[PADDING] = 0.05f * (pubYearLimit[MAX] - pubYearLimit[MIN]);
                subjectYearLimit[PADDING] = 0.05f * (subjectYearLimit[MAX] - subjectYearLimit[MIN]);

                // set the zoom to show all pubyears and all subject years (showing the entire range for both values)
                pubYearZoom[MIN] = pubYearLimit[MIN];
                pubYearZoom[MAX] = pubYearLimit[MAX];
                subjectYearZoom[MIN] = subjectYearLimit[MIN];
                subjectYearZoom[MAX] = subjectYearLimit[MAX];
            }

            // now position all the lines properly.
            RepositionLines(true);
        }