private void CaptureButton_Click(object sender, RoutedEventArgs e)
        {
            // save coordinates of 'content grid'
            System.Windows.Point locationFromScreen =
                ContentGrid.PointToScreen(new System.Windows.Point(0, 0));
            contentGrid_X      = locationFromScreen.X;
            contentGrid_Y      = locationFromScreen.Y;
            contentGrid_Width  = ContentGrid.ActualWidth;
            contentGrid_Height = ContentGrid.ActualHeight;

            // hide window
            this.WindowState = WindowState.Minimized;

            // wait some seconds
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(2);

            timer.Tick += (paramSender, paramArgs) =>
            {
                timer.Stop();

                Thread t = new Thread(new ThreadStart(StartProcessing));
                Stop = false;
                t.Start();
            };
            timer.Start();
        }
Beispiel #2
0
        protected override void StartDrag(UIElement dragObj, MouseButtonEventArgs e)
        {
            mContainedNodes.Clear();
            base.StartDrag(dragObj, e);

            // 计算所有在范围内的节点
            int deepestZIndex = -10;
            var lt            = ContentGrid.TranslatePoint(new Point(0, 0), ParentDrawCanvas);
            var rb            = ContentGrid.TranslatePoint(new Point(ContentGrid.ActualWidth, ContentGrid.ActualHeight), ParentDrawCanvas);
            var nodes         = HostNodesContainer.CtrlNodeList;

            for (int i = 0; i < nodes.Count; i++)
            {
                var checkNode = nodes[i];
                var loc       = checkNode.GetLocation();
                var nRight    = loc.X + checkNode.GetWidth();
                var nBottom   = loc.Y + checkNode.GetHeight();

                if (lt.X <= loc.X && rb.X >= nRight && lt.Y <= loc.Y && rb.Y >= nBottom)
                {
                    var zIndex = Canvas.GetZIndex(checkNode);
                    if (deepestZIndex > zIndex)
                    {
                        deepestZIndex = zIndex;
                    }
                    mContainedNodes.Add(checkNode);
                    checkNode.CalculateDeltaPt(e);
                }
            }
            Canvas.SetZIndex(this, deepestZIndex - 1);
        }
Beispiel #3
0
        private static void SourceProperty_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ControlTextGrid controlTextGrid = d as ControlTextGrid;
            ContentGrid     controlGrid     = e.NewValue as ContentGrid;

            if (controlTextGrid == null)
            {
                return;
            }
            if (controlGrid == null)
            {
                return;
            }

            controlTextGrid.RowCount        = controlGrid.RowCount;
            controlTextGrid.ColumnCount     = controlGrid.ColumnCount;
            controlTextGrid.BorderWidth     = controlGrid.BorderWidth;
            ToolboxItem.DirectoryAssResInfo = new Dictionary <string, System.Collections.ObjectModel.ObservableCollection <string> >();
            ToolboxItem.DirectoryTpage      = new Dictionary <string, TPageControl>();

            foreach (var v in controlGrid.List)
            {
                if (v.Content != null)
                {
                    controlTextGrid.SetContent(v.Column, v.Row, v.Content);
                }
                if (v.Children != null)
                {
                    controlTextGrid.SetContent(v.Column, v.Row, v.Children);
                }
            }
        }
Beispiel #4
0
        private void SetScrollBar()
        {
            VScrollBar = ContentGrid.ChildAt <ScrollBar>(0, 0, 1, 0, 0, 2);
            HScrollBar = ContentGrid.ChildAt <ScrollBar>(0, 0, 1, 0, 0, 3);

            UpdateScrollBar();
        }
Beispiel #5
0
        private void ContentGrid_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            isDraggingSelection = false;
            ContentGrid.ReleasePointerCapture(e.Pointer);

            SelectionRect.Width  = 0;
            SelectionRect.Height = 0;
        }
Beispiel #6
0
        public void PageEnter()
        {
            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 0,
                To             = 1,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = new Thickness(
                    TitleGrid.Margin.Left - 50,
                    TitleGrid.Margin.Top,
                    TitleGrid.Margin.Right + 50,
                    TitleGrid.Margin.Bottom),
                To             = TitleGrid.Margin,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            };

            MarginAnimation.Completed += delegate
            {
                ContentGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                });
                ContentGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                {
                    From = new Thickness(
                        ContentGrid.Margin.Left - 50,
                        ContentGrid.Margin.Top,
                        ContentGrid.Margin.Right + 50,
                        ContentGrid.Margin.Bottom),
                    To             = ContentGrid.Margin,
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                });
            };
            TitleGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            TitleGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }
Beispiel #7
0
        private void InitiateNewGaugeDlg(VPanelDlg dlgWindow, PanelSettings panelSettings)
        {
            dlgWindow.Owner = this;
            bool result = (bool)dlgWindow.ShowDialog(null);

            if (result)
            {
                ContentGrid.CreateNewPanel(panelSettings);
            }
        }
                public CardViewFrame()
                {
                    CornerRadius = 4;
                    HasShadow    = false;
                    Padding      = new Thickness(16);
                    Elevation    = 4;
                    Content      = new ContentGrid();

                    SetDynamicResource(MaterialThemeProperty, nameof(BaseTheme.MaterialFrameTheme));
                }
Beispiel #9
0
        private void InitComposition()
        {
            this.Visibility = Visibility.Collapsed;

            _compositor    = this.GetVisual().Compositor;
            _maskVisual    = MaskBorder.GetVisual();
            _contentVisual = ContentGrid.GetVisual();

            _contentVisual.Opacity = _maskVisual.Opacity = 0f;
        }
                public CardViewFrame()
                {
                    CornerRadius    = 4;
                    HasShadow       = false;
                    Padding         = new Thickness(16);
                    BorderThickness = 2;
                    Content         = new ContentGrid();

                    SetDynamicResource(BorderColorProperty, nameof(BaseTheme.CardBorderColor));
                    SetDynamicResource(BackgroundColorProperty, nameof(BaseTheme.CardSurfaceColor));
                }
Beispiel #11
0
        internal void ToggleInertia()
        {
            ScrollViewer SV = ContentGrid.Child_0 <ScrollViewer>(1);

            if (SV != null)
            {
                SV.HorizontalSnapPointsType = SnapPointsType.None;
                SV.VerticalSnapPointsType   = SnapPointsType.None;
                SV.IsScrollInertiaEnabled   = Container.UseInertia;
            }
        }
Beispiel #12
0
        private void PaggingTimer_Tick(object sender, EventArgs e)
        {
            ContentGrid.Children.Clear();
            BindPage(GetNextPageData());

            DoubleAnimation opacityAnimation2 = new DoubleAnimation();

            opacityAnimation2.From     = 0; //透明度初始值
            opacityAnimation2.To       = 1; //透明度值
            opacityAnimation2.Duration = new Duration(TimeSpan.FromSeconds(2));
            ContentGrid.BeginAnimation(Grid.OpacityProperty, opacityAnimation2);
        }
Beispiel #13
0
        private void SwitchPagesIfSequential(PageInsertionMode insertionMode, MtPageDescription currentPage, MtPageDescription newPage)
        {
            if (insertionMode == PageInsertionMode.Sequential)
            {
                if (currentPage != null)
                {
                    ContentGrid.Children.Remove(currentPage.GetPage(this).InternalPage);
                }

                ContentGrid.Children.Add(newPage.GetPage(this).InternalPage);
                ContentGrid.UpdateLayout();
            }
        }
Beispiel #14
0
        private async Task ShowNewTranslationControlAsync()
        {
            if (ViewModel.ShowNewTranslationWidgetOnMainPage)
            {
                NewTranslationWidgetGrid.Visibility = Visibility.Visible;
                await NewTranslationWidgetGrid.Fade(1).StartAsync();
            }
            else
            {
                await ContentGrid.Blur(10f).StartAsync();

                await NewTranslationControl.Fade(1).StartAsync();
            }
        }
Beispiel #15
0
 private void BindContents(int categoryID)
 {
     try
     {
         DataTable contents = AdminContents.GetContents(categoryID);
         ContentGrid.DataSource = contents;
         ContentGrid.DataBind();
         //logger.Debug("contents - " + contents.Rows.Count);
     }
     catch (Exception ex)
     {
         logger.Error("BindContents Exception - " + ex.Message);
     }
 }
Beispiel #16
0
        private void ContentGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            var pointer = e.GetCurrentPoint(ContentGrid);

            //if (pointer.Properties.IsRightButtonPressed)
            //{
            isDraggingSelection = true;
            pressedPos          = e.GetCurrentPoint((FrameworkElement)sender);
            ContentGrid.CapturePointer(e.Pointer);

            Canvas.SetLeft(SelectionRect, pressedPos.Position.X);
            Canvas.SetTop(SelectionRect, pressedPos.Position.Y);
            //}
        }
Beispiel #17
0
        internal void ContentGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Reader == null || UserStartReading)
            {
                return;
            }
            UserStartReading = true;

            if (0 < e.AddedItems.Count)
            {
                ContentGrid.ScrollIntoView(e.AddedItems[0]);
            }

            Reader.AutoVolumeAnchor();
        }
Beispiel #18
0
        // This calls onLoaded
        private void SetBookAnchor(object sender, RoutedEventArgs e)
        {
            SetScrollBar();
            ToggleInertia();

            ContentGrid.IsSynchronizedWithCurrentItem = false;

            AccelerSV = ContentGrid.Child_0 <ScrollViewer>(1);

            // Reader may not be available as ContentGrid.OnLoad is faster then SetTemplate
            if (!(Reader == null || Reader.SelectedData == null))
            {
                ContentGrid.ScrollIntoView(Reader.SelectedData, ScrollIntoViewAlignment.Leading);
            }
        }
Beispiel #19
0
        public void Expand()
        {
            ((SolidColorBrush)EllipseBackground.Fill).Color = Colors.Black;
            DiceText.Visibility = Visibility.Hidden;
            DispatcherTimer Timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.3)
            };

            Timer.Tick += delegate
            {
                ContentGrid.Visibility = Visibility.Visible;
                DoubleAnimation OpacityAnimation = new DoubleAnimation()
                {
                    From           = 0,
                    To             = 1,
                    Duration       = TimeSpan.FromSeconds(0.3),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseOut
                    }
                };
                OpacityAnimation.Completed += delegate { Begin(); };
                ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
                Timer.Stop();
            };
            this.BeginAnimation(HeightProperty, new DoubleAnimation()
            {
                From           = 0,
                To             = 200,
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            });
            this.BeginAnimation(WidthProperty, new DoubleAnimation()
            {
                From           = 0,
                To             = 200,
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                }
            });
            Timer.Start();
        }
        private void UpdateContentView(object sender, FileSystemEventArgs e)
        {
            // This has to be done on UI thread.
            syncContext.Send(
                delegate
            {
                ContentGrid.DataContext = CreateContentDataTable(Navigation.CurrentPath);

                //Scroll to the first item. Otherwise, the previous scroll will affect current view.
                if (ContentGrid.Items.Count > 0)
                {
                    ContentGrid.ScrollIntoView(ContentGrid.Items[0]);
                }
            }, null
                );
        }
Beispiel #21
0
        //Add any additional event handlers here. NOTE: this method is not for binding event handlers to
        //Menu Items. That is handled in the Routed UI Commands (Maps to Custom Event Handlers) section at
        //the bottom of this class. Also see README for more info
        public void ProcessKeyDownEvent(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Left:
            case Key.Right:
            case Key.Up:
            case Key.Down:
                ContentGrid.ProcessArrowNavigation(e.Key, isAltDown, isControlDown, isShiftDown);
                break;

            case Key.LeftAlt:
            case Key.RightAlt:
                isAltDown = true;
                break;

            case Key.LeftCtrl:
            case Key.RightCtrl:
                isControlDown = true;
                break;

            case Key.LeftShift:
            case Key.RightShift:
                isShiftDown = true;
                break;

            default:
                break;
            }
            switch ((ModifierKeys)e.Key)
            {
            case ModifierKeys.Alt:
                isAltDown = true;
                break;

            case ModifierKeys.Control:
                isControlDown = true;
                break;

            case ModifierKeys.Shift:
                isShiftDown = true;
                break;

            default:
                break;
            }
        }
Beispiel #22
0
        private void NextButton_Click(object sender, RoutedEventArgs e)
        {
            Image image = ((Image)this.FindName("I" + currentPage.ToString()));

            image.Visibility = Visibility.Collapsed;
            ContentGrid.UpdateLayout();
            ((Ellipse)this.FindName("E" + currentPage.ToString())).Fill = WhiteBrush;
            currentPage++;
            if (currentPage > TUTORIAL_PAGE_COUNT)
            {
                // Tutorial finished, go to main page
                SkipButton_Click(sender, e);
            }
            else
            {
                ((Ellipse)this.FindName("E" + currentPage.ToString())).Fill = SteelBlueBrush;
            }
        }
Beispiel #23
0
        internal void GotoIndex(int i)
        {
            if (ContentGrid.ItemsSource == null)
            {
                return;
            }
            int l = ContentGrid.Items.Count;

            if (!(-1 < i && i < l))
            {
                return;
            }

            ContentGrid.SelectedIndex = i;
            ContentGrid.ScrollIntoView(ContentGrid.SelectedItem, ScrollIntoViewAlignment.Leading);
            Reader.SelectIndex(i);
            ShowUndoButton();
        }
Beispiel #24
0
        public void ProcessKeyUpEvent(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.LeftAlt:
            case Key.RightAlt:
                isAltDown = false;
                break;

            case Key.LeftCtrl:
            case Key.RightCtrl:
                isControlDown = false;
                break;

            case Key.LeftShift:
            case Key.RightShift:
                isShiftDown = false;
                break;

            case Key.Left:
            case Key.Right:
            case Key.Up:
            case Key.Down:
                ContentGrid.ProcessArrowRelease();
                break;

            default:
                break;
            }
            switch ((ModifierKeys)e.Key)
            {
            case ModifierKeys.Alt:
                isAltDown = false;
                break;

            case ModifierKeys.Control:
                isControlDown = false;
                break;

            case ModifierKeys.Shift:
                isShiftDown = false;
                break;
            }
        }
Beispiel #25
0
        //Close Window with fade out animation
        private async void CloseSnap(bool result, int delay)
        {
            DoubleAnimation anim = new DoubleAnimation(0, TimeSpan.FromSeconds(0.25));

            anim.Completed += delegate {
                try {
                    DialogResult = result;
                } catch {
                    // ignored
                }
            };
            anim.From = ContentGrid.Opacity;
            anim.To   = 0;

            //Wait delay (ms) and then begin animation
            await Task.Delay(TimeSpan.FromMilliseconds(delay));

            ContentGrid.BeginAnimation(OpacityProperty, anim);
        }
Beispiel #26
0
        private void SaveAs_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var dlg = new FileSelector("\\configuration\\screens", ConfigManager.Settings.Contents.screenFilePath, "scr.json")
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                ExcludeLockedFiles    = true,
                AllowNewFiles         = true,
                NewFilesExtension     = ".scr.json",
                AllowImports          = false,
            };

            if ((bool)dlg.ShowDialog())
            {
                ConfigManager.Screen.SaveConfigurationAs(dlg.ResultFilePath);
                ConfigManager.Settings.Contents.screenFilePath = dlg.ResultFilePath;
                ContentGrid.InitPanels(this);
            }
        }
        public CounterPage()
        {
            InitializeComponent();

            // Observe changes on state
            Store.Select(SelectCount)
            .UntilDestroyed(this)
            .Subscribe(count =>
            {
                CounterValueTextBlock.Text = count.ToString();
            });

            // Observe UI events
            IncrementButton.Events().Click
            .Subscribe(_ => Store.Dispatch(new IncrementAction()));

            DecrementButton.Events().Click
            .Subscribe(_ => Store.Dispatch(new DecrementAction()));

            // Initialize Documentation
            DocumentationComponent.LoadMarkdownFilesAsync("Counter");

            GoToGitHubButton.Events().Click
            .Subscribe(async _ =>
            {
                var uri = new Uri("https://github.com/Odonno/ReduxSimple/tree/master/ReduxSimple.Samples/Counter");
                await Launcher.LaunchUriAsync(uri);
            });

            OpenDevToolsButton.Events().Click
            .Subscribe(async _ =>
            {
                await Store.OpenDevToolsAsync();
            });

            ContentGrid.Events().Tapped
            .Subscribe(_ => DocumentationComponent.Collapse());
            DocumentationComponent.ObserveOnExpanded()
            .Subscribe(_ => ContentGrid.Blur(5).Start());
            DocumentationComponent.ObserveOnCollapsed()
            .Subscribe(_ => ContentGrid.Blur(0).Start());
        }
Beispiel #28
0
        private async Task HideNewTranslationControlAsync()
        {
            if (ViewModel.ShowNewTranslationWidgetOnMainPage)
            {
                await NewTranslationWidgetGrid.Fade(0).StartAsync().ContinueWith(async _ =>
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher
                    .RunAsync(CoreDispatcherPriority.High, () =>
                    {
                        NewTranslationWidgetGrid.Visibility = Visibility.Collapsed;
                    });
                });
            }
            else
            {
                await ContentGrid.Blur(0f).StartAsync();

                await NewTranslationControl.Fade().StartAsync();
            }
        }
Beispiel #29
0
        private void AutoSelectParagraph()
        {
            if (ParaVisualizer == null)
            {
                ParaVisualizer = ContentGrid.ChildAt <ItemsStackPanel>(0, 0, 0, 0, 0, 0, 1);
                if (ParaVisualizer == null)
                {
                    return;
                }
            }

            Rect ScreenBounds = IsHorz ? new Rect(0, 0, ActualWidth * 0.8, ActualHeight) : new Rect(0, 0, ActualWidth, ActualHeight * 0.8);

            if (VisibleParagraph != null && VisibleContext?.DataContext?.Equals(SelectedParagraph) == true)
            {
                if (VisualTreeHelper.FindElementsInHostCoordinates(ScreenBounds, ParaVisualizer).Contains(VisibleParagraph))
                {
                    return;
                }
            }

            int l = ParaVisualizer.Children.Count();

            for (int i = 0; i < l; i++)
            {
                FrameworkElement Item = ( FrameworkElement )ParaVisualizer.Children[i];
                if (VisualTreeHelper.FindElementsInHostCoordinates(ScreenBounds, ParaVisualizer).Contains(Item))
                {
                    FrameworkElement _ContentPresenter = Item.ChildAt <FrameworkElement>(0, 0, 1);
                    if (_ContentPresenter?.DataContext is Paragraph P)
                    {
                        VisibleParagraph         = Item;
                        VisibleContext           = _ContentPresenter;
                        SelectedParagraph        = P;
                        ContentGrid.SelectedItem = P;
                        Reader.SelectAndAnchor(P);
                        break;
                    }
                }
            }
        }
Beispiel #30
0
        private void Layouts_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var dlg = new FileSelector("\\configuration\\screens", ConfigManager.Settings.Contents.screenFilePath, "scr.json")
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                ExcludeLockedFiles    = true,
                AllowNewFiles         = true,
                NewFilesExtension     = ".scr.json",
                AllowImports          = true,
                ImportFilter          = "JSON Screen Files (*.scr.json)|*.vms"
            };

            if ((bool)dlg.ShowDialog())
            {
                ConfigManager.Settings.Contents.screenFilePath = dlg.ResultFilePath;
                //ConfigManager.Screen.SaveConfiguration();
                ConfigManager.Screen.Reload(dlg.ResultFilePath);
                ContentGrid.InitPanels(this);
                //Common.Helpers.ApplicationControl.Restart();
            }
        }