Example #1
0
        private void Teacher_Click(object sender, RoutedEventArgs e)
        {
            Window2 win2 = new Window2();

            win2.Owner = this;
            win2.ShowDialog();
        }
Example #2
0
        //Open new contact window
        private void MenuItem_Click_3(object sender, RoutedEventArgs e)
        {
            var wnd = new Window2(data.Contacts, (ValidationRule)comboboxPhone.SelectedItem, (ValidationRule)comboboxEmail.SelectedItem, (ValidationRule)comboboxName.SelectedItem, (ValidationRule)comboboxSurname.SelectedItem);

            Opacity = 0.5;
            wnd.ShowDialog();
            Opacity = 1;
        }
Example #3
0
        private void Button_Click3(object sender, RoutedEventArgs e)
        {
            Window2 reg = new Window2();

            reg.ShowDialog();
            CurrentUser          = reg.user;
            Title                = "Cuurent User: " + CurrentUser.Name;
            Add_Button.IsEnabled = true;
            if (CurrentUser != null)
            {
                Reg_Button.IsEnabled = false;
            }
        }
Example #4
0
 private void acceptButton_Click2(object sender, RoutedEventArgs e)
 {
     if (otvet == "Лампочка")
     {
         Hide();
         Window2 Готово = new Window2();
         Готово.ShowDialog();
         Close();
     }
     else
     {
         Hide();
         Close();
     }
 }
Example #5
0
        private void buttonTreeView_Click(object sender, RoutedEventArgs e)
        {
            Window2 window = new Window2();

            window.ShowDialog();
        }
Example #6
0
        public void work(int i)
        {
            if (checkForInternetConnection())
            {
                if (tasktype == "find")
                {
                    WebClient site = new WebClient();
                    Uri       uriResult;
                    bool      result = Uri.TryCreate(this.url, UriKind.Absolute, out uriResult) &&
                                       (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
                    if (result)
                    {
                        string linkToImage = FindImage(site);
                        if (linkToImage == "")
                        {
                            errorStr = "image";
                            return;
                        }
                        if (responsetype == "saveas")
                        {
                            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                            dlg.FileName   = this.text;
                            dlg.DefaultExt = ".png";
                            dlg.Filter     = "Image (.png)|*.png";

                            Nullable <bool> resultBool = dlg.ShowDialog();

                            if (resultBool == true)
                            {
                                this.filename = dlg.FileName;
                            }
                            if (filename != "")
                            {
                                using (WebClient client = new WebClient())
                                {
                                    client.DownloadFile(linkToImage, this.filename);
                                }

                                errorStr = "complete";
                            }
                        }
                        this.filename = "meme" + i.ToString() + ".png";
                        if (responsetype == "mail")
                        {
                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(linkToImage, this.filename);
                            }
                            if (!SendMail(linkToImage))
                            {
                                errorStr = "address";
                            }
                        }
                        this.filename = "meme" + i.ToString() + ".png";
                        if (responsetype == "display")
                        {
                            Window2 win2         = new Window2();
                            var     image        = new Image();
                            var     fullFilePath = linkToImage;

                            BitmapImage bitmap = new BitmapImage();
                            bitmap.BeginInit();
                            bitmap.UriSource = new Uri(fullFilePath, UriKind.Absolute);
                            bitmap.EndInit();

                            image.Source = bitmap;

                            win2.canvas.Children.Add(image);

                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(linkToImage, this.filename);
                            }

                            win2.ShowDialog();

                            errorStr = "complete";
                        }
                    }
                }
                else if (tasktype == "weather")
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            string fullcityname = city[0].ToString().ToUpper() + city.Substring(1).ToLower();

                            city = fullcityname;

                            string weatherJson = client.DownloadString(findweather(city));
                            var    wth         = JsonConvert.DeserializeObject <jsonClass.RootObject>(weatherJson);

                            this.name  = wth.name;
                            this.temp  = wth.main.temp;
                            this.press = wth.main.pressure;
                            this.humid = wth.main.humidity;
                            this.desc  = wth.weather[0].description;
                            int tmpInd = weatherJson.IndexOf("\"icon\":\"");
                            this.wetid = weatherJson.Substring(tmpInd + "\"icon\":\"".Length, 3);
                        }
                        if (tempCase < this.temp)
                        {
                            if (responsetype == "mail")
                            {
                                if (!SendWeather())
                                {
                                    errorStr = "address";
                                }
                            }

                            else if (responsetype == "saveas")
                            {
                                string content = "Oto dzisiejsza pogoda w mieście: " + name + "\n" +
                                                 " Temperatura powietrza wynosi " + temp + " stopni.\n" +
                                                 "Ciśnienie wynosi " + press + " hektopaskali.\n" +
                                                 "Wilgotność powietrza na poziomie " + humid + ".\n" +
                                                 "Ogólnie pogodę można opisać słowami: " + desc + ".";
                                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                                dlg.FileName   = "pogoda";
                                dlg.DefaultExt = ".txt";
                                dlg.Filter     = "txt files (*.txt)|*.txt";

                                Nullable <bool> resultBool = dlg.ShowDialog();

                                if (resultBool == true)
                                {
                                    StreamWriter writer = new StreamWriter(dlg.OpenFile());
                                    writer.Write(content);
                                    writer.Dispose();
                                    writer.Close();
                                    this.filename = dlg.FileName;
                                }
                                errorStr = "complete";
                            }
                            else if (responsetype == "display")
                            {
                                string content = "Oto dzisiejsza pogoda w mieście: " + name + "\n" +
                                                 "Temperatura powietrza wynosi " + temp + " stopni.\n" +
                                                 "Ciśnienie wynosi " + press + " hektopaskali.\n" +
                                                 "Wilgotność powietrza na poziomie " + humid + ".\n" +
                                                 "Ogólnie pogodę można opisać słowami: " + desc + ".";
                                Window3 win3 = new Window3();
                                win3.label.Content = content;

                                var image = new Image();

                                var fullFilePath = @"http://openweathermap.org/img/w/" + this.wetid + ".png";
                                Console.WriteLine(this.wetid);

                                BitmapImage bitmap = new BitmapImage();
                                bitmap.BeginInit();
                                bitmap.UriSource = new Uri(fullFilePath, UriKind.Absolute);
                                bitmap.EndInit();

                                image.Source = bitmap;

                                win3.weatherIcon.Children.Add(image);

                                win3.ShowDialog();
                                errorStr = "complete";
                            }
                        }

                        else
                        {
                            errorStr = "temp";
                        }
                    }
                    catch (Exception ex)
                    {
                        errorStr = "weather";
                    }
                }
            }
            else
            {
                errorStr = "internet"; return;
            }
        }