コード例 #1
0
        private void tsmCopySelectedLayer_Click(object sender, EventArgs e)
        {
            if (gridPsdLayer.SelectedRows.Count != 1)
            {
                return;
            }

            var item = gridPsdLayer.SelectedRows[0].DataBoundItem as PsdLayerVM;

            if (item == null)
            {
                return;
            }

            var vm = new PsdLayerVM();

            Common.Helper.CopyProperties(item, vm);
            var index = _validationMethods.DSPsdLayerVMList.IndexOf(item);

            _validationMethods.DSPsdLayerVMList.Insert(index + 1, vm);
        }
コード例 #2
0
        // 1. Bit 확인
        // 2. 그룹명/레이어명 공란 없음
        // 3. 레이어구조
        // 4. RGB(Road Background_Color, Transparency_Color)
        // 5. Arrow 그룹내위치(Road Background_Color, Transparency_Color)
        // 6. 채널
        // 7. 패스
        // 8. size(2048x2048 or 800x600)
        // 9. 해상도 72pixel
        // 10. 불투명도 Direction ->100%
        // 11. 불투명도 Transparency ->50%
        // 12. 이미지 크기, 위치(Road Background_Color, Transparency_Color)
        private void GetLayer(IPsdLayer layer, int layerDepth, int layerSeq)
        {
            // Layer 정보를 얻어오는 Method

            var vm = new PsdLayerVM();

            // dto 객체를 만들고
            // dto 객체에 set 메소드를 통해 한개의 객체를 완성한다
            vm.Index      = ++_index;
            vm.LayerDepth = layerDepth;
            vm.LayerSeq   = layerSeq;

            vm.Name      = layer.Name;
            vm.BlendMode = layer.BlendMode;
            vm.Bottom    = layer.Bottom;

            //vm.Channels = layer.Channels;
            vm.ChannelCount = layer.Channels.Count();
            var sb  = new List <string>();
            var sb2 = new List <string>();
            var sb3 = new List <string>();

            foreach (var x in layer.Channels)
            {
                sb.Add(string.Format("{0}", x.Type));
                sb2.Add(string.Format("{0}", x.Data.Length));
                sb3.Add(string.Format("{0}", x.Data.Length > 0 ? x.Data[0].ToString() : "-"));
                // 삼항연산자 이용 조건 ? 참 : 거짓
            }

            // string.join( string(seperator), 배열 또는 컬렉션 멤버 ) : 배열 또는 컬렉션 멤버의 요소들을 seperator를 사용하여 연결
            vm.ChannelTypes = string.Join("/", sb);
            vm.ChannelSize  = string.Join("/", sb2);
            vm.ChannelARGB  = string.Join("/", sb3);

            vm.ChildCount = layer.Childs.Count();
            vm.Depth      = layer.Depth;

            vm.HasImage    = layer.HasImage;
            vm.HasMask     = layer.HasMask;
            vm.Height      = layer.Height;
            vm.IsClippinig = layer.IsClipping;

            vm.Left = layer.Left;

            vm.Opacity = layer.Opacity;


            vm.Right = layer.Right;
            vm.Top   = layer.Top;
            vm.Width = layer.Width;

            //layer.LinkedLayer
            var descList = layer.GetDescription();

            vm.IsVisible = GetDictionaryValue(descList, DescriptionMode.Records_Flags_IsVisible) != "True";
            vm.IsLock    = GetDictionaryValue(descList, DescriptionMode.Records_Flags_IsTransparency) == "True";
            var flagNumber = GetDictionaryValue(descList, DescriptionMode.Records_Flags_Number);

            vm.RecordsFlags      = ToBin(int.Parse(flagNumber), 8);
            vm.SectionType       = GetDictionaryValue(descList, DescriptionMode.Records_SectionType);
            vm.HeightUnit        = GetDictionaryValue(descList, DescriptionMode.Docuemnt_HeightUnit);
            vm.HorizontalRes     = GetDictionaryValue(descList, DescriptionMode.Docuemnt_HorizontalRes);
            vm.HorizontalResUnit = GetDictionaryValue(descList, DescriptionMode.Docuemnt_HorizontalResUnit);
            vm.VerticalRes       = GetDictionaryValue(descList, DescriptionMode.Docuemnt_VerticalRes);
            vm.VerticalResUnit   = GetDictionaryValue(descList, DescriptionMode.Docuemnt_VerticalResUnit);
            vm.WidthUnit         = GetDictionaryValue(descList, DescriptionMode.Docuemnt_WidthUnit);


            //vm.Parent = layer.Parent;
            //vm.Document = layer.Document;
            //vm.LinkedLayer = layer.LinkedLayer;
            //vm.Resources = layer.Resources;

            Console.WriteLine("######vm#######");
            Console.WriteLine(vm);
            Console.WriteLine("###############");

            _vmList.Add(vm);

            var childLayerSeq = 1;

            foreach (var x in layer.Childs.Reverse())
            {
                GetLayer(x, layerDepth + 1, childLayerSeq++);   // 재귀함수 활용
            }
            //_vmList.Insert(vm);
        }