TV Management Plugin (1 Viewer)

Status
Not open for further replies.

vcrapps

Portal Pro
March 11, 2012
73
17
45
Home Country
United States of America United States of America
I'm new to writing code in C#, and I have gotten spoiled by the toolbox within the Windows Forms creations. I've searching the Internet trying to find out how to write the code for an open file dialog box, but using the xml skin file that I created. The current button from the how to create a plugin template just opens a message dialog box. Could anybody point me in the right direction on how to do this?
 

mbuzina

Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    There is no open file dialog box within the MP controls, you would have to write one yourself (I think).
     

    vcrapps

    Portal Pro
    March 11, 2012
    73
    17
    45
    Home Country
    United States of America United States of America
    ok, then for example the basic Video plugin built within MediaPortal allows you to click on a folder, then it will show the contents of the folder. This is what I'm trying to do basically. Is the GUIDialogFile.vitual directory command the one that I'm suppose to be using to show the contents of a specific folder?
     

    mbuzina

    Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    Ah now I get it. That is a GuiListControl (or a facade containing list, coverflow and others). Check that in the wiki. If you filled it with guiitems that represent folders, you can then fill a new dir
     

    vcrapps

    Portal Pro
    March 11, 2012
    73
    17
    45
    Home Country
    United States of America United States of America
    Actually I'm still having problems. I'm trying to create a plugin that will allow me or another user to Manage his TV Recordings, and move certain Recording to another Drive on his computer without having to exit MediaPortal to do so. I searched for already created plugins and can't find one that actually does this within MediaPoral, so I decided that this would be a good project to try to write. Anyways here is my XML Skin File:
    Code:
        <window>
     
      <id>2331</id>
     
      <defaultcontrol>3</defaultcontrol>
     
      <allowoverlay>yes</allowoverlay>
     
      <controls>
     
     
     
        <control>
     
          <description>BackGround</description>
     
          <type>image</type>
     
          <id>4</id>
     
          <posX>0</posX>
     
          <posY>0</posY>
     
          <width>1400</width>
     
          <height>800</height>
     
          <texture>bg.jpg</texture>
     
        </control>
     
     
     
          <control>
     
          <description>TV Recording Manager</description>
     
          <type>label</type>
     
          <id>1</id>
     
          <posX>250</posX>
     
          <posY>70</posY>
     
          <label>TV Recording Manager</label>
     
          <font>font13</font>
     
          <align>right</align>
     
          <textcolor>ffffffff</textcolor>
     
        </control>
     
     
     
        <control>
     
          <description>Clear Recordings</description>
     
          <type>button</type>
     
          <id>2</id>
     
          <posX>60</posX>
     
          <posY>250</posY>
     
          <label>Clear Recordings</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
        </control>
     
     
     
        <control>
     
          <description>Add Recordings</description>
     
          <type>button</type>
     
          <id>3</id>
     
          <posX>60</posX>
     
          <posY>150</posY>
     
          <label>Add Recordings</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
     
     
        </control>
     
    <control>
     
          <description>Move To Location</description>
     
          <type>button</type>
     
          <id>5</id>
     
          <posX>60</posX>
     
          <posY>350</posY>
     
          <label>Move To Location</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
        </control>
     
    <control>
     
          <description>Move Recording</description>
     
          <type>button</type>
     
          <id>6</id>
     
          <posX>60</posX>
     
          <posY>450</posY>
     
          <label>Move Recording</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
        </control>
     
    <control>
     
          <description>Delete Recording</description>
     
          <type>button</type>
     
          <id>7</id>
     
          <posX>60</posX>
     
          <posY>550</posY>
     
          <label>Delete Recording</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
        </control>
     
        <control>
     
          <description>Move All Recordings</description>
     
          <type>button</type>
     
          <id>8</id>
     
          <posX>60</posX>
     
          <posY>650</posY>
     
          <label>Move All Recordings</label>
         
          <font>font12</font>
     
          <onleft>2</onleft>
     
          <onright>2</onright>
     
          <onup>0</onup>
     
          <ondown>0</ondown>
     
        </control>
     
     
    <control>
     
      <description>Action Status label</description>
     
      <type>label</type>
     
      <id>10</id>
     
      <posX>650</posX>
     
      <posY>70</posY>
     
      <label>Status Window:</label>
     
      <font>font13</font>
     
      <textcolor>FFFFFFFF</textcolor>
     
    </control>
     
     
      <control>
     
          <description>Status Window</description>
     
          <type>image</type>
     
          <id>13</id>
     
          <posX>600</posX>
     
          <posY>80</posY>
     
          <width>500</width>
     
          <height>500</height>
     
          <texture>bg_basichome_slide.png</texture>
     
        </control>
     
    <control>
                             
     
    <description>listcontrol</description>
    <type>listcontrol</type>
    <id>12</id>
    <width>50</width>
    <height>60</height>
    <onleft>2</onleft>
    <onright>51</onright>
    <onup>2</onup>
    <ondown>2</ondown>
    <textcolor>FFFFFFFF</textcolor>
    </control>
     
     
     
     
     
    <control>
     
          <description>MediaPortal Logo</description>
     
          <type>image</type>
     
          <id>11</id>
     
          <posX>1150</posX>
     
          <posY>30</posY>
       
          <width>110</width>
     
          <height>110</height>
     
          <texture>hover_MediaPortal_Icon.png</texture>
     
        </control>
     
     
     
      </controls>
     
    </window>

    This produces the Skin in MediaPortal: TVM Skin File.jpg[DOUBLEPOST=1345068469][/DOUBLEPOST]Sorry I decided to break this post into two so that it wouldn't be so long.

    The C# plugin Code I have is :

    using System;
    using System.IO;
    using System.Windows.Forms;
    using MediaPortal.GUI.Library;
    using MediaPortal.Dialogs;
    using MediaPortal.Common.Utils;
    using System.Collections;
    using System.Diagnostics;
    using TV_Management;

    [assembly: CompatibleVersion("1.1.6.27644")]
    [assembly: UsesSubsystem("MP.SkinEngine")]
    [assembly: UsesSubsystem("MP.Config")]

    namespace TV_Management
    {
    public class Class1 : GUIWindow, ISetupForm
    {
    [SkinControlAttribute(2)]protected GUIButtonControl ClearRec = null;
    [SkinControlAttribute(3)]protected GUIButtonControl AddRec = null;
    [SkinControlAttribute(5)]protected GUIButtonControl MoveTo = null;
    [SkinControlAttribute(6)]protected GUIButtonControl MoveRec = null;
    [SkinControlAttribute(7)]protected GUIButtonControl DeleteRec = null;
    [SkinControlAttribute(8)]protected GUIButtonControl MoveAll = null;
    [SkinControlAttribute(12)]protected GUIFacadeControl StatusWin = null;

    string ReadSettings = ("C:\\Users\\Victor\\Desktop\\TV Managment Plugin Version 2\\UserSettings.text");
    string Read;




    public Class1()
    {

    }

    #region ISetupForm Members





    public string PluginName()
    {

    return "TV Management";

    }





    public string Description()
    {

    return "Allows you to Manage Recordings and Videos within MediaPortal";

    }





    public string Author()
    {

    return "Victor";

    }





    public void ShowPlugin()
    {


    System.Diagnostics.Process.Start("C:\\Users\\Victor\\Desktop\\TV Managment Plugin Version 2\\Configuration Utility.exe");

    }





    public bool CanEnable()
    {

    return true;

    }





    public int GetWindowId()
    {



    return 2331;

    }





    public bool DefaultEnabled()
    {

    return true;

    }





    public bool HasSetup()
    {

    return true;

    }

    public override bool Init()
    {
    return
    Load(GUIGraphicsContext.Skin + @"\TVM.xml");
    }





    public bool GetHome(out string strButtonText, out string strButtonImage,

    out string strButtonImageFocus, out string strPictureImage)
    {

    strButtonText = PluginName();

    strButtonImage = String.Empty;

    strButtonImageFocus = String.Empty;

    strPictureImage = @"hover_my programs.png";

    return true;

    }


    public override int GetID
    {

    get
    {

    return 2331;

    }



    set
    {

    }

    }


    #endregion






    protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
    {

    if (control == ClearRec)

    OnClearRec();

    if (control == AddRec)

    OnAddRec();

    if (control == MoveTo)

    OnMove();

    if (control == MoveRec)

    OnMoveRec();

    if (control == DeleteRec)

    OnDeleteRec();

    if (control == MoveAll)

    OnMoveAll();

    base.OnClicked(controlId, control, actionType);

    }


    private void OnClearRec()
    {

    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(

    (int)GUIWindow.Window.WINDOW_DIALOG_OK);

    dlg.SetHeading("Button has been pressed");

    dlg.SetLine(1, "You pressed button 1");

    dlg.SetLine(2, String.Empty);

    dlg.SetLine(3, String.Empty);

    dlg.DoModal(GUIWindowManager.ActiveWindow);

    }



    private void OnAddRec()
    {


    System.IO.StreamReader ReadUserSettings;
    ReadUserSettings = new System.IO.StreamReader(ReadSettings);

    Read = ReadUserSettings.ReadLine();

    StatusWin.Add(new GUIListItem(Read));


    }



    private void OnMove()
    {

    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);

    dlg.SetHeading("Button has been pressed");

    dlg.SetLine(1, "You pressed button 2");

    dlg.SetLine(2, String.Empty);

    dlg.SetLine(3, String.Empty);
    dlg.DoModal(GUIWindowManager.ActiveWindow);
    }

    private void OnMoveRec()
    {

    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(

    (int)GUIWindow.Window.WINDOW_DIALOG_OK);

    dlg.SetHeading("Button has been pressed");

    dlg.SetLine(1, "You pressed button 2");

    dlg.SetLine(2, String.Empty);

    dlg.SetLine(3, String.Empty);
    dlg.DoModal(GUIWindowManager.ActiveWindow);
    }

    private void OnDeleteRec()
    {

    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(

    (int)GUIWindow.Window.WINDOW_DIALOG_OK);

    dlg.SetHeading("Delete Recording!");

    dlg.SetLine(1, "You pressed button 2");

    dlg.SetLine(2, String.Empty);

    dlg.SetLine(3, String.Empty);
    dlg.DoModal(GUIWindowManager.ActiveWindow);
    }

    private void OnMoveAll()
    {

    GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(

    (int)GUIWindow.Window.WINDOW_DIALOG_OK);

    dlg.SetHeading("Button has been pressed");

    dlg.SetLine(1, "You pressed button 2");

    dlg.SetLine(2, String.Empty);

    dlg.SetLine(3, String.Empty);
    dlg.DoModal(GUIWindowManager.ActiveWindow);


    // Code to work with later to Allow user to Select Which Files to Move from Original Directory.
    // private void LoadList(string currentDirectory)
    //{
    // ArrayList arry = new ArrayList();
    // arry.Add(".pdf");
    // virtualDirectory.SetExtensions(arry);

    // List<GUIListItem> items = virtualDirectory.GetDirectoryExt(currentDirectory);

    // facadeView.Clear();

    // for (int i = 0; items.Count= > i; i++)
    // facadeView.Add(items);
    //}
    }

    }
    }
    [DOUBLEPOST=1345068762][/DOUBLEPOST]I'm trying to allow the user to select the Add Recordings Button to add the Recordings he would like to move one by one, to the "Status Window", then of of course the other buttons work to either Delete, Move All Recordings in the Directory, Clear the Status Window,etc. And help would be greatly appreicated. In the meantime, I'll continue trial and error looking at others people plugins in the Repository.
     

    vcrapps

    Portal Pro
    March 11, 2012
    73
    17
    45
    Home Country
    United States of America United States of America
    I think I fixed my own problem, it was a problem with the facade control within my Skin File. Thanks anyway though.
     

    vcrapps

    Portal Pro
    March 11, 2012
    73
    17
    45
    Home Country
    United States of America United States of America
    I've run into another problem now with actually adding and displaying the file from a directory. This is the code that I've gotten so far, but it still not displaying any files. Could anybody show me what I'm doing wrong with my loop.

    private void OnAddRec()
    {


    System.IO.StreamReader ReadUserSettings;
    ReadUserSettings = new System.IO.StreamReader(ReadSettings);

    Read = ReadUserSettings.ReadLine();



    GUIListItem item = new GUIListItem();
    item.Label = "Select Media:";
    item.Path = (Read);
    item.IsFolder = true;
    item.MusicTag = null;
    item.ThumbnailImage = string.Empty;
    MediaPortal.Util.Utils.SetDefaultIcons(item);
    DefaultDirect.Add(item);


    string[] filepaths;
    filepaths = new string[4];
    string[] filePaths = Directory.GetFiles(@"C:\Users\Victor\Desktop\Recording Test Folder2","*.xml");

    for (int i = 0; i != filepaths.Length; i++)
    {
    item = new GUIListItem();
    item.Label = "";
    item.Path = (Read);
    item.IsFolder = false;
    item.MusicTag = null;
    DefaultDirect.Add(item);
    DefaultDirect.AddSubItem(filePaths);

    }


    }
     

    vcrapps

    Portal Pro
    March 11, 2012
    73
    17
    45
    Home Country
    United States of America United States of America
    All problems have been Solved and plugin is Released and Ready for download, Please feel free to leave comments on what I should work to improve, besides a progress bar...and I'll see what I can do.

    Thanks
     

    Benoire

    MP Donator
  • Premium Supporter
  • March 17, 2012
    679
    161
    46
    Auckland
    Home Country
    New Zealand New Zealand
    Hi vcrapps, the purpose of this plugin is to move files from directory to directory using the MP interface, rather than dropping to windows? If so, fantastic this is just what I have been looking for!
     
    Status
    Not open for further replies.

    Users who are viewing this thread

    Top Bottom