public static ImageTask RegenerateImageForLayerSync(FlowInterfaceControl fic, Layer l, int width, int height, Action act)
 {
     ImageTask it = new ImageTask();
     ProgressCallback callback = (progress, bitmap) =>
     {
     #if FALSE
         it.Progress = progress;
     #endif
         if (bitmap != null)
         {
             it.HasResult = true;
             it.Result = bitmap;
         }
         act();
     };
     RegenerateImageForLayer(fic, l, width, height, callback);
     return it;
 }
 private static Bitmap RegenerateImageForLayer(FlowInterfaceControl fic, Layer l, int width, int height, ProgressCallback callback)
 {
     Bitmap b = new Bitmap(width, height);
     Graphics g = Graphics.FromImage(b);
     g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
     Dictionary<int, Brush> brushes = l.GetLayerColors();
     int[] data = l.GenerateData(LayerFlowImageGeneration.X, LayerFlowImageGeneration.Y, width, height);
     for (int x = 0; x < width; x++)
         for (int y = 0; y < height; y++)
         {
             while (true)
             {
                 try
                 {
                     if (brushes != null && brushes.ContainsKey(data[x + y * width]))
                         g.FillRectangle(
                             brushes[data[x + y * (width)]],
                             new Rectangle(x, y, 1, 1)
                             );
                     else
                         g.FillRectangle(
                             m_UnknownAssociation,
                             new Rectangle(x, y, 1, 1)
                             );
     #if FALSE
                     callback((int)((x + y * width) / (double)(width * height) * 100.0), null);
     #else
                     callback(0, null);
     #endif
                     break;
                 }
                 catch (InvalidOperationException)
                 {
                     // Graphics can be in use elsewhere, but we don't care; just try again.
                 }
             }
         }
     callback(100, b);
     return b;
 }
예제 #3
0
        public LayerFlowElement(FlowInterfaceControl control, Layer l)
        {
            this.m_Control = control;
            this.m_Layer   = l;
            this.Name      = l.ToString();
            if (l is Layer2D)
            {
                this.ImageWidth  = 128;
                this.ImageHeight = 128;
            }
            else
            {
                this.ImageWidth  = 128;
                this.ImageHeight = 192;
            }
            this.ObjectPropertyUpdated();

            // Create input / output connectors.
            foreach (string s in this.m_Layer.GetParentsRequired())
            {
                this.m_InputConnectors.Add(new LayerFlowConnector(this, s, true, l));
            }
            this.m_OutputConnectors.Add(new LayerFlowConnector(this, "Output", false, l));
        }
예제 #4
0
 public virtual void SetDeserializationData(FlowInterfaceControl control)
 {
 }
예제 #5
0
 public override void SetDeserializationData(FlowInterfaceControl control)
 {
     this.m_Control = control;
 }
 public static ImageTask RegenerateImageForLayerTask(FlowInterfaceControl fic, Layer l, int width, int height, Action act)
 {
     ImageTask it = new ImageTask();
     Thread t = new Thread(() =>
         {
             ProgressCallback callback = (progress, bitmap) =>
                 {
                     it.Progress = progress;
                     if (bitmap != null)
                     {
                         it.HasResult = true;
                         it.Result = bitmap;
                     }
                     act();
                 };
             RegenerateImageForLayer(fic, l, width, height, callback);
         });
     t.Start();
     return it;
 }