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