Пример #1
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();
        }
Пример #2
0
        private void StartFlash()
        {
            var args = new MiFlasherArgs()
            {
                DevBasicInfo = new DeviceBasicInfo()
                {
                    State  = DeviceState.Fastboot,
                    Serial = ShowInfo.Serial,
                },
                BatFileName = ((BatInfo)CBFlashType.SelectedItem).FullPath
            };

            _currentMiFlasher = new MiFlasher();
            _currentMiFlasher.Init(args);
            _currentMiFlasher.OutputReceived += (s, _e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    TBOutput.AppendText(_e.Text + "\n");
                    TBOutput.ScrollToEnd();
                });
            };
            _currentMiFlasher.Finished += (s, _e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    ChangeState(_e.Result.ResultType == Basic.FlowFramework.ResultType.Successful ? State.Successful : State.Fail);
                });
            };
            _currentMiFlasher.RunAsync();
            ChangeState(State.Flashing);
        }
Пример #3
0
        public PullingWindow(IFcuntionFlowBase _flow)
        {
            InitializeComponent();

            flow = _flow;
            flow.OutputReceived += (s, e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    TBOutput.AppendText(e.Text);
                    TBOutput.ScrollToEnd();
                });
            };
            flow.NoArgFinished += (s, e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    Close();
                });
            };
            if (flow.IsClosed)
            {
                throw new Exception("do not run flow!");
            }
            flow.MustTiggerAnyFinishedEvent = true;
        }
Пример #4
0
 public void loge <T>(T str)
 {
     TBOutput.AppendText(str + "\r\n");
     TBOutput.Visible = true;
     TBOutput.Select(TBOutput.Text.Length, 0);
     TBOutput.ScrollToCaret();
 }
Пример #5
0
        public void Write(string txt)
        {
            if (NextIsLineBeginning)
            {
                Data.Text += DateTime.Now.ToString("[dd.MM.yyyy - HH:mm:ss] ");
                this.NextIsLineBeginning = false;
            }


            Data.Text += txt;
            TBOutput.Dispatcher.Invoke(new Action(() =>
            {
                TBOutput.ScrollToEnd();
                TBOutput.ScrollToEnd();
            }));

            this.NextIsLineBeginning = txt.EndsWith("\n");


            /*
             * string[] lines = txt.Split('\n');
             *
             *
             *
             * string s = txt;
             * Data.Text += s;
             * TBOutput.Dispatcher.Invoke(new Action(()=>{
             *  TBOutput.ScrollToEnd();
             *  TBOutput.ScrollToEnd();
             * }));
             */
        }
Пример #6
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);
        }
Пример #7
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;
                }
            }
        }
Пример #8
0
 private void BTOutput_Click(object sender, EventArgs e)
 {
     TBOutput.Clear();
     foreach (IAnimal animal in Part3.animals)
     {
         Identify(animal);
     }
 }
Пример #9
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);
        }
Пример #10
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;
        }
Пример #11
0
 public RunningWindow()
 {
     InitializeComponent();
     ViewModel             = new VMRunningWindow(this);
     DataContext           = ViewModel;
     TBOutput.TextChanged += (s, e) =>
     {
         TBOutput.ScrollToEnd();
     };
 }
 public ApkInstallingWindow(ApkInstaller installer, List <FileInfo> files)
 {
     InitializeComponent();
     this.installer           = installer;
     _apkFilesCount           = files.Count;
     Owner                    = App.Current.MainWindow;
     TBCountOfInstalled.Text  = $"{_alreadyInstalledCount}/{_apkFilesCount}";
     this.installer.Finished += (s, e) =>
     {
         this.Dispatcher.Invoke(() =>
         {
             Close();
             new FlowResultWindow(e.Result).ShowDialog();
         });
     };
     this.installer.OutputReceived += (s, e) =>
     {
         this.Dispatcher.Invoke(() =>
         {
             var bytes = Encoding.Default.GetBytes(e.Text);
             TBOutput.AppendText(Encoding.UTF8.GetString(bytes) + "\n");
             TBOutput.ScrollToEnd();
         });
     };
     this.installer.AApkIstanlltionCompleted += (s, e) =>
     {
         this.Dispatcher.Invoke(() =>
         {
             ProgressAdd();
             if (!e.IsSuccess) //如果这次安装是失败的
             {                 //询问用户是否在安装失败的情况下继续
              //TODO
             }
         });
         return(true);
     };
 }
Пример #13
0
 private void TBOutput_TextChanged(object sender, TextChangedEventArgs e)
 {
     TBOutput.ScrollToEnd();
 }
Пример #14
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();
            }
        }
Пример #15
0
 private void ScrollToEnd()
 {
     TBOutput.SelectionStart = TBOutput.Text.Length;
     TBOutput.ScrollToCaret();
 }