예제 #1
0
        private void btDelete_Click(object sender, EventArgs e)
        {
            if (tempStaRect == null)
            {
                return;
            }

            String        query = "DELETE  FROM user WHERE pageName=@pageName AND (rectId=@rectId OR points=@point)";
            SQLiteCommand cmd   = new SQLiteCommand(query, cnn);

            cmd.Parameters.Add("@pageName", DbType.String);
            cmd.Parameters["@pageName"].Value = imageNames[activeImage];
            cmd.Parameters.Add("@rectId", DbType.Int16);
            cmd.Parameters["@rectId"].Value = tempStaRect.id;
            cmd.Parameters.Add("@point", DbType.String);
            int    x      = tempStaRect.Rectangle.X + tempStaRect.Rectangle.Width;
            int    y      = tempStaRect.Rectangle.Y - tempStaRect.Rectangle.Height;
            String points = tempStaRect.Rectangle.X.ToString() + "," + tempStaRect.Rectangle.Y.ToString() + ":" + tempStaRect.Rectangle.Width.ToString() + "," + tempStaRect.Rectangle.Height.ToString();

            cmd.Parameters["@point"].Value = points;
            int nested = cmd.ExecuteNonQuery();

            while (nested > 0)
            {
                starects.Remove(tempStaRect);
                nested--;
            }

            txtStatement.Text = "";
            tempStaRect       = null;
            staPanel.Hide();
            currentPanel.Refresh();
        }
예제 #2
0
        private void currentPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (editmode)
                {
                    currRectSaved = false;
                    currentPanel.Refresh();
                    using (Graphics g = currentPanel.CreateGraphics())
                    {
                        Rectangle rect = GetRectangle(mdown, e.Location);
                        g.DrawRectangle(Pens.Red, rect);
                    }
                    mup = e.Location;
                }

                i++;
            }

            if (!isAdding)
            {
                for (int i = 0; i < starects.Count; i++)
                {
                    if (starects[i].Rectangle.Contains(e.Location))
                    {
                        txtStatement.Text = starects[i].Statement;
                        tempStaRect       = starects[i];
                        this.Cursor       = questionMark;
                        if (editmode)
                        {
                            staPanel.Location = e.Location;
                        }
                        staPanel.Show();
                        return;
                    }
                }
            }

            //txtStatement.Text = "";
            if (editmode && !rubberbitti)
            {
                staPanel.Hide();
            }
            else if (!editmode)
            {
                staPanel.Hide();
            }

            tempStaRect = null;
            this.Cursor = Cursors.Default;
        }
예제 #3
0
        private void initializeStaRects()
        {
            String query = "SELECT* FROM user WHERE pageName=@pageName";

            SQLiteCommand cmd = new SQLiteCommand(query, cnn);

            cmd.Parameters.Add("@pageName", DbType.String);
            cmd.Parameters["@pageName"].Value = imageNames[activeImage];
            SQLiteDataReader reader = cmd.ExecuteReader();

            starects = new List <StaRect>();
            if (!reader.Read())
            {
                return;
            }


            do
            {
                String[] points = reader.GetValue(2).ToString().Split(':');

                int   x1    = Convert.ToInt32(points[0].Split(',')[0]);
                int   y1    = Convert.ToInt32(points[0].Split(',')[1]);
                Point first = new Point(x1, y1);

                int x2 = Convert.ToInt32(points[1].Split(',')[0]);

                int   y2     = Convert.ToInt32(points[1].Split(',')[1]);
                Point second = new Point(x2, y2);

                StaRect temp = new StaRect();
                temp.Rectangle = new Rectangle(x1, y1, x2, y2);

                temp.Statement = (String)reader.GetValue(3);
                temp.id        = Convert.ToInt32(reader.GetValue(1).ToString());
                starects.Add(temp);
            } while (reader.Read());
        }
예제 #4
0
        private void btSave_Click(object sender, EventArgs e)
        {
            String        query;
            SQLiteCommand cmd;



            if (starects.Contains(tempStaRect))
            {
                String pointss = tempStaRect.Rectangle.X.ToString() + "," + tempStaRect.Rectangle.Y.ToString() + ":" + tempStaRect.Rectangle.Width.ToString() + "," + tempStaRect.Rectangle.Height.ToString();
                tempStaRect.Statement = txtStatement.Text;
                query = "UPDATE user SET statement=@statement WHERE pageName=@activeImageName AND points=@point";
                cmd   = new SQLiteCommand(query, cnn);
                cmd.Parameters.Add("@activeImageName", DbType.String);
                cmd.Parameters.Add("@point", DbType.String);
                cmd.Parameters["@activeImageName"].Value = imageNames[activeImage];
                cmd.Parameters["@point"].Value           = pointss;
                cmd.Parameters.Add("@statement", DbType.AnsiString);
                cmd.Parameters["@statement"].Value = tempStaRect.Statement;
                cmd.ExecuteNonQuery();
                staPanel.Hide();
                return;
            }
            tempStaRect           = new StaRect();
            tempStaRect.Rectangle = currRect;
            tempStaRect.Statement = txtStatement.Text;



            currRectSaved     = false;
            txtStatement.Text = "";
            staPanel.Hide();

            String points = tempStaRect.Rectangle.X.ToString() + "," + tempStaRect.Rectangle.Y.ToString() + ":" + tempStaRect.Rectangle.Width.ToString() + "," + tempStaRect.Rectangle.Height.ToString();

            //save database
            try
            {
                query = "INSERT INTO user (pageName,points,statement) VALUES (@activeImageName,@point,@statement)";
                cmd   = new SQLiteCommand(query, cnn);
                cmd.Parameters.Add("@activeImageName", DbType.String);
                cmd.Parameters["@activeImageName"].Value = imageNames[activeImage];
                cmd.Parameters.Add("@point", DbType.String);

                cmd.Parameters["@point"].Value = points;
                cmd.Parameters.Add("@statement", DbType.AnsiString);
                cmd.Parameters["@statement"].Value = tempStaRect.Statement;
                cmd.ExecuteNonQuery();
            }
            catch (SQLiteException ex)
            {
                return;
            }



            query = "SELECT rectId FROM user WHERE pageName=@activeImageName AND points=@point";
            cmd   = new SQLiteCommand(query, cnn);
            cmd.Parameters.Add("@activeImageName", DbType.String);
            cmd.Parameters["@activeImageName"].Value = imageNames[activeImage];
            cmd.Parameters.Add("@point", DbType.String);
            cmd.Parameters["@point"].Value = points;
            SQLiteDataReader reader = cmd.ExecuteReader();

            reader.Read();


            starects.Add(tempStaRect);

            currRectSaved = true;
            rubberbitti   = false;
            isAdding      = false;

            currentPanel.Refresh();
        }