public override void ItemStarted(TrackItem sender, TimingEventArgs e) { soundPlayer.Open(new Uri(sender.OriginalPath)); soundPlayer.Play(); soundPlayer.Position = MediaTools.FrameToTimeSpan(e.Frame, e.TimeLine.FrameRate); //Console.WriteLine($"At {e.Frame} Sound Started!!!!!!!!!!!!!!!"); }
private void Source_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { var item = FileCacheDictionary.GetPathFromId(DownloadingSource.Id); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Delight", "External Sources Cache", item.Value.Item1); GlobalViewModel.MainWindowViewModel.MediaItems.Add(new VideoMedia() { Identifier = item.Key, Time = MediaTools.GetMediaDuration(path), Path = path, Thumbnail = new Uri(DownloadingSource.ThumbnailUri), FromYoutube = true, DownloadID = DownloadingSource.Id, Id = DownloadingSource.Id, }); }
private void LoadCheck() { if (_allVideos.Count == 0) { return; } TrackItem item = _allVideos.Peek(); if ((item.Offset - TimeLine.Position) < MediaTools.TimeSpanToFrame(TimeSpan.FromSeconds(10), TimeLine.FrameRate)) { Console.WriteLine("Should be Load!" + item.OriginalPath); _loadWaitVideos.Enqueue(item); _allVideos.Dequeue(); } }
public override void ItemPlaying(TrackItem sender, TimingEventArgs e) { if (!Items.Contains(sender)) { Items.Add(sender); PlayPlayer(sender); Console.WriteLine($"{sender.Text} item Playing"); } if (sender == CurrentPlayer.GetTag <TrackItem>()) { int currentFrame = e.Frame - sender.Offset + sender.ForwardOffset; if (lastFrame + 1 != currentFrame) { CurrentPlayer.Position = MediaTools.FrameToTimeSpan(currentFrame, CurrentFrameRate); } lastFrame = e.Frame - sender.Offset + sender.ForwardOffset; } }
public static StageComponent ConvertToComponent(BaseSource source) { if (source is ExternalVideoSource externalVideoSource) { return(new VideoMedia() { FromYoutube = false, Id = source.Id, Path = externalVideoSource.FullPath, Time = MediaTools.GetMediaDuration(externalVideoSource.FullPath), Thumbnail = ((BitmapImage)MediaTools.GetMediaThumbnail(externalVideoSource.FullPath)).UriSource, Identifier = externalVideoSource.Title, }); } else if (source is YoutubeSource youtubeSource) { source.Download(0); var item = FileCacheDictionary.GetPathFromId(source.Id); string path = Path.Combine(DelightAppPath, "External Sources Cache", item.Value.Item1); return(new VideoMedia() { Identifier = item.Key, Time = MediaTools.GetMediaDuration(path), Path = path, Thumbnail = new Uri(source.ThumbnailUri), FromYoutube = true, DownloadID = source.Id, Id = source.Id, }); } else if (source is LightSource lightSource) { return(new LightComponent(BoardSerializer.LoadFromString(lightSource.MovingData))); } return(null); }
public static void DrawPoziomOdpaduChart() { if (DataContainer.guiState == null) { return; } LiveCharts.WinForms.CartesianChart poziomOdpaduChart = DataContainer.poziomOdpaduChart; poziomOdpaduChart.Series.Clear(); poziomOdpaduChart.AxisX.Clear(); poziomOdpaduChart.AxisY.Clear(); var finishedOrders = DataContainer.sqlDataByOrder.Where(order => order.Value.kitting.endDate >= DataContainer.guiState.viTabs.poziomOdpaduTab.startDate && order.Value.kitting.endDate <= DataContainer.guiState.viTabs.poziomOdpaduTab.endDate); if (!DataContainer.guiState.viTabs.poziomOdpaduTab.lgOrders) { finishedOrders = finishedOrders.Where(order => order.Value.kitting.odredGroup != "LG"); } if (!DataContainer.guiState.viTabs.poziomOdpaduTab.mstOrders) { finishedOrders = finishedOrders.Where(order => order.Value.kitting.odredGroup != "MST"); } var sortedOrders = finishedOrders.OrderBy(o => o.Value.kitting.endDate); string lineKey = DataContainer.guiState.viTabs.poziomOdpaduTab.cumulatedLines ? "Skumulowany" : "Po linii"; string[] selectedLines = DataContainer.guiState.viTabs.poziomOdpaduTab.selectedLines; Dictionary <string, Dictionary <string, WastePerPointStruct> > chartPoints = new Dictionary <string, Dictionary <string, WastePerPointStruct> >(); foreach (var smtLine in selectedLines) { chartPoints.Add(smtLine, new Dictionary <string, WastePerPointStruct>()); } foreach (var orderEntry in sortedOrders) { if (orderEntry.Value.smt.totalManufacturedQty == 0) { continue; } if (lineKey != "Skumulowany") { lineKey = orderEntry.Value.smt.smtOrders[0].smtLine; if (!selectedLines.Contains(lineKey)) { continue; } } string dateKey = GetDateKey(DataContainer.guiState.viTabs.poziomOdpaduTab.timeInterval, orderEntry.Value.kitting.endDate); foreach (var lineEntry in chartPoints) { if (!chartPoints[lineEntry.Key].ContainsKey(dateKey)) { chartPoints[lineEntry.Key].Add(dateKey, new WastePerPointStruct()); } } chartPoints[lineKey][dateKey].totalProduction += orderEntry.Value.smt.totalManufacturedQty; chartPoints[lineKey][dateKey].totalNg += orderEntry.Value.visualInspection.ngCount; chartPoints[lineKey][dateKey].totalScrap += orderEntry.Value.visualInspection.scrapCount; } SeriesCollection seriesCollection = new SeriesCollection(); ChartValues <float> totalProdValues = new ChartValues <float>(); List <string> labels = new List <string>(); foreach (var dateEntry in chartPoints[chartPoints.Select(k => k.Key).First()]) { labels.Add(dateEntry.Key); totalProdValues.Add(0); } foreach (var lineEntry in chartPoints) { int day = 0; foreach (var dateKey in labels) { totalProdValues[day] += lineEntry.Value[dateKey].totalProduction; day++; } } ColumnSeries totalProductionSeries = new ColumnSeries(); totalProductionSeries.Fill = new SolidColorBrush { Color = System.Windows.Media.Color.FromArgb(255, 50, 50, 50), Opacity = .4 }; totalProductionSeries.ScalesYAt = 0; totalProductionSeries.Values = totalProdValues; totalProductionSeries.Title = "Produkcja"; Axis axX = new Axis(); axX.Labels = labels; Axis axY1 = new Axis(); axY1.Position = AxisPosition.RightTop; axY1.Separator.IsEnabled = false; Axis axY2 = new Axis(); poziomOdpaduChart.AxisX.Add(axX); poziomOdpaduChart.AxisY.Add(axY1); poziomOdpaduChart.AxisY.Add(axY2); seriesCollection.Add(totalProductionSeries); foreach (var lineEntry in chartPoints) { ChartValues <float> ngValues = new ChartValues <float>(); ChartValues <float> scrapValues = new ChartValues <float>(); foreach (var dateEntry in lineEntry.Value) { if (dateEntry.Value.totalProduction > 0) { ngValues.Add((float)Math.Round((float)dateEntry.Value.totalNg / (float)dateEntry.Value.totalProduction * 100, 2)); scrapValues.Add((float)Math.Round((float)dateEntry.Value.totalScrap / (float)dateEntry.Value.totalProduction * 100, 2)); } else { ngValues.Add(0); scrapValues.Add(0); } } LineSeries ngSeries = new LineSeries(); ngSeries.Title = $"ng_{lineEntry.Key}"; ngSeries.Values = ngValues; ngSeries.DataLabels = true; ngSeries.ScalesYAt = 1; Func <ChartPoint, string> ngPt = pt => Math.Round(pt.Y, 2).ToString() + "%"; ngSeries.LabelPoint = ngPt; ngSeries.Stroke = MediaTools.ColorDrawingToMediaBrush(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]); ngSeries.Fill = new SolidColorBrush { Color = MediaTools.ColorDrawingToColorMedia(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]), Opacity = 0.4 }; ngSeries.PointGeometry = DefaultGeometries.Square; LineSeries scrapSeries = new LineSeries(); scrapSeries.Values = scrapValues; scrapSeries.Title = $"scrap_{lineEntry.Key}"; scrapSeries.LabelPoint = ngPt; scrapSeries.DataLabels = true; scrapSeries.ScalesYAt = 1; scrapSeries.Fill = new SolidColorBrush { Color = (MediaTools.ColorDrawingToColorMedia(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()])), Opacity = 0.4 }; scrapSeries.Stroke = MediaTools.ColorDrawingToMediaBrush(GlobalParameters.smtLinesColors[lineEntry.Key.ToUpper()]); seriesCollection.Add(ngSeries); seriesCollection.Add(scrapSeries); //poziomOdpaduChart.Series.Add(ngSeries); //poziomOdpaduChart.Series.Add(scrapSeries); } poziomOdpaduChart.Series.AddRange(seriesCollection); poziomOdpaduChart.Zoom = ZoomingOptions.Xy; poziomOdpaduChart.Pan = PanningOptions.Xy; }
public async void PlayPlayer(TrackItem trackItem) { MediaElementPro player = p1Playing ? player2 : player1; MediaElementLoader loader = p1Playing ? loader2 : loader1; if (!player.VideoLoaded) { if (player.GetTag <TrackItem>() == null) { player.Tag = trackItem; } await loader.LoadVideo(player.GetTag <TrackItem>()); } if (trackItem != player.GetTag <TrackItem>()) { return; } Console.WriteLine($"Play{player.Source.ToString()} At {player.Name}"); player.Play(); Canvas rootCanvas = ((VideoLayer)player.TemplatedParent).Parent as Canvas; VideoLayer rootLayer = (VideoLayer)player.TemplatedParent; player.PositionChanged += localPositionChanged; p1Playing = !p1Playing; trackItem.PropertyChanged += (sen, e) => { object value = PropertyManager.GetProperty(trackItem.Property, e.PropertyName); switch (e.PropertyName.ToLower()) { case "left": case "top": case "scale": rootLayer.Width = (double.IsNaN(rootCanvas.Width) ? rootCanvas.ActualWidth : rootCanvas.Width) * (double)PropertyManager.GetProperty(trackItem.Property, "Scale"); rootLayer.Height = (double.IsNaN(rootCanvas.Height) ? rootCanvas.ActualWidth : rootCanvas.Height) * (double)PropertyManager.GetProperty(trackItem.Property, "Scale"); player.Width = rootLayer.Width; player.Height = rootLayer.Height; Canvas.SetLeft(rootLayer, (rootCanvas.ActualWidth - player.Width + (rootCanvas.ActualWidth * 2 * (double)PropertyManager.GetProperty(trackItem.Property, "Left"))) / 2); Canvas.SetTop(rootLayer, (rootCanvas.ActualHeight - player.Height + (rootCanvas.ActualHeight * 2 * (double)PropertyManager.GetProperty(trackItem.Property, "Top"))) / 2); break; case "opacity": player.Opacity = (double)value; break; case "volume": var volume = (((double)value) * 0.5); Console.WriteLine(trackItem.Text + " : " + volume); if (volume == 0) { Application.Current.MainWindow.Dispatcher.Invoke(() => { player.Volume = 0; }); } else { player.Volume = volume + 0.5; } if ((bool)PropertyManager.GetProperty(trackItem.Property, "IsMute") && player.Volume != 0) { ((VideoItemProperty)trackItem.Property).IsMute = false; } break; case "chromakeyuse": case "chromakeyusage": case "chromakeycolor": VideoLayer vLayer = (VideoLayer)player.TemplatedParent; Brush newColor = (Brush)PropertyManager.GetProperty(trackItem.Property, "ChromaKeyColor"); SolidColorBrush newBrush = (SolidColorBrush)newColor; newBrush.Color.ToHSL(out double _h, out double _s, out double _l); _chromaKeyEffect = new ChromaKeyEffect() { HueMin = (float)_h, HueMax = (float)_h, SaturationMax = (float)_s, SaturationMin = (float)_s, LuminanceMax = (float)_l, LuminanceMin = (float)_l, Smooth = (float)((double)PropertyManager.GetProperty(trackItem.Property, "ChromaKeyUsage")), }; if ((bool)PropertyManager.GetProperty(trackItem.Property, "ChromaKeyUse")) { vLayer.Effect = _chromaKeyEffect; } else { vLayer.Effect = null; } break; case "ismute": bool isMute = (bool)value; if (isMute) { player.Volume = 0; } else { player.Volume = (double)PropertyManager.GetProperty(trackItem.Property, "Volume"); } break; default: break; } }; foreach (PropertyInfo allProperties in trackItem.Property.GetType().GetRuntimeProperties()) { trackItem.OnPropertyChanged(allProperties.Name); } void localPositionChanged(MediaElementPro s, TimeSpan p) { s.PositionChanged -= localPositionChanged; TrackItem itm = s.GetTag <TrackItem>(); s.Position = MediaTools.FrameToTimeSpan(itm.ForwardOffset + CurrentFrame - itm.Offset, CurrentFrameRate); s.Visibility = Visibility.Visible; s.Width = rootCanvas.ActualWidth;// * itm.ItemProperty.Size; s.Height = rootCanvas.ActualHeight; if (s == player1) { player2.Visibility = Visibility.Hidden; } else { player1.Visibility = Visibility.Hidden; } } }
public MainWindow() { InitializeComponent(); InitializeMenuFiles(); InitializeLightItems(); lbMediaItem.PreviewMouseLeftButtonDown += lbMediaItem_PreviewMouseLeftButtonDown; lbMediaItem.PreviewMouseLeftButtonUp += lbMediaItem_PreviewMouseLeftButtonUp; lbMediaItem.PreviewMouseMove += lbMediaItem_PreviewMouseMove; ItemHeader.SelectionChanged += (s, e) => { if (ItemHeader.SelectedItem is ListBoxItem selItem) { int itm = int.Parse(selItem.Tag.ToString()); mwViewModel.FilterType = (SourceType)itm; } }; this.Loaded += MainWindow_Loaded; this.Closing += MainWindow_Closing; this.PreviewKeyDown += MainWindow_PreviewKeyDown; tl.ItemSelected += Tl_ItemSelected; tl.ItemDeselected += Tl_ItemDeselected; tl.ItemRemoved += Tl_ItemRemoved; tl.FrameChanged += (s, e) => { tbTime.Text = MediaTools.GetTimeText(tl.Position, tl.FrameRate); }; lvEvents.Items.Clear(); btnAdd.Click += BtnAdd_Click; btnRemove.Click += BtnRemove_Click; #region [ 주석 ] //GlobalViewModel.MainWindowViewModel.AddFilesFromPath(new string[] { @"C:\Users\장유탁\AppData\Roaming\delight\ot50ya4f.yyc.mp4" }); /* * * SetterBoard sb = new SetterBoard(); * sb.Identifier = "손 흔들기"; * * sb.AddSetterProperties(PortNumber.Blink, "Blinking", "깜빡이는 정도"); * * sb.AddSetterGroup(); * sb.AddSetterGroup(); * sb.SetInitalizeValue((PortNumber.XAxis, new StaticValue(45)), * (PortNumber.YAxis, new StaticValue(100)), * (PortNumber.Brightness, new StaticValue(254)), * (PortNumber.Blink, new PropertyValue("Blinking")), * (PortNumber.Color, new StaticValue(220))); * //(PortNumber.Color, new PropertyValue("Color")) * * sb[0].AddContinueLine(1000); * sb[0].AddStates((PortNumber.YAxis, (StaticValue)162)); * * sb[0].AddWait(200); * * sb[0].AddContinueLine(1000); * sb[0].AddStates((PortNumber.YAxis, (StaticValue)100)); * * sb[0].AddWait(200); * * sb[1].AddContinueLine(500); * sb[1].AddStates((PortNumber.XAxis, (StaticValue)50)); * * sb[1].AddWait(200); * * sb[1].AddContinueLine(500); * sb[1].AddStates((PortNumber.XAxis, (StaticValue)40)); * * sb[1].AddWait(200); * * * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb)); * * //(PortNumber.Blink, new PropertyValue("Blinking") * * * //string path = @"C:\Users\uutak\바탕 화면\GroupTest.xml"; * * //BoardSerializer.Save(sb, path); * * //var board = BoardSerializer.Load(path); * //Console.WriteLine("Done"); * * //GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(board)); * * * SetterBoard sb2 = new SetterBoard(); * * sb2.Identifier = "좌우로 흔들기"; * sb2.AddSetterGroup(); * * sb2[0].AddWait(1000); * * SetterBoard sb3 = new SetterBoard(); * * sb3.Identifier = "위아래로 움직이기"; * sb3.AddSetterGroup(); * * sb3[0].AddWait(1000); * * * SetterBoard sb4 = new SetterBoard(); * * sb4.Identifier = "깜빡이며 사선 움직임"; * sb4.AddSetterGroup(); * //sb2.AddSetterGroup(); * * sb4.SetInitalizeValue((PortNumber.XAxis, new StaticValue(90)), * (PortNumber.YAxis, new StaticValue(78)), * (PortNumber.Brightness, new StaticValue(89)), * (PortNumber.Blink, new StaticValue(200)), * (PortNumber.Color, new StaticValue(220))); * * //sb2.InitalizeWaitValue * * sb4[0].AddContinueLine(400); * sb4[0].AddStates((PortNumber.YAxis, new StaticValue(34)), * (PortNumber.XAxis, new StaticValue(60))); * * sb4[0].AddContinueLine(400); * * sb4[0].AddStates((PortNumber.YAxis, new StaticValue(120)), * (PortNumber.XAxis, new StaticValue(120))); * * SetterBoard sb5 = new SetterBoard(); * * sb5.Identifier = "깜빡이며 흔들기"; * sb5.AddSetterGroup(); * sb5.SetInitalizeValue((PortNumber.XAxis, new StaticValue(90)), * (PortNumber.YAxis, new StaticValue(78)), * (PortNumber.Brightness, new StaticValue(89)), * (PortNumber.Blink, new StaticValue(200)), * (PortNumber.Color, new StaticValue(200))); * * sb5[0].AddContinueLine(300); * sb5[0].AddStates((PortNumber.YAxis, new StaticValue(34))); * * sb5[0].AddContinueLine(300); * * sb5[0].AddStates((PortNumber.YAxis, new StaticValue(120))); * * * //sb2[1].AddContinueLine(2000); * * //sb2[1].AddStates((PortNumber.XAxis, new StaticValue(95))); * * //sb2[1].AddContinueLine(2000); * * //sb2[1].AddStates((PortNumber.XAxis, new StaticValue(85))); * * * //(PortNumber.Blink, new PropertyValue("Blinking") * * SetterBoard sb6 = new SetterBoard(); * * sb6.Identifier = "원 그리기"; * sb6.AddSetterGroup(); * * sb6[0].AddWait(1000); * * SetterBoard sb7 = new SetterBoard(); * * sb7.Identifier = "8자 그리기"; * sb7.AddSetterGroup(); * * sb7[0].AddWait(1000); * * SetterBoard sb8 = new SetterBoard(); * * sb8.Identifier = "색 바뀌며 돌기"; * sb8.AddSetterGroup(); * * sb8[0].AddWait(1000); * * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb2)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb3)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb4)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb5)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb6)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb7)); * GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(sb8)); * */ //LightBoard lb = new LightBoard(); //LightBoard lightBoard = new LightBoard(); //lightBoard.AddState(new LightState(45, 100, 254, 0, 42, 0, 0, 0, 0, 0, 0, 0)); //lightBoard.AddDelayState(new DelayState(1000, 45, 162, 254, 0, 42, 0, 0, 0, 0, 0, 0, 0)); //lightBoard.AddWait(200); //lightBoard.AddDelayState(new DelayState(1000, 45, 100, 254, 0, 42, 0, 0, 0, 0, 0, 0, 0)); //lightBoard.AddWait(200); //lightBoard.Identifier = "손 흔들기"; //var lightComponent2 = new LightComponent(lightBoard); //GlobalViewModel.MainWindowViewModel.MediaItems.Add(lightComponent2); //var lightEffect = EffectSerializer.GetStatesFromFile(@"C:\Users\uutak\바탕 화면\LightBoard.xml"); //var lightComponent = new LightComponent(lightEffect); //LightBoard lightBoard2 = new LightBoard(); //lightBoard2.AddState(new LightState(173, 40, 254, 193, 33, 0, 0, 0, 0, 0, 0, 0)); //lightBoard2.AddWait(100); //lightBoard2.AddDelayState(new DelayState(200, 188, 80, 254, 193, 33, 0, 0, 0, 0, 0, 0, 0)); //lightBoard2.AddWait(100); //lightBoard2.AddDelayState(new DelayState(200, 173, 40, 254, 193, 33, 0, 0, 0, 0, 0, 0, 0)); //lightBoard2.AddWait(100); //lightBoard2.AddDelayState(new DelayState(200, 158, 80, 254, 193, 33, 0, 0, 0, 0, 0, 0, 0)); //lightBoard2.AddWait(100); //lightBoard2.AddDelayState(new DelayState(200, 173, 40, 254, 193, 33, 0, 0, 0, 0, 0, 0, 0)); //lightBoard2.Identifier = "Swing!"; //GlobalViewModel.MainWindowViewModel.MediaItems.Add(new LightComponent(lightBoard2)); //GlobalViewModel.MainWindowViewModel.MediaItems.Add(lightComponent); //Console.WriteLine("CRC-32(File) is {0}", Crc32.GetHashFromFile(@"C:\Users\uutak\바탕 화면\LightBoard.xml")); //dynamic _employee = new DynamicProperty(); //_employee.asdf = "John"; //_employee.LastName = "Doe"; //_employee.Test = "This is a test"; //MessageBox.Show(PropertyManager.GetProperty(_employee, "Test")); //propGrid.SelectedObject = _employee; #endregion }