Example #1
0
        public void TestEqualOperator()
        {
            var s1 = new QPoint(3, 7);
            var s2 = new QPoint(3, 7);

            Assert.AreEqual(s1, s2);
        }
Example #2
0
        /// <summary>
        /// Convert Image to grayscale indexed image (like GIF)
        /// </summary>
        /// <param name="originalImage"></param>
        /// <returns></returns>
        public static QImage ConvertToGrayScaleIndexed(QImage originalImage)
        {
            var newImage = new QImage(originalImage.Size, QImage.Format.FormatGrayscale8);

            newImage.ColorCount = 256;
            for (int i = 0; i < 256; i++)
            {
                newImage.SetColor(i, qrgb.QRgb(i, i, i));
            }


            // Add color table for image
            // [looking at example](http://stackoverflow.com/questions/5504768/how-to-use-a-color-lut-in-qt-qimage)

            for (int x = 0; x < originalImage.Width; x++)
            {
                for (int y = 0; y < originalImage.Height; y++)
                {
                    var point = new QPoint(x, y); // pixel position

                    UInt32 pixel = originalImage.Pixel(point);
                    var    gray  = qrgb.QGray(pixel);
                    newImage.SetPixel(point, qrgb.QRgb(gray, gray, gray));
                }
            }
            //newImage.Save ( @"d:\dump.png", "png" );
            return(newImage);
        }
Example #3
0
        public void TestIntegerConstructor()
        {
            var s = new QPoint(5, 10);

            Assert.AreEqual(5, s.X);
            Assert.AreEqual(10, s.Y);
        }
Example #4
0
        private void OnContextMenu(QListViewItem item,QPoint point,int col)
        {
            popupMenuItem = item;

            if (item is ClassItem)
            {
                ClassItem klass = (ClassItem)item;

                QPopupMenu menu = new QPopupMenu(this);

                menu.InsertItem("Exclude from coverage",this,SLOT("OnExclude()"));

                if (klass.Model.sourceFile != null)
                {
                    menu.InsertItem("View Source",this,SLOT("OnViewSource()"));
                }

                menu.Exec(point);
            }
            else if (item is NamespaceItem)
            {
                QPopupMenu menu = new QPopupMenu(this);

                menu.InsertItem("Exclude from coverage",this,SLOT("OnExclude()"));
                menu.Exec(point);
            }
        }
Example #5
0
        void on_participantsGrid_customContextMenuRequested(QPoint point)
        {
            if (participantsGrid.HoverItem != null)
            {
                var mucHandler = (MucHandler)m_Handler;

                m_SelectedParticipant = participantsGrid.HoverItem;

                var me = mucHandler.Room.Participants[mucHandler.Room.RoomAndNick];

                bool isModerator    = me.Role == RoomRole.moderator;
                bool isAdminOrOwner = me.Affiliation == RoomAffiliation.admin || me.Affiliation == RoomAffiliation.owner;

                m_ModeratorActionsMenu.Enabled    = isModerator || isAdminOrOwner;
                m_ChangeAffiliationAction.Enabled = isAdminOrOwner;

                m_ModeratorAction.Checked   = (m_SelectedParticipant.Role == RoomRole.moderator);
                m_VisitorAction.Checked     = (m_SelectedParticipant.Role == RoomRole.visitor);
                m_ParticipantAction.Checked = (m_SelectedParticipant.Role == RoomRole.participant);

                m_AddAsFriendAction.Enabled = !String.IsNullOrEmpty(participantsGrid.HoverItem.RealJID);

                m_ParticipantItemMenu.Popup(participantsGrid.MapToGlobal(point));
            }
            else
            {
                m_ParticipantsMenu.Popup(participantsGrid.MapToGlobal(point));
            }
        }
Example #6
0
        public void TestEmptyConstructor()
        {
            var s = new QPoint();

            Assert.AreEqual(0, s.X);
            Assert.AreEqual(0, s.Y);
        }
Example #7
0
        public void TestManhattanLength()
        {
            var s1  = new QPoint(3, 7);
            var res = s1.ManhattanLength;

            Assert.AreEqual(10, res);
        }
Example #8
0
        public void TestY()
        {
            var s1 = new QPoint(3, 7);

            var res = s1.Y;

            Assert.AreEqual(7, res);
        }
Example #9
0
        public void TestDotProduct()
        {
            var s1  = new QPoint(3, 7);
            var s2  = new QPoint(-1, 4);
            var dot = QPoint.DotProduct(s1, s2);

            Assert.AreEqual(25, dot);
        }
Example #10
0
        public void TestX()
        {
            var s1 = new QPoint(3, 7);

            var res = s1.X;

            Assert.AreEqual(3, res);
        }
Example #11
0
        public unsafe void TestRy()
        {
            var s1 = new QPoint(3, 7);

            int *res = s1.Ry;

            Assert.AreEqual(7, *res);
        }
Example #12
0
        public void TestSubQPointOperator()
        {
            var s1 = new QPoint(3, 7);

            var res = -s1;

            Assert.AreEqual(-3, res.X);
            Assert.AreEqual(-7, res.Y);
        }
Example #13
0
        public void TestDivEqualOperator()
        {
            var s1 = new QPoint(-3, 10);

            s1 /= 2.5;

            Assert.AreEqual(-1, s1.X);
            Assert.AreEqual(4, s1.Y);
        }
Example #14
0
        public void TestDivOperator()
        {
            var s1 = new QPoint(3, 7);

            var res = s1 / 1.0;

            Assert.AreEqual(3, res.X);
            Assert.AreEqual(7, res.Y);
        }
Example #15
0
        public void TestMultiEqualDoubleOperator()
        {
            var s1 = new QPoint(3, 7);

            s1 *= 5.0;

            Assert.AreEqual(15, s1.X);
            Assert.AreEqual(35, s1.Y);
        }
Example #16
0
    private bool BarrelHit(QPoint pos)
    {
        QMatrix matrix = new QMatrix();

        matrix.Translate(0, Height());
        matrix.Rotate(-currentAngle);
        matrix = matrix.Inverted();
        return(barrelRect.Contains(matrix.Map(pos)));
    }
Example #17
0
        public void TestMultDoubleOperator()
        {
            var s1 = new QPoint(3, 7);

            var res = s1 * 5.0;

            Assert.AreEqual(15, res.X);
            Assert.AreEqual(35, res.Y);
        }
Example #18
0
        public void TestAddQPointOperator()
        {
            var s1 = new QPoint(3, 7);

            var res = +s1;

            Assert.AreEqual(3, res.X);
            Assert.AreEqual(7, res.Y);
        }
Example #19
0
        public void TestMultIntRevOperator()
        {
            var s1 = new QPoint(3, 7);

            var res = 5 * s1;

            Assert.AreEqual(15, res.X);
            Assert.AreEqual(35, res.Y);
        }
Example #20
0
        public void TestSubEqualOperator()
        {
            var s1 = new QPoint(3, 7);
            var s2 = new QPoint(-1, 4);

            s1 -= s2;

            Assert.AreEqual(4, s1.X);
            Assert.AreEqual(3, s1.Y);
        }
Example #21
0
        public void TestSubQPointsOperator()
        {
            var s1 = new QPoint(3, 7);
            var s2 = new QPoint(-1, 4);

            var res = s1 - s2;

            Assert.AreEqual(4, res.X);
            Assert.AreEqual(3, res.Y);
        }
Example #22
0
        public void TestAddQPointsOperator()
        {
            var s1 = new QPoint(3, 7);
            var s2 = new QPoint(-1, 4);

            var res = s1 + s2;

            Assert.AreEqual(2, res.X);
            Assert.AreEqual(11, res.Y);
        }
Example #23
0
        public void TestAddEqualOperator()
        {
            var s1 = new QPoint(3, 7);
            var s2 = new QPoint(-1, 4);

            s1 += s2;

            Assert.AreEqual(2, s1.X);
            Assert.AreEqual(11, s1.Y);
        }
Example #24
0
        public override void QueryOffset(Pnt point, out double offset, out double along)
        {
            along  = 0;
            offset = 0;
            bool rightSide = false;

            QPoint.PutCoords(point.X, point.Y);
            InnerSegment.QueryPointAndDistance(esriSegmentExtension.esriExtendTangents, QPoint,
                                               true, QPoint, ref along, ref offset, ref rightSide);
        }
Example #25
0
    public void NewTarget()
    {
        if (firstTime)
        {
            firstTime = false;
            random    = new Random();
        }

        target = new QPoint(200 + random.Next(190), 10 + random.Next(255));
        Update();
    }
Example #26
0
    public void newTarget()
    {
        if (firstTime)
        {
            firstTime = false;
            QTime midnight = new QTime(0,0,0);
            RandomClass = new Random();
        }

        target = new QPoint(200 + RandomClass.Next(190), 10 + RandomClass.Next(255));
        Update();
    }
Example #27
0
        public void TestPointSizeConstructor()
        {
            var p1 = new QPoint(50, 100);
            var p2 = new QSize(200, 150);

            var s = new QRect(p1, p2);

            Assert.AreEqual(50, s.Left);
            Assert.AreEqual(100, s.Top);
            Assert.AreEqual(200, s.Width);
            Assert.AreEqual(150, s.Height);
        }
Example #28
0
        public void TestContainsWithQPoint()
        {
            var s = new QRect();

            s.X      = 50;
            s.Y      = 150;
            s.Width  = 500;
            s.Height = 600;

            var p = new QPoint(275, 375);
            var n = s.Contains(p);

            Assert.IsTrue(n);
        }
Example #29
0
        public void TestSetPoints()
        {
            var s  = new QLine();
            var p1 = new QPoint(5, 5);
            var p2 = new QPoint(10, 10);

            s.SetPoints(p1, p2);

            Assert.AreEqual(5, s.P1.X);
            Assert.AreEqual(5, s.P1.Y);

            Assert.AreEqual(10, s.P2.X);
            Assert.AreEqual(10, s.P2.Y);
        }
Example #30
0
 public CannonField(QWidget parent) : base(parent)
 {
     currentAngle   = 45;
     currentForce   = 0;
     timerCount     = 0;
     autoShootTimer = new QTimer(this);
     Connect(autoShootTimer, SIGNAL("timeout()"), this, SLOT("moveShot()"));
     shootAngle         = 0;
     shootForce         = 0;
     target             = new QPoint(0, 0);
     Palette            = new QPalette(new QColor(250, 250, 200));
     AutoFillBackground = true;
     newTarget();
 }
Example #31
0
        public void TestContainsWithQPoint()
        {
            var s = new QRect();
            s.X = 50;
            s.Y = 150;
            s.Width = 500;
            s.Height = 600;

            var p = new QPoint(275, 375);
            var n = s.Contains(p);

            Assert.IsTrue(n);
        }
Example #32
0
        private void OnContextMenu(QListViewItem item, QPoint point, int col)
        {
            popupMenuItem = item;

            if (item is ClassItem) {
            ClassItem klass = (ClassItem)item;

            QPopupMenu menu = new QPopupMenu (this);

            menu.InsertItem ("Exclude from coverage", this, SLOT ("OnExclude()"));

            if (klass.Model.sourceFile != null)
                menu.InsertItem ("View Source", this, SLOT ("OnViewSource()"));

            menu.Exec (point);
            }
            else if (item is NamespaceItem) {
            QPopupMenu menu = new QPopupMenu (this);

            menu.InsertItem ("Exclude from coverage", this, SLOT ("OnExclude()"));
            menu.Exec (point);
            }
        }
Example #33
0
        public void TestPointSizeConstructor()
        {
            var p1 = new QPoint(50, 100);
            var p2 = new QSize(200, 150);

            var s = new QRect(p1, p2);

            Assert.AreEqual(50, s.Left);
            Assert.AreEqual(100, s.Top);
            Assert.AreEqual(200, s.Width);
            Assert.AreEqual(150, s.Height);
        }