internal contractMission(string n, string active, string hidden, string vessels, bool asc, bool showActive, int sMode, bool Master)
 {
     name = n;
     activeString = active;
     hiddenString = hidden;
     vesselIDString = vessels;
     ascendingOrder = asc;
     showActiveMissions = showActive;
     masterMission = Master;
     orderMode = (sortClass)sMode;
     contractList = new Dictionary<Guid, contractUIObject>();
     activeMissionList = new List<Guid>();
     hiddenMissionList = new List<Guid>();
     currentVessels = new Dictionary<Guid, Vessel>();
 }
        private void AddGoodsInContract_Load(object sender, EventArgs e)
        {
            var myBinding  = new BasicHttpBinding();
            var Uri        = new Uri(ConfigurationManager.ConnectionStrings["WcfConnectionString"].ConnectionString);
            var myEndpoint = new EndpointAddress(Uri);

            myChannelFactory = new ChannelFactory <IService>(myBinding, myEndpoint);

            this.service = myChannelFactory.CreateChannel();
            service.open();
            this.listView1.View = View.List;
            List <Goods>      goods = service.getAllGoods().ToList();
            sortClass <Goods> sort  = new sortClass <Goods>();

            goods.Sort(sort);
            this.comboGoods.Items.AddRange(goods.ToArray <Goods>());
            this.comboBoxContracts.Items.AddRange(service.getAllContracts().ToArray());
        }
Example #3
0
    public void SortByListNum(Dictionary <string, List <Transform> > Dic)
    {
        List <sortClass> sortList = new List <sortClass>();

        foreach (var item in Dic)
        {
            sortClass sort = new sortClass();
            sort.key   = item.Key;
            sort.value = item.Value;
            sortList.Add(sort);
        }
        sortList.Sort(delegate(sortClass a, sortClass b)
        {
            return(a.value.Count > b.value.Count ? 1 : 0);
        });

        Dic.Clear();
        for (int i = 0; i < sortList.Count; i++)
        {
            Dic.Add(sortList[i].key, sortList[i].value);
        }
    }
        //Function to sort the list based on several criteria
        private List<Guid> sortList(List<Guid> gID, sortClass s, bool Asc)
        {
            List<contractUIObject> cL = new List<contractUIObject>();
            //Only add non-pinned contracts to the sort list
            foreach (Guid id in gID)
            {
                contractUIObject cC = currentMission.getContract(id);
                if (cC != null)
                {
                    if (cC.Order == null)
                        cL.Add(cC);
                }
            }
            switch (s)
            {
                case sortClass.Expiration:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.Duration.CompareTo(b.Container.Duration), a.Container.Title.CompareTo(b.Container.Title)));
                    break;
                case sortClass.Acceptance:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.Contract.DateAccepted.CompareTo(b.Container.Contract.DateAccepted), a.Container.Title.CompareTo(b.Container.Title)));
                    break;
                case sortClass.Reward:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.TotalReward.CompareTo(b.Container.TotalReward), a.Container.Title.CompareTo(b.Container.Title)));
                    break;
                case sortClass.Difficulty:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.Contract.Prestige.CompareTo(b.Container.Contract.Prestige), a.Container.Title.CompareTo(b.Container.Title)));
                    break;
                case sortClass.Planet:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.TargetPlanet.CompareTo(b.Container.TargetPlanet), a.Container.Title.CompareTo(b.Container.Title)));
                    break;
                case sortClass.Type:
                    cL.Sort((a, b) => RUIutils.SortAscDescPrimarySecondary(Asc, a.Container.Contract.GetType().Name.CompareTo(b.Container.Contract.GetType().Name), a.Container.Title.CompareTo(b.Container.Title)));
                    cL = typeSort(cL, Asc);
                    break;
            }
            gID.Clear();

            //Add pinned contracts to the beginning of the list
            if (pinnedList.Count > 0)
                gID.AddRange(pinnedList);

            //Next add the sorted contracts
            foreach (contractUIObject cC in cL)
                gID.Add(cC.Container.Contract.ContractGuid);

            return gID;
        }