public static dynamic GetTSObject(FrameTypes dynEnum)
        {
            var tsType = TSActivator.CreateInstance("Tekla.Structures.Drawing.FrameTypes").GetType();

            switch (dynEnum)
            {
            case FrameTypes.None:
                return(System.Enum.Parse(tsType, "None"));

            case FrameTypes.Rectangular:
                return(System.Enum.Parse(tsType, "Rectangular"));

            case FrameTypes.Line:
                return(System.Enum.Parse(tsType, "Line"));

            case FrameTypes.Round:
                return(System.Enum.Parse(tsType, "Round"));

            case FrameTypes.Circle:
                return(System.Enum.Parse(tsType, "Circle"));

            case FrameTypes.Diamond:
                return(System.Enum.Parse(tsType, "Diamond"));

            case FrameTypes.Hexagon:
                return(System.Enum.Parse(tsType, "Hexagon"));

            case FrameTypes.Triangle:
                return(System.Enum.Parse(tsType, "Triangle"));

            case FrameTypes.Sharpened:
                return(System.Enum.Parse(tsType, "Sharpened"));

            default:
                throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented");
            }
        }
Ejemplo n.º 2
0
        //
        // GET: /Frame/Create

        public ActionResult Create(int canvasId = 0, int panelId = 0, FrameTypes? frameType = null)
        {
            Panel panel = null;
            if (panelId != 0)
            {
                panel = db.Panels
                    .Include(p => p.Canvas)
                    .FirstOrDefault(p => p.PanelId == panelId)
                    ;

                if (panel == null)
                    panelId = 0;
            }
            
            if (frameType == null || panel == null)
            {
                if (canvasId == 0 && panel != null)
                    canvasId = panel.CanvasId;
                
                return RedirectToAction("ForFrameType", new { 
                    canvasId = canvasId, 
                    panelId = panelId, 
                    frameType = frameType
                });
            }

            TempData[SelectorFrameKey] = new Frame()
            {
                Panel = panel,
                PanelId = panelId,
                CacheInterval = 0,
            };

            return RedirectToAction("Create", frameType.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrameIdentifier"/>.
        /// </summary>
        /// <param name="frametype">The type of data associated with this <see cref="FrameIdentifier"/></param>
        /// <param name="identifier">A user-defined string for the identifier. Must be 3 chars or more.</param>
        public FrameIdentifier(FrameTypes frametype, string identifier)
        {
            if (identifier.Length < 3)
                throw new ArgumentException("An identifier can be no shorter than 3 characters.");

            foreach (char c in identifier)
            {
                if (!char.IsLetterOrDigit(c))
                    throw new ArgumentException("An identifier cannot contain the char '" + c + "'");
            }

            this.type = frametype;
            char prefix = GetPrefix(frametype);
            if (prefix == '\0')
                throw new ArgumentException("Unknown frametype: " + frametype.ToString());
            else
                this.identifier = prefix + identifier;

            this.buffer = Encoding.ASCII.GetBytes(this.identifier);
            if (this.buffer.Length > byte.MaxValue)
                throw new ArgumentException("An identifier can be no longer than " + byte.MaxValue + " characters.");
        }
Ejemplo n.º 4
0
            //
            // Decode the received frame
            //
            Boolean Decode(out String packetFrame)
            {
                Int32         ptr    = 0;
                Boolean       retVal = false;
                StringBuilder s      = new StringBuilder("|", 4096);

                try
                {
                    //
                    //  Catch any exceptions during decode
                    //
                    ptr = staLink.destinationStation.Decode(inBuf, ptr);
                    ptr = staLink.sourceStation.Decode(inBuf, ptr);

                    s.Append("|" + staLink.sourceStation.stationIDString + "|ch=" + staLink.sourceStation.chBit.ToString());
                    s.Append("|" + staLink.destinationStation.stationIDString + "|ch=" + staLink.destinationStation.chBit.ToString());

                    if (staLink.sourceStation.extBit == 0)
                    {
                        ptr = staLink.relayStation1.Decode(inBuf, ptr);
                        s.Append("|" + staLink.relayStation1.stationIDString + "|ch=" + staLink.relayStation1.chBit.ToString());
                        if (staLink.relayStation1.extBit == 0)
                        {
                            ptr = staLink.relayStation2.Decode(inBuf, ptr);
                            s.Append("|" + staLink.relayStation2.stationIDString + "|ch=" + staLink.relayStation2.chBit.ToString());
                            if (staLink.relayStation2.extBit == 0)
                            {
                                StationAddress tmpR = new StationAddress();
                                s.Append("|r??:(");

                                do
                                {
                                    ptr = tmpR.Decode(inBuf, ptr);
                                    s.Append("\\" + tmpR.stationIDString + ":ch=" + tmpR.chBit.ToString());
                                } while (tmpR.extBit == 0);
                                s.Append(")");
                                //throw new Exception("Too many relay addresses");
                            }
                            else
                            {
                                s.Append("|");
                            }
                        }
                        else
                        {
                            s.Append("||");
                        }
                    }
                    else
                    {
                        s.Append("|||");
                    }
                    cmdOctetPtr = ptr;

                    if ((staLink.destinationStation.chBit == staLink.sourceStation.chBit))
                    {
                        //
                        // Old protocol version
                        //
                        version = ProtocolVersion.V20;
                    }
                    else
                    {
                        //
                        // New protocol version
                        //
                        version = ProtocolVersion.V22;
                    }

                    if (staLink.destinationStation.chBit == 0)
                    {
                        //
                        // Response type
                        //
                        cmdResp = PacketType.Response;
                    }
                    else
                    {
                        //
                        // Command type
                        //
                        cmdResp = PacketType.Command;
                    }

                    //
                    // Get frame type.  I and S frame must be decoded later after we know whether we
                    // are using mod8 or mod128 sequence numbers.
                    //
                    Byte   tmp = inBuf[ptr];
                    String t   = "";

                    pfBit = (tmp >> 4) & 0x01;      //ToDo  change needed to support SABME

                    seqNumMode = SequenceNumberMode.Mod8;

                    //Frame.InformationFrame.Decode(this, rawBuf, ptr, out t);

                    if ((tmp & 0x01) == I)
                    {
                        //
                        // I frame
                        //
                        frameClass = FrameClasses.IClass;
                        frameType  = FrameTypes.IType;
                        ptr        = InformationFrame.Decode(this, inBuf, ptr, out t);
                    }

                    if ((tmp & 0x03) == S)
                    {
                        //
                        // S frame
                        //
                        frameClass = FrameClasses.SClass;
                        frameType  = (FrameTypes)(tmp & 0x0f);
                        ptr        = SupervisoryFrame.Decode(this, inBuf, ptr, out t);
                    }

                    if ((tmp & 0x03) == U)
                    {
                        //
                        // U frame.  We can decode uFrames right away
                        //
                        frameClass = FrameClasses.UClass;
                        frameType  = (FrameTypes)(tmp & 0xef);
                        ptr        = UnnumberedFrame.Decode(this, inBuf, ptr, out t);
                    }
                    s.Append("|" + version.ToString() + "|" + frameType.ToString() + "|" + cmdResp.ToString() + "|pf=" + pfBit.ToString());

                    if (t.Length > 0)
                    {
                        s.Append(t);
                    }
                    s.Append(Support.DumpRawFrame(rawBuf));

                    retVal = true;
                }
                catch (Exception ex)
                {
                    s.Append(ex.Message + CRLF);
                    Support.DbgPrint("Exception during frame decode:" + ex.Message + CRLF);
                    retVal = false;
                }
                finally
                {
                    s.Append("]");
                    packetFrame = s.ToString();
                }

                return(retVal);
            }