Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            count_down         = 120; // 60 sekund na dzialanie inaczej wylogowanie
            count_down_started = count_down;


            Identyfikacji_okno = new Identyfikacja();


            try
            {
                Identyfikacji_okno.ShowDialog();

                if (MyIDentyf == "") // naprawic to gowno ... sprawdzanie zwracanej wartosci z zamykanego okna
                {
                    Identyfikacji_okno.End();
                    this.Close();
                    return;
                }
            }
            catch (Exception x)
            {
                System.Windows.MessageBox.Show(x.ToString());
            }

            if (MyIDentyf == "")
            {
                this.Close();
            }

            txtUser.Text     = MyIDentyf;
            imgtmpQR.Source  = QrGenerator.createQR(MyIDentyf, 100);
            imgtmpQR.ToolTip = MyIDentyf.ToString().ToUpper();
            ftp = new FTP();


            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);

            if (!Directory.Exists(@"C:\ProgramData\Garage"))
            {
                Directory.CreateDirectory(@"C:\ProgramData\Garage");
            }


            if (!dataBaseManager.DB_connection) //jezeli nie ma polaczenia z BD
            {
                //lblConnectionStatus.Content = "Brak połączenia z Bazą Danych";
            }
            else
            {
                // lblConnectionStatus.Content = "";
            }
            //string[] tmpItems = bindData.BindItems(dataBaseManager.DB_connection);
            // bindowanie z cmbItem

            //bindowanie listy jezyków
            cmbLeng.ItemsSource       = Jezyki.bindJezyki();
            cmbLeng.DisplayMemberPath = "Key";
            cmbLeng.SelectedValuePath = "Value";
            cmbLeng.SelectedIndex     = 1;
            Stringi = Jezyki.select(cmbLeng.Text.ToString());
            updateStrings();
            //-----------------------------------------

            //bindowanie Itemów


            //cmbItem.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            //cmbItem.AutoCompleteSource = AutoCompleteSource.ListItems;

            ItemsList           = bindData.BindItems(dataBaseManager.DB_connection);
            cmbItem.ItemsSource = ItemsList;


            //-----------------------------------------
            //bindowanie my items

            txtMyItems.Text = bindData.getTextForUI(dataBaseManager.CheckMyBorrowItems(MyIDentyf));

            //---------------------

            //bindowanie moich itemow do zwrotu
            cmbItemReturn.ItemsSource = bindData.bindItemToreturn(dataBaseManager.GetMyRentItemsNames());
            //---------------------------------
            Bind_AllAvailableItems();


            //DateTime dateTime = DateTime.UtcNow.Date;
            //var encoder = new PngBitmapEncoder();
            //encoder.Frames.Add(BitmapFrame.Create((BitmapSource)imgtmpQR.Source));
            //string path = Directory.GetCurrentDirectory();
            //using (FileStream stream = new FileStream($"{path}/{dateTime.ToShortDateString()}.jpg", FileMode.Create))
            //encoder.Save(stream);
            //---- wybieram na poczatek selection mode dla zwrotow i wypozyczen
            rbnSelectmode.IsChecked = false;
            rbnQRmode.IsChecked     = true;



            Timer_couter          = new DispatcherTimer();
            Timer_couter.Tick    += Timer_Counter;
            Timer_couter.Interval = new TimeSpan(0, 0, 1);
            Timer_couter.Start();



            if (!ftp.czyAktualnaversia())
            {
                btnUpdate.IsEnabled = true;
                btnUpdate.ToolTip   = ftp.checkVersionOnServer();
                try
                {
                    System.Windows.MessageBox.Show("update available");
                }
                catch (Exception x)
                {
                    System.Windows.MessageBox.Show("update available");
                }
            }
            else
            {
                try
                {
                    System.Windows.MessageBox.Show("");
                }
                catch (Exception x)
                {
                    Console.WriteLine("");
                }
            }
        }