Пример #1
0
 protected void OpenSkin(DirectoryInfo skinDir)
 {
     try
     {
         Cursor = Cursors.WaitCursor;
         if (skinExplorer.IsSkinLoaded)
         {
             cancelCommand = false;
             OnMenuClose(null, null);
             if (cancelCommand)
             {
                 return;
             }
         }
         skinExplorer.LoadSkin(skinDir);
         fileMenu.MenuCommands["&Close"].Enabled = true;
         Text = "MediaPortalEditor - Skin - [" + skinDir.Name + "]";
     }
     catch (MpeExplorerException ee)
     {
         MpeLog.Debug(ee);
         MpeLog.Error(ee);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
Пример #2
0
        public void Save()
        {
            XmlTextWriter writer = null;

            try
            {
                XmlDocument doc  = new XmlDocument();
                XmlNode     root = doc.CreateElement("MediaPortalEditor");
                doc.AppendChild(root);
                XmlNode node = doc.CreateElement("Preferences");
                root.AppendChild(node);

                SetXmlValue(doc, node, "MediaPortalDir", MediaPortalDir);
                SetXmlValue(doc, node, "WindowPosition", (WindowPosition.X + "," + WindowPosition.Y));
                SetXmlValue(doc, node, "WindowSize", (WindowSize.Width + "," + WindowSize.Height));
                SetXmlValue(doc, node, "WindowState", WindowState.ToString());
                SetXmlValue(doc, node, "LogLevel", LogLevel.ToString());

                writer             = new XmlTextWriter(file.FullName, Encoding.UTF8);
                writer.Formatting  = Formatting.Indented;
                writer.Indentation = 3;
                doc.WriteTo(writer);
                writer.Close();
            }
            catch (Exception e)
            {
                MpeLog.Debug(e);
                MpeLog.Error(e);
                throw new MpeParserException(e.Message);
            }
        }
Пример #3
0
 public void Load()
 {
     if (file == null || file.Exists == false)
     {
         Save();
         return;
     }
     try
     {
         XPathDocument     doc      = new XPathDocument(file.FullName);
         XPathNavigator    nav      = doc.CreateNavigator();
         XPathNodeIterator iterator = nav.Select("MediaPortalEditor/Preferences");
         if (iterator.MoveNext())
         {
             MediaPortalDir = GetXmlValue(iterator, "MediaPortalDir", MediaPortalDir);
             WindowPosition = GetXmlPoint(iterator, "WindowPosition", WindowPosition);
             WindowSize     = GetXmlSize(iterator, "WindowSize", WindowSize);
             WindowState    = GetXmlWindowState(iterator, "WindowState", WindowState);
             LogLevel       = GetXmlLogLevel(iterator, "LogLevel", LogLevel);
         }
     }
     catch (Exception e)
     {
         MpeLog.Debug(e);
         throw new MpeParserException(e.Message);
     }
 }
Пример #4
0
 protected void OnClosed(object sender, EventArgs e)
 {
     try
     {
         SaveConfiguration();
         SavePreferences();
     }
     catch (Exception ee)
     {
         MpeLog.Warn(ee);
     }
 }
Пример #5
0
 private static void Main()
 {
     try
     {
         Application.Run(new MediaPortalEditor());
     }
     catch (Exception e)
     {
         MpeLog.Debug(e);
         MpeLog.Error(e);
     }
 }
Пример #6
0
 protected void OnLoad(object sender, EventArgs e)
 {
     Size = new Size(1024, 768);
     CenterToScreen();
     Cursor = Cursors.WaitCursor;
     // Load Editor Configuration
     LoadConfiguration();
     // Continue Initialization
     MpeLog.Info("Initializing...");
     initTimer.Interval = 100;
     initTimer.Start();
 }
Пример #7
0
 public void AddDesigner(MpeDesigner designer)
 {
     try
     {
         designer.Initialize();
     }
     catch (DesignerException ee)
     {
         MpeLog.Debug(ee);
         MpeLog.Warn(ee);
         PropertyManager.SelectedResource = null;
         MessageBox.Show(this, ee.Message, "Designer Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (tabManager.TabPages[designer.ResourceName] == null)
     {
         TabPage newTab = new TabPage(designer.ResourceName, (Control)designer, 4);
         if (designer is MpeControlDesigner)
         {
             newTab.ImageIndex = 0;
         }
         else if (designer is FontDesigner)
         {
             newTab.ImageIndex = 1;
         }
         else if (designer is MpeImageDesigner)
         {
             newTab.ImageIndex = 2;
         }
         else if (designer is MpeScreenDesigner)
         {
             newTab.ImageIndex = 3;
         }
         else if (designer is MpeStringDesigner)
         {
             newTab.ImageIndex = 4;
         }
         else if (designer is MpeHelpBrowser)
         {
             newTab.ImageIndex = 5;
         }
         newTab.Tag = designer;
         tabManager.TabPages.Add(newTab);
         tabManager.SelectedTab = newTab;
         tabManager.ShowClose   = true;
     }
     else
     {
         tabManager.SelectedTab = tabManager.TabPages[designer.ResourceName];
     }
 }
Пример #8
0
        protected void OnInitEditor(object sender, EventArgs e)
        {
            initTimer.Stop();

            // Create Preferences
            try
            {
                preferences = new MpePreferences("preferences.xml");
            }
            catch
            {
                MessageBox.Show(this, "Invalid preferences file!", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            // Load Preferences
            try
            {
                LoadPreferences();
            }
            catch (Exception ee)
            {
                MpeLog.Debug(ee.Message);
            }

            while (preferences.MediaPortalDir == null)
            {
                MessageBox.Show(this, "You must set your MediaPortal directory in order to continue.", "MediaPortalEditor",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                MpePreferenceForm form = new MpePreferenceForm();
                if (form.ShowDialog(this) == DialogResult.Cancel)
                {
                    DialogResult r =
                        MessageBox.Show(this,
                                        "You must set your MediaPortal directory.  Click Retry" + Environment.NewLine +
                                        "to select the directory, or Cancel to exit the application.", "Invalid Directory",
                                        MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (r == DialogResult.Cancel)
                    {
                        Close();
                    }
                    else
                    {
                        initTimer.Start();
                        return;
                    }
                }
            }
            MpeLog.Info("MediaPortal Editor");
            Cursor = Cursors.Default;
        }
Пример #9
0
 protected void OnMenuSaveAll(object source, EventArgs e)
 {
     MpeDesigner[] designers = GetModifiedDesigners();
     for (int i = 0; i < designers.Length; i++)
     {
         try
         {
             designers[i].Save();
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             MpeLog.Error(ee);
         }
     }
 }
Пример #10
0
 protected void LoadConfiguration()
 {
     StatusBar.Info("Loading configuration...");
     if (File.Exists("config.xml"))
     {
         try
         {
             dockManager.LoadConfigFromFile("config.xml");
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             MpeLog.Warn(ee);
         }
     }
 }
Пример #11
0
 protected void OnMenuSave(object source, EventArgs e)
 {
     if (tabManager.SelectedTab != null)
     {
         try
         {
             MpeDesigner designer = (MpeDesigner)tabManager.SelectedTab.Tag;
             designer.Save();
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             MpeLog.Error(ee);
         }
     }
 }
Пример #12
0
        protected void OnClosing(object sender, CancelEventArgs e)
        {
            MpeDesigner[] designers = GetModifiedDesigners();
            if (designers.Length == 0)
            {
                Cursor = Cursors.Default;
                return;
            }
            MpeSaveForm  form   = new MpeSaveForm(designers, tabImageList);
            DialogResult result = form.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                e.Cancel = true;
                return;
            }
            else if (result == DialogResult.Yes)
            {
                for (int i = 0; i < form.SelectedDesigners.Length; i++)
                {
                    try
                    {
                        form.SelectedDesigners[i].Save();
                    }
                    catch (Exception ee)
                    {
                        MpeLog.Debug(ee);
                        MpeLog.Error(ee);
                    }
                }
            }
            else if (result == DialogResult.No)
            {
                for (int i = 0; i < form.SelectedDesigners.Length; i++)
                {
                    try
                    {
                        form.SelectedDesigners[i].Cancel();
                    }
                    catch (Exception ee)
                    {
                        MpeLog.Debug(ee);
                        MpeLog.Error(ee);
                    }
                }
            }
        }
Пример #13
0
        protected void OnDesignerClosed(object source, EventArgs args)
        {
            Cursor = Cursors.WaitCursor;
            MpeDesigner designer = (MpeDesigner)tabManager.SelectedTab.Tag;

            if (tabManager.SelectedTab.Title.EndsWith("*"))
            {
                MpeSaveForm form = new MpeSaveForm(new MpeDesigner[1] {
                    designer
                }, tabImageList);
                DialogResult result = form.ShowDialog(this);
                if (result == DialogResult.Cancel)
                {
                    Cursor = Cursors.Default;
                    return;
                }
                else if (result == DialogResult.Yes)
                {
                    OnMenuSave(source, args);
                }
                else if (result == DialogResult.No)
                {
                    designer.Cancel();
                }
            }
            selectedDesignerIndex = -1;
            tabManager.TabPages.Remove(tabManager.SelectedTab);
            try
            {
                designer.Destroy();
                if (designer is MpeHelpBrowser)
                {
                    helpBrowser = null;
                }
            }
            catch (Exception e)
            {
                MpeLog.Debug(e);
                MpeLog.Error(e);
            }
            if (tabManager.TabPages.Count == 0)
            {
                tabManager.ShowClose = false;
            }
            Cursor = Cursors.Default;
        }
Пример #14
0
 private void CopyFiles(DirectoryInfo source, DirectoryInfo destination)
 {
     MpeLog.Info("Copying files [" + source.FullName + "]");
     FileInfo[] files = source.GetFiles();
     MpeLog.Progress(0, files.Length, 0);
     for (int i = 0; i < files.Length; i++)
     {
         FileInfo f = files[i].CopyTo(destination.FullName + "\\" + files[i].Name);
         MpeLog.Debug("Created [" + f.FullName + "]", i);
     }
     DirectoryInfo[] dirs = source.GetDirectories();
     for (int i = 0; i < dirs.Length; i++)
     {
         DirectoryInfo destdir = destination.CreateSubdirectory(dirs[i].Name);
         CopyFiles(dirs[i], destdir);
     }
 }
Пример #15
0
 protected void OnDesignerIndexChanged(object source, EventArgs args)
 {
     if (selectedDesignerIndex != -1)
     {
         MpeDesigner d = (MpeDesigner)tabManager.TabPages[selectedDesignerIndex].Tag;
         if (d != null)
         {
             try
             {
                 d.Pause();
             }
             catch (Exception ee)
             {
                 MpeLog.Error(ee);
             }
         }
     }
     if (tabManager.SelectedTab != null)
     {
         MpeDesigner designer = (MpeDesigner)tabManager.SelectedTab.Tag;
         selectedDesignerIndex = tabManager.SelectedIndex;
         try
         {
             designer.Resume();
         }
         catch (Exception ee)
         {
             MpeLog.Error(ee);
         }
         if (tabManager.SelectedTab.Title.EndsWith("*"))
         {
             fileMenu.MenuCommands["&Save"].Enabled = true;
         }
         else
         {
             fileMenu.MenuCommands["&Save"].Enabled = false;
         }
     }
 }
Пример #16
0
 public void ShowHelp(FileInfo file)
 {
     if (helpBrowser == null)
     {
         MpeLog.Info("Creating help browser...");
         helpBrowser = new MpeHelpBrowser(this);
     }
     AddDesigner(helpBrowser);
     try
     {
         Cursor = Cursors.WaitCursor;
         helpBrowser.ShowHelp(file);
     }
     catch (Exception e)
     {
         MessageBox.Show(this, e.Message, "Help Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         Cursor = Cursors.Default;
     }
 }
Пример #17
0
        protected void OnMenuNew(object source, EventArgs e)
        {
            MpeSkinBrowserDialog f      = new MpeSkinBrowserDialog();
            DialogResult         result = f.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                try
                {
                    DirectoryInfo skinDir = f.NewSkinDir;
                    skinDir.Create();
                    MpeLog.Info("Creating new skin [" + skinDir.FullName + "]");
                    CopyFiles(f.SelectedSkinDir, skinDir);
                    skinDir.Refresh();
                    MpeLog.Info("Created new skin [" + skinDir.Name + "]");
                    OpenSkin(skinDir);
                }
                catch (Exception ee)
                {
                    MessageBox.Show(this, ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
        }
Пример #18
0
 protected void OnMenuClose(object source, EventArgs e)
 {
     if (skinExplorer.IsSkinLoaded == false)
     {
         return;
     }
     if (DialogResult.No ==
         MessageBox.Show(this, "Are you sure you want to close the current skin?", "Close Confirmation",
                         MessageBoxButtons.YesNo, MessageBoxIcon.Question))
     {
         cancelCommand = true;
         return;
     }
     MpeDesigner[] designers = GetModifiedDesigners();
     if (designers.Length > 0)
     {
         MpeSaveForm  form   = new MpeSaveForm(designers, tabImageList);
         DialogResult result = form.ShowDialog(this);
         if (result == DialogResult.Cancel)
         {
             return;
         }
         else if (result == DialogResult.Yes)
         {
             for (int i = 0; i < form.SelectedDesigners.Length; i++)
             {
                 try
                 {
                     form.SelectedDesigners[i].Save();
                 }
                 catch (Exception ee)
                 {
                     MpeLog.Debug(ee);
                     MpeLog.Error(ee);
                 }
             }
         }
         else if (result == DialogResult.No)
         {
             for (int i = 0; i < form.SelectedDesigners.Length; i++)
             {
                 try
                 {
                     form.SelectedDesigners[i].Cancel();
                 }
                 catch (Exception ee)
                 {
                     MpeLog.Debug(ee);
                     MpeLog.Error(ee);
                 }
             }
         }
     }
     try
     {
         selectedDesignerIndex = -1;
         for (int i = 0; i < tabManager.TabPages.Count; i++)
         {
             MpeDesigner designer = (MpeDesigner)tabManager.TabPages[i].Tag;
             designer.Destroy();
         }
         tabManager.TabPages.Clear();
     }
     catch
     {
         //
     }
     skinExplorer.CloseSkin();
     fileMenu.MenuCommands["&Close"].Enabled = false;
     Text = "MediaPortalEditor";
     MpeLog.Info("Skin closed");
 }