internal static void LoadSkin(string skinPath, PNSkinDetails skd) { try { //open skin file as regular zip archive using (Package package = Package.Open(skinPath, FileMode.Open, FileAccess.Read)) { //build parameters file URI Uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("data.xml", UriKind.Relative)); //get parameters file PackagePart documentPart = package.GetPart(uriTarget); //read parameters file with XmlReader var xrs = new XmlReaderSettings { IgnoreWhitespace = true }; using (XmlReader xr = XmlReader.Create(documentPart.GetStream(), xrs)) { var arr = new string[] { }; //load parameters file into XDocument var xdoc = XDocument.Load(xr); //get mask color var xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("mask_color"); if (element != null) arr = element.Value.Split((',')); } skd.MaskColor = Color.FromArgb(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant)); //get delete/hide position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("delete_hide"); if (element1 != null) arr = element1.Value.Split((',')); } } skd.PositionDelHide = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); //get marks position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("marks"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionMarks = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get toolbar position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("toolbar"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionToolbar = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get edit box position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("edit_box"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionEdit = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get tooltip position xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("tooltip"); if (element1 != null) { arr = element1.Value.Split((',')); skd.PositionTooltip = new Rectangle(int.Parse(arr[0], PNStatic.CultureInvariant), int.Parse(arr[1], PNStatic.CultureInvariant), int.Parse(arr[2], PNStatic.CultureInvariant), int.Parse(arr[3], PNStatic.CultureInvariant)); } } } //get skin info xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("skin_info"); if (element != null) skd.SkinInfo = element.Value; } //get possible vertical toolbar xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("vertical_toolbar"); if (element != null) skd.VerticalToolbar = bool.Parse(element.Value); } //get marks count xElement = xdoc.Element("data"); if (xElement != null) { var element = xElement.Element("dimensions"); if (element != null) { var element1 = element.Element("marks_count"); if (element1 != null) skd.MarksCount = int.Parse(element1.Value, PNStatic.CultureInvariant); } } } //build body image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("body.png", UriKind.Relative)); //extract body image PackagePart resourcePart = package.GetPart(uriTarget); //save body image skd.BitmapSkin = PNStatic.MakeTransparentBitmap( Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build pattern image uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("pattern.png", UriKind.Relative)); //extract pattern image resourcePart = package.GetPart(uriTarget); //save pattern image skd.BitmapPattern = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build inactive pattern image uri uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("inactivepattern.png", UriKind.Relative)); if (package.PartExists(uriTarget)) { //extract inactive pattern image resourcePart = package.GetPart(uriTarget); //save inactive pattern image skd.BitmapInactivePattern = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); } else { skd.BitmapInactivePattern = null; } //build delete/hide image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("dh.png", UriKind.Relative)); //extract delete/hide image resourcePart = package.GetPart(uriTarget); //save delete/hide image skd.BitmapDelHide = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build marks image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("marks.png", UriKind.Relative)); //extract marks image resourcePart = package.GetPart(uriTarget); //save marks image skd.BitmapMarks = PNStatic.MakeTransparentBitmap( Image.FromStream(resourcePart.GetStream()), skd.MaskColor); //build toolbar image URI uriTarget = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), new Uri("tbr.png", UriKind.Relative)); //extract toolbar image resourcePart = package.GetPart(uriTarget); //save toolbar image skd.BitmapCommands = PNStatic.MakeTransparentBitmap(Image.FromStream(resourcePart.GetStream()), skd.MaskColor); } } catch (Exception ex) { PNStatic.LogException(ex); } }
private void cmdStandard_Click(object sender, RoutedEventArgs e) { Skinless = (PNSkinlessDetails)_Group.Skinless.Clone(); Skin = _Group.Skin.PNClone(); _Opacity = PNStatic.Settings.Behavior.Opacity; trkTrans.Value = (int)(100 - (_Opacity * 100)); pckBGSknls.SelectedColor = Skinless.BackColor; blkCaption.DataContext = Skinless.CaptionFont; if (GridSkinnable.Visibility == Visibility.Visible) { if (Skin.SkinName != PNSkinDetails.NO_SKIN) { lstSkins.SelectedItem = lstSkins.Items.OfType<PNListBoxItem>().FirstOrDefault(it => it.Text == Skin.SkinName); } else { lstSkins.SelectedIndex = -1; } } _CustomOpacity = _CustomSkin = _CustomSkinless = false; }
private void DlgAdjustAppearance_Loaded(object sender, RoutedEventArgs e) { try { if (PNStatic.Settings.GeneralSettings.UseSkins) { GridSkinless.Visibility = Visibility.Hidden; GridSkinnable.Visibility = Visibility.Visible; } _CustomOpacity = _Note.CustomOpacity; applyLanguage(); if (_CustomOpacity) { trkTrans.Value = (int)(100 - (_Note.Opacity * 100)); _Opacity = _Note.Opacity; } else { trkTrans.Value = (int)(100 - (PNStatic.Settings.Behavior.Opacity * 100)); _Opacity = PNStatic.Settings.Behavior.Opacity; } _Group = PNStatic.Groups.GetGroupByID(_Note.GroupID); if (_Group == null) { throw new Exception("Group cannot be null"); } if (_Note.Skinless != null) { _CustomSkinless = true; Skinless = (PNSkinlessDetails)_Note.Skinless.Clone(); } else { Skinless = (PNSkinlessDetails)_Group.Skinless.Clone(); } blkCaption.DataContext = Skinless.CaptionFont; pckBGSknls.SelectedColor = Skinless.BackColor; if (GridSkinnable.Visibility == Visibility.Visible) { if (_Note.Skin != null) { _CustomSkin = true; Skin = _Note.Skin.PNClone(); } else { Skin = _Group.Skin.PNClone(); } loadSkinsList(); if (Skin.SkinName != PNSkinDetails.NO_SKIN) { lstSkins.SelectedItem = lstSkins.Items.OfType<PNListBoxItem>().FirstOrDefault(it => it.Text == Skin.SkinName); } else { lstSkins.SelectedIndex = -1; } } } catch (Exception ex) { PNStatic.LogException(ex); } }
public bool Equals(PNSkinDetails sk) { if ((object)sk == null) return false; return (_SkinName == sk._SkinName); }
internal NoteAppearanceAdjustedEventArgs(bool custOpacity, bool custSkinless, bool custSkin, double opacity, PNSkinlessDetails skinless, PNSkinDetails skin) { _CustomOpacity = custOpacity; _CustomSkinless = custSkinless; _CustomSkin = custSkin; _Opacity = opacity; _Skinless = skinless; _Skin = skin; }
internal void Clear() { _Skin.Dispose(); _Skin = new PNSkinDetails(); _Skinless = new PNSkinlessDetails(); var lf = new LOGFONT(); lf.Init(); lf.SetFontFace(PNStrings.DEFAULT_FONT_NAME); lf.SetFontSize(PNStatic.DEFAULT_FONTSIZE); _Font = lf; _FontColor = PNStatic.DefaultFontColor; }