Example #1
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();
 }
Example #2
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;
        }
Example #3
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);
     }
 }
Example #4
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;
     }
 }
Example #5
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;
                }
            }
        }
Example #6
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");
 }