public object Convert(object[] values, Type targetType, object parameter, String culture) { LifeLine lifeline = (LifeLine)values[0]; string tag = values[1].ToString(); if (lifeline == LifeLine.AskDAudience && tag == "2") { return(Visibility.Visible); } else if (lifeline == LifeLine.FoneAFriend && tag == "3") { return(Visibility.Visible); } else { return(Visibility.Collapsed); } }
public void Render() { items = new List<CanvasItem>(); lifeLines = new List<LifeLine>(); Dictionary<string, LifeLine> llDict = new Dictionary<string, LifeLine>(); double x_where = 50.5; double y_step = 25; y_current = 0; width = 0; height = 0; foreach(ElemObj elem in diagram.elements) { TextBox tb = new TextBox(); tb.YTop = 10.5; tb.XCenter = x_where; x_where += 100; width += 100; tb.Width = 70; tb.BorderWidth = 3; tb.Text = elem.text; tb.Layout(cr); items.Add(tb); LifeLine ll = new LifeLine(elem.label, this, tb.XCenter, tb.Y1); lifeLines.Add(ll); llDict.Add(elem.label, ll); if(tb.Y1 > YCurrent) { YCurrent = tb.Y1; } } foreach(Step step in diagram.sequence) { if(step.amount == 0) { step.amount = (int)y_step; } YCurrent += step.amount; foreach(LifeLine ll in lifeLines) { ll.BeforeActivations(); } foreach(Activation a in step.activations) { LifeLine ll = llDict[a.label]; if(a.on) { ll.Activate(); } else { ll.Deactivate(); } } foreach(LifeLine ll in lifeLines) { ll.AfterActivations(); } foreach(Arrow arrow in step.arrows) { TextArrow ta; LifeLine to = llDict[arrow.to]; LifeLine from = llDict[arrow.from]; if(to != from) { ta = new TextArrow(); bool right = to.X > from.X; ta.Y0 = YCurrent; if(right) { ta.X0 = from.XRightAfter; ta.X1 = to.XLeftAfter; ta.XText = from.XClearRight; } else { ta.X0 = from.XLeftAfter; ta.X1 = to.XRightAfter; ta.XText = from.XClearLeft; } } else { SelfTextArrow sta = new SelfTextArrow(); sta.Y0 = YCurrent - 10; sta.Y1 = YCurrent; sta.X0 = from.XRightBefore; sta.X0b = from.XRightAfter; sta.X1 = from.XRightBefore + 30; sta.XText = from.XClearRight; ta = sta; } ta.Text = arrow.text; ta.ArrowKind = arrow.type; ta.Layout(cr); items.Add(ta); } } foreach(LifeLine ll in lifeLines) { ll.End(); } height = YCurrent; }
/// <summary> /// Gets the life line image when there are 6 max chances. /// </summary> /// <param name="lifeline">The lifeline.</param> /// <returns></returns> private string Get6LifeLineImage(LifeLine lifeline) { #region Implementation string image = null; switch (lifeline) { case LifeLine.Dead: image = DEAD; break; case LifeLine.LeftLeg: image = LEFT_LEG; break; case LifeLine.RightArm: image = RIGHT_ARM; break; case LifeLine.LeftArm: image = LEFT_ARM; break; case LifeLine.Torso: image = TORSO; break; case LifeLine.Head: image = HEAD; break; default: image = FULL; break; } return image; #endregion }