// crates note with one empty slide public Note(StackPanel panel, NoteWindow noteWindow) { this.panel = panel; this.noteWindow = noteWindow; // adding note title titleBox = new TitleBox(this); panel.Children.Add(titleBox); slidesList = new List <Slide>(); // adding "Add slide" button at the beggining var grid = new Grid(); ColumnDefinition gridCol1 = new ColumnDefinition(); ColumnDefinition gridCol2 = new ColumnDefinition(); grid.ColumnDefinitions.Add(gridCol1); grid.ColumnDefinitions.Add(gridCol2); grid.Height = 40; var addSlideButton = new Button(); addSlideButton.Height = 20; addSlideButton.Width = 400; addSlideButton.Content = "Add slide"; // use lambda expressions to pass slide number as argument to event handler // -1 means inserting slide at the beggining addSlideButton.Click += (sender, e) => AddSlide_Click(sender, e, -1); Grid.SetColumn(addSlideButton, 1); grid.Children.Add(addSlideButton); panel.Children.Add(grid); isSaved = true; }
public Note(StackPanel panel, string fileName, NoteWindow noteWindow) : this(panel, noteWindow) { this.fileName = fileName; IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); SavableNote savableNote = (SavableNote)formatter.Deserialize(stream); stream.Close(); titleBox.Text = savableNote.Title; noteWindow.Title = System.IO.Path.GetFileNameWithoutExtension(fileName) + " - NoteIt"; foreach (SavableSlide slide in savableNote.SlidesList) { AddSlideOnEnd(slide); } isPdfPresent = savableNote.IsPdfPresent; isSaved = true; }