Ejemplo n.º 1
0
        private PageReport PaintInvalid(Page page, PageReport report, string mode)
        {
            int       invalidCount  = 0;
            Hashtable shapeHandlers = new Hashtable();

            CgoConfig[] Cgo = CgoConfigs.Search();

            GroupElementTable groupElementTable = new GroupElementTable();
            ElementTable      elementTable      = new ElementTable();

            foreach (Shape shape in page.Shapes)
            {
                string shapeName = VisioUtils.GetProperty(shape, "User", "ScreenShape");
                if (shapeName == null)
                {
                    continue;
                }

                IShapeHandler shapeHandler = GetShapeHandler(shapeHandlers, shape, shapeName, mode);
                if (shape.Data1 == _INVALID)
                {
                    shapeHandler.PaintAsInvalid();
                }
                else
                {
                    if (Cgo != null)
                    {
                        XmlNode shapeProperties = shapeHandler.GetProperties();
                        XmlNode cgoNode         = shapeProperties.SelectSingleNode("cgoName");
                        if (cgoNode != null)
                        {
                            string cgoCode = cgoNode.InnerText;
                            if (!CgoConfigs.Exists(Cgo, cgoCode))
                            {
                            }
                        }
                    }
                }
                invalidCount++;

                string groupElementName = VisioUtils.GetProperty(shape, "Prop", "Group");
                string elementName      = VisioUtils.GetProperty(shape, "Prop", "Element");
                if ((groupElementName == null) || (elementName == null))
                {
                    continue;
                }

                GroupElement groupElement = new GroupElement(groupElementName);
                groupElementTable.AddGroupElement(groupElement);

                Element element = new Element(elementName);
                elementTable.AddElement(element);
            }
            report = ShapeGroupValidation.Validate(groupElementTable, elementTable, report);

            return(report);
        }
Ejemplo n.º 2
0
 private void MarkInvalid(Page page)
 {
     foreach (Shape shape in page.Shapes)
     {
         string shapeName = VisioUtils.GetProperty(shape, "User", "ScreenShape");
         if (shapeName == null)
         {
             continue;
         }
         shape.Data1 = _INVALID;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the marker events.
        /// </summary>
        /// <param name="context">Parsed event context.</param>
        private void HandleMarkerEvent(NameValueCollection context)
        {
            Shape shape = VisioUtils.GetShape(_application, context);

            if (shape == null)
            {
                return;
            }

            string shapeName = VisioUtils.GetProperty(shape, "User", "Midgard");

            if (shapeName == null)
            {
                // se for um visio desenhado com a versão antiga (sem os layers)
                shapeName = VisioUtils.GetShapeType(shape);
                if (shapeName == null)
                {
                    return;
                }
            }
            string command = context["cmd"];

            if (command == null)
            {
                return;
            }

            /*
             *
             */
            string mode = "live";// GetMode();

            using (XmlForm form = new XmlForm())
            {
                form.LoadDefinition(shapeName, shape);
                form.Design(mode, Application.ActivePage);

                IShapeHandler   shapeHandler = (IShapeHandler)form.Tag;
                DisplaySettings newSettings  = shapeHandler.Execute(command, context, _displaySettings, _forceFormChange);
                if (newSettings != null)
                {
                    _displaySettings = newSettings;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the shape disconnect event.
        /// </summary>
        /// <param name="connection">Disconnection event.</param>
        private void HandleShapeDisconnect(Connects connection)
        {
            // connection.FromSheet is always the connector shape.
            // connection.ToSheet is always the shape to which the connector was previously connected.

            Shape  connect   = connection.FromSheet;
            string shapeName = VisioUtils.GetProperty(connect, "User", VisioUtils.GetShapeType(Application));

            if (shapeName == null)
            {
                return;
            }

            if (shapeName == "Event" || shapeName == "EventProcess")
            {
                VisioUtils.PaintShape(connection.FromSheet, "2");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a command-bar.
        /// </summary>
        public void CreateCommandBar()
        {
            string     commandBarName = Resources.GetString(ResourceTokens.CommandBarName);
            Object     missing        = System.Reflection.Missing.Value;
            CommandBar commandBar     = VisioUtils.GetCommandBar(Application, commandBarName);

            if (commandBar != null)
            {
                return;
            }

            //adicionar a barra ao Visio
            CommandBars applicationCommandBars = (CommandBars)Application.CommandBars;

            commandBar = applicationCommandBars.Add(commandBarName, MsoBarPosition.msoBarTop, false, true);


            // Validate transition Button
            _validateButton        = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, false);
            _validateButton.Click += new _CommandBarButtonEvents_ClickEventHandler(this.validateTransition_Click);
            SetButtonProperties(_validateButton, ResourceTokens.ButtonValidate, ResourceTokens.ButtonValidateTooltip, TagValidateButton, "Validate.bmp", "Validate-Mask.bmp");

            // Export transition
            _exportXMLButton        = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 2, false);
            _exportXMLButton.Click += new _CommandBarButtonEvents_ClickEventHandler(this.exportTransition_Click);
            SetButtonProperties(_exportXMLButton, ResourceTokens.ButtonExport, ResourceTokens.ButtonExportTooltip, TagExportXMLButton, "Export.bmp", "Export-Mask.bmp");


            // User cannot customize our commandbar
            commandBar.Protection = MsoBarProtection.msoBarNoCustomize;

            // Toolbar is only visible when viewing the drawing
            commandBar.Context = Convert.ToString((short)VisUIObjSets.visUIObjSetDrawing, CultureInfo.InvariantCulture) + "*";

            _application.DocumentCreated     += new EApplication_DocumentCreatedEventHandler(_application_DocumentCreated);
            _application.DocumentOpened      += new EApplication_DocumentOpenedEventHandler(_application_DocumentOpened);
            _application.BeforeDocumentClose += new EApplication_BeforeDocumentCloseEventHandler(_application_BeforeDocumentClose);
            _application.WindowActivated     += new EApplication_WindowActivatedEventHandler(_application_WindowActivated);
            _application.ViewChanged         += new EApplication_ViewChangedEventHandler(_application_ViewChanged);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Releases unmanaged resources help by the event sink.
        /// </summary>
        public void Dispose()
        {
            foreach (Event e in _events)
            {
                e.Delete();
                Marshal.ReleaseComObject(e);
            }

            _events = null;


            string     commandBarName = Resources.GetString(ResourceTokens.CommandBarName);
            CommandBar commandBar     = VisioUtils.GetCommandBar(Application, commandBarName);

            if (commandBar != null)
            {
                commandBar.Delete();
                Marshal.ReleaseComObject(_exportXMLButton);
                Marshal.ReleaseComObject(_validateButton);

                _validateButton  = null;
                _exportXMLButton = null;
            }
        }
Ejemplo n.º 7
0
        private CommandBar GetCommandBar()
        {
            string commandBarName = Resources.GetString(ResourceTokens.CommandBarName);

            return(VisioUtils.GetCommandBar(Application, commandBarName));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Event handler for subscribed events.
        /// </summary>
        /// <param name="eventCode">Code of the captured event.</param>
        /// <param name="source">Source object. In this case, it will always be the Visio application.</param>
        /// <param name="eventID">?</param>
        /// <param name="eventSequenceNumber">?</param>
        /// <param name="subject">The object which caused the event. This parameter is not set for marker events (which are raised by Visio).</param>
        /// <param name="moreInfo">?</param>
        /// <returns>Always null.</returns>
        public object VisEventProc(short eventCode, object source, int eventID, int eventSequenceNumber, object subject, object moreInfo)
        {
            VisioApplication visioApplication = null;

            try
            {
                visioApplication = (VisioApplication)source;

                if (_active == false)
                {
                    return(null);
                }

                if (visioApplication.IsUndoingOrRedoing == true)
                {
                    return(null);
                }

                /*
                 * Test eventCode.
                 * Yes, it's _so_ retarded to have to use if/else, but we can't switch
                 * since VisioEvent.* aren't constants. :/
                 */


                /*
                 * Called whenever one shape connects to another. Filter out
                 * connects which are not raised by QuartzProcess shapes.
                 */
                #region Shape Connect

                if (eventCode == VisioEvent.ShapeConnect)
                {
                    Connects connects = (Connects)subject;
                    HandleShapeConnect(connects);
                }

                #endregion


                /*
                 * Called whenever a shape is disconnected from another. Filter
                 * out disconnects which are not raised by QuartzProcess shapes.
                 */
                #region Shape Disconnect

                else if (eventCode == VisioEvent.ShapeDisconnect)
                {
                    Connects connects = (Connects)subject;
                    HandleShapeDisconnect(connects);
                }

                #endregion


                /*
                 * Called whenever a QueueMarkerEvent command is executed from
                 * the shape. Filter out events which are not raised by
                 * QuartzProcess app.
                 */
                #region Marker Events

                else if (eventCode == VisioEvent.ShapeEventMarker)
                {
                    string context = visioApplication.get_EventInfo(VisioEvent.IdMostRecent);

                    if (context == null)
                    {
                        return(null);
                    }

                    NameValueCollection nvc = VisioUtils.ParseContext(context);

                    HandleMarkerEvent(nvc);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ESIMessageBox.ShowError(ex);
            }

            return(null);
        }