public FlowConnector(FlowElement owner, bool isInput)
 {
     if (owner == null)
         throw new ArgumentNullException("owner");
     this.Owner = owner;
     this.IsInput = isInput;
 }
Exemple #2
0
 public static int GetConnectorIndex(FlowElement el, FlowConnector fl)
 {
     if (fl.IsInput)
     {
         return(el.InputConnectors.IndexOf(fl));
     }
     return(el.OutputConnectors.IndexOf(fl));
 }
Exemple #3
0
        public FlowConnector(FlowElement owner, string name, bool isInput)
            : this(owner, isInput)
        {
            this.Name = name;

            // Precalculate the invalidation width.
            this.InvalidationWidth = 200;
        }
Exemple #4
0
 /// <summary>
 /// Pushes an element on the queue for reprocessing.
 /// </summary>
 public void PushForReprocessing(FlowElement flowElement)
 {
     if (flowElement == null)
     {
         throw new ArgumentNullException("flowElement");
     }
     flowElement.ObjectReprocessRequested();
 }
        public FlowConnector(FlowElement owner, string name, bool isInput)
            : this(owner, isInput)
        {
            this.Name = name;

            // Precalculate the invalidation width.
            this.InvalidationWidth = 200;
        }
Exemple #6
0
 public FlowConnector(FlowElement owner, bool isInput)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner");
     }
     this.Owner   = owner;
     this.IsInput = isInput;
 }
Exemple #7
0
        public AnalyseForm(
            IStorageAccess storageAccess,
            FlowElement flowElement)
        {
            this.InitializeComponent();

            this.m_Layer = storageAccess.ToRuntime(((AlgorithmFlowElement)flowElement).Layer);
            this.c_AnalysisAddOptionsMenu.Items.AddRange((
                from assembly in AppDomain.CurrentDomain.GetAssemblies()
                from type in assembly.GetTypes()
                where typeof(AnalysisEngine).IsAssignableFrom(type) && !type.IsGenericType && !type.IsAbstract
                select new TypeWrapper(type)).ToArray());
        }
Exemple #8
0
        public ExportForm(
            IRenderingLocationProvider renderingLocationProvider,
            IStorageAccess storageAccess,
            FlowElement flowElement)
        {
            this.InitializeComponent();

            this.m_StorageAccess = storageAccess;
            this.m_RenderingLocationProvider = renderingLocationProvider;
            this.m_Layer = this.m_StorageAccess.ToRuntime(((AlgorithmFlowElement)flowElement).Layer);
            this.m_Bitmap = new Bitmap(1024 + 32, 1024 + 256);
            this.c_RenderBox.Image = this.m_Bitmap;
            this.c_Timer.Start();
        }
Exemple #9
0
        public TraceForm(
            IStorageAccess storageAccess,
            IAlgorithmTraceImageGeneration algorithmTraceImageGeneration,
            FlowElement flowElement,
            ICurrentWorldSeedProvider currentWorldSeedProvider)
        {
            this.m_AlgorithmTraceImageGeneration = algorithmTraceImageGeneration;

            this.InitializeComponent();
            this.m_Layer = storageAccess.ToRuntime(((AlgorithmFlowElement)flowElement).Layer);
            this.m_Layer.SetSeed(currentWorldSeedProvider.Seed);
            this.c_FormZoomSize.Items.Add(new ZoomLevel { Level = 1 });
            this.c_FormZoomSize.Items.Add(new ZoomLevel { Level = 2 });
            this.c_FormZoomSize.SelectedIndex = 0;
        }
Exemple #10
0
        internal static void RenderTo(FlowElement el, RenderAttributes re, bool selected)
        {
            int ex = (int)(el.X * re.Zoom);
            int ey = (int)(el.Y * re.Zoom);
            int ew = (int)(el.Width * re.Zoom);
            int eh = (int)(el.Height * re.Zoom);
            int eiw = (int)Math.Floor(el.ImageWidth * re.Zoom);
            int eih = (int)Math.Floor(el.ImageHeight * re.Zoom);
            int etx = (int)((el.X + 4) * re.Zoom);
            int ety = (int)((el.Y + 4) * re.Zoom);
            int aiw = 0, aih = 0;

            if (el.m_AdditionalInformation != null)
            {
                aiw = (int)Math.Floor(el.m_AdditionalInformation.Width * re.Zoom);
                aih = (int)Math.Floor(el.m_AdditionalInformation.Height * re.Zoom);
            }

            re.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
            re.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            re.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            re.Graphics.FillRectangle(selected ? m_TitleHighlight : SystemBrushes.Control, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom);
            re.Graphics.DrawRectangle(Pens.Black, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom);
            re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(etx, ety));
            var image = el.Image;

            if (image != null && ex + 1 * re.Zoom + eiw > 0 && ey + 21 * re.Zoom + eih > 0)
            {
                re.Graphics.DrawImage(image, ex + 1 * re.Zoom, ey + 21 * re.Zoom, eiw, eih);
            }
            var additional = el.m_AdditionalInformation;

            if (additional != null && ex + 1 * re.Zoom + aiw > 0 && ey + 21 * re.Zoom + eih + aih > 0)
            {
                re.Graphics.DrawImage(additional, ex + 1 * re.Zoom, ey + 21 * re.Zoom + eih, aiw, aih);
            }

            foreach (FlowConnector fl in el.OutputConnectors)
            {
                FlowConnector.RenderTo(fl, re);
            }
            foreach (FlowConnector fl in el.InputConnectors)
            {
                FlowConnector.RenderTo(fl, re);
            }
        }
Exemple #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.FillRectangle(SystemBrushes.ControlDark, e.ClipRectangle);

            // Render each flow element.
            var re = new RenderAttributes
            {
                Graphics = e.Graphics,
                Zoom     = this.Zoom,
                Font     = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size * this.Zoom)
            };

            foreach (FlowElement el in this.m_Elements)
            {
                FlowElement.RenderTo(el, re, this.m_SelectedElement == el || this.m_SelectedElements.Contains(el));
            }

            // Render the active connection line.
            if (this.m_ActiveConnection != null)
            {
                e.Graphics.DrawLine(new Pen(Color.Red, 3),
                                    this.m_ActiveConnection.Center,
                                    this.m_MouseActiveConnectionLocation
                                    );
            }

            if (this.m_Multiselecting)
            {
                var r = new Rectangle(
                    this.m_MultiselectStartX,
                    this.m_MultiselectStartY,
                    this.m_MultiselectEndX - this.m_MultiselectStartX,
                    this.m_MultiselectEndY - this.m_MultiselectStartY);
                r.Fix();

                e.Graphics.DrawRectangle(
                    new Pen(Color.Red, 3),
                    r
                    );
            }
        }
Exemple #12
0
        internal static void RenderTo(FlowConnector el, RenderAttributes re)
        {
            re.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            re.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            // If we are input, we draw on the left hand side of the flow element.
            int   idx = FlowElement.GetConnectorIndex(el.Owner, el);
            int   sx  = (int)Math.Ceiling(re.Graphics.MeasureString(el.Name, re.Font).Width);
            float xx  = (el.IsInput ? el.Owner.X - CONNECTOR_PADDING : el.Owner.X + el.Owner.Width + CONNECTOR_PADDING) * re.Zoom;
            float yy  = (el.Owner.Y + idx * (CONNECTOR_SIZE + CONNECTOR_PADDING)) * re.Zoom;

            if (el.IsInput)
            {
                re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(xx - sx + CONNECTOR_PADDING * re.Zoom, yy));
            }
            else
            {
                re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(xx, yy));
            }
            el.InvalidationWidth      = sx;
            el.m_CenterZoomAdjustment = re.Zoom;
            sx += CONNECTOR_PADDING;
            re.Graphics.DrawRectangle(Pens.Black, xx + (el.IsInput ? -sx : sx), yy, CONNECTOR_SIZE * re.Zoom, CONNECTOR_SIZE * re.Zoom);
            if (el.IsInput && el.ConnectedTo != null)
            {
                foreach (FlowConnector ct in el.ConnectedTo)
                {
                    try
                    {
                        re.Graphics.DrawLine(Pens.Blue, el.Center.Apply(re.Zoom), ct.Center.Apply(re.Zoom));
                    }
                    catch (OverflowException)
                    {
                    }
                }
            }
        }
 /// <summary>
 /// Pushes an element on the queue for reprocessing.
 /// </summary>
 public void PushForReprocessing(FlowElement flowElement)
 {
     if (flowElement == null)
         throw new ArgumentNullException("flowElement");
     flowElement.ObjectReprocessRequested();
 }
 /// <summary>
 /// Adds the element at the current mouse position.
 /// </summary>
 public void AddElementAtMouse(FlowElement flowElement)
 {
     flowElement.X = (int)(this.m_LastContextMenuOpenLocation.X / this.Zoom);
     flowElement.Y = (int)(this.m_LastContextMenuOpenLocation.Y / this.Zoom);
     this.Elements.Add(flowElement);
     this.Invalidate(flowElement.InvalidatingRegion.Fix());
 }
 public static int GetConnectorIndex(FlowElement el, FlowConnector fl)
 {
     if (fl.IsInput)
         return el.InputConnectors.IndexOf(fl);
     return el.OutputConnectors.IndexOf(fl);
 }
        internal static void RenderTo(FlowElement el, RenderAttributes re, bool selected)
        {
            int ex = (int)(el.X * re.Zoom);
            int ey = (int)(el.Y * re.Zoom);
            int ew = (int)(el.Width * re.Zoom);
            int eh = (int)(el.Height * re.Zoom);
            int eiw = (int)Math.Floor(el.ImageWidth * re.Zoom);
            int eih = (int)Math.Floor(el.ImageHeight * re.Zoom);
            int etx = (int)((el.X + 4) * re.Zoom);
            int ety = (int)((el.Y + 4) * re.Zoom);
            int aiw = 0, aih = 0;
            if (el.m_AdditionalInformation != null)
            {
                aiw = (int)Math.Floor(el.m_AdditionalInformation.Width * re.Zoom);
                aih = (int)Math.Floor(el.m_AdditionalInformation.Height * re.Zoom);
            }

            re.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
            re.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            re.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            re.Graphics.FillRectangle(selected ? m_TitleHighlight : SystemBrushes.Control, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom);
            re.Graphics.DrawRectangle(Pens.Black, ex, ey, ew - 1 * re.Zoom, eh - 1 * re.Zoom);
            re.Graphics.DrawString(el.Name, re.Font, SystemBrushes.ControlText, new PointF(etx, ety));
            var image = el.Image;
            if (image != null && ex + 1 * re.Zoom + eiw > 0 && ey + 21 * re.Zoom + eih > 0)
                re.Graphics.DrawImage(image, ex + 1 * re.Zoom, ey + 21 * re.Zoom, eiw, eih);
            var additional = el.m_AdditionalInformation;
            if (additional != null && ex + 1 * re.Zoom + aiw > 0 && ey + 21 * re.Zoom + eih + aih > 0)
                re.Graphics.DrawImage(additional, ex + 1 * re.Zoom, ey + 21 * re.Zoom + eih, aiw, aih);

            foreach (FlowConnector fl in el.OutputConnectors)
                FlowConnector.RenderTo(fl, re);
            foreach (FlowConnector fl in el.InputConnectors)
                FlowConnector.RenderTo(fl, re);
        }