/// <summary> /// Writes the skins file to disk to with all NoteFly skins. /// </summary> /// <param name="host"></param> /// <param name="editskinnr"></param> /// <param name="editskin"></param> /// <returns>true if writing skins file was succesfull.</returns> public static bool WriteSkinsFileEditSkin(IPlugin.IPluginHost host, int editskinnr, Skin editskin) { XmlTextWriter xmlwriter = null; bool succeed = false; try { xmlwriter = WriteSkinFileHeader(host.GetSkinsFile()); for (int i = 0; i < host.CountSkins; i++) { Skin currentskin = null; if (editskinnr == i) { currentskin = editskin; } else { currentskin = SkinFactory.GetSkin(host, i); } WriteSkinsFileSkin(xmlwriter, currentskin); } xmlwriter = WriteSkinFileFooter(xmlwriter); succeed = true; } finally { if (xmlwriter != null) { xmlwriter.Close(); } } return succeed; }
/// <summary> /// Show a preview of a note with a skin given by the skinnr. /// </summary> public void DrawNoteSkinPreview(Skin skin) { FontStyle titlestyle = FontStyle.Regular; if (this.host.GetSettingBool("FontTitleStylebold")) { titlestyle = FontStyle.Bold; } this.skin = skin; this.lblPreviewNoteTitle.ForeColor = skin.TextClr; this.lblPreviewNoteTitle.Font = new Font(this.host.GetSettingString("FontTitleFamily"), this.host.GetSettingFloat("FontTitleSize"), titlestyle); this.lblPreviewNoteContent.ForeColor = skin.TextClr; this.lblPreviewNoteContent.Font = new Font(this.host.GetSettingString("FontContentFamily"), this.host.GetSettingFloat("FontContentSize")); bool useprimarytexture = false; if (!string.IsNullOrEmpty(skin.PrimaryTexture)) { if (File.Exists(skin.PrimaryTexture)) { this.pnlPreviewNoteWindow.BackgroundImage = Image.FromFile(skin.PrimaryTexture); useprimarytexture = true; } else if (File.Exists(this.host.GetInstallFolder() + skin.PrimaryTexture)) { this.pnlPreviewNoteWindow.BackgroundImage = Image.FromFile(this.host.GetInstallFolder() + skin.PrimaryTexture); useprimarytexture = true; } } if (useprimarytexture) { this.pnlPreviewNoteWindow.BackgroundImageLayout = skin.PrimaryTextureLayout; this.pnlPreviewNoteHead.BackColor = Color.Transparent; this.pnlPreviewNoteContent.BackColor = Color.Transparent; } else { this.pnlPreviewNoteWindow.BackgroundImage = null; this.pnlPreviewNoteHead.BackColor = skin.PrimaryClr; this.pnlPreviewNoteContent.BackColor = skin.PrimaryClr; } if (this.lblPreviewNoteTitle.Height + this.lblPreviewNoteTitle.Location.Y >= this.pnlPreviewNoteHead.Height) { if (this.lblPreviewNoteTitle.Height < this.host.GetSettingInt("NotesTitlepanelMaxHeight")) { this.pnlPreviewNoteHead.Height = this.lblPreviewNoteTitle.Height; } else { this.pnlPreviewNoteHead.Height = this.host.GetSettingInt("NotesTitlepanelMaxHeight"); } } else { this.pnlPreviewNoteHead.Height = this.host.GetSettingInt("NotesTitlepanelMinHeight"); } this.pnlPreviewNoteContent.Location = new Point(0, this.pnlPreviewNoteHead.Height); this.pnlPreviewNoteContent.Size = new Size(200, 172 - this.pnlPreviewNoteHead.Height); this.gbxPreviewNote.Visible = true; }
/// <summary> /// /// </summary> /// <returns></returns> public static Skin CreateDefaultNewSkin() { Skin defaultskin = new Skin(); defaultskin.Name = string.Empty; defaultskin.PrimaryClr = Color.White; defaultskin.SelectClr = Color.Gray; defaultskin.HighlightClr = Color.WhiteSmoke; defaultskin.TextClr = Color.Black; return defaultskin; }
/// <summary> /// /// </summary> /// <param name="skinnr"></param> public static Skin GetSkin(IPlugin.IPluginHost host, int skinnr) { Skin skin = new Skin(); skin.Name = host.GetSkinName(skinnr); skin.PrimaryClr = host.GetPrimaryClr(skinnr); skin.SelectClr = host.GetSelectClr(skinnr); skin.HighlightClr = host.GetHighlightClr(skinnr); skin.TextClr = host.GetTextClr(skinnr); skin.PrimaryTexture = host.GetPrimaryTextureFile(skinnr); skin.PrimaryTextureLayout = host.GetPrimaryTextureLayout(skinnr); return skin; }
/// <summary> /// Write a skin xml element /// </summary> /// <param name="xmlwriter">The xmlwriter</param> /// <param name="currentskin"></param> private static void WriteSkinsFileSkin(XmlWriter xmlwriter, Skin currentskin) { xmlwriter.WriteStartElement("skin"); xmlwriter.WriteElementString("Name", currentskin.Name); xmlwriter.WriteStartElement("PrimaryClr"); if (!string.IsNullOrEmpty(currentskin.PrimaryTexture)) { xmlwriter.WriteAttributeString("texture", currentskin.PrimaryTexture); string texturelayout; try { texturelayout = Enum.GetName(currentskin.PrimaryTextureLayout.GetType(), currentskin.PrimaryTextureLayout); } catch (Exception) { texturelayout = "tile"; } xmlwriter.WriteAttributeString("texturelayout", texturelayout); } xmlwriter.WriteString(SkinFactory.ClrObjToHtmlHexClr(currentskin.PrimaryClr)); xmlwriter.WriteEndElement(); xmlwriter.WriteElementString("SelectClr", SkinFactory.ClrObjToHtmlHexClr(currentskin.SelectClr)); xmlwriter.WriteElementString("HighlightClr", SkinFactory.ClrObjToHtmlHexClr(currentskin.HighlightClr)); xmlwriter.WriteElementString("TextClr", SkinFactory.ClrObjToHtmlHexClr(currentskin.TextClr)); xmlwriter.WriteEndElement(); }
/// <summary> /// Set the mode of the editor. /// </summary> /// <param name="newmode">The new mode of the skinseditor.</param> private void setEditorMode(skineditormode newmode) { this.skinaction = newmode; switch (newmode) { case skineditormode.browseskins: this.btnEditSkin.Text = "&edit skin"; this.btnNewSkin.Text = "&new skin"; this.btnNewSkin.Enabled = true; this.btnEditSkin.Enabled = true; this.btnDeleteSkin.Enabled = true; this.SetFieldsEnabled(false); if (this.lbxSkins.SelectedIndex >= 0) { this.skin = SkinFactory.GetSkin(this.host, this.lbxSkins.SelectedIndex); this.SetFieldsCurrentSkin(); } break; case skineditormode.editskin: this.btnEditSkin.Text = "cancel &edit skin"; this.btnNewSkin.Text = "&new skin"; this.btnEditSkin.Enabled = true; this.btnNewSkin.Enabled = false; this.btnDeleteSkin.Enabled = false; this.editskinnr = this.lbxSkins.SelectedIndex; this.skin = SkinFactory.GetSkin(this.host, this.editskinnr); this.SetFieldsEnabled(true); this.SetFieldsCurrentSkin(); break; case skineditormode.newskin: this.btnEditSkin.Text = "&edit skin"; this.btnNewSkin.Text = "cancel &new skin"; this.btnNewSkin.Enabled = true; this.btnEditSkin.Enabled = false; this.btnDeleteSkin.Enabled = false; this.ClearFields(); this.skin = SkinFactory.CreateDefaultNewSkin(); this.SetFieldsEnabled(true); break; } }