Esempio n. 1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // loading position
            if (cfg.GetWindowPostition())
            {
                var position = cfg.WindowPostition();
                if (position.Top != 0 && position.Left != 0)
                {
                    WindowStartupLocation = WindowStartupLocation.Manual;
                    this.Top  = position.Top;
                    this.Left = position.Left;
                }
            }

            // loading switch settings
            swHander.IsEnabled   = App.IsAdministrator();
            swHander.IsChecked   = FileAssociation.IsDefault();
            swInstance.IsChecked = cfg.SingleInstance();
            swWindow.IsChecked   = cfg.GetWindowPostition();

            // open apk passes arg not null
            if (!string.IsNullOrWhiteSpace(pathApk))
            {
                txtPath.Text = pathApk;
            }

            // start pip server if in one single instance
            if (cfg.SingleInstance())
            {
                var server = new PipeServer(App.PIPENAMESERVER);
                server.OnMessageReceived += OnMessageReceived;
                server.StartListening();
            }
        }
Esempio n. 2
0
        private void SwitchSettings_Click(object sender, RoutedEventArgs e)
        {
            if (!(sender is ToggleSwitch ts))
            {
                return;
            }
            var tag       = ts.Tag as string;
            var isChecked = ts.IsChecked == true;

            if (tag == "Handler")
            {
                ts.IsChecked = FileAssociation.SetAsDefault(isChecked);
            }
            if (tag == "Instance")
            {
                cfg.SingleInstance(isChecked);
            }
            if (tag == "Window")
            {
                cfg.SetWindowPostition(isChecked);
            }
        }