示例#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
 private static void Main()
 {
     try
     {
         Application.Run(new MediaPortalEditor());
     }
     catch (Exception e)
     {
         MpeLog.Debug(e);
         MpeLog.Error(e);
     }
 }
示例#5
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;
        }
示例#6
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];
     }
 }
示例#7
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);
         }
     }
 }
示例#8
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);
         }
     }
 }
示例#9
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);
         }
     }
 }
示例#10
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);
                    }
                }
            }
        }
示例#11
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;
        }
示例#12
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);
     }
 }
示例#13
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");
 }