コード例 #1
0
        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);

            title.Text = self.Name + " modules";

            back.Tapped += async(a, b) => {
                await CoreData.SaveTimetable((e.Parameter as object[])[0] as StudentDataBundle);

                Frame.Navigate(typeof(MainPage), (e.Parameter as object[])[0]);
            };


            foreach (Module mod in self.Modules)
            {
                ModuleBox box = new ModuleBox(mod, self.TileColor, holder.Children, self);
                holder.Children.Add(box);
            }

            add.Tapped += (q, b) =>
            {
                Module m = new Module {
                    Name = "New"
                };
                self.Modules.Add(m);
                ModuleBox box = new ModuleBox(m, self.TileColor, holder.Children, self);

                holder.Children.Add(box);
            };

            edit.Tapped += (a, b) =>
            {
                if ((edit.Foreground as SolidColorBrush).Color == Windows.UI.Colors.Black)
                {
                    foreach (ModuleBox box in holder.Children)
                    {
                        box.setEditable(false);
                    }
                    edit.Foreground = new SolidColorBrush(self.TileColor);
                }
                else
                {
                    foreach (ModuleBox box in holder.Children)
                    {
                        box.setEditable(true);
                    }
                    edit.Foreground = new SolidColorBrush(Windows.UI.Colors.Black);
                }
            };
        }
コード例 #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            self = e.Parameter as StudentDataBundle;//keep a reference to the timetable
            refresh();

            //go back to previous page
            back.Tapped += async(a, b) =>
            {
                await CoreData.SaveTimetable(self);

                Frame.Navigate(typeof(MainPage), self);
            };

            //create new course
            add.Tapped += (a, b) =>
            {
                self.Courses.Add(new Course {
                    Name = "New Class"
                });
                refresh();
            };
        }
コード例 #3
0
        /// <summary>
        /// handle file double clicking to import
        /// </summary>
        /// <param name="args"></param>
        protected async override void OnFileActivated(FileActivatedEventArgs args)
        {
            bool error = false;

            try
            {
                StudentDataBundle fileTable = new StudentDataBundle();
                StorageFile       file      = args.Files[0] as Windows.Storage.StorageFile;
                Stream            stream    = await file.OpenStreamForReadAsync();

                await Task.Run(() =>
                {
                    fileTable = CoreData.Serializer.Deserialize(stream) as StudentDataBundle;
                    CoreData.Timetables.Add(fileTable);
                });

                await CoreData.SaveTimetable(fileTable);

                var rootFrame = new Frame();
                rootFrame.Navigate(typeof(MainPage), fileTable);
                Window.Current.Content = rootFrame;
                MainPage p = rootFrame.Content as MainPage;

                Window.Current.Activate();
            }
            catch
            {
                error = true;
            }
            if (error)
            {
                //cannot await in catch clause , so a variable is needed
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog("Something is wrong with this file - or there already is a file with the same name", "We have a problem");
                await dialog.ShowAsync();
            }
        }
コード例 #4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            self = (e.Parameter as object[])[1] as Course;

            title.Foreground = new SolidColorBrush(self.TileColor);
            pin.Foreground   = new SolidColorBrush(self.TileColor);
            back.Foreground  = new SolidColorBrush(self.TileColor);
            add.Foreground   = new SolidColorBrush(self.TileColor);

            title.Text = self.Name + " notes";

            bool isPinned = false;

            foreach (SecondaryTile tl in await SecondaryTile.FindAllForPackageAsync())
            {
                if (tl.TileId == self.Name.Replace(" ", "") + "notes")
                {
                    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(" ", "") + "notes";
                tile.Logo            = logo;
                tile.ForegroundText  = ForegroundText.Light;
                tile.DisplayName     = "NotesEditor for " + self.Name;
                tile.ShortName       = self.Name + " notes";
                tile.TileOptions     = TileOptions.ShowNameOnLogo;
                tile.Arguments       = "notes," + ((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(NotesEditor));
            moduleHolder.OnChosen += (module) => refresh();
            refresh();



            add.Tapped += (q, b) =>
            {
                var note = new Note {
                    Name = "Click edit to enter a name"
                };
                moduleHolder.Chosen.Notes.Add(note);
                refresh();
            };

            holder.SelectionChanged += (a, b) =>
            {
                if (NotesHolder.Items.Count > 0)
                {
                    NotesHolder.SelectedIndex = holder.SelectedIndex;
                }
            };
        }
コード例 #5
0
        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);
                }
            };
        }
コード例 #6
0
 public async void Save()
 {
     await CoreData.SaveTimetable(self);
 }
コード例 #7
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            self = (e.Parameter as object[])[1] as Course;//keep for reference

            //set default values
            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";

            //Handle pinning to start screen
            bool isPinned = false;

            foreach (SecondaryTile tl in  await SecondaryTile.FindAllForPackageAsync())
            {
                if (tl.TileId == self.Name.Replace(" ", "") + "definitions")
                {
                    pin.Icon = "";
                    isPinned = true;
                }
            }

            pin.Tapped += async(a, b) =>
            {
                Uri           logo = new Uri("ms-appx:///Assets/TileLogo.png");    //icon
                SecondaryTile tile = new SecondaryTile();
                tile.BackgroundColor = self.TileColor;                             //course color
                tile.TileId          = self.Name.Replace(" ", "") + "definitions"; //unique id
                tile.Logo            = logo;
                tile.ForegroundText  = ForegroundText.Light;
                tile.DisplayName     = "DefinitionsEditor for " + self.Name;
                tile.ShortName       = self.Name + " definitions";
                tile.TileOptions     = TileOptions.ShowNameOnLogo;
                tile.Arguments       = "definitions," + ((e.Parameter as object[])[0] as StudentDataBundle).Name + "," + self.Name;//used to direct to appropiate page
                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]);
            };

            //this will enable filtering by module
            moduleHolder.fill(self, typeof(DefinitionsEditor));
            moduleHolder.OnChosen += (module) =>
            {
                refresh();
            };
            refresh();



            add.Tapped += (q, b) =>
            {
                Definition def = new Definition {
                    Caption = "Title here", Content = "Definition or explanation goes here!"
                };
                moduleHolder.Chosen.Definitions.Add(def);
                refresh();
            };

            //change the editable mode of each box
            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);
                }
            };
        }