Exemplo n.º 1
0
    public static void PopuplateJointMap()
    {
        HandMeshSurface hms = GameObject.FindObjectOfType <HandMeshSurface>();

        if (hms == null)
        {
            return;
        }

        List <JointMap> jointMaps = new System.Collections.Generic.List <JointMap>(hms.leftJointMaps);

        for (int i = jointMaps.Count - 1; i >= 0; i--)
        {
            if (string.IsNullOrEmpty(jointMaps[i].Name))
            {
                jointMaps.RemoveAt(i);
            }
        }
        hms.leftJointMaps = jointMaps.ToArray();

        jointMaps.Clear();
        jointMaps.AddRange(hms.rightJointMaps);
        for (int i = jointMaps.Count - 1; i >= 0; i--)
        {
            if (string.IsNullOrEmpty(jointMaps[i].Name))
            {
                jointMaps.RemoveAt(i);
            }
        }
        hms.rightJointMaps = jointMaps.ToArray();
    }
Exemplo n.º 2
0
        /// <summary>
        /// Take first element from queue, remove it from queue, and finally return.
        /// If queue is empty, function will return null.
        /// </summary>
        /// <returns>Element</returns>
        public T Pull()
        {
            bool signal = false;

            try
            {
                lock (_List)
                {
                    if (_List.Count == 0)
                    {
                        return(default(T));
                    }
                    T item = _List[0];
                    _List.RemoveAt(0);
                    signal = true;
                    return(item);
                }
            }
            finally
            {
                //_PushResetEvent.Reset();
                if (signal)
                {
                    if (OnPull != null)
                    {
                        OnPull(this);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the items in a directory
        /// </summary>
        /// <param name="DirectoryFullName">Directory name (e.g. "directory\subdirectory" or "." for the root)</param>
        /// <param name="ExcludeNavigationDots">When posted as true, return list will not contains "." and ".."</param>
        /// <returns>A list of the items name</returns>
        public List <String> GetItemList(String DirectoryFullName, Boolean ExcludeNavigationDots)
        {
            DirectoryFullName = CorrectPath(DirectoryFullName);

            System.Collections.Generic.List <String> content = this._nfsInterface.GetItemList(DirectoryFullName);

            if (ExcludeNavigationDots)
            {
                int dotIdx, ddotIdx;

                dotIdx = content.IndexOf(".");
                if (dotIdx > -1)
                {
                    content.RemoveAt(dotIdx);
                }

                ddotIdx = content.IndexOf("..");
                if (ddotIdx > -1)
                {
                    content.RemoveAt(ddotIdx);
                }
            }

            return(content);
        }
Exemplo n.º 4
0
    private Action SubscribeToAll(string csv, Action <ScriptEventData> callback)
    {
        if (!__debugInitialized)
        {
            SetupSimple();
        }
        if (string.IsNullOrWhiteSpace(csv))
        {
            return(null);
        }

        Func <string, Action <ScriptEventData>, Action> subscribeAction;

        if (__subscribeActions.TryGetValue(csv, out subscribeAction))
        {
            return(subscribeAction(csv, callback));
        }

        // Simple case.
        if (!csv.Contains(">>"))
        {
            __subscribeActions[csv] = SubscribeToAllInternal;
            return(SubscribeToAllInternal(csv, callback));
        }

        // Chaining
        __subscribeActions[csv] = (_csv, _callback) =>
        {
            System.Collections.Generic.List <string> chainedCommands = new System.Collections.Generic.List <string>(csv.Split(new string[] { ">>" }, StringSplitOptions.RemoveEmptyEntries));

            string initial = chainedCommands[0];
            chainedCommands.RemoveAt(0);
            chainedCommands.Add(initial);

            Action unsub = null;
            Action <ScriptEventData> wrappedCallback = null;
            wrappedCallback = (data) =>
            {
                string first = chainedCommands[0];
                chainedCommands.RemoveAt(0);
                chainedCommands.Add(first);
                if (unsub != null)
                {
                    unsub();
                }
                unsub = SubscribeToAllInternal(first, wrappedCallback);
                Log.Write(LogLevel.Info, "CHAIN Subscribing to " + first);
                _callback(data);
            };

            unsub = SubscribeToAllInternal(initial, wrappedCallback);
            return(unsub);
        };

        return(__subscribeActions[csv](csv, callback));
    }
Exemplo n.º 5
0
        private static void CreateOrgWithAFewUsers(MongoDBDataAccessor mongodb)
        {
            System.Collections.Generic.List <Guid> ids = mongodb.GetAllUsers().Select(x => x.Id).ToList();

            ids.RemoveAt(4);
            ids.RemoveAt(1);

            mongodb.CreateOrganization(new OrganizationModel()
            {
                Name        = "Realm of Lost Data",
                Description = "We're bad at devops",
                WorkerIds   = ids
            });
        }
Exemplo n.º 6
0
        //=========================================================================
        //  パス規格化
        //-------------------------------------------------------------------------
        static Gen::List <string> InternalResolveTraversal(string path)
        {
            Gen::List <string> list = new System.Collections.Generic.List <string>();

            string[] elems = path.Split('/');
            for (int index = 0; index < elems.Length; index++)
            {
                string elem = elems[index];
                if (index == 0)
                {
                    list.Add(elem);
                    continue;
                }

                if (elem.Length == 0 || elem == ".")
                {
                    continue;
                }
                else if (elem == "..")
                {
                    if (list.Count == 1)
                    {
                        if (list[0].Length == 0)
                        {
                            continue; // 絶対パス
                        }
                        else if (list[0] == ".")
                        {
                            list.RemoveAt(0);
                        }
                    }

                    if (list.Count > 0 && list[list.Count - 1] != "..")
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    else
                    {
                        list.Add(elem);
                    }
                }
                else
                {
                    list.Add(elem);
                }
            }

            return(list);
        }
Exemplo n.º 7
0
        void DoRestart()
        {
            System.Collections.Generic.List <string> args =
                new System.Collections.Generic.List <string>();
            var cmds = System.Environment.GetCommandLineArgs();

            foreach (string a in cmds)
            {
                args.Add(a);
            }

            args.RemoveAt(0);
            args.Remove("-restart");

            string sArgs = string.Empty;

            foreach (string s in args)
            {
                sArgs += (s + " ");
            }

            sArgs += " -restart";

            Process.Start("Elpis.exe", sArgs);
        }
Exemplo n.º 8
0
    /// <summary>
    /// Get a list of widgets underneath the tooltip.
    /// </summary>

    protected virtual void Start()
    {
        mTrans = transform;

        mWidgets.Clear();
        GetComponentsInChildren(mWidgets);

        for (int i = 0, imax = mWidgets.Count; i < imax; ++i)
        {
            var sw = mWidgets[i];

            if (!sw.isSelectable || !sw.enabled)
            {
                mWidgets.RemoveAt(i--);
                --imax;
            }
        }

        mPos = mTrans.localPosition;
        if (uiCamera == null)
        {
            uiCamera = NGUITools.FindCameraForLayer(gameObject.layer);
        }
        SetAlpha(0f);
    }
        public T remove(int i)
        {
            var element = get(i);

            _list.RemoveAt(i);
            return(element);
        }
Exemplo n.º 10
0
    private void SendToAll(string csv, Reflective data)
    {
        if (!__debugInitialized) SetupSimple();
        if (string.IsNullOrWhiteSpace(csv)) return;

        Action<string, Reflective> sendAction;
        if (__sendActions.TryGetValue(csv, out sendAction))
        {
            sendAction(csv, data);
            return;
        }

        // Simple case.
        if (!csv.Contains(">>"))
        {
            __sendActions[csv] = SendToAllInternal;
            SendToAllInternal(csv, data);
            return;
        }

        // Chaining
        System.Collections.Generic.List<string> chainedCommands = new System.Collections.Generic.List<string>(csv.Split(new string[] { ">>" }, StringSplitOptions.RemoveEmptyEntries));
        __sendActions[csv] = (_csv, _data) =>
        {
            string first = chainedCommands[0];
            chainedCommands.RemoveAt(0);
            chainedCommands.Add(first);

            Log.Write(LogLevel.Info, "CHAIN Sending to " + first);
            SendToAllInternal(first, _data);
        };
        __sendActions[csv](csv, data);
    }
Exemplo n.º 11
0
    //Sets the exit of the start tile (selecting a random one inside the bounds).
    public int startExit(Coordinate coordinate)
    {
        int        res      = 0;
        List <int> allExits = new System.Collections.Generic.List <int> ();

        for (int i = 1; i < 7; i++)
        {
            allExits.Add(i);
        }


        while (res == 0)
        {
            int        randomVal         = (int)Mathf.Floor(Random.Range(0, allExits.Count));
            int        possibleExit      = allExits [randomVal];
            Coordinate possibleFirstTile = getCoordinateFromExit(coordinate, possibleExit);

            if (isOnBounds(possibleFirstTile))
            {
                res = possibleExit;
            }
            else
            {
                allExits.RemoveAt(randomVal);
            }
        }


        return(res);
    }
Exemplo n.º 12
0
        void DoRestart()
        {
            System.Collections.Generic.List <string> args =
                new System.Collections.Generic.List <string>();
            var cmds = System.Environment.GetCommandLineArgs();

            foreach (string a in cmds)
            {
                args.Add(a);
            }

            args.RemoveAt(0);
            args.Remove("-restart");

            string sArgs = string.Empty;

            foreach (string s in args)
            {
                sArgs += (s + " ");
            }

            sArgs += " -restart";
            //Process.Start("Elpis.exe", sArgs);
            try
            {
                //run the program again and close this one
                Process.Start("Elpis.exe", sArgs);
                //or you can use Application.ExecutablePath

                //close this one
                Process.GetCurrentProcess().Kill();
            }
            catch
            { }
        }
Exemplo n.º 13
0
    public override void _PhysicsProcess(float Delta)
    {
        Items.Instance Item = Game.PossessedPlayer.Inventory[Game.PossessedPlayer.InventorySlot];
        if (Item != null && Item.Type != CurrentMeshType)        //null means no item in slot
        {
            GhostMesh.Mesh  = Meshes[Item.Type];
            CurrentMeshType = Item.Type;
        }

        GhostMesh.Translation     = OldPositions[0];
        GhostMesh.RotationDegrees = OldRotations[0];
        GhostMesh.Visible         = OldVisible[0];

        Player Plr = Game.PossessedPlayer;

        OldVisible.RemoveAt(0);
        OldVisible.Add(false);
        if (Plr.Inventory[Plr.InventorySlot] != null)
        {
            RayCast BuildRayCast = Plr.GetNode("SteelCamera/RayCast") as RayCast;
            if (BuildRayCast.IsColliding())
            {
                Structure Hit = BuildRayCast.GetCollider() as Structure;
                if (Hit != null)
                {
                    System.Nullable <Vector3> GhostPosition = BuildPositions.Calculate(Hit, Plr.Inventory[Plr.InventorySlot].Type);
                    if (GhostPosition != null)
                    {
                        Vector3 GhostRotation = BuildRotations.Calculate(Hit, Plr.Inventory[Plr.InventorySlot].Type);
                        Translation     = (Vector3)GhostPosition;
                        RotationDegrees = GhostRotation;
                        OldVisible[1]   = true;
                    }
                }
            }
        }
        if (OldVisible[1] == false)
        {
            OldVisible[0]     = false;
            GhostMesh.Visible = false;
        }

        OldCanBuild.RemoveAt(0);
        if (GetOverlappingBodies().Count > 0)
        {
            GhostMesh.MaterialOverride = RedMat;
            OldCanBuild.Add(false);
        }
        else
        {
            GhostMesh.MaterialOverride = GreenMat;
            OldCanBuild.Add(true);
        }
        CanBuild = OldCanBuild[0];

        OldPositions.RemoveAt(0);
        OldPositions.Add(Translation);
        OldRotations.RemoveAt(0);
        OldRotations.Add(RotationDegrees);
    }
Exemplo n.º 14
0
        //private async void Timer_Elapsed(object sender, EventArgs e)
        private void dispatcherTimer_Tick(object sender, object e)
        {
            if (dataList.Count == 0)
            {
                //never should happen
                _timer.Stop();
                return;
            }
            DispatcherTimerData data = dataList[0];

            if (--(data.tickCount) > 0)
            {
                return;
            }

            NewTestamentEnArm.Helpers.Dbg.d(" " + data.description);
            dataList.RemoveAt(0);
            if (dataList.Count == 0)
            {
                _timer.Stop();
            }
            data.onTick();
            //await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            //);
        }
Exemplo n.º 15
0
            static bool Test2b()
            {
                System.Random ran = new System.Random(2134);

                {
//%%if IsEx==0 (
                    Gen::List <int> list2 = new System.Collections.Generic.List <int>();
//%%elif IsEx==1
                    Gen::List <TestElement> list2 = new System.Collections.Generic.List <TestElement>();
//%%)
                    const int N = 100000;
                    for (int i = 0; i < N; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list2.Count);
//%%if IsEx==0 (
                        list2.Insert(idx, i);
//%%elif IsEx==1
                        TestElement e = new TestElement(i);
                        list2.Insert(idx, e);
//%%)
                    }

                    for (int i = 0; i < N / 2; i++)
                    {
                        int idx = (int)(ran.NextDouble() * list2.Count);
                        list2.RemoveAt(idx);
                    }
                }
                return(true);
            }
Exemplo n.º 16
0
        private void run()
        {
            lock (this)
            {
                while (bRun)
                {
                    if (list.Count == 0)
                    {
                        System.Threading.Monitor.Wait(this);
                    }
                    else
                    {
                        int it = (list[0].OrderDate.AddMinutes(20) - DateTime.Now).Milliseconds;
                        if (it > 0)
                        {
                            System.Threading.Monitor.Wait(this, it);
                            continue;
                        }

                        //执行
                        OrderInfo item = list[0];
                        updateOrder(item.OrderId);
                        list.RemoveAt(0);
                    }
                }
            }
        }
Exemplo n.º 17
0
 public static void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
         if (FRB_icon != null)
         {
             FRB_icon = null;
         }
         if (Veilstone_Corner_Moon_Stone != null)
         {
             Veilstone_Corner_Moon_Stone = null;
         }
         if (something != null)
         {
             something = null;
         }
         if (Bariguess != null)
         {
             Bariguess = null;
         }
         if (adiamond != null)
         {
             adiamond = null;
         }
         if (RollingSlotsforall != null)
         {
             RollingSlotsforall = null;
         }
     }
 }
Exemplo n.º 18
0
 public static void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
         if (MainShip1 != null)
         {
             MainShip1 = null;
         }
         if (MainShip2 != null)
         {
             MainShip2 = null;
         }
         if (MainShip3 != null)
         {
             MainShip3 = null;
         }
         if (MainShip4 != null)
         {
             MainShip4 = null;
         }
     }
 }
Exemplo n.º 19
0
 public static void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
         if (Rock1 != null)
         {
             Rock1 = null;
         }
         if (Rock2 != null)
         {
             Rock2 = null;
         }
         if (Rock3 != null)
         {
             Rock3 = null;
         }
         if (Rock4 != null)
         {
             Rock4 = null;
         }
     }
 }
Exemplo n.º 20
0
		//Sets the exit of the start tile (selecting a random one inside the bounds).
		public int startExit (Coordinate coordinate)
		{
		
				int res = 0;
				List<int> allExits = new System.Collections.Generic.List<int> ();
				for (int i =1; i<7; i++) {
						allExits.Add (i); 
				}		
		
		
				while (res == 0) {
			
						int randomVal = (int)Mathf.Floor (Random.Range (0, allExits.Count));
						int possibleExit = allExits [randomVal];
						Coordinate possibleFirstTile = getCoordinateFromExit (coordinate, possibleExit);
			
						if (isOnBounds (possibleFirstTile)) {
								res = possibleExit;
						} else {
								allExits.RemoveAt (randomVal);
						}
				} 
		
		
				return res;
		}
Exemplo n.º 21
0
 public void TraverseMenu()
 {
     //if I am in a submenu, no matter how many levels deep, clicking on the menu button
     //acts as a "Back" button and goes to the menu one level up
     if (menuPath.Count > 0)
     {
         crMenu lastMenu = menuPath[menuPath.Count - 1];
         menuPath.RemoveAt(menuPath.Count - 1);
         ShowMenu(lastMenu.MenuName, false);
     }
     else
     //if there is no menu currently active, show the first one in the list.
     {
         if (activeMenu != null)
         {
             ShowMenu("", false);
         }
         else
         if (Menus != null)
         {
             if (Menus.Length > 0)
             {
                 ShowMenu(Menus[0].MenuName, true);
             }
         }
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// 移除指定索引处的元素。
 /// </summary>
 /// <param name="index">从0开始的索引值。</param>
 public void RemoveAt(int index)
 {
     if (index < 0 || index > _list.Count - 1)
     {
         return;
     }
     _list.RemoveAt(index);
 }
Exemplo n.º 23
0
        public void RemoveAt(int index)
        {
            MapNode node = selectedNodes[index];

            selectedNodes.RemoveAt(index);

            NodeDeselected(node, this);
        }
Exemplo n.º 24
0
    //================================================================
    //		chk ListBehaviour
    //================================================================
    private static void chkListBehaviour()
    {
        System.Console.WriteLine("---- check List Behaviour on Removing Last Item ----");
        Gen::List <int> list = new System.Collections.Generic.List <int>();

        list.Add(2);
        list.Add(3);
        list.Add(5);
        list.Add(7);
        ASSERT("Appended 4 items", chkListBehaviour_List2Str(list), "2 3 5 7");
        list.RemoveAt(3);
        ASSERT("Removed 1 item", chkListBehaviour_List2Str(list), "2 3 5");
        list.RemoveAt(2);
        ASSERT("Removed 2 items", chkListBehaviour_List2Str(list), "2 3");
        list.RemoveAt(1);
        ASSERT("Removed 3 items", chkListBehaviour_List2Str(list), "2");
        System.Console.WriteLine();
    }
Exemplo n.º 25
0
        public static string IntegerToHexByteString(int valueToConvert, byte byteSize)
        {
            System.Collections.Generic.List <byte> bytes = new System.Collections.Generic.List <byte>();
            string output = string.Empty;

            if (byteSize != 1 && byteSize != 2 && byteSize != 4)
            {
                throw new Exception(string.Format("Invalid byte size of '{0}' passed to IntegerToHexByteString.\r\n" +
                                                  "Please ensure that your value will be split into valid byte-sized pieces.  Valid values are 1, 2, and 4.", byteSize));
            }

            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(ms))
                {
                    writer.Write(valueToConvert);
                    bytes.AddRange(ms.ToArray());
                }

            int byteCount = bytes.Count;

            if (byteCount < byteSize)
            {
                for (int i = byteCount; i <= byteSize - byteCount; i++)
                {
                    bytes.Add(0);
                }
            }

            byteCount = bytes.Count;
            if (byteCount > byteSize)
            {
                // Carefully trim off extra zeros from the array
                try
                {
                    for (int i = byteCount - 1; i >= byteSize; i--)
                    {
                        if (bytes[i] > 0)
                        {
                            throw new Exception();
                        }
                        bytes.RemoveAt(i);
                    }
                }
                catch
                {
                    throw new Exception(string.Format("The conversion of value '{0}' to a hex byte string resulted in a byte count of '{1}'.\r\n" +
                                                      "This is greater than the byte size that was specified of '{2}'.", valueToConvert, bytes.Count, byteSize));
                }
            }

            for (int i = bytes.Count - 1; i >= 0; i--)
            {
                output += bytes[i].ToString("X").PadLeft(2, '0');
            }

            return(output);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 删除当前选中ROI
        /// </summary>
        /// <param name="roi"></param>
        protected internal void removeActiveROI(ref System.Collections.Generic.List <ROI> roi)
        {
            int activeROIIdx = this.getActiveROIIdx();

            if (activeROIIdx > -1)
            {
                this.removeActive();
                roi.RemoveAt(activeROIIdx);
            }
        }
Exemplo n.º 27
0
        public ItemType Pop()
        {
            if (!IsEmpty)
            {
                ItemType item = items[0];
                items.RemoveAt(0);
                return(item);
            }

            return((ItemType)typeof(ItemType).GetDefaultValue());
        }
Exemplo n.º 28
0
 public static void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
     }
 }
Exemplo n.º 29
0
        private void ClipboardChanged(object sender, EventArgs e)
        {
            String clipboardText;

            try
            {
                // Handle your clipboard update here, debug logging example:
                if (Clipboard.ContainsText())
                {
                    clipboardText = Clipboard.GetText(TextDataFormat.UnicodeText);
                    if (!clipboardText.Equals(currentItem)) //make sure that if you click an item, it can differentiate from the item that was copied
                                                            // it goes into this multiple times after writing to clipboard, so that is how I stopped it
                    {
                        if (!actualClipboard.Contains(clipboardText))
                        { //if it has the thing already
                            actualClipboard.Insert(0, clipboardText);

                            if (actualClipboard.Count > 10)
                            {
                                actualClipboard.RemoveAt(10);
                            }
                        }
                        else
                        {
                            MoveToTop(actualClipboard.IndexOf(clipboardText));
                        }

                        Repopulate();
                    }
                }
                else
                {
                    justWroteToClipboard = false;
                }
            }
            catch (Exception err)
            {
                //do nothing
            }
        }
Exemplo n.º 30
0
    public void Populate()
    {
        this.Clear();
        System.Collections.Generic.List <RPOSWindow> list = new System.Collections.Generic.List <RPOSWindow>(RPOS.GetBumperWindowList());
        int count = list.Count;

        for (int i = 0; i < count; i++)
        {
            if ((list[i] != null) && !string.IsNullOrEmpty(list[i].title))
            {
                list[i].EnsureAwake <RPOSWindow>();
            }
            else
            {
                list.RemoveAt(i--);
                count--;
            }
        }
        float num3 = 75f * this.buttonPrefab.gameObject.transform.localScale.x;
        float num4 = 5f;
        float num5 = (count * num3) * -0.5f;
        int   num6 = 0;

        if (this.instances == null)
        {
            this.instances = new HashSet <Instance>();
        }
        foreach (RPOSWindow window in list)
        {
            Instance inst = new Instance {
                window = window
            };
            Vector3    vector = this.buttonPrefab.gameObject.transform.localScale;
            GameObject obj2   = NGUITools.AddChild(base.gameObject, this.buttonPrefab.gameObject);
            inst.label      = obj2.gameObject.GetComponentInChildren <UILabel>();
            inst.label.name = window.title + "BumperButton";
            Vector3 localPosition = obj2.transform.localPosition;
            localPosition.x = num5 + ((num3 + num4) * num6);
            obj2.transform.localPosition = localPosition;
            obj2.transform.localScale    = vector;
            inst.button = obj2.GetComponentInChildren <UIButton>();
            inst.bumper = this;
            window.AddBumper(inst);
            this.instances.Add(inst);
            num6++;
        }
        Vector3 localScale = this.background.transform.localScale;

        localScale.x = (count * num3) + (count - (1f * num4));
        this.background.gameObject.transform.localScale    = localScale;
        this.background.gameObject.transform.localPosition = new Vector3(localScale.x * -0.5f, base.transform.localPosition.y, 0f);
    }
Exemplo n.º 31
0
        public T Dequeue()
        {
            if (queue.Count == 0)
            {
                return(default(T));
            }

            T t = queue[0];

            queue.RemoveAt(0);

            return(t);
        }
Exemplo n.º 32
0
        /// <summary>
        /// チェックリストを統合し、string[][]型で返す。
        /// </summary>
        /// <returns></returns>
        private string[][] mergeMemberC83()
        {
            var result = new System.Collections.Generic.List<string[]>();
            var recordCircle = new System.Collections.Generic.List<int>();
            var Color = new Color();

            string[] header = { "Header", "ComicMarketCD-ROMCatalog", "ComicMarket83", "UTF-8", VERSION };
            result.Add(header);

            foreach (ListViewItem item in memberList.Items)
            {
                DataContainer obj = item.Tag as DataContainer;
                if (obj == null) continue;

                for (int i = 0; i < obj.data.GetLength(0); i++)
                {
                    if (obj.data[i][0] != "Circle") continue;
                    try
                    {
                        if (recordCircle.IndexOf(int.Parse(obj.data[i][1])) < 0)
                        {
                            result.Add(obj.data[i]);
                            recordCircle.Add(int.Parse(obj.data[i][1]));
                        }
                        else
                        {
                            int m = recordCircle.IndexOf(int.Parse(obj.data[i][1])) + 1;
                            string[] tmp = result.ToArray()[m];
                            int tmp1 = int.Parse(tmp[2]);
                            int tmp2 = int.Parse(obj.data[i][2]);
                            if (tmp1 == 0) tmp1 = 10;
                            if (tmp2 == 0) tmp2 = 10;
                            if (tmp1 > tmp2)
                                tmp1 = tmp2;
                            if (tmp1 >= 10) tmp1 = 0;
                            tmp[2] = tmp1.ToString();

                            tmp[17] += obj.data[i][17];
                            result.RemoveAt(result.Count);
                            result.Add(tmp);
                        }
                    }
                    catch (Exception) { continue; }
                }
            }

            foreach (Color item in Settings.colorSettings)
            {
                if (item.label == null) continue;
                string[] tmpcolor = { "Color", item.number.ToString(), Color.ToBGRColor(item.checkcolor), Color.ToBGRColor(item.printcolor), item.label };
                result.Add(tmpcolor);
            }

            return result.ToArray();
        }
Exemplo n.º 33
0
		//Finding a random path.
		public void Backtracking (TileScript newTile, List<TileScript> currentPath)
		{

				//Adding the previous tiles to the new list of tiles.
			
				List<TileScript> newPath = new List<TileScript> (currentPath);

				
			
				//Adding the current tile to the new list.
				newPath.Add (newTile);
		
				if (newPath.Count == pathLenght + 2) {
						// If the path has the desired lenght (plus 1 for the start and 1 for the finish tile,
						//we found the path!

						pathFound = true;
						
	
						completePath = new List<TileScript> (newPath);


				} else {
						//If we didn't find the path yet, we go on.

						//We find the current tile's exit.
						int prevExitPosition = 0; 

						
						if (newPath.Count == 1) {
								//If we are on the first iteration the second tile will be placed at a random exit form the
								//start, within the bounding box. We use the method "startExit()" to find an available one.
				
								prevExitPosition = startExit (newTile.getCoordinates ());
			
						} else {
								//If we are not on the first iteration we can find the next position using the current tile's  
								//coordinates and it's second exit to find it.


								prevExitPosition = newTile.getExits () [1];
						
						}

						//Now that we have the current tile's exit, we can use that information along the coordinate to obtain the
						//coordinate the next tile would have.

						Coordinate nextIterationCoordinate = getCoordinateFromExit (newTile.getCoordinates (), prevExitPosition);

						if (isOnBounds (nextIterationCoordinate) && placeUnused (nextIterationCoordinate, newPath)) {
								//Checking if the next coordinate is on bounds and it's not used already.
				
								
								if (newPath.Count == pathLenght + 1) {
										//If we only have one tile to go, we add the Finish tile.
										TileScript finish = new TileScript (nextIterationCoordinate, "Finish");
										Backtracking (finish, newPath);
					
								} else {
										//We have more than one iteration to go. 

										/*
										We already know that we have a empty slot to place a new tile. We will place one
										at random calling backtracking again. If at any point one branch would not find an
										available path, it'll contenue on the previous branch with more options.

										Once a turn is chosen and the random orientation selected cannot produce a available
										path before going to the other two types of tiles, we try our luck turning to the 
										second possible turn first.
							
										The algorithm will find a branch that suits the desired lenght.
										*/
									
										//Listing all the possible type of tiles.
										List<int> possibleTiles = new System.Collections.Generic.List<int> ();
										
										for (int i = 1; i<4; i++) {
												possibleTiles.Add (i);
										}
										
										while (possibleTiles.Count>0&&!pathFound) {
												//If there is still a type of tile to test on a slot.
							
												/*
												 To improve the execution time, we check if a path was found on a previous 
												attemp. There is repeated code here. That's a bad smell, but i'll be fixed 
												on further refactorizations.
												*/
			
												
												int randomVal = (int)Mathf.Floor (Random.Range (0, possibleTiles.Count));
												int chosen = possibleTiles [randomVal];
												possibleTiles.RemoveAt (randomVal);

										
												if (chosen == 1) {	
								
														//In the Straight tile, we dont mind the left or right orientation.
														TileScript nextTile = new TileScript ("Straight", "Tile " + newPath.Count, nextIterationCoordinate, prevExitPosition, 0);
														Backtracking (nextTile, newPath);
												}


												
												if (chosen == 2) {	
					
														
														List<int> possibleTurns = new System.Collections.Generic.List<int> ();
														possibleTurns.Add (0);
														possibleTurns.Add (1);

														
														while (possibleTurns.Count>0&&!pathFound) {

																int randomTurn = (int)Mathf.Floor (Random.Range (0, possibleTurns.Count));
																int leftOrRight = possibleTurns [randomTurn];
																possibleTurns.RemoveAt (randomTurn);

																TileScript nextTile = new TileScript ("Turn", "Tile " + newPath.Count, nextIterationCoordinate, prevExitPosition, leftOrRight);
																Backtracking (nextTile, newPath);
														
														}
												}

												if (chosen == 3) {	
						
							
														List<int> possibleTurns = new System.Collections.Generic.List<int> ();
														possibleTurns.Add (0);
														possibleTurns.Add (1);
							
							
														while (possibleTurns.Count>0&&!pathFound) {
								
																int randomTurn = (int)Mathf.Floor (Random.Range (0, possibleTurns.Count));
																int leftOrRight = possibleTurns [randomTurn];
																possibleTurns.RemoveAt (randomTurn);
								
																TileScript nextTile = new TileScript ("SharpTurn", "Tile " + newPath.Count, nextIterationCoordinate, prevExitPosition, leftOrRight);
																Backtracking (nextTile, newPath);
								
														}
												}
												
										}
					
					
					
					
					
					
								}
				
				
						

			
						}

				}
				
			

		}
Exemplo n.º 34
0
        void DoRestart()
        {
            System.Collections.Generic.List<string> args =
                new System.Collections.Generic.List<string>();
            var cmds = System.Environment.GetCommandLineArgs();
            foreach (string a in cmds)
                args.Add(a);

            args.RemoveAt(0);
            args.Remove("-restart");

            string sArgs = string.Empty;
            foreach(string s in args)
                sArgs += (s + " ");

            sArgs += " -restart";

            Process.Start("Elpis.exe", sArgs);
        }
Exemplo n.º 35
0
        //private Program.SlotTable<string> GetSlotOwnerTable(bool BCMPathMode)
        private object GetSlotOwnerInfo(int Mode)
        {
            object SlotOwnerInfo = null;
            switch (Mode)
            {
                case 0: //GetSlotOwnerTable
                    SlotOwnerInfo = new Program.SlotTable<string>("");
                    break;
                case 1: //GetSlotOwnerPathAndDLCData
                    SlotOwnerInfo = new Program.SlotTable<Tuple<string, DLCData,int>>(null/*new Tuple<string, DLCData,int>("", null,0)*/);
                    break;
            }
            //Program.SlotTable<string> SlotOwnerTable = new Program.SlotTable<string>("");

            // 想定される書式のパスが指定されているか
            string SavePath = tbSavePath.Text;
            string ParentPath;
            if (System.Text.RegularExpressions.Regex.IsMatch(SavePath, @"\\\d+$"))
            {
                ParentPath = Path.GetDirectoryName(SavePath);
            }
            else
            {
                return SlotOwnerInfo;
            }

            // 兄弟 DLC を取得
            string[] brothers;
            try
            {
                brothers = Directory.GetDirectories(ParentPath);
            }
            catch
            {
                return SlotOwnerInfo;
            }

            // Lists フォルダを読んでおく
            string[] listpaths = null;
            try
            {
                listpaths = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Lists"));
            }
            catch { }
            System.Collections.Generic.List<DLCData> LCands0 = null;
            System.Collections.Generic.List<string> LCandPaths0 = null;
            if (listpaths != null)
            {
                LCands0 = new System.Collections.Generic.List<DLCData>();
                LCandPaths0 = new System.Collections.Generic.List<string>();

                System.Text.RegularExpressions.Regex checkComIni = new System.Text.RegularExpressions.Regex(@"default(?:\.[^\\]*)?\.[lr]st$", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                for (int k = 0; k < listpaths.Length; k++)
                {
                    if (!checkComIni.IsMatch(Path.GetFileName(listpaths[k])))
                    {
                        try
                        {
                            // 順序を逆転させないこと!
                            LCands0.Add(Program.OpenState(listpaths[k], false));
                            LCandPaths0.Add(listpaths[k]);
                        }
                        catch { }
                    }
                }
            }

            // 兄弟 DLC をすべて調べる
            //System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\\(\d+)([^\\]*)$"); // 1234 - DLC Name\1234.bcm を許す記述
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\\(\d+)$"); // 1234 - DLC Name\1234.bcm を許さない記述
            for (int i = 0; i < brothers.Length; i++)
            {
                var LCands = new System.Collections.Generic.List<DLCData>();
                System.Collections.Generic.List<string> LCandPaths = new System.Collections.Generic.List<string>();
                if (LCands0 != null && LCandPaths0 != null)
                {
                    LCands.AddRange(LCands0);
                    LCandPaths.AddRange(LCandPaths0);
                }

                //MessageBox.Show(((brothers[i] != SavePath) + ", " + ( regex.IsMatch(brothers[i]))));

                if (brothers[i] != SavePath && regex.IsMatch(brothers[i]))
                {

                    //string brotherBCM = regex.Replace(brothers[i], @"\$1$2\$1.bcm"); // 1234 - DLC Name\1234.bcm を許す記述
                    string brotherBCM = regex.Replace(brothers[i], @"\$1\$1.bcm"); // 1234 - DLC Name\1234.bcm を許さない記述
                    DLCData dlcData2;
                    //MessageBox.Show(brotherBCM);
                    try
                    {
                        dlcData2 = Program.OpenBCM_超原始的修正(brotherBCM);
                    }
                    catch
                    {
                        continue;
                    }
                    //MessageBox.Show(brothers[i] + "\n" + dlcData2.Chars.Count.ToString());

                    for (int j = 0; j < dlcData2.Chars.Count; j++)
                    {
                        string name;
                        string listpath = "";
                        string[] lsts = Directory.GetFiles(brothers[i], "*.lst");
                        string[] rsts = Directory.GetFiles(brothers[i], "*.rst");

                        //新しい配列を作る
                        string[] lists = new string[lsts.Length + rsts.Length];
                        //マージする配列のデータをコピーする
                        Array.Copy(lsts, lists, lsts.Length);
                        Array.Copy(rsts, 0, lists, lsts.Length, rsts.Length);

                        //MessageBox.Show(lists.Length.ToString());
                        if (lists.Length <= 0)
                        {
                            name = Path.GetFileName(brothers[i]);
                        }
                        else
                        {
                            var last = File.GetLastWriteTime(lists[0]);
                            name = Path.GetFileNameWithoutExtension(lists[0]);
                            for (int k = 1; k < lists.Length; k++)
                            {
                                var last2 = File.GetLastWriteTime(lists[k]);
                                if (last2 > last)
                                {
                                    last = last2;
                                    listpath = lists[k];
                                    name = Path.GetFileNameWithoutExtension(listpath);
                                }
                            }
                        }

                        //  Lists フォルダから name と listpath を作る
                        DLCData listdata = null;

                        if (listpath == "" && listpaths != null)
                        {

                            // break のためだけの while 文
                            bool found;

                            while (true)
                            {
                                // パスがドンピシャのものを探す
                                found = false;
                                for (int k = 0; k < LCands.Count; k++)
                                {
                                    if (LCands[k].SavePath == brothers[i])
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                                if (found)
                                {
                                    for (int k = 0; k < LCands.Count; k++)
                                    {
                                        if (LCands[k].SavePath != brothers[i])
                                        {
                                            LCands.RemoveAt(k);
                                            LCandPaths.RemoveAt(k);
                                            k--;
                                        }
                                    }
                                    break;
                                }

                                // リストファイルの path のファイル名が brothers[i] のプレフィックスに一致するものを探す
                                // 同時に最大一致文字数を取得

                                int maxlength = 0;
                                found = false;
                                for (int k = 0; k < LCands.Count; k++)
                                {
                                    string listpathfilename = Path.GetFileName(LCands[k].SavePath);
                                    string br = Path.GetFileName(brothers[i]);
                                    //MessageBox.Show(brothers[i] + ", \n" + Path.GetFileName(LCands[k].SavePath) + "\n" + maxlength);

                                    if (listpathfilename.Length > maxlength && listpathfilename == br.Substring(0, Math.Min(listpathfilename.Length, br.Length)))
                                    {
                                        //MessageBox.Show(brothers[i] + ", \n" + Path.GetFileName(LCands[k].SavePath) + "\n" + k);
                                        found = true;
                                        maxlength = listpathfilename.Length;
                                        //break;
                                    }
                                }

                                if (found)
                                {
                                    for (int k = 0; k < LCands.Count; k++)
                                    {
                                        string listpathfilename = Path.GetFileName(LCands[k].SavePath);
                                        string br = Path.GetFileName(brothers[i]);
                                        //MessageBox.Show(listpathfilename + "\n" + br + "\n" + k.ToString() + "\n" + LCandPaths[k]);
                                        if (!(listpathfilename.Length == maxlength && listpathfilename == br.Substring(0, Math.Min(listpathfilename.Length, br.Length))))
                                        {
                                            LCands.RemoveAt(k);
                                            LCandPaths.RemoveAt(k);
                                            k--;
                                        }
                                    }

                                    break;
                                }

                                break;
                            }

                            // もし何かしら見つかっていたらその中で更新日時が最も新しい物を設定
                            if (found && LCands.Count > 0)
                            {
                                listpath = LCandPaths[0];
                                name = Path.GetFileNameWithoutExtension(listpath);
                                listdata = LCands[0];
                                var last = File.GetLastWriteTime(listpath);
                                for (int k = 1; k < LCands.Count; k++)
                                {
                                    var last2 = File.GetLastWriteTime(LCandPaths[k]);
                                    if (last2 > last)
                                    {
                                        listpath = LCandPaths[k];
                                        name = Path.GetFileNameWithoutExtension(listpath);
                                        listdata = LCands[k];
                                        last = last2;
                                    }
                                }
                            }

                        }

                        // リストファイル内のコメントから設定する
                        if (listpath != "")
                        {
                            if (listdata == null)
                            {
                                listdata = Program.OpenState(listpath, false);
                            }

                            for (int k = 0; k < listdata.Chars.Count; k++)
                            {
                                if (dlcData2.Chars[j].CostumeSlot == listdata.Chars[k].CostumeSlot && dlcData2.Chars[j].ID == listdata.Chars[k].ID && listdata.Chars[k].Comment != "")
                                {
                                    name = listdata.Chars[k].Comment;
                                    while (name.Substring(name.Length - 1) == ",")
                                    {
                                        name = name.Substring(0, name.Length - 1);
                                    }
                                    break;
                                }
                            }
                        }

                        switch(Mode)
                        {
                            case 0:
                                var SlotOwnerTable = ((Program.SlotTable<string>)SlotOwnerInfo);
                                if (SlotOwnerTable[dlcData2.Chars[j]] == "")
                                {
                                    SlotOwnerTable[dlcData2.Chars[j]] = name;
                                }
                                else
                                {
                                    SlotOwnerTable[dlcData2.Chars[j]] += ", " + name;
                                }
                                break;
                            case 1:
                                var SlotOwnerPathAndDLCData= (Program.SlotTable<Tuple<string, DLCData,int>>)SlotOwnerInfo;

                                SlotOwnerPathAndDLCData[dlcData2.Chars[j]] = new Tuple<string, DLCData,int>(brotherBCM,dlcData2,j);

                                break;
            }

                        /*
                        if (BCMPathMode)
                        {
                            SlotOwnerTable[dlcData2.Chars[j]] = brotherBCM;
                        }
                        else
                        {
                            if (SlotOwnerTable[dlcData2.Chars[j]] == "")
                            {
                                SlotOwnerTable[dlcData2.Chars[j]] = name;
                            }
                            else
                            {
                                SlotOwnerTable[dlcData2.Chars[j]] += ", " + name;
                            }
                        }
                        */
                    }
                }
            }

            return SlotOwnerInfo;
        }
Exemplo n.º 36
0
 private static void RemoveOldBackupFiles(string sectionName)
 {
     string[] files = System.IO.Directory.GetFiles(RemoteConfigurationManager.instance.config.LocalApplicationFolder, sectionName + ".*.config");
     if (files.Length > RemoteConfigurationManager.instance.config.MaxBackupFiles)
     {
         System.Collections.Generic.List<string> lst = new System.Collections.Generic.List<string>(files);
         lst.Sort();
         while (lst.Count > RemoteConfigurationManager.instance.config.MaxBackupFiles)
         {
             System.IO.File.Delete(lst[0]);
             lst.RemoveAt(0);
         }
     }
 }