Exemplo n.º 1
0
		private void Window_Loaded (object sender, RoutedEventArgs e)
			{
			if (WMB.Basics.IAmActiveBefore ())
				{
				WMB.Basics.ReportErrorToEventViewer ("WPMediaPlayingDataController.Window_Loaded",
					"Start wird abgebrochen, weil schon eine Instanz aktiv ist");
				Close ();
				return;
				}
			m_CVM = new CommonValues();
			m_XAMLHandling = new XAMLHandling (m_CVM);
			m_CVM.SetVideoSize ();

			Width = 0;
			Height = 0;
			MaxWidth = 0;
			MaxHeight = 0;
			MinWidth = 0;
			MinHeight = 0;
			Top = 0;
			Left = 0;
			this.Topmost = false;

			CreateTimeWindow ();
			if (CheckIfLogoWindowShouldUsed () == true)
				CreateLogoWindow ();

			this.WindowStartupLocation = WindowStartupLocation.Manual; 
			m_StartDataCopyProcess = new DispatcherTimer();
			m_StartDataCopyProcess.Tick += new EventHandler (m_StartDataCopyProcess_Tick);
			m_StartDataCopyProcess.Interval = TimeSpan.FromSeconds (60);
#if DEBUG
			m_StartDataCopyProcess.Interval = TimeSpan.FromSeconds (1);
			m_StartDataCopyProcess.Start ();
			return;
#endif
			m_StartDataCopyProcess.Start ();
			m_ShowTimeTimer = new DispatcherTimer();
			m_ShowTimeTimer.Interval = TimeSpan.FromSeconds (1);
			m_ShowTimeTimer.Tick += new EventHandler (m_ShowTimeTimer_Tick);
			m_ShowTimeTimer.Start ();
			m_StartPlayerTimer = new DispatcherTimer ();
			m_StartPlayerTimer.Tick += new EventHandler (m_StartPlayerTimer_Tick);
			m_StartPlayerTimer.Interval = TimeSpan.FromSeconds (10);
			m_StartPlayerTimer.Start ();
			Mouse.OverrideCursor = Cursors.None;
			}
		private void Application_Startup (object sender, StartupEventArgs e)
			{
			if (WMB.Basics.IsTestRun)
				{
				WMB.Basics.ReportInformationToEventViewer("PlayingDataProcessApplication.Application_Startup",
					"\"PlayingDataProcessApplication\" ist als Process aktiv\r\n"
					+ "mit folgenden anderen Proccess ID's\r\n"
					+ String.Join("\r\n", CVM.CommonValues.GetMyAndTheOtherProcessIDs()));
				}
			if (e.Args.Length > 0)
				{
				String [] Elements = (e.Args [0]).Split (';');

				if (Elements.Length > 1)
					IsMultiTableRun = true;
				else
					IsMultiTableRun = false;
				//    {
				//    WMB.Basics.ReportInformationToEventViewer ("PlayingDataProcessApplication.Application_Startup",
				//        "Mehr Control File Aufrufe sind nicht implementiert:\r\n" + e.Args [0]);
				//    throw new NotImplementedException ("Mehr Control File Aufrufe sind nicht implementiert");
				//    }
				}

			DateTime FirstStartTime = DateTime.Now;

			DispatcherTimer DoubleRunCheckTimer = new DispatcherTimer();
			DoubleRunCheckTimer.Interval = TimeSpan.FromMilliseconds (2000);
			DoubleRunCheckTimer.Tick += DoubleRunCheckTimer_Tick;
			DoubleRunCheckTimer.Tag = FirstStartTime;
			DoubleRunCheckTimer.Start ();


			if ((DateTime.Now - FirstStartTime).TotalSeconds > 5)
				WMB.Basics.ReportErrorToEventViewer ("Delayed_____Start.PlayingDataProcessApplication.Application_Startup",
											  "Diese Instanz von \"PlayingDataProcessApplication\" wurde "
											+ "mit einer Verzögerung von  "
											+ Convert.ToString ((DateTime.Now - FirstStartTime).TotalSeconds)
											+ " gestarted.\r\n");

			String StopTimeString = String.Empty;
			if ((e.Args.Length == 1)
				&& (File.Exists (e.Args [0])
				&& ((String.Compare( Path.GetExtension (e.Args [0]), ".stb", true) == 0)
					|| (String.Compare (Path.GetExtension (e.Args [0]), ".ser", true) == 0)
					|| (String.Compare (Path.GetExtension (e.Args [0]), ".ext", true) == 0)
					|| (String.Compare (Path.GetExtension (e.Args [0]), ".pkg", true) == 0))))
				{
				m_Arguments = new String [e.Args.Length + 5];
				m_Arguments [0] = CVM.CommonValues.GetControlFileNameFromUnitName (e.Args [0]);
				m_Arguments [1] = CVM.CommonValues.WPMEDIA_SHOW_ONLY_THIS_FILE_PARAMETER + "\"" + e.Args [0] + "\"";
// sac
				StopTimeString = DateTime.Now.AddSeconds (15).ToString( );
				if (String.Compare (Path.GetExtension (e.Args [0]), ".ext", true) == 0)
					{
					StopTimeString = String.Empty;
					}
				if (String.Compare (Path.GetExtension (e.Args [0]), ".ser", true) == 0)
					{
					StopTimeString = DateTime.Now.AddHours (12).ToString ();
					}
				if (String.Compare (Path.GetExtension (e.Args [0]), ".pkg", true) == 0)
					{
					StopTimeString = String.Empty;
					}
				m_Arguments [2] = CVM.CommonValues.WPMEDIA_STOP_TIME_PARAMETER + StopTimeString;
				Rectangle [] SimulatedVideoRectangle = CVM.CommonValues.ConvertPhysicalScreenBounds (CVM.CommonValues.GetPhysicalScreenBounds ());
				m_Arguments [3] = CVM.CommonValues.WPMEDIA_VIDEO_WIDTH_PARAMETER + Convert.ToString (SimulatedVideoRectangle [0].Width / 2);
				m_Arguments [4] = CVM.CommonValues.WPMEDIA_VIDEO_HEIGHT_PARAMETER + Convert.ToString (SimulatedVideoRectangle [0].Height / 2);
				m_Arguments [5] = CVM.CommonValues.WPMEDIA_TYPE_OF_BEITRAG + WPMediaManagement.ManagedProgrammData.Type_UtilityDisplay;
				//WMB.Basics.ReportErrorToEventViewer ("PlayingDataProcessApplication.Application_Startup",
				//    "ProgrammDirectory = \"" + CVM.CommonValues.sGetProgrammDirectory () + "\"");

				}
			else
				{
				m_Arguments = new String [e.Args.Length];
				for (int i = 0; i != e.Args.Length; ++i)
					{
					m_Arguments [i] = e.Args [i];
					if (m_Arguments [i].IndexOf (CVM.CommonValues.WPMEDIA_STOP_TIME_PARAMETER) != -1)
						{
						StopTimeString = m_Arguments [i].Substring
							(CVM.CommonValues.WPMEDIA_STOP_TIME_PARAMETER.Length).Replace ("\"", "");
						}
					}
				
				}
			CVM.CommonValues m_CVM = new CVM.CommonValues ();
			m_CVM.CreateMultiTableEnvironmentCall += new WMB.CreateMultiTableEnvironmentEvent (CreateMultiTableEnvironmentCall);
			try
				{

				DataRow SenderRow = WPMediaManagement.SingletonManagedProgrammManagement.Instance
					.ActuallManagedProgrammManagement.ActuallProgrammData.GetSenderRow ();
				DataRow PlayerRow = WPMediaManagement.SingletonManagedProgrammManagement.Instance
					.ActuallManagedProgrammManagement.ActuallProgrammData.GetMaschinenRow ();
				m_CVM.m_Arguments = WMB.Basics.ConvertCommandlineToNameCollection(m_Arguments); 

				m_CVM.SetVideoSize (m_Arguments, IsMultiTableRun);
				}
			catch (Exception Excp)
				{
				WMB.Basics.ReportErrorToEventViewer ("PlayingDataProcessApplication.Application_Startup",
					"Folgender Fehler trat auf:\r\n" + Excp.ToString());
				WMB.Basics.ReportErrorToEventViewer ("PlayingDataProcessApplication.Application_Startup",
							 "Bei folgenden Parameter Settings \"" + String.Join (";\r\n", m_Arguments) + "\"");
				Shutdown (-1);
				}

			this.MainWindow = new WPMediaPlayingDataProcess.PlayingDataProcessMainWindow ();
			if (!String.IsNullOrEmpty (StopTimeString))
				{
				DateTime EmergencyStopTime = m_CVM.GetDateTimeNowReal (DateTime.Parse (StopTimeString));
				m_EmergencyStopTimer = new DispatcherTimer ();
				m_EmergencyStopTimer.Tag = MainWindow;
				if ((EmergencyStopTime - DateTime.Now).TotalSeconds < 86500)
					{
					TimeSpan StopInterval = EmergencyStopTime - DateTime.Now;
					if (StopInterval > TimeSpan.FromTicks (1))
						m_EmergencyStopTimer.Interval = StopInterval;
					else
						m_EmergencyStopTimer.Interval = TimeSpan.FromTicks (1);
					
					}
				else
					m_EmergencyStopTimer.Interval = TimeSpan.FromDays (1);
				m_EmergencyStopTimer.Tick += new EventHandler (EmergencyStopTimer_Tick);
				m_EmergencyStopTimer.Start ();

				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PlayingDataProcessApplication.Application_Startup",
					           "\"PlayingDataProcessApplication\" ist aktiviert");

				}


			((PlayingDataProcessMainWindow) this.MainWindow).SetParameter (m_CVM, m_Arguments, m_CVM.VideoWidth, m_CVM.VideoHeight, m_CVM.TargetAspectRatio);
			((PlayingDataProcessMainWindow) this.MainWindow).CloseRequestedCall += new CloseRequested (App_CloseRequestedCall);
			this.MainWindow.Left = m_CVM.XPosition;
			this.MainWindow.Top = m_CVM.YPosition;
			this.MainWindow.Width = 1;
			this.MainWindow.Height = 1;
			this.MainWindow.Background = System.Windows.Media.Brushes.Black;
			this.MainWindow.Show();
			//this.MainWindow.Left = m_CVM.XPosition;
			//this.MainWindow.Top = m_CVM.YPosition;
			this.MainWindow.Width = m_CVM.VideoWidth;
			this.MainWindow.Height = m_CVM.VideoHeight;
			}