Exemple #1
0
        private List <Pin> CollectPins(Function function)
        {
            List <Pin> list = new List <Pin>();

            System.Drawing.RectangleF r = Util.eplan.GetBoundingBox(function);

            foreach (Placement p in function.Page.AllPlacements)
            {
                if (p != function)
                {
                    System.Drawing.Point location = new System.Drawing.Point((int)p.Location.X, (int)p.Location.Y);
                    if (r.Contains(location))
                    {
                        Function f = p as Function;
                        if (f == null)
                        {
                            continue;
                        }

                        list.AddRange(f.Pins);
                    }
                }
            }
            return(list);
        }
Exemple #2
0
        public bool HitTest(Rectangle contentRect, Vector2 point)
        {
            Rectangle rect = drawRect != null ? (Rectangle)drawRect : contentRect;

            if (!rect.Contains(point.X, point.Y))
            {
                return(false);
            }

            float radiusX = rect.Width * 0.5f;
            float raduisY = rect.Height * 0.5f;
            float xx      = point.X - radiusX - rect.X;
            float yy      = point.Y - raduisY - rect.Y;

            if (Math.Pow(xx / radiusX, 2) + Math.Pow(yy / raduisY, 2) < 1)
            {
                if (startDegree != 0 || endDegreee != 360)
                {
                    float deg = MathHelper.ToDegrees((float)Math.Atan2(yy, xx));
                    if (deg < 0)
                    {
                        deg += 360;
                    }
                    return(deg >= startDegree && deg <= endDegreee);
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
        internal bool HitTest(Point p, Transformation trans)
        {
            if (!IsVisible)
            {
                return(false);
            }

            int size = 5;

            if (IsHighlighted)
            {
                size = StyleManager.PassengerHightlightSize;
            }
            else
            {
                size = StyleManager.PassengerSize;
            }

            System.Drawing.Point      pictureRectangle = trans.CalculatePixel(Location);
            System.Drawing.RectangleF rect             = new System.Drawing.RectangleF(pictureRectangle.X - size, pictureRectangle.Y - size, size * 2, size * 2);

            if (rect.Contains((float)p.X, (float)p.Y))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        public void DrawDebug(DrawParameters p)
        {
            if (!(this is XImage) && !(this is XBlock))
            {
                return;
            }

            tmpBounds = this.GetScreenBounds();

#if WINDOWS
            tmpVector1 = MouseProcessor.LastPosition;
#else
            tmpVector1 = TouchPanelProcessor.LastPosition;
#endif

            if (!tmpBounds.Contains((int)tmpVector1.X, (int)tmpVector1.Y))
            {
                return;
            }

            Color c = Color.Red * 0.3f;


            p.SpriteBatch.Draw(p.Game.BlankTexture, tmpBounds, c);

            if (!string.IsNullOrEmpty(this.Id))
            {
                tmpVector1.X = tmpBounds.X;
                tmpVector1.Y = tmpBounds.Y;

                p.SpriteBatch.DrawString(p.Game.SystemFont, this.Id, tmpVector1, Color.Yellow);
            }
        }
        public bool HitTest(Rectangle contentRect, Vector2 point)
        {
            if (!contentRect.Contains(point.X, point.Y))
            {
                return(false);
            }

            bool flag = false;
            int  cnt  = elements.Count;

            for (int i = 0; i < cnt; i++)
            {
                if (activeIndex == -1 || i == activeIndex)
                {
                    IHitTest ht = elements[i] as IHitTest;
                    if (ht != null)
                    {
                        if (ht.HitTest(contentRect, point))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }

            return(flag);
        }
        public bool HitTest(Rectangle contentRect, Vector2 point)
        {
            if (!contentRect.Contains(point.X, point.Y))
            {
                return(false);
            }

            // Algorithm & implementation thankfully taken from:
            // -> http://alienryderflex.com/polygon/
            // inspired by Starling
            int  len = points.Count;
            int  i;
            int  j        = len - 1;
            bool oddNodes = false;

            for (i = 0; i < len; ++i)
            {
                float ix = points[i].X;
                float iy = points[i].Y;
                float jx = points[j].X;
                float jy = points[j].Y;

                if ((iy < point.Y && jy >= point.Y || jy < point.Y && iy >= point.Y) && (ix <= point.X || jx <= point.X))
                {
                    if (ix + (point.Y - iy) / (jy - iy) * (jx - ix) < point.X)
                    {
                        oddNodes = !oddNodes;
                    }
                }

                j = i;
            }

            return(oddNodes);
        }
Exemple #7
0
 public static List <CharBox> GetCharBoxsSurroundedByRectangle(List <CharBox> cbs, System.Drawing.RectangleF r, bool excludeInvisibleCharacters = false)
 {
     cbs = removeDuplicates(cbs.Where(a => (r.Contains(a.R) /*|| d.IntersectsWith(a.R)*/)));
     if (excludeInvisibleCharacters)
     {
         cbs = cbs.Where(a => !InvisibleCharacters.Contains(a.Char)).ToList();
     }
     return(cbs);
 }
        public bool ContainsInVisibleRegion(Position position, Position bottomLeft, Position topRight)
        {
            var rect = new System.Drawing.RectangleF((float)bottomLeft.Latitude, (float)bottomLeft.Longitude,
                                                     (float)(topRight.Latitude - bottomLeft.Latitude), (float)(topRight.Longitude - bottomLeft.Longitude));

            var point = new System.Drawing.PointF((float)position.Latitude, (float)position.Longitude);

            return(rect.Contains(point));
        }
 public bool HitTest(Rectangle contentRect, Vector2 point)
 {
     if (drawRect != null)
     {
         return(((Rectangle)drawRect).Contains(point.X, point.Y));
     }
     else
     {
         return(contentRect.Contains(point.X, point.Y));
     }
 }
Exemple #10
0
        /// <summary>
        /// Finds all objects of the layer contained by specified rectangular area.
        /// </summary>
        /// <param name="area">The area for search.</param>
        /// <returns>Returns array of the objects which are located inside specified area.</returns>
        public IVObject[] Find(System.Drawing.RectangleF area, bool includeLockedObjects)
        {
            System.Collections.ArrayList acc = new System.Collections.ArrayList(16);
            for (int i = 0; i < _objects.Count; i++)
            {
                System.Drawing.RectangleF bounds = _objects[i].GetTransformedVObjectBounds();
                if (area.Contains(bounds) && (!_objects[i].Locked || includeLockedObjects))
                {
                    acc.Add(_objects[i]);
                }
            }

            return((IVObject[])acc.ToArray(typeof(IVObject)));
        }
        /// <summary>
        /// Returns a collection of MapObjects inside the given region
        /// </summary>
        /// <param name="objectLayerID">The object layer to check</param>
        /// <param name="region">The region, in pixles, to check</param>
        /// <returns>Collection of matching MapObjects</returns>
        public IEnumerable <MapObject> GetObjectsInRegion(Int32 objectLayerID, ref System.Drawing.RectangleF region)
        {
            List <MapObject> results = new List <MapObject>();

            for (int i = 0; i < this.ObjectLayers[objectLayerID].MapObjects.Length; i++)
            {
                if (region.Contains(RecToRecF(this.ObjectLayers[objectLayerID].MapObjects[i].Bounds)) || region.Intersects(RecToRecF(this.ObjectLayers[objectLayerID].MapObjects[i].Bounds)))
                {
                    results.Add(this.ObjectLayers[objectLayerID].MapObjects[i]);
                }
            }

            return(results);
        }
Exemple #12
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                System.Drawing.RectangleF rec = ButtonBounds;
                if (rec.Contains(e.CanvasLocation))
                {
                    MessageBox.Show("The button was clicked, and we want " + (base.Owner as VariableParameterTestComponent).outputparamno + " output params", "Button", MessageBoxButtons.OK);
                    (base.Owner as VariableParameterTestComponent).MatchParameterCount();

                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
        /// <summary>
        /// Determines whether the <see cref="TerrainQuad"/> is inside the bounds
        /// of the specified rectangle.
        /// </summary>
        /// <param name="rectangle"></param>
        /// <returns></returns>
        public override bool IsInsideRectangle(System.Drawing.RectangleF rectangle)
        {
            bool inside = false;

            for (int i = 0; i < 4; i++)
            {
                if (rectangle.Contains(this.corners[i].X, this.corners[i].Z))
                {
                    inside = true;
                    break;
                }
            }

            return(inside);
        }
Exemple #14
0
        private int GetCharacterIndexAtPoint(Point point)
        {
            if (!_drawRect.Contains(point))
            {
                return(-1);
            }

            UpdateHyperlinkLayout();

            // Find the tapped character's index
            var partialFraction      = (nfloat)0;
            var pointInTextContainer = new CGPoint(point.X - _drawRect.X, point.Y - _drawRect.Y);
            var characterIndex       = (int)_layoutManager.CharacterIndexForPoint(pointInTextContainer, _layoutManager.TextContainers.FirstOrDefault(), ref partialFraction);

            return(characterIndex);
        }
Exemple #15
0
        /// <summary>
        /// ポインタセット
        /// </summary>
        /// <param name="px"></param>
        /// <param name="py"></param>
        public void PointerSet(double px, double py)
        {
            if (AxisPointed != null)
            {
                if (plotArea.Contains((float)px, (float)py))
                {
                    var arg = new AxisPointedEventArgs
                    {
                        X                                              = axisX != null?axisX.PhysicalValueToLogicalValue(px, plotArea.Location) : 0,
                                                  Y1                   = axisY1 != null?axisY1.PhysicalValueToLogicalValue(py, plotArea.Location) : 0,
                                                                    Y2 = axisY1 != null?axisY2.PhysicalValueToLogicalValue(py, plotArea.Location) : 0
                    };

                    AxisPointed.Invoke(this, arg);
                }
            }
        }
Exemple #16
0
        public void MovePlacements(PointD delta)
        {
            System.Drawing.RectangleF r = Util.eplan.GetBoundingBox(this.Function);

            this.Function.Location = new PointD(this.Function.Location.X + delta.X, this.Function.Location.Y + delta.Y);

            foreach (Placement p in this.Function.Page.AllPlacements)
            {
                System.Drawing.Point location = new System.Drawing.Point((int)p.Location.X, (int)p.Location.Y);
                if (r.Contains(location))
                {
                    p.Location = new PointD(p.Location.X + delta.X, p.Location.Y + delta.Y);
                }
            }

            return;
        }
Exemple #17
0
        internal bool HitTest(Point p, Transformation trans)
        {
            if (!IsVisible)
            {
                return(false);
            }

            System.Drawing.Point      pictureRectangle = trans.CalculatePixel(Location);
            System.Drawing.RectangleF rect             = new System.Drawing.RectangleF(pictureRectangle.X - 5, pictureRectangle.Y - 5, 10, 10);

            if (rect.Contains((float)p.X, (float)p.Y))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        virtual protected DisplayObject HitTest()
        {
            Rectangle rect = GetBounds(this);

            if (rect.Width == 0 || rect.Height == 0)
            {
                return(null);
            }

            Vector2 localPoint = GlobalToLocal(HitTestContext.screenPoint);

            if (rect.Contains(localPoint.X, localPoint.Y))
            {
                return(this);
            }
            else
            {
                return(null);
            }
        }
Exemple #19
0
        private static Control _ParentContains(Control control, System.Drawing.PointF mousePosition, Control currentControl, ref bool ok)
        {
            //Application.Log(control.Name);
            if (control == null || control.Parent == null)
            {
                return(currentControl);
            }

            var parentLocation = control.Parent.PointToScreen(System.Drawing.Point.Zero);
            var parentRect     = new System.Drawing.RectangleF(parentLocation.X, parentLocation.Y, control.Parent.Width, control.Parent.Height);

            if (parentRect.Contains(mousePosition) == true)
            {
                currentControl = control.Parent;
            }
            else
            {
                ok = false; // Control is not visible due to groups;
            }
            return(_ParentContains(control.Parent, mousePosition, currentControl, ref ok));
        }
Exemple #20
0
        private int GetCharacterIndexAtPoint(Point point)
        {
            if (!_drawRect.Contains(point))
            {
                return(-1);
            }

            // Configure textContainer
            var textContainer = new NSTextContainer();

            textContainer.LineFragmentPadding  = 0;
            textContainer.LineBreakMode        = LineBreakMode;
            textContainer.MaximumNumberOfLines = (nuint)Lines;
            textContainer.Size = _drawRect.Size;

            // Configure layoutManager
            var layoutManager = new NSLayoutManager();

            layoutManager.AddTextContainer(textContainer);

            // Configure textStorage
            var textStorage = new NSTextStorage();

            textStorage.SetString(AttributedText);
            textStorage.AddLayoutManager(layoutManager);
            textStorage.SetAttributes(
                new UIStringAttributes()
            {
                Font = Font
            },
                new NSRange(0, textStorage.Length)
                );

            // Find the tapped character's index
            var partialFraction      = (nfloat)0;
            var pointInTextContainer = new CGPoint(point.X - _drawRect.X, point.Y - _drawRect.Y);
            var characterIndex       = (int)layoutManager.CharacterIndexForPoint(pointInTextContainer, textContainer, ref partialFraction);

            return(characterIndex);
        }
Exemple #21
0
 public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
 {
     if (e.Clicks == 2 && e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         System.Drawing.RectangleF rec = ButtonBounds;
         if (rec.Contains(e.CanvasLocation))
         {
             ((SelectComponent)Owner).inputLock = !((SelectComponent)Owner).inputLock;
             if (((SelectComponent)Owner).inputLock == false) //unlock
             {
                 //((SelectablePreviewComponent)Owner).addSelection = true;
                 ((SelectComponent)Owner).ForceExpireSolution(true, false, true);
                 ((SelectComponent)Owner).SelectStoredPathObj();
                 //((SelectablePreviewComponent)Owner).addSelection = false;
             }
             else
             {
                 ((SelectComponent)Owner).ForceExpireSolution(false, false);
             }
         }
     }
     return(base.RespondToMouseDown(sender, e));
 }
Exemple #22
0
 public bool HitTest(Rectangle rect, Vector2 localPoint)
 {
     return(rect.Contains(localPoint.X, localPoint.Y));
 }
Exemple #23
0
		public void DrawDebug(DrawParameters p)
		{
			if (!(this is XImage) && !(this is XBlock))
				return;
			
			tmpBounds =  this.GetScreenBounds();
		
#if WINDOWS
			tmpVector1 = MouseProcessor.LastPosition;
#else
			tmpVector1 = TouchPanelProcessor.LastPosition;
#endif
			
			if (!tmpBounds.Contains((int)tmpVector1.X, (int)tmpVector1.Y))
				return;
			
			Color c = Color.Red * 0.3f;
			
			
			p.SpriteBatch.Draw(p.Game.BlankTexture, tmpBounds, c);
			
			if (!string.IsNullOrEmpty(this.Id))
			{
				tmpVector1.X = tmpBounds.X;
				tmpVector1.Y = tmpBounds.Y;
				
				p.SpriteBatch.DrawString(p.Game.SystemFont, this.Id, tmpVector1, Color.Yellow);
			}
		}
Exemple #24
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                ModelBuilder modelbld = Owner as ModelBuilder;


                System.Drawing.RectangleF rec1 = Button1Bounds;
                if (rec1.Contains(e.CanvasLocation))
                {
                    if (own.Params.Input[0].Sources.Count == 0) // if no inputs are plugged in
                    {
                        DialogResult result = MessageBox.Show("Datagenerator is not connected.", "Warning");
                    }
                    else
                    {
                        CSVtype csvinput = own.Params.Input[0].Sources[0] as CSVtype;

                        if (!File.Exists(own.csvfilepath))
                        {
                            DialogResult result = MessageBox.Show("No data has been generated.", "Warning");
                        }

                        else if (own.datagencomponent.Params.Input[0].SourceCount == 0 || own.datagencomponent.Params.Input[1].SourceCount == 0 || own.datagencomponent.Params.Input[2].SourceCount == 0)

                        {
                            DialogResult result = MessageBox.Show("Datagenerator is missing some inputs.", "Warning");
                        }

                        else
                        {
                            modelbld.RunSolver_BuildBN();
                        }
                    }

                    return(GH_ObjectResponse.Handled);
                }

                System.Drawing.RectangleF rec2 = Button2Bounds;
                if (rec2.Contains(e.CanvasLocation))
                {
                    if (own.Params.Input[0].Sources.Count == 0) // if no inputs are plugged in
                    {
                        DialogResult result = MessageBox.Show("Datagenerator is not connected.", "Warning");
                    }
                    else
                    {
                        if (modelbld.model == null)
                        {
                            DialogResult result = MessageBox.Show("No model has been built. Please build model before updating.", "Warning");
                        }
                        else
                        {
                            modelbld.RunSolver_UpdateBN();
                        }
                    }



                    return(GH_ObjectResponse.Handled);
                }

                System.Drawing.RectangleF rec3 = Button3Bounds;
                if (rec3.Contains(e.CanvasLocation))
                {
                    if (own.Params.Input[0].Sources.Count == 0) // if no inputs are plugged in
                    {
                        DialogResult result = MessageBox.Show("Datagenerator is not connected.", "Warning");
                    }
                    else
                    {
                        if (modelbld.model == null)
                        {
                            DialogResult result = MessageBox.Show("Nothing to reset. No model has been built.", "Warning");
                        }

                        else
                        {
                            modelbld.RunSolver_ResetBN();
                        }
                    }

                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemple #25
0
        private static Control _ParentContains(Control control, System.Drawing.PointF mousePosition, Control currentControl, ref bool ok)
        {
            //Application.Log(control.Name);
            if (control == null || control.Parent == null) return currentControl;

            var parentLocation = control.Parent.PointToScreen(System.Drawing.Point.Zero);
            var parentRect = new System.Drawing.RectangleF(parentLocation.X, parentLocation.Y, control.Parent.Width, control.Parent.Height);
            if (parentRect.Contains(mousePosition) == true)
                currentControl = control.Parent;
            else
                ok = false; // Control is not visible due to groups;

            return _ParentContains(control.Parent, mousePosition, currentControl, ref ok);
        }
Exemple #26
0
        private static bool _ProcessControl(System.Drawing.PointF mousePosition, Control control, bool ignore_rect)
        {
            // ignore_rect will call mouse_up & mouse_move in any case.
            var c_location = control.PointToScreen(System.Drawing.Point.Zero);
            var clientRect = new System.Drawing.RectangleF(c_location.X, c_location.Y, control.Width, control.Height);
            var contains = clientRect.Contains(mousePosition);

            if (contains && (_mouseEvent == MouseEvents.Down) || _mouseEvent == MouseEvents.Up)
            {
                if (control.Parent != null)
                {
                    bool ok = true;
                    var clickedControl = _ParentContains(control, mousePosition, control, ref ok);
                    if (clickedControl != null && ok == false)
                        control = clickedControl;
                }
            }

            if (ignore_rect || contains)
            {
                var client_mpos = control.PointToClient(mousePosition);
                if (_mouseMovePosition != mousePosition)
                {
                    MouseEventArgs m_args = new MouseEventArgs(MouseButtons.None, 0, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseMove(m_args);
                    if (_dragData != null)
                        _dragndrop = true;
                }

                if (!contains && _mouseEvent != MouseEvents.Up)
                    return true;
                switch (_mouseEvent)
                {
                    case MouseEvents.Down:
                        MouseEventArgs md_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                        control.RaiseOnMouseDown(md_args);
                        _mouseLastClickControl = control;
                        return true;
                    case MouseEvents.Up:
                        if (_dragndrop)
                        {
                            if (control.AllowDrop)
                            {
                                DataObject dnd_data = new DataObject(_dragData);
                                DragEventArgs dnd_args = new DragEventArgs(dnd_data, 0, (int)client_mpos.X, (int)client_mpos.Y, DragDropEffects.None, _dragControlEffects);
                                control.RaiseOnDragDrop(dnd_args);
                            }
                            _dragData = null;
                            _dragndrop = false;
                        }
                        MouseEventArgs mu_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                        control.RaiseOnMouseUp(mu_args);
                        if (_mouseLastClickControl == control)
                            control.RaiseOnMouseClick(mu_args);
                        if (_mouseLastClickControl != null && control != _mouseLastClickControl)
                            _mouseLastClickControl.RaiseOnMouseUp(mu_args);
                        return true;
                    case MouseEvents.DoubleClick:
                        MouseEventArgs mdc_args = new MouseEventArgs(_mouseButton, 2, (int)client_mpos.X, (int)client_mpos.Y, 0);
                        control.RaiseOnMouseDoubleClick(mdc_args);
                        return true;
                    case MouseEvents.Wheel:
                        MouseEventArgs mw_args = new MouseEventArgs(MouseButtons.Middle, 0, (int)client_mpos.X, (int)client_mpos.Y, (int)(-_mouseWheelDelta * 4));
                        control.RaiseOnMouseWheel(mw_args);
                        return true;
                }
            }
            if (!contains)
                control.RaiseOnMouseLeave(null);
            return false;
        }
Exemple #27
0
 private void DoClickObjectByParamID(string objectName, int pageN, float left, float top)
 {
     if (Report.PreparedPages != null)
     {
         bool found = false;
         while (pageN < Report.PreparedPages.Count && !found)
         {
             ReportPage page = Report.PreparedPages.GetPage(pageN);
             if (page != null)
             {
                 ObjectCollection      allObjects = page.AllObjects;
                 System.Drawing.PointF point      = new System.Drawing.PointF(left + 1, top + 1);
                 foreach (Base obj in allObjects)
                 {
                     if (obj is ReportComponentBase)
                     {
                         ReportComponentBase c = obj as ReportComponentBase;
                         if (c is TableBase)
                         {
                             TableBase table = c as TableBase;
                             for (int i = 0; i < table.RowCount; i++)
                             {
                                 for (int j = 0; j < table.ColumnCount; j++)
                                 {
                                     TableCell textcell = table[j, i];
                                     if (textcell.Name == objectName)
                                     {
                                         System.Drawing.RectangleF rect =
                                             new System.Drawing.RectangleF(table.Columns[j].AbsLeft,
                                                                           table.Rows[i].AbsTop,
                                                                           textcell.Width,
                                                                           textcell.Height);
                                         if (rect.Contains(point))
                                         {
                                             Click(textcell, pageN, page);
                                             found = true;
                                             break;
                                         }
                                     }
                                 }
                                 if (found)
                                 {
                                     break;
                                 }
                             }
                         }
                         else
                         if (c.Name == objectName &&
                             //#if FRCORE
                             c.AbsBounds.Contains(point))
                         //#else
                         //                                  c.PointInObject(point))
                         //#endif
                         {
                             Click(c, pageN, page);
                             found = true;
                             break;
                         }
                     }
                 }
                 page.Dispose();
                 pageN++;
             }
         }
     }
 }
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                DataGenerator datgen = Owner as DataGenerator;

                System.Drawing.RectangleF rec = ButtonBounds;
                if (rec.Contains(e.CanvasLocation))
                {
                    //call check if file exists function


                    //int num  = numSld;

                    //if no data has been generated
                    if (File.Exists(own.csvfilepath))
                    {
                        DialogResult result = MessageBox.Show("Data already exists. Are you sure you would like to generate new data?", "Slider Automator", MessageBoxButtons.YesNo);

                        if (result == DialogResult.Yes)
                        {
                            // first empty all PSlider and POutput PD bins
                            foreach (PSlider slider in own.pluggedSliders)
                            {
                                slider.emptyPD();
                            }

                            foreach (POutput output in own.pluggedPOutputs)
                            {
                                output.emptyPD();
                            }

                            own.ExpireSolution(true);

                            datgen.RunSolver();
                        }
                        else if (result == DialogResult.No)
                        {
                            // do nothing
                        }
                    }

                    else
                    {
                        int numsliders = own.Params.Input[0].SourceCount;
                        if (numsliders != 0)
                        {
                            DialogResult result = MessageBox.Show("You have " + numsliders + " input sliders connected. Go ahead?", "Slider Automator", MessageBoxButtons.YesNo);

                            if (result == DialogResult.Yes)
                            {
                                datgen.RunSolver();
                            }
                            else if (result == DialogResult.No)
                            {
                                // do nothing
                            }
                        }
                        else
                        {
                            DialogResult result = MessageBox.Show("No sliders are connected!", "Warning");
                        }
                    }



                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemple #29
0
        private static bool _ProcessControl(System.Drawing.PointF mousePosition, Control control, bool ignore_rect)
        {
            // ignore_rect will call mouse_up & mouse_move in any case.
            var c_location = control.PointToScreen(System.Drawing.Point.Zero);
            var clientRect = new System.Drawing.RectangleF(c_location.X, c_location.Y, control.Width, control.Height);
            var contains   = clientRect.Contains(mousePosition);

            if (contains && (_mouseEvent == MouseEvents.Down) || _mouseEvent == MouseEvents.Up)
            {
                if (control.Parent != null)
                {
                    bool ok             = true;
                    var  clickedControl = _ParentContains(control, mousePosition, control, ref ok);
                    if (clickedControl != null && ok == false)
                    {
                        control = clickedControl;
                    }
                }
            }

            if (ignore_rect || contains)
            {
                var client_mpos = control.PointToClient(mousePosition);
                if (_mouseMovePosition != mousePosition)
                {
                    MouseEventArgs m_args = new MouseEventArgs(MouseButtons.None, 0, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseMove(m_args);
                    if (_dragData != null)
                    {
                        _dragndrop = true;
                    }
                }

                if (!contains && _mouseEvent != MouseEvents.Up)
                {
                    return(true);
                }
                switch (_mouseEvent)
                {
                case MouseEvents.Down:
                    MouseEventArgs md_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseDown(md_args);
                    _mouseLastClickControl = control;
                    return(true);

                case MouseEvents.Up:
                    if (_dragndrop)
                    {
                        if (control.AllowDrop)
                        {
                            DataObject    dnd_data = new DataObject(_dragData);
                            DragEventArgs dnd_args = new DragEventArgs(dnd_data, 0, (int)client_mpos.X, (int)client_mpos.Y, DragDropEffects.None, _dragControlEffects);
                            control.RaiseOnDragDrop(dnd_args);
                        }
                        _dragData  = null;
                        _dragndrop = false;
                    }
                    MouseEventArgs mu_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseUp(mu_args);
                    if (_mouseLastClickControl == control)
                    {
                        control.RaiseOnMouseClick(mu_args);
                    }
                    if (_mouseLastClickControl != null && control != _mouseLastClickControl)
                    {
                        _mouseLastClickControl.RaiseOnMouseUp(mu_args);
                    }
                    return(true);

                case MouseEvents.DoubleClick:
                    MouseEventArgs mdc_args = new MouseEventArgs(_mouseButton, 2, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseDoubleClick(mdc_args);
                    return(true);

                case MouseEvents.Wheel:
                    MouseEventArgs mw_args = new MouseEventArgs(MouseButtons.Middle, 0, (int)client_mpos.X, (int)client_mpos.Y, (int)(-_mouseWheelDelta * 4));
                    control.RaiseOnMouseWheel(mw_args);
                    return(true);
                }
            }
            if (!contains)
            {
                control.RaiseOnMouseLeave(null);
            }
            return(false);
        }