Beispiel #1
0
        public XtermTerminalView()
        {
            InitializeComponent();
            StartMediatorTask();

            _webView = new WebView(WebViewExecutionMode.SeparateThread)
            {
                DefaultBackgroundColor = Colors.Transparent
            };
            Root.Children.Add(_webView);

            _webView.NavigationCompleted += _webView_NavigationCompleted;
            _webView.NavigationStarting  += _webView_NavigationStarting;
            _webView.NewWindowRequested  += _webView_NewWindowRequested;

            _copyMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Copy")
            };
            _copyMenuItem.Click += Copy_Click;

            _pasteMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Paste")
            };
            _pasteMenuItem.Click += Paste_Click;

            _webView.ContextFlyout = new MenuFlyout
            {
                Items = { _copyMenuItem, _pasteMenuItem }
            };

            _optionsChanged = new DebouncedAction <TerminalOptions>(Dispatcher, TimeSpan.FromMilliseconds(800), async options =>
            {
                var serialized = JsonConvert.SerializeObject(options);
                await ExecuteScriptAsync($"changeOptions('{serialized}')");
            });

            // _sizedChanged is used to debounce terminal resize events to
            // avoid spamming the terminal with them (this can result in
            // buffer corruption).
            _sizeChanged = new DebouncedAction <TerminalSize>(Dispatcher, TimeSpan.FromMilliseconds(1000), async size => {
                await ViewModel.Terminal.SetSize(size).ConfigureAwait(true);

                // Allow output to the terminal soon (hopefully, once the resize event has been processed).
                _unblockOutput.Invoke(true);
            });

            _outputBlockedBuffer = new MemoryStream();
            _outputBlocked       = new ManualResetEventSlim();

            // _unblockOutput allows output to the terminal again, 500ms after it invoked.
            _unblockOutput = new DebouncedAction <bool>(Dispatcher, TimeSpan.FromMilliseconds(500), x => {
                _outputBlocked.Reset();
            });


            _navigationCompleted = new SemaphoreSlim(0, 1);
            _connectedEvent      = new ManualResetEventSlim(false);

            _webView.Navigate(new Uri("ms-appx-web:///Client/index.html"));
        }
 public MainWindow()
 {
     InitializeComponent();
     throttler         = Throttler.Throttle <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(throttled, now)), TimeSpan.FromSeconds(1));
     debouncerTrailing = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedTrailing, now)), TimeSpan.FromSeconds(1), false, true);
     debouncerLeading  = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedLeading, now)), TimeSpan.FromSeconds(1), true, false);
     debouncerBoth     = Debouncer.Debounce <string>(now => Dispatcher.Invoke(() => UpdateLabelContent(debouncedBoth, now)), TimeSpan.FromSeconds(1), true, true);
 }
        public XtermTerminalView()
        {
            InitializeComponent();
            StartMediatorTask();

            _webView = new WebView(WebViewExecutionMode.SeparateThread)
            {
                DefaultBackgroundColor = Colors.Transparent
            };
            Root.Children.Add(_webView);

            _webView.NavigationCompleted += _webView_NavigationCompleted;
            _webView.NavigationStarting  += _webView_NavigationStarting;

            _copyMenuItem = new MenuFlyoutItem {
                Text = "Copy"
            };
            _copyMenuItem.Click += Copy_Click;

            _pasteMenuItem = new MenuFlyoutItem {
                Text = "Paste"
            };
            _pasteMenuItem.Click += Paste_Click;

            _webView.ContextFlyout = new MenuFlyout
            {
                Items = { _copyMenuItem, _pasteMenuItem }
            };

            JsonConvert.DefaultSettings = () =>
            {
                var settings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver(),
                };
                settings.Converters.Add(new StringEnumConverter(typeof(CamelCaseNamingStrategy)));

                return(settings);
            };

            _optionsChanged = new DebouncedAction <TerminalOptions>(Dispatcher, TimeSpan.FromMilliseconds(800), async options =>
            {
                var serialized = JsonConvert.SerializeObject(options);
                await ExecuteScriptAsync($"changeOptions('{serialized}')");
            });

            _navigationCompleted = new SemaphoreSlim(0, 1);
            _connectedEvent      = new SemaphoreSlim(0, 1);

            _webView.Navigate(new Uri("ms-appx-web:///Client/index.html"));
        }
        internal void startGuarding()
        {
            fixSubscriptions();

            DebouncedAction onSubscriptionFileChanged = Debouncer.Debounce(() => {
                Console.WriteLine("\nChange detected, fixing subscriptions...");
                fixSubscriptions();
            }, TimeSpan.FromMilliseconds(50));

            subscriptionConfigurationFileWatcher.Changed += delegate { onSubscriptionFileChanged.Run(); };
            folderWatcher.Created += delegate { onSubscriptionFileChanged.Run(); };
            folderWatcher.Renamed += delegate { onSubscriptionFileChanged.Run(); };

            subscriptionConfigurationFileWatcher.EnableRaisingEvents = true;
            folderWatcher.EnableRaisingEvents = true;

            Console.WriteLine("Waiting for subscription changes...");
        }
Beispiel #5
0
        public GitExtensionsHandlerImpl(WindowOpeningListener windowOpeningListener)
        {
            _onWindowClosedThrottled = Throttler.Throttle((bool firstRun) =>
                                                          onWindowClosed(firstRun), TimeSpan.FromSeconds(2));

            timer = new Timer {
                AutoReset = true,
                Interval  = 200
            };

            timer.Elapsed += findCommitWindows;

            windowOpeningListener.windowOpened += onWindowOpened;
            Automation.AddAutomationEventHandler(WindowPattern.WindowClosedEvent, AutomationElement.RootElement, TreeScope.Subtree, onWindowClosedThrottled);

            _onWindowClosedThrottled.Run(true);

            LOGGER.Trace("Waiting for Git Extensions commit window");
        }
        public XtermTerminalView()
        {
            InitializeComponent();
            StartMediatorTask();

            _webView = new WebView(WebViewExecutionMode.SeparateThread)
            {
                DefaultBackgroundColor = Colors.Transparent
            };
            Root.Children.Add(_webView);

            _webView.NavigationCompleted += _webView_NavigationCompleted;
            _webView.NavigationStarting  += _webView_NavigationStarting;

            _copyMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Copy")
            };
            _copyMenuItem.Click += Copy_Click;

            _pasteMenuItem = new MenuFlyoutItem {
                Text = I18N.Translate("Command.Paste")
            };
            _pasteMenuItem.Click += Paste_Click;

            _webView.ContextFlyout = new MenuFlyout
            {
                Items = { _copyMenuItem, _pasteMenuItem }
            };

            _optionsChanged = new DebouncedAction <TerminalOptions>(Dispatcher, TimeSpan.FromMilliseconds(800), async options =>
            {
                var serialized = JsonConvert.SerializeObject(options);
                await ExecuteScriptAsync($"changeOptions('{serialized}')");
            });

            _navigationCompleted = new SemaphoreSlim(0, 1);
            _connectedEvent      = new ManualResetEventSlim(false);

            _webView.Navigate(new Uri("ms-appx-web:///Client/index.html"));
        }
Beispiel #7
0
        public MainWindow()
        {
            InitializeComponent();

            registryKey = Registry.CurrentUser.CreateSubKey(@"Software\DakarMapper", true);
            string?previousWindowPosition = (string?)registryKey.GetValue(WINDOW_POSITION_REGISTRY_NAME);

            if (previousWindowPosition != null)
            {
                string[] coordinates = previousWindowPosition.Split(',');
                Left   = Convert.ToDouble(coordinates[0]);
                Top    = Convert.ToDouble(coordinates[1]);
                Width  = Convert.ToDouble(coordinates[2]);
                Height = Convert.ToDouble(coordinates[3]);
            }

            DebouncedAction onWindowMoved = Debouncer.Debounce(() => Dispatcher.Invoke(() => registryKey.SetValue(WINDOW_POSITION_REGISTRY_NAME, string.Join(",", new[] { Left, Top, Width, Height }))),
                                                               TimeSpan.FromMilliseconds(500));

            LocationChanged += delegate { onWindowMoved.Run(); };
            SizeChanged     += delegate { onWindowMoved.Run(); };
        }