public void CollapseAll() => TreeGrid.CollapseAllNodes();
 public void ExpandAll() => TreeGrid.ExpandAllNodes();
Exemplo n.º 3
0
        protected override void ProcessOnDrop(DragEventArgs args, RowColumnIndex rowColumnIndex)
        {
            this.TreeGrid.AutoScroller.AutoScrolling = AutoScrollOrientation.None;
            var dropPosition = GetDropPosition(args, rowColumnIndex);

            if (dropPosition != DropPosition.None && rowColumnIndex.RowIndex != -1)
            {
                var draggedItem = GetDraggedItem(args);
                if (this.TreeGrid.View is TreeGridNestedView)
                {
                    var treeNode = this.TreeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);
                    if (treeNode == null)
                    {
                        return;
                    }
                    var data = treeNode.Item;
                    TreeGrid.SelectionController.SuspendUpdates();
                    var itemIndex = -1;

                    TreeNode parentNode = null;
                    if (dropPosition == DropPosition.DropBelow || dropPosition == DropPosition.DropAbove)
                    {
                        parentNode = treeNode.ParentNode;
                    }
                    else if (dropPosition == DropPosition.DropAsChild)
                    {
                        if (!treeNode.IsExpanded)
                        {
                            TreeGrid.ExpandNode(treeNode);
                        }
                        parentNode = treeNode;
                    }
                    IList sourceCollection = null;
                    if (dropPosition == DropPosition.DropBelow || dropPosition == DropPosition.DropAbove)
                    {
                        if (treeNode.ParentNode != null)
                        {
                            var collection = TreeGrid.View.GetPropertyAccessProvider().GetValue(treeNode.ParentNode.Item, TreeGrid.ChildPropertyName) as IEnumerable;
                            sourceCollection = GetSourceListCollection(collection);
                        }
                        else
                        {
                            sourceCollection = GetSourceListCollection(TreeGrid.View.SourceCollection);
                        }
                        itemIndex = sourceCollection.IndexOf(data);
                        if (dropPosition == DropPosition.DropBelow)
                        {
                            itemIndex += 1;
                        }
                    }
                    else if (dropPosition == DropPosition.DropAsChild)
                    {
                        var collection = TreeGrid.View.GetPropertyAccessProvider().GetValue(data, TreeGrid.ChildPropertyName) as IEnumerable;
                        sourceCollection = GetSourceListCollection(collection);
                        if (sourceCollection == null)
                        {
                            var list = data.GetType().GetProperty(TreeGrid.ChildPropertyName).PropertyType.CreateNew() as IList;
                            if (list != null)
                            {
                                TreeGrid.View.GetPropertyAccessProvider().SetValue(treeNode.Item, TreeGrid.ChildPropertyName, list);
                                sourceCollection = list;
                            }
                        }
                        itemIndex = sourceCollection.Count;
                    }
                    sourceCollection.Insert(itemIndex, draggedItem);
                    TreeGrid.SelectionController.ResumeUpdates();
                    (TreeGrid.SelectionController as TreeGridRowSelectionController).RefreshSelection();
                }
            }
            CloseDragIndicators();
        }
Exemplo n.º 4
0
 public void TestInit()
 {
     _grid = new TreeGrid();
 }
Exemplo n.º 5
0
 protected override void InitializeControls()
 {
     base.InitializeControls();
     UpdateActionButtonsControlLayout();
     UpdateCancelButton();
     UpdateOKButton();
     UpdateCommonControlLayout();
     UpdateSelectedRowsControlLayout();
     UpdateSelectedRecordsGridContolLayout();
     UpdateSelectedRecordButtonsControlLayout();
     UpdateRemoveSelectedRecordButton();
     UpdateAddSelectedRecordButton();
     UpdateTreeGrid();
     UpdateShowChangelogMenuItem();
     UpdateCallMenuItem();
     UpdateSendEmailMenuItem();
     UpdateButtonsControlLayout();
     UpdateActionButton();
     UpdateContextHelpButton();
     UpdatePrintButton();
     UpdateDeleteButton();
     UpdateEditButton();
     UpdateCopyButton();
     UpdateAddButton();
     UpdateSearchControlLayout();
     UpdateSearchButton();
     UpdateSearchEdit();
     UpdateToolButtonClearSearch();
     UpdateSearchComboBoxEdit();
     UpdateSchemaListEdit();
     TopLevelControl.MoveItem(0, BaseMessagePanel);
     TopLevelControl.MoveItem(1, SearchControlLayout);
     SearchControlLayout.MoveItem(0, SchemaListEdit);
     SearchControlLayout.MoveItem(1, SearchComboBoxEdit);
     SearchControlLayout.MoveItem(2, SearchEdit);
     SearchEdit.MoveItem(0, ToolButtonClearSearch);
     SearchControlLayout.MoveItem(3, SearchButton);
     TopLevelControl.MoveItem(2, ButtonsControlLayout);
     ButtonsControlLayout.MoveItem(0, AddButton);
     ButtonsControlLayout.MoveItem(1, CopyButton);
     ButtonsControlLayout.MoveItem(2, EditButton);
     ButtonsControlLayout.MoveItem(3, DeleteButton);
     ButtonsControlLayout.MoveItem(4, SpacerDeleteButton);
     ButtonsControlLayout.MoveItem(5, SpacerPrintButton);
     ButtonsControlLayout.MoveItem(6, PrintButton);
     ButtonsControlLayout.MoveItem(7, ContextHelpButton);
     ButtonsControlLayout.MoveItem(8, ActionButton);
     TopLevelControl.MoveItem(3, CommonControlLayout);
     CommonControlLayout.MoveItem(0, TreeGrid);
     TreeGrid.MoveItem(0, SendEmailMenuItem);
     TreeGrid.MoveItem(1, CallMenuItem);
     TreeGrid.MoveItem(2, ShowChangelogMenuItem);
     CommonControlLayout.MoveItem(1, SelectedRowsControlLayout);
     SelectedRowsControlLayout.MoveItem(0, SelectedRecordButtonsControlLayout);
     SelectedRecordButtonsControlLayout.MoveItem(0, Spacer1);
     SelectedRecordButtonsControlLayout.MoveItem(1, AddSelectedRecordButton);
     SelectedRecordButtonsControlLayout.MoveItem(2, RemoveSelectedRecordButton);
     SelectedRecordButtonsControlLayout.MoveItem(3, Spacer2);
     SelectedRowsControlLayout.MoveItem(1, SelectedRecordsGridContolLayout);
     SelectedRecordsGridContolLayout.MoveItem(0, SelectedRecordsGrid);
     TopLevelControl.MoveItem(4, ActionButtonsControlLayout);
     ActionButtonsControlLayout.MoveItem(0, SpacerOKButton);
     ActionButtonsControlLayout.MoveItem(1, OKButton);
     ActionButtonsControlLayout.MoveItem(2, CancelButton);
     TopLevelControl.MoveItem(5, DataSource);
     SetControlsDefInheritance(UId);
     InitializeLocalizableValues();
 }
Exemplo n.º 6
0
			public TreeGridUpdater(TreeGrid tree)
			{
				_tree = tree;
				_root = tree.Nodes;
				_activeNode = tree.ActiveNode;
				tree.Nodes = null;
			}
        /// <summary>
        /// Let Renderer decide whether the parent grid should be allowed to handle keys and prevent
        /// the key event from being handled by the visual UIElement for this renderer. If this method
        /// returns true the parent grid will handle arrow keys and set the Handled flag in the event
        /// data. Keys that the grid does not handle will be ignored and be routed to the UIElement
        /// for this renderer.
        /// </summary>
        /// <param name="e">A <see cref="KeyEventArgs" /> object.</param>
        /// <returns>
        /// True if the parent grid should be allowed to handle keys; false otherwise.
        /// </returns>
        protected override bool ShouldGridTryToHandleKeyDown(KeyEventArgs e)
        {
#if WPF
            if (!HasCurrentCellState || !IsInEditing)
            {
                return(true);
            }
            var currentCellUiElement = (MaskedTextBox)CurrentCellRendererElement;
            switch (e.Key)
            {
            case Key.Escape:
            {
                currentCellUiElement.ClearValue(MaskedTextBox.ValueProperty);
                return(true);
            }

            case Key.F2:
            {
                if (!IsInEditing)
                {
                    TreeGrid.Focus();
                }
                return(true);
            }

            case Key.A:
                return(SelectionHelper.CheckControlKeyPressed() && !IsInEditing);

            case Key.Left:
                return(currentCellUiElement.SelectionStart == currentCellUiElement.SelectionLength && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed());

            case Key.Right:
                return(currentCellUiElement.CaretIndex >= currentCellUiElement.Text.Length && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed());

            case Key.Home:
                return(currentCellUiElement.SelectionStart == currentCellUiElement.SelectionLength && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed());

            case Key.End:
                return(currentCellUiElement.CaretIndex == currentCellUiElement.Text.Length && !SelectionHelper.CheckControlKeyPressed() && !SelectionHelper.CheckShiftKeyPressed());
            }
#else
            if (!HasCurrentCellState)
            {
                return(true);
            }

            if (!IsInEditing)
            {
                ProcessPreviewTextInput(e);
                if (!(CurrentCellRendererElement is SfMaskedEdit))
                {
                    return(true);
                }
            }

            var currentCellUiElement = (SfMaskedEdit)CurrentCellRendererElement;
            switch (e.Key)
            {
            case Key.Escape:
            {
                currentCellUiElement.ClearValue(SfMaskedEdit.TextProperty);
                return(true);
            }
            }
#endif
            return(base.ShouldGridTryToHandleKeyDown(e));
        }
Exemplo n.º 8
0
 protected override void ResetState()
 {
     grid = null;
 }
        private void UpdateNodesOnChildPropertyChange(object sender, TreeNode treeNode, PropertyChangedEventArgs e)
        {
            if (SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.None))
            {
                return;
            }
            TreeNode newParentNode = null;
            var      childValue    = propertyAccessProvider.GetValue(sender, childPropertyName);

            if (SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnPropertyChange))
            {
                if (treeNode == null)
                {
                    var rootAdded = AddRootNode(sender, childValue);
                    if (!rootAdded)
                    {
                        newParentNode = FindParentNode(Nodes.RootNodes, childValue);
                        if (newParentNode != null)
                        {
                            if (newParentNode.IsExpanded || newParentNode.ChildNodes.Any())
                            {
                                AddNode(newParentNode, sender, newParentNode.ChildNodes.Count);
                                return;
                            }
                            else
                            {
                                newParentNode.HasChildNodes = true;
                                // If FilterLevel is Root, no need to update HasVisibleChildNodes based on filtering.
                                if (FilterLevel != FilterLevel.Root)
                                {
                                    UpdateHasVisibleChildNodesBasedOnChildItem(newParentNode, sender);
                                }
                                ChangeParentNodeExpander(newParentNode);
                            }
                        }
                    }
                    return;
                }
            }
            var parentNode = treeNode.ParentNode;

            // Changing root node data
            if (parentNode == null)
            {
                var addAsRoot = AddRootNode(sender, childValue, isRoot: true, canAdd: false);
                if (addAsRoot)
                {
                    // no need to do anything
                    return;
                }
            }

            newParentNode = FindParentNode(Nodes.RootNodes, childValue);
            if (newParentNode == parentNode && parentNode != null)
            {
                return;
            }

            if (newParentNode != null)
            {
                // invalid case
                if (IsAncestor(newParentNode, treeNode))
                {
                    // UWP-3144 - When child property and parent property have same value and needs to be added as root, we should remove existing node and add as root.
                    var addAsRoot = AddRootNode(sender, childValue, canAdd: false);
                    if (addAsRoot)
                    {
                        RemoveNode(treeNode);
                        AddNode(null, treeNode, newParentNode.ChildNodes.Count);
                        return;
                    }
                    RemoveNode(parentNode, sender);
                    return;
                }
                else
                {
                    if (this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnPropertyChange) || ((this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnEdit) || this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveAndExpandOnEdit)) && e == null))
                    {
                        RemoveNode(treeNode);
                        if (newParentNode.IsExpanded || newParentNode.ChildNodes.Any())
                        {
                            AddNode(newParentNode, treeNode, newParentNode.ChildNodes.Count);
                        }
                        else
                        {
                            ResetParentAndLevel(newParentNode, treeNode);
                            newParentNode.HasChildNodes = true;
                            if (CanFilterNode(treeNode))
                            {
                                UpdateParentNodeOnPropertyChange(treeNode, newParentNode);
                            }
                            ChangeParentNodeExpander(newParentNode);
                        }
                        if (e == null && this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveAndExpandOnEdit))
                        {
                            List <TreeNode> nodes = new List <TreeNode>();
                            tempNode = treeNode;
                            var rootNode = Nodes.GetRootNode(treeNode, ref nodes);
                            for (int i = nodes.Count - 1; i >= 0; i--)
                            {
                                TreeGrid.ExpandNode(nodes[i]);
                            }
                            BringUpdatedItemIntoView(treeNode, childPropertyName);
                            return;
                        }

                        if ((parentNode == null || parentNode.IsExpanded) || newParentNode.IsExpanded)
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                var parentItem = FindParentItem(childValue);
                if (parentItem == null)
                {
                    if (parentNode == null)
                    {
                        return;
                    }

                    if (this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnPropertyChange) || ((this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnEdit) || this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveAndExpandOnEdit)) && e == null))
                    {
                        RemoveNode(treeNode);
                        // Check whether node can be added as root.
                        var addAsRoot = AddRootNode(sender, childValue, canAdd: false);
                        if (addAsRoot)
                        {
                            // Add updated tree node as root node
                            AddNode(null, treeNode, Nodes.RootNodes.Count);
                            // While using editing only, need to scroll to updated item.
                            if (e == null)
                            {
                                BringUpdatedItemIntoView(treeNode, childPropertyName);
                            }
                        }
                    }
                    else
                    {
                        RemoveNode(parentNode, sender);
                    }
                    return;
                }
                else
                {
                    var visibleParentNode = FindVisibleParentNode(parentItem);
                    if (IsAncestor(visibleParentNode, treeNode))
                    {
                        RemoveNode(parentNode, sender);
                        return;
                    }
                    else
                    {
                        if (this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnPropertyChange) || ((this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnEdit) || this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveAndExpandOnEdit)) && e == null))
                        {
                            RemoveNode(treeNode);
                            if (visibleParentNode == null)
                            {
                                return;
                            }
                            if (this.SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveAndExpandOnEdit) && e == null)
                            {
                                List <TreeNode> nodes = new List <TreeNode>();
                                tempNode = treeNode;
                                var visibleParentNodeLineCount = visibleParentNode.GetYAmountCache() - 1;
                                nodes.Add(visibleParentNode);
                                var rootNode = Nodes.GetRootNode(visibleParentNode, ref nodes);
                                TreeGrid.TreeGridModel.suspend = true;
                                for (int i = nodes.Count - 1; i >= 0; i--)
                                {
                                    TreeGrid.ExpandNode(nodes[i]);
                                }
                                var orgParentNode = ExpandNodeRecursively(visibleParentNode, parentItem, parentItemCollection.Count - 2);
                                if (orgParentNode != null)
                                {
                                    TreeGrid.ExpandNode(orgParentNode);
                                }
                                TreeGrid.TreeGridModel.suspend = false;
                                foreach (var n in treeNode.ChildNodes)
                                {
                                    n.Level = treeNode.Level + 1;
                                    ResetLevel(n);
                                }
                                tempNode = null;
                                TreeGrid.TreeGridModel.UpdateRows(nodes.FirstOrDefault(), visibleParentNodeLineCount);
                                parentItemCollection.Clear();
                                BringUpdatedItemIntoView(treeNode, childPropertyName);
                            }
                            return;
                        }
                    }
                }
            }
            return;
        }
        private void UpdateNodesOnParentPropertyChange(object sender, TreeNode treeNode, PropertyChangedEventArgs e)
        {
            if (SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.None))
            {
                return;
            }

            var parentValue = propertyAccessProvider.GetValue(sender, parentPropertyName);

            if (treeNode != null && treeNode.ChildNodes.Any())
            {
                object childValue = propertyAccessProvider.GetValue(treeNode.ChildNodes[0].Item, childPropertyName);
                // checking parent property is changed or not (by comparing child and parent property values)
                if (IsEqual(parentValue, childValue))
                {
                    return;
                }
            }
            if ((e == null && SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnEdit)) || (e != null && SelfRelationUpdateMode.HasFlag(SelfRelationUpdateMode.MoveOnPropertyChange)))
            {
                TreeNodes nodeCollection = null;
                object    childValue     = propertyAccessProvider.GetValue(sender, childPropertyName);
                // if (!IsEqual(parentValue, childValue) || (IsEqual(parentValue, childValue) && SelfRelationRootValue == DependencyProperty.UnsetValue))
                if (!IsEqual(parentValue, childValue) || SelfRelationRootValue == DependencyProperty.UnsetValue)
                {
                    // Root value not set case. Remove root nodes if it has child property value equals to parent property value.
                    nodeCollection = RemoveNodesHavingChildPropertyEqualsToNewParentProperty(parentValue, treeNode);
                }

                // For property change case only

                if (treeNode == null)
                {
                    var childItems = GetChildSourceFromParentID(SelfRelationRootValue, null, true);

                    foreach (var childItem in childItems)
                    {
                        CanAddRootNode(childItem, true);
                    }
                }
                else
                {
                    if (SelfRelationRootValue == DependencyProperty.UnsetValue)
                    {
                        AddRootNodesFromRemovedParent(treeNode);
                        // When parent and child value both are same, need to add the child nodes(removed from root nodes) having child property equal to parent property.
                        if (nodeCollection != null && nodeCollection.Any() && IsEqual(parentValue, childValue) && SelfRelationRootValue == DependencyProperty.UnsetValue)
                        {
                            nodeCollection.Remove(treeNode);
                            if (treeNode.IsExpanded || treeNode.ChildNodes.Any())
                            {
                                AddTreeNodes(treeNode, nodeCollection);
                            }
                        }
                    }
                    else
                    {
                        ResetNodes(treeNode, true);
                    }

                    // After parent property name is changed, if node is expanded and dont have child node, need to populate child nodes based on new parent property value.
                    if (treeNode.IsExpanded && !treeNode.ChildNodes.Any())
                    {
                        TreeGrid.TreeGridModel.ExpandNode(treeNode, true);
                    }
                    else
                    {
                        IsChildNodeAvailable(treeNode);
                        var rowIndex = TreeGrid.ResolveToRowIndex(treeNode);
                        TreeGrid.UpdateDataRow(rowIndex);
                    }
                }
            }
        }
        internal void ChangeParentNodeExpander(TreeNode node)
        {
            var rowIndex = TreeGrid.ResolveToRowIndex(node);

            TreeGrid.UpdateDataRow(rowIndex);
        }
        void OnHyperLinkClick(object sender, EventArgs e)
#endif
        {
#if WPF
            Hyperlink hyperlinkControl;
            //Content is TetxBlock, so we need to get the Hyperlink from Inlines of TextBlock
            if (sender is TextBlock)
            {
                hyperlinkControl = (sender as TextBlock).Inlines.Cast <Hyperlink>().FirstOrDefault();
            }
            else
            {
                hyperlinkControl = (Hyperlink)sender;
            }
#else
            var hyperlinkControl = (HyperlinkButton)sender;
#endif
            TreeGridCell gridcell = null;
#if UWP
            if (hyperlinkControl.Parent is TreeGridCell)
            {
                gridcell = hyperlinkControl.Parent as TreeGridCell;
            }
#else
            if (hyperlinkControl.Parent is TextBlock)
            {
                var textBlock = hyperlinkControl.Parent as TextBlock;
                gridcell = textBlock.Parent as TreeGridCell;
            }
#endif
            var navigateText   = string.Empty;
            var rowColumnIndex = RowColumnIndex.Empty;
            rowColumnIndex.RowIndex    = gridcell != null ? gridcell.ColumnBase.RowIndex : new RowColumnIndex().RowIndex;
            rowColumnIndex.ColumnIndex = gridcell != null ? gridcell.ColumnBase.ColumnIndex : new RowColumnIndex().ColumnIndex;
            if (!rowColumnIndex.IsEmpty)
            {
                this.TreeGrid.SelectionController.HandlePointerOperations(new GridPointerEventArgs(PointerOperation.Pressed, null), rowColumnIndex);
                this.TreeGrid.SelectionController.HandlePointerOperations(new GridPointerEventArgs(PointerOperation.Released, null), rowColumnIndex);
            }
            if (hyperlinkControl.NavigateUri != null)
            {
                navigateText = hyperlinkControl.NavigateUri.ToString();
            }
            else
            {
                if (rowColumnIndex != null && !rowColumnIndex.IsEmpty)
                {
                    //Get the column from rowColumnIndex.
                    var column = this.TreeGrid.Columns[this.TreeGrid.ResolveToGridVisibleColumnIndex(rowColumnIndex.ColumnIndex)];
                    column.ColumnWrapper.DataContext = hyperlinkControl.DataContext;
                    if (column.ColumnWrapper.Value != null)
                    {
                        navigateText = column.ColumnWrapper.Value.ToString();
                    }
                }
            }

            if (TreeGrid.CurrentCellRequestNavigateEvent(new CurrentCellRequestNavigateEventArgs(TreeGrid)
            {
                NavigateText = navigateText, RowData = hyperlinkControl.DataContext, RowColumnIndex = rowColumnIndex
            }))
            {
                return;
            }
            const string pattern = @"((http|https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)";
            //the hyperlink value is stored in the variable navigateText.
            if (navigateText != null)
            {
                var NavigateUri = Regex.IsMatch(navigateText.ToString(), pattern)
                                  ? new Uri(navigateText.ToString())
                                  : null;
                if (NavigateUri == null)
                {
                    return;
                }

                hyperlinkControl.NavigateUri = NavigateUri;
#if WPF
                Process.Start(new ProcessStartInfo(hyperlinkControl.NavigateUri.AbsoluteUri));
#else
                if (e is KeyRoutedEventArgs && (e as KeyRoutedEventArgs).Key == Key.Space)
                {
                    await Launcher.LaunchUriAsync(new Uri(hyperlinkControl.NavigateUri.AbsoluteUri));
                }
#endif
            }
        }
        /// <summary>
        /// Sets the focus to the specified current cell uielement.
        /// </summary>
        /// <param name="uiElement">
        /// Specifies the corresponding current cell uielement.
        /// </param>
        /// <param name="needToFocus">
        /// Decides whether the focus set to current cell uielement.
        /// </param>
        protected virtual void SetFocus(FrameworkElement uiElement, bool needToFocus)
        {
            if (uiElement != null && IsFocusable)
            {
                UIElement uielement;
                var       focusedElement = FocusManagerHelper.GetFocusedUIElement(CurrentCellRendererElement);
                uielement = focusedElement ?? uiElement;

                TreeGridColumn column = null;
                if (needToFocus)
                {
                    var columnIndex = TreeGrid.ResolveToGridVisibleColumnIndex(CurrentCellIndex.ColumnIndex);
                    column = TreeGrid.Columns[columnIndex];
                }

                //SupportsRenderOptimization condition checked to move the Focus always to CheckBox instead of DataGrid - WPF-22403
                if (needToFocus && (IsInEditing || column.CanFocus() || !SupportsRenderOptimization))
                {
                    if (IsFocused)
                    {
#if WPF
                        if (!uielement.IsFocused)
                        {
                            uielement.Focusable = true;
                            Keyboard.Focus(uielement);
                        }
#endif
                        return;
                    }
#if WPF
                    uielement.Focus();
#else
                    if (uielement is Control)
                    {
                        (uielement as Control).Focus(FocusState.Programmatic);
                        isfocused = false;
                        return;
                    }
#endif
                    isfocused = true;
                }
                else
                {
#if WPF
                    this.TreeGrid.Focus();
#else
                    this.treeGrid.Focus(FocusState.Programmatic);
#endif
                    isfocused = false;
                }
            }
            else
            {
#if WPF
                TreeGrid.Focus();
#else
                TreeGrid.Focus(FocusState.Programmatic);
#endif
                isfocused = false;
            }
        }
Exemplo n.º 14
0
		public ActiveNodeHoldHelper(TreeGrid grid)
		{
			_grid = grid;
			_pathKey = GetActivePathKey();
		}
Exemplo n.º 15
0
        public GameWindow()
        {
            InitializeComponent();

            Application.Current.MainWindow        = this;
            Application.Current.MainWindow.Width  = 800;
            Application.Current.MainWindow.Height = 900;

            RowDefinition    mainrow1   = new RowDefinition();
            RowDefinition    mainrow2   = new RowDefinition();
            ColumnDefinition maincolumn = new ColumnDefinition();

            mainDivision.RowDefinitions.Add(mainrow1);
            mainDivision.RowDefinitions.Add(mainrow2);
            mainrow1.MaxHeight  = 50;
            mainrow1.MinHeight  = 50;
            maincolumn.MinWidth = 5000;


            //Creating the grid in the upper part of the Dockpanel;

            Grid.SetRow(counters, 0);
            Grid.SetColumn(counters, 0);
            counters.Background = Brushes.Black;

            ColumnDefinition counterColumn1 = new ColumnDefinition();
            ColumnDefinition counterColumn2 = new ColumnDefinition();
            ColumnDefinition counterColumn3 = new ColumnDefinition();
            ColumnDefinition counterColumn4 = new ColumnDefinition();
            ColumnDefinition counterColumn5 = new ColumnDefinition();

            counters.ColumnDefinitions.Add(counterColumn1);
            counters.ColumnDefinitions.Add(counterColumn2);
            counters.ColumnDefinitions.Add(counterColumn3);
            counters.ColumnDefinitions.Add(counterColumn4);
            counters.ColumnDefinitions.Add(counterColumn5);

            //Creating the texts to be shown in the upper grid;
            TextBlock timeText = new TextBlock();

            timeText.Text       = "Time";
            timeText.FontSize   = 24;
            timeText.Foreground = Brushes.DarkGreen;
            timeText.Width      = 300;
            Grid.SetColumn(timeText, 0);
            Grid.SetRow(timeText, 0);


            int timeRemaining = Mechanics.Mechanics.GetTime();

            timeCount.Text       = timeRemaining.ToString();
            timeCount.FontSize   = 24;
            timeCount.Foreground = Brushes.DarkGreen;
            timeCount.Width      = 100;
            Grid.SetColumn(timeCount, 1);
            Grid.SetRow(timeCount, 0);

            TextBlock pointText = new TextBlock();

            pointText.Text       = "Points";
            pointText.FontSize   = 24;
            pointText.Foreground = Brushes.DarkGreen;
            pointText.Width      = 300;
            Grid.SetColumn(pointText, 2);
            Grid.SetRow(pointText, 0);


            int pointsEarned = Mechanics.Mechanics.GetPoints();

            pointCount.Text       = pointsEarned.ToString();
            pointCount.FontSize   = 24;
            pointCount.Foreground = Brushes.DarkGreen;
            pointCount.Width      = 100;
            Grid.SetColumn(pointCount, 3);
            Grid.SetRow(pointCount, 0);

            ExitButton exit = new ExitButton();

            Grid.SetColumn(exit, 4);
            exit.Foreground = Brushes.Black;
            exit.Background = Brushes.DarkGreen;
            exit.Content    = "X";

            //Adding the created filling into the upper grid;
            counters.Children.Add(timeText);
            counters.Children.Add(timeCount);
            counters.Children.Add(pointText);
            counters.Children.Add(pointCount);
            counters.Children.Add(exit);

            //Adding the upper grid tot he upper Dockpanel
            mainDivision.Children.Add(counters);
            this.Content = mainDivision;

            //Creating the grid to the lower part, together with the buttons
            TreeGrid treeGrid = new TreeGrid(Mechanics.Mechanics.diffNum);

            Grid.SetRow(treeGrid, 1);
            mainDivision.Children.Add(treeGrid);

            this.Show();

            //Start the game
            Mechanics.Mechanics.GrowRandomTree();

            Console.WriteLine("Creating a timer?");
            //Create the timer
            //Create the Timer
            // 1) Create a class that contains what to do once the timer reaches one click
            TimeUp tu = new TimeUp(this);
            // 2) Create an autoresetevent that makes somethig to reset the timer and things like that. I dont get it yet...
            AutoResetEvent autoReset = new AutoResetEvent(false);
            // 3) Create the timer with the thing to do and the autoresetevent
            // 3.2) it also includes how many milisecs for the timer to start, and how many milisecs between clicks
            Timer gameTimer = new Timer(tu.Timer_Tick, autoReset, 1000, 1000);

            // Is this what to do once the timer should end?
            Console.WriteLine("And now we wait for the timer to end");
            autoReset.WaitOne();
            GameEnd end = new GameEnd();

            end.Show();
            this.Close();
            Console.WriteLine("Timer should have started");
        }
Exemplo n.º 16
0
			public TreeUpdateHelper(TreeGrid.TreeGrid treeGrid)
			{
				_treeGrid = treeGrid;
				_nodes = _treeGrid.Nodes;
				_activeNode = _treeGrid.ActiveNode;
				_treeGrid.Nodes = null;
			}
Exemplo n.º 17
0
 protected override void LoadState()
 {
     grid = ParseGrid();
 }