Exemplo n.º 1
0
        private void BTPrint_Click(object sender, EventArgs e)
        {
            TBOutput.Clear();
            string type = "";

            switch (CBTypes.SelectedIndex)
            {
            case 0:
                type = "Животные";
                break;

            case 1:
                type = "Млекопитающие";
                break;

            case 2:
                type = "Птицы";
                break;

            case 3:
                type = "Парнокопытные";
                break;
            }

            FormPrinter printer = new FormPrinter();

            printer.PrintElThisType = this;
            сollection.PrintThisType(type, printer);
        }
Exemplo n.º 2
0
        private void BTShow_Click(object sender, EventArgs e)
        {
            TBOutput.Clear();
            int output = -1;

            switch (CBTypes.SelectedIndex)
            {
            case 0:
                TBOutput.Text += "Животных: ";
                output         = collection.GetAnimalNumber();
                break;

            case 1:
                TBOutput.Text += "Млекопитающих: ";
                output         = collection.GetMammalNumber();
                break;

            case 2:
                TBOutput.Text += "Птиц: ";
                output         = collection.GetBirdNumber();
                break;

            case 3:
                TBOutput.Text += "Парнокопытных: ";
                output         = collection.GetArtiodactylNumber();
                break;
            }
            TBOutput.Text += output.ToString();
        }
Exemplo n.º 3
0
        private void BTClone_Click(object sender, EventArgs e)
        {
            int    weight;
            string name;

            TBOutput.Clear();
            foreach (IAnimal animal in Part3.animals)
            {
                TBOutput.Text += "Клон ";
                object newAnimal = animal.Clone();

                if (newAnimal is Animal)
                {
                    Animal animal_ = animal as Animal;
                    weight = animal_.Weight;
                    name   = animal_.Name;

                    ShowInfo(weight, name);
                }
                if (newAnimal is Bird)
                {
                    Bird bird = newAnimal as Bird;

                    weight = bird.Weight;
                    name   = bird.Name;
                    bool flying   = bird.Flying;
                    bool domestic = bird.Domestic;

                    ShowInfo(weight, name, flying, domestic);
                    continue;
                }
                if (newAnimal is Mammal)
                {
                    Mammal mammal = newAnimal as Mammal;

                    weight = mammal.Weight;
                    name   = mammal.Name;
                    int incubationPeriod = mammal.IncubationPeriod;
                    int lifeExpectancy   = mammal.LifeExpectancy;

                    ShowInfo(weight, name, incubationPeriod, lifeExpectancy);
                    continue;
                }
                if (newAnimal is Artiodactyl)
                {
                    Artiodactyl artiodactyl = newAnimal as Artiodactyl;

                    weight = artiodactyl.Weight;
                    name   = artiodactyl.Name;
                    int    incubationPeriod = artiodactyl.IncubationPeriod;
                    int    lifeExpectancy   = artiodactyl.LifeExpectancy;
                    bool   hasHorns         = artiodactyl.HasHorns;
                    string habitat          = artiodactyl.Habitat;

                    ShowInfo(weight, name, incubationPeriod, lifeExpectancy, hasHorns, habitat);
                    continue;
                }
            }
        }
Exemplo n.º 4
0
 private void BTOutput_Click(object sender, EventArgs e)
 {
     TBOutput.Clear();
     foreach (IAnimal animal in Part3.animals)
     {
         Identify(animal);
     }
 }
Exemplo n.º 5
0
        private void BTSort_Click(object sender, EventArgs e)
        {
            TBOutput.Clear();
            string content = "Животные отсортированы по весу";
            string header  = "info";

            MessageBox.Show(content, header, MessageBoxButtons.OK, MessageBoxIcon.Information);
            Array.Sort(Part3.animals);
        }
Exemplo n.º 6
0
        private void ChangeState(State state)
        {
            switch (state)
            {
            case State.PleaseSelectFloder:
                TBState.Foreground   = new SolidColorBrush(FontColors.Plz);
                TBState.Text         = App.Current.Resources["mfPlzSelectLineFlashFloder"].ToString();
                BtnSelect.IsEnabled  = true;
                TBLoading.Visibility = Visibility.Hidden;
                break;

            case State.Ready:
                TBLoading.Visibility = Visibility.Hidden;
                BeginStoryboard((Storyboard)this.Resources["Step2Animation"]);
                BtnSelect.IsEnabled   = true;
                CBFlashType.IsEnabled = true;

                TBState.Foreground = new SolidColorBrush(FontColors.Ready);
                BtnMain.Content    = App.Current.Resources["btnStartMiFlash"];
                TBState.Text       = App.Current.Resources["mfReady"].ToString();
                break;

            case State.Flashing:
                BeginStoryboard((Storyboard)this.Resources["Step3Animation"]);
                BtnSelect.IsEnabled   = false;
                CBFlashType.IsEnabled = false;
                TBLoading.Visibility  = Visibility.Visible;
                TBOutput.Clear();

                TBState.Foreground = new SolidColorBrush(FontColors.Flashing);
                BtnMain.Content    = App.Current.Resources["btnStopMiFlash"];
                TBState.Text       = App.Current.Resources["mfFlashing"].ToString();
                break;

            case State.Successful:
                TBLoading.Visibility  = Visibility.Hidden;
                BtnSelect.IsEnabled   = true;
                CBFlashType.IsEnabled = true;

                TBState.Text       = App.Current.Resources["mfSuccess"].ToString();
                TBState.Foreground = new SolidColorBrush(FontColors.Success);
                BtnMain.Content    = App.Current.Resources["btnStartMiFlash"].ToString();
                break;

            case State.Fail:
                TBLoading.Visibility  = Visibility.Hidden;
                BtnSelect.IsEnabled   = true;
                CBFlashType.IsEnabled = true;

                TBState.Text       = App.Current.Resources["mfFail"].ToString();
                BtnMain.Content    = App.Current.Resources["btnStartMiFlash"].ToString();
                TBState.Foreground = new SolidColorBrush(FontColors.Fail);
                break;
            }
            _currentState = state;
        }
Exemplo n.º 7
0
        private async void BExecute_Click(object sender, EventArgs e)
        {
            TBOutput.Clear();

            String Url = TBUrl.Text;
            String AuthenticationToken = await _auth.GetBearerToken();

            Url = Url.Replace("{subscriptionId}", _subscriptionId);

            try
            {
                HttpClient ManagementClient = new HttpClient();
                ManagementClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AuthenticationToken);

                HttpResponseMessage Response;

                StringContent Content = null;

                if (TBInput.Enabled && String.IsNullOrWhiteSpace(TBInput.Text))
                {
                    Content = new StringContent(TBInput.Text.Trim(), Encoding.UTF8, "application/json");
                }

                switch (CBMethod.SelectedItem as String)
                {
                case "GET":
                    Response = await ManagementClient.GetAsync(Url);

                    break;

                case "PUT":
                    Response = await ManagementClient.PutAsync(Url, Content);

                    break;

                case "POST":
                    Response = await ManagementClient.PostAsync(Url, Content);

                    break;

                case "DELETE":
                    Response = await ManagementClient.DeleteAsync(Url);

                    break;

                default:
                    return;
                }

                StringBuilder OutputBuilder = new StringBuilder(500);

                if (Response.IsSuccessStatusCode)
                {
                    OutputBuilder.AppendLine("SUCCESS");
                }
                else
                {
                    OutputBuilder.AppendLine("FAILED");
                }

                OutputBuilder.AppendLine($"{Response.StatusCode}");

                if (Response.Content.Headers.ContentLength > 0)
                {
                    String ResponseContent = await Response.Content.ReadAsStringAsync();

                    OutputBuilder.AppendLine(ResponseContent);
                }

                TBOutput.Text = OutputBuilder.ToString();
            }
            catch (Exception exc)
            {
                TBOutput.Text = exc.ToString();
            }
        }