public StructureBlockControl(StructureBlock block, Windows.UI.Color c, UIElementCollection container = null, Module module = null) { this.InitializeComponent(); root.Background = new SolidColorBrush(c); SetEditableItems(nameEdit); SetStaticItems(name); self = block; name.Text = self.Name; nameEdit.Text = self.Name; foreach (Topic topic in block.Topics) { TopicControl cont = new TopicControl(topic); topicsHolder.Children.Add(cont); cont.OnChange += () => OnChange(); cont.OnDelete += (tpC) => { self.Topics.Remove(tpC.self); topicsHolder.Children.Remove(tpC); // OnChange(); }; } addButton.Tapped += (e, ev) => { Topic topic = new Topic(); TopicControl cont = new TopicControl(topic); if (isEditable) { cont.setEditable(true); } topicsHolder.Children.Add(cont); self.Topics.Add(topic); //cont.OnChange += () => ; cont.OnDelete += (tpC) => { self.Topics.Remove(tpC.self); topicsHolder.Children.Remove(tpC); //OnChange(); }; }; deleteButton.Tapped += (e, ev) => { //OnDelete(this); container.Remove(this); module.StructureBlocks.Remove(self); }; nameEdit.TextChanged += (e, ev) => { Validator.isStringValid( target: nameEdit.Text, scope: "name", allowDigits: false, allowEmpty: true, max: Validator.StructureBlockNameMax, autoFix: true, fixTarget: nameEdit, autoNotify: true); name.Text = nameEdit.Text; self.Name = nameEdit.Text; }; }
protected async override void OnNavigatedTo(NavigationEventArgs e) { self = (e.Parameter as object[])[1] as Course; title.Foreground = new SolidColorBrush(self.TileColor); back.Foreground = new SolidColorBrush(self.TileColor); add.Foreground = new SolidColorBrush(self.TileColor); edit.Foreground = new SolidColorBrush(self.TileColor); pin.Foreground = new SolidColorBrush(self.TileColor); title.Text = self.Name + " definitions"; bool isPinned = false; foreach (SecondaryTile tl in await SecondaryTile.FindAllForPackageAsync()) { if (tl.TileId == self.Name.Replace(" ", "") + "topics") { pin.Icon = ""; isPinned = true; } } pin.Tapped += async(a, b) => { Uri logo = new Uri("ms-appx:///Assets/TileLogo.png"); SecondaryTile tile = new SecondaryTile(); tile.BackgroundColor = self.TileColor; tile.TileId = self.Name.Replace(" ", "") + "topics"; tile.Logo = logo; tile.ForegroundText = ForegroundText.Light; tile.DisplayName = "Topics for " + self.Name; tile.ShortName = self.Name + " topics"; tile.TileOptions = TileOptions.ShowNameOnLogo; tile.Arguments = "topics," + ((e.Parameter as object[])[0] as StudentDataBundle).Name + "," + self.Name; if (!isPinned) { isPinned = await tile.RequestCreateAsync(); pin.Icon = ""; } else { isPinned = !await tile.RequestDeleteAsync(); pin.Icon = ""; } }; back.Tapped += async(a, b) => { await CoreData.SaveTimetable((e.Parameter as object[])[0] as StudentDataBundle); Frame.Navigate(typeof(MainPage), (e.Parameter as object[])[0]); }; moduleHolder.fill(self, typeof(TopicsEditor)); moduleHolder.OnChosen += (module) => { refresh(); }; refresh(); add.Tapped += (q, b) => { StructureBlock bl = new StructureBlock(); moduleHolder.Chosen.StructureBlocks.Add(bl); refresh(); }; edit.Tapped += (a, b) => { if ((edit.Foreground as SolidColorBrush).Color == Windows.UI.Colors.Black) { foreach (EditableItem box in holder.Children) { box.setEditable(false); } edit.Foreground = new SolidColorBrush(self.TileColor); } else { foreach (EditableItem box in holder.Children) { box.setEditable(true); } edit.Foreground = new SolidColorBrush(Windows.UI.Colors.Black); } }; }