Beispiel #1
0
        public static void addCompletedCircle(Circle circle)
        {
            completeCircles.Add(circle);

            string dbPath = GetDBPath();
            SQLiteConnection db;
            db = new SQLiteConnection(dbPath);
            db.Insert(circle);

            var result = db.Query<Line>("SELECT * FROM Lines");
            foreach (Line l in result) {
                Console.WriteLine("Line DB: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
            }
            var result2 = db.Query<Circle>("SELECT * FROM Circles");
            foreach (Circle c in result2) {
                Console.WriteLine("Circle DB: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
            }

            db.Close();
            db = null;

            foreach (Line l in completeLines) {
                Console.WriteLine("Line CL: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
            }
            foreach (Circle c in completeCircles) {
                Console.WriteLine("Circle CC: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
            }
        }
Beispiel #2
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            if (evt.TouchesForView(this).Count == 2 && linesInProcess.Count < 1) {
                bool firstTouch = true;
                Circle newCircle = new Circle();
                string key = "";
                foreach (UITouch t in touches) {
                    // Is this a double tap?
                    if (t.TapCount > 1) {
                        this.clearAll();
                        return;
                    }

                    // Create a circle for the value
                    CGPoint loc = t.LocationInView(this);

                    if (firstTouch) {
                        // Use the touch object (packed in an string, as the key)
                        key = NSValue.ValueFromNonretainedObject(t).ToString();
                        newCircle.center = loc;
                        firstTouch = false;
                    } else {
                        newCircle.point2 = loc;
                    }
                }
                newCircle.setColor();
                circlesInProcess.Add(key, newCircle);
            } else {
                foreach (UITouch t in touches) {
                    // Is this a double tap?
                    if (t.TapCount > 1) {
                        this.clearAll();
                        return;
                    }
                    // Use the touch object (packed in an string, as the key)
                    string key = NSValue.ValueFromNonretainedObject(t).ToString();

                    // Create a line for the value
                    CGPoint loc = t.LocationInView(this);
                    Line newLine = new Line();
                    newLine.begin = loc;
                    newLine.end = loc;

                    // Put pair in dictionary
                    newLine.setColor();
                    linesInProcess.Add(key, newLine);
                }
            }
            this.SetNeedsDisplay();
        }