Пример #1
0
        /// <summary>
        /// The background worker run worker completed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false);
            MessageBox.Show("Congratulations! You have added a new Train into the Database");
            if (DataHelper.Train != null)
            {
                if (MessageBox.Show(
                        "Lets Confirm"
                        + $"\nTrain Number: {DataHelper.Train.TrainNumber}"
                        + $"\nTrain Name: {DataHelper.Train.TrainName}"
                        + $"\nTrain Type: {DataHelper.Train.Type}"
                        + $"\nSource Station: {DataHelper.Train.SourceStation}"
                        + $"\nDestination Station: {DataHelper.Train.DestinationStation}"
                        + $"\nRake Zone: {DataHelper.Train.RakeZone}",
                        "Confirm Message",
                        MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    MessageBox.Show("Ok... Data is not added");
                    return;
                }
            }

            if (DataHelper.Train != null)
            {
                DataHelper.Train.Route = this.routes.ToList();
            }

            this.Refresh();

            DataHelper.Accept = true;
        }
Пример #2
0
 private void StartPlayback()
 {
     Bass.ChannelSetPosition(fxStream, audioLength / 3); // start from second third of the track
     Bass.ChannelPlay(fxStream);
     playIcon.Kind = PackIconKind.Pause;
     ButtonProgressAssist.SetIsIndicatorVisible(playButton, true);
 }
Пример #3
0
        private void SendMail()
        {
            ButtonProgressAssist.SetIsIndicatorVisible(Send, true);

            ClientOptions clientOptions = Utils.ReadConfig();

            MailOptions mailOptions = new MailOptions
            {
                From    = From.Text.Trim(),
                To      = GetItems(To),
                Cc      = GetItems(Cc),
                Subject = Subject.Text.Trim(),
                Body    = Body.Text.Trim()
            };

            MailClient mailClient = new MailClient(clientOptions);

            mailClient.Sended += () =>
            {
                Utils.InvokeUIThread(() =>
                {
                    ButtonProgressAssist.SetIsIndicatorVisible(Send, false);
                    ShowMessage("Mail Sended!");
                });
            };
            mailClient.Send(mailOptions);
        }
Пример #4
0
 /// <summary>
 /// The background worker run worker completed.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ButtonProgressAssist.SetIsIndeterminate(this.ButtonRefresh, false);
     this.TextBlockWait.Visibility = Visibility.Collapsed;
     this.ButtonRefresh.IsEnabled  = true;
     MessageBox.Show("Data Updated Successfully!");
 }
Пример #5
0
        /// <summary>
        /// The button accept on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void ButtonAcceptOnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.TextBoxTteName.Text) ||
                string.IsNullOrWhiteSpace(this.TextBoxTteEmailId.Text) ||
                string.IsNullOrWhiteSpace(this.PasswordBoxTtePassword.Password) ||
                string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) ||
                string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text))
            {
                MessageBox.Show("Please fill up all the fields!");
                return;
            }

            if (!this.TextBoxTteName.Text.Contains(" "))
            {
                if (MessageBox.Show(
                        $"Is \"{this.TextBoxTteName.Text}\" Full Name of the TTE?",
                        "Confirmation of Full Name",
                        MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }
            }

            ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true);

            var tte = new Tte
            {
                Name     = this.TextBoxTteName.Text,
                EmailId  = this.TextBoxTteEmailId.Text,
                Password = this.PasswordBoxTtePassword.Password,
                Zone     = this.ComboBoxZoneName.Text,
                Division = this.ComboBoxDivisionName.Text
            };

            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += (o, args) =>
            {
                var task = this.AddTteAsync(tte);

                Task.WaitAll(task);
            };
            backgroundWorker.RunWorkerCompleted += (o, args) =>
            {
                MessageBox.Show("You have successfully added TTE" + $"\nName: {this.TextBoxTteName.Text}\nId: {this.tteId}");
                ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false);
            };

            try
            {
                backgroundWorker.RunWorkerAsync();
                this.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Пример #6
0
 private void btnDownload_Click(object sender, RoutedEventArgs e)
 {
     if (this.downloaderManager.Destination != null && Directory.Exists(this.downloaderManager.Destination))
     {
         ButtonProgressAssist.SetValue(this.btnDownload, 50);
         //this.btnDownload.IsEnabled = false;
         this.downloaderManager.Start();
     }
 }
Пример #7
0
        private void buttonOnClick(object sender, EventArgs e)
        {
            Button button = sender as Button;

            ButtonProgressAssist.SetIsIndicatorVisible(button, true);
            ButtonProgressAssist.SetIsIndeterminate(button, true);
            int i = (int)button.Tag;

            Debug.WriteLine(i + "-" + links[i]);
            downloadAndOpen(links[i], button);
        }
Пример #8
0
 private void checkActivateDownloadButton()
 {
     if (Directory.Exists(this.downloaderManager.Destination) && this.dgLinks.Items.Count > 0 && !this.downloaderManager.Completed)
     {
         this.btnDownload.IsEnabled = true;
         ButtonProgressAssist.SetIsIndicatorVisible(this.btnDownload, true);
     }
     else
     {
         btnDownload.IsEnabled = false;
         ButtonProgressAssist.SetIsIndicatorVisible(this.btnDownload, false);
     }
 }
Пример #9
0
        private static void OnProgressValueChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UserControl_ProgressButton button = d as UserControl_ProgressButton;
            ProgressType progressType         = (ProgressType)e.NewValue;

            switch (progressType)
            {
            case ProgressType.Ini:
                ButtonProgressAssist.SetValue(button.but, 0);
                button.packIcon.Kind = button.Kind;
                ButtonProgressAssist.SetIsIndicatorVisible(button.but, false);
                break;

            case ProgressType.Start:
                ButtonProgressAssist.SetValue(button.but, 0);
                ButtonProgressAssist.SetIsIndicatorVisible(button.but, true);
                button.packIcon.Kind = PackIconKind.Sync;
                new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.Normal, (s, ee) =>
                {
                    if (ButtonProgressAssist.GetValue(button.but) <= 50)
                    {
                        ButtonProgressAssist.SetValue(button.but, ButtonProgressAssist.GetValue(button.but) + 1);
                    }
                    else
                    {
                        ((DispatcherTimer)s).Stop();
                    }
                }, Dispatcher.CurrentDispatcher);
                break;

            case ProgressType.Done:
                new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.Normal, (s, ee) =>
                {
                    if (ButtonProgressAssist.GetValue(button.but) <= 100)
                    {
                        ButtonProgressAssist.SetValue(button.but, ButtonProgressAssist.GetValue(button.but) + 1);
                    }
                    else
                    {
                        ButtonProgressAssist.SetIsIndicatorVisible(button.but, false);
                        button.packIcon.Kind = PackIconKind.Check;
                        ((DispatcherTimer)s).Stop();
                    }
                }, Dispatcher.CurrentDispatcher);
                break;
            }
        }
Пример #10
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (progress != 100)
            {
                ButtonProgressAssist.SetValue(LoginButton, progress);
                progress += 1;
            }
            else
            {
                (sender as DispatcherTimer).Stop();
                Window3 wind = new Window3(foundUser);

                wind.Show();

                context.SaveChanges();
                this.Close();
            }
        }
Пример #11
0
        /// <summary>
        /// The tile refresh on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void ButtonRefreshOnClick(object sender, RoutedEventArgs e)
        {
            ButtonProgressAssist.SetIsIndeterminate(this.ButtonRefresh, true);
            this.TextBlockWait.Visibility = Visibility.Visible;
            this.ButtonRefresh.IsEnabled  = false;

            this.backgroundWorker                     = new BackgroundWorker();
            this.backgroundWorker.DoWork             += this.BackgroundWorkerDoWork;
            this.backgroundWorker.RunWorkerCompleted += this.BackgroundWorkerRunWorkerCompleted;

            try
            {
                this.backgroundWorker.RunWorkerAsync();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Пример #12
0
        /// <summary>
        /// The button accept on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void ButtonAcceptOnClick(object sender, RoutedEventArgs e)
        {
            if (DataHelper.Train != null)
            {
                if (this.routes.Count == 0)
                {
                    MessageBox.Show($"Please add routes for the Train {DataHelper.Train.TrainNumber}");
                    return;
                }

                if (this.routes.Any(r => r.StationCode == DataHelper.Train.SourceStation) == false)
                {
                    MessageBox.Show($"Please add a route details for Source Station {DataHelper.Train.SourceStation}");
                    return;
                }

                if (this.routes.Any(r => r.StationCode == DataHelper.Train.DestinationStation) == false)
                {
                    MessageBox.Show(
                        $"Please add a route details for Destination Station {DataHelper.Train.DestinationStation}");
                    return;
                }
            }

            ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true);

            if (DataHelper.Train != null)
            {
                DataHelper.Train.Route = this.routes.ToList();
            }

            this.backgroundWorker                     = new BackgroundWorker();
            this.backgroundWorker.DoWork             += this.BackgroundWorkerDoWork;
            this.backgroundWorker.RunWorkerCompleted += this.BackgroundWorkerRunWorkerCompleted;
            try
            {
                this.backgroundWorker.RunWorkerAsync();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Пример #13
0
        private async void  downloadAndOpen(string v, Button button)
        {
            var path = await v.DownloadFileAsync(AppDomain.CurrentDomain.BaseDirectory, "filed.torrent");

            ButtonProgressAssist.SetIsIndicatorVisible(button, false);
            ButtonProgressAssist.SetIsIndeterminate(button, false);
            Debug.WriteLine("Path : " + path);
            try
            {
                Process.Start(new ProcessStartInfo(path)
                {
                    UseShellExecute = true
                });
            }
            catch
            {
                Debug.WriteLine("Error");
                MessageBox.Show("Make sure any Torrent client is installed");
            }
        }
Пример #14
0
 private async void GlobalProgress(object sender, double progress)
 {
     this.btnDownload.Dispatcher.Invoke(() => ButtonProgressAssist.SetValue(this.btnDownload, progress), DispatcherPriority.Background);
     Debug.WriteLine("Global progress : " + progress);
 }
Пример #15
0
        private void btnImport_Click_1(object sender, RoutedEventArgs e)
        {
            ButtonProgressAssist.SetIsIndeterminate(btnImport, true);

            BancoInfo info = new BancoInfo();

            info.Instancia1    = lblInstancia.Text;
            info.NomeServidor1 = lblNomeServe.Text;

            Conexao conec = new Conexao(info);

            ImportacaoEnti   inserirEnti = new ImportacaoEnti(conec);
            ImportacaoProd   inserirProd = new ImportacaoProd(conec);
            ImportacaoDoc    inserirDoc  = new ImportacaoDoc(conec);
            ImportacaoFilial inserirFil  = new ImportacaoFilial(conec);
            ImportacaoEmp    inserirEmp  = new ImportacaoEmp(conec);
            ImportConsignado inserirCon  = new ImportConsignado(conec);

            checkEntidade.IsChecked = inserirEnti.ChecarEntidade();
            if (checkHiper.IsChecked == true)
            {
                try
                {
                    inserirEmp.InsertCME();
                    MessageBox.Show("Empresa Cadastrada");
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                if (checkFilial.IsChecked == true)
                {
                    try
                    {
                        inserirFil.InserFilial();
                    } catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                if (checkEntidade.IsChecked == true)
                {
                    try
                    {
                        inserirEnti.ImportPerf();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                if (checkProd.IsChecked == true)
                {
                    try
                    {
                        inserirProd.InserEnderec();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }

                if (checkDoc.IsChecked == true)
                {
                    try
                    {
                        inserirDoc.DocumentoDuplicado();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }

                if (checkCon.IsChecked == true)
                {
                    try
                    {
                        inserirCon.ImportarConsignado();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                if (checkCfop.IsChecked == true)
                {
                    inserirProd.UpdateCFOP();
                    try
                    {
                        inserirProd.InserCFOP();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }

                MessageBox.Show("Importação do Hiper Legado concluída");
            }
            ImportMiniEnti InserMiniEnti = new ImportMiniEnti(conec);
            ImportMiniProd InserMiniProd = new ImportMiniProd(conec);

            if (checkHiperMini.IsChecked == true)
            {
                if (checkMiniEnt.IsChecked == true)
                {
                    try
                    {
                        InserMiniEnti.InsertEnti();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                if (checkMiniProd.IsChecked == true)
                {
                    try
                    {
                        InserMiniProd.InsertMarca();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                if (checkMiniCFOP.IsChecked == true)
                {
                    InserMiniProd.UpdateMiniCFOP();
                    InserMiniProd.InserMiniCFOP();
                }

                MessageBox.Show("Importação do Hiper Mini Concluída");
            }
            ButtonProgressAssist.SetIsIndeterminate(btnImport, false);
        }
Пример #16
0
        private async void Button_OnClick(object sender, RoutedEventArgs e)
        {
            if (CurrentWork?.Result == ResultCodes.Success)
            {
                MainTransitioner.SelectedIndex = 3;
                Content.SelectedIndex          = 2;
                return;
            }

            var NextButton = (Button)sender;

            if (MainViewModel.Instance.Encoder == null)
            {
                MainTransitioner.SelectedIndex = 1;
                PeerDiscovery.DiscoverPeersAsync(PeerDiscovery.DiscoveryMethod.UDPBroadcast);
                return;
            }

            if (workFetched)
            {
                return;
            }
            workFetched = true;
            ButtonProgressAssist.SetIsIndicatorVisible(NextButton, true);
            ButtonProgressAssist.SetIsIndeterminate(NextButton, true);
            var work = await Client.GetNextWork();

            CurrentWork         = work;
            Student.DataContext = work.Student;
            ButtonProgressAssist.SetIsIndicatorVisible(NextButton, false);
            ButtonProgressAssist.SetIsIndeterminate(NextButton, false);
            //_encoderMagic.IsGenieOut = false;
            var errorMessage = "";

            switch (work.Result)
            {
            case ResultCodes.Success:
                WorkDataGrid.ItemsSource = work.ClassSchedules;
                //_workMagic.IsGenieOut = true;
                MainTransitioner.SelectedIndex = 3;
                Content.SelectedIndex          = 2;
                LoginLamp.Visibility           = Visibility.Collapsed;
                StudentId.Text   = work.StudentId;
                StudentName.Text = work.StudentName;
                break;

            case ResultCodes.NotFound:
                //MessageBox.Show("No more pending items.");
                errorMessage = "No more requests";
                break;

            case ResultCodes.Offline:
                errorMessage = "Can not find server";
                break;

            case ResultCodes.Timeout:
                errorMessage = "Request timeout";
                break;

            case ResultCodes.Error:
                errorMessage = "Request timeout";
                break;
            }


            await ShowMessage(errorMessage);


            workFetched = false;
        }
Пример #17
0
        /// <summary>
        /// The button accept on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void ButtonAcceptOnClick([CanBeNull] object sender, [CanBeNull] RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.ComboBoxZoneName.Text) ||
                string.IsNullOrWhiteSpace(this.ComboBoxDivisionName.Text) ||
                string.IsNullOrWhiteSpace(this.TextBoxStationCode.Text) ||
                string.IsNullOrWhiteSpace(this.TextBoxStationName.Text) ||
                string.IsNullOrWhiteSpace(this.TextBoxPinCode.Text))
            {
                MessageBox.Show("Please fill up all the fields!");
                return;
            }

            if (this.TextBoxPinCode.Text.Length < 6)
            {
                MessageBox.Show("Pin Code must have SIX digits!");
                return;
            }

            var s = MessageBox.Show(
                "Are you sure you want to continue? You cannot undo this operation",
                "Question",
                MessageBoxButton.YesNo);

            if (s == MessageBoxResult.No)
            {
                return;
            }

            ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true);

            var station = new Station
            {
                Zone            = this.ComboBoxZoneName.Text,
                RailwayDivision = this.ComboBoxDivisionName.Text,
                StationCode     = this.TextBoxStationCode.Text,
                StationName     = this.TextBoxStationName.Text,
                StationPinCode  = Convert.ToInt32(this.TextBoxPinCode.Text)
            };

            var backgroundWorker2 = new BackgroundWorker();

            backgroundWorker2.DoWork += (o, args) =>
            {
                var task = this.AddStationAsync(station);

                Task.WaitAll(task);
            };

            backgroundWorker2.RunWorkerCompleted += (o, args) =>
            {
                ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false);
                MessageBox.Show("Data Successfully added");
            };

            try
            {
                backgroundWorker2.RunWorkerAsync();
                this.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Пример #18
0
        /// <summary>
        /// The background worker do work.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private async void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(() => ButtonProgressAssist.SetIsIndeterminate(this.ButtonRefresh, true));

            #region Zone And Division

            var zoneAndDivisionModel =
                StaticDbContext.ConnectFireStore.GetCollectionFields <ZoneAndDivision>("Root", "Employee");

            DataHelper.ZoneAndDivisionModel = zoneAndDivisionModel;

            var jsonResult = JsonConvert.SerializeObject(zoneAndDivisionModel, Formatting.Indented);

            var zoneAndDivisionFile = Path.Combine(DataHelper.JsonFolderPath, Properties.Resources.ZoneAndDivisionJson);

            if (File.Exists(zoneAndDivisionFile))
            {
                File.Delete(zoneAndDivisionFile);
            }

            using (var streamWriter = new StreamWriter(zoneAndDivisionFile, true))
            {
                await streamWriter.WriteLineAsync(jsonResult).ConfigureAwait(false);

                streamWriter.Close();
            }

            #endregion

            #region Stations

            if (DataHelper.ZoneAndDivisionModel != null)
            {
                var stationsList = new StationsList {
                    Stations = new Dictionary <string, Station>()
                };

                foreach (var zone in DataHelper.ZoneAndDivisionModel.ZoneList)
                {
                    var collectionList = StaticDbContext.ConnectFireStore.GetCollections(
                        "Root",
                        "Stations",
                        "StationDetails",
                        zone);

                    foreach (var collectionReference in collectionList)
                    {
                        var stations = StaticDbContext.ConnectFireStore.GetAllDocumentData <Station>(
                            "Root",
                            "Stations",
                            "StationDetails",
                            zone,
                            collectionReference.Id);

                        foreach (var station in stations)
                        {
                            stationsList.Stations.Add(new KeyValuePair <string, Station>(station.StationCode, station));
                        }
                    }
                }

                DataHelper.StationsList = stationsList;

                var jsonResult2 = JsonConvert.SerializeObject(stationsList, Formatting.Indented);

                var stationsJson = Path.Combine(DataHelper.JsonFolderPath, Properties.Resources.StationsListJson);

                if (File.Exists(stationsJson))
                {
                    File.Delete(stationsJson);
                }

                using (var streamWriter = new StreamWriter(stationsJson, true))
                {
                    await streamWriter.WriteLineAsync(jsonResult2).ConfigureAwait(false);

                    streamWriter.Close();
                }
            }

            #endregion
        }
Пример #19
0
        private void CreateBTN_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true);
            btn.IsEnabled = false;
            bool allFine = true;

            MaxPlayersBox.Text = new String(MaxPlayersBox.Text.Where(Char.IsDigit).ToArray());
            if (MaxPlayersBox.Text.Length > 3)
            {
                MaxPlayersBox.Text = MaxPlayersBox.Text.Substring(0, 3);
            }
            if (String.IsNullOrEmpty(MaxPlayersBox.Text))
            {
                setError(MaxPlayersBox, "Field is required.");
                allFine = false;
            }
            else
            {
                int count = int.Parse(MaxPlayersBox.Text);
                if (count > 15)
                {
                    setError(MaxPlayersBox, "Can't be more than 15 players.");
                    allFine = false;
                }
                else if (count < 2)
                {
                    setError(MaxPlayersBox, "Can't be less than 2 players.");
                    allFine = false;
                }
                else
                {
                    Validation.ClearInvalid(MaxPlayersBox.GetBindingExpression(TextBox.TextProperty));
                }
            }
            QuestionsBox.Text = new String(QuestionsBox.Text.Where(Char.IsDigit).ToArray());
            if (QuestionsBox.Text.Length > 3)
            {
                QuestionsBox.Text = QuestionsBox.Text.Substring(0, 3);
            }
            if (String.IsNullOrEmpty(QuestionsBox.Text))
            {
                setError(QuestionsBox, "Field is required.");
                allFine = false;
            }
            else
            {
                int count = int.Parse(QuestionsBox.Text);
                if (count > 20)
                {
                    setError(QuestionsBox, "Can't be more than 20 questions.");
                    allFine = false;
                }
                else if (count < 2)
                {
                    setError(QuestionsBox, "Can't be less than 2 questions.");
                    allFine = false;
                }
                else
                {
                    Validation.ClearInvalid(QuestionsBox.GetBindingExpression(TextBox.TextProperty));
                }
            }
            SecondsBox.Text = new String(SecondsBox.Text.Where(Char.IsDigit).ToArray());
            if (SecondsBox.Text.Length > 3)
            {
                SecondsBox.Text = SecondsBox.Text.Substring(0, 3);
            }
            if (String.IsNullOrEmpty(SecondsBox.Text))
            {
                setError(SecondsBox, "Field is required.");
                allFine = false;
            }
            else
            {
                int count = int.Parse(SecondsBox.Text);
                if (count > 100)
                {
                    setError(SecondsBox, "Can't be more than 100 seconds.");
                    allFine = false;
                }
                else if (count < 10)
                {
                    setError(SecondsBox, "Can't be less than 10 seconds.");
                    allFine = false;
                }
                else
                {
                    Validation.ClearInvalid(SecondsBox.GetBindingExpression(TextBox.TextProperty));
                }
            }
            if (String.IsNullOrEmpty(RoomNameBox.Text))
            {
                setError(RoomNameBox, "Field is required.");
                allFine = false;
            }
            else
            {
                Validation.ClearInvalid(RoomNameBox.GetBindingExpression(TextBox.TextProperty));
            }
            if (allFine)
            {
                CreateRoomRequest createRoomRequest = new CreateRoomRequest();
                createRoomRequest.answerTimeout = int.Parse(SecondsBox.Text);
                createRoomRequest.maxUsers      = int.Parse(MaxPlayersBox.Text);
                createRoomRequest.questionCount = int.Parse(QuestionsBox.Text);
                createRoomRequest.roomName      = RoomNameBox.Text;
                app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(createRoomRequest, Constants.CREATE_ROOM_REQUEST_CODE)).ContinueWith(task =>
                {
                    ResponseInfo response = task.Result;
                    CreateRoomResponse createRoomResponse = JsonDeserializer.deserializeResponse <CreateRoomResponse>(response.buffer);
                    switch (createRoomResponse.status)
                    {
                    case Constants.CREATE_ROOM_SUCCESS:
                        MyMessageQueue.Enqueue("Room Created Successfully!");
                        this.Dispatcher.Invoke(() =>
                        {
                            app.admin            = true;
                            NavigationService ns = NavigationService.GetNavigationService(this);
                            ns.Navigate(new Uri("RoomLobby.xaml", UriKind.Relative));
                        });
                        break;

                    case Constants.CREATE_ROOM_MAXIMUM_ROOMS_IN_SERVER:
                        MyMessageQueue.Enqueue("Max rooms reached.\nTry again later.");
                        break;
                    }
                    this.Dispatcher.Invoke(() =>
                    {
                        ButtonProgressAssist.SetIsIndeterminate(btn, false);
                        ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                        btn.IsEnabled = true;
                    });
                });
            }
            else
            {
                ButtonProgressAssist.SetIsIndeterminate(btn, false);
                ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                btn.IsEnabled = true;
            }
        }
Пример #20
0
        public void UpdateControls()
        {
            Session s = SavedState.Data.CurrentSession;

            if (s == null)
            {
                return;
            }
            SessionType sType = SavedState.Data.SessionTypes.First(x => x.Id == s.TypeId);
            TimeSpan    timeRemaining;

            if (s.Paused)
            {
                iconPlayPause.Kind   = PackIconKind.PlayOutline;
                iconPlayPause.Margin = new Thickness(5, 0, 0, 0);
                timeRemaining        = sType.Time - s.TimeElapsed;
                btnPlayPause.ToolTip = "Start";
            }
            else
            {
                iconPlayPause.Kind   = PackIconKind.Pause;
                iconPlayPause.Margin = new Thickness(0);
                timeRemaining        = sType.Time - s.TimeElapsed - stopwatch.Elapsed;
                btnPlayPause.ToolTip = "Pause";
            }
            if (!sType.CountUp && timeRemaining.TotalSeconds < -5)
            {
                lblOvertime.Visibility = Visibility.Visible;
            }
            else
            {
                lblOvertime.Visibility = Visibility.Collapsed;
            }
            if (timeRemaining.TotalSeconds > 0)
            {
                lblTimerHour.Text   = ((int)Math.Floor(timeRemaining.TotalHours)).ToString("00");
                lblTimerMinute.Text = timeRemaining.Minutes.ToString("00");
                lblTimerSecond.Text = timeRemaining.Seconds.ToString("00");
                ButtonProgressAssist.SetMaximum(btnPlayPause, sType.Time.TotalSeconds);
                ButtonProgressAssist.SetValue(btnPlayPause, timeRemaining.TotalSeconds);
            }
            else if (timeRemaining.TotalSeconds < -5 || sType.CountUp)
            {
                timeRemaining       = -timeRemaining;
                lblTimerHour.Text   = ((int)Math.Floor(timeRemaining.TotalHours)).ToString("00");
                lblTimerMinute.Text = timeRemaining.Minutes.ToString("00");
                lblTimerSecond.Text = timeRemaining.Seconds.ToString("00");
                ButtonProgressAssist.SetMaximum(btnPlayPause, sType.Time.TotalSeconds);
                ButtonProgressAssist.SetValue(btnPlayPause, 0);
            }
            else
            {
                lblTimerHour.Text   = "00";
                lblTimerMinute.Text = "00";
                lblTimerSecond.Text = "00";
                ButtonProgressAssist.SetMaximum(btnPlayPause, 5);
                ButtonProgressAssist.SetValue(btnPlayPause, -timeRemaining.TotalSeconds);
            }
            if (lblTimerHour.Text == "00")
            {
                lblTimerHour.Opacity = 0.5;
                if (lblTimerMinute.Text == "00")
                {
                    lblTimerMinute.Opacity = 0.5;
                    if (lblTimerSecond.Text == "00")
                    {
                        lblTimerSecond.Opacity = 0.5;
                    }
                    else
                    {
                        lblTimerSecond.Opacity = 1;
                    }
                }
                else
                {
                    lblTimerMinute.Opacity = 1;
                    lblTimerSecond.Opacity = 1;
                }
            }
            else
            {
                lblTimerHour.Opacity   = 1;
                lblTimerMinute.Opacity = 1;
                lblTimerSecond.Opacity = 1;
            }
            lblColon1.Opacity   = lblTimerHour.Opacity;
            lblColon2.Opacity   = lblTimerMinute.Opacity;
            lblSessionName.Text = sType.Name;
        }
Пример #21
0
 /// <summary>
 /// The background worker run worker completed.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ButtonProgressAssist.SetIsIndeterminate(this.ButtonRefresh, false);
 }
Пример #22
0
 /// <summary>
 /// The background worker run worker completed.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     MessageBox.Show("You have successfully added Station Master" + $"\nName: {this.TextBoxStationMasterName.Text}\nId: {this.stationMasterId}");
     ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, false);
 }
Пример #23
0
        public HomeView()
        {
            InitializeComponent();

            this.WhenActivated(disposables =>
            {
                // Link and Start
                this.Bind(ViewModel,
                          viewModel => viewModel.Link,
                          view => view.linkTextBox.Text)
                .DisposeWith(disposables);

                linkTextBox.Events().KeyDown
                .Where(x => x.Key == Key.Enter)
                .Select(x => Unit.Default)
                .InvokeCommand(ViewModel !.StartDownloadCommand)           // Null forgiving reason: upstream limitation.
                .DisposeWith(disposables);

                this.OneWayBind(ViewModel,
                                viewModel => viewModel.BackendService.GlobalDownloadProgressPercentage,
                                view => view.downloadButton.Content,
                                percentage => percentage > 0.0 ? percentage.ToString("P1") : "_Download")
                .DisposeWith(disposables);

                // ButtonProgressAssist bindings
                ViewModel.WhenAnyValue(x => x.BackendInstance.IsRunning)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x =>
                {
                    ButtonProgressAssist.SetIsIndicatorVisible(downloadButton, x);
                    ButtonProgressAssist.SetIsIndicatorVisible(listFormatsButton, x);
                })
                .DisposeWith(disposables);

                ViewModel.WhenAnyValue(x => x.BackendService.ProgressState)
                .Select(x => x == TaskbarItemProgressState.Indeterminate)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x => ButtonProgressAssist.SetIsIndeterminate(downloadButton, x))
                .DisposeWith(disposables);

                ViewModel.WhenAnyValue(x => x.BackendService.GlobalDownloadProgressPercentage)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x => ButtonProgressAssist.SetValue(downloadButton, x * 100))
                .DisposeWith(disposables);

                ViewModel.WhenAnyValue(x => x.BackendService.ProgressState)
                .Select(x => x == TaskbarItemProgressState.Indeterminate)
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x => ButtonProgressAssist.SetIsIndeterminate(listFormatsButton, x))
                .DisposeWith(disposables);

                // presetComboBox
                this.OneWayBind(ViewModel,
                                viewModel => viewModel.Presets,
                                view => view.presetComboBox.ItemsSource)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.SelectedPreset,
                          view => view.presetComboBox.SelectedItem)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.SelectedPresetText,
                          view => view.presetComboBox.Text)
                .DisposeWith(disposables);

                // Subtitles
                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadSubtitles,
                          view => view.subtitlesDefaultCheckBox.IsChecked)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadSubtitlesAllLanguages,
                          view => view.subtitlesAllLanguagesCheckBox.IsChecked)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadAutoGeneratedSubtitles,
                          view => view.subtitlesAutoGeneratedCheckBox.IsChecked)
                .DisposeWith(disposables);

                // Options row 1
                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.AddMetadata,
                          view => view.metadataToggle.IsChecked)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadThumbnail,
                          view => view.thumbnailToggle.IsChecked)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadPlaylist,
                          view => view.playlistToggle.IsChecked)
                .DisposeWith(disposables);

                // Options row 2
                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.UseCustomOutputTemplate,
                          view => view.filenameTemplateToggle.IsChecked)
                .DisposeWith(disposables);

                this.OneWayBind(ViewModel,
                                viewModel => viewModel.SharedSettings.UseCustomOutputTemplate,
                                view => view.filenameTemplateTextBox.IsEnabled)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.CustomOutputTemplate,
                          view => view.filenameTemplateTextBox.Text)
                .DisposeWith(disposables);

                // Options row 3
                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.UseCustomPath,
                          view => view.pathToggle.IsChecked)
                .DisposeWith(disposables);

                this.OneWayBind(ViewModel,
                                viewModel => viewModel.SharedSettings.UseCustomPath,
                                view => view.pathComboBox.IsEnabled)
                .DisposeWith(disposables);

                this.OneWayBind(ViewModel,
                                viewModel => viewModel.DownloadPathHistory,
                                view => view.pathComboBox.ItemsSource)
                .DisposeWith(disposables);

                this.Bind(ViewModel,
                          viewModel => viewModel.SharedSettings.DownloadPath,
                          view => view.pathComboBox.Text)
                .DisposeWith(disposables);

                // Arguments
                this.OneWayBind(ViewModel,
                                viewModel => viewModel.DownloadArguments,
                                view => view.argumentsItemsControl.ItemsSource)
                .DisposeWith(disposables);

                // Output
                this.Bind(ViewModel,
                          viewModel => viewModel.QueuedTextBoxSink.Content,
                          view => view.resultTextBox.Text)
                .DisposeWith(disposables);

                resultTextBox.Events().TextChanged
                .Where(_ => WpfHelper.IsScrolledToEnd(resultTextBox))
                .Subscribe(_ => resultTextBox.ScrollToEnd())
                .DisposeWith(disposables);

                // Download, list, abort button
                this.BindCommand(ViewModel,
                                 viewModel => viewModel.StartDownloadCommand,
                                 view => view.downloadButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.ListFormatsCommand,
                                 view => view.listFormatsButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.AbortDlCommand,
                                 view => view.abortButton)
                .DisposeWith(disposables);

                // Browse and open folder button
                this.BindCommand(ViewModel,
                                 viewModel => viewModel.BrowseDownloadFolderCommand,
                                 view => view.browseButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.OpenDownloadFolderCommand,
                                 view => view.openFolderButton)
                .DisposeWith(disposables);

                // Reset custom filename template button
                this.BindCommand(ViewModel,
                                 viewModel => viewModel.ResetCustomFilenameTemplateCommand,
                                 view => view.resetFilenameTemplateButton)
                .DisposeWith(disposables);

                // Custom preset buttons
                this.BindCommand(ViewModel,
                                 viewModel => viewModel.OpenAddCustomPresetDialogCommand,
                                 view => view.addPresetButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.OpenEditCustomPresetDialogCommand,
                                 view => view.editPresetButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.DuplicatePresetCommand,
                                 view => view.duplicatePresetButton)
                .DisposeWith(disposables);

                this.BindCommand(ViewModel,
                                 viewModel => viewModel.DeleteCustomPresetCommand,
                                 view => view.deletePresetButton)
                .DisposeWith(disposables);
            });
        }
Пример #24
0
        /// <summary>
        /// The background worker do work.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private async void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            var stationMasterName = string.Empty;
            var zone     = string.Empty;
            var division = string.Empty;

            this.Dispatcher.Invoke(
                () =>
            {
                ButtonProgressAssist.SetIsIndicatorVisible(this.ButtonAccept, true);
                stationMasterName = this.TextBoxStationMasterName.Text;
                zone     = this.ComboBoxZoneName.Text;
                division = this.ComboBoxDivisionName.Text;
            },
                DispatcherPriority.Normal);

            var id = StaticDbContext.ConnectFireStore.GetAllDocumentId(
                "Root",
                "Employee",
                zone,
                division,
                "StationMaster");

            var max = 0;

            if (id.Count != 0)
            {
                max = Convert.ToInt32(id.OrderByDescending(i => int.Parse(i.Substring(8))).First().Substring(8));
            }

            this.stationMasterId = $"{(int)EnumEmployeeGroups.GroupB:D2}" +
                                   $"{(int)EnumEmployeeType.StationMaster:D2}" +
                                   $"{DataHelper.ZoneAndDivisionModel.ZoneList.IndexOf(zone):D2}" +
                                   $"{DataHelper.ZoneAndDivisionModel.DivisionList[zone].IndexOf(division):D2}" +
                                   $"{(max + 1):D7}";

            var stationMaster = new StationMaster
            {
                Name = stationMasterName,
                Id   = this.stationMasterId
            };

            var noOfStationMaster = 0;

            var divisionField =
                StaticDbContext.ConnectFireStore.GetCollectionFields("Root", "Employee", zone, division);

            if (divisionField != null)
            {
                noOfStationMaster = Convert.ToInt32(divisionField["noOfStationMaster"]);
            }

            noOfStationMaster++;

            await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync(
                new Dictionary <string, int> {
                { "noOfStationMaster", noOfStationMaster }
            },
                "Root",
                "Employee",
                zone,
                division);

            await StaticDbContext.ConnectFireStore.AddOrUpdateCollectionDataAsync(
                stationMaster,
                "Root",
                "Employee",
                zone,
                division,
                "StationMaster",
                stationMaster.Id);
        }
Пример #25
0
        private void LoginBTN_Clicked(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, true);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetValue(btn, -1);
            MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, true);
            btn.IsEnabled       = false;
            SignupBTN.IsEnabled = false;
            bool EverythingFine = true;

            if (String.IsNullOrEmpty(UsernameBox.Text))
            {
                UsernameBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), UsernameBox.GetBindingExpression(TextBox.TextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    UsernameBox.GetBindingExpression(TextBox.TextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(UsernameBox.GetBindingExpression(TextBox.TextProperty));
            }
            if (String.IsNullOrEmpty(PasswordBox.Password))
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "Field is required.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else if (PasswordBox.Password.Length < 1)
            {
                PasswordBox.GetBindingExpression(TextBox.TextProperty);
                ValidationError validationError = new ValidationError(new NotEmptyValidationRule(), PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
                validationError.ErrorContent = "At least 8 characters.";

                Validation.MarkInvalid(
                    PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty),
                    validationError);
                EverythingFine = false;
            }
            else
            {
                Validation.ClearInvalid(PasswordBox.GetBindingExpression(PasswordBox.DataContextProperty));
            }
            if (EverythingFine)
            {
                LoginRequest loginRequest = new LoginRequest();
                loginRequest.username = UsernameBox.Text;
                loginRequest.password = PasswordBox.Password;

                app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(loginRequest, Constants.LOGIN_REQUEST_CODE)).ContinueWith(task =>
                {
                    ResponseInfo response       = task.Result;
                    LoginResponse loginResponse = JsonDeserializer.deserializeResponse <LoginResponse>(response.buffer);
                    switch (loginResponse.status)
                    {
                    case Constants.LOGIN_SUCCESS:
                        MyMessageQueue.Enqueue("Sign in Successfully!");
                        this.Dispatcher.Invoke(() =>
                        {
                            app.username         = UsernameBox.Text;
                            NavigationService ns = NavigationService.GetNavigationService(this);
                            ns.Navigate(new Uri("Menu.xaml", UriKind.Relative));
                        });
                        break;

                    case Constants.LOGIN_INCORRECT_PASSWORD:
                        MyMessageQueue.Enqueue("Incorrect password.");
                        break;

                    case Constants.LOGIN_USERNAME_NOT_EXIST:
                        MyMessageQueue.Enqueue("Username not exist.");
                        break;

                    case Constants.LOGIN_UNEXPECTED_ERR:
                        MyMessageQueue.Enqueue("There was an unexpected error.");
                        break;

                    case Constants.LOGIN_ALREADY_ONLINE:
                        MyMessageQueue.Enqueue("This Username is already online.");
                        break;
                    }
                    this.Dispatcher.Invoke(() =>
                    {
                        ButtonProgressAssist.SetIsIndeterminate(btn, false);
                        ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                        btn.IsEnabled       = true;
                        SignupBTN.IsEnabled = true;
                    });
                });
            }
            else
            {
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndeterminate(btn, false);
                MaterialDesignThemes.Wpf.ButtonProgressAssist.SetIsIndicatorVisible(btn, false);
                btn.IsEnabled       = true;
                SignupBTN.IsEnabled = true;
            }
        }
Пример #26
0
        private async void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            if (ImageConverter.IsLoaded)
            {
                ExportButton.IsEnabled      = false;
                Options.IsEnabled           = false;
                BrowsImageButton.IsEnabled  = false;
                BrowsFolderButton.IsEnabled = false;
                ButtonProgressAssist.SetValue(ExportButton, 0);
                int        coord     = CoordinateAxis.SelectedIndex;
                int        verAlig   = VerticalAlignmentBox.SelectedIndex;
                int        horAlig   = HorizontalAlignmentBox.SelectedIndex;
                Particle[] particles = ImageConverter.GetParticles(coord, verAlig, horAlig);
                ButtonProgressAssist.SetMaximum(ExportButton, particles.Length + 20);
                ButtonProgressAssist.SetValue(ExportButton, 20);
                ExportButton.UpdateLayout();
                string       fileName = System.IO.Path.GetFileNameWithoutExtension(FilePathBox.Text);
                string       filePath = FolderPathBox.Text + "\\" + fileName.ToLower() + ".mcfunction";
                Encoding     enc      = new System.Text.UTF8Encoding();;
                StreamWriter writer   = null;
                try
                {
                    string cs = "~";
                    switch (((ComboBoxItem)CoordinateModeBox.SelectedItem).Tag)
                    {
                    case "Relative":
                        cs = "~";
                        break;

                    case "Local":
                        cs = "^";
                        break;
                    }
                    if (!Directory.Exists(System.IO.Path.GetDirectoryName(filePath)))
                    {
                        Directory.CreateDirectory(System.IO.Path.GetDirectoryName(filePath));
                    }
                    var fullname = typeof(App).Assembly.Location;
                    var info     = FileVersionInfo.GetVersionInfo(fullname);
                    var ver      = info.FileVersion;
                    writer = new StreamWriter(filePath, false, enc);
                    writer.WriteLine($"### Particle Image Function");
                    writer.WriteLine($"### Version: {ver}");
                    writer.WriteLine($"### Width: {ImageConverter.ResizedWidth}");
                    writer.WriteLine($"### Height: {ImageConverter.ResizedHeight}");
                    writer.WriteLine($"### ParticleType: {ParticleTypeBox.SelectedValue}");
                    writer.WriteLine($"");
                    writer.WriteLine($"### This file was generated by Kemo431's Particle-Converter.");
                    writer.WriteLine($"### Download Link: https://github.com/kemo14331/Particle-Converter");
                    writer.WriteLine($"");
                    for (int i = 0; i < particles.Length; i++)
                    {
                        var    p        = particles[i];
                        string axis     = $"{cs}{Math.Round(p.x, 7).ToString("R", format)} {cs}{Math.Round(p.y, 7).ToString("R", format)} {cs}{Math.Round(p.z, 7).ToString("R", format)}";
                        string particle = "minecraft:" + ParticleTypeBox.Text;
                        if (ParticleTypeBox.SelectedValue.Equals("dust"))
                        {
                            if (UseStaticDustColor.IsChecked.Value)
                            {
                                Color color = (Color)ColorConverter.ConvertFromString(ColorCodeBox.Text);
                                particle += $" {Math.Round(color.R / 255.0d, 2).ToString("R", format)} {Math.Round(color.G / 255.0d, 2).ToString("R", format)} {Math.Round(color.B / 255.0d, 2).ToString("R", format)} {double.Parse(ParticleSizeBox.Text).ToString("R", format)}";
                            }
                            else
                            {
                                particle += $" {Math.Round(p.r / 255.0d, 2).ToString("R", format)} {Math.Round(p.g / 255.0d, 2).ToString("R", format)} {Math.Round(p.b / 255.0d, 2).ToString("R", format)} {double.Parse(ParticleSizeBox.Text).ToString("R", format)}";
                            }
                        }
                        string particleString = $"particle {particle} {axis} 0 0 0 0 1 {((ComboBoxItem)DisplayModeBox.SelectedItem).Tag} {ParticleViewerBox.Text}";
                        await Task.Run(() =>
                        {
                            writer.WriteLine(particleString);
                        });

                        ButtonProgressAssist.SetValue(ExportButton, 20 + 1 + i);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("ファイルの書き込みに失敗しました\nFailed to export a file.",
                                    "エラー/Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    Logger.WriteExceptionLog(exc);
                }
                finally
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
                ButtonProgressAssist.SetValue(ExportButton, 0);
                Options.IsEnabled           = true;
                ExportButton.IsEnabled      = true;
                BrowsImageButton.IsEnabled  = true;
                BrowsFolderButton.IsEnabled = true;
                SystemSounds.Beep.Play();
            }
            else
            {
                SystemSounds.Beep.Play();
            }
        }
Пример #27
0
 private void StopPlayback()
 {
     Bass.ChannelStop(fxStream);
     playIcon.Kind = PackIconKind.Play;
     ButtonProgressAssist.SetIsIndicatorVisible(playButton, false);
 }
 private void ToggleBusyIndicator(bool isBusy)
 {
     hasPendingTask = isBusy;
     ButtonProgressAssist.SetIsIndicatorVisible(SaveButton, isBusy);
 }