Ejemplo n.º 1
0
        public void AddPackage()
        {
            var ret = new SetPackageItemViewModel()
            {
                ItemSource = PackageItems, Parent = this
            };

            PackageItems.Add(ret);
            SelectedPackage = ret;
            RaisePropertyChanged("SelectedPackage");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add package parameter for a project
        /// </summary>
        /// <param name="name">parameter's name</param>
        /// <param name="type">parameter's type</param>
        /// <param name="pkgStreamName">package stream name</param>
        /// <returns>parameter object</returns>
        public Parameter AddPackageParameter(string name, TypeCode type, string pkgStreamName)
        {
            Debug.Assert(!string.IsNullOrEmpty(name), @"The parameter name should not be nullable.");
            Debug.Assert(!string.IsNullOrEmpty(pkgStreamName), @"The package stream name should not be nullable.");

            //if pacakge exists, add the parameter, else throw exception
            if (PackageItems.IndexOf(pkgStreamName) > -1)
            {
                Parameter param = PackageItems[pkgStreamName].Package.Parameters.Add(name, type);
                return(param);
            }
            else
            {
                throw new ApplicationException("The specified package doesn't exist in the project");
            }
        }
Ejemplo n.º 3
0
        protected override void UnpackResponse()
        {
            base.UnpackResponse();

            // Create the streams we will be reading from.
            var responseStream = new MemoryStream(m_responsePayload);
            var responseReader = new BinaryReader(responseStream, Encoding.Unicode);

            // Check the response length.
            if (responseStream.Length < MinResponseMessageLength)
            {
                throw new MessageWrongSizeException("Get Package Item");
            }

            // Try to unpack the data.
            try
            {
                // Seek past return code.
                responseReader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin);

                // Get the count of Packages.
                var packageItemCount = responseReader.ReadUInt16();

                // Clear the Package Item array.
                PackageItems.Clear();

                // Get all the Package Items
                for (ushort x = 0; x < packageItemCount; x++)
                {
                    var packageItem = new PackageItem
                    {
                        PackageId       = responseReader.ReadInt32(),
                        ChargeDeviceFee = responseReader.ReadBoolean()
                    };

                    // Package Name
                    var stringLen = responseReader.ReadUInt16();
                    packageItem.PackageName = new string(responseReader.ReadChars(stringLen));

                    // Receipt Text
                    stringLen = responseReader.ReadUInt16();
                    packageItem.ReceiptText = new string(responseReader.ReadChars(stringLen));

                    // Package Price
                    stringLen = responseReader.ReadUInt16();
                    packageItem.PackagePrice = new string(responseReader.ReadChars(stringLen));

                    //read override
                    packageItem.OverrideValidation = responseReader.ReadBoolean();

                    //read override quantity
                    packageItem.ValidationQuantity = responseReader.ReadInt32();

                    //read if requires validation to purchase
                    packageItem.RequiresValidation = responseReader.ReadBoolean();

                    PackageItems.Add(packageItem);
                }
            }
            catch (EndOfStreamException e)
            {
                throw new MessageWrongSizeException("Get Package Item", e);
            }
            catch (Exception e)
            {
                throw new ServerException("Get Package Item", e);
            }

            // Close the streams.
            responseReader.Close();
        }
Ejemplo n.º 4
0
        private void _updateButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedPackages = PackageItems.Where(p => p.Selected).ToArray();

            UpdateButtonClicked(selectedPackages);
        }
Ejemplo n.º 5
0
    void LoadXML()
    {
        equipsLoaded.Clear();

        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(filepath);

        //        XmlElement root = xmlDoc.DocumentElement;
        //        Debug.Log("Root : " + root.Name);

        // XPath的开头是一个斜线代表这是绝对路径,可以选出所有路径符合这个模式的元素。
        XmlNode     node      = xmlDoc.SelectSingleNode("/道具列表/装备");
        XmlNodeList pNodeList = node.ChildNodes;

        foreach (var item in pNodeList)
        {
            XmlElement element = item as XmlElement;
            if (element != null)
            {
                PackageItems equip = new PackageItems();
                equip.type = int.Parse(element.GetAttribute("type"));
                equip.name = element.Name;
                //获取道具下的各个属性
                XmlNodeList List = element.ChildNodes;
                foreach (var info in List)
                {
                    XmlElement infoElm = info as XmlElement;
                    if (infoElm.Name == "冷却")
                    {
                        equip.coldTime = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "买价")
                    {
                        equip.buyPrice = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "卖价")
                    {
                        equip.sellPrice = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "攻击距离")
                    {
                        equip.range = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "伤害")
                    {
                        equip.damage = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "冲击")
                    {
                        equip.hitback = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "健康值消耗")
                    {
                        equip.healthUse = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "子弹特效名")
                    {
                        equip.bulletEffectName = infoElm.InnerText;
                    }
                    else if (infoElm.Name == "魔法特效名")
                    {
                        equip.magicEffectName = infoElm.InnerText;
                    }
                    else if (infoElm.Name == "击中特效名")
                    {
                        equip.hitEffectName = infoElm.InnerText;
                    }
                    else if (infoElm.Name == "后坐力")
                    {
                        equip.playerHitBack = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "发射物飞行速度")
                    {
                        equip.bulletSpeed = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "爆炸半径")
                    {
                        equip.exploadRadius = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "爆炸伤害")
                    {
                        equip.explodeDamage = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "准备时长")
                    {
                        equip.prepareTime = float.Parse(infoElm.InnerText);
                    }
                    else if (infoElm.Name == "是否可以穿墙")
                    {
                        equip.canCrossWall = int.Parse(infoElm.InnerText);
                    }
                }
                //equip.buyPrice = int.Parse(element.InnerText);
                equipsLoaded.Add(equip);
            }
        }
    }
Ejemplo n.º 6
0
        public void RefreshAllPackages()
        {
            PackageItems.Clear();

            var repo    = PackageRepositoryFactory.Default.CreateRepository(PackagesDir);
            var pkgList = repo.GetPackages();

            var pkgSet = new SortedSet <string>();

            foreach (var pkg in pkgList)
            {
                //通过set去重
                pkgSet.Add(pkg.Id);
            }

            Dictionary <string, IPackage> installedPkgDict = new Dictionary <string, IPackage>();

            var packageManager = new PackageManager(repo, InstalledPackagesDir);

            foreach (IPackage pkg in packageManager.LocalRepository.GetPackages())
            {
                installedPkgDict[pkg.Id] = pkg;
            }

            foreach (var name in pkgSet)
            {
                var item = new PackageItem();
                item.Name = name;

                var version = repo.FindPackagesById(name).Max(p => p.Version);
                item.Version = version.ToString();

                var pkgNameList = repo.FindPackagesById(name);
                foreach (var i in pkgNameList)
                {
                    item.VersionList.Add(i.Version.ToString());
                }

                bool isNeedUpdate = false;
                if (installedPkgDict.ContainsKey(item.Name))
                {
                    var installedVer = installedPkgDict[item.Name].Version;
                    if (version > installedVer)
                    {
                        isNeedUpdate = true;
                    }
                }
                else
                {
                    isNeedUpdate = true;
                }
                item.IsNeedUpdate = isNeedUpdate;

                var pkg = repo.FindPackage(name, version);
                item.Package = pkg;
                var    publishedTime = pkg.Published.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                string toolTip       = ResxIF.GetString("PackageToolTip"); //"名称:{0}\r\n版本:{1}\r\n发布说明:{2}\r\n项目描述:{3}\r\n发布时间:{4}"
                item.ToolTip = string.Format(toolTip, item.Name, item.Version, pkg.ReleaseNotes, pkg.Description, (publishedTime == null ? "未知" : publishedTime));

                if (IsWorkflowRunning && item.Name == WorkflowRunningName)
                {
                    item.IsRunning = true;//如果当前该包工程已经在运行,则要设置IsRunning
                }

                PackageItems.Add(item);
            }


            doSearch();
        }