private void newPencil_Click(object sender, RoutedEventArgs e) { try { PencilConfig config = new PencilConfig(); File.WriteAllText(Helper.NextAvailableFilename(Helper.TemplateFolder + $"\\{config.TemplateName}.pencil"), CreateConfigFile.Create(config)); refresh_Click(sender, e); } catch (Exception) { Helper.Error("Error", "Unable to create new template."); } }
private void ShowPreview(PencilConfig config) { // Set colors and text pencilBack.Background = config.Background.ToBrush(); pDevIcon.Source = new BitmapImage(new Uri(config.IconLocation, UriKind.RelativeOrAbsolute)); pDevName.Content = config.StaticName; pDevName.Foreground = config.DeviceNameTextForeground.ToBrush(); pDevStatus.Content = config.StatusText; pDevStatus.Foreground = config.StatusTextForeground.ToBrush(); pencilBack.Visibility = Visibility.Visible; cTint.Visibility = Visibility.Hidden; banner.Visibility = Visibility.Hidden; }
public static void Parse(string[] args) { Log.Information($"Got args {args[0]} and {args[1]}"); string ext = Path.GetExtension(args[0]).ToLower(); if (ext == ".pencil") { PencilConfig config = ConfigParser.ParseP(args[0]); if (string.IsNullOrEmpty(config.StaticName)) { config.StaticName = args[1]; } new Pencil(config).Show(); } else if (ext == ".notif") { NotificationConfig config = ConfigParser.ParseN(args[0]); if (string.IsNullOrEmpty(config.StaticName)) { config.StaticName = args[1]; } new Banner(config).Show(); } else if (ext == ".card") { CardConfig config = ConfigParser.ParseC(args[0]); if (string.IsNullOrEmpty(config.StaticName)) { config.StaticName = args[1]; } new Card(config).Show(); } else { new MainWindow(); } }
public Pencil(PencilConfig config) { // Set variables InitializeComponent(); timer = new Timer(); focused = Helper.ActiveWindowHandle; // Set colors and text background.Background = config.Background.ToBrush(); devIcon.Source = new BitmapImage(new Uri(config.IconLocation, UriKind.RelativeOrAbsolute)); devName.Content = config.StaticName; devName.Foreground = config.DeviceNameTextForeground.ToBrush(); devStatus.Content = config.StatusText; devStatus.Foreground = config.StatusTextForeground.ToBrush(); // Set timer to close after 5 seconds timer.Interval = 5000; timer.Elapsed += Timer_Elapsed; this.FadingBottom = false; // Set to middle of screen this.Left = (SystemParameters.WorkArea.Width / 2) - (this.Width / 2); }