Ejemplo n.º 1
0
 void SaveFileBtnClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     //TODO: delete elements using back key
     //_generator.controls.Clear();
     //_textEditor.TextArea.TextView.Redraw();
     _outText.Text = "Saved!";
 }
Ejemplo n.º 2
0
 private void RunBtnClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     //var code = _textEditor.Text;
     //var ast = RegexpParser.parseRegexpFromString(code);
     //Interpreter.run(ast);
     try
     {
         _runBtn.IsEnabled           = false;
         isSuccessfulRun             = true;
         _executionStatus.Background = Brushes.Yellow;
         _console.Text = "Execution started:\n";
         var code = this._textEditor.Text;
         var ast  = RegexpParser.parseRegexpFromString(code);
         var task = new Task(() => Interpreter.run(ast));
         task.ContinueWith(t =>
                           Dispatcher.UIThread.Post(() =>
         {
             _runBtn.IsEnabled = true;
             if (isSuccessfulRun)
             {
                 _executionStatus.Background = Brushes.Green;
             }
             _console.Text += "\n" + "Execution finished.";
         }));
         task.Start();
     }
     catch (Exception exception)
     {
         _console.Text += exception.Message;
         _console.Text += "\n" + "Execution finished.";
         _executionStatus.Background = Brushes.Red;
         _runBtn.IsEnabled           = true;
         isSuccessfulRun             = false;
     }
 }
Ejemplo n.º 3
0
 void _addControlBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     _generator.controls.Add(new Pair(_textEditor.CaretOffset, new Button()
     {
         Content = "Click me"
     }));
     _textEditor.TextArea.TextView.Redraw();
 }
Ejemplo n.º 4
0
        protected void B1_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            this.OnClickInButton1();

            var _e = new RoutedEventArgs(MainButtonClickEvent);

            RaiseEvent(_e);
            _e.Handled = true;
        }
Ejemplo n.º 5
0
        private void Addbtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            var a_C = "This Tab is Closable";

            tabc.AddTab(new AuraTabItem()
            {
                Header = "AuraTabItem", Content = a_C
            }, true);
        }
Ejemplo n.º 6
0
        protected void B2_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            var _e = new RoutedEventArgs(SecondaryButtonClickEvent);

            RaiseEvent(_e);
            _e.Handled = true;

            this.OnClickInButton2();
        }
Ejemplo n.º 7
0
        public void Tunneling_Event_Should_Tunnel()
        {
            var ev = new RoutedEvent("test", RoutingStrategies.Tunnel, typeof(RoutedEventArgs), typeof(TestInteractive));
            var invoked = new List<string>();
            EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
            var target = CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "1", "2b" }, invoked);
        }
Ejemplo n.º 8
0
        public void Direct_Event_Should_Go_Straight_To_Source()
        {
            var ev = new RoutedEvent("test", RoutingStrategies.Direct, typeof(RoutedEventArgs), typeof(TestInteractive));
            var invoked = new List<string>();
            EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
            var target = CreateTree(ev, handler, RoutingStrategies.Direct);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "2b" }, invoked);
        }
Ejemplo n.º 9
0
        private static void PointerReleased(RoutedEventArgs ev)
        {
            if (ev.Route == RoutingStrategies.Bubble)
            {
                var e = (PointerReleasedEventArgs)ev;

                if (s_lastPress?.IsAlive == true && s_lastPress.Target == e.Source)
                {
                    ((IInteractive)s_lastPress.Target).RaiseEvent(new RoutedEventArgs(TappedEvent));
                }
            }
        }
Ejemplo n.º 10
0
        async void _openFileBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            var openDialog = new OpenFileDialog();

            openDialog.AllowMultiple = false;
            var path = await openDialog.ShowAsync(this);

            if (path != null)
            {
                var text = System.IO.File.ReadAllText(path[0]);
                _currentFile     = path[0];
                _textEditor.Text = text;
            }
            ;
        }
Ejemplo n.º 11
0
        private static void PointerPressed(RoutedEventArgs ev)
        {
            if (ev.Route == RoutingStrategies.Bubble)
            {
                var e = (PointerPressedEventArgs)ev;

                if (e.ClickCount <= 1)
                {
                    s_lastPress = new WeakReference(e.Source);
                }
                else if (s_lastPress?.IsAlive == true && e.ClickCount == 2 && s_lastPress.Target == e.Source)
                {
                    e.Source.RaiseEvent(new RoutedEventArgs(DoubleTappedEvent));
                }
            }
        }
Ejemplo n.º 12
0
        public void Direct_Event_Should_Have_Route_Set_To_Direct()
        {
            var ev = new RoutedEvent("test", RoutingStrategies.Direct, typeof(RoutedEventArgs), typeof(TestInteractive));
            bool called = false;

            EventHandler<RoutedEventArgs> handler = (s, e) =>
            {
                Assert.Equal(RoutingStrategies.Direct, e.Route);
                called = true;
            };

            var target = CreateTree(ev, handler, RoutingStrategies.Direct);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.True(called);
        }
Ejemplo n.º 13
0
        public void btn_OnClick(object sender, Avalonia.Interactivity.RoutedEventArgs args)
        {
            Avalonia.Controls.Button?btn = sender as Avalonia.Controls.Button;
            int index = -1;

            int.TryParse(btn?.Tag?.ToString(), out index);
            if (btn != null && index >= 0 && index < status.Length)
            {
                status[index]  = !status[index];
                btn.Background = status[index] ?
                                 new SolidColorBrush(new Color(colors[index].A, colors[index].R, colors[index].G, colors[index].B))
                    : Brushes.Transparent;
                series[index].Color = status[index] ? colors[index] : OxyColors.Transparent;
                // foreach (var a in Model.Axes)
                //     a.Maximum -= 1;

                // AddRandomValue(index);

                if (flag)
                {
                    timePeriod_sec -= 20;
                    flag            = timePeriod_sec > 20;
                }

                else
                {
                    timePeriod_sec += 20;
                }
                dataLength            = timePeriod_sec;
                Model.Axes[0].Maximum = timePeriod_sec;

                for (int i = 0; i < DataSources.Count; i++)
                {
                    DataSources[i].SetParams(dataLength, timePeriod_sec);
                }
            }
        }
Ejemplo n.º 14
0
 private void Next_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     CurrentPage++;
     SetImage();
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Called when a submenu is clicked somewhere in the menu.
 /// </summary>
 /// <param name="e">The event args.</param>
 private void OnMenuClick(RoutedEventArgs e)
 {
     Close();
     FocusManager.Instance.Focus(null);
     e.Handled = true;
 }
Ejemplo n.º 16
0
 private void CloseButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     this.Close();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Called when the menu item's access key is pressed.
        /// </summary>
        /// <param name="e">The event args.</param>
        private void AccessKeyPressed(RoutedEventArgs e)
        {
            if (HasSubMenu)
            {
                SelectedIndex = 0;
                IsSubMenuOpen = true;
            }
            else
            {
                RaiseEvent(new RoutedEventArgs(ClickEvent));
            }

            e.Handled = true;
        }
Ejemplo n.º 18
0
        public void Typed_Class_Handlers_Should_Be_Called()
        {
            var ev = new RoutedEvent<RoutedEventArgs>(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
                typeof(TestInteractive));

            var target = CreateTree(ev, null, 0);

            ev.AddClassHandler<TestInteractive>(x => x.ClassHandler, RoutingStrategies.Bubble);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.True(target.ClassHandlerInvoked);
            Assert.True(target.GetVisualParent<TestInteractive>().ClassHandlerInvoked);
        }
Ejemplo n.º 19
0
        public void Handled_Tunnelled_Event_Should_Not_Propogate_Further()
        {
            var ev = new RoutedEvent(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel, 
                typeof(RoutedEventArgs), 
                typeof(TestInteractive));
            var invoked = new List<string>();

            EventHandler<RoutedEventArgs> handler = (s, e) =>
            {
                var t = (TestInteractive)s;
                invoked.Add(t.Name);
                e.Handled = t.Name == "2b";
            };

            var target = CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "1", "2b" }, invoked);
        }
Ejemplo n.º 20
0
        public void Tunneling_Subscription_Should_Not_Catch_Bubbling()
        {
            var ev = new RoutedEvent(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
                typeof(RoutedEventArgs),
                typeof(TestInteractive));
            var count = 0;

            EventHandler<RoutedEventArgs> handler = (s, e) =>
            {
                Assert.Equal(RoutingStrategies.Tunnel, e.Route);
                ++count;
            };

            var target = CreateTree(ev, handler, RoutingStrategies.Tunnel);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(2, count);
        }
Ejemplo n.º 21
0
 public void Prev_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     CurrentPage--;
     SetImage();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Called before the <see cref="LostFocus"/> event occurs.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnLostFocus(RoutedEventArgs e)
 {
     IsFocused = false;
 }
Ejemplo n.º 23
0
 private void CloseButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     RaiseEvent(new RoutedEventArgs(CloseButtonClickEvent));
     Close();
 }
Ejemplo n.º 24
0
 protected override void OnClick(RoutedEventArgs e)
 {
     Toggle();
     base.OnClick(e);
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Global handler for pointer pressed events.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void OnPreviewPointerPressed(object sender, RoutedEventArgs e)
        {
            if (sender == e.Source)
            {
                var ev = (PointerPressedEventArgs)e;
                var element = (ev.Device?.Captured as IInputElement) ?? (e.Source as IInputElement);

                if (element == null || !CanFocus(element))
                {
                    element = element.GetSelfAndVisualAncestors()
                        .OfType<IInputElement>()
                        .FirstOrDefault(CanFocus);
                }

                if (element != null)
                {
                    Focus(element, NavigationMethod.Pointer, ev.InputModifiers);
                }
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Called when the menu loses focus.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected override void OnLostFocus(RoutedEventArgs e)
 {
     base.OnLostFocus(e);
     SelectedItem = null;
 }
Ejemplo n.º 27
0
 private void Cbtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     tabc.CloseTab(tabc.ItemCount);
 }
Ejemplo n.º 28
0
    private void Button_Click(object?sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        var content = this.Find <ContentControl>("content");

        content.Content = new UserControl1();
    }
Ejemplo n.º 29
0
 private void RootGotFocus(object sender, RoutedEventArgs e)
 {
     this.HasFocus = true;
     GdkWindow.Focus(0);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Raises the <see cref="Click"/> event.
        /// </summary>
        private void RaiseClickEvent()
        {
            RoutedEventArgs click = new RoutedEventArgs
            {
                RoutedEvent = ClickEvent,
            };

            RaiseEvent(click);
        }
 /// <summary>
 /// Set apllication main theme to dark fluent theme.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SetDarkTheme(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     Cursor = new Cursor(StandardCursorType.Wait);
     Application.Current.Styles[1] = App.FluentDark;
     Cursor = new Cursor(StandardCursorType.Arrow);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Invokes the <see cref="Click"/> event.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnClick(RoutedEventArgs e)
 {
     Command?.Execute(CommandParameter);
 }
Ejemplo n.º 33
0
 private void Last_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     CurrentPage = pages.Count - 1;
     SetImage();
 }
Ejemplo n.º 34
0
        public void Event_Should_Should_Keep_Propogating_To_HandedEventsToo_Handlers()
        {
            var ev = new RoutedEvent(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
                typeof(RoutedEventArgs),
                typeof(TestInteractive));
            var invoked = new List<string>();

            EventHandler<RoutedEventArgs> handler = (s, e) =>
            {
                invoked.Add(((TestInteractive)s).Name);
                e.Handled = true;
            };

            var target = CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel, true);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "1", "2b", "2b", "1" }, invoked);
        }
Ejemplo n.º 35
0
 void _clearControlBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     //TODO: delete elements using back key
     _generator.controls.Clear();
     _textEditor.TextArea.TextView.Redraw();
 }
Ejemplo n.º 36
0
        public void Bubbling_Class_Handlers_Should_Be_Called()
        {
            var ev = new RoutedEvent(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
                typeof(RoutedEventArgs),
                typeof(TestInteractive));
            var invoked = new List<string>();
            EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);

            var target = CreateTree(ev, null, 0);

            ev.AddClassHandler(typeof(TestInteractive), handler, RoutingStrategies.Bubble);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "2b", "1" }, invoked);
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Called when a container raises the <see cref="IsSelectedChangedEvent"/>.
        /// </summary>
        /// <param name="e">The event.</param>
        private void ContainerSelectionChanged(RoutedEventArgs e)
        {
            if (!_ignoreContainerSelectionChanged)
            {
                var control = e.Source as IControl;
                var selectable = e.Source as ISelectable;

                if (control != null &&
                    selectable != null &&
                    control.LogicalParent == this &&
                    ItemContainerGenerator?.IndexFromContainer(control) != -1)
                {
                    UpdateSelection(control, selectable.IsSelected);
                }
            }

            if (e.Source != this)
            {
                e.Handled = true;
            }
        }
Ejemplo n.º 38
0
 public void ClassHandler(RoutedEventArgs e)
 {
     ClassHandlerInvoked = true;
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Called when a submenu opens somewhere in the menu.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected virtual void OnSubmenuOpened(RoutedEventArgs e)
        {
            var menuItem = e.Source as MenuItem;

            if (menuItem != null && menuItem.Parent == this)
            {
                foreach (var child in this.GetLogicalChildren().OfType<MenuItem>())
                {
                    if (child != menuItem && child.IsSubMenuOpen)
                    {
                        child.IsSubMenuOpen = false;
                    }
                }
            }

            IsOpen = true;
        }
Ejemplo n.º 40
0
        public void Events_Should_Have_Route_Set()
        {
            var ev = new RoutedEvent(
                "test",
                RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
                typeof(RoutedEventArgs),
                typeof(TestInteractive));
            var invoked = new List<RoutingStrategies>();
            EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(e.Route);
            var target = CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[]
            {
                RoutingStrategies.Tunnel,
                RoutingStrategies.Tunnel,
                RoutingStrategies.Bubble,
                RoutingStrategies.Bubble,
            },
            invoked);
        }
Ejemplo n.º 41
0
 public void FirstClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
 {
     CurrentPage = 0;
     SetImage();
 }