Exemplo n.º 1
0
 /// <summary>
 ///     Draws the respecting Icon for this cell
 /// </summary>
 public void DrawIcon()
 {
     if (control == null)
     {
         try
         {
             var container = new CellErrorInfoContainer();
             container.SuspendLayout();
             container.ElementHost.Child = new CellErrorInfo
             {
                 DataContext = this,
                 Visibility  = Visibility.Visible
             };
             container.ResumeLayout(true);
             var vsto = Globals.Factory.GetVstoObject(Worksheet);
             controlName    = Guid.NewGuid().ToString();
             control        = vsto.Controls.AddControl(container, Worksheet.Range[ShortLocation], controlName);
             control.Width  = 13;
             control.Height = 13;
         }
         catch (Exception e)
         {
             Debug.WriteLine(e);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Removes the icon from this cell
 /// </summary>
 public void RemoveIcon()
 {
     if (!string.IsNullOrWhiteSpace(controlName))
     {
         var vsto = Globals.Factory.GetVstoObject(Worksheet);
         vsto.Controls.Remove(controlName);
         controlName = null;
         control     = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Attach the control to a specified document's control collection using a specified process.
        /// </summary>
        /// <param name="collection">The control collection to hold the control.</param>
        /// <param name="range">The location of the control.</param>
        /// <param name="width">The width of the control.</param>
        /// <param name="height">The height of the control.</param>
        /// <param name="shape">The control's inline shape object in the document</param>
        /// <returns>The component of the attached control.</returns>
        protected override Control Attach(ControlCollection collection, Word.Range range, float width, float height, out Word.InlineShape shape)
        {
            //adds a panel to document
            Panel       control     = new Panel();
            ControlSite controlSite = collection.AddControl(control, range, width, height, ObjectId);

            shape = controlSite.InlineShape;

            //if there is no list item in the item collection then attach a new list box to document
            if (Items.Count == 0)
            {
                CreateDefaultTemplateItems();

                RenderItems(control, _tempItems);
            }
            else
            {
                RenderItems(control, Items, false);
            }

            Items.TemplateItemsChanged += new EventHandler(Items_TemplateItemsChanged);

            return(control);
        }