public MpeFont(MpeFont font)
 {
     textureWorkDir  = font.textureWorkDir;
     name            = font.name;
     systemFont      = new Font(font.systemFont.FontFamily, font.systemFont.Size, font.systemFont.Style);
     spacingPerChar  = font.spacingPerChar;
     startChar       = font.startChar;
     endChar         = font.endChar;
     textureFile     = font.textureFile;
     textureDataFile = font.TextureDataFile;
     if (font.texture != null)
     {
         try
         {
             texture = new Bitmap(font.texture, font.texture.Width, font.texture.Height);
         }
         catch (Exception e)
         {
             MpeLog.Warn(e);
         }
     }
     if (font.textureCoordinates != null)
     {
         textureCoordinates = new float[font.textureCoordinates.GetLength(0), font.textureCoordinates.GetLength(1)];
         for (int i = 0; i < textureCoordinates.GetLength(0); i++)
         {
             for (int j = 0; j < textureCoordinates.GetLength(1); j++)
             {
                 textureCoordinates[i, j] = font.textureCoordinates[i, j];
             }
         }
         ConvertTextureData();
     }
 }
        private void OnPanelClick(object sender, StatusBarPanelClickEventArgs e)
        {
            if (e.StatusBarPanel == iconPanel && sender == this)
            {
                MenuCommand c = menu.TrackPopup(PointToScreen(new Point(0, -90)), false);
                if (c != null)
                {
                    switch (c.Text)
                    {
                    case "Debug":
                        MpeLog.Threshold = MpeLogLevel.Debug;
                        MpeLog.Debug("Log Level set to Debug");
                        break;

                    case "Info":
                        MpeLog.Threshold = MpeLogLevel.Info;
                        MpeLog.Info("Log Level set to Info");
                        break;

                    case "Warn":
                        MpeLog.Threshold = MpeLogLevel.Warn;
                        MpeLog.Warn("Log Level set to Warn");
                        break;

                    case "Error":
                        MpeLog.Threshold = MpeLogLevel.Error;
                        MpeLog.Error("Log Level set to Error");
                        break;
                    }
                }
            }
        }
 private void OnItemTypeChanging(MpeItemEventArgs e)
 {
     if (e.NewType == MpeItemType.Text)
     {
         MpeLog.Warn("SpinButton items must be of type Integer or Float");
         e.CancelTypeChange = true;
     }
 }
 private void OnItemTypeChanging(MpeItemEventArgs e)
 {
     if (e.NewType != MpeItemType.Text)
     {
         MpeLog.Warn("MpeSelectButton items must be of type of Text");
         e.CancelTypeChange = true;
     }
 }
Beispiel #5
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is String)
     {
         string s = (string)value;
         if (s.IndexOf(",") < 0)
         {
             try
             {
                 int i = int.Parse(s);
                 return(new MpeControlPadding(i));
             }
             catch
             {
                 MpeLog.Warn("Invalid format for padding property.");
                 throw new ArgumentException("Invalid format for padding property [" + s + "]");
             }
         }
         else
         {
             MpeControlPadding padding = new MpeControlPadding();
             try
             {
                 string[] ss = s.Split(',');
                 if (ss == null || (ss.Length != 4 && ss.Length != 2))
                 {
                     MpeLog.Warn("Invalid format for padding property [" + s + "]");
                     throw new ArgumentException("Invalid format for padding property [" + s + "]");
                 }
                 if (ss.Length == 4)
                 {
                     padding.Left   = int.Parse(ss[0].Trim());
                     padding.Right  = int.Parse(ss[1].Trim());
                     padding.Top    = int.Parse(ss[2].Trim());
                     padding.Bottom = int.Parse(ss[3].Trim());
                 }
                 else
                 {
                     padding.Left   = int.Parse(ss[0].Trim());
                     padding.Right  = padding.Left;
                     padding.Top    = int.Parse(ss[1].Trim());
                     padding.Bottom = padding.Top;
                 }
                 return(padding);
             }
             catch (Exception ee)
             {
                 MpeLog.Debug(ee);
                 MpeLog.Warn("Invalid format for padding property [" + s + "]");
                 throw new ArgumentException("Invalid format for padding property [" + s + "]");
             }
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Beispiel #6
0
 protected override void OnPaddingChanged()
 {
     if (LayoutStyle == MpeLayoutStyle.Grid)
     {
         MpeLog.Warn("Padding cannot be changed. The control belongs to a grid layout.");
         Padding = new MpeControlPadding(0);
     }
     else
     {
         Prepare();
     }
 }
 public void Add(MpeResource resource)
 {
     if (resource == null)
     {
         MpeLog.Warn("The control was null and therefore not added to the resource collection.");
         return;
     }
     if (IsUniqueId(resource.Id) == false)
     {
         int id = GenerateUniqueId();
         MpeLog.Warn("The control id must be unique. The id [" + resource.Id + "] will be changed to [" + id + "]");
         resource.Id = id;
     }
     resources.Add(resource);
 }
Beispiel #8
0
 public void SendBack()
 {
     if (MpeParent != null)
     {
         try
         {
             int i = MpeParent.Controls.GetChildIndex(this, true);
             MpeParent.Controls.SetChildIndex(this, (i + 1));
             MpeParent.Prepare();
         }
         catch (Exception ee)
         {
             MpeLog.Warn(ee);
         }
     }
 }
Beispiel #9
0
 public void LoadHelp()
 {
     while (mpe.Preferences == null)
     {
         Thread.Sleep(250);
     }
     preferences = mpe.Preferences;
     if (preferences.HelpDir == null || preferences.HelpDir.Exists == false)
     {
         MpeLog.Warn("Could not initialize HelpManager!");
         return;
     }
     rootNode = new TreeNode("Help", 0, 0);
     LoadHelpFiles(rootNode, preferences.HelpDir);
     Invoke(new UpdateHelpTreeDelegate(UpdateHelpTree), new object[] { rootNode });
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (value is MpeItemCollection)
     {
         MpeItemCollection c = (MpeItemCollection)value;
         if (c.Type == MpeItemType.Text)
         {
             return(base.EditValue(context, provider, value));
         }
         else
         {
             MpeLog.Warn("To edit this collection set the First, Last, Interval, and Digits properties.");
         }
     }
     return(value);
 }
Beispiel #11
0
 private void OnBeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Node.Parent != imageNode && e.Node.Parent != screenNode && e.Node.Parent != fontNode)
     {
         e.CancelEdit = true;
         e.Node.EndEdit(true);
     }
     if (mpe.IsResourceOpen(e.Node.Text))
     {
         MpeLog.Warn("The resource file cannot be renamed because it is currently being editted.");
         MessageBox.Show(this, "The resource file cannot be renamed because it is currently being editted.",
                         "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         e.CancelEdit = true;
         e.Node.EndEdit(true);
         return;
     }
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context.Instance is MpeTagCollection)
            {
                MpeTagCollection tags = (MpeTagCollection)context.Instance;
                MpeTag           tag  = tags[context.PropertyDescriptor.DisplayName];
                if (tag != null)
                {
                    IWindowsFormsEditorService editorService =
                        (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    MpeTagEditorForm form = new MpeTagEditorForm(tag, editorService);
                    editorService.DropDownControl(form);
                    switch (form.Result)
                    {
                    case DialogResult.OK:
                        if (tag.Name == form.TagName && tag.Name != "-")
                        {
                            tag.Value = form.TagValue;
                            MpeLog.Info("Tag Updated! Name = " + tag.Name + " Value = " + tag.Value);
                        }
                        else if (tag.Name == form.TagName)
                        {
                            MpeLog.Warn("Invalid tag name specified");
                        }
                        else
                        {
                            tags.Remove(tag.Name);
                            tag.Name  = form.TagName;
                            tag.Value = form.TagValue;
                            tags.Add(tag);
                            MpeLog.Info("Tag Updated! Name = [" + tag.Name + "] Value = [" + tag.Value + "]");
                        }
                        break;

                    case DialogResult.Abort:
                        tags.Remove(tag.Name);
                        MpeLog.Info("Tag Removed! Name = [" + tag.Name + "[ Value = [" + tag.Value + "]");
                        break;
                    }
                    return(tag);
                }
            }
            return(base.EditValue(context, provider, value));
        }
Beispiel #13
0
 public void BringForward()
 {
     if (MpeParent != null)
     {
         try
         {
             int i = MpeParent.Controls.GetChildIndex(this, true);
             if (i > 0)
             {
                 MpeParent.Controls.SetChildIndex(this, (i - 1));
                 MpeParent.Prepare();
             }
         }
         catch (Exception ee)
         {
             MpeLog.Warn(ee);
         }
     }
 }
Beispiel #14
0
        public void OnDragDrop(object sender, DragEventArgs e)
        {
            MpeLog.Debug("OnDragDrop()");
            if (sender == null || !(sender is MpeContainer))
            {
                MpeLog.Warn("Could not locate parent MpeContainer... Cancelling DragDrop operation.");
                return;
            }
            MpeContainer mpc = (MpeContainer)sender;

            if (e.Data.GetDataPresent(typeof(MpeControlType)))
            {
                MpeControlType type = (MpeControlType)e.Data.GetData(typeof(MpeControlType));
                MpeLog.Debug("DragDrop: " + type.ToString());
                MpeControl c = Parser.CreateControl(type);
                c.Id       = ResourceList.GenerateUniqueId();
                c.Location = mpc.PointToClient(new Point(e.X, e.Y));
                mpc.Controls.Add(c);
                c.BringToFront();
                Mask.SelectedControl = c;
                UpdatePropertyManager();
            }
            else if (e.Data.GetDataPresent(typeof(FileInfo)))
            {
                FileInfo image = (FileInfo)e.Data.GetData(typeof(FileInfo));
                MpeImage mpi   = (MpeImage)Parser.CreateControl(MpeControlType.Image);
                mpi.Id = ResourceList.GenerateUniqueId();
                mpc.Controls.Add(mpi);
                mpi.Texture  = image;
                mpi.AutoSize = true;
                mpi.Location = mpc.PointToClient(new Point(e.X, e.Y));
                mpi.BringToFront();
                Mask.SelectedControl = mpi;
                UpdatePropertyManager();
            }
            else
            {
                MpeLog.Debug("Unknown DataType... Cancelling DragDrop");
                return;
            }
            Focus();
        }
        public void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeFont.Load()");
            textureWorkDir = parser.FontDir.FullName;
            name           = parser.GetString(iterator, "name", name);
            string    family = parser.GetString(iterator, "filename", Family);
            int       height = parser.GetInt(iterator, "height", Size);
            string    style  = parser.GetString(iterator, "style", "");
            FontStyle fs     = FontStyle.Regular;

            if (style.IndexOf("Bold") >= 0)
            {
                fs |= FontStyle.Bold;
            }
            if (style.IndexOf("Italic") >= 0)
            {
                fs |= FontStyle.Italic;
            }
            if (style.IndexOf("Underline") >= 0)
            {
                fs |= FontStyle.Underline;
            }
            if (style.IndexOf("Strikeout") >= 0)
            {
                fs |= FontStyle.Strikeout;
            }
            systemFont = new Font(family, (float)height, fs);
            startChar  = parser.GetInt(iterator, "start", startChar);
            if (startChar < 32)
            {
                startChar = 32;
            }
            endChar = parser.GetInt(iterator, "end", endChar) + 1;
            if (endChar > 256)
            {
                endChar = 256;
            }
            // Setup Texture Files
            if (textureWorkDir != null)
            {
                textureFile     = new FileInfo(textureWorkDir + "\\" + name + "_" + height + ".png");
                textureDataFile = new FileInfo(textureFile.FullName + ".xml");
                bool loaded = false;
                if (textureFile.Exists)
                {
                    Bitmap b = null;
                    try
                    {
                        b       = new Bitmap(textureFile.FullName);
                        texture = new Bitmap(b);
                        loaded  = true;
                    }
                    catch (Exception e)
                    {
                        MpeLog.Warn(e);
                    }
                    finally
                    {
                        if (b != null)
                        {
                            b.Dispose();
                        }
                    }
                }
                if (loaded && textureDataFile.Exists)
                {
                    loaded = false;
                    Stream r = null;
                    try
                    {
                        r = File.Open(textureDataFile.FullName, FileMode.Open, FileAccess.Read);
                        textureCoordinates = (float[, ]) new SoapFormatter().Deserialize(r);
                        spacingPerChar     = (int)textureCoordinates[endChar - startChar, 0];
                        ConvertTextureData();
                        loaded = true;
                    }
                    catch (Exception e)
                    {
                        MpeLog.Warn(e);
                    }
                    finally
                    {
                        if (r != null)
                        {
                            r.Close();
                        }
                    }
                }
                if (loaded)
                {
                    MpeLog.Info("Loaded font texture and data [" + name + "]");
                }
                else
                {
                    GenerateTexture();
                }
            }
        }
Beispiel #16
0
        protected void OnMenuSelection(MenuCommand c)
        {
            if (c == null)
            {
                return;
            }
            if (selectedNode == null || selectedNode.Parent == null)
            {
                return;
            }
            switch (c.Text)
            {
            case "Delete":
                if (mpe.IsResourceOpen(selectedNode.Text))
                {
                    MpeLog.Warn("The resource file cannot be deleted because it is currently being editted.");
                    MessageBox.Show(this, "The resource file cannot be deleted because it is currently being editted.",
                                    "Error Deleting File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (selectedNode.Parent == imageNode)
                {
                    DialogResult result =
                        MessageBox.Show(this,
                                        "Are you sure you want to permanently delete the selected image?\n\n" + selectedNode.Text,
                                        "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        try
                        {
                            Parser.DeleteImageFile(selectedNode.Text);
                            MpeLog.Info("Deleted image file [" + selectedNode.Text + "]");
                        }
                        catch (Exception ee)
                        {
                            MpeLog.Debug(ee);
                            MpeLog.Error(ee);
                        }
                        finally
                        {
                            LoadImages();
                        }
                    }
                }
                else if (selectedNode.Parent == screenNode)
                {
                    DialogResult result =
                        MessageBox.Show(this,
                                        "Are you sure you want to permanently delete the selected screen?\n\n" + selectedNode.Text,
                                        "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        try
                        {
                            Parser.DeleteScreenFile(selectedNode.Text);
                            MpeLog.Info("Deleted screen file [" + selectedNode.Text + "]");
                        }
                        catch (Exception ee)
                        {
                            MpeLog.Debug(ee);
                            MpeLog.Error(ee);
                        }
                        finally
                        {
                            LoadScreens();
                        }
                    }
                }
                else if (selectedNode.Parent == fontNode)
                {
                    DialogResult result =
                        MessageBox.Show(this,
                                        "Are you sure you want to permanently delete the selected font?\n\n" + selectedNode.Text,
                                        "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        try
                        {
                            Parser.DeleteFont(selectedNode.Text);
                            MpeLog.Info("Deleted font [" + selectedNode.Text + "]");
                        }
                        catch (Exception ee)
                        {
                            MpeLog.Debug(ee);
                            MpeLog.Error(ee);
                        }
                        finally
                        {
                            LoadFonts();
                        }
                    }
                }
                break;

            case "Rename":
                if (selectedNode.Parent == imageNode || selectedNode.Parent == screenNode || selectedNode.Parent == fontNode)
                {
                    skinTree.SelectedNode = selectedNode;
                    skinTree.LabelEdit    = true;
                    if (selectedNode.IsEditing == false)
                    {
                        selectedNode.BeginEdit();
                    }
                }
                break;

            case "Add Existing...":
                if (selectedNode == imageNode)
                {
                    openFileDialog.Title  = "Add Existing Image";
                    openFileDialog.Filter = "Image Files (*.png;*.jpg;*.gif;*.bmp)|*.PNG;*.JPG;*.GIF;*.BMP";
                    DialogResult result = openFileDialog.ShowDialog(this);
                    if (result == DialogResult.OK)
                    {
                        try
                        {
                            FileInfo newImageFile = Parser.AddImageFile(new FileInfo(openFileDialog.FileName));
                            LoadImages();
                            for (int i = 0; i < imageNode.Nodes.Count; i++)
                            {
                                if (imageNode.Nodes[i].Text.Equals(newImageFile.Name))
                                {
                                    selectedNode          = imageNode.Nodes[i];
                                    skinTree.SelectedNode = imageNode.Nodes[i];
                                    skinTree.LabelEdit    = true;
                                    selectedNode.BeginEdit();
                                    break;
                                }
                            }
                            MpeLog.Info("Added image file [" + newImageFile.FullName + "]");
                        }
                        catch (Exception ee)
                        {
                            MpeLog.Debug(ee);
                            MpeLog.Error(ee);
                        }
                    }
                }
                else if (selectedNode == screenNode)
                {
                    openFileDialog.Title  = "Add Existing Screen";
                    openFileDialog.Filter = "Screen Files (*.xml)|*.XML";
                    DialogResult result = openFileDialog.ShowDialog(this);
                    if (result == DialogResult.OK)
                    {
                        try
                        {
                            FileInfo newScreenFile = Parser.AddScreenFile(new FileInfo(openFileDialog.FileName));
                            LoadScreens();
                            for (int i = 0; i < screenNode.Nodes.Count; i++)
                            {
                                if (screenNode.Nodes[i].Text.Equals(newScreenFile.Name))
                                {
                                    selectedNode          = screenNode.Nodes[i];
                                    skinTree.SelectedNode = screenNode.Nodes[i];
                                    skinTree.LabelEdit    = true;
                                    selectedNode.BeginEdit();
                                    break;
                                }
                            }
                            MpeLog.Info("Added screen file [" + openFileDialog.FileName + "]");
                        }
                        catch (Exception ee)
                        {
                            MpeLog.Debug(ee);
                            MpeLog.Error(ee);
                        }
                    }
                }
                break;

            case "Add New...":
                if (selectedNode == screenNode)
                {
                    try
                    {
                        FileInfo f = Parser.AddScreenFile();
                        MpeLog.Info("Added new screen file [" + f.Name + "]");
                        LoadScreens();
                        for (int i = 0; i < screenNode.Nodes.Count; i++)
                        {
                            if (screenNode.Nodes[i].Text.Equals(f.Name))
                            {
                                skinTree.SelectedNode = screenNode.Nodes[i];
                                selectedNode          = screenNode.Nodes[i];
                                skinTree.LabelEdit    = true;
                                selectedNode.BeginEdit();
                                return;
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        MpeLog.Debug(ee);
                        MpeLog.Error(ee);
                    }
                }
                else if (selectedNode == fontNode)
                {
                    try
                    {
                        string s = Parser.AddFont();
                        MpeLog.Info("Added new font [" + s + "]");
                        LoadFonts();
                        for (int i = 0; i < fontNode.Nodes.Count; i++)
                        {
                            if (fontNode.Nodes[i].Text.Equals(s))
                            {
                                skinTree.SelectedNode = fontNode.Nodes[i];
                                selectedNode          = fontNode.Nodes[i];
                                skinTree.LabelEdit    = true;
                                selectedNode.BeginEdit();
                                return;
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        MpeLog.Debug(ee);
                        MpeLog.Error(ee);
                    }
                }
                break;

            case "Window":
                if (mpe.IsResourceOpen(selectedNode.Text))
                {
                    MpeLog.Warn("The screen type cannot be modified because it is currently being editted.");
                    MessageBox.Show(this, "The screen type cannot be modified because it is currently being editted..",
                                    "Error Modifying Screen Type", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (DialogResult.Yes ==
                        MessageBox.Show(this, "Are you sure you want to change this screen's type?", "Screen Type Confirmation",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        MpeScreenInfo info = Parser.ModifyScreenType(selectedNode.Text, MpeScreenType.Window);
                        selectedNode.Tag                = info;
                        selectedNode.ImageIndex         = 6;
                        selectedNode.SelectedImageIndex = 6;
                    }
                }
                break;

            case "Dialog":
                if (mpe.IsResourceOpen(selectedNode.Text))
                {
                    MpeLog.Warn("The screen type cannot be modified because it is currently being editted.");
                    MessageBox.Show(this, "The screen type cannot be modified because it is currently being editted..",
                                    "Error Modifying Screen Type", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (DialogResult.Yes ==
                        MessageBox.Show(this, "Are you sure you want to change this screen's type?", "Screen Type Confirmation",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        MpeScreenInfo info = Parser.ModifyScreenType(selectedNode.Text, MpeScreenType.Dialog);
                        selectedNode.Tag                = info;
                        selectedNode.ImageIndex         = 7;
                        selectedNode.SelectedImageIndex = 7;
                    }
                }
                break;

            case "OnScreenDisplay":
                if (mpe.IsResourceOpen(selectedNode.Text))
                {
                    MpeLog.Warn("The screen type cannot be modified because it is currently being editted.");
                    MessageBox.Show(this, "The screen type cannot be modified because it is currently being editted..",
                                    "Error Modifying Screen Type", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (DialogResult.Yes ==
                        MessageBox.Show(this, "Are you sure you want to change this screen's type?", "Screen Type Confirmation",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        MpeScreenInfo info = Parser.ModifyScreenType(selectedNode.Text, MpeScreenType.OnScreenDisplay);
                        selectedNode.Tag                = info;
                        selectedNode.ImageIndex         = 8;
                        selectedNode.SelectedImageIndex = 8;
                    }
                }
                break;
            }
        }
Beispiel #17
0
 private void OnAfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Node == null || e.Label == null)
     {
         return;
     }
     if (e.Node.Parent == imageNode)
     {
         int    i1 = e.Node.Text.LastIndexOf(".");
         string s1 = (i1 > 0) ? e.Node.Text.Substring(i1) : "";
         int    i2 = e.Label.LastIndexOf(".");
         string s2 = (i2 > 0) ? e.Label.Substring(i2) : "";
         if (s1.ToLower().Equals(s2.ToLower()) == false)
         {
             MessageBox.Show(this, "You cannot change an image file's extension.", "Error Renaming File",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
             e.CancelEdit = true;
             e.Node.BeginEdit();
             return;
         }
         try
         {
             FileInfo f = Parser.RenameImageFile(e.Node.Text, e.Label);
             e.Node.EndEdit(false);
             e.Node.Tag = f;
             MpeLog.Info("Renamed image file from [" + e.Node.Text + "] to [" + e.Label + "]");
             skinTree.LabelEdit = false;
             return;
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             if (ee.Message.IndexOf("being used by another process") > 0)
             {
                 MpeLog.Warn("The image file cannot be renamed because it is locked by another process.");
                 MessageBox.Show(this,
                                 "The image cannot be renamed because it is locked by another process.\n\nIf the image is currently open inside the MediaPortal Editor, please close the image, and try again.",
                                 "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else if (ee.Message.IndexOf("already exists") > 0)
             {
                 MpeLog.Warn("An image file with the name [" + e.Label + "] already exists.");
                 MessageBox.Show(this, "An image file with the name \"" + e.Label + "\" already exists.",
                                 "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 MpeLog.Error(ee);
                 MessageBox.Show(this, ee.Message, "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         e.CancelEdit = true;
         e.Node.EndEdit(true);
     }
     else if (e.Node.Parent == screenNode)
     {
         if (e.Label.ToLower().EndsWith(".xml") == false)
         {
             MessageBox.Show(this, "You cannot change a screen file's extension.", "Error Renaming File",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
             e.CancelEdit = true;
             e.Node.BeginEdit();
             return;
         }
         try
         {
             MpeScreenInfo info = Parser.RenameScreenFile(e.Node.Text, e.Label);
             e.Node.EndEdit(false);
             e.Node.Tag = info;
             MpeLog.Info("Renamed screen file from [" + e.Node.Text + "] to [" + e.Label + "]");
             skinTree.LabelEdit = false;
             return;
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             if (ee.Message.IndexOf("being used by another process") > 0)
             {
                 MpeLog.Warn("The screen file cannot be renamed because it is locked by another process.");
                 MessageBox.Show(this,
                                 "The screen cannot be renamed because it is locked by another process.\n\nIf the screen is currently open inside the MediaPortal Editor, please close the screen, and try again.",
                                 "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else if (ee.Message.IndexOf("already exists") > 0)
             {
                 MpeLog.Warn("A screen file with the name [" + e.Label + "] already exists.");
                 MessageBox.Show(this, "A screen file with the name \"" + e.Label + "\" already exists.",
                                 "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 MpeLog.Error(ee);
                 MessageBox.Show(this, ee.Message, "Error Renaming File", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         e.CancelEdit = true;
         e.Node.EndEdit(true);
     }
     else if (e.Node.Parent == fontNode)
     {
         try
         {
             Parser.RenameFont(e.Node.Text, e.Label);
             e.Node.EndEdit(false);
             e.Node.Tag = Parser.GetFont(e.Label);
             MpeLog.Info("Renamed font from [" + e.Node.Text + "] to [" + e.Label + "]");
             skinTree.LabelEdit = false;
             return;
         }
         catch (Exception ee)
         {
             MpeLog.Debug(ee);
             if (ee.Message.IndexOf("already exists") > 0)
             {
                 MpeLog.Warn("A font with the name [" + e.Label + "] already exists.");
                 MessageBox.Show(this, "A font with the name \"" + e.Label + "\" already exists.", "Error Renaming File",
                                 MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 MpeLog.Error(ee);
                 MessageBox.Show(this, ee.Message, "Error Renaming Font", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         e.CancelEdit = true;
         e.Node.EndEdit(true);
     }
     skinTree.LabelEdit = false;
 }
Beispiel #18
0
        protected virtual void OnLockChanged(MpeControlLockType type, bool value)
        {
            if (MpeParent != null)
            {
                switch (type)
                {
                case MpeControlLockType.Location:
                    if (MpeParent.Spring)
                    {
                        if (value == false)
                        {
                            MpeLog.Warn("Cannot change location lock. The control belongs to a spring layout.");
                            controlLock.Location = true;
                        }
                    }
                    else
                    {
                        if (MpeParent.LayoutStyle != MpeLayoutStyle.Grid)
                        {
                            if (value == false)
                            {
                                MpeLog.Warn("Cannot change location lock. The control belongs to a flow layout.");
                                controlLock.Location = true;
                            }
                        }
                    }
                    break;

                case MpeControlLockType.Size:
                    if (MpeParent.Spring)
                    {
                        if (value == false)
                        {
                            MpeLog.Warn("Cannot change size lock. The control belongs to a spring layout.");
                            controlLock.Size = true;
                        }
                    }
                    else
                    {
                        if (MpeParent.LayoutStyle == MpeLayoutStyle.Grid)
                        {
                            if (AutoSize)
                            {
                                if (value == false)
                                {
                                    MpeLog.Warn("Cannot change size lock. The control is autosized.");
                                    controlLock.Size = true;
                                }
                            }
                        }
                    }
                    break;
                }
            }
            if (type == MpeControlLockType.Location)
            {
                FirePropertyValueChanged("LocationLocked");
            }
            else
            {
                FirePropertyValueChanged("SizeLocked");
            }
        }