Recent Posts

Pages: [1] 2 3 ... 10
1
Programming & Code / Re: Visio.Application.DeferRecalc hangs Visio
« Last post by Paul Herber on September 22, 2018, 10:14:54 AM »
What is this VisioHelper you are using?
2
Programming & Code / Visio.Application.DeferRecalc hangs Visio
« Last post by bwharrington on September 21, 2018, 03:17:16 PM »
I have a class that I am using to turn Events On and Off that includes using DefereRecalc.

Below is that class and sample usage below it.

I highlighted the line that causes the hang. Removing it seems to fix my issue. However I'm nervous about removing this. As I researched this it is mainly a performance enhancement.

I found something sort of supporting this may not be a good idea and that you can find unexpected behavior. However from other posts in this forum I see people using this without issue. So it seems :)

http://visguy.com/vgforum/index.php?topic=6813.msg28466#msg28466

I have verified the value I am setting and all appears to be correct.

Has any experienced problems using DefereRecalc and possibilities to resolving them?

Code: [Select]
public class VisioEventSilencer : IDisposable
    {
        private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private short _lastEventsEnabledValue;
        private short _lastDeferRecalcValue;
        private Visio.Application _application;

        public VisioEventSilencer(Visio.Application application)
        {
            _application = application;
            Off();
        }

        public VisioEventSilencer Off()
        {
            logger.Debug("Turning events off");
            _lastEventsEnabledValue = _application.EventsEnabled;
            _application.EventsEnabled = VisioHelper.FALSE;
            _lastDeferRecalcValue = _application.DeferRecalc;
            _application.DeferRecalc = VisioHelper.TRUE;

            return this;
        }

        public void Restore()
        {
            logger.Debug("Restoring events");
            try
            {
                _application.EventsEnabled = _lastEventsEnabledValue;
                [color=yellow][color=red]_application.DeferRecalc = _lastDeferRecalcValue;[/color][/color]
            }
            catch(Exception ex)
            {
                logger.Debug(ex.Message);
                logger.Debug(ex.StackTrace);
            }
        }

        #region IDisposable Support
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue) {
                if (disposing) {
                    this.Restore();
                }

                disposedValue = true;
            }
        }

        ~VisioEventSilencer()
        {
            Dispose(false);
        }

        // This code added to correctly implement the disposable pattern.
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        #endregion
    }


Sample Usage

Application application....
using (var silencer = new VisioEventSilencer(application))
           {
               //Get Server Data, Send Server Data, Create Shapes, Manipulate Existing Shapes and so on.
            }

3
General Visio / Re: Can I know if my shape is on top of another shape
« Last post by mlussier on September 20, 2018, 12:49:11 PM »
That looks like what I want to do. I will try to make this works for my project.

Thank you very much kind sir
4
Shapes & Templates / Re: images as a custom fill pattern
« Last post by Yacine on September 20, 2018, 11:27:51 AM »
Didn't find problems with the picture. Check attachment.
5
User-submitted Stuff / Re: Articulated Line
« Last post by wapperdude on September 20, 2018, 11:12:06 AM »
...or perhaps wapper-thebull-dawg?   ???

As for being intuitively obvious, well, it wasn't.  I knew that cell helped keep things looking elliptical.  But, was there a nice expression to define it.  Trial and error with different settings proved that a linear relationship was unlikely.  From my past life, when I earned money to make a living, I remembered using Excel to do curve fitting and finding trends.  So, taking a proper amount of data points, I then let excel find the necessary equation.  As they say in England...Brilliant!  LOL.

The coloring scheme thing with the NoFill cell was again experience with such a thing.  I have a JuneTheSecond post to help me recognize the interaction with multiple geometry sections.  You, subsequently, found the John Goldsmith article.

To do really clever fill patterns, then you will need to use the grouped approach.

Dawgoneit!
6
Shapes & Templates / images as a custom fill pattern
« Last post by dtallent on September 20, 2018, 08:42:52 AM »
I am using some images for a custom fill pattern. I can use one picture and it will fill the shape, but when I use another picture, it will not fill the shape. Does it have something to do with the original picture. The attachment is one picture that will not work. I have created patterns with shingles, pine straw, grass, flowers, brick, but this one is giving me grief.
7
User-submitted Stuff / Re: Articulated Line
« Last post by Hey Ken on September 20, 2018, 07:47:29 AM »

   0.4886*User.Thk^-1.015??  Of course!  Why didn’t I think of that!  It’s so obvious!  (NOT!)

   Good plan, splitting my ellipse into two elliptical arcs.  Understandable, and your piecing them together kept the illusion of an oval better than I could manage.  It’s that highly-intuitive 0.4886*User.Thk^-1.015 that did the trick.

   We have a real winner here with your final shape, Wapperdude, what with the constant topologies, color choices and all.  It’s all I could ask for, and more!  Thanks!!

   Henceforth I shall refer to it as The Wappershape. 

   - Ken

8
General Visio / Re: Can I know if my shape is on top of another shape
« Last post by wapperdude on September 19, 2018, 11:28:05 PM »
As far as I know, it takes code to do that.  You want to look at Spatial Neighbors, https://docs.microsoft.com/en-us/office/vba/api/Visio.Shape.SpatialNeighbors
and related Spatial Properties, https://docs.microsoft.com/en-us/office/vba/api/visio.shape.spatialrelation

Wapperdude
9
User-submitted Stuff / Re: Articulated Line
« Last post by wapperdude on September 19, 2018, 06:18:19 PM »
Well, while I'm at it., another, non-grouped option.  Call this fun with fills.

The controlling cell is the GeometryXXX.NoFil cell.  This cell, as  previously mentioned, has a Boolean personality.  So, where two geometry sections overlap, there lies the Boolean interaction.  The fourth shape is designed such that there is maximal options: 
  1)  Full shape fill
  2)  No shape fill
  3)  Only oval shape fill
  4)  Only cylinder wall fill

Just play with the true/false, i.e., 1 / 0, settings of the geometry.nofill cells.

Wapperdude
10
User-submitted Stuff / Re: Articulated Line
« Last post by wapperdude on September 19, 2018, 06:03:53 PM »
Here's ungrouped approach.  I left the control point in to convenient set the oval height...orange shape 1st page.  But, the height now remains constant with both width and height changes.
Pages: [1] 2 3 ... 10