public PageEditor(PageStorage newPage, bool multi, Int32Rect clip, int messageNum, string messageName, int pageNum, int totalPages) { Page = newPage; InitializeComponent(); if (!multi) MessageTime.IsEnabled = false; Title = "MyFaPixel - Page Editor - " + messageName + " №" + messageNum + " - page №" + (pageNum + 1) + " (total " + totalPages + " pages)"; SelectedMessagePreview = new PagePreview(Settings.Default.DisplayWidth, Settings.Default.DisplayHeight, clip); SelectedMessagePreview.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; PagePreviewScroll.Content = SelectedMessagePreview; string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\MyFaPixel\Fonts"; if (!Directory.Exists(path)) Directory.CreateDirectory(path); DirectoryInfo tmpDI = new DirectoryInfo(path); FileInfo[] tmpFI = tmpDI.GetFiles("*.mfpf"); foreach (FileInfo tmpFont in tmpFI) { ComboBoxItem tmpItem = new ComboBoxItem(); tmpItem.Content = tmpFont.Name.Substring(0, tmpFont.Name.Length - 5); if (Page != null && Page.Strings[0].Font == (string)tmpItem.Content) MessageFont.SelectedItem = tmpItem.Content; MessageFont.Items.Add(tmpItem); } if (MessageFont.Items.Count == 0) { fontsFound = false; ComboBoxItem tmpItem = new ComboBoxItem(); tmpItem.Content = "no fonts found"; MessageFont.Items.Add(tmpItem); } else fontsFound = true; if (MessageFont.SelectedItem == null) MessageFont.SelectedIndex = 0; if (Page != null) { if (multi) MessageTime.Text = Page.Time.ToString(); MessageText.Text = Page.Strings[0].Text; Indent = Page.Strings[0].Indent; Shift = Page.Strings[0].Shift; VShift = Page.Strings[0].VShift; } Initialized = true; MessageChanged(); }
private void InitializeAll() { AllInitialized = false; SelectedMessagePreview = new PagePreview(Settings.Default.DisplayWidth, Settings.Default.DisplayHeight, new Int32Rect(0, 0, Settings.Default.DisplayWidth, Settings.Default.DisplayHeight)); SelectedMessagePreview.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; PagePreviewScroll.Content = SelectedMessagePreview; ComboBoxItem tmpItem; LineSelector.Items.Clear(); for (int i = 0; i < Settings.Default.MessageLinesCount; ++i) { tmpItem = new ComboBoxItem(); tmpItem.Content = i + " line"; if (ExistsLine(i)) tmpItem.Background = ItemExists; LineSelector.Items.Add(tmpItem); UpdateLineText(i); } DestinationSelector.Items.Clear(); for (int i = 0; i < Settings.Default.MessageDestinationsCount; ++i) { tmpItem = new ComboBoxItem(); tmpItem.Content = i + " destination"; if (ExistsDestination(i)) tmpItem.Background = ItemExists; DestinationSelector.Items.Add(tmpItem); UpdateDestinationText(i); } StopSelector.Items.Clear(); for (int i = 0; i < Settings.Default.MessageStopsCount; ++i) { tmpItem = new ComboBoxItem(); tmpItem.Content = i + " stop"; if (ExistsStop(i)) tmpItem.Background = ItemExists; StopSelector.Items.Add(tmpItem); UpdateStopText(i); } DestinationPageSelector.Items.Clear(); StopPageSelector.Items.Clear(); for (int i = 0; i < Settings.Default.MessagePageCount; ++i) { tmpItem = new ComboBoxItem(); tmpItem.Content = (i + 1) + " page"; DestinationPageSelector.Items.Add(tmpItem); UpdateDestinationPageText(0, i); tmpItem = new ComboBoxItem(); tmpItem.Content = (i + 1) + " page"; StopPageSelector.Items.Add(tmpItem); UpdateStopPageText(0, i); } LineSelector.SelectedIndex = 0; DestinationSelector.SelectedIndex = 0; StopSelector.SelectedIndex = 0; DestinationPageSelector.SelectedIndex = 0; StopPageSelector.SelectedIndex = 0; PagePreviewScroll.Visibility = System.Windows.Visibility.Visible; PreviewSelectScroll.Visibility = System.Windows.Visibility.Visible; AllInitialized = true; }