private void ButtonAdd_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = "Font files (*.ttf)|*.ttf|All files|*.*"; // Get the selected file name and display in a TextBox if (dlg.ShowDialog() == true) { // Open document string filename = dlg.FileName; string familyname = ""; foreach (FontFamily family in Fonts.GetFontFamilies(dlg.FileName)) { Debug.WriteLine(family.FamilyNames.Count + " " + family); foreach (KeyValuePair <XmlLanguage, string> sfamily in family.FamilyNames) { Debug.WriteLine(sfamily.Value); familyname = sfamily.Value; } } data.FontManager.Add(new Class.Save.FontPackage(File.ReadAllBytes(dlg.FileName), familyname)); } FontWorker.LoadFonts(data); AddFonts(); }
private void Window_Presentation_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (data.SaveOutput) { output.W = data.CanvasW; output.H = data.CanvasH; if (!String.IsNullOrWhiteSpace(Good_Teacher.MainWindow.pathtofile)) { SaveOutputData(); SaveEditor saveEditor = new SaveEditor(); string dirp = System.IO.Path.GetDirectoryName(Good_Teacher.MainWindow.pathtofile); Directory.CreateDirectory(dirp + "\\GT_Output\\"); saveEditor.SaveWithCompressionO(dirp + "\\GT_Output\\GT_" + DateTime.Now.Year + "_" + DateTime.Now.Month.ToString("00") + "_" + DateTime.Now.Day + "__" + DateTime.Now.Hour.ToString("00") + "_" + DateTime.Now.Minute.ToString("00") + ".gtout", output); } } mediaplayer.Stop(); dispatcherTimer_Timers.Stop(); dispatcherTimer_Timers.IsEnabled = false; FontWorker.RemoveTemporaryFolder(); }
private void MenuItem_New_Click(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = MessageBox.Show(Strings.ResStrings.NewProject, Strings.ResStrings.New, System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { BorderWindowSize.Visibility = Visibility.Collapsed; HistoryRedo.Clear(); HistoryUndo.Clear(); SelectedPosition = -1; SelectedControl = null; ValueEditor.Content = ""; data = new DataStore(); RemoveUnloadEvent(); DesignCanvas.Children.Clear(); Stack_TestList.Children.Clear(); DesignCanvas.Background = new SolidColorBrush(Colors.White); pathtofile = ""; BorderWindowSize.Width = 1282; BorderWindowSize.Height = 722; L_FileName.Content = ""; FontWorker.RemoveTemporaryFolder(); MainWindow.IsChanged = false; } }
private void DeleteFont_Click(object sender, MouseEventArgs e) { FontPackage fontp = (FontPackage)((StackPanel)((Control)sender).Tag).Tag; data.FontManager.Remove(fontp); AddFonts(); FontWorker.LoadFonts(data); }
public void Deserialize(Control cont) { cont.FontSize = fontsize; cont.FontStyle = fontStyle; cont.FontWeight = fontWeight; cont.FontFamily = fontFamily; if (!string.IsNullOrEmpty(cont.FontFamily.Source)) { FontFamily fontFamily; if (FontWorker.GetFontFamily(cont.FontFamily, out fontFamily)) { cont.FontFamily = fontFamily; } } }
public Label Create(DataStore data) { Label lab = new Label() { Margin = new System.Windows.Thickness(MarginLeft, 0, 0, 0), FontSize = fontsize }; if (ShowGood) { lab.Content = "" + MainWindow.GoodAnswersCount; } else { lab.Content = "" + MainWindow.WrongAnswersCount; } lab.VerticalAlignment = System.Windows.VerticalAlignment.Center; lab.Foreground = foreground.DeserializeToBrushWithKey(data); if (fontFamily != null) { lab.FontFamily = fontFamily; if (!string.IsNullOrEmpty(fontFamily.Source)) { FontFamily fontFamily; if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily)) { lab.FontFamily = fontFamily; } } } if (Bold) { lab.FontWeight = FontWeights.Bold; } if (Italic) { lab.FontStyle = FontStyles.Italic; } return(lab); }
public void OpenFile(string path) { try { SaveEditor save = new SaveEditor(); data = save.LoadWithCompression(path); SetWorkingFileLabel(path); LoadFileData(); pathtofile = path; BorderWindowSize.Width = data.CanvasW + 2; BorderWindowSize.Height = data.CanvasH + 2; CanvasW = data.CanvasW; CanvasH = data.CanvasH; FontWorker.LoadFonts(data); LoadCanvas(); IMG_StackCount = Stack_TestList.Children.Count; IMG_Work = false; IMG_Current = 0; IMG_dispatcherTimer = new DispatcherTimer(); IMG_dispatcherTimer.Tick += new EventHandler(IMG_dispatcherTimer_Tick); IMG_dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); IMG_dispatcherTimer.Start(); //UpdateCanvasIcon(); ScrollViewer_TestList.ScrollToHome(); MainWindow.IsChanged = false; } catch (Exception ex) { Debug.WriteLine(ex); MessageBox.Show(Strings.ResStrings.ErrorLoad, Strings.ResStrings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } }
public Label Create(DataStore data) { Label lab = new Label() { Content = (MainWindow.ActualPage + 1) - SubtractPages, Margin = new System.Windows.Thickness(MarginLeft, 0, 0, 0), FontSize = fontsize }; lab.VerticalAlignment = System.Windows.VerticalAlignment.Center; lab.Foreground = foreground.DeserializeToBrushWithKey(data); if (fontFamily != null) { lab.FontFamily = fontFamily; if (!string.IsNullOrEmpty(fontFamily.Source)) { FontFamily fontFamily; if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily)) { lab.FontFamily = fontFamily; } } } if (Bold) { lab.FontWeight = FontWeights.Bold; } if (Italic) { lab.FontStyle = FontStyles.Italic; } return(lab); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { CheckState(); ((FrameworkElement)Toolbar_Main.Template.FindName("OverflowGrid", Toolbar_Main)).Visibility = Visibility.Collapsed; //PreviewKeyDown += MainWindow_KeyDown; BorderWindowSize.Visibility = Visibility.Collapsed; timer = new DispatcherTimer(); timer.Tick += new EventHandler(Timer_Tick); timer.Interval = new TimeSpan(0, 0, 0, 5); timer.Start(); FontWorker.RemoveTemporaryFolder(); TempFilesWorker.RemoveUpdateFolder(); if (OpenFileARG) { OpenFile(OpenFileARGPath); } }
public MainWindow() { InitializeComponent(); if (!File.Exists("Data.gtchp")) { MessageBox.Show(Good_Teacher.Strings.ResStrings.ErrorRunData, Good_Teacher.Strings.ResStrings.Error); Application.Current.Shutdown(); } else { SaveEditor save = new SaveEditor(); data = save.LoadWithCompression("Data.gtchp"); Good_Teacher.MainWindow.pathtofile = AppDomain.CurrentDomain.BaseDirectory + "\\Data.gtchp"; FontWorker.LoadFonts(data); if (data.CacheCanvas) { PlayCanvas.CacheMode = new BitmapCache(1); } Good_Teacher.MainWindow.GoodAnswersCount = 0; Good_Teacher.MainWindow.WrongAnswersCount = 0; if (data.OptimizedMode) { Good_Teacher.MainWindow.OPTIMIZEDMODE = true; } else { Good_Teacher.MainWindow.OPTIMIZEDMODE = false; } Border_CanvasSize.Width = data.CanvasW; Border_CanvasSize.Height = data.CanvasH; PreviewMouseMove += Window_Presentation_PreviewMouseMove; currentC = 0; maxC = data.pages.Count; Label_Number.Content = "/" + maxC; UpdateNumberLabel(); LoadCanvas(0); dispatcherTimer.Tick -= DispatcherTimer_Tick; dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1); dispatcherTimer.IsEnabled = true; Timer_TimersLast = DateTime.Now.Ticks; dispatcherTimer_Timers.Tick -= DispatcherTimer_Timers_Tick; dispatcherTimer_Timers.Tick += DispatcherTimer_Timers_Tick; dispatcherTimer_Timers.Interval = new TimeSpan(0, 0, 0, 0, 100); dispatcherTimer_Timers.IsEnabled = true; dispatcherTimerTransition.Tick -= DispatcherTimerTransition_Tick; dispatcherTimerTransition.Tick += DispatcherTimerTransition_Tick; dispatcherTimerTransition.Interval = TimeSpan.FromMilliseconds(data.pages[LoadedPage].TransitionMove); dispatcherTimerTransition.IsEnabled = (data.pages[LoadedPage].transitionType != Good_Teacher.Class.Enumerators.TransitionTypeEnum.TransitionType.Manual); if (data.BlockPresentationInput) { ControlPanelC.Visibility = Visibility.Collapsed; } if (data.HideInput) { SP_InputControls.Visibility = Visibility.Collapsed; } MainGrid.Background = data.OutsideBrush; this.ResizeMode = ResizeMode.NoResize; this.WindowStyle = WindowStyle.None; this.WindowState = WindowState.Maximized; Closing += Window_Presentation_Closing; mediaplayer.MediaEnded += Mediaplayer_MediaEnded; Activate(); ContentRendered += MainWindow_ContentRendered; } }
public void AddFonts() { SP_Fonts.Children.Clear(); foreach (FontPackage fontp in data.FontManager) { StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; Image image = new Image(); image.Width = 48; image.Height = 48; image.Source = new BitmapImage(new Uri("pack://*****:*****@"pack://application:,,,/Resources/Icons/DeleteFill.png")), VerticalAlignment = VerticalAlignment.Center, Width = 20, Height = 20 }; Delete.Click += DeleteFont_Click; Delete.Margin = new Thickness(10, 0, 0, 0); Delete.DefaultBrush = null; Delete.Hover = new SolidColorBrush(Color.FromRgb(240, 98, 146)); Delete.ClickBrush = new SolidColorBrush(Color.FromRgb(233, 30, 99)); Delete.Height = 24; Delete.Width = 24; Delete.Tag = stackPanel; Delete.VerticalContentAlignment = VerticalAlignment.Center; stackPanel.Children.Add(image); stackPanel.Children.Add(label); stackPanel.Children.Add(label2); stackPanel.Children.Add(Delete); stackPanel.Tag = fontp; SP_Fonts.Children.Add(stackPanel); } }
}//ToSerializableCanvas public static void ExtractHiddenData(DataStore data, Canvas canvas, int pos) { if ((int)data.BitmapScalingMode != 1) { RenderOptions.SetBitmapScalingMode(canvas, data.BitmapScalingMode); } if (data.pages[pos].IsImageBrush) { canvas.Background = new ImageBrush(data.archive.GetImage(data.pages[pos].ImageBrush.Path)); ((ImageBrush)canvas.Background).Stretch = data.pages[pos].ImageBrush.stretch; } else if (data.pages[pos].CustomBrush && !String.IsNullOrWhiteSpace(data.pages[pos].canvasbrush)) { canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.pages[pos].canvasbrush); } else { if (data.IsImageBrush) { canvas.Background = new ImageBrush(data.archive.GetImage(data.ImageBrush.Path)); ((ImageBrush)canvas.Background).Stretch = data.ImageBrush.stretch; } else if (!String.IsNullOrEmpty(data.AllBackground)) { canvas.Background = (Brush)SaveEditor.XMLDeserialize(data.AllBackground); } else { canvas.Background = new SolidColorBrush(Colors.White); } } foreach (FrameworkElement frw in canvas.Children) { if (frw is Image) { Image img = (Image)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { img.Source = new BitmapImage(new Uri("pack://application:,,,/Good Teacher;Component/Resources/Controls/image.png")); } else { DesignSave designSave = DesignSave.Deserialize(img.Tag.ToString()); designSave.ToImage(data, img); } } else if (frw is Shape) { Shape shape = (Shape)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(shape.Tag.ToString()); designSave.ToShape(data, shape); } } else if (frw is Label || frw is CheckBox || frw is RadioButton) { Control control = (Control)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString()); designSave.ToControlWithForeground(data, control); } if (control.FontFamily.BaseUri != null && control.FontFamily.Source != null) { Debug.WriteLine("Ffontfamilysource: " + control.FontFamily.Source); string fontfamilyloc = ""; string fontfamilyfile = ""; if (control.FontFamily.Source.Length >= 5) { fontfamilyloc = control.FontFamily.Source.Substring(0, 3); fontfamilyfile = control.FontFamily.Source.Substring(0, 5); } if (!string.IsNullOrWhiteSpace(control.FontFamily.Source) && (fontfamilyloc == "./#" || fontfamilyfile == "file:")) { //Debug.WriteLine("-------------------\nBU: " + control.FontFamily.BaseUri + "\nFF: " + control.FontFamily + "\nAP: " + control.FontFamily.BaseUri.AbsolutePath + "\nAU: " + control.FontFamily.BaseUri.AbsoluteUri + "\nH: " + control.FontFamily.BaseUri.Host + "\nS: " + control.FontFamily.Source + "\n********\n"); FontFamily fontFamily; if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily)) { control.FontFamily = fontFamily; } } } } else if (frw is MediaPlayer_Control) { //Nothing } else if (frw is Control) { Control control = (Control)frw; if (frw.Tag == null || String.IsNullOrWhiteSpace(frw.Tag.ToString())) { } else { DesignSave designSave = DesignSave.Deserialize(control.Tag.ToString()); designSave.ToControl(data, control); } if (control.FontFamily.BaseUri != null) { //Debug.WriteLine(""+ control.FontFamily.BaseUri+ " "+ control.FontFamily+" AP: "+control.FontFamily.BaseUri.AbsolutePath+" AU: "+control.FontFamily.BaseUri.AbsoluteUri+" H: "+control.FontFamily.BaseUri.Host+ " S: "+control.FontFamily.Source); FontFamily fontFamily; if (FontWorker.GetFontFamily(control.FontFamily, out fontFamily)) { control.FontFamily = fontFamily; } } } } DeserializeCustomControls(data, canvas, pos); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { FontWorker.RemoveTemporaryFolder(); }
public Label Create(DataStore data) { Label lab = new Label() { Margin = new System.Windows.Thickness(MarginLeft, 0, 0, 0), FontSize = fontsize }; switch (showDateType) { case ShowDateType.Second: lab.Content = "" + DateTime.Now.Second; break; case ShowDateType.Minute: lab.Content = "" + DateTime.Now.Minute; break; case ShowDateType.Hour: lab.Content = "" + DateTime.Now.Hour; break; case ShowDateType.Day: lab.Content = "" + DateTime.Now.Day; break; case ShowDateType.DayOfYear: lab.Content = "" + DateTime.Now.DayOfYear; break; case ShowDateType.Month: lab.Content = "" + DateTime.Now.Month; break; case ShowDateType.Year: lab.Content = "" + DateTime.Now.Year; break; default: lab.Content = "" + DateTime.Now; break; } lab.VerticalAlignment = System.Windows.VerticalAlignment.Center; lab.Foreground = foreground.DeserializeToBrushWithKey(data); if (fontFamily != null) { lab.FontFamily = fontFamily; if (!string.IsNullOrEmpty(fontFamily.Source)) { FontFamily fontFamily; if (FontWorker.GetFontFamily(lab.FontFamily, out fontFamily)) { lab.FontFamily = fontFamily; } } } if (Bold) { lab.FontWeight = FontWeights.Bold; } if (Italic) { lab.FontStyle = FontStyles.Italic; } return(lab); }