Пример #1
0
        public static List <PictureBoxInfo> Select() //Parametre Almaz Eğer Return Value Null!=İse İşlem Başarılı Denebilir.
        {
            SqlConnection         Connect   = new SqlConnection(defaultConnectionString);
            List <PictureBoxInfo> PassValue = new List <PictureBoxInfo>();

            if (Connect.State == ConnectionState.Closed)
            {
                Connect.Open();
                SqlCommand Cmd = new SqlCommand("SELECT * FROM Story", Connect);

                SqlDataReader reader = Cmd.ExecuteReader();
                while (reader.Read())
                {
                    PictureBoxInfo AddPB = new PictureBoxInfo();
                    AddPB.PB_BackColor      = (reader["Story_Color"].ToString());
                    AddPB.PB_Size           = new Size(140, 140);
                    AddPB.PB_Location       = new Point((int)reader["StoryLocationX"], (int)reader["StoryLocationY"]);
                    AddPB.Story_ID          = (int)reader["Story_ID"];
                    AddPB.Story_Task_Count  = (int)reader["Story_Task_Count"];
                    AddPB.Story_Description = (string)reader["Story_Description"];
                    AddPB.Story_Name        = (string)reader["Story_Name"];
                    AddPB.Story_AddDate     = (string)reader["Story_AddDate"];
                    AddPB.Story_Author      = (string)reader["Story_Author"];
                    PassValue.Add(AddPB);
                }
                reader.Close();
                Cmd.ExecuteNonQuery();
                Connect.Close();
                return(PassValue);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 设置PictureBox大小和位置
        /// </summary>
        public static void SetPictureBoxSize(ref System.Windows.Forms.PictureBox picBox, Size sz, Direction direction)
        {
            PictureBoxInfo info = null;
            foreach (var item in PictureBoxList)
            {
                if (item.Key == picBox)
                {
                    info = item.Value;
                }
            }
            if (info == null)
            {
                info = new PictureBoxInfo();
                info.Centre = new Point(picBox.Location.X + picBox.Width / 2, picBox.Location.Y + picBox.Height / 2);
                info.Location = picBox.Location;
                info.Size = picBox.Size;
                PictureBoxList.Add(picBox, info);
            }

            Size newSize = GetSizeWithRatio(info.Size, sz);

            picBox.Width = newSize.Width;
            picBox.Height = newSize.Height;

            switch (direction)
            {
                case Direction.Left:
                    picBox.Location = new Point(info.Location.X, info.Centre.Y - picBox.Height / 2);
                    break;
                case Direction.Right:
                    picBox.Location = new Point(info.Location.X + info.Size.Width - picBox.Width, info.Centre.Y - picBox.Height / 2);
                    break;
                case Direction.Centre:
                default:
                    picBox.Location = new Point(info.Centre.X - picBox.Width / 2, info.Centre.Y - picBox.Height / 2);
                    break;
            }
        }