public override void WriteXml(XmlWriter writer) { WriteCoordinates(writer); writer.WriteStartElement("Condition"); if (Condition != null) { if (!Fitter.IsBooleanExpression(Condition)) { throw new ApplicationException("Condition was not a Statement or BooleanBlock."); } if (Condition is Statement) { writer.WriteStartElement("Statement"); } else if (Condition is BooleanBlock) { writer.WriteStartElement("Boolean"); } Condition.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("Consequences"); if (Consequences != null) { writer.WriteStartElement("Spine"); Consequences.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
public override void WriteXml(XmlWriter writer) { WriteCoordinates(writer); writer.WriteAttributeString("Type", this.GetType().FullName); writer.WriteStartElement("Condition1"); if (slot1.Contents != null) { if (!Fitter.IsBooleanExpression(slot1.Contents)) { throw new ApplicationException("Condition1 was not a Statement or BooleanBlock."); } if (slot1.Contents is Statement) { writer.WriteStartElement("Statement"); } else if (slot1.Contents is BooleanBlock) { writer.WriteStartElement("Boolean"); } slot1.Contents.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
public StatementSlot(string name, Fitter fitter) { InitializeComponent(); thin = (Thickness)Resources["thin"]; thick = (Thickness)Resources["thick"]; slotName = name; moveableFitter = fitter; slotBorder.Width = ObjectBlock.DefaultSize.Width + slotBorder.BorderThickness.Left + slotBorder.BorderThickness.Right; slotBorder.Height = ObjectBlock.DefaultSize.Height + slotBorder.BorderThickness.Top + slotBorder.BorderThickness.Bottom; PreviewDrop += new DragEventHandler(DroppedOnSlotPanel); DragEnter += delegate(object sender, DragEventArgs e) { if (!e.Handled) { ObjectBlock block = e.Data.GetData(typeof(Moveable)) as ObjectBlock; if (block != null && block != Attached && Fits(block)) { SetToCanDropAppearance(); } } }; DragLeave += delegate(object sender, DragEventArgs e) { SetToStandardAppearance(); }; }
protected void AddParameter(Fitter fitter) { if (fitter == null) { throw new ArgumentNullException("fitter", "Can't add a parameter without providing a fitter."); } BlockSlot parameter = new BlockSlot(fitter); AddParameter(parameter); }
/// <summary> /// Constructs a new <see cref="PegSlot"/> instance. /// </summary> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public PegSlot(Fitter fitter) : base(fitter) { InitializeComponent(); SetDefaultAppearance(); MoveableChanged += delegate { if (Contents != null) { Contents.HorizontalAlignment = HorizontalAlignment.Left; } }; }
/// <summary> /// Constructs a new <see cref="TriggerSlot"/> instance. /// </summary> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public TriggerSlot(Fitter fitter) : base(fitter) { InitializeComponent(); SetDefaultAppearance(); MoveableChanged += delegate { if (Contents == null) { dragMessageTextBlock.Visibility = Visibility.Visible; } else { dragMessageTextBlock.Visibility = Visibility.Hidden; } }; Contents = null; }
/// <summary> /// Constructs a new <see cref="MoveableSlot"/> instance. /// </summary> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public MoveableSlot(Fitter fitter) { if (fitter == null) { throw new ArgumentNullException("fitter"); } this.fitter = fitter; changeTracker = new EventHandler(AnnounceChange); Drop += AcceptDrop; DragEnter += HandleDragEnter; DragLeave += HandleDragLeave; MoveableChanged += delegate { OnChanged(new EventArgs()); }; }
public Peg(Fitter fitter) { InitializeComponent(); dropZone = new DropZone(fitter); Grid.SetRow(dropZone, 2); Grid.SetColumn(dropZone, 0); Grid.SetColumnSpan(dropZone, 2); mainGrid.Children.Add(dropZone); slot = new PegSlot(fitter); slot.MinHeight = 70; slot.MinWidth = 190; Grid.SetRow(slot, 0); Grid.SetRowSpan(slot, 2); Grid.SetColumn(slot, 1); mainGrid.Children.Add(slot); }
public Spine(Fitter fitter, uint pegs) { if (fitter == null) { throw new ArgumentNullException("fitter"); } this.fitter = fitter; animationTime = new Duration(new TimeSpan(1000000)); InitializeComponent(); pegs = Math.Max(minPegs, pegs); for (int i = 0; i < pegs; i++) { AddPeg(); } }
public TriggerBar(Fitter fitter) { if (fitter == null) { throw new ArgumentNullException("fitter"); } currentScriptIsBasedOn = String.Empty; spine = new Spine(fitter, 3); Grid.SetRow(spine, 0); Grid.SetColumn(spine, 0); spine.Margin = new Thickness(14, 0, 0, 0); triggerSlot = new TriggerSlot(new TriggerFitter()); triggerSlot.AllowDrop = true; triggerSlot.Margin = new Thickness(100, 0, 0, 0); InitializeComponent(); triggerBarPanel.Children.Add(triggerSlot); saveButton = new BigButton("Save"); saveButton.Margin = new Thickness(35, 5, 5, 5); triggerBarPanel.Children.Add(saveButton); spine.Extends = border.Height + 20; Grid.SetZIndex(spine, 1); Grid.SetZIndex(border, 2); mainGrid.Children.Add(spine); Effect = new DropShadowEffect(); triggerSlot.Changed += delegate { OnChanged(new EventArgs()); }; spine.Changed += delegate { OnChanged(new EventArgs()); }; }
/// <summary> /// Constructs a new <see cref="BlockSlot"/> instance. /// </summary> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public BlockSlot(Fitter fitter) : base(fitter) { InitializeComponent(); this.fitter = fitter; border.MinWidth = ObjectBlock.DefaultSize.Width + border.BorderThickness.Left + border.BorderThickness.Right; border.MinHeight = ObjectBlock.DefaultSize.Height + border.BorderThickness.Top + border.BorderThickness.Bottom; string text = fitter.GetMoveableDescription(); if (text == "something") { text = "some thing"; } fitterText.Text = text; fitterText.Foreground = Brushes.DarkSlateBlue; fitterText.MaxWidth = border.MinWidth; fitterText.MaxHeight = border.MinHeight; fitterText.Padding = textThickness; SetDefaultAppearance(); }
/// <summary> /// Constructs a new <see cref="ConditionSlot"/> instance. /// </summary> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public ConditionSlot(Fitter fitter) : base(fitter) { InitializeComponent(); SetDefaultAppearance(); }
public Spine(Fitter fitter) : this(fitter, 3) { }
public StatementComponent(Fitter parameterFitter) { this.parameterFitter = parameterFitter; this.labelText = null; this.componentType = ComponentType.Parameter; }
/// <summary> /// Constructs a new <see cref="BlockSlot"/> instance. /// </summary> /// <param name="slotName">The name of this slot.</param> /// <param name="fitter">A fitter which decides whether a /// given Moveable can fit into this slot.</param> public BlockSlot(string slotName, Fitter fitter) : this(fitter) { // Not sure if I'm going to use slot names or not, so here's // a dummy constructor for all the instances I'm already // creating using them. }
public StatementComponent(string labelText) { this.parameterFitter = null; this.labelText = labelText; this.componentType = ComponentType.Label; }
public Spine(Fitter fitter, uint pegs, double extends) : this(fitter, pegs) { Extends = extends; }
public DropZone(Fitter fitter) : base(fitter) { InitializeComponent(); SetDefaultAppearance(); }