/// <summary>
        /// Sets an generic content and a related renderer for this type.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="renderer">The renderer - can not be null.</param>
        public void SetOtherContent(Object content, IBrailleIOContentRenderer renderer)
        {
            if (renderer == null)
            {
                throw new ArgumentException("No content render set! The content renderer can not be null.", "renderer");
            }

            if (Monitor.TryEnter(syncRoot, new TimeSpan(0, 0, 1)))
            {
                try
                {
                    this.otherContent = content;
                    if (renderer != null)
                    {
                        this.ContentRender = renderer;
                    }
                    this.is_other = true;
                    this.is_image = this.is_matrix = this.is_text = false;
                    Render        = true;
                }
                finally
                {
                    Monitor.Exit(syncRoot);
                }
            }
            fireContentChangedEvent();
        }
Beispiel #2
0
 /// <summary>
 /// Sets the text that should be rendered.
 /// </summary>
 /// <param name="text">The text.</param>
 public void SetText(string text)
 {
     this.text          = text;
     this.is_text       = true;
     this.is_image      = this.is_matrix = this.is_other = false;
     this.ContentRender = _tr;
     Render             = true;
     fireContentChangedEvent();
 }
Beispiel #3
0
 /// <summary>
 /// set matrix
 /// </summary>
 /// <param name="matrix">
 /// bool[,] matrix
 /// </param>
 public void SetMatrix(bool[,] matrix)
 {
     this.matrix        = matrix;
     this.is_matrix     = true;
     this.is_text       = this.is_image = this.is_other = false;
     this.ContentRender = _mr;
     Render             = true;
     fireContentChangedEvent();
 }
        public void SetBitmap(Bitmap img)
        {
            if (Monitor.TryEnter(syncRoot, new TimeSpan(0, 0, 1)))
            {
                try
                {
                    //clean up the memory
                    if (this.image != null)
                    {
                        this.image.Dispose();
                    }
                    if (img == null)
                    {
                        img = new Bitmap(1, 1);
                    }

                    int tries = 0;
                    while (tries++ < 5)
                    {
                        try
                        {
                            this.image = img.Clone() as Bitmap;
                        }
                        catch (InvalidOperationException) { Thread.Sleep(5); }
                        catch (AccessViolationException) { Thread.Sleep(5); }
                        catch (Exception)
                        {
                            break;
                        }
                    }
                    imageSize          = new Size(img.Width, img.Height);
                    this.is_image      = true;
                    this.is_text       = this.is_matrix = this.is_other = false;
                    this.ContentRender = _ir;
                    img.Dispose();
                    Render = true;
                }
                catch { }
                finally
                {
                    Monitor.Exit(syncRoot);
                }
                fireContentChangedEvent();
            }
        }
Beispiel #5
0
 /// <summary>
 /// Sets an generic content and a related renderer for this type.
 /// </summary>
 /// <param name="content">The contet.</param>
 /// <param name="renderer">The renderer - can not be null.</param>
 public void SetOtherContent(Object content, IBrailleIOContentRenderer renderer)
 {
     if (renderer == null)
     {
         throw new ArgumentException("No content render set! The content renderer can not be null.", "renderer");
     }
     //bool update = !this.is_other || !this.otherContent.Equals(content);
     this.otherContent = content;
     if (renderer != null)
     {
         this.ContentRender = renderer;
     }
     this.is_other = true;
     this.is_image = this.is_matrix = this.is_text = false;
     Render        = true;
     fireContentChangedEvent();
     //if (update) UpdateContentSize();
 }
 /// <summary>
 /// Sets the text that should be rendered.
 /// </summary>
 /// <param name="text">The text.</param>
 public void SetText(string text)
 {
     if (Monitor.TryEnter(syncRoot, new TimeSpan(0, 0, 1)))
     {
         try
         {
             this.text          = text;
             this.is_text       = true;
             this.is_image      = this.is_matrix = this.is_other = false;
             this.ContentRender = _tr;
             Render             = true;
         }
         finally
         {
             Monitor.Exit(syncRoot);
         }
     }
     fireContentChangedEvent();
 }
 /// <summary>
 /// set matrix
 /// </summary>
 /// <param name="matrix">
 /// bool[,] matrix
 /// </param>
 public void SetMatrix(bool[,] matrix)
 {
     if (Monitor.TryEnter(syncRoot, new TimeSpan(0, 0, 1)))
     {
         try
         {
             Matrix             = matrix;
             this.is_matrix     = true;
             this.is_text       = this.is_image = this.is_other = false;
             this.ContentRender = _mr;
             Render             = true;
         }
         finally
         {
             Monitor.Exit(syncRoot);
         }
     }
     fireContentChangedEvent();
 }
 /// <summary>
 /// Sets the content of the region.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="vrName">Name of the region (viewRange).</param>
 /// <param name="content">The content.</param>
 /// <param name="renderer">The renderer to use to transform the content into a matrix.</param>
 /// <returns>true if the content could be set, otherwise false</returns>
 public bool SetRegionContent(BrailleIOScreen screen, String vrName, Object content, IBrailleIOContentRenderer renderer)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             if (content != null)
             {
                 vr.SetOtherContent(content, renderer);
             }
             else { vr.SetMatrix(null); }
         }
     }
     return false;
 }
 /// <summary>
 /// Sets the content of the region.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="vrName">Name of the region (viewRange).</param>
 /// <param name="content">The content.</param>
 /// <param name="renderer">The renderer to use to transform the content into a matrix.</param>
 /// <returns>true if the content could be set, otherwise false</returns>
 public bool SetRegionContent(BrailleIOScreen screen, String vrName, Object content, IBrailleIOContentRenderer renderer)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             if (content != null)
             {
                 vr.SetOtherContent(content, renderer);
             }
             else
             {
                 vr.SetMatrix(null);
             }
         }
     }
     return(false);
 }