public void ShouldProvideCurrentItems()
 {
     Window window = LaunchPetShopWindow();
     var comboBox = window.Find<EditableComboBox>("petTypeInput");
     var items = new System.Collections.Generic.List<string>(comboBox.Items);
     Assert.True(items.Contains("PetType[Rabbit]"));
     Assert.True(items.Contains("PetType[Dog]"));
 }
Exemplo n.º 2
0
    public System.Collections.Generic.List<Edge> createMinimumSpan()
    {
        Vector2 start = Vector2.zero;
        //Choose a point to start with
        foreach(Vector2 point in this.allPoints)
        {
            //This just pulls the first point. Do I need to do differently? If so I can put it here.

            start = point;
            break;
        }//for each

        System.Collections.Generic.List<Vector2> finished = new System.Collections.Generic.List<Vector2>();

        finished.Add(start);
        int numFinished = 1;

        //Reapeat until each vert in this.allPoints has been added to "finished"
        while(numFinished < this.allPoints.Count)
        {

            Vector2 source = allPoints[0];
            Vector2 destWithMinimalWeight = allPoints[1];
            float currentBestWeight = float.MaxValue;
            foreach(Vector2 point in finished)
            {
                //1. For each point in "finished"
                //Check all the other points and check to see if they're closer than the current best one
                foreach (Vector2 dest in this.allPoints)
                {
                    //If the dest is already in "finished", just ignore it and keep going
                    if(finished.Contains(dest))
                    {
                        continue; // go to the next one
                    }
                    float dist = Vector2.Distance(point, dest);
                    if(dist < currentBestWeight && dist > 0)
                    {
                        //If they are closer than the current best weight, update the current best
                        currentBestWeight = dist;
                        destWithMinimalWeight = dest;
                        source = point;
                    }//if
                }//for
            }//for each

            //2. Connect the source to the destWithMinimalPoint by making an edge
            Edge theNewEdge = new Edge(source, destWithMinimalWeight);
            edges.Add(theNewEdge);

            //3. Add the destination to "finished"
            finished.Add(destWithMinimalWeight);
            numFinished++;
        }//while

        return edges;
    }
Exemplo n.º 3
0
 static void LogHook(string name)
 {
     lock (_hooks)
     {
         if (!_hooks.Contains(name))
         {
             _hooks.Add(name);
             Console.WriteLine($"[Hook] {name}");
         }
     }
 }
Exemplo n.º 4
0
        public static void ProcessQueue()
        {
            //MelonLogger.Log(requestQueue.Count.ToString() + " in queue.");

            if (requestQueue.Count != 0)
            {
                for (int i = 0; i < requestQueue.Count; i++)
                {
                    SongSelectItem result = SearchSong(requestQueue[i]);

                    if (result != null)
                    {
                        MelonLogger.Log("Result: " + result.mSongData.songID);
                        MelonLogger.Log(result.mSongData.title);
                        if (!requestList.Contains(result.mSongData.songID))
                        {
                            requestList.Add(result.mSongData.songID);
                        }
                    }
                    else
                    {
                        MelonLogger.Log("Song not found");
                    }
                }
                requestQueue.Clear();
            }

            TextMeshPro buttonText = filterSongRequestsButton.GetComponentInChildren <TextMeshPro>();

            if (requestList.Count == 0)
            {
                if (buttonText.text.Contains("=green>"))
                {
                    buttonText.text = buttonText.text.Replace("=green>", "=red>");
                }
                else
                {
                    buttonText.text = "<color=red>" + buttonText.text + "</color>";
                }
                MelonLogger.Log("Red");
            }
            else
            {
                if (buttonText.text.Contains("=red>"))
                {
                    buttonText.text = buttonText.text.Replace("=red>", "=green>");
                }
                else
                {
                    buttonText.text = "<color=green>" + buttonText.text + "</color>";
                }
                MelonLogger.Log("Green");
            }
        }
 /// <summary> sets the key value tuple
 ///
 /// </summary>
 /// <param name="key">
 /// </param>
 /// <param name="value_Renamed">
 /// </param>
 public virtual void SetProperty(System.String key, System.String value_Renamed)
 {
     //System.Object tempObject = this[key];
     UnityEngine.PlayerPrefs.SetString(key, value_Renamed);
     if (!keys.Contains(key))
     {
         keys.Add(key);
     }
     //this[key] = value_Renamed;
     //System.Object generatedAux2 = tempObject;
 }
Exemplo n.º 6
0
        public void OpenFile(System.Windows.Forms.Form parent)
        {
            try
            {
                string filename = null;
                using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog())
                {
                    //pre-select last file if exist
                    string lastFN = (string)Settings.GetObject("Core.LastOpenFile", null);
                    if (lastFN != null && System.IO.File.Exists(lastFN))
                    {
                        ofd.FileName = lastFN;
                    }

                    ofd.Filter           = "Any supported file|*.nc;*.cnc;*.tap;*.gcode;*.bmp;*.png;*.jpg;*.gif|GCODE Files|*.nc;*.cnc;*.tap;*.gcode|Raster Image|*.bmp;*.png;*.jpg;*.gif";
                    ofd.CheckFileExists  = true;
                    ofd.Multiselect      = false;
                    ofd.RestoreDirectory = true;
                    if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        filename = ofd.FileName;
                    }
                }

                if (filename != null)
                {
                    Logger.LogMessage("OpenFile", "Open {0}", filename);
                    Settings.SetObject("Core.LastOpenFile", filename);

                    if (ImageExtensions.Contains(System.IO.Path.GetExtension(filename).ToLowerInvariant()))                     //import raster image
                    {
                        try
                        { RasterConverter.RasterToLaserForm.CreateAndShowDialog(this, filename, parent); }
                        catch (Exception ex)
                        { Logger.LogException("RasterImport", ex); }
                    }
                    else                     //load GCODE file
                    {
                        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                        try
                        { file.LoadFile(filename); }
                        catch (Exception ex)
                        { Logger.LogException("GCodeImport", ex); }

                        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("OpenFile", ex);
            }
        }
Exemplo n.º 7
0
    protected override void Awake()
    {
        portalCollider           = GetComponent <UnityEngine.BoxCollider>();
        portalCollider.isTrigger = true;

        portalTransform = new AkTransform();

        // set portal in it's initial state
        portalActive = initialState != State.Closed;

        RegisterTriggers(closePortalTriggerList, ClosePortal);

        base.Awake();

        //Call the ClosePortal function if registered to the Awake Trigger
        if (closePortalTriggerList.Contains(AWAKE_TRIGGER_ID))
        {
            ClosePortal(null);
        }
    }
Exemplo n.º 8
0
 public void updateTuioCur(long s_id, float x, float y, float X, float Y, float m)
 {
     if (list.Contains((int)s_id))
     {
         InputManager.Instance.RaiseCursorUpdate((int)s_id, new Microsoft.Xna.Framework.Vector2(1280 * x, 1024 * y));
     }
     else
     {
         list.Add((int)s_id);
         InputManager.Instance.RaiseCursorDown((int)s_id, new Microsoft.Xna.Framework.Vector2(1280 * x, 1024 * y));
     }
 }
Exemplo n.º 9
0
        protected override string GetFragments(Highlighter highlighter, TokenStream stream, string text)
        {
            var fragments = Array.FindAll(highlighter.GetBestTextFragments(stream, text, false, maxNumFragments), x => x.GetScore() > 0);

            if (fragments.Length == 0)
            {
                return(string.Empty);
            }

            var markupText = fragments[0].markedUpText.ToString();
            var matches    = Regex.Matches(markupText, "\r\n|\r|\n");
            var offsets    = new int[1 + matches.Count];

            offsets[0] = 0;
            for (var i = 0; i < matches.Count; i++)
            {
                offsets[1 + i] = matches[i].Index + matches[i].Length;
            }

            var result = new System.Text.StringBuilder();
            var lines  = new System.Collections.Generic.List <int>();

            foreach (var fragment in fragments)
            {
                var offset = markupText.LastIndexOfAny(DELIMITERS, fragment.textEndPos - 1, fragment.textEndPos - fragment.textStartPos);
                var line   = Array.FindIndex(offsets, x => x >= (offset == -1 ? fragment.textStartPos : offset));

                for (var l = Math.Max(0, line - contextLines); l <= Math.Min(matches.Count, line + contextLines); l++)
                {
                    if (!lines.Contains(l))
                    {
                        lines.Add(l);
                    }
                }
            }
            lines.Sort();

            var strFormat = "D" + lines[lines.Count - 1].ToString().Length;

            for (var i = 0; i < lines.Count; i++)
            {
                var line = lines[i];
                if (i > 0 && lines[i] > 1 + lines[i - 1])
                {
                    result.AppendLine(" .. ");
                }
                result.Append("<span class='line'>L")
                .Append((1 + line).ToString(strFormat))
                .Append(": </span>")
                .Append(markupText, offsets[line], (line == matches.Count ? markupText.Length : offsets[line + 1]) - offsets[line]);
            }
            return(result.ToString());
        }
Exemplo n.º 10
0
        protected void activateGO()
        {
            bool active = Platforms.Contains(currentPlatform) ? Active : !Active;

            foreach (GameObject go in Objects)
            {
                if (go != null)
                {
                    go.SetActive(active);
                }
            }
        }
Exemplo n.º 11
0
 public static Point[] GetResolutions()
 {
     System.Collections.Generic.List <Point> resolutions = new System.Collections.Generic.List <Point>();
     foreach (DisplayMode ds in d3d.Adapters[adapter].GetDisplayModes(Format.X8R8G8B8))
     {
         if (!resolutions.Contains(new Point(ds.Width, ds.Height)))
         {
             resolutions.Add(new Point(ds.Width, ds.Height));
         }
     }
     return(resolutions.ToArray());
 }
Exemplo n.º 12
0
        public bool Contains(Player player)
        {
            lock (mutex)
            {
                if (createdPlayers.Contains(player))
                {
                    return(true);
                }

                return(GetById(player.UserId) != null);;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the dependencies for a specific model elements.
        /// </summary>
        /// <param name="dependenciesData">Dependencies data to add new dependency and origin items to.</param>
        /// <param name="modelElement">Model element to get the dependencies for.</param>
        /// <param name="excludedDomainModels">Exclude dependencies that belong to a domain model that is provied in this list.</param>
        /// <param name="categories">List of categories to include in the search.</param>
        public virtual void GetDependencies(DependenciesData dependenciesData, DslModeling::ModelElement modelElement, System.Collections.Generic.List <DslModeling::ModelElement> excludedDomainModels, params DependencyItemCategory[] categories)
        {
            #region Check Parameter
            if (dependenciesData == null)
            {
                throw new System.ArgumentNullException("dependenciesData");
            }
            if (modelElement == null)
            {
                throw new System.ArgumentNullException("modelElement");
            }
            if (excludedDomainModels == null)
            {
                throw new System.ArgumentNullException("excludedDomainModels");
            }
            if (categories == null)
            {
                throw new System.ArgumentNullException("categories");
            }
            #endregion

            #region DomainTypeReferencesPropertyGridEditor
            // get all instances of DomainTypeReferencesPropertyGridEditor
            System.Collections.ObjectModel.ReadOnlyCollection <global::Tum.PDE.LanguageDSL.DomainTypeReferencesPropertyGridEditor> DomainTypeReferencesPropertyGridEditorLinks = DslModeling::DomainRoleInfo.GetElementLinks <global::Tum.PDE.LanguageDSL.DomainTypeReferencesPropertyGridEditor>(modelElement, global::Tum.PDE.LanguageDSL.DomainTypeReferencesPropertyGridEditor.DomainTypeDomainRoleId);
            if (DomainTypeReferencesPropertyGridEditorLinks.Count > 0)
            {
                foreach (global::Tum.PDE.LanguageDSL.DomainTypeReferencesPropertyGridEditor link in DomainTypeReferencesPropertyGridEditorLinks)
                {
                    bool bExclude = false;
                    if (excludedDomainModels.Count > 0)
                    {
                        DslModeling::ModelElement domainModel = LanguageDSLElementParentProvider.Instance.GetEmbeddingDomainModel(link.PropertyGridEditor);
                        if (excludedDomainModels.Contains(domainModel))
                        {
                            bExclude = true;
                        }
                    }
                    if (!bExclude)
                    {
                        foreach (DependencyItemCategory category in categories)
                        {
                            if (category == DependencyItemCategory.Referencing)
                            {
                                DependencyItem item = new DependencyItem(link, category,
                                                                         link.DomainType, link.PropertyGridEditor);
                                dependenciesData.ActiveDependencies.Add(item);
                            }
                        }
                    }
                }
            }
            #endregion
        }
        private System.Collections.Generic.List <Object> readers; // added by .net follower (http://dotnetfollower.com)

        // public MultiFormatOneDReader(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public MultiFormatOneDReader(System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            //System.Collections.ArrayList possibleFormats = hints == null?null:(System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS]; // commented by .net follower (http://dotnetfollower.com)
            System.Collections.Generic.List <Object> possibleFormats = null;                                        // added by .net follower (http://dotnetfollower.com)
            if (hints != null && hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))                                // added by .net follower (http://dotnetfollower.com)
            {
                possibleFormats = (System.Collections.Generic.List <Object>)hints[DecodeHintType.POSSIBLE_FORMATS]; // added by .net follower (http://dotnetfollower.com)
            }
            // bool useCode39CheckDigit = hints != null && hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] != null; // commented by .net follower (http://dotnetfollower.com)
            bool useCode39CheckDigit = hints != null && hints.ContainsKey(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT); // added by .net follower (http://dotnetfollower.com)

            // readers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
            readers = new System.Collections.Generic.List <Object>(10); // added by .net follower (http://dotnetfollower.com)
            if (possibleFormats != null)
            {
                if (possibleFormats.Contains(BarcodeFormat.EAN_13) || possibleFormats.Contains(BarcodeFormat.UPC_A) || possibleFormats.Contains(BarcodeFormat.EAN_8) || possibleFormats.Contains(BarcodeFormat.UPC_E))
                {
                    readers.Add(new MultiFormatUPCEANReader(hints));
                }
                if (possibleFormats.Contains(BarcodeFormat.CODE_39))
                {
                    readers.Add(new Code39Reader(useCode39CheckDigit));
                }
                if (possibleFormats.Contains(BarcodeFormat.CODE_128))
                {
                    readers.Add(new Code128Reader());
                }
                if (possibleFormats.Contains(BarcodeFormat.ITF))
                {
                    readers.Add(new ITFReader());
                }
            }
            if ((readers.Count == 0))
            {
                readers.Add(new MultiFormatUPCEANReader(hints));
                readers.Add(new Code39Reader());
                readers.Add(new Code128Reader());
                readers.Add(new ITFReader());
            }
        }
Exemplo n.º 15
0
        public static double FindPhaseAngleOfTarget(Vessel thisVessel, string TargetName)
        {
            //0       1       2        3       4       5      6       7      8        9        10     11      12       13     14      15      16
            string[] BODIES = {"Sun","Kerbin", "Mun", "Minmus", "Moho", "Eve", "Duna", "Ike", "Jool", "Laythe", "Vall", "Bop", "Tylo", "Gilly", "Pol", "Dres", "Eeloo"};
            CelestialBody body = FlightGlobals.Bodies[0];
            for (int i=0;i<BODIES.Length;i++)
            {
                //if (FlightGlobals.Bodies[i].GetName() == FlightGlobals.fetch.VesselTarget.GetName ())
                if (FlightGlobals.Bodies[i].GetName() == TargetName)
                {
                    body = FlightGlobals.Bodies[i];
                    break;
                }
            }

            System.Collections.Generic.List<CelestialBody> parentBodies = new System.Collections.Generic.List<CelestialBody>();
            CelestialBody parentBody = thisVessel.mainBody;
            while (true)
            {
                if (parentBody == body)
                {
                    return double.NaN;
                }
                parentBodies.Add(parentBody);
                if (parentBody == Planetarium.fetch.Sun)
                {
                    break;
                }
                else
                {
                    parentBody = parentBody.referenceBody;
                }
            }

            while (!parentBodies.Contains(body.referenceBody))
            {
                body = body.referenceBody;
            }

            Orbit orbit = thisVessel.orbit;
            while (orbit.referenceBody != body.referenceBody)
            {
                orbit = orbit.referenceBody.orbit;
            }

            // Calculate the phase angle
            double ut = Planetarium.GetUniversalTime();
            Vector3d vesselPos = orbit.getRelativePositionAtUT(ut);
            Vector3d bodyPos = body.orbit.getRelativePositionAtUT(ut);
            double phaseAngle = (Math.Atan2(bodyPos.y, bodyPos.x) - Math.Atan2(vesselPos.y, vesselPos.x)) * (180.0 / Math.PI);
            return (phaseAngle < 0) ? phaseAngle + 360 : phaseAngle;
        }
Exemplo n.º 16
0
        /// <summary>
        /// 递归遍历目录
        /// add yuangang by 2016-06-13
        /// </summary>
        private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath, System.Collections.Generic.List <string> IgNoreFiles = null)
        {
            if (strDirectory[strDirectory.Length - 1] != Path.DirectorySeparatorChar)
            {
                strDirectory += Path.DirectorySeparatorChar;
            }
            Crc32 crc = new Crc32();

            string[] filenames = Directory.GetFileSystemEntries(strDirectory);

            foreach (string file in filenames)// 遍历所有的文件和目录
            {
                if (IgNoreFiles != null && IgNoreFiles.Count > 0 && IgNoreFiles.Contains(file + "\\"))
                {
                    continue;
                }

                if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
                {
                    string pPath = parentPath;
                    pPath += file.Substring(file.LastIndexOf("\\") + 1);
                    pPath += "\\";
                    ZipSetp(file, s, pPath);
                }

                else // 否则直接压缩文件
                {
                    //打开压缩文件
                    using (FileStream fs = File.OpenRead(file))
                    {
                        byte[] buffer = new byte[fs.Length];
                        fs.Read(buffer, 0, buffer.Length);

                        string   fileName = parentPath + file.Substring(file.LastIndexOf("\\") + 1);
                        ZipEntry entry    = new ZipEntry(fileName);

                        entry.DateTime = DateTime.Now;
                        entry.Size     = fs.Length;

                        fs.Close();

                        crc.Reset();
                        crc.Update(buffer);

                        entry.Crc = crc.Value;
                        s.PutNextEntry(entry);

                        s.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }
Exemplo n.º 17
0
        public MultiFormatOneDReader(System.Collections.Generic.Dictionary <Object, Object> hints)
        {
            //System.Collections.Generic.List <Object> possibleFormats = hints == null?null:(System.Collections.Generic.List <Object>) hints[DecodeHintType.POSSIBLE_FORMATS];
            System.Collections.Generic.List <Object> possibleFormats = null;            //WP7 Port: above was throwing an exception when hints did not include Possible Format key
            if (hints != null && hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))
            {
                possibleFormats = (System.Collections.Generic.List <Object>)hints[DecodeHintType.POSSIBLE_FORMATS];
            }
            //bool useCode39CheckDigit = hints != null && hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] != null;
            bool useCode39CheckDigit = hints != null && hints.ContainsKey(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) && (bool)hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT];

            readers = new System.Collections.Generic.List <Object>(10);
            if (possibleFormats != null)
            {
                if (possibleFormats.Contains(BarcodeFormat.EAN_13) || possibleFormats.Contains(BarcodeFormat.UPC_A) || possibleFormats.Contains(BarcodeFormat.EAN_8) || possibleFormats.Contains(BarcodeFormat.UPC_E))
                {
                    readers.Add(new MultiFormatUPCEANReader(hints));
                }
                if (possibleFormats.Contains(BarcodeFormat.CODE_39))
                {
                    readers.Add(new Code39Reader(useCode39CheckDigit));
                }
                if (possibleFormats.Contains(BarcodeFormat.CODE_128))
                {
                    readers.Add(new Code128Reader());
                }
                if (possibleFormats.Contains(BarcodeFormat.ITF))
                {
                    readers.Add(new ITFReader());
                }
            }
            if ((readers.Count == 0))
            {
                readers.Add(new MultiFormatUPCEANReader(hints));
                readers.Add(new Code39Reader());
                readers.Add(new Code128Reader());
                readers.Add(new ITFReader());
            }
        }
Exemplo n.º 18
0
    public void UpdateEnvironments()
    {
        //Timer is reset when starting play mode and when coming back to editor mode
        if (UnityEngine.Time.realtimeSinceStartup < m_timeStamp)
        {
            m_timeStamp = UnityEngine.Time.realtimeSinceStartup;

            //The PortalManager object doesn't get destroyed but all game objects in our lists become null
            //So we populate
            Populate();
            return;
        }

        //The update is done once every second
        if (UnityEngine.Time.realtimeSinceStartup - m_timeStamp < 1.0f)
        {
            return;
        }

        m_timeStamp = UnityEngine.Time.realtimeSinceStartup;

        var portals = UnityEditor.Selection.GetFiltered(typeof(AkEnvironmentPortal), UnityEditor.SelectionMode.Unfiltered);

        if (portals != null)
        {
            for (var i = 0; i < portals.Length; i++)
            {
                if (!PortalList.Contains((AkEnvironmentPortal)portals[i]))
                {
                    PortalList.Add((AkEnvironmentPortal)portals[i]);
                }

                UpdatePortal((AkEnvironmentPortal)portals[i]);
            }
        }

        var envs = UnityEditor.Selection.GetFiltered(typeof(AkEnvironment), UnityEditor.SelectionMode.Unfiltered);

        if (envs != null)
        {
            for (var i = 0; i < envs.Length; i++)
            {
                if (!EnvironmentList.Contains((AkEnvironment)envs[i]))
                {
                    EnvironmentList.Add((AkEnvironment)envs[i]);
                }

                UpdateEnvironment((AkEnvironment)envs[i]);
            }
        }
    }
Exemplo n.º 19
0
 bool PartOfHex(string value)
 {
     if (value.Length == 7) { return false; }
     if (value.Length + la.val.Length > 7) { return false; }
     System.Collections.Generic.List<string> hexes = new System.Collections.Generic.List<string>(new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "a", "b", "c", "d", "e", "f" });
     foreach (char c in la.val)
     {
         if (!hexes.Contains(c.ToString()))
         {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 20
0
        /// <summary>
        /// Adds external event listener.
        /// </summary>
        /// <param name="observer">Event listener.</param>
        public void AddDebugListener(IEcsSystemsDebugListener observer)
        {
#if DEBUG
            if (observer == null)
            {
                throw new Exception("observer is null");
            }
            if (_debugListeners.Contains(observer))
            {
                throw new Exception("Listener already exists");
            }
#endif
            _debugListeners.Add(observer);
        }
Exemplo n.º 21
0
    public string CalculateDefines(string addDefines, string removeDefines)
    {
        var addArray = addDefines.Trim(';').Split(';');
        var removeArray = removeDefines.Trim(';').Split(';');

        var list = new System.Collections.Generic.List<string>();
        foreach (var a in addArray)
        {
            if (!list.Contains(a))
            {
                list.Add(a);
            }
        }
        foreach (var r in removeArray)
        {
            if (list.Contains(r))
            {
                list.Remove(r);
            }
        }

        return string.Join(";", list.ToArray());
    }
Exemplo n.º 22
0
        public void TraceFunctionAttached()
        {
            var list = new System.Collections.Generic.List <string>();
            Log log  = (x, y) =>
            {
                if (x == typeof(MockSpeller))
                {
                    list.Add(y);
                }
            };

            using (NHunspellWrapper wrap = new NHunspellWrapper(this.affixFile, this.dictFile, typeof(MockSpeller).AssemblyQualifiedName, log))
            {
                wrap.Spell("test");
                wrap.Add("test");
            }

            Assert.AreEqual(4, list.Count, string.Join(Environment.NewLine, list.ToArray()));
            Assert.IsTrue(list.Contains("Init"));
            Assert.IsTrue(list.Contains("Spell"));
            Assert.IsTrue(list.Contains("Add"));
            Assert.IsTrue(list.Contains("Free"));
        }
    protected virtual void Start()
    {
#if UNITY_EDITOR
        if (UnityEditor.BuildPipeline.isBuildingPlayer || AkUtilities.IsMigrating)
        {
            return;
        }
#endif

        if (triggerList.Contains(START_TRIGGER_ID))
        {
            HandleEvent(null);
        }
    }
Exemplo n.º 24
0
        RemoveDuplicates()
        {
            var newList = new System.Collections.Generic.List <string>();

            foreach (var item in this.list)
            {
                if (!newList.Contains(item))
                {
                    newList.Add(item);
                }
            }

            this.list = newList;
        }
Exemplo n.º 25
0
        private string getNextScenarioId()
        {
            System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
            string strProjDir     = frmMain.g_oFrmMain.getProjectDirectory();
            string strScenarioDir = strProjDir + "\\" + ScenarioType + "\\db";
            string strFile        = "scenario_" + ScenarioType + "_rule_definitions.mdb";

            System.Text.StringBuilder strFullPath = new System.Text.StringBuilder(strScenarioDir);
            strFullPath.Append("\\");
            strFullPath.Append(strFile);
            ado_data_access oAdo    = new ado_data_access();
            string          strConn = oAdo.getMDBConnString(strFullPath.ToString(), "admin", "");

            oAdo.OpenConnection(strConn);
            string strSQL = "SELECT scenario_id from " + Tables.Scenario.DefaultScenarioTableName;

            System.Collections.Generic.IList <string> lstExistingScenarios = new System.Collections.Generic.List <string>();

            oAdo.SqlQueryReader(oAdo.m_OleDbConnection, strSQL);
            if (oAdo.m_OleDbDataReader.HasRows)
            {
                // Load all of the existing scenarios into a list we can query
                while (oAdo.m_OleDbDataReader.Read())
                {
                    string strScenario = Convert.ToString(oAdo.m_OleDbDataReader["scenario_id"]).Trim();
                    if (!String.IsNullOrEmpty(strScenario))
                    {
                        lstExistingScenarios.Add(strScenario);
                    }
                }
            }
            oAdo.CloseConnection(oAdo.m_OleDbConnection);

            int    i = 1;
            string strTestName;

            // keep incrementing the scenario name until we find one that doesn't exist
            while (i < (lstExistingScenarios.Count + 1))
            {
                strTestName = "scenario" + Convert.ToString(i);
                if (!lstExistingScenarios.Contains(strTestName))
                {
                    break;
                }
                i++;
            }

            strTestName = "scenario" + Convert.ToString(i);
            return(strTestName);
        }
        private System.Collections.Generic.List <Object> readers; // added by .net follower (http://dotnetfollower.com)

        // public MultiFormatUPCEANReader(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public MultiFormatUPCEANReader(System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            // System.Collections.ArrayList possibleFormats = hints == null?null:(System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS]; // commented by .net follower (http://dotnetfollower.com)
            System.Collections.Generic.List <Object> possibleFormats = null;                                        // added by .net follower (http://dotnetfollower.com)
            if (hints != null && hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))                                // added by .net follower (http://dotnetfollower.com)
            {
                possibleFormats = (System.Collections.Generic.List <Object>)hints[DecodeHintType.POSSIBLE_FORMATS]; // added by .net follower (http://dotnetfollower.com)
            }
            // readers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); // commented by .net follower (http://dotnetfollower.com)
            readers = new System.Collections.Generic.List <Object>(10); // added by .net follower (http://dotnetfollower.com)
            if (possibleFormats != null)
            {
                if (possibleFormats.Contains(BarcodeFormat.EAN_13))
                {
                    readers.Add(new EAN13Reader());
                }
                else if (possibleFormats.Contains(BarcodeFormat.UPC_A))
                {
                    readers.Add(new UPCAReader());
                }
                if (possibleFormats.Contains(BarcodeFormat.EAN_8))
                {
                    readers.Add(new EAN8Reader());
                }
                if (possibleFormats.Contains(BarcodeFormat.UPC_E))
                {
                    readers.Add(new UPCEReader());
                }
            }
            if ((readers.Count == 0))
            {
                readers.Add(new EAN13Reader());
                // UPC-A is covered by EAN-13
                readers.Add(new EAN8Reader());
                readers.Add(new UPCEReader());
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Returns a collection of property view models for the given selected elements.
        /// </summary>
        /// <param name="models">Already gathered models.</param>
        /// <param name="modelElement">ModelElement.</param>
        /// <param name="handledStores">Stores that have already been processed.</param>
        /// <returns>Collection of property view models. Can be empty.</returns>
        public override bool AddPropertyEditorViewModels(System.Collections.Generic.List <DslEditorViewModelPropertyGrid::PropertyGridViewModel> models, DslModeling::ModelElement modelElement, System.Collections.Generic.List <DslEditorViewModelData::ViewModelStore> handledStores)
        {
            if (handledStores.Contains(this.Store))
            {
                return(false);
            }
            else
            {
                handledStores.Add(this.Store);
            }

            if (modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.FamilyTreePerson.DomainClassId)
            {
                models.Add(new PropertyGridFamilyTreePersonViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.FamilyTreePerson));
                return(true);
            }
            else if (modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.ParentOf.DomainClassId)
            {
                models.Add(new PropertyGridParentOfViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.ParentOf));
                return(true);
            }
            else if (modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.MarriedTo.DomainClassId)
            {
                models.Add(new PropertyGridMarriedToViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.MarriedTo));
                return(true);
            }
            else if (modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.Person.DomainClassId)
            {
                models.Add(new PropertyGridPersonViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.Person));
                return(true);
            }
            else if (modelElement.GetDomainClass().Id == global::Tum.FamilyTreeDSL.Pet.DomainClassId)
            {
                models.Add(new PropertyGridPetViewModel(this.Store, modelElement as global::Tum.FamilyTreeDSL.Pet));
                return(true);
            }
            else
            {
                foreach (DslEditorViewModelData::ViewModelStore eS in this.Store.ExternStores)
                {
                    if (eS.Factory.AddPropertyEditorViewModels(models, modelElement, handledStores))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        private void RefreshMounters_Menu()
        {
            // Design note: This process is designed to support mounters that have been linked
            // from other game objects.

            m_Mounters.PurgeDestroyed();

            var seen = new System.Collections.Generic.List <IAccessoryMounter>();

            // TODO: Remove this once the GUI properly prevents duplicates.
            for (int i = m_Mounters.Count - 1; i >= 0; i--)
            {
                if (seen.Contains(m_Mounters[i]))
                {
                    m_Mounters.Remove(m_Mounters[i]);
                }
                else
                {
                    seen.Add(m_Mounters[i]);
                }
            }

            var refreshItems = GetComponents <IAccessoryMounter>();

            if (refreshItems.Length == 0)
            {
                return;  // Leave existing alone.
            }
            var items = new System.Collections.Generic.List <IAccessoryMounter>(refreshItems.Length);

            for (int i = 0; i < m_Mounters.Count; i++)
            {
                if (m_Mounters[i] != null)
                {
                    items.Add(m_Mounters[i]);
                }
            }

            // Add new items to end.
            foreach (var refreshItem in refreshItems)
            {
                if (!items.Contains(refreshItem))
                {
                    items.Add(refreshItem);
                }
            }

            AccessoryMounterGroup.UnsafeReplaceItems(this, m_Mounters, items.ToArray());
        }
Exemplo n.º 29
0
 private void Frame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     try
     {
         Page page = Frame.Content as Page;
         page.BeginAnimation(Page.OpacityProperty, ani);
         if (!pages.Contains(Frame.Content))
         {
             pages.Add(Frame.Content);
         }
     }
     catch
     {
     }
 }
    private bool WasInitializedInPlayMode(AkInitializer akInitializer)
    {
        if (UnityEngine.Application.isPlaying)
        {
            if (AkInitializers.Contains(akInitializer))
            {
                return(false);
            }

            AkInitializers.Add(akInitializer);
            return(AkInitializers.Count == 1);
        }

        return(true);
    }
Exemplo n.º 31
0
 public MultiFormatUPCEANReader(System.Collections.Generic.Dictionary <Object, Object> hints)
 {
     //System.Collections.Generic.List <Object> possibleFormats null?null:(System.Collections.Generic.List <Object>) hints[DecodeHintType.POSSIBLE_FORMATS];
     System.Collections.Generic.List <Object> possibleFormats = null; //WP7 Port: above was throwing an exception when hints did not include Possible Format key
     if (hints != null && hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))
     {
         possibleFormats = (System.Collections.Generic.List <Object>)hints[DecodeHintType.POSSIBLE_FORMATS];
     }
     readers = new System.Collections.Generic.List <Object>(10);
     if (possibleFormats != null)
     {
         if (possibleFormats.Contains(BarcodeFormat.EAN_13))
         {
             readers.Add(new EAN13Reader());
         }
         else if (possibleFormats.Contains(BarcodeFormat.UPC_A))
         {
             readers.Add(new UPCAReader());
         }
         if (possibleFormats.Contains(BarcodeFormat.EAN_8))
         {
             readers.Add(new EAN8Reader());
         }
         if (possibleFormats.Contains(BarcodeFormat.UPC_E))
         {
             readers.Add(new UPCEReader());
         }
     }
     if ((readers.Count == 0))
     {
         readers.Add(new EAN13Reader());
         // UPC-A is covered by EAN-13
         readers.Add(new EAN8Reader());
         readers.Add(new UPCEReader());
     }
 }
Exemplo n.º 32
0
    public void MergeBanklogs(Banklog[] b)
    {
        int i;

        System.Collections.Generic.List<Banklog> t = new System.Collections.Generic.List<Banklog>(this.banklog);
        if (!System.Object.ReferenceEquals(this, b))
        {
            for (i = 0; i < b.Length; i++)
            {
                if (!t.Contains(b[i]))
                    t.Add(b[i]);
            }
        }

        this.banklog = t.ToArray();
    }
Exemplo n.º 33
0
        /// <summary>
        /// Registers imported libraries main ressource dictionaries.
        /// </summary>
        /// <param name="handledLibraries">Already handled libraries.</param>
        public static void RegisterImportedLibrariesRessources(System.Collections.Generic.List <string> handledLibraries)
        {
            if (handledLibraries.Contains("FamilyTreeDSL"))
            {
                return;
            }
            else
            {
                handledLibraries.Add("FamilyTreeDSL");
            }

            System.Windows.Application.Current.Resources.MergedDictionaries.Add(new System.Windows.ResourceDictionary()
            {
                Source = new System.Uri("pack://application:,,,/" + System.Reflection.Assembly.GetAssembly(typeof(FamilyTreeDSLMainViewModelBase)).GetName().Name + ";component/Resources.xaml")
            });
        }
Exemplo n.º 34
0
        public double NextDouble()
        {
            InitializeGeneratedDoubles();
            double num;

            do
            {
                if (generatedDoubles.Count == int.MaxValue)
                {
                    NoPossibleNumber?.Invoke(this, System.EventArgs.Empty); return(-1);
                }
                num = random.NextDouble();
            } while (generatedDoubles.Contains(num));
            generatedDoubles.Add(num);
            return(num);
        }
Exemplo n.º 35
0
 public int solution0(int[] A)
 {
     var l = new System.Collections.Generic.List<int>();
     for (int i = 0; i < A.Length; i++)
     {
         if (l.Contains(A[i]))
         {
             l.Remove(A[i]);
         }
         else
         {
             l.Add(A[i]);
         }
     }
     return l.FirstOrDefault();
 }
Exemplo n.º 36
0
        public void Can_Query_With_Content_Type_Aliases_List()
        {
            // Arrange - Contains is List.Contains instance method
            var aliases = new System.Collections.Generic.List <string> {
                "Test1", "Test2"
            };
            Expression <Func <IMedia, bool> > predicate = content => aliases.Contains(content.ContentType.Alias);
            var modelToSqlExpressionHelper = new ModelToSqlExpressionVisitor <IContent>(SqlContext.SqlSyntax, Mappers);
            var result = modelToSqlExpressionHelper.Visit(predicate);

            Debug.Print("Model to Sql ExpressionHelper: \n" + result);

            Assert.AreEqual("[cmsContentType].[alias] IN (@1,@2)", result);
            Assert.AreEqual("Test1", modelToSqlExpressionHelper.GetSqlParameters()[1]);
            Assert.AreEqual("Test2", modelToSqlExpressionHelper.GetSqlParameters()[2]);
        }
Exemplo n.º 37
0
        /// <summary>
        ///     Uniquely adds listeners to the list
        /// </summary>
        /// <param name="listener"></param>
        /// <returns></returns>
        public bool Add(AkSpatialAudioListener listener)
        {
            if (listener == null)
            {
                return(false);
            }

            if (listenerList.Contains(listener))
            {
                return(false);
            }

            listenerList.Add(listener);
            Refresh();
            return(true);
        }
Exemplo n.º 38
0
    public void addCallToNPCList(string buttonDisplayText, string conversationName, string playerName)
    {
        if (PhotonNetwork.playerName == playerName) {

                        // add the conversationName to the list
                        System.Collections.Generic.List<string> conversationList = new System.Collections.Generic.List<string> (dialogueNames);

                        if (!conversationList.Contains (conversationName))
                                conversationList.Add (conversationName);

                        dialogueNames = conversationList.ToArray ();

                        // add the display text to the textlist
                        System.Collections.Generic.List<string> textList = new System.Collections.Generic.List<string> (dialogueDisplayText);

                        if (!textList.Contains (buttonDisplayText))
                                textList.Add (buttonDisplayText);

                        dialogueDisplayText = textList.ToArray ();
                }
    }
Exemplo n.º 39
0
    public void addCustomerInfo(string newName, Texture newTexture)
    {
        //if(PhotonNetwork.playerName == targetPlayer)
        //	{
            // add the conversationName to the list
            System.Collections.Generic.List<string> nameList = new System.Collections.Generic.List<string>(customerNames);

            if(!nameList.Contains(newName))
                nameList.Add(newName);

            customerNames = nameList.ToArray();

            // add the display text to the textlist
            System.Collections.Generic.List<Texture> textureList = new System.Collections.Generic.List<Texture>(customerImages);

            if(!textureList.Contains(newTexture))
                textureList.Add(newTexture);

            customerImages = textureList.ToArray();
        //	}
    }
Exemplo n.º 40
0
    public void addDocument(GameObject toBeAdd)
    {
        System.Collections.Generic.List<GameObject> list = new System.Collections.Generic.List<GameObject>(documents);

        if(!list.Contains(toBeAdd))
        list.Add(toBeAdd);

        documents = list.ToArray();

        //		foreach(GameObject a in documents)
        //			print (a.name);

        // re allocate the position of documents
        if(documents.Length != 0)
            for(int i =0; i < documents.Length; i ++)
        {

            documents[i].transform.parent = fileModeObj.transform;

            documents[i].transform.localPosition = new Vector3(-0.2275543f +i*0.35f,0,-0.03671265f);
        }
    }
Exemplo n.º 41
0
        private static Texture2D convertCharArrayToTex(System.Collections.Generic.List<KSF_CharArray> chArray, int length, Color color)
        {
            Texture2D tex = new Texture2D(length - 4, 7);
            int offSet = 0;
            System.Collections.Generic.List<Vector2> pxMap = new System.Collections.Generic.List<Vector2>();
            pxMap.Clear();

            foreach (KSF_CharArray ka in chArray)
            {
                foreach (Vector2 px in ka.pixelList)
                {
                    pxMap.Add(new Vector2(px.x + offSet, px.y));
                }
                offSet += ka.charWidth;
            }

            for (int y = 0; y < tex.height; y++)
            {
                for (int x = 0; x < tex.width; x++)
                {
                    if (pxMap.Contains(new Vector2(x, y)))
                    {
                        tex.SetPixel(x, y, Color.black);
                    }
                    else
                    {
                        tex.SetPixel(x, y, color);
                    }
                }
            }
            return tex;
        }
Exemplo n.º 42
0
		/// <summary>
		/// Reads in the embedded files from an assembly an processes them into
		/// the virtual filesystem.
		/// </summary>
		/// <param name="assemblyName">The name of the <see cref="System.Reflection.Assembly"/> to load and process.</param>
		/// <exception cref="System.ArgumentNullException">
		/// Thrown if <paramref name="assemblyName" /> is <see langword="null" />.
		/// </exception>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// Thrown if <paramref name="assemblyName" /> is <see cref="System.String.Empty" />.
		/// </exception>
		/// <exception cref="System.IO.FileNotFoundException">
		/// Thrown if the <see cref="System.Reflection.Assembly"/> indicated by
		/// <paramref name="assemblyName" /> is not found.
		/// </exception>
		/// <remarks>
		/// <para>
        /// The <paramref name="assemblyName" /> will be passed to <see cref="System.Reflection.Assembly.Load(string)"/>
		/// so the associated assembly can be processed.  If the assembly is not
		/// found, a <see cref="System.IO.FileNotFoundException"/> is thrown.
		/// </para>
		/// <para>
		/// Once the assembly is retrieved, it is queried for <see cref="TVA.Web.Hosting.EmbeddedResourceFileAttribute"/>
		/// instances.  For each one found, the associated resources are processed
		/// into virtual files that will be stored in
		/// <see cref="TVA.Web.Hosting.EmbeddedResourcePathProvider.Files"/>
		/// for later use.
		/// </para>
		/// </remarks>
		/// <seealso cref="TVA.Web.Hosting.EmbeddedResourcePathProvider" />
		/// <seealso cref="TVA.Web.Hosting.EmbeddedResourcePathProvider.Initialize" />
		protected virtual void ProcessEmbeddedFiles(string assemblyName)
		{
            if (string.IsNullOrEmpty(assemblyName))
                throw new ArgumentNullException("assemblyName");

			Assembly assembly = Assembly.LoadFrom(FilePath.GetAbsolutePath(assemblyName));

			// Get the embedded files specified in the assembly; bail early if there aren't any.
			EmbeddedResourceFileAttribute[] attribs = (EmbeddedResourceFileAttribute[])assembly.GetCustomAttributes(typeof(EmbeddedResourceFileAttribute), true);
			if (attribs.Length == 0)
			{
				return;
			}

			// Get the complete set of embedded resource names in the assembly; bail early if there aren't any.
			System.Collections.Generic.List<String> assemblyResourceNames = new System.Collections.Generic.List<string>(assembly.GetManifestResourceNames());
			if (assemblyResourceNames.Count == 0)
			{
				return;
			}

			foreach (EmbeddedResourceFileAttribute attrib in attribs)
			{
				// Ensure the resource specified actually exists in the assembly
				if (!assemblyResourceNames.Contains(attrib.ResourcePath))
				{
					continue;
				}

				// Map the path into the web application
				string mappedPath;
				try
				{
					mappedPath = System.Web.VirtualPathUtility.ToAbsolute(MapResourceToWebApplication(attrib.ResourceNamespace, attrib.ResourcePath));
				}
				catch (ArgumentNullException)
				{
					continue;
				}
				catch (ArgumentOutOfRangeException)
				{
					continue;
				}

				// Create the file and ensure it's unique
				EmbeddedResourceVirtualFile file = new EmbeddedResourceVirtualFile(mappedPath, assembly, attrib.ResourcePath);
				if (this.Files.Contains(file.VirtualPath))
				{
					continue;
				}

				// The file is unique; add it to the filesystem
				this.Files.Add(file);
			}
		}
Exemplo n.º 43
0
        /// <summary>
        /// This will return an image of the specified size with the thrust graph for this nozzle
        /// Totally jacked the image code from the wiki http://wiki.kerbalspaceprogram.com/wiki/Module_code_examples, with some modifications
        /// 
        /// 
        /// </summary>
        /// <param name="imgH">Hight of the desired output, in pixels</param>
        /// <param name="imgW">Width of the desired output, in pixels</param>
        /// <param name="burnTime">Chart for burn time in seconds</param>
        /// <returns></returns>
        public static Texture2D stackThrustPredictPic(int imgH, int imgW, int burnTime, FloatCurve atmoCurve, AdvSRBNozzle nozzle)
        {
            //First we set up the analyzer
            //Step 1: Figure out fuel sources
            nozzle.FuelStackSearcher(nozzle.FuelSourcesList);
            //Step 2: Set up mass variables
            float stackTotalMass = 0f;
            stackTotalMass = nozzle.fullStackFuelMass;

            float remStackFuel = nozzle.fullStackFuelMass;

            //stackTotalMass = CalcStackWetMass(FuelSourcesList, stackTotalMass);

            //float[] segmentFuelArray = new float[nozzle.FuelSourcesList.Count];

            int i = 0;
            //foreach (Part p in nozzle.FuelSourcesList)
            //{
            //    segmentFuelArray[i] = p.GetResourceMass();
            //    i++;
            //}

            //float stackCurrentMass = stackTotalMass;
            //Now we set up the image maker
            Texture2D image = new Texture2D(imgW, imgH);
            int graphXmin = 19;
            int graphXmax = imgW - 20;
            int graphYmin = 19;
            //Step 3: Set Up color variables
            Color brightG = Color.black;
            brightG.r = .3372549f;
            brightG.g = 1;
            Color mediumG = Color.black;
            mediumG.r = 0.16862745f;
            mediumG.g = .5f;
            Color lowG = Color.black;
            lowG.r = 0.042156863f;
            lowG.g = .125f;

            Color MassColor = Color.blue;
            Color ThrustColor = Color.cyan;
            Color ExtraThrustColor = Color.yellow;

            //Step 4: Define text arrays
            KSF_CharArrayUtils.populateCharArrays();
            //Step 5a: Define time markings (every 10 seconds gets a verticle line)
            System.Collections.Generic.List<int> timeLines = new System.Collections.Generic.List<int>();
            double xScale = (imgW - 40) / (double)burnTime;
            //print("xScale: " + xScale);
            calcTimeLines((float)burnTime, 10, timeLines, (float)xScale, 20);
            //Step 5b: Define vertical line markings (9 total to give 10 sections)
            System.Collections.Generic.List<int> horzLines = new System.Collections.Generic.List<int>();
            calcHorizLines(imgH - graphYmin, horzLines, 9, 20);
            //Step 6: Clear the background

            //Set all the pixels to black. If you don't do this the image contains random junk.
            for (int y = 0; y < image.height; y++)
            {
                for (int x = 0; x < image.width; x++)
                {
                    image.SetPixel(x, y, Color.black);
                }
            }

            //Step 7a: Draw Time Lines
            for (int y = 0; y < image.height; y++)
            {
                for (int x = 0; x < image.width; x++)
                {
                    if (timeLines.Contains(x) && y > graphYmin)
                        image.SetPixel(x, y, lowG);
                }
            }

            //Step 7b: Draw Vert Lines
            for (int y = 0; y < image.height; y++)
            {
                for (int x = 0; x < image.width; x++)
                {
                    if (horzLines.Contains(y) && x < graphXmax && x > graphXmin)
                        image.SetPixel(x, y, lowG);
                }
            }

            //Step 7c: Draw Bounding Lines
            for (int y = 0; y < image.height; y++)
            {
                for (int x = 0; x < image.width; x++)
                {
                    if ((x == graphXmin | x == graphXmax) && (y > graphYmin | y == graphYmin))
                        image.SetPixel(x, y, mediumG);

                    if (y == graphYmin && graphXmax > x && graphXmin < x)
                        image.SetPixel(x, y, mediumG);
                }
            }

            //Step 8a: Populate graphArray
            double simStep = .2;
            i = 0;
            //double peakThrustTime = 0;
            double peakThrustAmt = 0;

            //set up the array for the graphs
            int graphArraySize = Convert.ToInt16(Convert.ToDouble(burnTime) / simStep);
            double[,] graphArray = new double[graphArraySize, 4];

            //one time setups
            //graphArray[i, 0] = stackMassFlow(FuelSourcesList, (float)(i * simStep), segmentFuelArray, simStep);

            graphArray[i, 0] = nozzle.MassFlow.Evaluate((float)(i * simStep)) * nozzle.fullStackFuelMass;
            graphArray[i, 1] = stackTotalMass;
            graphArray[i, 2] = 9.80665 * atmoCurve.Evaluate(1) * graphArray[i, 0];
            graphArray[i, 3] = graphArray[i, 2] - (graphArray[i, 1] * 9.80665);

            remStackFuel -= (float)graphArray[i, 0];

            //fForce = 9.81f * fCurrentIsp * fFuelFlowMass / TimeWarp.fixedDeltaTime;
            do
            {
                i++;
                //
                //graphArray[i, 0] = stackMassFlow(FuelSourcesList, (float)(i * simStep), segmentFuelArray, simStep);

                graphArray[i, 0] = nozzle.MassFlow.Evaluate((float)(i * simStep)) * nozzle.fullStackFuelMass;

                graphArray[i, 1] = graphArray[i - 1, 1] - (graphArray[i - 1, 0] * simStep);

                if (remStackFuel > 0)
                    graphArray[i, 2] = 9.80665 * atmoCurve.Evaluate(1) * graphArray[i, 0];
                else
                    graphArray[i, 2] = 0;

                if (graphArray[i, 2] > 0)
                    graphArray[i, 3] = graphArray[i, 2] - (graphArray[i, 1] * 9.80665);
                else
                    graphArray[i, 3] = 0;

                if (graphArray[i, 2] > peakThrustAmt)
                {
                    peakThrustAmt = graphArray[i, 2];
                    //peakThrustTime = i;
                }

                remStackFuel -= (float)graphArray[i, 0] * (float)simStep;

                //print("generating params i=" + i + " peak at " + Convert.ToInt16(Convert.ToDouble(simDuration) / simStep));
            } while (i + 1 < graphArraySize);

            //Step 8b: Make scales for the y axis
            double yScaleMass = 1;
            double yScaleThrust = 1;
            int usableY;
            usableY = imgH - 20;

            yScaleMass = usableY / (Mathf.CeilToInt((float)(graphArray[0, 1] / 10)) * 10);
            float inter;
            inter = (float)peakThrustAmt / 100;
            //print("1: " + inter);
            inter = Mathf.CeilToInt(inter);
            //print("22: " + inter);
            inter = inter * 100;
            //print("3: " + inter);
            inter = usableY / inter;
            //print("4: " + inter);

            yScaleThrust = inter;

            //print(yScaleThrust + ":" + peakThrustAmt + ":" + usableY);

            Debug.Log("graphed scales");

            //Step 8c: Graph the mass
            int lineWidth = 3;
            for (int x = graphXmin; x < graphXmax; x++)
            {
                int fx = fGraph(xScale, x - 20, yScaleMass, graphArray, simStep, graphArraySize, 1, 20);

                for (int y = fx; y < fx + lineWidth; y++)
                {
                    image.SetPixel(x, y, MassColor);
                }
            }

            //Step 8d: Graph the thrust
            lineWidth = 3;
            for (int x = graphXmin; x < graphXmax; x++)
            {
                int fx = fGraph(xScale, x - 20, yScaleThrust, graphArray, simStep, graphArraySize, 2, 20);
                for (int y = fx; y < fx + lineWidth; y++)
                {
                    image.SetPixel(x, y, ThrustColor);
                }
            }

            //Step 8e: Graph the thrust extra
            lineWidth = 2;
            for (int x = graphXmin; x < graphXmax; x++)
            {
                int fx = fGraph(xScale, x - 20, yScaleThrust, graphArray, simStep, graphArraySize, 3, 20);
                for (int y = fx; y < fx + lineWidth; y++)
                {
                    image.SetPixel(x, y, ExtraThrustColor);
                }
            }

            //Step 9: Set up boxes for time

            //int i = 0;
            string s;
            i = 0;
            int length = 0;
            int pos = 0;
            int startpos = 0;
            Texture2D tex;

            do
            {
                s = "";

                pos = timeLines[i];
                i++;
                s = i * 10 + " s";

                //print("composite string: " + s);

                length = calcStringPixLength(KSF_CharArrayUtils.convertStringToCharArray(s));
                //print("length: " + length);

                startpos = Mathf.FloorToInt((float)pos - 0.5f * (float)length);

                Color[] region = image.GetPixels(startpos, 23, length, 11);

                for (int c = 0; c < region.Length; c++)
                {
                    region[c] = brightG;
                }

                image.SetPixels(startpos, 23, length, 11, region);

                tex = convertCharArrayToTex(KSF_CharArrayUtils.convertStringToCharArray(s), length, brightG);

                Color[] region2 = tex.GetPixels();

                image.SetPixels(startpos + 2, 25, length - 4, 7, region2);

                length = 0;

            } while (i < timeLines.Count);

            //set up boxes for horizontal lines, mass first
            startpos = 0;
            length = 0;
            pos = 0;
            i = 0;
            do
            {
                s = "";
                pos = horzLines[i];
                i++;
                s = ((Mathf.CeilToInt((float)(graphArray[0, 1] / 10)) * i)).ToString() + " t";
                length = calcStringPixLength(KSF_CharArrayUtils.convertStringToCharArray(s));
                startpos = Mathf.FloorToInt((float)pos - 5f);
                Color[] region = image.GetPixels(23, startpos, length, 11);
                for (int c = 0; c < region.Length; c++)
                {
                    region[c] = brightG;
                }
                image.SetPixels(23, startpos, length, 11, region);
                tex = convertCharArrayToTex(KSF_CharArrayUtils.convertStringToCharArray(s), length, brightG);
                Color[] region2 = tex.GetPixels();
                image.SetPixels(25, startpos + 2, length - 4, 7, region2);
                length = 0;
            } while (i < horzLines.Count);

            //set up boxes for horizontal lines,  thrust
            startpos = 0;
            length = 0;
            pos = 0;
            i = 0;
            do
            {
                s = "";
                pos = horzLines[i];
                i++;
                s = ((Mathf.CeilToInt((float)(peakThrustAmt / 100)) * (i * 10))).ToString() + " k";
                length = calcStringPixLength(KSF_CharArrayUtils.convertStringToCharArray(s));
                startpos = Mathf.FloorToInt((float)pos - 5f);
                Color[] region = image.GetPixels(imgW - 60, startpos, length, 11);
                for (int c = 0; c < region.Length; c++)
                {
                    region[c] = brightG;
                }
                image.SetPixels(imgW - 60, startpos, length, 11, region);
                tex = convertCharArrayToTex(KSF_CharArrayUtils.convertStringToCharArray(s), length, brightG);
                Color[] region2 = tex.GetPixels();
                image.SetPixels(imgW - 58, startpos + 2, length - 4, 7, region2);
                length = 0;
            } while (i < horzLines.Count);

            image.Apply();
            return image;
        }
        /// <summary>
        /// 取回YYetSearch的数据模型
        /// </summary>
        /// <param name="celllistr"></param>
        /// <returns></returns>
        private static LiuXingData GetYYetSearchItem(string celllistr)
        {
            #region 取回YYetSearch的数据模型
            var cellitem = new LiuXingData();
            // 影片大类
            string tempmpe = StringRegexHelper.GetSingle(celllistr, "【", "】");
            if (!string.IsNullOrEmpty(tempmpe))
            {
                cellitem.Mpe = tempmpe;
            }
            // 电影名称
            string tempname = StringRegexHelper.GetSingle(celllistr, "<strong>", "<label id=\"play");
            if (!string.IsNullOrEmpty(tempname))
            {
                cellitem.Name = tempname
                    .Replace("【", "")
                    .Replace("】", "")
                    .Replace("《", "")
                    .Replace("》", "").Replace(cellitem.Mpe, "").Trim();
            }
            // 电影网址
            const string tempurl = "";
            if (!string.IsNullOrEmpty(tempurl))
            {
                cellitem.Url = tempurl;
            }
            // 电影封面
            string tempimg = StringRegexHelper.GetSingle(celllistr, "<img src=\"", "\" /></a>");
            if (!string.IsNullOrEmpty(tempimg))
            {
                cellitem.Img = tempimg.Replace("m_", "b_");
            }
            // 电影质量
            const string tempHDs = @"HR-HDTV";
            if (!string.IsNullOrEmpty(tempHDs))
            {
                cellitem.HDs = tempHDs;
            }
            // 电影评分
            const string tempCos = "6.5";
            if (!string.IsNullOrEmpty(tempCos))
            {
                cellitem.Cos = tempCos;
            }
            // 电影地区
            string tempLoc = StringRegexHelper.GetSingle(celllistr, "<span>地区:</span><strong", "</strong>");
            if (!string.IsNullOrEmpty(tempLoc))
            {
                cellitem.Loc = UrlCodeHelper.GetVideoLocation(tempLoc.Replace(">", ""));
            }
            // 电影年代
            string tempTim = StringRegexHelper.GetSingle(celllistr, "<span>年代:</span><strong>",
                                                    "</strong>             <font class=\"f5\">类");
            if (!string.IsNullOrEmpty(tempTim))
            {
                cellitem.Tim = tempTim;
            }
            // 电影演员
            const string tempCar = "";
            if (!string.IsNullOrEmpty(tempCar))
            {
                cellitem.Car = tempCar;
            }
            // 电影类型
            const string tempTyp = "";
            if (!string.IsNullOrEmpty(tempTyp))
            {
                cellitem.Typ = tempTyp;
            }
            // 电影更新
            const string tempUpt = "";
            if (!string.IsNullOrEmpty(tempUpt))
            {
                cellitem.Upt = tempUpt;
            }

            var tagurls = new System.Collections.Generic.List<string>();
            string urllists = celllistr;//LiuXingRegex.GetSingle(,"<ul class=\"resod_list\"","</ul>");
            if (string.IsNullOrEmpty(urllists)) return null;
            if (urllists.Contains("type=\"ed2k\""))
            {
                var orignli = StringRegexHelper.GetValue(urllists, "type=\"ed2k\" href=\"", "\"");
                if (orignli == null || orignli.Count <= 0) return null;
                foreach (string v in orignli)
                {
                    if (!tagurls.Contains(v))
                    {
                        tagurls.Add(v);
                    }
                }
            }
            if (urllists.Contains("thunder=\""))
            {
                var orignli = StringRegexHelper.GetValue(urllists, "thunder=\"", "\"");
                if (orignli == null || orignli.Count <= 0) return null;
                foreach (string v in orignli)
                {
                    if (!tagurls.Contains(v))
                    {
                        tagurls.Add(v);
                    }
                }
            }
            var yyets = new System.Collections.Generic.List<string>();
            foreach (string tagurl in tagurls)
            {
                if (!string.IsNullOrEmpty(tagurl))
                {
                    if (tagurl.StartsWith("ed2k") || tagurl.StartsWith("ED2K") || tagurl.StartsWith("http") ||
                        tagurl.StartsWith("magnet") || tagurl.StartsWith("thunder") || tagurl.StartsWith("flashget") ||
                        tagurl.StartsWith("flashget"))
                    {
                        yyets.Add(System.Web.HttpUtility.HtmlDecode(tagurl));
                    }
                }
            }
            cellitem.Drl = yyets;
            return cellitem;
            #endregion
        }
Exemplo n.º 45
0
        public override double GetFinishPercent(Mission mission, int userID, int cycleTimes, DateTime beginDate, StringTable values, out bool isFail)
        {
            isFail = false;

            System.Collections.Generic.List<int> forumIDs = new System.Collections.Generic.List<int>();
            if (!string.IsNullOrEmpty(values[forumIDsName]))
            {
                int[] tempforumIDs = StringUtil.Split<int>(values[forumIDsName]);

                StringBuilder forumNames = new StringBuilder();
                foreach (int forumID in tempforumIDs)
                {
                    Forum forum = ForumBO.Instance.GetForum(forumID);
                    if (forum != null)
                    {
                        forumIDs.Add(forumID);
                    }
                }
            }

            DateTime endDate = DateTime.MaxValue;

            if (false == string.IsNullOrEmpty(values[timeOutName]))
            {
                int hour = int.Parse(values[timeOutName]);
                if (hour > 0)
                {
                    endDate = beginDate.AddHours(hour);
                }
                else if (cycleTimes == 0)
                {
                    beginDate = DateTime.MinValue;
                }
            }
            else if (cycleTimes == 0)
            {
                beginDate = DateTime.MinValue;
            }
            else if (cycleTimes > 0)
            {
                endDate = beginDate.AddSeconds(cycleTimes);
            }

            int postCount = int.Parse(values[topicCountName]);

            if (values[actionName] == "0")//发主题
            {
                int total;

                ThreadCollectionV5 threads = PostBOV5.Instance.GetMyThreads(userID, true, 1, int.MaxValue, out total);

                int finishCount = 0;
                foreach (BasicThread thread in threads)
                {
                    if (thread.ThreadStatus != ThreadStatus.Recycled && thread.ThreadStatus != ThreadStatus.UnApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(thread.ForumID))
                        {
                            if (thread.CreateDate >= beginDate && thread.CreateDate <= endDate)
                                finishCount++;
                        }
                    }

                    if (finishCount >= postCount)
                    {
                        return 1;
                    }
                }

                if (endDate <= DateTimeUtil.Now)
                    isFail = true;

                return (double)finishCount / (double)postCount;

            }
            else if (values[actionName] == "1")//发回复
            {

                PostCollectionV5 posts = PostBOV5.Instance.GetUserPosts(userID, beginDate, endDate);

                int targetUserID = 0;
                int.TryParse(values[replyUserName], out targetUserID);

                ThreadCollectionV5 threads = null;

                if (targetUserID > 0)
                {
                    System.Collections.Generic.List<int> threadIDs = new System.Collections.Generic.List<int>();
                    foreach (PostV5 post in posts)
                    {
                        if (post.IsApproved && !threadIDs.Contains(post.ThreadID))
                        {
                            threadIDs.Add(post.ThreadID);
                        }
                    }
                    if (threadIDs.Count > 0)
                        threads = PostBOV5.Instance.GetThreads(threadIDs);
                }

                int targetThreadID = 0;
                int.TryParse(values[replyTopicName], out targetThreadID);

                int finishCount = 0;

                foreach (PostV5 post in posts)
                {
                    if (post.IsApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(post.ForumID))
                        {
                            if (targetThreadID == 0 || post.ThreadID == targetThreadID)//回复指定主题
                            {
                                if (targetUserID == 0)
                                {
                                    finishCount++;
                                }
                                else
                                {
                                    foreach (BasicThread thread in threads)
                                    {
                                        if (thread.ThreadID == post.ThreadID && thread.PostUserID == targetUserID)//回复指定用户
                                        {
                                            finishCount++;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (finishCount >= postCount)
                        return 1;
                }


                if (endDate <= DateTimeUtil.Now)
                    isFail = true;

                return (double)finishCount / (double)postCount;

            }
            else //发主题或者回复
            {
                int total;

                ThreadCollectionV5 threads = PostBOV5.Instance.GetMyThreads(userID, true, 1, int.MaxValue, out total);

                int finishCount = 0;
                foreach (BasicThread thread in threads)
                {
                    if (thread.ThreadStatus != ThreadStatus.Recycled && thread.ThreadStatus != ThreadStatus.UnApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(thread.ForumID))
                        {
                            if (thread.CreateDate >= beginDate && thread.CreateDate <= endDate)
                                finishCount++;
                        }
                    }

                    if (finishCount >= postCount)
                        return 1;
                }

                PostCollectionV5 posts = PostBOV5.Instance.GetUserPosts(userID, beginDate, endDate);

                foreach (PostV5 post in posts)
                {
                    if (post.IsApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(post.ForumID))
                        {
                            finishCount++;
                        }
                    }

                    if (finishCount >= postCount)
                        return 1;
                }


                if (endDate <= DateTimeUtil.Now)
                    isFail = true;

                return (double)finishCount / (double)postCount;

            }
        }
Exemplo n.º 46
0
        private int MathParserLogic(System.Collections.Generic.List<string> _tokens)
        {
            // CALCULATING THE EXPRESSIONS INSIDE THE BRACKETS
            // IF NEEDED, EXECUTE A FUNCTION

            while (_tokens.IndexOf("(") != -1)
            {
                // getting data between "(", ")"
                int open = _tokens.LastIndexOf("(");
                int close = _tokens.IndexOf(")", open); // in case open is -1, i.e. no "(" // , open == 0 ? 0 : open - 1
                if (open >= close)
                {
                    // if there is no closing bracket, throw a new exception
                    throw new ArithmeticException("No closing bracket/parenthesis! tkn: " + open);
                }
                var roughExpr = new System.Collections.Generic.List<string>();
                for (int i = open + 1; i < close; i++)
                {
                    roughExpr.Add(_tokens[i]);
                }

                int result; // the temporary result is stored here

                string functioName = _tokens[open == 0 ? 0 : open - 1];
                var _args = new int[0];
                if (this.LocalFunctions.Keys.Contains(functioName))
                {
                    if (roughExpr.Contains(","))
                    {
                        // converting all arguments into a int array
                        for (int i = 0; i < roughExpr.Count; i++)
                        {
                            int firstCommaOrEndOfExpression = roughExpr.IndexOf(",", i) != -1
                                ? roughExpr.IndexOf(",", i)
                                : roughExpr.Count;

                            var defaultExpr = new System.Collections.Generic.List<string>();
                            while (i < firstCommaOrEndOfExpression)
                            {
                                defaultExpr.Add(roughExpr[i]);
                                i++;
                            }

                            // changing the size of the array of arguments
                            Array.Resize(ref _args, _args.Length + 1);
                            if (defaultExpr.Count == 0)
                            {
                                _args[_args.Length - 1] = 0;
                            }
                            else
                            {
                                _args[_args.Length - 1] = this.BasicArithmeticalExpression(defaultExpr);
                            }
                        }

                        // finnaly, passing the arguments to the given function
                        result = int.Parse(
                            this.LocalFunctions[functioName](_args).ToString(this.CULTURE_INFO),
                            this.CULTURE_INFO);
                    }

                    else
                    {
                        // but if we only have one argument, then we pass it directly to the function
                        result =
                            int.Parse(
                                this.LocalFunctions[functioName](new[] { this.BasicArithmeticalExpression(roughExpr) })
                                    .ToString(this.CULTURE_INFO),
                                this.CULTURE_INFO);
                    }
                }
                else
                {
                    // if no function is need to execute following expression, pass it
                    // to the "BasicArithmeticalExpression" method.
                    result = this.BasicArithmeticalExpression(roughExpr);
                }

                // when all the calculations have been done
                // we replace the "opening bracket with the result"
                // and removing the rest.
                _tokens[open] = result.ToString(this.CULTURE_INFO);
                _tokens.RemoveRange(open + 1, close - open);
                if (this.LocalFunctions.Keys.Contains(functioName))
                {
                    // if we also executed a function, removing
                    // the function name as well.
                    _tokens.RemoveAt(open - 1);
                }
            }

            // at this point, we should have replaced all brackets
            // with the appropriate values, so we can simply
            // calculate the expression. it's not so complex
            // any more!
            return this.BasicArithmeticalExpression(_tokens);
        }
Exemplo n.º 47
0
        protected override void OnRowCommand(GridViewCommandEventArgs e)
        {
            base.OnRowCommand(e);
            if (e.CommandName == "ExportToExcel")
            {
                string[] ss = UnExportedColumnNames.Split(',');
                System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

                foreach (string s in ss)
                {
                    if (s != ",")
                    {
                        list.Add(s);
                    }
                }
                ShowToolBar = false;
                this.AllowSorting = false;
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write("<meta   http-equiv=Content-Type   content=text/html;charset=GB2312>");
                string fileName = HttpUtility.UrlEncode(ExcelFileName + ".xls", Encoding.GetEncoding("GB2312"));
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);

                HttpContext.Current.Response.Charset = "GB2312";
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//�����������������

                ////HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7;
                HttpContext.Current.Response.ContentType = "application/vnd.xls";
                System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);

                System.IO.StringWriter stringWrite = new System.IO.StringWriter(myCItrad);

                System.Web.UI.HtmlTextWriter htmlWrite =
                new HtmlTextWriter(stringWrite);
                bool showCheckAll = ShowCheckAll;
                this.ShowCheckAll = false;
                this.AllowPaging = false;
                OnBind();
                DisableControls(this);
                foreach (DataControlField c in this.Columns)
                {
                    if (list.Contains(c.HeaderText) && !string.IsNullOrEmpty(c.HeaderText))
                    {
                        c.Visible = false;
                    }
                }
                this.RenderControl(htmlWrite);
                string content = System.Text.RegularExpressions.Regex.Replace(stringWrite.ToString(), "(<a[^>]+>)|(</a>)", "");
                HttpContext.Current.Response.Write(content);
                HttpContext.Current.Response.End();

                this.AllowPaging = true;
                this.AllowSorting = true;
                ShowToolBar = true;
                this.ShowCheckAll = showCheckAll;
                OnBind();
            }
            else if (e.CommandName == "ExportToWord")
            {
                string[] ss = UnExportedColumnNames.Split(',');
                System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

                foreach (string s in ss)
                {
                    if (s != ",")
                    {
                        list.Add(s);
                    }
                }
                ShowToolBar = false;
                this.AllowSorting = false;
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write("<meta   http-equiv=Content-Type   content=text/html;charset=GB2312>");
                string fileName = HttpUtility.UrlEncode(ExcelFileName + ".doc", Encoding.GetEncoding("GB2312"));
                HttpContext.Current.Response.AddHeader("content-disposition",
                "attachment;filename=" + fileName);

                HttpContext.Current.Response.Charset = "GB2312";
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//�����������������

                ////HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7;
                HttpContext.Current.Response.ContentType = "application/ms-word";

                System.IO.StringWriter stringWrite = new System.IO.StringWriter();

                System.Web.UI.HtmlTextWriter htmlWrite =
                new HtmlTextWriter(stringWrite);

                bool showCheckAll = ShowCheckAll;
                this.ShowCheckAll = false;
                this.AllowPaging = false;
                OnBind();

                DisableControls(this);
                foreach (DataControlField c in this.Columns)
                {
                    if (list.Contains(c.HeaderText) && !string.IsNullOrEmpty(c.HeaderText))
                    {
                        c.Visible = false;
                    }
                }
                this.RenderControl(htmlWrite);
                string content = System.Text.RegularExpressions.Regex.Replace(stringWrite.ToString(), "(<a[^>]+>)|(</a>)", "");
                HttpContext.Current.Response.Write(content);
                HttpContext.Current.Response.End();
                this.AllowPaging = true;
                this.AllowSorting = true;
                ShowToolBar = true;
                ShowCheckAll = showCheckAll;
                OnBind();
            }
        }
        // Your BeginRequest event handler.
        private void Application_BeginRequest(object source, System.EventArgs e)
        {
            System.Web.HttpApplication application = (System.Web.HttpApplication)source;
            System.Web.HttpContext context = application.Context;

            System.Data.DataRow dr = dt.NewRow();
            dr["Method"] = context.Request.HttpMethod;
            dr["URL"]=context.Request.Url.OriginalString;
            // dr["Params"] = context.Request.Params.ToString();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            System.Collections.Generic.List<string> lsExclude = new System.Collections.Generic.List<string>();
            lsExclude.Add("SERVER_SOFTWARE");
            lsExclude.Add("SERVER_PROTOCOL");
            lsExclude.Add("SERVER_NAME");
            lsExclude.Add("SCRIPT_NAME");
            lsExclude.Add("SERVER_PORT");
            lsExclude.Add("GATEWAY_INTERFACE");
            lsExclude.Add("SERVER_PORT_SECURE");
            lsExclude.Add("HTTPS");
            lsExclude.Add("HTTP_HOST");

            lsExclude.Add("HTTP_CONNECTION");
            lsExclude.Add("REQUEST_METHOD");

            lsExclude.Add("REMOTE_HOST");
            lsExclude.Add("REMOTE_PORT");
            lsExclude.Add("REMOTE_ADDR");

            lsExclude.Add("APPL_PHYSICAL_PATH");
            lsExclude.Add("APPL_MD_PATH");
            lsExclude.Add("PATH_INFO");
            lsExclude.Add("PATH_TRANSLATED");
            lsExclude.Add("LOCAL_ADDR");

            lsExclude.Add("INSTANCE_META_PATH");
            lsExclude.Add("INSTANCE_ID");

            lsExclude.Add("CONTENT_LENGTH");

            lsExclude.Add("ALL_HTTP");
            lsExclude.Add("ALL_RAW");
            lsExclude.Add("URL");

            foreach (string key in context.Request.Params.AllKeys)
            {
                string value = context.Request.Params[key];
                if (!string.IsNullOrEmpty(value))
                {
                    if(!lsExclude.Contains(key))
                        sb.AppendLine(key + ": " + value);
                }
            }

            dr["Params"] = sb.ToString();
            sb.Length = 0;
            sb = null;

            dt.Rows.Add(dr);

            //context.Response.Write("<h1><font color=red>HelloWorldModule: Beginning of Request</font></h1><hr>");
        }
Exemplo n.º 49
0
 bool IsUnit()
 {
     if (la.kind != 1) { return false; }
     System.Collections.Generic.List<string> units = new System.Collections.Generic.List<string>(new string[] { "em", "ex", "px", "gd", "rem", "vw", "vh", "vm", "ch", "mm", "cm", "in", "pt", "pc", "deg", "grad", "rad", "turn", "ms", "s", "hz", "khz" });
     return units.Contains(la.val.ToLower());
 }
Exemplo n.º 50
0
    //process selection here
    public bool ProcessSelection()
    {
        sel = Selection.GetFiltered(typeof(GameObject), SelectionMode.Assets);
        //Debug.Log(sel.Length + " object(s) selected");

        //store processed materials and textures so that the program doesn't process again that is already processed 
        System.Collections.Generic.List<string> processedMats = new System.Collections.Generic.List<string>();
        System.Collections.Generic.List<string> processedTexs = new System.Collections.Generic.List<string>();

        //Handles multiple gameObjects
        foreach (GameObject ob in sel)
        {
            //get the path of the asset
            string path = AssetDatabase.GetAssetPath(ob);
            //Debug.Log(ob.name + " | " + path + " | " + AssetDatabase.Contains(ob) + " | " + AssetDatabase.IsMainAsset(ob));

            //there is a chance of getting proper data when the asset is in hierarchy and also the renders are enabled in the hierarchy
            GameObject go = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(path, typeof(GameObject))) as GameObject;
            Renderer[] renders;
            //get renders from the @go
            try
            {
                renders = go.GetComponentsInChildren<Renderer>();
            }
            catch (System.Exception e)
            {
                Debug.LogWarning(e.Message);
                Debug.LogWarning("Select Models from Project window");
                return false;
            }
            //Renderer[] renders = go.GetComponentsInChildren<Renderer>();
            Debug.Log("Renders/skinnedMeshRenders found = " + renders.Length);
            //process through all the @renders
            foreach (Renderer rnd in renders)
            {
                //get shared materials and process them
                Material[] mats = rnd.sharedMaterials;
                for (int i = 0; i < mats.Length; i++)
                {
                    //get path and guid from the material. guid contains unique ID assigned by Unity
                    string pathMat = AssetDatabase.GetAssetPath(mats[i].GetInstanceID());
                    string guidMat = AssetDatabase.AssetPathToGUID(pathMat);
                    //checking if the material is already processed
                    if (!processedMats.Contains(guidMat))
                    {
                        processedMats.Add(guidMat);
                        //make a copy of material
                        if(duplicateMats)
                            mats[i] = CopyAssetExtnd(pathMat, mats[i].name + postFix + ".", typeof(Material)) as Material;
                        //cycle through all the textures using @texIDs
                        foreach (string texID in texIDs)
                        {
                            //checking if the material has the property or not
                            if (mats[i].HasProperty(texID))
                            {
                                //get the texture to make copy of it
                                Texture2D tex = mats[i].GetTexture(texID) as Texture2D;
                                //check if the texture is assigned to material or not, if it is not assigned #moveOn
                                if (tex == null) continue;
                                //get path and guid for textures also
                                string pathTex = AssetDatabase.GetAssetPath(tex.GetInstanceID());
                                string guidTex = AssetDatabase.AssetPathToGUID(pathTex);
                                //check for existing processed textures
                                if (!processedTexs.Contains(guidTex))
                                {
                                    //create a copy of texture and also compress its size
                                    tex = CopyTexture(pathTex, tex.name + postFix + ".", typeof(Texture2D), (int)((float)tex.width * (float)texSizeDivider/100)) as Texture2D;
                                    //assign the new compressed texture to the material
                                    mats[i].SetTexture(texID, tex);
                                }
                            }
                        }
                    }
                }
                //assign the material to renderer
                rnd.sharedMaterials = mats;
            }
            //create a new prefab to save the low_settings of selected prefab/model. NOTE: Models in the projects window doesn't allow you to replace materials
            string newPath = GetDirectory(path) + go.name + ".prefab";
            //OverWiting on existing asset if one available
            AssetDatabase.DeleteAsset(newPath);
            PrefabUtility.CreatePrefab(newPath, go);
            //destroy the created gameObject @go in the start
            DestroyImmediate(go);
            //create a gameObject in the hierarchy using the new prefab
            GameObject low = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject))) as GameObject;
        }
        return true;
    }
Exemplo n.º 51
0
    private void BindTags()
    {
        System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();
        foreach (Post post in Post.Posts)
        {
            foreach (string tag in post.Tags)
            {
                if (!col.Contains(tag))
                    col.Add(tag);
            }
        }

        col.Sort(delegate(string s1, string s2) { return String.Compare(s1, s2); });

        foreach (string tag in col)
        {
            HtmlAnchor a = new HtmlAnchor();
            a.HRef = "javascript:void(0)";
            a.Attributes.Add("onclick", "AddTag(this)");
            a.InnerText = tag;
            phTags.Controls.Add(a);
        }
    }
        public void RemoveClientCode()
        {
            var methods = _asm.MainModule.Types
                .SelectMany(x => x.Methods)
                .ToArray();
            var offsets = new System.Collections.Generic.List<Instruction>();

            foreach (var mth in methods)
            {
                var hasMatch = true;
                while (mth.HasBody && hasMatch)
                {
                    var match = mth.Body.Instructions
                        .SingleOrDefault(x => x.OpCode == OpCodes.Ldsfld
                                    && x.Operand is FieldReference
                                    && (x.Operand as FieldReference).Name == "netMode"
                                    && x.Next.OpCode == OpCodes.Ldc_I4_1
                                    && (x.Next.Next.OpCode == OpCodes.Bne_Un_S)// || x.Next.Next.OpCode == OpCodes.Bne_Un)
                                    && !offsets.Contains(x)
                                    && (x.Previous == null || x.Previous.OpCode != OpCodes.Bne_Un_S));

                    hasMatch = match != null;
                    if (hasMatch)
                    {
                        var blockEnd = match.Next.Next.Operand as Instruction;
                        var il = mth.Body.GetILProcessor();

                        var cur = il.Body.Instructions.IndexOf(match) + 3;

                        while (il.Body.Instructions[cur] != blockEnd)
                        {
                            il.Remove(il.Body.Instructions[cur]);
                        }
                        offsets.Add(match);
                        //var newIns = il.Body.Instructions[cur];
                        //for (var x = 0; x < il.Body.Instructions.Count; x++)
                        //{
                        //    if (il.Body.Instructions[x].Operand == newIns)
                        //    {
                        //        il.Replace(il.Body.Instructions[x], il.Create(il.Body.Instructions[x].OpCode, newIns));
                        //    }
                        //}
                    }
                }
            }
        }
        /// <summary>
        /// Resets the id provider.
        /// </summary>
        /// <param name="servicesToDiscard">Services to ignore.</param>
        public virtual void Reset(System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> servicesToDiscard)
		{
			IDList.Clear();
			
			// extern services
			System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> discard = new System.Collections.Generic.List<DslEditorModeling::IDomainModelServices>();
			discard.AddRange(servicesToDiscard);
			discard.Add(VSPluginDSLDomainModelServices.Instance);

			foreach(DslEditorModeling::IDomainModelServices externService in VSPluginDSLDomainModelExtensionServices.Instance.ExternServices)
			{
				if( discard.Contains(externService) )
					continue;
			
				externService.ElementIdProvider.Reset(discard);
			}
		}
Exemplo n.º 54
0
		/// <summary>
		/// Handler for validating the current selection.
		/// </summary>
		internal virtual void OnMenuValidate(object sender, global::System.EventArgs e)
		{
			if (this.CurrentScheduledTasksDocData != null && this.CurrentScheduledTasksDocData.Store != null)
			{
				System.Collections.Generic.List<DslModeling::ModelElement> elementList = new System.Collections.Generic.List<Microsoft.VisualStudio.Modeling.ModelElement>();
				DslModeling::DepthFirstElementWalker elementWalker = new DslModeling::DepthFirstElementWalker(new ValidateCommandVisitor(elementList), new DslModeling::EmbeddingVisitorFilter(), true);
				foreach (object selectedObject in this.CurrentSelection)
				{
					// Build list of elements embedded beneath the selected root.
					DslModeling::ModelElement element = GetValidationTarget(selectedObject);
					if (element != null && !elementList.Contains(element))
					{
						elementWalker.DoTraverse(element);
					}
				}

				this.CurrentScheduledTasksDocData.ValidationController.Validate(elementList, DslValidation::ValidationCategories.Menu);
			}
		}
Exemplo n.º 55
0
 // the actual dynamic type of an object may not be publically available
 // (e.g. Type.GetMethods() returns an array of RuntimeMethodInfo)
 // so we look for the first public base class.
 static Type GetPublicRuntimeType(Type symType)
 {
     if (symType == null)
     {
         return symType;
     }
     // Find try to find a public class-type
     Type pubType = symType;
     while ((pubType != null) && (!pubType.IsPublic) && (!pubType.IsNestedPublic))
     {
         pubType = pubType.BaseType;
     }
     bool isObject = (pubType == typeof(object));
     if (isObject)
     {
         // Rather try to find a more specific interface-type 
         // instead, although we remember that this is an object and 
         // revert back to that type if no public interface is found
         pubType = null;
     }
     if (pubType == null)
     {
         // As a last resort, try to find a public interface-type
         System.Collections.Generic.List<Type> interfaceTypes =
             new System.Collections.Generic.List<Type>();
         int interfaceIndex = 0;
         while ((pubType == null) &&
             (symType != null) &&
             (symType != typeof(object)))
         {
             foreach (Type interfaceType in symType.GetInterfaces())
             {
                 if (interfaceTypes.Contains(interfaceType))
                 {
                     continue;
                 }
                 interfaceTypes.Add(interfaceType);
             }
             symType = symType.BaseType;
             while (interfaceIndex < interfaceTypes.Count)
             {
                 Type interfaceType = interfaceTypes[interfaceIndex++];
                 if (interfaceType.IsPublic || interfaceType.IsNestedPublic)
                 {
                     pubType = interfaceType;
                     break;
                 }
                 interfaceType = interfaceType.BaseType;
                 if ((interfaceType == null) ||
                     (interfaceType == typeof(object)) ||
                     (interfaceTypes.Contains(interfaceType)))
                 {
                     continue;
                 }
                 interfaceTypes.Add(interfaceType);
             }
         }
     }
     return pubType ?? ((isObject) ? typeof(object) : null);
 }
Exemplo n.º 56
0
        public static Matrix DropColumns(Matrix mat, params int[] columns)
        {
            System.Collections.Generic.List<int> li = new System.Collections.Generic.List<int>(columns);

            Matrix m = new Matrix(mat.Height, mat.Width - li.Count);
            for (int jj = 0, j = 0; j < mat.Width; j++)
            {
                if (li.Contains(j))
                    continue;

                for (int i = 0; i < mat.Height; i++)
                {
                    m[i, jj] = mat[i, j];
                }
                jj++;
            }
            return m;
        }
        /// <summary>
        /// Gets whether a certain key has already been assigned.
        /// </summary>
        /// <param name="modelElementId">Domain model element Id.</param>
        /// <param name="servicesToDiscard">Services to ignore.</param>
        /// <returns>True if the given id has already been assigned; false otherwise.</returns>
        public virtual bool HasKey(System.Guid modelElementId, System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> servicesToDiscard)
		{
			if( IDList.Contains(modelElementId) )
				return true;
				
			if( ExcludedIDList.Contains(modelElementId) )
				return true;
		
			// extern services
			System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> discard = new System.Collections.Generic.List<DslEditorModeling::IDomainModelServices>();
			discard.AddRange(servicesToDiscard);
			discard.Add(VSPluginDSLDomainModelServices.Instance);

			foreach(DslEditorModeling::IDomainModelServices externService in VSPluginDSLDomainModelExtensionServices.Instance.ExternServices)
			{
				if( discard.Contains(externService) )
					continue;
			
				bool bHasKey = externService.ElementIdProvider.HasKey(modelElementId, discard);
				if( bHasKey )
					return true;
			}
		
			return false;
		}
Exemplo n.º 58
0
 public static Point[] GetResolutions()
 {
     System.Collections.Generic.List<Point> resolutions=new System.Collections.Generic.List<Point>();
     foreach(DisplayMode ds in Manager.Adapters[adapter].SupportedDisplayModes) {
         if(ds.Format==Format.X8R8G8B8 && !resolutions.Contains(new Point(ds.Width, ds.Height)))
             resolutions.Add(new Point(ds.Width, ds.Height));
     }
     return resolutions.ToArray();
 }
        /// <summary>
        /// Removes a specific key.
        /// </summary>
        /// <param name="modelElement">Domain model element to remove the key for.</param>
        /// <param name="servicesToDiscard">Services to ignore.</param>
        public virtual bool RemoveKey(DslModeling::ModelElement modelElement, System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> servicesToDiscard)
		{
			//if( IDList.Contains(modelElement.Id) )
			//	IDList.Remove(modelElement.Id);
			try
			{
				if( modelElement is DslEditorModeling::IDableElement )			
					IDList.Remove(modelElement.Id);
					
				return true;
			}
			catch{}		
			
			// extern services
			System.Collections.Generic.List<DslEditorModeling::IDomainModelServices> discard = new System.Collections.Generic.List<DslEditorModeling::IDomainModelServices>();
			discard.AddRange(servicesToDiscard);
			discard.Add(VSPluginDSLDomainModelServices.Instance);

			foreach(DslEditorModeling::IDomainModelServices externService in VSPluginDSLDomainModelExtensionServices.Instance.ExternServices)
			{
				if( discard.Contains(externService) )
					continue;
			
				bool bRemoved = externService.ElementIdProvider.RemoveKey(modelElement, discard);
				if( bRemoved )
					return true;
			}
		
			return false;
		}
Exemplo n.º 60
0
    public void TestCslaDataProviderCanOperationsObjectLevel()
    {
      var context = GetContext();

      var provider = new Csla.Xaml.CslaDataProvider();
      Customer.GetCustomer((o1, e1) =>
      {
        Csla.ApplicationContext.GlobalContext.Clear();
        var cust = e1.Object;
        int custID = cust.Id;
        string custName = cust.Name;


        context.Assert.AreEqual(provider.CanEditObject, false);
        context.Assert.AreEqual(provider.CanGetObject, false);
        context.Assert.AreEqual(provider.CanDeleteObject, false);
        context.Assert.AreEqual(provider.CanCreateObject, false);

        System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();

        provider.PropertyChanged += (o3, e3) =>
          {
            list.Add(e3.PropertyName);
          };
        context.Completed += (o5, e5) =>
          {
            bool success = list.Contains("CanDeleteObject") &&
                              list.Contains("CanDeleteObject") &&
                              list.Contains("CanDeleteObject") &&
                              list.Contains("CanDeleteObject");
            context.Assert.IsTrue(success);
          };
        provider.ObjectInstance = cust;

        context.Assert.AreEqual(provider.CanEditObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.EditObject, cust));
        context.Assert.AreEqual(provider.CanGetObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.GetObject, cust));
        context.Assert.AreEqual(provider.CanDeleteObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.DeleteObject, cust));
        context.Assert.AreEqual(provider.CanCreateObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.CreateObject, cust));

        context.Assert.AreEqual(provider.CanEditObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.EditObject, typeof(Customer)));
        context.Assert.AreEqual(provider.CanGetObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.GetObject, typeof(Customer)));
        context.Assert.AreEqual(provider.CanDeleteObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.DeleteObject, typeof(Customer)));
        context.Assert.AreEqual(provider.CanCreateObject, Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.CreateObject, typeof(Customer)));
        context.Assert.Success();

      });
      var tmp = provider.Data;
      context.Complete();
    }