示例#1
0
 private void LoadLayoutInfo(XmlReader xmlReader, PictureLayout layout)
 {
     if (Guid.TryParse(xmlReader.GetAttribute("BlendModeGuid"), out Guid blendmodeGuid))
     {
         layout.BlendMode = blendmodesMap[blendmodeGuid];
     }
     if (bool.TryParse(xmlReader.GetAttribute("Hidden"), out bool hidden))
     {
         layout.Hidden = hidden;
     }
     if (float.TryParse(xmlReader.GetAttribute("Alpha"), out float alpha))
     {
         layout.Alpha = alpha;
     }
     if (int.TryParse(xmlReader.GetAttribute("RenderBufferNumber"), out int bufNum))
     {
         layout.RenderBufferNum = bufNum;
     }
     if (int.TryParse(xmlReader.GetAttribute("RefBufferNumber"), out int refBufNum))
     {
         layout.RefBufferNum = refBufNum;
     }
     for (int i = 0; i < Core.BlendMode.c_parameterCount; i++)
     {
         int.TryParse(xmlReader.GetAttribute(string.Format("Parameter{0}", i + 1)), out int layoutParameter);
         layout.Parameters[i].Value = layoutParameter;
     }
     layout.Name = xmlReader.GetAttribute("Name");
 }
示例#2
0
        public PictureLayout CopyLayout(int index)
        {
            watched = false;
            PictureLayout pictureLayout    = Layouts[index];
            PictureLayout newPictureLayout = null;

            if (pictureLayout is StandardLayout standardLayout)
            {
                newPictureLayout = new StandardLayout(standardLayout)
                {
                    Name = string.Format("{0} 复制", standardLayout.Name)
                };
            }
            else if (pictureLayout is PureLayout pureLayout)
            {
                newPictureLayout = new PureLayout(pureLayout)
                {
                    Name = string.Format("{0} 复制", pureLayout.Name)
                };
            }
            Layouts.Insert(index, newPictureLayout);
            watched = true;
            UndoManager.AddUndoData(new CMD_DeleteLayout(newPictureLayout, this, index));
            return(newPictureLayout);
        }
 public override void GetData(PictureLayout layout, int[] outData, out bool hidden)
 {
     for (int j = 0; j < BlendMode.c_parameterCount; j++)
     {
         outData[j] = layout.Parameters[j].Value;
     }
     hidden = layout.Hidden;
 }
示例#4
0
 public void RenderAll()
 {
     PrepareRenderData();
     for (int i = 0; i < RenderTarget.Count; i++)
     {
         RenderTarget[i].Clear();
     }
     for (int i = ManagedLayout.Count - 1; i >= 0; i--)
     {
         PictureLayout selectedLayout = ManagedLayout[i];
         if (LayoutsHiddenData[i] == true)
         {
             continue;
         }
         if (selectedLayout is StandardLayout standardLayout)
         {
             RenderTexture[] refs = new RenderTexture[Core.BlendMode.c_refCount];
             if (standardLayout.RefBufferNum >= 0 && standardLayout.RefBufferNum < RenderTarget.Count)
             {
                 refs[0] = RenderTarget[standardLayout.RefBufferNum];
             }
             if (standardLayout.RenderBufferNum >= 0 && standardLayout.RenderBufferNum < RenderTarget.Count)
             {
                 if (standardLayout.activated)
                 {
                     standardLayout.BlendMode?.Blend(PaintingTexture, RenderTarget[standardLayout.RenderBufferNum], refs, RenderDataCaches[i]);
                 }
                 else if (standardLayout.tiledTexture != null && standardLayout.tiledTexture.tilesCount != 0)
                 {
                     standardLayout.BlendMode?.Blend(standardLayout.tiledTexture, RenderTarget[standardLayout.RenderBufferNum], refs, RenderDataCaches[i]);
                 }
             }
         }
         else if (selectedLayout is PureLayout pureLayout)
         {
             if (!pureLayout.colorUpdated)
             {
                 pureLayout.UpdateColor();
             }
             RenderTexture[] refs = new RenderTexture[Core.BlendMode.c_refCount];
             if (pureLayout.RefBufferNum >= 0 && pureLayout.RefBufferNum < RenderTarget.Count)
             {
                 refs[0] = RenderTarget[pureLayout.RefBufferNum];
             }
             if (pureLayout.RenderBufferNum >= 0 && pureLayout.RenderBufferNum < RenderTarget.Count)
             {
                 pureLayout.BlendMode?.Blend(RenderTarget[pureLayout.RenderBufferNum], refs, pureLayout.colorBuffer, RenderDataCaches[i]);
             }
         }
         else
         {
             throw new System.NotImplementedException();
         }
     }
 }
示例#5
0
        public override void SetContentView(Android.Views.View view)
        {
            if (TEST_PICTURE)
            {
                ViewGroup vg = new PictureLayout(this);
                vg.AddView(view);
                view = vg;
            }

            base.SetContentView(view);
        }
示例#6
0
        public void DeleteLayout(int index)
        {
            PictureLayout pictureLayout = Layouts[index];

            watched = false;
            if (pictureLayout is StandardLayout standardLayout)
            {
                standardLayout.Deactivate();
            }
            if (PaintAgent.CurrentLayout == pictureLayout)
            {
                PaintAgent.CurrentLayout = null;
            }
            Layouts.RemoveAt(index);
            watched = true;
            UndoManager.AddUndoData(new CMD_RecoverLayout(pictureLayout, this, index));
        }
 public override void GetData(PictureLayout layout, int[] outData, out bool hidden)
 {
     if (LayoutPropertyBagMap.TryGetValue(layout.guid, out var layoutPropertyBag))
     {
         hidden = layoutPropertyBag.hiddenUsed ? layoutPropertyBag.hidden : layout.Hidden;
         for (int j = 0; j < Core.BlendMode.c_parameterCount; j++)
         {
             outData[j] = layoutPropertyBag.propertyValueUsed[j] ? layoutPropertyBag.propertyValues[j] : layout.Parameters[j].Value;
         }
     }
     else
     {
         hidden = layout.Hidden;
         for (int j = 0; j < Core.BlendMode.c_parameterCount; j++)
         {
             outData[j] = layout.Parameters[j].Value;
         }
     }
 }
示例#8
0
        public async Task SaveAsync()
        {
            await SaveDocInfo();

            StorageFile LayoutSettingsFile = await CaseFolder.CreateFileAsync("Layouts.xml", CreationCollisionOption.ReplaceExisting);

            Stream    layoutsInfoStream = (await LayoutSettingsFile.OpenAsync(FileAccessMode.ReadWrite)).AsStream();
            XmlWriter writer            = XmlWriter.Create(layoutsInfoStream, xmlWriterSettings);

            writer.WriteStartDocument();
            writer.WriteStartElement("Layouts");
            for (int ia = 0; ia < canvasCase.Layouts.Count; ia++)
            {
                PictureLayout layout = canvasCase.Layouts[ia];
                if (layout is StandardLayout)
                {
                    writer.WriteStartElement("Layout");
                }
                else if (layout is PureLayout pureLayout)
                {
                    writer.WriteStartElement("PureLayout");
                    System.Numerics.Vector4 color = pureLayout.Color;
                    writer.WriteAttributeString("Color", string.Format("{0} {1} {2} {3}", color.X, color.Y, color.Z, color.W));
                }
                writer.WriteAttributeString("Name", layout.Name);
                writer.WriteAttributeString("Guid", layout.guid.ToString());
                writer.WriteAttributeString("Hidden", layout.Hidden.ToString());
                writer.WriteAttributeString("Alpha", layout.Alpha.ToString());
                if (layout.BlendMode != null)
                {
                    writer.WriteAttributeString("BlendModeGuid", layout.BlendMode.Guid.ToString());
                }
                if (layout.RenderBufferNum != 0)
                {
                    writer.WriteAttributeString("RenderBufferNumber", layout.RenderBufferNum.ToString());
                }
                if (layout.RefBufferNum != -1)
                {
                    writer.WriteAttributeString("RefBufferNumber", layout.RefBufferNum.ToString());
                }
                for (int i = 0; i < Core.BlendMode.c_parameterCount; i++)
                {
                    if (layout.Parameters[i].Value != 0)
                    {
                        writer.WriteAttributeString(string.Format("Parameter{0}", i + 1), layout.Parameters[i].Value.ToString());
                    }
                }

                writer.WriteEndElement();
                if (layout is StandardLayout standardLayout && !standardLayout.saved)
                {
                    if (!layoutFileMap.TryGetValue(standardLayout.guid, out StorageFile storageFile))
                    {
                        storageFile = await layoutsFolder.CreateFileAsync(string.Format("{0}.dclf", standardLayout.guid.ToString(), CreationCollisionOption.ReplaceExisting));

                        layoutFileMap[standardLayout.guid] = storageFile;
                    }
                    await standardLayout.SaveToFileAsync(storageFile);
                }
            }
            writer.WriteEndDocument();
            writer.Flush();
            layoutsInfoStream.Dispose();
            HashSet <Guid> existLayoutGuids = new HashSet <Guid>();

            foreach (var layout in canvasCase.Layouts)
            {
                existLayoutGuids.Add(layout.guid);
            }
            foreach (var cmd in canvasCase.UndoManager.undoStack)
            {
                if (cmd is Undo.CMD_DeleteLayout delLCmd)
                {
                    existLayoutGuids.Add(delLCmd.layout.guid);
                }
                else if (cmd is Undo.CMD_RecoverLayout recLCmd)
                {
                    existLayoutGuids.Add(recLCmd.layout.guid);
                }
            }
            foreach (var cmd in canvasCase.UndoManager.redoStack)
            {
                if (cmd is Undo.CMD_DeleteLayout delLCmd)
                {
                    existLayoutGuids.Add(delLCmd.layout.guid);
                }
                else if (cmd is Undo.CMD_RecoverLayout recLCmd)
                {
                    existLayoutGuids.Add(recLCmd.layout.guid);
                }
            }
            List <Guid> delFileGuids = new List <Guid>();

            foreach (var pair in layoutFileMap)
            {
                if (!existLayoutGuids.Contains(pair.Key))
                {
                    delFileGuids.Add(pair.Key);
                    await pair.Value.DeleteAsync();
                }
            }
            foreach (Guid guid in delFileGuids)
            {
                layoutFileMap.Remove(guid);
            }
        }
示例#9
0
 public CMD_RecoverLayout(PictureLayout layout, CanvasCase canvasCase, int insertIndex)
 {
     this.layout      = layout;
     this.insertIndex = insertIndex;
     this.canvasCase  = canvasCase;
 }
示例#10
0
 public abstract void GetData(PictureLayout layout, int[] outData, out bool hidden);
示例#11
0
 public void RenderPart(List <Vector2Int> part, TileRect filterRect)
 {
     if (part == null || part.Count == 0)
     {
         return;
     }
     PrepareRenderData();
     for (int i = 0; i < RenderTarget.Count; i++)
     {
         //清除部分
         int           partCount        = part.Count;
         ComputeShader texturePartClear = TiledTexture.TexturePartClear;
         ComputeBuffer buf = new ComputeBuffer(RenderTarget[0].GetDeviceResources(), partCount, 8, part.ToArray());
         texturePartClear.SetBuffer(buf, 0);
         texturePartClear.SetUAVTexture(RenderTarget[i], 0);
         texturePartClear.Dispatch(1, 1, partCount / 16 + (partCount % 16 > 0 ? 1 : 0));
         buf.Dispose();
     }
     for (int i = ManagedLayout.Count - 1; i >= 0; i--)
     {
         PictureLayout selectedLayout = ManagedLayout[i];
         if (LayoutsHiddenData[i] == true)
         {
             continue;
         }
         if (selectedLayout is StandardLayout standardLayout)
         {
             if (standardLayout.RenderBufferNum >= 0 && standardLayout.RenderBufferNum < RenderTarget.Count)
             {
                 RenderTexture[] refs = new RenderTexture[Core.BlendMode.c_refCount];
                 if (standardLayout.RefBufferNum >= 0 && standardLayout.RefBufferNum < RenderTarget.Count)
                 {
                     refs[0] = RenderTarget[standardLayout.RefBufferNum];
                 }
                 if (standardLayout.RenderBufferNum >= 0 && standardLayout.RenderBufferNum < RenderTarget.Count)
                 {
                     if (standardLayout.activated)
                     {
                         standardLayout.BlendMode?.Blend(PaintingTexture, RenderTarget[standardLayout.RenderBufferNum], part, refs, RenderDataCaches[i]);
                     }
                     else if (standardLayout.tiledTexture != null && standardLayout.tiledTexture.tileRect.HaveIntersections(filterRect))
                     {
                         standardLayout.BlendMode?.Blend(standardLayout.tiledTexture, RenderTarget[standardLayout.RenderBufferNum], part, refs, RenderDataCaches[i]);
                     }
                 }
             }
         }
         else if (selectedLayout is PureLayout pureLayout)
         {
             if (!pureLayout.colorUpdated)
             {
                 pureLayout.UpdateColor();
             }
             RenderTexture[] refs = new RenderTexture[Core.BlendMode.c_refCount];
             if (pureLayout.RefBufferNum >= 0 && pureLayout.RefBufferNum < RenderTarget.Count)
             {
                 refs[0] = RenderTarget[pureLayout.RefBufferNum];
             }
             if (pureLayout.RenderBufferNum >= 0 && pureLayout.RenderBufferNum < RenderTarget.Count)
             {
                 pureLayout.BlendMode?.Blend(RenderTarget[pureLayout.RenderBufferNum], part, refs, pureLayout.colorBuffer, RenderDataCaches[i]);
             }
         }
         else
         {
             throw new System.NotImplementedException();
         }
     }
 }
 public CMD_DeleteLayout(PictureLayout layout, CanvasCase case1, int atIndex)
 {
     this.layout  = layout;
     canvasCase   = case1;
     this.atIndex = atIndex;
 }
示例#13
0
 public CMD_BlendModeChange(PictureLayout host, BlendMode blendMode)
 {
     Host      = host;
     BlendMode = blendMode;
 }