Example #1
0
        private void Node_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            ParentRow.Invalidate();

            if (e.PropertyName == "PercentComplete")
            {
                if (_PercentCompleteElement == null)
                {
                    return;
                }

                PercentCompleteWidth = (Node.PercentComplete / 100) * NodeWidth;

                _PercentCompleteElement.Width = PercentCompleteWidth;
                if (_PercentCompleteElement.Width == 0)
                {
                    _OriginalPercentCompleteElementHeight = _PercentCompleteElement.Height;
                    _PercentCompleteElement.Height        = 0;
                }
                else if (_OriginalPercentCompleteElementHeight > 0)
                {
                    _PercentCompleteElement.Height = _OriginalPercentCompleteElementHeight;
                }
            }
        }
Example #2
0
    public static void AddInitialEmptyRows(DataSet ds, StringCollection rootTables)
    {
        //if root table is totally empty, create an initial row so that the grids show up and are ready to add the first entry
        foreach (string r in rootTables)
        {
            DataTable t = ds.Tables[r];
            if (t.Rows.Count == 0)
            {
                AddNewRowWithPK(t);
            }
        }

        //now walk the relationships and create initial CHILD rows where necessary
        foreach (DataRelation rel in ds.Relations)
        {
            foreach (DataRow ParentRow in rel.ParentTable.Rows)
            {
                if (ParentRow.GetChildRows(rel).Length == 0)
                {
                    DataRow ChildRow = AddNewRowWithPK(rel.ChildTable);
                    //fill out the foreign-key
                    ChildRow[rel.ChildKeyConstraint.Columns[0].ColumnName] = ParentRow[rel.ChildKeyConstraint.RelatedColumns[0].ColumnName];
                }
            }
        }
    }
Example #3
0
File: Row.cs Project: lzroc/Vixen
 internal void InvalidateRowLabel()
 {
     if (Visible)
     {
         RowLabel.Invalidate();
     }
     ParentRow?.InvalidateRowLabel();
 }
Example #4
0
        private Column GetColumn()
        {
            ColumnList columns     = ParentRow?.ParentDataGrid?.Columns;
            int?       columnIndex = ParentRow?.IndexOfCell(this);

            return(columns != null && columnIndex.HasValue
                ? ParentRow?.ParentDataGrid?.Columns[columnIndex.Value]
                : null);
        }
Example #5
0
File: Row.cs Project: lzroc/Vixen
        public string TreePathName()
        {
            if (ParentRow == null)
            {
                return(Name);
            }

            return(Name + ParentRow.TreePathName());
        }
Example #6
0
        /// <summary>
        /// This is a hash id based on its position in the tree. It is based on the hash of it's name and all it's parents.
        /// This should provide a pretty unique that is fairly static for restoring row settings. This can change if the user
        /// restructures the group, but then the settings are probably not valid anyway.
        /// </summary>
        /// <returns></returns>
        public double TreeId()
        {
            if (ParentRow == null)
            {
                return(Name.GetHashCode());
            }

            return(Name.GetHashCode() + ParentRow.TreeId());
        }
Example #7
0
        public void ExampleJoining()
        {
            var numbersAlpha          = new int[] { 1, 2, 3 };
            var numbersBravo          = new int[] { 2, 4 };
            var numbersExcludingBravo = numbersAlpha.Except(numbersBravo);
            var products = new Product[]
            {
                new Product()
                {
                    Id = 1, Name = "One"
                },
                new Product()
                {
                    Id = 2, Name = "Two"
                }
            };
            var productsDiscontinued = new Product[]
            {
                new Product()
                {
                    Id = 2, Name = "Two"
                }
            };
            var productsAvailable = products.Except(productsDiscontinued);
            var numbersInBothSets = numbersAlpha.Intersect(numbersBravo);

            var infos = new PlayerInfo[]
            {
                new PlayerInfo()
                {
                    PlayerId = 1, Name = "Name1", CreatedDate = DateTime.Parse("01/01/2001")
                },
                new PlayerInfo()
                {
                    PlayerId = 2, Name = "Name2", CreatedDate = DateTime.Parse("02/02/2002")
                },
                new PlayerInfo()
                {
                    PlayerId = 7, Name = "Name7", CreatedDate = DateTime.Parse("07/07/2007")
                }
            };
            var metadatas = new PlayerMetadata[]
            {
                new PlayerMetadata()
                {
                    PlayerId = 1, Tags = new string[] { "strong slow" }
                },
                new PlayerMetadata()
                {
                    PlayerId = 2, Tags = new string[] { "weak fast" }
                },
                new PlayerMetadata()
                {
                    PlayerId = 8, Tags = new string[] { "tall smart" }
                }
            };
            var joinedPlayers = infos.Join(metadatas, i => i.PlayerId, m => m.PlayerId, (i, m) => new Player()
            {
                Id          = i.PlayerId,
                Name        = i.Name,
                CreatedDate = i.CreatedDate,
                Tags        = m.Tags
            });

            var parents = new ParentRow[]
            {
                new ParentRow()
                {
                    ParentId = 1, ParentName = "Parent1"
                },
                new ParentRow()
                {
                    ParentId = 2, ParentName = "Parent2"
                }
            };
            var children = new ChildRow[]
            {
                new ChildRow()
                {
                    ChildId = 1, ParentId = 1, ChildName = "Child1"
                },
                new ChildRow()
                {
                    ChildId = 2, ParentId = 1, ChildName = "Child2"
                },
                new ChildRow()
                {
                    ChildId = 3, ParentId = 2, ChildName = "Child3"
                },
                new ChildRow()
                {
                    ChildId = 4, ParentId = 2, ChildName = "Child4"
                }
            };

            var joinedFamily = parents.Join(children, p => p.ParentId, c => c.ParentId, (p, c) => new
            {
                Parent = p,
                Child  = c
            });
            var joinedFamilyMessageBuilder = new StringBuilder();

            foreach (var relationship in joinedFamily)
            {
                var line = relationship.Parent.ParentName + ":" + relationship.Child.ChildName;
                joinedFamilyMessageBuilder.AppendLine(line);
            }
            var joinedFamilyMessage = joinedFamilyMessageBuilder.ToString();

            var groupJoinedFamily = parents.GroupJoin(children, p => p.ParentId, c => c.ParentId, (p, c) => new
            {
                Parent   = p,
                Children = c
            });
            var groupJoinedFamilyMessageBuilder = new StringBuilder();

            foreach (var parent in groupJoinedFamily)
            {
                var childrensNames = String.Join(",", parent.Children.Select(c => c.ChildName));
                var line           = parent.Parent.ParentName + ":" + childrensNames;
                groupJoinedFamilyMessageBuilder.AppendLine(line);
            }
            var groupJoinedFamilyMessage = groupJoinedFamilyMessageBuilder.ToString();

            var numbers             = new int[] { 1, 2, 3, 4, 5 };
            var groups              = numbers.GroupBy(n => n % 2 == 0);
            var groupMessageBuilder = new StringBuilder();

            foreach (var group in groups)
            {
                var line = (group.Key ? "Even" : "Odd") + ":" + String.Join(",", group);
                groupMessageBuilder.AppendLine(line);
            }
            var groupMessage = groupMessageBuilder.ToString();

            var animals = new Animal[]
            {
                new Animal()
                {
                    Id = 1, Species = "Dog", Age = 7
                },
                new Animal()
                {
                    Id = 2, Species = "Cat", Age = 3
                },
                new Animal()
                {
                    Id = 3, Species = "Cat", Age = 6
                },
                new Animal()
                {
                    Id = 4, Species = "Cat", Age = 3
                },
                new Animal()
                {
                    Id = 5, Species = "Dog", Age = 6
                }
            };
            var animalSummaryBuilder = new StringBuilder();
            var animalsByAge         = animals.GroupBy(a => a.Age);

            foreach (var ageGroup in animalsByAge)
            {
                animalSummaryBuilder.AppendLine($"Animals Age {ageGroup.Key}");
                foreach (var animal in ageGroup)
                {
                    var line = $"\tId:{animal.Id}:Species:{animal.Species}";
                    animalSummaryBuilder.AppendLine(line);
                }
            }
            var animalsBySpecies = animals.GroupBy(a => a.Species);

            foreach (var speciesGroup in animalsBySpecies)
            {
                animalSummaryBuilder.AppendLine($"{speciesGroup.Key}s");
                foreach (var animal in speciesGroup)
                {
                    var line = $"\tId:{animal.Id}:Age:{animal.Age}";
                    animalSummaryBuilder.AppendLine(line);
                }
            }
            var animalSummary = animalSummaryBuilder.ToString();
        }
Example #8
0
 private async Task OnClickHandlerAsync(MouseEventArgs args)
 {
     ParentRow.OnActiveToggle();
     await OnClick.InvokeAsync(args);
 }