Example #1
0
        private void timeStatusChanged(object sender, RoutedEventArgs e)
        {
            HorizontalToggleSwitch swits = sender as HorizontalToggleSwitch;
            RealTimeAMS            rtams = new RealTimeAMS();
            int status = swits.IsChecked ? 0 : 1;

            rtams.changetimeState(status);
        }
        private void SwitchCheck(object sender, RoutedEventArgs e)
        {
            HorizontalToggleSwitch switchButton = sender as HorizontalToggleSwitch;
            string switchName = switchButton.Name;

            if (switchName == "switch1")
            {
                Switch1Check = true;
            }
            if (switchName == "switch2")
            {
                Switch2Check = true;
            }
            if (switchName == "switch3")
            {
                Switch3Check = true;
            }
            if (switchName == "switch4")
            {
                Switch4Check = true;
            }
        }
Example #3
0
        public MainWindow()
        {
            this.DataContext = vm;
            InitializeComponent();

            int numPins = 20;

            // programmatically create the chart series so we don't copy-and-paste
            for (int i = 0; i < numPins; i++)
            {
                channelGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });


                var tb = new TextBlock()
                {
                    Text = i.ToString(), HorizontalAlignment = HorizontalAlignment.Left
                };
                TextOptions.SetTextFormattingMode(tb, TextFormattingMode.Ideal);
                var vb = new Viewbox()
                {
                    Width = 70, StretchDirection = StretchDirection.Both, Stretch = Stretch.Uniform
                };
                vb.Child = tb;

                var toggle = new HorizontalToggleSwitch()
                {
                };

                var toggleBinding = new Binding();
                toggleBinding.Source = DataContext;
                toggleBinding.Path   = new PropertyPath("ChannelEnabled[" + i + "]");
                toggleBinding.Mode   = BindingMode.TwoWay;

                BindingOperations.SetBinding(toggle, ToggleSwitchBase.IsCheckedProperty, toggleBinding);

                var sp = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                sp.Children.Add(vb);
                sp.Children.Add(toggle);

                channelGrid.Children.Add(sp);

                Grid.SetRow(sp, i);

                var row = new ChartRowDefinition();
                row.BorderThickness = 5;
                row.BorderStroke    = new SolidColorBrush(Color.FromArgb(0xff, 0x6C, 0x6C, 0x6C));
                chart.RowDefinitions.Add(row);

                var series = new FastLineSeries();

                var binding = new Binding();
                binding.Source = DataContext;
                binding.Path   = new PropertyPath("Data");
                binding.Mode   = BindingMode.OneWay;
                binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

                BindingOperations.SetBinding(series, ChartSeriesBase.ItemsSourceProperty, binding);


                series.XBindingPath = "TimestampOffset";
                series.YBindingPath = "Values[" + i + "]";
                var axis = new NumericalAxis();
                axis.TickLineSize  = 0;
                axis.LabelFormat   = " ";
                axis.ShowGridLines = false;
                axis.Minimum       = 0;
                axis.Maximum       = 3.3;
                axis.PlotOffset    = 10;
                series.YAxis       = axis;
                chart.Series.Add(series);
                ChartBase.SetRow(axis, numPins - 1 - i); // rows start from the bottom
            }

            channelGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(35, GridUnitType.Pixel)
            });
        }
Example #4
0
        private void databaseConnectionChange(object sender, RoutedEventArgs e)
        {
            HorizontalToggleSwitch hts = sender as HorizontalToggleSwitch;

            XDLINE.isOnline = hts.IsChecked;
        }
Example #5
0
 public static void toggleIsChecked(HorizontalToggleSwitch toggle, bool isChecked) => toggle.Dispatcher.BeginInvoke(new Action(() => { toggle.IsChecked = isChecked; }));
Example #6
0
        private async void handleToggleChange(object sender, RoutedEventArgs e)
        {
            try
            {
                HorizontalToggleSwitch currentToggle = (HorizontalToggleSwitch)sender;

                if (!_isInitialized)
                {
                    return;
                }

                if (Process.GetProcessesByName("Client").Length >= 1)
                {
                    peepoWtfText.Text = "You can't do that when Blade & Soul is already running!";
                    ((Storyboard)FindResource("animate")).Begin(ErrorPromptGrid);
                    return;
                }

                string sourceDirectory;
                string destinationDirectory;

                //Check if it is an individual class toggle
                if (systemToggles.Any(toggle => toggle.animToggle == currentToggle || toggle.fxToggle == currentToggle))
                {
                    string[]     upkfiles;
                    toggleStruct sysToggle;

                    if (currentToggle.Name.Contains("_fx_"))
                    {
                        sysToggle = systemToggles.Where(x => x.fxToggle.Name == currentToggle.Name).FirstOrDefault();
                        upkfiles  = SystemConfig.SYS.CLASSES.Where(x => x.CLASS == sysToggle.className).Select(upk => upk.EFFECTS).FirstOrDefault();
                    }
                    else
                    {
                        sysToggle = systemToggles.Where(x => x.animToggle.Name == currentToggle.Name).FirstOrDefault();
                        upkfiles  = SystemConfig.SYS.CLASSES.Where(x => x.CLASS == sysToggle.className).Select(upk => upk.ANIMATIONS).FirstOrDefault();
                    }

                    //We're restoring
                    if (currentToggle.IsChecked)
                    {
                        sourceDirectory      = backupLocation;
                        destinationDirectory = SystemConfig.SYS.BNS_DIR + @"\contents\bns\CookedPC\";
                    }
                    else
                    {
                        sourceDirectory      = SystemConfig.SYS.BNS_DIR + @"\contents\bns\CookedPC\";
                        destinationDirectory = backupLocation;
                    }

                    // _isInitialized = false;
                    if (upkfiles.Count() > 0)
                    {
                        foreach (string file in upkfiles)
                        {
                            try
                            {
                                //Move our target file to our new destination
                                if (File.Exists(sourceDirectory + file))
                                {
                                    if (!File.Exists(destinationDirectory + file))
                                    {
                                        File.Move(sourceDirectory + file, destinationDirectory + file);
                                    }
                                    else
                                    {
                                        File.Delete(sourceDirectory + file);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                //ProgressControl.updateProgressLabel(ex.Message);
                            }
                        }
                    }

                    //_isInitialized = true;
                    Dispatchers.labelContent(classLabel, String.Format("{0} {1}", sysToggle.className, (currentToggle.IsChecked) ? "Restored" : "Removed"));
                    ((Storyboard)FindResource("animate")).Begin(classLabel);
                    ((Storyboard)FindResource("animate")).Begin(successStatePicture);
                }
                else
                {
                    string[] upkFiles;
                    upkFiles = SystemConfig.SYS.MAIN_UPKS;

                    _progressControl = new ProgressControl();
                    MainWindow.mainWindowFrame.RemoveBackEntry();
                    ProgressGrid.Visibility = Visibility.Visible;
                    MainGrid.Visibility     = Visibility.Collapsed;

                    ProgressPanel.Children.Add(_progressControl);

                    //Turning whatever the f**k it is on
                    if (currentToggle.IsChecked)
                    {
                        ProgressControl.errorSadPeepo(Visibility.Hidden);
                        ProgressControl.updateProgressLabel("Restoring files");
                        await Task.Delay(150);

                        sourceDirectory      = backupLocation;
                        destinationDirectory = SystemConfig.SYS.BNS_DIR + @"\contents\bns\CookedPC\";
                    }
                    else
                    {
                        ProgressControl.errorSadPeepo(Visibility.Hidden);
                        ProgressControl.updateProgressLabel("Removing files");
                        await Task.Delay(150);

                        sourceDirectory      = SystemConfig.SYS.BNS_DIR + @"\contents\bns\CookedPC\";
                        destinationDirectory = backupLocation;
                    }

                    if (upkFiles.Count() > 0)
                    {
                        foreach (string file in upkFiles)
                        {
                            try
                            {
                                ProgressControl.updateProgressLabel(String.Format("Checking for {0}", file));
                                await Task.Delay(25);

                                //Move our target file to our new destination
                                if (File.Exists(sourceDirectory + file))
                                {
                                    ProgressControl.updateProgressLabel(String.Format("{0} {1}", (currentToggle.IsChecked) ? "Restoring" : "Removing", file));
                                    if (!File.Exists(destinationDirectory + file))
                                    {
                                        File.Move(sourceDirectory + file, destinationDirectory + file);
                                    }
                                    else
                                    {
                                        File.Delete(sourceDirectory + file);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                ProgressControl.updateProgressLabel(ex.Message);
                                await Task.Delay(500);
                            }
                            await Task.Delay(50);
                        }
                    }

                    ProgressGrid.Visibility = Visibility.Hidden;
                    MainGrid.Visibility     = Visibility.Visible;
                    ProgressPanel.Children.Clear();
                    _progressControl = null;
                }
            } catch (Exception ex)
            {
                var dialog = new ErrorPrompt("Something went wrong, \r\rAddition information: \r" + ex.Message);
                dialog.ShowDialog();
            }

            GC.WaitForPendingFinalizers();
        }