Пример #1
0
        /// <summary>
        /// Transform Photoshop's layer tree to Paint.NET's flat layer list.
        /// Indicate where layer sections begin and end, and hide all layers within
        /// hidden layer sections.
        /// </summary>
        private static void ApplyLayerSections(List <PhotoshopFile.Layer> layers)
        {
            // BUG: PsdPluginResources.GetString will always return English resource,
            // because Paint.NET does not set the CurrentUICulture when OnLoad is
            // called.  This situation should be resolved with Paint.NET 4.0, which
            // will provide an alternative mechanism to retrieve the UI language.

            // Cache layer section strings
            var beginSectionWrapper = PsdPluginResources.GetString("LayersPalette_LayerGroupBegin");
            var endSectionWrapper   = PsdPluginResources.GetString("LayersPalette_LayerGroupEnd");

            // Track the depth of the topmost hidden section.  Any nested sections
            // will be hidden, whether or not they themselves have the flag set.
            int topHiddenSectionDepth = Int32.MaxValue;
            var layerSectionNames     = new Stack <string>();

            // Layers are stored bottom-to-top, but layer sections are specified
            // top-to-bottom.
            foreach (var layer in Enumerable.Reverse(layers))
            {
                // Apply to all layers within the layer section, as well as the
                // closing layer.
                if (layerSectionNames.Count > topHiddenSectionDepth)
                {
                    layer.Visible = false;
                }

                var sectionInfo = (LayerSectionInfo)layer.AdditionalInfo
                                  .SingleOrDefault(x => x is LayerSectionInfo);
                if (sectionInfo == null)
                {
                    continue;
                }

                switch (sectionInfo.SectionType)
                {
                case LayerSectionType.OpenFolder:
                case LayerSectionType.ClosedFolder:
                    // Start a new layer section
                    if ((!layer.Visible) && (topHiddenSectionDepth == Int32.MaxValue))
                    {
                        topHiddenSectionDepth = layerSectionNames.Count;
                    }
                    layerSectionNames.Push(layer.Name);
                    layer.Name = String.Format(beginSectionWrapper, layer.Name);
                    break;

                case LayerSectionType.SectionDivider:
                    // End the current layer section
                    var layerSectionName = layerSectionNames.Pop();
                    if (layerSectionNames.Count == topHiddenSectionDepth)
                    {
                        topHiddenSectionDepth = Int32.MaxValue;
                    }
                    layer.Name = String.Format(endSectionWrapper, layerSectionName);
                    break;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.rleCompressCheckBox = new System.Windows.Forms.CheckBox();
     this.SuspendLayout();
     //
     // rleCompressCheckBox
     //
     this.rleCompressCheckBox.Location        = new System.Drawing.Point(0, 0);
     this.rleCompressCheckBox.Name            = "rleCompressCheckBox";
     this.rleCompressCheckBox.Size            = new System.Drawing.Size(184, 24);
     this.rleCompressCheckBox.TabIndex        = 0;
     this.rleCompressCheckBox.Text            = PsdPluginResources.GetString("SaveDialog_RleCompression");
     this.rleCompressCheckBox.CheckedChanged += new System.EventHandler(this.OnCheckedChanged);
     //
     // PsdSaveConfigWidget
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Dpi;
     this.Controls.Add(this.rleCompressCheckBox);
     this.Name = "PsdSaveConfigWidget";
     this.Size = new System.Drawing.Size(180, 104);
     this.ResumeLayout(false);
 }