From: <lk...@us...> - 2008-02-02 08:45:19
|
Revision: 1335 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1335&view=rev Author: lkuech Date: 2008-02-02 00:45:14 -0800 (Sat, 02 Feb 2008) Log Message: ----------- ViewModeSwitcher: Remove the reflection idea. Now a much simpler method is used (GUIPropertyManager.GetProperty("#TV.View.channel")). This one is working for TVE2 & 3! Modified Paths: -------------- trunk/plugins/ViewModeSwitcher/TVstatusWrapper.cs trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.cs trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.csproj Removed Paths: ------------- trunk/plugins/ViewModeSwitcher/TVPluginReflection.cs Deleted: trunk/plugins/ViewModeSwitcher/TVPluginReflection.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/TVPluginReflection.cs 2008-02-02 06:16:24 UTC (rev 1334) +++ trunk/plugins/ViewModeSwitcher/TVPluginReflection.cs 2008-02-02 08:45:14 UTC (rev 1335) @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Windows.Forms; -using MediaPortal.GUI.Library; -using System.Reflection; - - -namespace ProcessPlugins.ViewModeSwitcher -{ - public class TVPluginReflection - { - public enum States - { - notstarted, - delayed, - running, - finished - } - - public bool TVPluginFound = false; - public States State = States.notstarted; - - private System.Reflection.PropertyInfo CurrentChannelPropInfo = null; - private object oAssembly = null; - - public string CurrentTVChannel - { - get - { - if (CurrentChannelPropInfo == null && State == States.notstarted) DelayedStart(10000); - if (CurrentChannelPropInfo == null && State == States.finished) return string.Empty; - return GetCurrentChannelViaReflection(); - } - } - - public void Start() - { - Log.Debug("ViewModeSwitcher: TVPluginReflection: Start()"); - State = States.running; - - // Load the TVPlugin Assembly - Log.Debug("ViewModeSwitcher: TVPluginReflection: Try to find the TvPlugin"); - try - { - Assembly assembly = Assembly.LoadFrom("plugins\\Windows\\TvPlugin.dll"); - - Log.Debug("ViewModeSwitcher: TVPluginReflection: Try to load a instance of TvPlugin.ChannelNavigator"); - Type AssemblyType = assembly.GetType("TvPlugin.ChannelNavigator", false); - oAssembly = Activator.CreateInstance(AssemblyType); - - Log.Debug("ViewModeSwitcher: TVPluginReflection: Try to read CurrentTVChannel property"); - CurrentChannelPropInfo = AssemblyType.GetProperty("CurrentChannel"); - if (CurrentChannelPropInfo!=null) TVPluginFound = true; - - string tmpCurrentTVChannel = GetCurrentChannelViaReflection(); - Log.Debug("ViewModeSwitcher: TVPluginReflection: Value was: {0}", tmpCurrentTVChannel); - } - catch (Exception e) - { - Log.Debug("ViewModeSwitcher: TVPluginReflection: Error! {0}",e.Message); - } - - State = States.finished; - } - - string GetCurrentChannelViaReflection() - { - if (CurrentChannelPropInfo == null || oAssembly == null) - { - return string.Empty; - } - return (string)CurrentChannelPropInfo.GetValue(oAssembly, null); - } - - public void DelayedStart(int timeout) - { - State = States.delayed; - Log.Debug("ViewModeSwitcher: TVPluginReflection: Delayed start"); - Timer delayTimer = new Timer(); - delayTimer.Interval = timeout; - delayTimer.Tick += new EventHandler(delayTimer_Tick); - delayTimer.Start(); - } - - void delayTimer_Tick(object sender, EventArgs e) - { - Timer tmpTimer = (Timer)sender; - tmpTimer.Stop(); - Start(); - } - - } -} Modified: trunk/plugins/ViewModeSwitcher/TVstatusWrapper.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/TVstatusWrapper.cs 2008-02-02 06:16:24 UTC (rev 1334) +++ trunk/plugins/ViewModeSwitcher/TVstatusWrapper.cs 2008-02-02 08:45:14 UTC (rev 1335) @@ -8,47 +8,17 @@ { public class TVstatusWrapper { - public TVPluginReflection TVPluginReference; - - public TVstatusWrapper() + public static string CurrentChannelName { - TVPluginReference = new TVPluginReflection(); - //Log.Debug("ViewModeSwitcher: {0}", TVPluginReference.CurrentTVChannel); - } - - public string CurrentChannelName - { get { string tmpChannelName = string.Empty; - - if (TVPluginReference.State == TVPluginReflection.States.delayed || TVPluginReference.State == TVPluginReflection.States.notstarted) - { - Log.Debug("ViewModeSwitcher: TVstatusWrapper: CurrentChannelName: TVPluginReference.State = {0}", TVPluginReference.State); - return string.Empty; - } - - //if (TVPluginReference.State == TVPluginReflection.States.notstarted) // make sure tvplug is searched via reflection - //{ - // tmpChannelName = TVPluginReference.CurrentTVChannel; // let the Reflection class do her work - // Log.Debug("ViewModeSwitcher: TVstatusWrapper: CurrentChannelName: first start! Try to return the tve3 channel: {0}", tmpChannelName); - // return tmpChannelName; - //} - - if (TVPluginReference.State == TVPluginReflection.States.finished && TVPluginReference.TVPluginFound) - { - tmpChannelName = TVPluginReference.CurrentTVChannel; - Log.Debug("ViewModeSwitcher: TVstatusWrapper: CurrentChannelName: returning tve3 channel {0}", tmpChannelName); - return tmpChannelName; // return tve3 channel name - } - - tmpChannelName = Recorder.GetTVChannelName(); - Log.Debug("ViewModeSwitcher: TVstatusWrapper: CurrentChannelName: returning tve2 channel {0}", tmpChannelName); - return tmpChannelName; // return tve2 channel name + tmpChannelName = GUIPropertyManager.GetProperty("#TV.View.channel"); + return tmpChannelName; } } - public bool IsViewingTV() + public static bool IsViewingTV() { if (CurrentChannelName != string.Empty) return true; Modified: trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.cs =================================================================== --- trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.cs 2008-02-02 06:16:24 UTC (rev 1334) +++ trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.cs 2008-02-02 08:45:14 UTC (rev 1335) @@ -65,7 +65,6 @@ private bool MenuShown = false; private int CurrentRule = -1; private int RecentGuiWindowID = 0; - private TVstatusWrapper TvStatus = null; enum MoveDirection { @@ -105,7 +104,6 @@ //GUIGraphicsContext.OnNewAction += new OnActionHandler(OnAction); - TvStatus = new TVstatusWrapper(); //Log.Debug("ViewModeSwitcher: test the channel: {0}", TvStatus.CurrentChannelName); } @@ -327,8 +325,6 @@ ResetWorkerPlaybackValues(); if (ViewModeSwitcherEnabled) workerEvent.Set(); - - TvStatus.TVPluginReference.Start(); } /// <summary> @@ -354,8 +350,6 @@ ResetWorkerPlaybackValues(); if (ViewModeSwitcherEnabled) workerEvent.Set(); - - TvStatus.TVPluginReference.Start(); } /// <summary> @@ -515,9 +509,9 @@ //SetZoomModeOffset(curZoomMode); } - if (TvStatus.IsViewingTV()) + if (TVstatusWrapper.IsViewingTV()) { - string tmpChannelName = TvStatus.CurrentChannelName; + string tmpChannelName = TVstatusWrapper.CurrentChannelName; if (curTVChannelName != tmpChannelName) { curTVChannelName = tmpChannelName; Modified: trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.csproj =================================================================== --- trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.csproj 2008-02-02 06:16:24 UTC (rev 1334) +++ trunk/plugins/ViewModeSwitcher/ViewModeSwitcher.csproj 2008-02-02 08:45:14 UTC (rev 1335) @@ -57,7 +57,6 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Rule.cs" /> <Compile Include="Settings.cs" /> - <Compile Include="TVPluginReflection.cs" /> <Compile Include="TVstatusWrapper.cs" /> <Compile Include="ViewModeSwitcher.cs" /> <Compile Include="ViewModeSwitcherConfig.cs"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |