Example #1
0
        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();
        }
Example #2
0
        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();
        }
Example #3
0
        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();
            };
        }
Example #4
0
        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);
        }
Example #5
0
 /// <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;
         }
     };
 }
Example #6
0
 /// <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;
 }
Example #7
0
        /// <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()); };
        }
Example #8
0
        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);
        }
Example #9
0
        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();
            }
        }
Example #10
0
        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()); };
        }
Example #11
0
        /// <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();
        }
Example #12
0
 /// <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();
 }
Example #13
0
 public Spine(Fitter fitter) : this(fitter, 3)
 {
 }
Example #14
0
 public StatementComponent(Fitter parameterFitter)
 {
     this.parameterFitter = parameterFitter;
     this.labelText       = null;
     this.componentType   = ComponentType.Parameter;
 }
Example #15
0
 /// <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.
 }
Example #16
0
 public StatementComponent(string labelText)
 {
     this.parameterFitter = null;
     this.labelText       = labelText;
     this.componentType   = ComponentType.Label;
 }
Example #17
0
 public Spine(Fitter fitter, uint pegs, double extends) : this(fitter, pegs)
 {
     Extends = extends;
 }
Example #18
0
 public DropZone(Fitter fitter) : base(fitter)
 {
     InitializeComponent();
     SetDefaultAppearance();
 }