private void Ok_Click(object sender, RoutedEventArgs e) { ScreenTemplate = new ScreenTemplate() { Title = title.Text }; for (int i = 4; i < StackPanel.Children.Count; i += 2) { if ((StackPanel.Children[i] as ScreenTemplateElementControl).IsPlaylistScreen.IsChecked == false) { ScreenTemplate.ScreenTemplateElements.Add(new ScreenTemplateElement() { Path = (StackPanel.Children[i] as ScreenTemplateElementControl).ElementPath, ScreenNumber = ScreenTemplate.ScreenTemplateElements.Count }); } else if ((StackPanel.Children[i] as ScreenTemplateElementControl).IsPlaylistScreen.IsChecked == true) { ScreenTemplate.ScreenTemplateElements.Add(new ScreenTemplateElement() { Path = ((StackPanel.Children[i] as ScreenTemplateElementControl).PlaylistScreen.SelectedItem as Playlist).JsonString(), IsPlaylist = true, ScreenNumber = ScreenTemplate.ScreenTemplateElements.Count }); } } this.DialogResult = true; }
public ChangeTemplateWindow(ScreenTemplate screenTemplate) { InitializeComponent(); ScreenTemplate = screenTemplate; title.Text = screenTemplate.Title; screen1.Text = screenTemplate.Screen1; screen2.Text = screenTemplate.Screen2; screen3.Text = screenTemplate.Screen3; screen4.Text = screenTemplate.Screen4; screen5.Text = screenTemplate.Screen5; screen6.Text = screenTemplate.Screen6; }
private void Ok_Click(object sender, RoutedEventArgs e) { ScreenTemplate = new ScreenTemplate() { Screen1 = screen1.Text, Screen2 = screen2.Text, Screen3 = screen3.Text, Screen4 = screen4.Text, Screen5 = screen5.Text, Screen6 = screen6.Text, Title = title.Text }; this.DialogResult = true; }
private void removeTemplate_Click(object sender, RoutedEventArgs e) { if (templateList.SelectedItems.Count > 0) { var selectedTemplate = templateList.SelectedItem; using (TemplateContext db = new TemplateContext()) { if (selectedTemplate != null) { ScreenTemplate screenTemplate = db.ScreenTemplates.Where(x => x.Id == (selectedTemplate as ScreenTemplate).Id).FirstOrDefault(); db.ScreenTemplates.Remove(screenTemplate); } db.SaveChanges(); var templates = db.ScreenTemplates.ToList(); templateList.ItemsSource = templates; } } }
public ChangeTemplateWindow(ScreenTemplate screenTemplate) { InitializeComponent(); ScreenTemplate = screenTemplate; ScreenTemplate.ScreenTemplateElements.Sort(new ScreenTemplateElementCopm()); title.Text = screenTemplate.Title; for (int i = 4; i < StackPanel.Children.Count; i += 2) { if (screenTemplate.ScreenTemplateElements[(i - 4) / 2].IsPlaylist) { (StackPanel.Children[i] as ScreenTemplateElementControl).IsPlaylistScreen.IsChecked = true; dynamic tmp = JsonConvert.DeserializeObject(screenTemplate.ScreenTemplateElements[(i - 4) / 2].Path); (StackPanel.Children[i] as ScreenTemplateElementControl).ElementDefaultId = tmp.id; } else { (StackPanel.Children[i] as ScreenTemplateElementControl).ElementPathBox.Text = screenTemplate.ScreenTemplateElements[(i - 4) / 2].Path; } } }
async private void TemplateButton_Click(object sender, RoutedEventArgs e) { if (MainGrid.Children[2].GetType() != Type.GetType("Six_Screens_Controller.view.TemplatesPageView")) { if (MainGrid.Children[2].GetType() == Type.GetType("Six_Screens_Controller.view.PlaylistsPageView")) { (MainGrid.Children[2] as PlaylistsPageView).IsDestroy = true; } TemplatesPageView templatesPageControl = new TemplatesPageView(); Grid.SetColumn(templatesPageControl, 2); MainGrid.Children.RemoveAt(2); MainGrid.Children.Insert(2, templatesPageControl); ((MainGrid.Children[0] as Grid).Children[1] as Button).Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ((MainGrid.Children[0] as Grid).Children[3] as Button).Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ((MainGrid.Children[0] as Grid).Children[2] as Button).Background = new SolidColorBrush(Color.FromRgb(197, 197, 197)); await Task.Run(() => { while (!templatesPageControl.IsDestroy) { if (templatesPageControl.IsChangeTemplate) { screensPage.IsChangedTemplate = true; Thread.Sleep(2); ScreenTemplateNow = templatesPageControl.ScreenTemplate; Application.Current.Dispatcher.Invoke(() => { templatesPageControl.IsChangeTemplate = false; if (ScreenTemplateNow != null) { screensPage.SetScreenTemplate(ScreenTemplateNow); } }); } Thread.Sleep(100); } }); } }