Ejemplo n.º 1
0
        //private void LoadFormPosition()
        //{
        //    int allScreenWidth = 0;
        //    int allScreenHeight = 0;

        //    //Перебор всех мониторов
        //    for (int i = 0; i < Screen.AllScreens.Length; i++)
        //    {
        //        // + width монитора
        //        allScreenWidth += Screen.AllScreens[i].Bounds.Width;

        //        //Если height монитора > переменной, то присвоить
        //        if (Screen.AllScreens[i].Bounds.Height > allScreenHeight)
        //            allScreenHeight = Screen.AllScreens[i].Bounds.Height;
        //    }

        //    RegistryKey formPos = Registry.CurrentUser.CreateSubKey("SOFTWARE\\All in One");
        //    Location = new Point(Convert.ToInt32(formPos.GetValue("PositionX", Location.X)),
        //        Convert.ToInt32(formPos.GetValue("PositionY", Location.Y)));   //загрузить позицию формы из реестра
        //    formPos.Close();



        //    if ((Location.X < -500) || (Location.X > allScreenWidth) || (Location.Y < -500) || (Location.Y > allScreenHeight))
        //        Location = new Point(100, 100);
        //}

        private void LoadFormPosition()
        {
            //RegistryKey formPos = Registry.CurrentUser.CreateSubKey("SOFTWARE\\All in One");
            //Location = new Point(Convert.ToInt32(formPos.GetValue("PositionX", Location.X)),
            //    Convert.ToInt32(formPos.GetValue("PositionY", Location.Y)));   //загрузить позицию формы из реестра
            //formPos.Close();

            //Загрузить позицию формы из реестра
            Location = new Point(Convert.ToInt32(AiOMethods.LoadFromRegistry("PositionX", Location.X)),
                                 Convert.ToInt32(AiOMethods.LoadFromRegistry("PositionY", Location.Y)));

            var WidthScreenLocationForm =
                Screen.GetWorkingArea(Location).X == 0 ? Screen.GetBounds(Location).Width : Screen.GetWorkingArea(Location).X;
            var HeightScreenLocationForm = Screen.GetWorkingArea(Location).Height;

            //Если Location формы на дисплее с отрицательной рабочей областью
            if (WidthScreenLocationForm < 0)
            {
                if ((Location.X < WidthScreenLocationForm) || (Location.X > 0) || (Location.Y > HeightScreenLocationForm) || (Location.Y < 0))
                {
                    Location = new Point(100, 100);
                }
            }
            else
            {
                if ((Location.X < -100) || (Location.X > WidthScreenLocationForm) || (Location.Y > HeightScreenLocationForm) || (Location.Y < 0))
                {
                    Location = new Point(100, 100);
                }
            }
        }
Ejemplo n.º 2
0
        public void Form1_Load(object sender, EventArgs e)
        {
            CheckDBexist form = new CheckDBexist();

            if (File.Exists(AiOMethods.LoadFromRegistry("PathDB", "Data_DB.db").ToString()))
            {
                form.Close();
                Text += $" ({Environment.UserName})   - v.{AiOMethods.AiOVersion()}.alfa";

                LoadFormPosition(); //Загрузка координат формы

                FormCreate formCreate = new FormCreate(pnlTabs);
            }
            else
            {
                DialogResult result = MessageBox.Show
                                          ("Файл базы данных не найден.\nЖелаешь указать к нему путь или создать новый?", "Хде он?!?!?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    form.ShowDialog();
                    Close();
                }
                else
                {
                    MessageBox.Show("Ну и фиг с тобой :P", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }

            //registry.Close();
        }
Ejemplo n.º 3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            saveFileDialog.FileName = "ToDo_" + DateTime.Now.ToString().Replace(':', '-'); //Имя файла

            if (dgvList.Rows.Count <= 0)                                                   //Проверка на наличие строк в DGV
            {
                MessageBox.Show("Выгружать нечего", "Пусто", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (saveFileDialog.ShowDialog() == DialogResult.OK) //Проверка на нажатие ОК
            {
                AiOMethods.SaveExcel(dgvList, saveFileDialog.FileName);
            }
        }
Ejemplo n.º 4
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     UseDB.connectDB.Close(); //закрыть БД
     AiOMethods.SaveFormPosition(Location.X, Location.Y);
 }