예제 #1
0
        /// <summary>
        /// Setzt die Beziehungen zwischen zwei Spielern
        /// </summary>
        /// <param name="userA">Benutzer 1</param>
        /// <param name="userB">Benutzer 2</param>
        /// <param name="state">Beziehungsstatus</param>
        public void setRelation(User userA, User userB, RelationState state)
        {
            RelationHolder[] list2 = new RelationHolder[list.Count];
            this.list.CopyTo(list2);

            foreach (RelationHolder hold in list2)
            {
                if (((userA == hold.userA) && (userB == hold.userB)) || ((userB == hold.userA) && (userA == hold.userB)))
                {
                    list.Remove(hold);
                    RelationHolder holder = new RelationHolder();
                    holder.userA = userA;
                    holder.userB = userB;
                    holder.state = state;
                    list.Add(holder);
                    return;

                }

            }

            //Nicht in der Liste => neu Einfügen;
            RelationHolder holder2 = new RelationHolder();
            holder2.userA = userA;
            holder2.userB = userB;
            holder2.state = state;
            list.Add(holder2);
        }
예제 #2
0
        /// <summary>
        /// Vykreslí přímou linku nebo křivku Prev.Center to Next.Center
        /// </summary>
        /// <param name="e">Data pro kreslení</param>
        /// <param name="mode">Důvody zobrazení</param>
        /// <param name="ratio">Poměr průhlednosti: hodnota v rozsahu 0.0 (neviditelná) - 1.0 (plná barva)</param>
        protected void DrawCenter(GInteractiveDrawArgs e, TimeGraphLinkMode mode, float ratio)
        {
            TimeGraph     graph         = (this.ItemNext != null ? this.ItemNext.Graph : (this.ItemPrev != null ? this.ItemPrev.Graph : null));
            RelationState relationState = GetRelationState(this.ItemPrev, this.ItemNext);
            Color         color1        = this.GetColorForState(relationState, graph);

            Point?prevPoint = GetPoint(this.ItemPrev, RectangleSide.CenterX | RectangleSide.CenterY, true, false);
            Point?nextPoint = GetPoint(this.ItemNext, RectangleSide.CenterX | RectangleSide.CenterY, true, false);

            if (!(prevPoint.HasValue && nextPoint.HasValue))
            {
                return;
            }

            Painter.DrawLinkLine(e.Graphics, prevPoint.Value, nextPoint.Value, color1, this.LinkWidth, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.ArrowAnchor, ratio);
        }
예제 #3
0
        /// <summary>
        /// Vrací barvu pro daný čas
        /// </summary>
        /// <param name="state"></param>
        /// <param name="graph"></param>
        /// <returns></returns>
        protected Color GetColorForState(RelationState state, TimeGraph graph = null)
        {
            switch (state)
            {
            case RelationState.Warning:
                return(this.LinkColorWarning.HasValue ? this.LinkColorWarning.Value :
                       (graph != null && graph.LinkColorWarning.HasValue ? graph.LinkColorWarning.Value : Skin.Graph.LinkColorWarning));

            case RelationState.Error:
                return(this.LinkColorError.HasValue ? this.LinkColorError.Value :
                       (graph != null && graph.LinkColorError.HasValue ? graph.LinkColorError.Value : Skin.Graph.LinkColorError));

            case RelationState.Standard:
            default:
                return(this.LinkColorStandard.HasValue ? this.LinkColorStandard.Value :
                       (graph != null && graph.LinkColorStandard.HasValue ? graph.LinkColorStandard.Value : Skin.Graph.LinkColorStandard));
            }
        }
예제 #4
0
        /// <summary>
        /// Vykreslí přímou linku nebo S křivku { Prev.End to Next.Begin }
        /// </summary>
        /// <param name="e">Data pro kreslení</param>
        /// <param name="mode">Důvody zobrazení</param>
        /// <param name="ratio">Poměr průhlednosti: hodnota v rozsahu 0.0 (neviditelná) - 1.0 (plná barva)</param>
        protected void DrawPrevNext(GInteractiveDrawArgs e, TimeGraphLinkMode mode, float ratio)
        {
            TimeGraph     graph         = (this.ItemNext != null ? this.ItemNext.Graph : (this.ItemPrev != null ? this.ItemPrev.Graph : null));
            RelationState relationState = GetRelationState(this.ItemPrev, this.ItemNext);
            Color         color1        = this.GetColorForState(relationState, graph);

            Point?prevPoint = GetPoint(this.ItemPrev, RectangleSide.MiddleRight, true, true);
            Point?nextPoint = GetPoint(this.ItemNext, RectangleSide.MiddleLeft, true, true);

            LinkLineType lineType = this.CurrentLineShape;
            float?       treshold = 4f * (float)(this.LinkWidth.HasValue ? this.LinkWidth.Value : 3);

            using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = Painter.CreatePathLink(lineType, prevPoint, nextPoint, treshold))
            {
                bool useRoundAnchor = (lineType == LinkLineType.ZigZagHorizontal || lineType == LinkLineType.ZigZagVertical || lineType == LinkLineType.ZigZagOptimal);
                System.Drawing.Drawing2D.LineCap startCap = (useRoundAnchor ? System.Drawing.Drawing2D.LineCap.RoundAnchor : System.Drawing.Drawing2D.LineCap.Round);
                System.Drawing.Drawing2D.LineCap endCap   = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                Painter.DrawLinkPath(e.Graphics, graphicsPath, color1, null, this.LinkWidth, startCap, endCap, ratio);
            }
        }
예제 #5
0
    private static void BuildTrafficLightIndex()
    {
        foreach (TrafficLightLogic trafficLight in TrafficLights)
        {
            // Add to our Pos.id -> [trafficLight] dictionary
            long posId = trafficLight.getPos().Id;
            if (!TrafficLightsForPos.ContainsKey(posId))
            {
                TrafficLightsForPos.Add(posId, new List <TrafficLightLogic>());
            }
            TrafficLightsForPos [posId].Add(trafficLight);

            foreach (TrafficLightLogic otherTrafficLight in TrafficLights)
            {
                if (trafficLight != otherTrafficLight && trafficLight.getPos().Equals(otherTrafficLight.getPos()))
                {
                    // This traffic light is either same light or opposite to it
                    bool          isSameDirection = trafficLight.getState() == otherTrafficLight.getState();
                    RelationState relationState   = isSameDirection ? RelationState.SAME_DIRECTION : RelationState.CROSSING_DIRECTION;

                    if (!TrafficLightRelations.ContainsKey(trafficLight))
                    {
                        TrafficLightRelations.Add(trafficLight, new Dictionary <RelationState, List <TrafficLightLogic> > ());
                    }
                    Dictionary <RelationState, List <TrafficLightLogic> > trafficLightEntry = TrafficLightRelations [trafficLight];

                    if (!trafficLightEntry.ContainsKey(relationState))
                    {
                        trafficLightEntry.Add(relationState, new List <TrafficLightLogic>());
                    }
                    List <TrafficLightLogic> linkedTrafficLightsList = trafficLightEntry [relationState];

                    linkedTrafficLightsList.Add(otherTrafficLight);
                }
            }
        }
    }