void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           nodes          = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList           shapes         = nodes.Filter(TableShapeFilter);

                if (shapes.Count == 0)
                {
                    diagramControl.Document.Tag = null;
                    return;
                }

                NNodeList decorators = nodes.Filter(DecoratorFilter);

                if (decorators.Count > 0)
                {
                    // Toggle the clicked show/hide subtree decorator and update the view
                    ((NShowHideSubtreeDecorator)decorators[0]).ToggleState();
                    diagramControl.UpdateView();
                }

                // Send a custom command
                NTableShape table    = (NTableShape)shapes[0];
                NEmployee   employee = (NEmployee)table.Tag;

                diagramControl.AddCustomClientCommand(employee.GetData());
            }
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(TABLE_SHAPE_FILTER);

            if (shapes.Count == 0)
            {
                NDrawingView1.Document.Tag = null;
                return;
            }

            NNodeList decorators = nodes.Filter(DECORATOR_FILTER);

            if (decorators.Count > 0)
            {
                ((NShowHideSubtreeDecorator)decorators[0]).ToggleState();
            }

            NTableShape table    = (NTableShape)shapes[0];
            NEmployee   employee = (NEmployee)table.Tag;

            NDrawingView1.Document.Tag = employee;
            NDrawingView1.Document.SmartRefreshAllViews();
        }
 void Delete(NCallbackMouseEventArgs args)
 {
     nDrawingViewDocument.Document.HistoryService.StartTransaction("Delete");
     try
     {
         NNodeList clickedNodes  = nDrawingViewDocument.HitTest(args);
         NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);
         if (clickedShapes.Count != 0)
         {
             NShape clickedShape = clickedShapes[clickedShapes.Count - 1] as NShape;
             nDrawingViewDocument.Document.ActiveLayer.RemoveChild(clickedShape);
         }
         else
         {
             NNodeList clickedConnectors = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape1D);
             if (clickedConnectors.Count != 0)
             {
                 NShape clickedConnector = clickedConnectors[clickedConnectors.Count - 1] as NShape;
                 nDrawingViewDocument.Document.ActiveLayer.RemoveChild(clickedConnector);
             }
         }
     }
     finally
     {
         nDrawingViewDocument.Document.HistoryService.Commit();
     }
 }
Example #4
0
        private void UpdatePortGeneralPropertiesControls(NPort port)
        {
            // can only disconnect the port if it is connected to any plugs
            disconnectPortButton.Enabled = (port.Plugs.Count != 0);

            // update port offset
            NSizeF offset = port.Offset;

            portOffsetXNumeric.Value = (decimal)offset.Width;
            portOffsetYNumeric.Value = (decimal)offset.Height;

            // populate the combo with available anchors
            INDiagramElementContainer searchRoot = port.GetRootForReferenceProperty("AnchorUniqueId");
            NFilter filter = port.GetFilterForReferenceProperty("AnchorUniqueId");

            NNodeList anchors = searchRoot.Descendants(null, -1);

            anchors.Insert(0, searchRoot);
            anchors = anchors.Filter(filter);

            anchorIdComboBox.Items.Clear();
            anchorIdComboBox.Items.AddRange((object[])(anchors.ToArray(typeof(object))));

            // select the currently chosen anchor
            for (int i = 0; i < anchorIdComboBox.Items.Count; i++)
            {
                Guid elemendGuid = (anchorIdComboBox.Items[i].Tag as INDiagramElement).UniqueId;
                if (elemendGuid.Equals(port.AnchorUniqueId))
                {
                    anchorIdComboBox.SelectedIndex = i;
                    break;
                }
            }
        }
            protected void OnMouseEvent(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList affectedNodes  = diagramState.HitTest(args);
                NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                int length;

                length = allShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = allShapes[i] as NShape;
                    shape.Style.ShadowStyle = null;
                    if (shape.Tag != null)
                    {
                        shape.Style.FillStyle = new NColorFillStyle((Color)shape.Tag);
                    }
                }

                length = affectedShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = affectedShapes[i] as NShape;
                    shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10));
                    NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle;
                    if (fs != null && fs.Color != Color.White)
                    {
                        shape.Tag             = fs.Color;
                        shape.Style.FillStyle = new NColorFillStyle(Color.YellowGreen);
                    }
                }
            }
            void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           nodes          = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList           shapes         = nodes.Filter(CellFilter);

                if (shapes.Count == 0)
                {
                    return;
                }

                NClickomaniaGame game = (NClickomaniaGame)diagramControl.Document.Tag;
                NTableCell       cell = (NTableCell)shapes[0];

                if (cell.ParentNode.ParentNode != game.BoardShape)
                {
                    return;
                }

                if (String.IsNullOrEmpty(cell.StyleSheetName))
                {
                    return;
                }

                if (game.OnCellClicked(cell) == false)
                {
                    return;
                }

                // The user has clicked on a cell that is part of a region
                diagramControl.ServerSettings.EnableAutoUpdate = true;
                diagramControl.Update();
            }
            public override void OnAsyncClick(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;
                NNodeList clickedNodes  = diagramState.HitTest(args);
                NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList shapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);
                int       length = shapes.Count;

                for (int i = 0; i < length; i++)
                {
                    NShape s = shapes[i] as NShape;
                    s.Style.FillStyle   = null;
                    s.Style.StrokeStyle = null;
                    s.Style.ShadowStyle = null;
                    s.Tag = null;
                }

                if (clickedShapes.Count == 0)
                {
                    return;
                }

                NShape clickedShape = clickedShapes[0] as NShape;

                clickedShape.Style.FillStyle   = new NColorFillStyle(libraryHighlightFillColor);
                clickedShape.Style.StrokeStyle = new NStrokeStyle(libraryHighlightBorderColor);
                clickedShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(90, Color.Black), new NPointL(2, 1));
                clickedShape.Tag = "selected";
            }
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList            nodes  = NDrawingView1.HitTest(args);
            NNodeList            shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);
            NExpandCollapseCheck check  = null;
            int length = shapes.Count;

            for (int i = 0; i < length; i++)
            {
                if (shapes[i] is NExpandCollapseCheck)
                {
                    check = shapes[i] as NExpandCollapseCheck;
                    break;
                }
            }
            if (check == null)
            {
                return;
            }

            NExpandableShape shape = check.ParentNode.ParentNode as NExpandableShape;

            shape.Expand(!shape.Expanded);
        }
            protected void ChangeCurrentShapeShadow(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList affectedNodes  = diagramState.HitTest(args as NCallbackMouseEventArgs);
                NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                int    length;
                NShape shape;

                length = allShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    shape = allShapes[i] as NShape;
                    shape.Style.ShadowStyle = null;
                }

                if (affectedShapes.Count == 0)
                {
                    return;
                }

                shape = affectedShapes[affectedShapes.Count - 1] as NShape;
                if (shape.Style.StrokeStyle == null)
                {
                    shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10));
                }
            }
        protected void OnMouseEvent(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList allShapes = NDrawingView1.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

            NNodeList affectedNodes  = NDrawingView1.HitTest(args);
            NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

            int length;

            length = allShapes.Count;
            for (int i = 0; i < length; i++)
            {
                NShape shape = allShapes[i] as NShape;
                shape.Style.ShadowStyle = null;
                if (shape.Tag != null)
                {
                    shape.Style.FillStyle = new NColorFillStyle((Color)shape.Tag);
                }
            }

            length = affectedShapes.Count;
            for (int i = 0; i < length; i++)
            {
                NShape shape = affectedShapes[i] as NShape;
                shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10));
                NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle;
                if (fs != null && fs.Color != Color.White)
                {
                    shape.Tag             = fs.Color;
                    shape.Style.FillStyle = new NColorFillStyle(Color.YellowGreen);
                }
            }
        }
Example #11
0
            void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           nodes          = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList           decorators     = nodes.Filter(ExpandCollapseDecoratorFilter);

                if (decorators.Count > 0)
                {
                    ((NExpandCollapseDecorator)decorators[0]).ToggleState();
                    diagramControl.UpdateView();
                }
            }
Example #12
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes      = NDrawingView1.HitTest(args);
            NNodeList decorators = nodes.Filter(DECORATOR_FILTER);

            if (decorators.Count > 0)
            {
                ((NShowHideSubtreeDecorator)decorators[0]).ToggleState();
                DoLayout();
            }
        }
Example #13
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;
            NNodeList nodes      = NDrawingView1.HitTest(args);
            NNodeList decorators = nodes.Filter(DecoratorFilter);

            if (decorators.Count > 0)
            {
                ((NShowHideSubtreeDecorator)decorators[0]).ToggleState();
            }

            NDrawingView1.Document.SmartRefreshAllViews();
        }
            void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           allShapes      = diagramControl.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList affectedNodes  = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                int  length;
                bool fillChanged = false;

                length = allShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = allShapes[i] as NShape;
                    shape.Style.ShadowStyle = null;
                    if (shape.Tag != null)
                    {
                        NColorFillStyle newFill = new NColorFillStyle((Color)shape.Tag);
                        fillChanged           = fillChanged || !shape.Style.FillStyle.Equals(newFill);
                        shape.Style.FillStyle = newFill;
                    }
                }

                length = affectedShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    NShape shape = affectedShapes[i] as NShape;
                    shape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(96, Color.Black), new NPointL(3, 3), 1, new NLength(10));

                    NColorFillStyle fs = shape.Style.FillStyle as NColorFillStyle;
                    if (fs != null && fs.Color != Color.White)
                    {
                        shape.Tag = fs.Color;
                        NColorFillStyle newFill = new NColorFillStyle(Color.YellowGreen);
                        fillChanged = fillChanged || !shape.Style.FillStyle.Equals(newFill);

                        shape.Style.FillStyle = newFill;
                    }
                }

                if (fillChanged)
                {
                    diagramControl.UpdateView();
                }
                else
                {
                    diagramControl.ClearResponse();
                }
            }
Example #15
0
            void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           nodes          = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList           shapes         = nodes.Filter(NFilters.Shape2D);
                NDrawingDocument    document       = diagramControl.Document;

                if (String.IsNullOrEmpty(m_MapRenderer.CurrentState))
                {
                    if (shapes.Count == 0)
                    {
                        return;
                    }

                    // The user has clicked a state
                    NShape shape = (NShape)shapes[0];
                    m_MapRenderer.LoadStateMap(document, shape.Name);
                }
                else
                {
                    if (shapes.Count == 0)
                    {
                        // Return to the States map
                        m_MapRenderer.LoadUsaMap(document);
                    }
                    else
                    {
                        // The user has clicked a county
                        NShape shape = (NShape)shapes[0];
                        if (shape.StyleSheetName == "ClickedCounty")
                        {
                            // The user has clicked a selected county - unselect it
                            shape.StyleSheetName = String.Empty;
                            shape.Text           = String.Empty;
                        }
                        else
                        {
                            // The user has clicked a non selected county - select it (make it red)
                            shape.StyleSheetName = "ClickedCounty";
                            shape.Text           = shape.Name;
                        }
                    }
                }

                diagramControl.UpdateView();
            }
Example #16
0
            protected NRectangleShape HitTestCell(NStateObject state, NCallbackMouseEventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;
                NNodeList nodes  = diagramState.HitTest(args);
                NNodeList shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                foreach (NShape node in shapes)
                {
                    if (!(node.Tag is CellState))
                    {
                        continue;
                    }
                    return(node as NRectangleShape);
                }

                return(null);
            }
 void Fill(NCallbackMouseEventArgs args, Color c)
 {
     nDrawingViewDocument.Document.HistoryService.StartTransaction("Fill");
     try
     {
         NNodeList clickedNodes  = nDrawingViewDocument.HitTest(args);
         NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);
         if (clickedShapes.Count == 0)
         {
             return;
         }
         NShape clickedShape = clickedShapes[clickedShapes.Count - 1] as NShape;
         clickedShape.Style.FillStyle = new NColorFillStyle(c);
     }
     finally
     {
         nDrawingViewDocument.Document.HistoryService.Commit();
     }
 }
        protected NEllipseShape HitTestEllipse(NCallbackMouseEventArgs args)
        {
            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

            foreach (NShape node in shapes)
            {
                if (!(node is NEllipseShape))
                {
                    continue;
                }
                if (!node.Name.Contains("Ellipse"))
                {
                    continue;
                }
                return(node as NEllipseShape);
            }

            return(null);
        }
            protected NEllipseShape HitTestEllipse(NStateObject state, NCallbackMouseEventArgs args)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;
                NNodeList nodes  = diagramState.HitTest(args);
                NNodeList shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                foreach (NShape node in shapes)
                {
                    if (!(node is NEllipseShape))
                    {
                        continue;
                    }
                    if (!node.Name.Contains("Ellipse"))
                    {
                        continue;
                    }
                    return(node as NEllipseShape);
                }

                return(null);
            }
        void NThinDiagramControl1_Postback(object sender, ThinWeb.NPostbackEventArgs e)
        {
            NThinDiagramControl diagramControl = (NThinDiagramControl)sender;
            NNodeList           allShapes      = diagramControl.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);
            NNodeList           hitNodes       = diagramControl.HitTest(e.MousePosition.ToNPointF());

            hitNodes = hitNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

            foreach (NShape shape in allShapes)
            {
                if (NSystem.SafeEquals(shape.Tag, true))
                {
                    shape.Style.FillStyle = new NColorFillStyle(Color.LightBlue);
                }
            }

            foreach (NShape shape in hitNodes)
            {
                if (NSystem.SafeEquals(shape.Tag, true))
                {
                    shape.Style.FillStyle = new NColorFillStyle(Color.Red);
                }
            }
        }
            protected void ChangeCurrentShapeColor(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args, Color c)
            {
                NDiagramSessionStateObject diagramState = state as NDiagramSessionStateObject;

                NNodeList allShapes = diagramState.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);

                NNodeList affectedNodes  = diagramState.HitTest(args as NCallbackMouseEventArgs);
                NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

                int    length;
                NShape shape;

                length = allShapes.Count;
                for (int i = 0; i < length; i++)
                {
                    shape = allShapes[i] as NShape;
                    if (shape.Tag != null)
                    {
                        shape.Style.FillStyle = shape.Tag as NAdvancedGradientFillStyle;
                    }
                }

                if (affectedShapes.Count == 0)
                {
                    return;
                }

                shape = affectedShapes[affectedShapes.Count - 1] as NShape;
                NAdvancedGradientFillStyle fs = shape.Style.FillStyle as NAdvancedGradientFillStyle;

                if (fs != null)
                {
                    shape.Tag             = fs;
                    shape.Style.FillStyle = new NColorFillStyle(c);
                }
            }
        void MoveOrSelect(NCallbackMouseEventArgs args)
        {
            NNodeList clickedNodes  = nDrawingViewDocument.HitTest(args);
            NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

            if (clickedShapes.Count == 0)
            {
                //	move the shape, if one is selected
                nDrawingViewDocument.Document.HistoryService.StartTransaction("Move");
                try
                {
                    if (SelectedShapeId == Guid.Empty)
                    {
                        return;
                    }

                    NShape selectedShape = nDrawingViewDocument.Document.ActiveLayer.GetChildFromUniqueId(SelectedShapeId) as NShape;
                    selectedShape.Center = new NPointF(args.Point.X, args.Point.Y);
                }
                finally
                {
                    nDrawingViewDocument.Document.HistoryService.Commit();
                }
            }
            else
            {
                //	select a shape
                nDrawingViewDocument.Document.HistoryService.Pause();
                try
                {
                    NShape clickedShape  = clickedShapes[clickedShapes.Count - 1] as NShape;
                    NShape selectedShape = nDrawingViewDocument.Document.ActiveLayer.GetChildFromUniqueId(SelectedShapeId) as NShape;
                    if (clickedShape == selectedShape)
                    {
                        selectedShape.Style.StrokeStyle = null;
                        SelectedShapeId = Guid.Empty;
                        return;
                    }

                    NNodeList shapes = nDrawingViewDocument.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);
                    int       length = shapes.Count;
                    for (int i = 0; i < length; i++)
                    {
                        NShape s = shapes[i] as NShape;
                        if (s.UniqueId == clickedShape.UniqueId)
                        {
                            s.Style.StrokeStyle = new NStrokeStyle(2, documentSelectedShapeBorderColor);
                        }
                        else
                        {
                            s.Style.StrokeStyle = null;
                        }
                    }
                    SelectedShapeId = clickedShape.UniqueId;
                }
                finally
                {
                    nDrawingViewDocument.Document.HistoryService.Resume();
                }
            }
        }
        void Connect(NCallbackMouseEventArgs args)
        {
            NNodeList clickedNodes  = nDrawingViewDocument.HitTest(args);
            NNodeList clickedShapes = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

            if (clickedShapes.Count == 0)
            {
                return;
            }
            NShape clickedShape;

            if (SelectedShapeId == Guid.Empty)
            {
                //	select a shape
                nDrawingViewDocument.Document.HistoryService.Pause();
                try
                {
                    clickedShape = clickedShapes[clickedShapes.Count - 1] as NShape;
                    NNodeList shapes = nDrawingViewDocument.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.Shape2D);
                    int       length = shapes.Count;
                    for (int i = 0; i < length; i++)
                    {
                        NShape s = shapes[i] as NShape;
                        if (s.UniqueId == clickedShape.UniqueId)
                        {
                            s.Style.StrokeStyle = new NStrokeStyle(2, documentSelectedShapeBorderColor);
                        }
                        else
                        {
                            s.Style.StrokeStyle = null;
                        }
                    }
                    SelectedShapeId = clickedShape.UniqueId;
                    return;
                }
                finally
                {
                    nDrawingViewDocument.Document.HistoryService.Resume();
                }
            }

            NShape selectedShape = nDrawingViewDocument.Document.ActiveLayer.GetChildFromUniqueId(SelectedShapeId) as NShape;

            nDrawingViewDocument.Document.HistoryService.StartTransaction("Connect");
            try
            {
                //	connect shapes
                clickedShape = clickedShapes[clickedShapes.Count - 1] as NShape;

                NRoutableConnector connector = new NRoutableConnector(RoutableConnectorType.DynamicHV);
                nDrawingViewDocument.Document.ActiveLayer.AddChild(connector);
                connector.StyleSheetName       = "Connectors";
                connector.FromShape            = selectedShape;
                connector.ToShape              = clickedShape;
                connector.RerouteAutomatically = RerouteAutomatically.Always;

                if (connector.IsReflexive)
                {
                    connector.Reflex();
                }
                else
                {
                    connector.Reroute();
                }
            }
            finally
            {
                nDrawingViewDocument.Document.HistoryService.Commit();
            }

            //	deselect the shape
            nDrawingViewDocument.Document.HistoryService.Pause();
            try
            {
                selectedShape.Style.StrokeStyle = null;
                SelectedShapeId = Guid.Empty;
            }
            finally
            {
                nDrawingViewDocument.Document.HistoryService.Resume();
            }
        }
        protected void nDrawingViewToolbar_AsyncClick(object sender, EventArgs e)
        {
            //	get the selected command
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;
            NNodeList clickedNodes       = nDrawingViewToolbar.HitTest(args);
            NNodeList clickedGroups      = clickedNodes.Filter(Nevron.Diagram.Filters.NFilters.TypeNGroup);

            if (clickedGroups.Count == 0)
            {
                return;
            }
            NGroup clickedGroup = clickedGroups[0] as NGroup;
            string command      = clickedGroup.Tag as string;

            if (command == null)
            {
                return;
            }

            //	get the selected button
            ToolbarButton selectedBtn = GetButtonByCommand(command);

            if (!selectedBtn.IsClientSide)
            {
                this.ActiveCommand = command;
            }
            else
            {
                return;
            }

            //	highlight the clicked button
            NShape selectedCoverShape = clickedGroup.Shapes.GetChildByName("coverShape", 0) as NShape;

            if (selectedCoverShape == null)
            {
                return;
            }
            NNodeList groups = nDrawingViewToolbar.Document.ActiveLayer.Children(Nevron.Diagram.Filters.NFilters.TypeNGroup);
            int       length = groups.Count;

            for (int i = 0; i < length; i++)
            {
                NGroup        group = groups[i] as NGroup;
                ToolbarButton btn   = GetButtonByCommand(group.Tag as string);
                if (btn == null)
                {
                    continue;
                }
                NShape coverShape = group.Shapes.GetChildByName("coverShape", 0) as NShape;
                if (!btn.IsSeparator)
                {
                    if (!object.ReferenceEquals(selectedCoverShape, coverShape) && !btn.IsClientSide)
                    {
                        if (btn.IsColorSelector)
                        {
                            coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(80, Color.White));
                        }
                        else
                        {
                            coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(160, Color.White));
                        }
                        coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(160, Color.White));
                        coverShape.Style.ShadowStyle = null;
                    }
                    else
                    {
                        coverShape.Style.FillStyle   = new NColorFillStyle(Color.FromArgb(0, Color.White));
                        coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(0, Color.White));
                        coverShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(70, Color.Black), new NPointL(1, 0));
                    }
                }
            }
        }
Example #25
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(CELL_FILTER);

            if (shapes.Count == 0)
            {
                return;
            }

            NTableCell cell = (NTableCell)shapes[0];

            if (cell.ParentNode.ParentNode != table)
            {
                return;
            }

            if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty)
            {
                if (CellClicked(cell))
                {
                    UpdateInfo();

                    // Check for end of the game
                    string status = string.Empty;
                    if (AllClear())
                    {
                        score *= 2;
                        status = "You've cleared all cells !!!" + Environment.NewLine;
                    }

                    if (status == string.Empty && GameOver())
                    {
                        status = "Game Over !" + Environment.NewLine;
                    }

                    if (status != string.Empty)
                    {
                        status += "Your score is " + score.ToString();
                        NTableShape gameOver = new NTableShape();
                        document.ActiveLayer.AddChild(gameOver);

                        gameOver.BeginUpdate();
                        gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8);
                        gameOver[0, 0].Text  = status;

                        NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Ocean1, 0));
                        NStyle.SetStrokeStyle(gameOver, new NStrokeStyle(Color.DarkBlue));

                        NTextStyle textStyle = (NTextStyle)table.ComposeTextStyle().Clone();
                        textStyle.FillStyle = new NColorFillStyle(Color.DarkBlue);
                        NStyle.SetTextStyle(gameOver, textStyle);

                        gameOver.EndUpdate();
                        gameOver.Center = table.Center;
                    }
                }
            }
        }