Esempio n. 1
0
        internal void StartParsing(XmlReader reader, string targetNamespace, SchemaInfo schemaInfo) {
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            this.namespaceManager = reader.NamespaceManager;
            if (this.namespaceManager == null) {
                this.namespaceManager = new XmlNamespaceManager(this.nameTable);
                this.isProcessNamespaces = true;
            } 
            else {
                this.isProcessNamespaces = false;
            }
            while (this.reader.NodeType != XmlNodeType.Element && this.reader.Read()) {}

            this.markupDepth = int.MaxValue;
			this.schemaXmlDepth = reader.Depth;
            XmlQualifiedName qname = new XmlQualifiedName(this.reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(this.reader.NamespaceURI, this.nameTable, this.schemaNames));
            if (this.schemaNames.IsXDRRoot(qname)) {
                Debug.Assert(schemaInfo != null);
                schemaInfo.SchemaType = SchemaType.XDR;
                this.schema = null;
                this.builder = new XdrBuilder(reader, this.namespaceManager, schemaInfo, targetNamespace, this.nameTable, this.schemaNames, this.validationEventHandler);
            }
            else if (this.schemaNames.IsXSDRoot(qname)) {
                if (schemaInfo != null) {
                    schemaInfo.SchemaType = SchemaType.XSD;
                }
                this.schema = new XmlSchema();
                this.schema.BaseUri = reader.BaseURI;
                this.builder = new XsdBuilder(reader, this.namespaceManager, this.schema, this.nameTable, this.schemaNames, this.validationEventHandler);
            }
            else { 
                throw new XmlSchemaException(Res.Sch_SchemaRootExpected, reader.BaseURI, positionInfo.LineNumber, positionInfo.LinePosition);
            }
                
        }
Esempio n. 2
0
        private int EvaluateOrientation(PositionInfo.LineInfo positive, PositionInfo.LineInfo negative, Side player)
        {
            if (positive.amount > 0 && negative.amount > 0)
            {
                if (positive.side == negative.side)
                {
                    int n = 1 + positive.amount + negative.amount;
                    return LineCost(n, positive.open, negative.open);
                }
                else
                {
                    int npos = positive.amount + 1;
                    int nneg = negative.amount + 1;

                    return Math.Max(LineCost(npos, positive.open, false), LineCost(nneg, negative.open, false));
                }
            }

            if (positive.amount > 0)
            {
                return LineCost(positive.amount + 1, positive.open, true);
            }

            if (negative.amount > 0)
            {
                return LineCost(negative.amount + 1, negative.open, true);
            }

            return 0;
        }
Esempio n. 3
0
        public void StartParsing(XmlReader reader, string targetNamespace) {
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            namespaceManager = reader.NamespaceManager;
            if (namespaceManager == null) {
                namespaceManager = new XmlNamespaceManager(nameTable);
                isProcessNamespaces = true;
            } 
            else {
                isProcessNamespaces = false;
            }
            while (reader.NodeType != XmlNodeType.Element && reader.Read()) {}

            markupDepth = int.MaxValue;
            schemaXmlDepth = reader.Depth;
            SchemaType rootType = schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI);
            
            string code;
            if (!CheckSchemaRoot(rootType, out code)) {
                throw new XmlSchemaException(code, reader.BaseURI, positionInfo.LineNumber, positionInfo.LinePosition);
            }
            
            if (schemaType == SchemaType.XSD) {
                schema = new XmlSchema();
                schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute);
                builder = new XsdBuilder(reader, namespaceManager, schema, nameTable, schemaNames, eventHandler);
            }
            else {  
                Debug.Assert(schemaType == SchemaType.XDR);
                xdrSchema = new SchemaInfo();
                xdrSchema.SchemaType = SchemaType.XDR;
                builder = new XdrBuilder(reader, namespaceManager, xdrSchema, targetNamespace, nameTable, schemaNames, eventHandler);
                ((XdrBuilder)builder).XmlResolver = xmlResolver;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initialisiert den Antrieb des Roboters
        /// </summary>
        public Drive()
        {
            _tracksToRun = new List<Track>();

              // Antrieb initialisieren
              if (Constants.IsWinCE)
              {
              DriveCtrl = new DriveCtrlHW(Constants.IODriveCtrl);
              MotorCtrlLeft = new MotorCtrlHW(Constants.IOMotorCtrlLeft);
              MotorCtrlRight = new MotorCtrlHW(Constants.IOMotorCtrlRight);
              }
              else
              {
            DriveCtrl = new DriveCtrlSim();
            MotorCtrlLeft = new MotorCtrlSim();
            MotorCtrlRight = new MotorCtrlSim();
              }

              // Beschleunigung festlegen
              DriveCtrl.Power = true;
              MotorCtrlLeft.Acceleration = 10f;
              MotorCtrlRight.Acceleration = 10f;
              Position = new PositionInfo(0f, 0f, 90);

              // Prozess-Thread erzeugen und starten
              _thread = new Thread(RunTracks) {IsBackground = true, Priority = ThreadPriority.Highest};
              _thread.Start();
        }
Esempio n. 5
0
 private void DriveOnOnPositionUpdated(PositionInfo positionInfo)
 {
     lock (_locker)
       {
     _posList.Add(positionInfo);
       }
 }
Esempio n. 6
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="roznica">Typ różnicy</exception>
 /// <param name="komunikat">Komunikat o problemie</exception>
 /// <param name="istotnosc">Istotoność problemu</exception>
 /// <param name="l_pozycja">Pozycja lewego elementu</exception>
 /// <param name="p_pozycja">Pozycja prawego elementu</exception>
 public Roznica(TYP_ROZNICY roznica, string komunikat, bool istotnosc,PositionInfo l_pozycja = null, PositionInfo p_pozycja = null)
 {
     this.problem = new Problem(roznica);
     this.l_pozycja = l_pozycja;
     this.p_pozycja = p_pozycja;
     this.komunikat = komunikat;
     this.Glowna = istotnosc;
 }
 public BaseValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, ValidationEventHandler eventHandler) {
     Debug.Assert(schemaCollection == null || schemaCollection.NameTable == reader.NameTable);
     this.reader = reader;
     this.schemaCollection = schemaCollection;
     this.eventHandler = eventHandler;
     nameTable = reader.NameTable;
     positionInfo = PositionInfo.GetPositionInfo(reader);
     elementName = new XmlQualifiedName();
 }
Esempio n. 8
0
 /// <summary>
 /// Metoda wydobywająca z obiektu XAttribute informacje o jego lokalizacji
 /// </summary>
 /// <param name="atrybut">obiekt XAttribute</param>
 public static PositionInfo Pozycja(XAttribute atrybut)
 {
     if (atrybut is IXmlLineInfo)
     {
         IXmlLineInfo info = atrybut as IXmlLineInfo;
         PositionInfo pozycja = new PositionInfo(info.LineNumber, info.LinePosition);
         return pozycja;
     }
     return null;
 }
Esempio n. 9
0
 /// <summary>
 /// Metoda wydobywająca z obiektu WezelXML informacje o jego lokalizacji
 /// </summary>
 /// <param name="wezel">obiekt WezelXML</param>
 public static PositionInfo Pozycja(WezelXML wezel)
 {
     if (wezel.Element is IXmlLineInfo)
     {
         IXmlLineInfo info = wezel.Element as IXmlLineInfo;
         PositionInfo pozycja = new PositionInfo(info.LineNumber, info.LinePosition);
         return pozycja;
     }
     return null;
 }
 public BaseValidator(BaseValidator other) {
     reader = other.reader;
     schemaCollection = other.schemaCollection;
     eventHandler = other.eventHandler;
     nameTable = other.nameTable;
     schemaNames = other.schemaNames;
     positionInfo = other.positionInfo;
     xmlResolver = other.xmlResolver;
     baseUri = other.baseUri;
     elementName = other.elementName;
 }
Esempio n. 11
0
        public override TurnHeuristics.Value EvaluatePosition(PositionInfo positionInfo, Side player)
        {
            var value = new TurnHeuristics.Value();
            foreach (PositionInfo.Orientation o in PositionInfo.Orientations)
            {
                value.threat_level = Math.Max(EvaluateThreatLevel(positionInfo[o, PositionInfo.Direction.Positive],
                         positionInfo[o, PositionInfo.Direction.Negative],
                         player), value.threat_level);

                if (value.threat_level >= 2) return value;

                value.cost += EvaluateOrientation(positionInfo[o, PositionInfo.Direction.Positive],
                                         positionInfo[o, PositionInfo.Direction.Negative],
                                         player);
            }
            return value;
        }
Esempio n. 12
0
 public DriveInfo(PositionInfo position,
     float runtime,
     float speedL, float speedR,
     float distanceL, float distanceR,
     int driveStatus,
     int motorStatusL, int motorStatusR)
 {
     Position = position;
       Runtime = runtime;
       SpeedL = speedL;
       SpeedR = speedR;
       DistanceL = distanceL;
       DistanceR = distanceR;
       DriveStatus = driveStatus;
       MotorStatusL = motorStatusL;
       MotorStatusR = motorStatusR;
 }
Esempio n. 13
0
        public static float GetFreeSpace()
        {
            if (ObstacleMap != null)
              {
            PositionInfo offset = Robot.Radar.AntennaPosition;
            PositionInfo position = Robot.Position;

            float phi = position.Angle/180.0f*(float) Math.PI;

            var radarPos = new PositionInfo(
              position.X + offset.X*(float) Math.Cos(phi) - offset.Y*(float) Math.Sin(phi),
              position.Y + offset.X*(float) Math.Sin(phi) + offset.Y*(float) Math.Cos(phi),
              (position.Angle + offset.Angle)%360);
            return (float) ObstacleMap.GetFreeSpace(radarPos);
              }
              else return 2.55f;
        }
Esempio n. 14
0
        internal Validator(XmlNameTable nameTable, SchemaNames schemaNames, XmlValidatingReader reader) {
            this.nameTable = nameTable;
            this.schemaNames = schemaNames;
            this.reader = reader;
            positionInfo = PositionInfo.GetPositionInfo(reader);
            nsManager = reader.NamespaceManager;
            if (nsManager == null) {
                nsManager = new XmlNamespaceManager(nameTable);
                isProcessContents = true;
            }
            SchemaInfo = new SchemaInfo(schemaNames);

            validationStack = new HWStack(STACK_INCREMENT);
            textValue = new StringBuilder();
            this.name = XmlQualifiedName.Empty;
            attPresence = new Hashtable();
            context = null;
            attnDef = null;
        }
Esempio n. 15
0
 protected override PositionInfo CalcColumnDrag(GridHitInfo hit, GridColumn column)
 {
     var patchedPI = base.CalcColumnDrag(hit, column);
     if (patchedPI.Index != HideElementPosition || !patchedPI.Valid)
     {
         return patchedPI;
     }
     var col = column as CommonGridColumn;
     if (col == null)
     {
         return patchedPI;
     }
     if (!col.OptionsColumn.AllowQuickHide)
     {
         patchedPI = new PositionInfo
         {
             Valid = false
         };
     }
     return patchedPI;
 }
Esempio n. 16
0
    /// <summary>
    /// 
    /// </summary>
    void Start()
    {
        m_Transform = transform;
        //add the current position as first position in the list
        PositionInfo[] all = Positions.ToArray();
        List<PositionInfo> newall = new List<PositionInfo>();
        PositionInfo npi = new PositionInfo();
        npi.Position = m_Transform.position;
        npi.Speed = all[0].Speed;
        npi.DelayToNext = all[0].DelayToNext;

        newall.Add(npi);
        newall.AddRange(all);
        Positions = newall;

        if (Sync)
        {
            if (!isMine)
                return;
        }

        StartCoroutine(Process());
    }
Esempio n. 17
0
    public static jQueryObject ScrollPagerPlugin(ScrollPagerPluginOptions customOptions)
    {
        ScrollPagerPluginOptions defaultOptions =new ScrollPagerPluginOptions();
        defaultOptions.pageSize = 10;
        defaultOptions.currentPage = 1;
        defaultOptions.holder = ".listcontainer";
        defaultOptions.viewport = "";
        defaultOptions.pageHeight = 23;
        defaultOptions.onPageChanged = null;
        defaultOptions.container = "#listcontainerdiv";

        ScrollPagerPluginOptions options =jQuery.ExtendObject<ScrollPagerPluginOptions>(new ScrollPagerPluginOptions(), defaultOptions, customOptions);

        //if (options.totalRecords / options.pageSize > 1)
        //{
        //    options.showThumbNavigators = true;
        //}

        return jQuery.Current.Each(delegate(int i, Element element)
                                   	{
                                   		jQueryObject selector = jQuery.This;
                                        int pageCounter = 1;
                                        PositionInfo iPosition = new PositionInfo();
                                        MouseInfo iMouse = new MouseInfo();
                                   		Number candidatePageIndex = 0;

                                        //this goes through every item in the
                                   		selector
                                            .Children()
                                            .Each(delegate(int ic, Element elc)
                                   		                         	{
                                                                        if (ic < pageCounter * options.pageSize && ic >= (pageCounter - 1) * options.pageSize)
                                                                        {
                                                                            jQuery.This.AddClass("page" + pageCounter);
                                                                        }
                                                                        else
                                                                        {
                                                                            jQuery.This.AddClass("page" + (pageCounter+1));
                                                                            pageCounter++;
                                                                        }
                                   		                         	});

                                        //set and default the slider item height
                                        int contHeight = jQuery.Select(options.container).GetHeight();
                                        int sliderItemHeight = contHeight;

                                        //show/hide the appropriate regions
                                        selector.Children().Hide();
                                        jQuery.Select(".page" + options.currentPage).Show();

                                        //more than one page?
                                        if (pageCounter > 1)
                                        {
                                            //calculate the slider item height
                                            sliderItemHeight = (contHeight / pageCounter);
                                            int sliderThumbNavigatorHeight = 10;

                                            //Define the sliderThumbNavigators
                                            jQueryObject sliderThumbNavigate = jQuery.FromHtml("<div><div>");
                                            sliderThumbNavigate.AddClass("sliderNavigate");
                                            sliderThumbNavigate.CSS("height", sliderThumbNavigatorHeight + "px");

                                            jQueryObject sliderThumbNavigateUp = sliderThumbNavigate.Clone(true);
                                            sliderThumbNavigateUp.AddClass("up");
                                            sliderThumbNavigateUp.Text("U");

                                            jQueryObject sliderThumbNavigateDown = sliderThumbNavigate.Clone(true);
                                            sliderThumbNavigateDown.AddClass("down");
                                            sliderThumbNavigateDown.Text("D");

                                            //Build pager navigation
                                            jQueryObject pageNav = jQuery.FromHtml("<ul class=scrollbar sizcache='4' sizset='13'></ul>");
                                            for (i = 1; i <= pageCounter; i++)
                                            {
                                                if (i == options.currentPage)
                                                {
                                                    pageNav.Append("<LI class='currentPage pageItem' sizcache='4' sizset='13'><A class='sliderPage' href='#' rel='" + i + "'></A>");
                                                }
                                                else
                                                {
                                                    pageNav.Append("<LI class='pageNav" + i + " pageItem' sizcache='4' sizset='14'><A class='sliderPage' href='#' rel='" + i + "'></A>");
                                                }

                                            }

                                            //line-height:
                                            //Create slider item
                                            int sliderItemThumbPosition = Math.Round((options.currentPage - 1)*sliderItemHeight);
                                            double sliderItemThumbHeight = Math.Round((sliderItemHeight - 3));

                                            //If the height of the slide thumb is less than 3 * the height of the navigators then change the height
                                            if (options.showThumbNavigators && ((3 * sliderThumbNavigatorHeight) > sliderItemThumbHeight))
                                            {
                                                sliderItemThumbHeight = (3*sliderThumbNavigatorHeight);
                                            }

                                            jQueryObject sliderThumbObject = jQuery.FromHtml("<li></li>");
                                            sliderThumbObject.AddClass("thumb");
                                            sliderThumbObject.CSS("top", sliderItemThumbPosition.ToString());
                                            sliderThumbObject.CSS("height", sliderItemThumbHeight.ToString() + "px");

                                            jQueryObject sliderThumbBar = jQuery.FromHtml("<div></div>");
                                            sliderThumbBar.AddClass("sliderThumb");
                                            sliderThumbBar.CSS("line-height", sliderItemThumbHeight.ToString() + "px");
                                            sliderThumbBar.Attribute("rel", i.ToString());
                                            sliderThumbBar.Text(options.currentPage.ToString());

                                            //If there is more than one page of data then add navigators
                                            if (options.showThumbNavigators)
                                            {
                                                sliderThumbObject.Append(sliderThumbNavigateUp);
                                                sliderThumbObject.Append(sliderThumbBar);
                                                sliderThumbObject.Append(sliderThumbNavigateDown);
                                            }
                                            else
                                            {
                                                sliderThumbObject.Append(sliderThumbBar);
                                            }

                                            pageNav.Append(sliderThumbObject);

                                            if (options.holder == "")
                                            {
                                                selector.After(pageNav);
                                            }
                                            else
                                            {
                                                jQuery.Select(options.holder).Append(pageNav);
                                            }

                                            //Apply the slider item height
                                            jQuery.Select(".pageItem").Height(sliderItemHeight);

                                        }

                                        jQueryObject oTrack = jQuery.Select(".scrollbar");
                                        jQueryObject oThumb = jQuery.Select(".thumb");
                                        //jQueryObject oViewPort = jQuery.Select(options.viewport);
                                        Number maxPos = (oTrack.GetHeight() - oThumb.GetHeight());
                                        jQueryObject pageItemCollection = jQuery.Select(".pageItem a");

                                   		Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
                                   		                                      	{
                                                                                    string clickedLink = pageItem.GetAttribute("rel");
                                                                                    options.onPageChanged.Invoke(pageItem, new SelectedPageEventArgs(int.Parse(clickedLink)));

                                                                                    options.currentPage = int.Parse(clickedLink);
                                                                                    //remove current current (!) page
                                                                                    jQuery.Select("li.currentPage").RemoveClass("currentPage");
                                                                                    //Add current page highlighting
                                                                                    pageItem.Parent("li").AddClass("currentPage");
                                                                                    //hide and show relevant links
                                                                                    selector.Children().Hide();
                                                                                    selector.Find(".page" + clickedLink).Show();
                                   		                                      	};

                                        //Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
                                        jQueryEventHandler selectPageItemHandler = delegate(jQueryEvent pageItemClickedEvent)
                                        {
                                            //grab the REL attribute
                                            jQueryObject pageItem = jQuery.FromElement(pageItemClickedEvent.CurrentTarget);
                                            selectPageItem(pageItem);
                                        };

                                        //pager navigation behaviour
                                   		pageItemCollection.Live("click", selectPageItemHandler);

                                        jQueryEventHandler wheel = delegate(jQueryEvent oEvent)
                                   		                           	{
                                   		                           	};

                                        jQueryEventHandler drag = delegate(jQueryEvent oEvent)
                                        {
                                            Number candidatePos = Math.Max(0, (iPosition.Start + ((oEvent.PageY) - iMouse.Start)));
                                            iPosition.Now = Math.Round((candidatePos > maxPos) ? maxPos : candidatePos);
                                            candidatePageIndex = Math.Round(iPosition.Now / oThumb.GetHeight());
                                            oThumb.CSS("top", iPosition.Now.ToString() + "px");

                                            //If navigators are visible then choose the second child. NB: Going to tidy all this up as this approach is def not BP
                                            if (options.showThumbNavigators)
                                            {
                                                oThumb.Children().First().Next().Text((candidatePageIndex + 1).ToString());
                                            }
                                            else
                                            {
                                                oThumb.Children().First().Text((candidatePageIndex + 1).ToString());
                                            }
                                        };

                                        jQueryEventHandler end = null;
                                        end = delegate(jQueryEvent oEvent)
                                              	{
                                                    jQuery.Document.Unbind("mousemove", drag);
                                                    jQuery.Document.Unbind("mouseup", end);
                                                    oThumb.Die("mouseup", end);
                                                    selectPageItem(jQuery.FromElement(pageItemCollection[candidatePageIndex]));
                                                };

                                        jQueryEventHandler start = delegate(jQueryEvent oEvent)
                                        {
                                            iMouse.Start = oEvent.PageY;
                                            string oThumbDir = oThumb.GetCSS("top");
                                            iPosition.Start = (oThumbDir == "auto") ? 0 : int.Parse(oThumbDir);
                                            jQuery.Document.Bind("mousemove", drag);
                                            jQuery.Document.Bind("mouseup", end);
                                            oThumb.Live("mouseup", end);
                                        };

                                        Action setEvents = delegate()
                                        {
                                            oThumb.Live("mousedown", start);
                                            oTrack.Live("mouseup", drag);
                                            //if (options.scroll != null)
                                            //{
                                            //    oViewPort[0].AddEventListener("DOMMouseScroll", wheel, false);
                                            //    oViewPort[0].AddEventListener("mousewheel", wheel, false);
                                            //}
                                            //else if (options.scroll != null)
                                            //{
                                            //    oViewPort[0].OnMouseWheel = wheel;
                                            //}
                                        };

                                        setEvents.Invoke();

                                   	});
    }
Esempio n. 18
0
 public void UpdatePosition(PositionInfo pos)
 {
     service.SendMessage(WsMessageType.UpdatePosition, pos);
 }
Esempio n. 19
0
 /// <summary>
 /// Creates a new Blank Node ID Event for an anonymous Blank Node
 /// </summary>
 /// <param name="sourceXml">Source XML</param>
 /// <param name="pos">Position Info</param>
 public BlankNodeIDEvent(String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.BlankNodeID, sourceXml, pos)
 {
     _id = String.Empty;
 }
Esempio n. 20
0
 /// <summary>
 /// Creates a new Parse Type Attribute Event
 /// </summary>
 /// <param name="type">Parse Type</param>
 /// <param name="sourceXml">Source XML</param>
 /// <param name="pos">Position Info</param>
 public ParseTypeAttributeEvent(RdfXmlParseType type, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.ParseTypeAttribute, sourceXml, pos)
 {
     _type = type;
 }
Esempio n. 21
0
 /// <summary>
 /// Creates a new Blank Node ID Event for a named Blank Node
 /// </summary>
 /// <param name="identifier">Node ID for the Blank Node</param>
 /// <param name="sourceXml">Source XML</param>
 /// <param name="pos">Position Info</param>
 public BlankNodeIDEvent(String identifier, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.BlankNodeID, sourceXml, pos)
 {
     _id = identifier;
 }
Esempio n. 22
0
 public void Set(PositionInfo info)
 {
     lock (this)
     {
         m_pos = info.m_pos;
         m_parentPos = info.m_parentPos;
         m_parent = info.m_parent;
     }
 }
Esempio n. 23
0
 /// <summary>
 /// Creates a new URIRef Event from a URIRef in an XML Attribute value or similar
 /// </summary>
 /// <param name="identifier">URIRef</param>
 /// <param name="sourceXml">Source XML of the URIRef</param>
 /// <param name="pos">Position Info</param>
 public UriReferenceEvent(String identifier, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.UriReference, sourceXml, pos)
 {
     _id = identifier;
 }
Esempio n. 24
0
 /// <summary>
 /// Creates a new Plain Literal Event
 /// </summary>
 /// <param name="value">Value of the Literal</param>
 /// <param name="language">Language Specifier of the Literal</param>
 /// <param name="sourceXml">Source XML of the Event</param>
 /// <param name="pos">Position Info</param>
 public PlainLiteralEvent(String value, String language, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.Literal, sourceXml, pos)
 {
     _value    = value;
     _language = language;
 }
Esempio n. 25
0
 /// <summary>
 /// Gets the Position range from the given Start Position to the current Position
 /// </summary>
 /// <param name="startPosition">Start Position</param>
 /// <returns></returns>
 public PositionInfo GetPositionRange(PositionInfo startPosition)
 {
     return new PositionInfo(startPosition.StartLine, this._input.LineNumber, startPosition.StartPosition, this._input.LinePosition);
 }
Esempio n. 26
0
    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";
        List <Vector3>  list        = new List <Vector3>();
        List <DateTime> timelist    = new List <DateTime>();
        var             posInfoList = new PositionInfoList();
        DateTime        end         = GetEndTime();
        DateTime        start       = GetStartTime();

        //List<Position> positions = new List<Position>();
        positions = new List <Position>();

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);


        Loom.StartSingleThread(() =>
        {
            //ps = CommunicationObject.Instance.GetHistoryPositonsByTime(code, start, end);
            positions = GetHistoryData(personnel.Id, topoNodeIds, start, end);

            Loom.DispatchToMainThread(() =>
            {
                Debug.LogError("点数:" + positions.Count);
                if (positions.Count < 2)
                {
                    return;
                }

                for (int i = 0; i < positions.Count; i++)
                {
                    var p = new PositionInfo(positions[i], start);
                    posInfoList.Add(p);
                }

                PathInfo pathInfo   = new PathInfo();
                pathInfo.personnelT = personnel;
                pathInfo.color      = Color.green;
                pathInfo.posList    = posInfoList;
                pathInfo.timeLength = timeLength;

                LocationHistoryPath histoyObj             = LocationHistoryManager.Instance.ShowLocationHistoryPath(pathInfo, "HistoryPath0002");
                HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                histoyObj.historyManController            = historyManController;
                historyManController.Init(Color.green, histoyObj);
                PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                personAnimationController.DoMove();

                PathFindingManager.Instance.StartNavAgent(historyManController);

                isLoadDataSuccessed = true;
                timeStart           = Time.time;
                timeSum             = 0;
                //histoyObj.InitData(timeLength, timelist);
            });
        });
    }
Esempio n. 27
0
 public void InsertPosition(PositionInfo pos)
 {
     service.SendMessage(WsMessageType.InsertPosition, pos);
 }
Esempio n. 28
0
        public void UpdateSLTP(long magicId, long AccountNumber, IEnumerable <PositionInfo> UpdatePositions)
        {
            lock (lockObject)
            {
                Dictionary <long, PositionInfo> positionsToAdd = new Dictionary <long, PositionInfo>();
                List <long> positionsToDelete = new List <long>();
                foreach (var notcontains in UpdatePositions)
                {
                    if (!positionsToAdd.ContainsKey(notcontains.Ticket))
                    {
                        notcontains.AccountName = terminals[AccountNumber].Broker;
                        notcontains.Profit      = (double)xtrade.ConvertToUSD(new decimal(notcontains.Profit), terminals[AccountNumber].Currency);
                        positionsToAdd.Add(notcontains.Ticket, notcontains);
                    }
                }

                foreach (var pos in positions.Where(x => x.Value.Account.Equals(AccountNumber)))
                {
                    var contains = UpdatePositions.Where(x => x.Ticket == pos.Key && x.Account == AccountNumber);
                    if (contains != null && contains.Count() > 0)
                    {
                        positionsToAdd.Remove(pos.Key);
                        var newvalue = contains.FirstOrDefault();
                        newvalue.AccountName = terminals[AccountNumber].Broker;
                        if (positions.TryUpdate(pos.Key, newvalue, pos.Value))
                        {
                            UpdatePosition(newvalue);
                        }
                    }
                    else
                    {
                        //if (pos.Value.Magic == magicId) (pos.Value.Account == AccountNumber)
                        if ((pos.Value.Magic == magicId))//&& (pos.Value.Ticket > 0)
                        {
                            positionsToDelete.Add(pos.Key);
                        }
                    }

                    foreach (var notcontains in UpdatePositions.Where(x => x.Ticket != pos.Key))
                    {
                        if (!positionsToAdd.ContainsKey(notcontains.Ticket))
                        {
                            positionsToAdd.Add(notcontains.Ticket, notcontains);
                        }
                    }
                }

                foreach (var toremove in positionsToDelete)
                {
                    PositionInfo todel = null;
                    if (positions.TryRemove(toremove, out todel))
                    {
                        RemovePosition(toremove);
                    }
                }

                foreach (var toadd in positionsToAdd)
                {
                    toadd.Value.AccountName = terminals[AccountNumber].Broker;
                    if (positions.TryAdd(toadd.Key, toadd.Value))
                    {
                        InsertPosition(toadd.Value);
                    }
                }
            }
        }
Esempio n. 29
0
 public EtdFuturePosition createPosition(PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData)
 {
     return(EtdFuturePosition.ofLongShort(positionInfo, this, longQuantity, shortQuantity));
 }
Esempio n. 30
0
 public EtdFuturePosition createPosition(PositionInfo positionInfo, double quantity, ReferenceData refData)
 {
     return(EtdFuturePosition.ofNet(positionInfo, this, quantity));
 }
Esempio n. 31
0
        public bool ApplyMove(GameObject gameObject, Vector2Int dest, bool checkObjects = true, bool collision = true)
        {
            if (gameObject.Room == null)
            {
                return(false);
            }
            if (gameObject.Room.Map != this)
            {
                return(false);
            }

            PositionInfo posInfo = gameObject.PosInfo;

            if (CanGo(dest, checkObjects) == false)
            {
                return(false);
            }

            if (collision)
            {
                // Remove
                {
                    int x = posInfo.PosX - MinX;
                    int y = MaxY - posInfo.PosY;
                    if (_objects[y, x] == gameObject)
                    {
                        _objects[y, x] = null;
                    }
                }
                {
                    int x = dest.x - MinX;
                    int y = MaxY - dest.y;
                    _objects[y, x] = gameObject;
                }
            }

            // Zone
            GameObjectType type = ObjectManager.GetObjectTypeById(gameObject.Id);

            if (type == GameObjectType.Player)
            {
                Player player = (Player)gameObject;
                Zone   now    = gameObject.Room.GetZone(gameObject.CellPos);
                Zone   after  = gameObject.Room.GetZone(dest);
                if (now != after)
                {
                    now.Players.Remove(player);
                    after.Players.Add(player);
                }
            }
            else if (type == GameObjectType.Monster)
            {
                Monster monster = (Monster)gameObject;
                Zone    now     = gameObject.Room.GetZone(gameObject.CellPos);
                Zone    after   = gameObject.Room.GetZone(dest);
                if (now != after)
                {
                    now.Monsters.Remove(monster);
                    after.Monsters.Add(monster);
                }
            }
            else if (type == GameObjectType.Projectile)
            {
                Projectile projectile = (Projectile)gameObject;
                Zone       now        = gameObject.Room.GetZone(gameObject.CellPos);
                Zone       after      = gameObject.Room.GetZone(dest);
                if (now != after)
                {
                    now.Projectiles.Remove(projectile);
                    after.Projectiles.Add(projectile);
                }
            }

            // 실제 좌표 이동
            posInfo.PosX = dest.x;
            posInfo.PosY = dest.y;
            return(true);
        }
            public static ChessGamePlayer CreateFromFEN(string
								     fen)
            {
                PositionInfo info = new PositionInfo (fen);
                string[]lines = info.position_str.Split ('/');
                if (lines.Length != 8)
                    throw new
                        ChessException
                        (Catalog.GetString("Invalid number tokens in the FEN position"));
                ChessSide whites =
                    new ChessSide (ColorType.WHITE);
                ChessSide blacks =
                    new ChessSide (ColorType.BLACK);
                for (int i = 0; i < lines.Length; i++)
                  {
                      string line = lines[i];
                      for (int j = 0; j < line.Length;
                           j++)
                        {
                            char ch = line[j];
                            if (Char.IsNumber (ch))
                              {
                                  j += ch - '1';	// starting from 1 since j++ will increment 1
                                  continue;
                              }
                            int rank = 7 - i;
                            int file = j;
                            ChessPiece piece;
                            GetPieceForFENChar (ch,
                                    whites,
                                    blacks,
                                    rank,
                                    file,
                                    out
                                    piece);
                            piece.addToSide ();
                        }
                  }
                whites.King.CanCastle = info.WhiteCanCastle;
                blacks.King.CanCastle = info.BlackCanCastle;
                ChessGamePlayer game = new ChessGamePlayer ();
                game.turn = info.Turn;
                game.StartGame (whites, blacks);
                return game;
            }
Esempio n. 33
0
        public void UpdatePositions(long magicId, long AccountNumber, IEnumerable <PositionInfo> posMagic)
        {
            lock (lockObject)
            {
                bool doSave = false;
                Dictionary <long, PositionInfo> positionsToAdd = new Dictionary <long, PositionInfo>();
                List <long> positionsToDelete = new List <long>();
                foreach (var notcontains in posMagic)
                {
                    if (!positionsToAdd.ContainsKey(notcontains.Ticket))
                    {
                        notcontains.AccountName = terminals[AccountNumber].Broker;
                        notcontains.Profit      = (double)xtrade.ConvertToUSD(new decimal(notcontains.Profit), terminals[AccountNumber].Currency);
                        notcontains.Value       = notcontains.Profit + (double)xtrade.ConvertToUSD(new decimal(notcontains.calculateValue()), notcontains.cur);
                        positionsToAdd.Add(notcontains.Ticket, notcontains);
                    }
                }

                foreach (var pos in positions.Where(x => x.Value.Account.Equals(AccountNumber)))
                {
                    var contains = posMagic.Where(x => x.Ticket == pos.Key && x.Account == AccountNumber);
                    if (contains != null && contains.Count() > 0)
                    {
                        positionsToAdd.Remove(pos.Key);
                        var newvalue = contains.FirstOrDefault();
                        //newvalue.ProfitStopsPercent = pos.Value.ProfitStopsPercent;
                        newvalue.AccountName = terminals[AccountNumber].Broker;
                        if (!newvalue.Role.Equals(pos.Value.Role))
                        {
                            newvalue.Role = pos.Value.Role;
                            doSave        = true;
                        }
                        if (positions.TryUpdate(pos.Key, newvalue, pos.Value))
                        {
                            UpdatePosition(newvalue);
                        }
                    }
                    else
                    {
                        //if (pos.Value.Account == AccountNumber)  (pos.Value.Account == AccountNumber) && (pos.Value.Ticket > 0)
                        if ((pos.Value.Account == AccountNumber) && (pos.Value.Ticket > 0))
                        {
                            positionsToDelete.Add(pos.Key);
                        }
                    }

                    foreach (var notcontains in posMagic.Where(x => x.Ticket != pos.Key))
                    {
                        if (!positionsToAdd.ContainsKey(notcontains.Ticket))
                        {
                            positionsToAdd.Add(notcontains.Ticket, notcontains);
                            doSave = true;
                        }
                    }
                }

                foreach (var toremove in positionsToDelete)
                {
                    PositionInfo todel = null;
                    if (positions.TryRemove(toremove, out todel))
                    {
                        RemovePosition(toremove);
                        doSave = true;
                    }
                }

                foreach (var toadd in positionsToAdd)
                {
                    toadd.Value.AccountName = terminals[AccountNumber].Broker;
                    if (positions.TryAdd(toadd.Key, toadd.Value))
                    {
                        InsertPosition(toadd.Value);
                        doSave = true;
                    }
                }
                if (doSave)
                {
                    SavePositions();
                }
            }
        }
Esempio n. 34
0
        public static PositionInfo GetBestPosition()
        {
            var posChecked    = 0;
            var maxPosToCheck = 50;
            var posRadius     = 50;
            var radiusIndex   = 0;

            var extraDelayBuffer   = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
            var extraEvadeDistance = ObjectCache.MenuCache.Cache["ExtraEvadeDistance"].As <MenuSlider>().Value;

            SpellDetector.UpdateSpells();
            CalculateEvadeTime();

            if (ObjectCache.MenuCache.Cache["CalculateWindupDelay"].Enabled)
            {
                var extraWindupDelay = Evade.LastWindupTime - Environment.TickCount;
                if (extraWindupDelay > 0)
                {
                    extraDelayBuffer += (int)extraWindupDelay;
                }
            }

            extraDelayBuffer += (int)Evade.AvgCalculationTime;

            if (ObjectCache.MenuCache.Cache["HigherPrecision"].Enabled)
            {
                maxPosToCheck = 150;
                posRadius     = 25;
            }

            var heroPoint   = ObjectCache.MyHeroCache.ServerPos2D;
            var lastMovePos = Game.CursorPos.To2D();

            var lowestEvadeTime = SpellDetector.GetLowestEvadeTime(out var lowestEvadeTimeSpell);

            var fastestPositions = GetFastestPositions();

            var posTable = fastestPositions.Select(pos => InitPositionInfo(pos, extraDelayBuffer, extraEvadeDistance, lastMovePos, lowestEvadeTimeSpell)).ToList();

            while (posChecked < maxPosToCheck)
            {
                radiusIndex++;

                var curRadius       = radiusIndex * 2 * posRadius;
                var curCircleChecks = (int)Math.Ceiling(2 * Math.PI * curRadius / (2 * (double)posRadius));

                for (var i = 1; i < curCircleChecks; i++)
                {
                    posChecked++;
                    var cRadians = 2 * Math.PI / (curCircleChecks - 1) * i; //check decimals
                    var pos      = new Vector2((float)Math.Floor(heroPoint.X + curRadius * Math.Cos(cRadians)), (float)Math.Floor(heroPoint.Y + curRadius * Math.Sin(cRadians)));
                    posTable.Add(InitPositionInfo(pos, extraDelayBuffer, extraEvadeDistance, lastMovePos, lowestEvadeTimeSpell));
                }
            }

            IOrderedEnumerable <PositionInfo> sortedPosTable;

            if (ObjectCache.MenuCache.Cache["EvadeMode"].As <MenuList>().SelectedItem == "Fastest")
            {
                sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenByDescending(p => p.IntersectionTime).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount);

                FastEvadeMode = true;
            }
            else if (FastEvadeMode)
            {
                sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenByDescending(p => p.IntersectionTime).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount);
            }
            else if (ObjectCache.MenuCache.Cache["FastEvadeActivationTime"].As <MenuSlider>().Value > 0 &&
                     ObjectCache.MenuCache.Cache["FastEvadeActivationTime"].As <MenuSlider>().Value + ObjectCache.GamePing + extraDelayBuffer > lowestEvadeTime)
            {
                sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenByDescending(p => p.IntersectionTime).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount);

                FastEvadeMode = true;
            }
            else
            {
                sortedPosTable = posTable.OrderBy(p => p.RejectPosition).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount).ThenBy(p => p.DistanceToMouse);

                if (sortedPosTable.First().PosDangerCount != 0) //if can't dodge smoothly, dodge fast
                {
                    var sortedPosTableFastest = posTable.OrderBy(p => p.IsDangerousPos).ThenByDescending(p => p.IntersectionTime).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount);

                    if (sortedPosTableFastest.First().PosDangerCount == 0)
                    {
                        sortedPosTable = sortedPosTableFastest;
                        FastEvadeMode  = true;
                    }
                }
            }

            foreach (var posInfo in sortedPosTable)
            {
                if (CheckPathCollision(MyHero, posInfo.Position))
                {
                    continue;
                }
                if (FastEvadeMode)
                {
                    posInfo.Position = GetExtendedSafePosition(ObjectCache.MyHeroCache.ServerPos2D, posInfo.Position, extraEvadeDistance);
                    return(CanHeroWalkToPos(posInfo.Position, ObjectCache.MyHeroCache.MoveSpeed, ObjectCache.GamePing, 0));
                }

                if (!PositionInfoStillValid(posInfo))
                {
                    continue;
                }

                if (posInfo.Position.CheckDangerousPos(extraEvadeDistance)) //extra evade distance, no multiple skillshots
                {
                    posInfo.Position = GetExtendedSafePosition(ObjectCache.MyHeroCache.ServerPos2D, posInfo.Position, extraEvadeDistance);
                }

                return(posInfo);
            }

            return(PositionInfo.SetAllUndodgeable());
        }
Esempio n. 35
0
        private static Position trade()
        {
            PositionInfo info = PositionInfo.of(StandardId.of("OG-Position", "1"));

            return(GenericSecurityPosition.ofNet(info, SECURITY, 6));
        }
Esempio n. 36
0
 /// <summary>
 /// Creates a new XML Base Attribute
 /// </summary>
 /// <param name="baseUri">Base URI</param>
 /// <param name="sourceXml">Source XML</param>
 /// <param name="pos">Position Info</param>
 public XmlBaseAttributeEvent(String baseUri, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.XmlBaseAttribute, sourceXml, pos)
 {
     _baseUri = baseUri;
 }
Esempio n. 37
0
        /// <summary>
        /// Creates a new Entity (should not occur on it's own)
        /// </summary>
        public EntityBase()
        {
            m_uuid = UUID.Zero;

            m_posInfo = new PositionInfo();

            Rotation = Quaternion.Identity;
            m_name = "(basic entity)";
            m_rotationalvelocity = Vector3.Zero;
        }
 public BindablePositionInfo(PositionInfo info) : base()
     => SetPositionInfo(info);
Esempio n. 39
0
 /// <summary>
 /// Creates a new QName Event
 /// </summary>
 /// <param name="qname">QName</param>
 /// <param name="sourceXml">Source XML of the QName</param>
 /// <param name="pos">Position Info</param>
 public QNameEvent(String qname, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.QName, sourceXml, pos)
 {
     _qname = qname;
 }
Esempio n. 40
0
 public void SetPosInfo(PositionInfo info)
 {
     lock (m_posInfo)
     {
         m_posInfo.m_pos = info.m_pos;
         m_posInfo.m_parentPos = info.m_parentPos;
         m_posInfo.m_parent = info.m_parent;
     }
 }
Esempio n. 41
0
 public override void ClearScreen()
 {
     this.tempInfo = new PositionInfo();
     base.ClearScreen();
 }
Esempio n. 42
0
 public PositionInfo(PositionInfo info)
 {
     Set(info);
 }
Esempio n. 43
0
 /// <summary>
 /// Obtains an instance from the security, long quantity and short quantity.
 /// <para>
 /// The long quantity and short quantity must be zero or positive, not negative.
 /// In many cases, only a long quantity or short quantity will be present with the other set to zero.
 /// However it is also possible for both to be non-zero, allowing long and short positions to be treated separately.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="longQuantity">  the long quantity of the underlying security </param>
 /// <param name="shortQuantity">  the short quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static EtdFuturePosition ofLongShort(EtdFutureSecurity security, double longQuantity, double shortQuantity)
 {
     return(ofLongShort(PositionInfo.empty(), security, longQuantity, shortQuantity));
 }
        /// <summary>
        /// Returns best position to move and profit
        /// </summary>
        /// <param name="maxEnergy"></param>
        /// <param name="profit"></param>
        /// <param name="robot"></param>
        /// <returns></returns>
        public Position GetBestMovePosition(int maxEnergy, out int profit, Rb robot = null)
        {
            if (robot == null)
                robot = Current.Robot;
            Position bestPosition = null;
            var bestProfit = int.MinValue;
            var posVariants = new Dictionary<Position, PositionInfo>();
            var stationsInTouch = DistanceHelper.GetNearbyStations(robot.Position, maxEnergy);

            foreach (var station in stationsInTouch)
            {
                for (var i = -Constants.EnergyCollectingDistance; i <= Constants.EnergyCollectingDistance; ++i)
                {
                    for (var j = -Constants.EnergyCollectingDistance; j <= Constants.EnergyCollectingDistance; ++j)
                    {
                        var pos = new Position(station.Position.X + i, station.Position.Y + j);
                        if(DistanceHelper.FindCost(pos, robot.Position) > maxEnergy) continue;
                        Rb attRob;
                        var stInfo = new StationInfo()
                        {
                            UsageVariant = CheckStaionUsage(station, out attRob),
                            AttackRobot = attRob
                        };
                        if(stInfo.UsageVariant == StationUseVariant.SkipOrLeave) continue;

                        if (posVariants.ContainsKey(pos))
                        {
                            posVariants[pos].NearestStations.Add(station, stInfo);
                        }
                        else
                        {
                            var posInfo = new PositionInfo
                            {
                                NearestStations = new Dictionary<EnergyStation, StationInfo> {{station, stInfo}}
                            };
                            posVariants[pos] = posInfo;
                        }
                    }
                }
            }

            foreach (var posKV in posVariants)
            {
                var pos = posKV.Key;
                var posInfo = posVariants[posKV.Key];
                var joinableStations = 0;
                var reserveStations = 0;
                posInfo.Profit = 0;
                foreach (var stationKV in posInfo.NearestStations)
                {
                    var station = stationKV.Key;
                    var stInfo = stationKV.Value;
                    posInfo.Profit += station.Energy;
                    switch (stInfo.UsageVariant)
                    {
                        case StationUseVariant.JoinOrCollect:
                            joinableStations++;
                            break;
                        case StationUseVariant.AttackOnly:
                            if (pos == stInfo.AttackRobot.Position)
                                posInfo.Profit += -50 + stInfo.AttackRobot.Energy/20;
                            else
                                posInfo.Profit -= station.Energy;
                            break;
                        case StationUseVariant.JoinReserve:
                            posInfo.Profit -= station.Energy;
                            reserveStations++;
                            break;
                    }
                }
                posInfo.Profit += (int) (posInfo.Profit*((double) joinableStations/2));
                posInfo.Profit += (int) (posInfo.Profit*((double) reserveStations/8));
                posInfo.Profit -= DistanceHelper.FindCost(robot.Position, pos);
                if (posInfo.Profit > bestProfit)
                {
                    bestProfit = posInfo.Profit;
                    bestPosition = pos;
                }
            }

            profit = bestProfit;
            return bestPosition;
        }
Esempio n. 45
0
 /// <summary>
 /// Obtains an instance from position information, security, long quantity and short quantity.
 /// <para>
 /// The long quantity and short quantity must be zero or positive, not negative.
 /// In many cases, only a long quantity or short quantity will be present with the other set to zero.
 /// However it is also possible for both to be non-zero, allowing long and short positions to be treated separately.
 ///
 /// </para>
 /// </summary>
 /// <param name="positionInfo">  the position information </param>
 /// <param name="security">  the underlying security </param>
 /// <param name="longQuantity">  the long quantity of the underlying security </param>
 /// <param name="shortQuantity">  the short quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static EtdFuturePosition ofLongShort(PositionInfo positionInfo, EtdFutureSecurity security, double longQuantity, double shortQuantity)
 {
     return(new EtdFuturePosition(positionInfo, security, longQuantity, shortQuantity));
 }
Esempio n. 46
0
 private static bool IsContainer(PositionInfo position)
 {
     var emberId = position.EmberId;
     return position.IsInner &&
         ((emberId == Sequence) || (emberId == Set) || (emberId.Class == Class.Application));
 }
Esempio n. 47
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableDefaults private static void applyDefaults(Builder builder)
        private static void applyDefaults(Builder builder)
        {
            builder.info_Renamed = PositionInfo.empty();
        }
Esempio n. 48
0
 /// <summary>
 /// Creates a new Language Attribute Event
 /// </summary>
 /// <param name="lang">Language</param>
 /// <param name="sourceXml">Source XML</param>
 /// <param name="pos">Position Info</param>
 public LanguageAttributeEvent(String lang, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.LanguageAttribute, sourceXml, pos)
 {
     _lang = lang;
 }
Esempio n. 49
0
 //-------------------------------------------------------------------------
 public EtdFuturePosition withInfo(PositionInfo info)
 {
     return(new EtdFuturePosition(info, security, longQuantity, shortQuantity));
 }
Esempio n. 50
0
		SearchControlPosition GetsearchControlPosition(SnapshotSpan span) {
			if (!IsSearchControlVisible)
				return SearchControlPosition.Default;

			var infos = new PositionInfo[] {
				// Sorted on preferred priority
				new PositionInfo(SearchControlPosition.TopRight, TopRightRect),
				new PositionInfo(SearchControlPosition.BottomRight, BottomRightRect),
			};
			Debug.Assert(infos.Length != 0 && infos[0].Position == SearchControlPosition.Default);

			foreach (var line in wpfTextView.TextViewLines.GetTextViewLinesIntersectingSpan(span)) {
				foreach (var info in infos) {
					if (Intersects(span, line, info.Rect))
						info.IntersectsSpan = true;
				}
			}
			var info2 = infos.FirstOrDefault(a => !a.IntersectsSpan) ?? infos.First(a => a.Position == SearchControlPosition.Default);
			return info2.Position;
		}
Esempio n. 51
0
 /// <summary>
 /// Creates a new Text Node
 /// </summary>
 /// <param name="value">Textual Content of the XML Text Node</param>
 /// <param name="sourceXml">Source XML of the Node</param>
 /// <param name="pos">Position Info</param>
 public TextEvent(String value, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.Text, sourceXml, pos)
 {
     _value = value;
 }
Esempio n. 52
0
        /// <summary>
        /// Liefert die Information, wie weit das nächste Hindernist entfernt ist.
        /// </summary>
        /// <param name="position">die aktuelle (eigene) Position inkl. Blickrichtung</param>
        /// <returns>Die Distanz zum nächsten Hindernis in Blickrichtung</returns>
        public double GetFreeSpace(PositionInfo position)
        {
            lock (_syncRoot)
              {
            // Hindernis-Suche mit Bresenham-Algorithmus
            int x1 = xToIndex(position.X);
            int y1 = yToIndex(position.Y);
            int x2 = xToIndex(position.X + MaxLength*Math.Cos(position.Angle/180*Math.PI));
            int y2 = yToIndex(position.Y + MaxLength*Math.Sin(position.Angle/180*Math.PI));

            int dx = x2 - x1;
            int dy = y2 - y1;
            int absDx = Math.Abs(dx);
            int absDy = Math.Abs(dy);
            int incX = Math.Sign(dx);
            int incY = Math.Sign(dy);
            int x = x1, y = y1, err = 0;
            if (absDx >= absDy)
            {
              err = -absDx/2;
              for (x = x1; x != x2; x = x + incX)
              {
            if ((x >= 0) && (x < _imageWidth) &&
                (y >= 0) && (y < _imageHeight) &&
                _obstaclePixel[y, x])
              break;
            else
            {
              err += absDy;
              if (err >= 0)
              {
                y += incY;
                err -= absDx;
              }
            }
              }
            }
            else
            {
              err = -absDy/2;
              for (y = y1; y != y2; y = y + incY)
              {
            if ((x >= 0) && (x < _imageWidth) &&
                (y >= 0) && (y < _imageHeight) &&
                _obstaclePixel[y, x])
              break;
            else
            {
              err += absDx;
              if (err >= 0)
              {
                x += incX;
                err -= absDy;
              }
            }
              }
            }
            double xSpace = (x - x1)*_area.Width/_imageWidth;
            double ySpace = (y - y1)*_area.Height/_imageHeight;
            return Math.Sqrt(xSpace*xSpace + ySpace*ySpace);
              }
        }
Esempio n. 53
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the security and net quantity.
 /// <para>
 /// The net quantity is the long quantity minus the short quantity, which may be negative.
 /// If the quantity is positive it is treated as a long quantity.
 /// Otherwise it is treated as a short quantity.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="netQuantity">  the net quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static EtdFuturePosition ofNet(EtdFutureSecurity security, double netQuantity)
 {
     return(ofNet(PositionInfo.empty(), security, netQuantity));
 }
Esempio n. 54
0
        public virtual void test()
        {
            EtdOptionSecurity test = sut();

            assertEquals(test.Variant, EtdVariant.MONTHLY);
            assertEquals(test.Type, EtdType.OPTION);
            assertEquals(test.Currency, Currency.GBP);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
            assertEquals(test.createProduct(REF_DATA), test);
            assertEquals(test.createTrade(TradeInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionTrade.of(TradeInfo.empty(), test, 1, 2));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, ReferenceData.empty()), EtdOptionPosition.ofNet(PositionInfo.empty(), test, 1));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionPosition.ofLongShort(PositionInfo.empty(), test, 1, 2));
        }
Esempio n. 55
0
        public static PositionInfo GetBestPositionTargetedDash(EvadeSpellData spell)
        {
            var extraDelayBuffer   = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value;
            var extraEvadeDistance = Math.Max(100, ObjectCache.MenuCache.Cache["ExtraEvadeDistance"].As <MenuSlider>().Value);
            var extraDist          = ObjectCache.MenuCache.Cache["ExtraCPADistance"].As <MenuSlider>().Value;

            var heroPoint = ObjectCache.MyHeroCache.ServerPos2DPing;

            var posTable  = new List <PositionInfo>();
            var spellList = SpellDetector.GetSpellList();

            var collisionCandidates = new List <Obj_AI_Base>();

            if (spell.SpellTargets.Contains(SpellTargets.Targetables))
            {
                collisionCandidates.AddRange(ObjectManager.Get <Obj_AI_Base>().Where(h => !h.IsMe && h.IsValidTarget(spell.Range)).Where(obj => obj.Type != GameObjectType.obj_AI_Turret));
            }
            else
            {
                var heroList = new List <Obj_AI_Hero>(); // Maybe change to IEnumerable

                if (spell.SpellTargets.Contains(SpellTargets.EnemyChampions) && spell.SpellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = GameObjects.Heroes.ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.EnemyChampions))
                {
                    heroList = GameObjects.EnemyHeroes.ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.AllyChampions))
                {
                    heroList = GameObjects.AllyHeroes.ToList();
                }

                collisionCandidates.AddRange(heroList.Where(h => !h.IsMe && h.IsValidTarget(spell.Range)).Cast <Obj_AI_Base>());

                var minionList = new List <Obj_AI_Minion>();

                if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions) && spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = GameObjects.Minions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.EnemyMinions))
                {
                    minionList = GameObjects.EnemyMinions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }
                else if (spell.SpellTargets.Contains(SpellTargets.AllyMinions))
                {
                    minionList = GameObjects.AllyMinions.Where(m => m.Distance(MyHero.ServerPosition) <= spell.Range).ToList();
                }

                collisionCandidates.AddRange(minionList.Where(h => h.IsValidTarget(spell.Range)).Cast <Obj_AI_Base>());
            }

            foreach (var candidate in collisionCandidates)
            {
                var pos = candidate.ServerPosition.To2D();

                PositionInfo posInfo;

                if (spell.SpellName == "YasuoDashWrapper")
                {
                    var hasDashBuff = candidate.Buffs.Any(buff => buff.Name == "YasuoDashWrapper");

                    if (hasDashBuff)
                    {
                        continue;
                    }
                }

                if (spell.BehindTarget)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = pos + dir * (candidate.BoundingRadius + ObjectCache.MyHeroCache.BoundingRadius);
                }

                if (spell.InfrontTarget)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = pos - dir * (candidate.BoundingRadius + ObjectCache.MyHeroCache.BoundingRadius);
                }

                if (spell.FixedRange)
                {
                    var dir = (pos - heroPoint).Normalized();
                    pos = heroPoint + dir * spell.Range;
                }

                if (spell.EvadeType == EvadeType.Dash)
                {
                    posInfo = CanHeroWalkToPos(pos, spell.Speed, extraDelayBuffer + ObjectCache.GamePing, extraDist);
                    posInfo.IsDangerousPos  = pos.CheckDangerousPos(6);
                    posInfo.DistanceToMouse = pos.GetPositionValue();
                    posInfo.SpellList       = spellList;
                }
                else
                {
                    var isDangerousPos = pos.CheckDangerousPos(6);
                    var dist           = pos.GetPositionValue();

                    posInfo = new PositionInfo(pos, isDangerousPos, dist);
                }

                posInfo.Target = candidate;
                posTable.Add(posInfo);
            }

            if (spell.EvadeType == EvadeType.Dash)
            {
                var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenBy(p => p.PosDangerLevel).ThenBy(p => p.PosDangerCount).ThenBy(p => p.DistanceToMouse);

                var first = sortedPosTable.FirstOrDefault();
                if (first != null && Evade.LastPosInfo != null && first.IsDangerousPos == false && Evade.LastPosInfo.PosDangerLevel > first.PosDangerLevel)
                {
                    return(first);
                }
            }
            else
            {
                var sortedPosTable = posTable.OrderBy(p => p.IsDangerousPos).ThenBy(p => p.DistanceToMouse);

                var first = sortedPosTable.FirstOrDefault();

                return(first);
            }

            return(null);
        }
Esempio n. 56
0
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the additional position information, defaulted to an empty instance.
 /// <para>
 /// This allows additional information to be attached to the position.
 /// </para>
 /// </summary>
 /// <param name="info">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder info(PositionInfo info)
 {
     JodaBeanUtils.notNull(info, "info");
     this.info_Renamed = info;
     return(this);
 }
Esempio n. 57
0
 /// <summary>
 /// Creates a new Root Event
 /// </summary>
 /// <param name="baseUri">Base Uri of the Document</param>
 /// <param name="sourceXml">Source XML of the Document</param>
 /// <param name="pos">Position Info</param>
 public RootEvent(String baseUri, String sourceXml, PositionInfo pos)
     : base(RdfXmlEvent.Root, sourceXml, pos)
 {
     _baseuri = baseUri;
 }
    public static jQueryObject ScrollPagerPlugin(ScrollPagerPluginOptions customOptions)
    {
        ScrollPagerPluginOptions defaultOptions =new ScrollPagerPluginOptions();
        defaultOptions.pageSize = 10;
        defaultOptions.currentPage = 1;
        defaultOptions.holder = ".listcontainer";
        defaultOptions.viewport = "";
        defaultOptions.pageHeight = 23;
        defaultOptions.onPageChanged = null;
        defaultOptions.container = "#listcontainerdiv";

        ScrollPagerPluginOptions options =jQuery.ExtendObject<ScrollPagerPluginOptions>(new ScrollPagerPluginOptions(), defaultOptions, customOptions);

        return jQuery.Current.Each(delegate(int i, Element element)
                                   	{
                                   		jQueryObject selector = jQuery.This;
                                        int pageCounter = 1;
                                        PositionInfo iPosition = new PositionInfo();
                                        MouseInfo iMouse = new MouseInfo();
                                   		Number candidatePageIndex = 0;

                                        //this goes through every item in the
                                   		selector
                                            .Children()
                                            .Each(delegate(int ic, Element elc)
                                   		                         	{
                                                                        if (ic < pageCounter * options.pageSize && ic >= (pageCounter - 1) * options.pageSize)
                                                                        {
                                                                            jQuery.This.AddClass("page" + pageCounter);
                                                                        }
                                                                        else
                                                                        {
                                                                            jQuery.This.AddClass("page" + (pageCounter+1));
                                                                            pageCounter++;
                                                                        }
                                   		                         	});

                                        //set and default the slider item height
                                        int contHeight = jQuery.Select(options.container).GetHeight();
                                        int sliderItemHeight = contHeight;

                                        //show/hide the appropriate regions
                                        selector.Children().Hide();
                                        jQuery.Select(".page" + options.currentPage).Show();

                                        //more than one page?
                                        if (pageCounter > 1)
                                        {
                                            //calculate the slider item height
                                            sliderItemHeight = (contHeight / pageCounter);

                                            //Build pager navigation
                                            string pageNav = "<UL class=scrollbar sizcache='4' sizset='13'>";
                                            for (i = 1; i <= pageCounter; i++)
                                            {
                                                if (i == options.currentPage)
                                                {
                                                    pageNav += "<LI class='currentPage pageItem' sizcache='4' sizset='13'><A class='sliderPage' href='#' rel='" + i + "'></A>";
                                                }
                                                else
                                                {
                                                    pageNav += "<LI class='pageNav" + i + " pageItem' sizcache='4' sizset='14'><A class='sliderPage' href='#' rel='" + i + "'></A>";
                                                }

                                            }

                                            //Create slider item
                                            string sliderItem = "<LI class='thumb' sizcache='4' sizset='13' style='top:" + (options.currentPage - 1) * sliderItemHeight + "; height:" + (sliderItemHeight - 3) + "'><A class='sliderThumb' href='#' rel='" + i + "'></A>";
                                            pageNav += sliderItem;
                                            pageNav += "</LI></UL>";

                                            if (options.holder == "")
                                            {
                                                selector.After(pageNav);
                                            }
                                            else
                                            {
                                                jQuery.Select(options.holder).Append(pageNav);
                                            }

                                            //Apply the slider item height
                                            jQuery.Select(".pageItem").Height(sliderItemHeight);

                                        }

                                        jQueryObject oTrack = jQuery.Select(".scrollbar");
                                        jQueryObject oThumb = jQuery.Select(".thumb");
                                        //jQueryObject oViewPort = jQuery.Select(options.viewport);
                                        Number maxPos = (oTrack.GetHeight() - oThumb.GetHeight());
                                        jQueryObject pageItemCollection = jQuery.Select(".pageItem a");

                                   		Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
                                   		                                      	{
                                                                                    string clickedLink = pageItem.GetAttribute("rel");
                                                                                    options.onPageChanged.Invoke(pageItem, new SelectedPageEventArgs(int.Parse(clickedLink)));

                                                                                    options.currentPage = int.Parse(clickedLink);
                                                                                    //remove current current (!) page
                                                                                    jQuery.Select("li.currentPage").RemoveClass("currentPage");
                                                                                    //Add current page highlighting
                                                                                    pageItem.Parent("li").AddClass("currentPage");
                                                                                    //hide and show relevant links
                                                                                    selector.Children().Hide();
                                                                                    selector.Find(".page" + clickedLink).Show();
                                   		                                      	};

                                        //Action<jQueryObject> selectPageItem = delegate(jQueryObject pageItem)
                                        jQueryEventHandler selectPageItemHandler = delegate(jQueryEvent pageItemClickedEvent)
                                        {
                                            //grab the REL attribute
                                            jQueryObject pageItem = jQuery.FromElement(pageItemClickedEvent.CurrentTarget);
                                            selectPageItem(pageItem);
                                        };

                                        //pager navigation behaviour
                                   		pageItemCollection.Live("click", selectPageItemHandler);

                                        jQueryEventHandler wheel = delegate(jQueryEvent oEvent)
                                   		                           	{
                                   		                           	};

                                        jQueryEventHandler drag = delegate(jQueryEvent oEvent)
                                        {
                                            Number candidatePos = Math.Max(0, (iPosition.Start + ((oEvent.PageY) - iMouse.Start)));
                                            iPosition.Now = (candidatePos > maxPos) ? maxPos : candidatePos;
                                            candidatePageIndex = Math.Round(iPosition.Now / oThumb.GetHeight());
                                            oThumb.CSS("top", iPosition.Now.ToString()); ;
                                        };

                                        jQueryEventHandler end = null;
                                        end = delegate(jQueryEvent oEvent)
                                        {
                                            jQuery.Document.Unbind("mousemove", drag);
                                            jQuery.Document.Unbind("mouseup", end);
                                            oThumb.Die("mouseup", end);
                                            selectPageItem(jQuery.FromElement(pageItemCollection[candidatePageIndex]));
                                        };

                                        jQueryEventHandler start = delegate(jQueryEvent oEvent)
                                        {
                                            iMouse.Start = oEvent.PageY;
                                            string oThumbDir = oThumb.GetCSS("top");
                                            iPosition.Start = (oThumbDir == "auto") ? 0 : int.Parse(oThumbDir);
                                            jQuery.Document.Bind("mousemove", drag);
                                            jQuery.Document.Bind("mouseup", end);
                                            oThumb.Live("mouseup", end);
                                        };

                                        Action setEvents = delegate()
                                        {
                                            oThumb.Live("mousedown", start);
                                            oTrack.Live("mouseup", drag);
                                            //if (options.scroll != null)
                                            //{
                                            //    oViewPort[0].AddEventListener("DOMMouseScroll", wheel, false);
                                            //    oViewPort[0].AddEventListener("mousewheel", wheel, false);
                                            //}
                                            //else if (options.scroll != null)
                                            //{
                                            //    oViewPort[0].OnMouseWheel = wheel;
                                            //}
                                        };

                                        setEvents.Invoke();

                                   	});
    }
Esempio n. 59
0
 internal XsdBuilder( 
                    XmlReader reader,
                    XmlNamespaceManager curmgr, 
                    XmlSchema schema, 
                    XmlNameTable nameTable,
                    SchemaNames schemaNames,
                    ValidationEventHandler eventhandler
                    ) {
     this.reader = reader;
     this.xso = this.schema = schema;
     this.namespaceManager = new BuilderNamespaceManager(curmgr, reader);
     this.validationEventHandler = eventhandler;
     this.nameTable = nameTable;
     this.schemaNames = schemaNames;
     this.stateHistory = new HWStack(STACK_INCREMENT);
     this.currentEntry = SchemaEntries[0];
     positionInfo = PositionInfo.GetPositionInfo(reader);
 }
Esempio n. 60
-1
 internal XdrBuilder(
                    XmlReader reader,
                    XmlNamespaceManager curmgr,
                    SchemaInfo sinfo,
                    string targetNamspace,
                    XmlNameTable nameTable,
                    SchemaNames schemaNames,
                    ValidationEventHandler eventhandler
                    )
 {
     _SchemaInfo = sinfo;
     _TargetNamespace = targetNamspace;
     _reader = reader;
     _CurNsMgr = curmgr;
     _validationEventHandler = eventhandler;
     _StateHistory = new HWStack(StackIncrement);
     _ElementDef = new ElementContent();
     _AttributeDef = new AttributeContent();
     _GroupStack = new HWStack(StackIncrement);
     _GroupDef = new GroupContent();
     _NameTable = nameTable;
     _SchemaNames = schemaNames;
     _CurState = s_schemaEntries[0];
     _positionInfo = PositionInfo.GetPositionInfo(_reader);
     _xmlResolver = null;
 }