예제 #1
0
파일: theme.cs 프로젝트: scutsky/iyuewan
       /// <summary>
       /// 添加联系方式
       /// </summary>
       /// <param name="model"></param>
       public void  Add(Spread.Model.theme model)
       {
           StringBuilder strSql = new StringBuilder();
           strSql.Append("insert into ContactUs(");
           strSql.Append("Contacts,Postal,phone,Tel,fax,Mail,Adress)");
           strSql.Append(" values (");
           strSql.Append("@Contacts,@Postal,@phone,@Tel,@fax,@Mail,@Adress)");
           SqlParameter[] parameters = {
					new SqlParameter("@Contacts", SqlDbType.NVarChar,50),
					new SqlParameter("@Postal", SqlDbType.NVarChar,20),
					new SqlParameter("@phone", SqlDbType.NVarChar,30),
					new SqlParameter("@Tel", SqlDbType.NVarChar,20),
                    new SqlParameter("@fax", SqlDbType.NVarChar,20),
					new SqlParameter("@Mail", SqlDbType.NVarChar,50),
					new SqlParameter("@Adress", SqlDbType.NVarChar,1000),};

           parameters[0].Value = model.Contacts;
           parameters[1].Value = model.Postal;
           parameters[2].Value = model.Phone;
           parameters[3].Value = model.Tel;
           parameters[4].Value = model.fax;
           parameters[5].Value = model.Mail;
           parameters[6].Value = model.Adress;

           DbHelper.ExecuteSql(strSql.ToString(), parameters);

       }
예제 #2
0
파일: Menu.cs 프로젝트: scutsky/iyuewan
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Spread.Model.Menu model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [Menu](");
            strSql.Append("MenuID,Title,ParentId,ClassList,ClassLayer,ClassOrder,IsShow,IsLock,IsMenu)");
            strSql.Append(" values (");
            strSql.Append("@MenuID ,@Title,@ParentId,@ClassList,@ClassLayer,@ClassOrder,@IsShow,@IsLock,@IsMenu)");
            SqlParameter[] parameters = {
					new SqlParameter("@MenuID", SqlDbType.NVarChar,100),
                    new SqlParameter("@Title", SqlDbType.NVarChar,50),
					new SqlParameter("@ParentId", SqlDbType.Int,4),
					new SqlParameter("@ClassList", SqlDbType.NVarChar,300),
					new SqlParameter("@ClassLayer", SqlDbType.Int,4),
					new SqlParameter("@ClassOrder", SqlDbType.Int,4),
                    new SqlParameter("@IsShow", SqlDbType.Bit),
                    new SqlParameter("@IsLock",SqlDbType.Bit),
					new SqlParameter("@IsMenu", SqlDbType.Bit)};
            parameters[0].Value = model.MenuID;
            parameters[1].Value = model.Title;
            parameters[2].Value = model.ParentId;
            parameters[3].Value = model.ClassList;
            parameters[4].Value = model.ClassLayer;
            parameters[5].Value = model.ClassOrder;
            parameters[6].Value = model.IsShow;
            parameters[7].Value = model.IsLock;
            parameters[8].Value = model.IsMenu;

            DbHelper.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #3
0
파일: Tag.cs 프로젝트: scutsky/iyuewan
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Spread.Model.Tag model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Tag(");
            strSql.Append("Name,TagCategoryID,ModelType,DaySearchCount,YesterdaySearchCount,TotalSearchCount,UserID,UserName,CountTime)");
            strSql.Append(" values (");
            strSql.Append("@Name,@TagCategoryID,@ModelType,@DaySearchCount,@YesterdaySearchCount,@TotalSearchCount,@UserID,@UserName,@CountTime)");
            SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@TagCategoryID", SqlDbType.Int,4),
					new SqlParameter("@ModelType", SqlDbType.Int,4),
					new SqlParameter("@DaySearchCount", SqlDbType.Int,4),				
					new SqlParameter("@YesterdaySearchCount", SqlDbType.Int,4),
					new SqlParameter("@TotalSearchCount", SqlDbType.Int,4),
					new SqlParameter("@UserID", SqlDbType.Int,4),					
					new SqlParameter("@UserName", SqlDbType.NVarChar,50),                 
					new SqlParameter("@CountTime", SqlDbType.DateTime)};
            parameters[0].Value = model.Name;
            parameters[1].Value = model.TagCategoryId;
            parameters[2].Value = model.ModelType;
            parameters[3].Value = model.DaySearchCount;
            parameters[4].Value = model.YesterdaySearchCount;//5_1_a_s_p_x
            parameters[5].Value = model.TotalSearchCount;
            parameters[6].Value = model.UserID;
            parameters[7].Value = model.UserName;
            parameters[8].Value = model.CountTime;

            DbHelper.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Spread.Model.TagCategory model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update TagCategory set ");
            strSql.Append("[Name]=@Name,");
            strSql.Append("[Desc]=@Desc ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,20),
					new SqlParameter("@Desc", SqlDbType.NVarChar,50),
					new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Desc;
            parameters[2].Value = model.ID;

            int rows = DbHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #5
0
      /// <summary>
      /// 增加一条数据
      /// </summary>
      public void Add(Spread.Model.Article_type model)
      {
          StringBuilder strSql = new StringBuilder();
          strSql.Append("insert into Article_type(");
          strSql.Append("Title,ParentId,ClassList,ClassLayer,ClassOrder,PageUrl,KindId)");
          strSql.Append(" values (");
          strSql.Append("@Title,@ParentId,@ClassList,@ClassLayer,@ClassOrder,@PageUrl,@KindId)");
          SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.NVarChar,50),
					new SqlParameter("@ParentId", SqlDbType.Int,4),
					new SqlParameter("@ClassList", SqlDbType.NVarChar,300),
					new SqlParameter("@ClassLayer", SqlDbType.Int,4),
					new SqlParameter("@ClassOrder", SqlDbType.Int,4),
                    new SqlParameter("@PageUrl",SqlDbType.NVarChar,250),
					new SqlParameter("@KindId", SqlDbType.Int,4)};
                    

          parameters[0].Value = model.Title;
          parameters[1].Value = model.ParentId;
          parameters[2].Value = model.ClassList;
          parameters[3].Value = model.ClassLayer;
          parameters[4].Value = model.ClassOrder;
          parameters[5].Value = model.PageUrl;
          parameters[6].Value = model.KindId;
         
       

          DbHelper.ExecuteSql(strSql.ToString(), parameters);
      }
예제 #6
0
파일: Adbanner.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Spread.Model.Adbanner model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Adbanner(");
			strSql.Append("Aid,Title,StartTime,EndTime,AdUrl,LinkUrl,AdRemark,IsLock,AddTime)");
			strSql.Append(" values (");
			strSql.Append("@Aid,@Title,@StartTime,@EndTime,@AdUrl,@LinkUrl,@AdRemark,@IsLock,@AddTime)");
			SqlParameter[] parameters = {
					new SqlParameter("@Aid", SqlDbType.Int,4),
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@StartTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@AdUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@LinkUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@AdRemark", SqlDbType.NVarChar,0),
					new SqlParameter("@IsLock", SqlDbType.Bit),
					new SqlParameter("@AddTime", SqlDbType.DateTime)};
			parameters[0].Value = model.Aid;
			parameters[1].Value = model.Title;
			parameters[2].Value = model.StartTime;
			parameters[3].Value = model.EndTime;
			parameters[4].Value = model.AdUrl;
			parameters[5].Value = model.LinkUrl;
			parameters[6].Value = model.AdRemark;
			parameters[7].Value = model.IsLock;
			parameters[8].Value = model.AddTime;

			DbHelper.ExecuteSql(strSql.ToString(),parameters);
		}
예제 #7
0
파일: Links.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Spread.Model.Links model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Links(");
			strSql.Append("Title,UserName,UserTel,UserMail,WebUrl,ImgUrl,IsImage,IsRed,IsLock,SortId,AddTime)");
			strSql.Append(" values (");
            strSql.Append("@Title,@UserName,@UserTel,@UserMail,@WebUrl,@ImgUrl,@IsImage,@IsRed,@IsLock,@SortId,@AddTime)");
			SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@UserName", SqlDbType.NVarChar,20),
					new SqlParameter("@UserTel", SqlDbType.NVarChar,30),
					new SqlParameter("@UserMail", SqlDbType.NVarChar,30),
					new SqlParameter("@WebUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@ImgUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@IsImage", SqlDbType.Int,4),
                    new SqlParameter("@IsRed", SqlDbType.Int,4),
					new SqlParameter("@IsLock", SqlDbType.Int,4),
					new SqlParameter("@SortId", SqlDbType.Int,4),
					new SqlParameter("@AddTime", SqlDbType.DateTime)};
			parameters[0].Value = model.Title;
			parameters[1].Value = model.UserName;
			parameters[2].Value = model.UserTel;
			parameters[3].Value = model.UserMail;
			parameters[4].Value = model.WebUrl;
			parameters[5].Value = model.ImgUrl;
			parameters[6].Value = model.IsImage;
            parameters[7].Value = model.IsRed;
			parameters[8].Value = model.IsLock;
			parameters[9].Value = model.SortId;
			parameters[10].Value = model.AddTime;

            DbHelper.ExecuteSql(strSql.ToString(), parameters);
		}
예제 #8
0
        public TransformState(int id, Vector2D value)
        {
            Blobs = new Spread<Blob>();
            PBlobs = new Spread<Blob>();

            Reset(id, value);
        }
예제 #9
0
		public void Evaluate(int spreadMax)
		{
			if (!FPinInFilename.IsChanged || FPinInFilename.SliceCount < 1) return;

			FPinOutImage.SliceCount = spreadMax;
			FPinOutStatus.SliceCount = spreadMax;
			FImages.SliceCount = spreadMax;

			for (int i = 0; i < spreadMax; i++)
			{
				if(FPinInFilename[i] == FFilename[i]) continue;

				FPinOutImage[i] = new ImageRGB();
				
				try
				{
					FImages[i] = new ImageRGB();
					FPinOutImage[i] = FImages[i];
					Image<Bgr, byte> image = new Image<Bgr, byte>(FPinInFilename[i]);

					FImages[i].SetImage(image);

					FPinOutStatus[i] = "OK";
				}
				catch
				{
					FPinOutStatus[i] = "Failed";
				}
			}

			FFilename = (Spread<string>) FPinInFilename.Clone();
		}
예제 #10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Spread.Model.Advertising model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Advertising(");
            strSql.Append("Title,AdType,AdRemark,AdNum,AdPrice,AdWidth,AdHeight,AdTarget)");
            strSql.Append(" values (");
            strSql.Append("@Title,@AdType,@AdRemark,@AdNum,@AdPrice,@AdWidth,@AdHeight,@AdTarget)");
            SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@AdType", SqlDbType.Int,4),
					new SqlParameter("@AdRemark", SqlDbType.NVarChar,0),
					new SqlParameter("@AdNum", SqlDbType.Int,4),
					new SqlParameter("@AdPrice", SqlDbType.Decimal,9),
					new SqlParameter("@AdWidth", SqlDbType.Int,4),
					new SqlParameter("@AdHeight", SqlDbType.Int,4),
					new SqlParameter("@AdTarget", SqlDbType.NVarChar,50)};
            parameters[0].Value = model.Title;
            parameters[1].Value = model.AdType;
            parameters[2].Value = model.AdRemark;
            parameters[3].Value = model.AdNum;
            parameters[4].Value = model.AdPrice;
            parameters[5].Value = model.AdWidth;
            parameters[6].Value = model.AdHeight;
            parameters[7].Value = model.AdTarget;

            DbHelper.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #11
0
파일: Products.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Spread.Model.Products model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Products(");
            strSql.Append("Title,Brand,ClassId,Sort,AddTime,Url,ImgUrl,AddUser,Keyword,IsTop,IsLock)");
			strSql.Append(" values (");
            strSql.Append("@Title,@Brand,@ClassId,@Sort,@AddTime,@Url,@ImgUrl,@AddUser,@Keyword,@IsTop,@IsLock)");
			SqlParameter[] parameters = {
                    new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@Brand", SqlDbType.NVarChar,100),
					new SqlParameter("@ClassId", SqlDbType.Int,4),
                    new SqlParameter("@Sort", SqlDbType.Int,4),
					new SqlParameter("@AddTime", SqlDbType.DateTime),
                    new SqlParameter("@Url", SqlDbType.NVarChar,200),
                    new SqlParameter("@ImgUrl", SqlDbType.NVarChar,100),
                    new SqlParameter("@AddUser", SqlDbType.NVarChar,50),
                    new SqlParameter("@Keyword", SqlDbType.NVarChar,500),
                    new SqlParameter("@IsTop", SqlDbType.Bit),
                    new SqlParameter("@IsLock", SqlDbType.Bit)};
            parameters[0].Value = model.Title;
			parameters[1].Value = model.Brand;
			parameters[2].Value = model.ClassId;
            parameters[3].Value = model.Sort;
			parameters[4].Value = model.AddTime;
            parameters[5].Value = model.Url;
            parameters[6].Value = model.ImgUrl;
            parameters[7].Value = model.AddUser;
            parameters[8].Value = model.Keyword;
            parameters[9].Value = model.IsTop;
            parameters[10].Value = model.IsLock;
            DbHelper.ExecuteSql(strSql.ToString(), parameters);
		}
예제 #12
0
		public void ReadIntoSpread(CancellationToken ct)
		{
			var channels = FAudioFile.WaveFormat.Channels;
			long samples = (long)Math.Round(FAudioFile.TotalTime.TotalSeconds * FAudioFile.WaveFormat.SampleRate);
			long startSample = 0;
			if (Loop) 
			{
				startSample = (long)(StartTime * FAudioFile.WaveFormat.SampleRate);
				samples = (long)((EndTime - StartTime) * FAudioFile.WaveFormat.SampleRate);
			}
			var localSpreadCount = (int)Math.Min(SpreadCount, samples);
			if (ToMono) 
			{
				WaveFormSpread.SliceCount = 1;
				WaveFormSpread[0] = new Spread<double>(localSpreadCount);
			}
			else 
			{
				WaveFormSpread.SliceCount = channels;
				for (int i = 0; i < channels; i++) 
				{
					WaveFormSpread[i] = new Spread<double>(localSpreadCount);
				}
			}
			
			int blockSize = (int)(samples / localSpreadCount);
			FAudioFile.Position = startSample * channels * 4;
			var bufferSize = blockSize * channels;
			var buffer = new float[bufferSize];
			var maxValue = 0.0f;
			var outputBuffers = WaveFormSpread.Select(s => s.Stream.Buffer).ToArray();
			for (int slice = 0; slice < localSpreadCount; slice++) 
			{
				//read one interleaved block
				var samplesRead = FAudioFile.Read(buffer, 0, bufferSize);
				//split into channels and do the max
				for (int channel = 0; channel < channels; channel++) 
				{
					maxValue = MinValue;
					for (int i = 0; i < samplesRead; i += channels)
					{
						maxValue = Math.Max(maxValue, Math.Abs(buffer[i + channel]));
					}
					if (ToMono) 
					{
						outputBuffers[0][slice] = Math.Max(maxValue, outputBuffers[0][slice]);
					}
					else
					{
						outputBuffers[channel][slice] = maxValue;
					}
					ct.ThrowIfCancellationRequested();
				}
			}
		}
예제 #13
0
파일: Goods.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Spread.Model.Goods model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Goods(");
            strSql.Append("Title,Form,ClassId,ImgUrl,IsMsg,IsTop,IsRed,IsHot,IsSlide,IsLock,AddTime,Zhaiyao,GType,GFactory,GBrand,Code1,Code2,Bak1,Bak2,Bak3,Bak4,Bak5)");
			strSql.Append(" values (");
            strSql.Append("@Title,@Form,@ClassId,@ImgUrl,@IsMsg,@IsTop,@IsRed,@IsHot,@IsSlide,@IsLock,@AddTime,@Zhaiyao,@GType,@GFactory,@GBrand,@Code1,@Code2,@Bak1,@Bak2,@Bak3,@Bak4,@Bak5)");
            SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@Form", SqlDbType.NVarChar,50),
					new SqlParameter("@ClassId", SqlDbType.Int,4),
					new SqlParameter("@ImgUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@IsMsg", SqlDbType.Bit),
					new SqlParameter("@IsTop", SqlDbType.Bit),
					new SqlParameter("@IsRed", SqlDbType.Bit),
					new SqlParameter("@IsHot", SqlDbType.Bit),
					new SqlParameter("@IsSlide", SqlDbType.Bit),
					new SqlParameter("@IsLock", SqlDbType.Bit),
					new SqlParameter("@AddTime", SqlDbType.DateTime),
                    new SqlParameter("@Zhaiyao", SqlDbType.NVarChar,1000),
                    new SqlParameter("@GType", SqlDbType.NVarChar,50),
                    new SqlParameter("@GFactory", SqlDbType.NVarChar,50),
                    new SqlParameter("@GBrand", SqlDbType.NVarChar,50),
                    new SqlParameter("@Code1", SqlDbType.NVarChar,50),
                    new SqlParameter("@Code2", SqlDbType.NVarChar,50),
                    new SqlParameter("@Bak1", SqlDbType.NVarChar,50),
                    new SqlParameter("@Bak2", SqlDbType.NVarChar,50),
                    new SqlParameter("@Bak3", SqlDbType.NVarChar,50),
                    new SqlParameter("@Bak4", SqlDbType.NVarChar,50),
                    new SqlParameter("@Bak5", SqlDbType.NVarChar,50)};
			parameters[0].Value = model.Title;
			parameters[1].Value = model.Form;
			parameters[2].Value = model.ClassId;
			parameters[3].Value = model.ImgUrl;
			parameters[4].Value = model.IsMsg;
			parameters[5].Value = model.IsTop;
			parameters[6].Value = model.IsRed;
			parameters[7].Value = model.IsHot;
			parameters[8].Value = model.IsSlide;
			parameters[9].Value = model.IsLock;
			parameters[10].Value = model.AddTime;
            parameters[11].Value = model.Zhaiyao;
            parameters[12].Value = model.GType;
            parameters[13].Value = model.GFactory;
            parameters[14].Value = model.GBrand;
            parameters[15].Value = model.Code1;
            parameters[16].Value = model.Code2;
            parameters[17].Value = model.Bak1;
            parameters[18].Value = model.Bak2;
            parameters[19].Value = model.Bak3;
            parameters[20].Value = model.Bak4;
            parameters[21].Value = model.Bak5;
            DbHelper.ExecuteSql(strSql.ToString(), parameters);
		}
		public SimpleTweener()
		{
			FStart = new Spread<int>();
			FValue = new Spread<double>();
			
			FStartDate = new Spread<DateTime>();
			
			FPreviousValue = new Spread<double>();
			FNextValue = new Spread<double>();
			
			FFinished = new Spread<bool>();
		}
예제 #15
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(Spread.Model.TagCategory model)
 {
     if (model.ID <= 0)
     {
         StringBuilder strSql = new StringBuilder();               
         strSql.Append("insert into TagCategory(");
         strSql.Append("[Name],[Desc])");
         strSql.Append(" values (");               
         strSql.Append("'" + model.Name + "','" + model.Desc + "')");
        
         DbHelper.ExecuteSql(strSql.ToString());
     }
     else { Update(model);}
 }
예제 #16
0
		public void Process(ISpread<string> input, ISpread<string> separator, int spreadMax)
		{
			Output.SliceCount = spreadMax;

			for (int i = 0; i < spreadMax; i++)
			{
				string[] strings = input[i].Split(separator[i].ToArray());

				if (!strings.Any()) continue;
				
				if(Output[i] == null) Output[i] = new Spread<string>(1);

				Output[i].AssignFrom(strings);
			}
		}
예제 #17
0
파일: Protocol.cs 프로젝트: scutsky/iyuewan
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Spread.Model.Protocol model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Protocol(");
            strSql.Append("Title,Author,Form,ClassId,ImgUrl,Content,Click,IsMsg,IsTop,IsRed,IsHot,IsSlide,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Title,@Author,@Form,@ClassId,@ImgUrl,@Content,@Click,@IsMsg,@IsTop,@IsRed,@IsHot,@IsSlide,@AddTime)");
            SqlParameter[] parameters = {
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@Author", SqlDbType.NVarChar,50),
					new SqlParameter("@Form", SqlDbType.NVarChar,500),
					
					new SqlParameter("@ClassId", SqlDbType.Int,4),
					new SqlParameter("@ImgUrl", SqlDbType.NVarChar,250),
					
					new SqlParameter("@Content", SqlDbType.NVarChar,100000),
					new SqlParameter("@Click", SqlDbType.Bit),
					new SqlParameter("@IsMsg", SqlDbType.Bit),
					new SqlParameter("@IsTop", SqlDbType.Bit),
					new SqlParameter("@IsRed", SqlDbType.Bit),
					new SqlParameter("@IsHot", SqlDbType.Bit),
					new SqlParameter("@IsSlide", SqlDbType.Bit),
				
					new SqlParameter("@AddTime", SqlDbType.DateTime)};



            parameters[0].Value = model.Title;
            parameters[1].Value = model.Author;
            parameters[2].Value = model.Form;
            parameters[3].Value = model.ClassId;
            parameters[4].Value = model.ImgUrl;

            parameters[5].Value = model.Content;
            parameters[6].Value = model.Click;
            parameters[7].Value = model.IsMsg;
            parameters[8].Value = model.IsTop;
            parameters[9].Value = model.IsRed;
            parameters[10].Value = model.IsHot;
            parameters[11].Value = model.IsSlide;

            parameters[12].Value = model.AddTime;



            DbHelper.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #18
0
		void UpdateVertices()
		{
			FPosition.SliceCount = FPinInInput.SliceCount;

			int i = 0, j;
			foreach (var line in FPinInInput)
			{
				FPosition[i] = new Spread<Vector3d>(line.SliceCount);

				j = 0;
				foreach (var vertex in line)
				{
					FPosition[i][j] = UMath.ToGL(vertex);
					j++;
				}
				i++;
			}
		}
예제 #19
0
파일: Pgame.cs 프로젝트: scutsky/iyuewan
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Spread.Model.Pgame model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Pgame(");
            strSql.Append("Name,version,Platform,Status,UpdateType,UpdateDate,OnTime,FirstLetter,IsLock,Bak1,Bak2,Bak3)");
            strSql.Append(" values (");
            strSql.Append("@Name,@version,@Platform,@Status,@UpdateType,@UpdateDate,@OnTime,@FirstLetter,@IsLock,@Bak1,@Bak2,@Bak3)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@version", SqlDbType.NVarChar,50),
					new SqlParameter("@Platform", SqlDbType.NVarChar,50),
					new SqlParameter("@Status", SqlDbType.NVarChar,50),
					new SqlParameter("@UpdateType", SqlDbType.NVarChar,50),
					new SqlParameter("@UpdateDate", SqlDbType.DateTime),
					new SqlParameter("@OnTime", SqlDbType.DateTime),
					new SqlParameter("@FirstLetter", SqlDbType.NVarChar,50),
					new SqlParameter("@IsLock", SqlDbType.Bit,1),
					new SqlParameter("@Bak1", SqlDbType.NVarChar,50),
					new SqlParameter("@Bak2", SqlDbType.NVarChar,50),
					new SqlParameter("@Bak3", SqlDbType.NVarChar,50)};
            parameters[0].Value = model.Name;
            parameters[1].Value = model.version;
            parameters[2].Value = model.Platform;
            parameters[3].Value = model.Status;
            parameters[4].Value = model.UpdateType;
            parameters[5].Value = model.UpdateDate;
            parameters[6].Value = model.OnTime;
            parameters[7].Value = model.FirstLetter;
            parameters[8].Value = model.IsLock;
            parameters[9].Value = model.Bak1;
            parameters[10].Value = model.Bak2;
            parameters[11].Value = model.Bak3;

            object obj = DbHelper.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
예제 #20
0
파일: contant.cs 프로젝트: scutsky/iyuewan
       /// <summary>
       /// 添加企业信息
       /// </summary>
       /// <param name="model"></param>
       public void Add(Spread.Model.contant model)
       {
           StringBuilder strSql = new StringBuilder();
           strSql.Append("insert into contant(");
           strSql.Append("ContName,ContAddres,ContImage,Contcont)");
           strSql.Append(" values (");
           strSql.Append("@ContName,@ContAddres,@ContImage,@Contcont)");
           SqlParameter[] parameters = {
					new SqlParameter("@ContName", SqlDbType.NVarChar,30),
					new SqlParameter("@ContAddres", SqlDbType.NVarChar,50),
					new SqlParameter("@ContImage", SqlDbType.NVarChar,250),
					new SqlParameter("@Contcont", SqlDbType.NVarChar,12500)};

           parameters[0].Value = model.ContName;
           parameters[1].Value = model.ContAddres;
           parameters[2].Value = model.ContImage;
           parameters[3].Value = model.Contcont;

           DbHelper.ExecuteSql(strSql .ToString(),parameters);
       }
예제 #21
0
		protected override void Update()
		{
			if (FPinInInput.IsChanged)
				return;

			FPosition.SliceCount = FPinInInput.SliceCount;

			int i=0, j;
			foreach (var line in FPinInInput)
			{
				FPosition[i] = new Spread<Vector3d>(line.SliceCount);

				j=0;
				foreach (var vertex in line)
				{
					FPosition[i][j] = UMath.ToGL(vertex);
					j++;
				}
				i++;
			}
		}
예제 #22
0
파일: Adbanner.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public void Update(Spread.Model.Adbanner model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Adbanner set ");
			strSql.Append("Aid=@Aid,");
			strSql.Append("Title=@Title,");
			strSql.Append("StartTime=@StartTime,");
			strSql.Append("EndTime=@EndTime,");
			strSql.Append("AdUrl=@AdUrl,");
			strSql.Append("LinkUrl=@LinkUrl,");
			strSql.Append("AdRemark=@AdRemark,");
			strSql.Append("IsLock=@IsLock,");
			strSql.Append("AddTime=@AddTime");
			strSql.Append(" where Id=@Id ");
			SqlParameter[] parameters = {
					new SqlParameter("@Aid", SqlDbType.Int,4),
					new SqlParameter("@Title", SqlDbType.NVarChar,100),
					new SqlParameter("@StartTime", SqlDbType.DateTime),
					new SqlParameter("@EndTime", SqlDbType.DateTime),
					new SqlParameter("@AdUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@LinkUrl", SqlDbType.NVarChar,250),
					new SqlParameter("@AdRemark", SqlDbType.NVarChar,0),
					new SqlParameter("@IsLock", SqlDbType.Bit),
					new SqlParameter("@AddTime", SqlDbType.DateTime),
                    new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = model.Aid;
			parameters[1].Value = model.Title;
			parameters[2].Value = model.StartTime;
			parameters[3].Value = model.EndTime;
			parameters[4].Value = model.AdUrl;
			parameters[5].Value = model.LinkUrl;
			parameters[6].Value = model.AdRemark;
			parameters[7].Value = model.IsLock;
			parameters[8].Value = model.AddTime;
            parameters[9].Value = model.Id;

			DbHelper.ExecuteSql(strSql.ToString(),parameters);
		}
예제 #23
0
파일: Messages.cs 프로젝트: scutsky/iyuewan
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Spread.Model.Messages model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Messages(");
            strSql.Append("Subject,FullName,Mail,Address,ZipCode,Province,City,Phone,Fax,Type,Question,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Subject,@FullName,@Mail,@Address,@ZipCode,@Province,@City,@Phone,@Fax,@Type,@Question,@AddTime)");
            SqlParameter[] parameters = {
					new SqlParameter("@Subject", SqlDbType.NVarChar,100),
					new SqlParameter("@FullName", SqlDbType.NVarChar,50),
					new SqlParameter("@Mail", SqlDbType.NVarChar,50),					
					new SqlParameter("@Address", SqlDbType.NVarChar,50),
					new SqlParameter("@ZipCode", SqlDbType.NVarChar,50),					
					new SqlParameter("@Province", SqlDbType.NVarChar,50),
					new SqlParameter("@City", SqlDbType.NVarChar,50),
					new SqlParameter("@Phone", SqlDbType.NVarChar,50),
					new SqlParameter("@Fax", SqlDbType.NVarChar,50),
					new SqlParameter("@Type", SqlDbType.NVarChar,50),
					new SqlParameter("@Question", SqlDbType.NVarChar,50),				
					new SqlParameter("@AddTime", SqlDbType.DateTime)};



            parameters[0].Value = model.Subject;
            parameters[1].Value = model.FullName;
            parameters[2].Value = model.Mail;
            parameters[3].Value = model.Address;
            parameters[4].Value = model.ZipCode;
            parameters[5].Value = model.Province;
            parameters[6].Value = model.City;
            parameters[7].Value = model.Phone;
            parameters[8].Value = model.Fax;
            parameters[9].Value = model.Type;
            parameters[10].Value = model.Question;
            parameters[11].Value = model.AddTime;
            DbHelper.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #24
0
        public static unsafe SpreadBuilder <int> GetValues(KinectBuffer buffer, SpreadBuilder <int> builder, int width, int height, Spread <Vector2> pixels)
        {
            builder.Clear();
            short *data = (short *)buffer.UnderlyingBuffer;

            int pixelX = 0;
            int pixelY = 0;

            foreach (var item in pixels)
            {
                pixelX = (int)item.X;
                pixelY = (int)item.Y;

                pixelX = pixelX < 0 ? 0 : pixelX;
                pixelY = pixelY < 0 ? 0 : pixelY;

                pixelX = pixelX > width - 1 ? width - 1 : pixelX;
                pixelY = pixelY > height - 1 ? height - 1 : pixelY;

                int pixel = data[pixelY * width + pixelX];
                builder.Add(pixel);
            }
            return(builder);
        }
예제 #25
0
 void IDataReceiver.PutStock(Quote[] quotes, Spread spread)
 {
 }
예제 #26
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Spread.Model.Article_type model)
 {
     dal.Update(model);
 }
        void FillFrameList(BitmapDecoder decoder)
        {
            //continue if loaded
            Progress = 1;
            var list = new List<FrameData>(decoder.Frames.Count);
            var delaySpread = new Spread<int>(0);
            var positionSpread = new Spread<Vector2D>(0);
            var sizeSpread = new Spread<Vector2D>(0);
            var disposalSpread = new Spread<GifDisposal>(0);

            Format = decoder.Frames[0].Format;

            //convert and copy frames
            foreach (var frame in decoder.Frames)
            {

                //read meta data
                if(!frame.IsFrozen)
                    frame.Freeze();

                var meta = frame.Metadata as BitmapMetadata;
                if(meta != null)
                {
                    if(meta.ContainsQuery("/grctlext/Delay"))
                        delaySpread.Add((ushort)meta.GetQuery("/grctlext/Delay"));
                    else
                        delaySpread.Add(0);

                    if(meta.ContainsQuery("/grctlext/Disposal"))
                        disposalSpread.Add((GifDisposal)((byte)meta.GetQuery("/grctlext/Disposal")));
                    else
                        disposalSpread.Add(GifDisposal.None);

                    var left = (ushort)0;
                    var top = (ushort)0;

                     if(meta.ContainsQuery("/imgdesc/Left"))
                         left = (ushort)meta.GetQuery("/imgdesc/Left");

                     if(meta.ContainsQuery("/imgdesc/Top"))
                         top = (ushort)meta.GetQuery("/imgdesc/Top");

                    positionSpread.Add(new Vector2D(left, top));
                }

                sizeSpread.Add(new Vector2D(frame.PixelWidth, frame.PixelHeight));

                var convertedBitmap = new FormatConvertedBitmap();

                convertedBitmap.BeginInit();
                convertedBitmap.Source = frame;
                convertedBitmap.DestinationFormat = PixelFormats.Bgra32;
                convertedBitmap.EndInit();

                list.Add(CopyBitmapFrameToFrameData(convertedBitmap));
            }

            FFrameDataList = list;

            //recreate texture resources
            FTextureSpread.ResizeAndDispose(FFrameDataList.Count, i => CreateTextureResource(i));
            DelaySpread = delaySpread;
            PositionSpread = positionSpread;
            SizeSpread = sizeSpread;
            DisposalSpread = disposalSpread;
            IsLoading = false;
            HasNewData = true;
        }
예제 #28
0
파일: Messages.cs 프로젝트: scutsky/iyuewan
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Spread.Model.Messages model)
		{
			dal.Add(model);
		}
예제 #29
0
        /// <summary>
        /// スプレッドの列属性設定 列幅など
        /// </summary>
        private void setSpreadInfo()
        {
            ////行ヘッダーの列幅
            //fpS1.ActiveSheet.RowHeader.Columns[0].Width = 25;
            //fpS1.ActiveSheet.RowHeader.Columns[0].Font = new Font("MS UI Gothic", 8);
            //fpS1.ActiveSheet.RowHeader.Columns[0].HorizontalAlignment = CellHorizontalAlignment.Right;
            ////fpS1.ActiveSheet.RowHeader.Columns[0].HorizontalAlignment = CellHorizontalAlignment.Center;

            //// 列の非表示設定 sample
            //fpS1.ActiveSheet.Columns[(int)SpreadColum.user_id].Visible = false;


            ////列幅,他の設定 sample
            //fpS1.ActiveSheet.Columns[(int)SpreadColum.user_id].Width = (float)40;

            //// テキスト型セル 折り返し無し
            //FarPoint.Win.Spread.CellType.TextCellType textcell_row = new FarPoint.Win.Spread.CellType.TextCellType();
            //textcell_row.WordWrap = false;

            ////  テキスト型セル 折り返し有り
            //FarPoint.Win.Spread.CellType.TextCellType textcell_rows = new FarPoint.Win.Spread.CellType.TextCellType();
            //textcell_rows.Multiline = true;         //改行の入力 Shift+Enterが可能となる。 シフト無しでもOKだった。確定はフォーカスを外すこと。
            //textcell_rows.WordWrap = true;
            //textcell_rows.MaxLength = 2000;         //デフォルトで切られていた為、DBの最大サイズとした。

            ////小数点、桁区切りの設定
            //// 0
            //FarPoint.Win.Spread.CellType.NumberCellType lobjCellTypeNumberDecimalPlaces0 = new FarPoint.Win.Spread.CellType.NumberCellType();
            //lobjCellTypeNumberDecimalPlaces0.DecimalPlaces = 0;
            //lobjCellTypeNumberDecimalPlaces0.ShowSeparator = false;
            //lobjCellTypeNumberDecimalPlaces0.MaximumValue = 99999999;

            //// 1
            //FarPoint.Win.Spread.CellType.NumberCellType lobjCellTypeNumberDecimalPlaces1 = new FarPoint.Win.Spread.CellType.NumberCellType();
            //lobjCellTypeNumberDecimalPlaces1.DecimalPlaces = 1;
            //lobjCellTypeNumberDecimalPlaces1.ShowSeparator = true;

            //// 2
            //FarPoint.Win.Spread.CellType.NumberCellType lobjCellTypeNumberDecimalPlaces2 = new FarPoint.Win.Spread.CellType.NumberCellType();
            //lobjCellTypeNumberDecimalPlaces2.DecimalPlaces = 2;
            //lobjCellTypeNumberDecimalPlaces2.ShowSeparator = true;

            ////CELL タイプの設定
            //fpS1.ActiveSheet.Columns[(int)SpreadColum.user_id].CellType = (FarPoint.Win.Spread.CellType.NumberCellType)lobjCellTypeNumberDecimalPlaces0.Clone();
            ////パディング設定
            //fpS1.ActiveSheet.Columns[(int)SpreadColum.user_id].CellPadding.Left = (int)5;
            ////水平位置
            //fpS1.ActiveSheet.Columns[(int)SpreadColum.user_id].HorizontalAlignment = CellHorizontalAlignment.Center;


            ////行の高さを設定
            //int rows_count = fpS1.ActiveSheet.RowCount;
            //for (int i = 0; i < rows_count; i++)
            //{
            //    // 最も高さのあるテキストの高さに設定します
            //    fpS1.ActiveSheet.Rows[i].Height = (rows_hight > fpS1.ActiveSheet.GetPreferredRowHeight(i) ? rows_hight : fpS1.ActiveSheet.GetPreferredRowHeight(i));
            //}

            ////列を追加

            //列情報の設定 : NG
            Spread.setSpreadColumInfo(fpS1.ActiveSheet, spread_list);

            //奇数行、偶数行の背景色設定 : OK
            Spread.SetColorAlternating(fpS1.ActiveSheet);

            //固定列数の設定 : +1でOK
            Spread.SetFrozenColumn(fpS1.ActiveSheet, (int)SpreadColum.pds_code + 1);
        }
예제 #30
0
        void IDataReceiver.PutStock(Quote[] quotes, Spread spread)
        {
            if (writeStock)
            {
                lock (pLock)
                {
                    diffQuotes.Clear();

                    int i = 0;

                    foreach (Quote lq in lastQuotes)
                    {
                        while (i < quotes.Length && lq.Price < quotes[i].Price)
                        {
                            diffQuotes.Add(quotes[i++]);
                        }

                        if (i < quotes.Length && quotes[i].Price == lq.Price)
                        {
                            if (lq.Type != quotes[i].Type || lq.Volume != quotes[i].Volume)
                            {
                                diffQuotes.Add(quotes[i]);
                            }

                            i++;
                        }
                        else
                        {
                            diffQuotes.Add(new Quote(lq.Price, 0, QuoteType.Unknown));
                        }
                    }

                    while (i < quotes.Length)
                    {
                        diffQuotes.Add(quotes[i++]);
                    }

                    if (diffQuotes.Count > 0)
                    {
                        try
                        {
                            if (diffQuotes.Count > ushort.MaxValue)
                            {
                                throw new OverflowException("Превышение допустимой глубины стакана");
                            }

                            WriteRecHeader(stockId);

                            bw.Write((ushort)diffQuotes.Count);

                            foreach (Quote q in diffQuotes)
                            {
                                bw.Write(q.Price);

                                switch (q.Type)
                                {
                                case QuoteType.Ask:
                                case QuoteType.BestAsk:
                                    bw.Write(q.Volume);
                                    break;

                                case QuoteType.Bid:
                                case QuoteType.BestBid:
                                    bw.Write(-q.Volume);
                                    break;

                                default:
                                    bw.Write(0);
                                    break;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            SetError(e.Message);
                        }
                    }

                    lastQuotes = quotes;
                }
            }

            Receiver.PutStock(quotes, spread);
        }
예제 #31
0
 public BasicGui2dNode()
 {
     FControllerGroups = new ArrayList();
     FLastMouseLeft    = new Spread <bool>(1);
 }
예제 #32
0
 public static GunType Create(Firerate firerate, Damage damage, Spread spread, bool autoFiring,
                              bool shootThroughEverything)
 {
     return(new GunType(firerate, damage, spread, autoFiring, shootThroughEverything));
 }
예제 #33
0
//		[Output("Mesh")]
//       public IDXMeshOut MOut;
        #endregion fields & pins

/*		public void Unify(IMesh mesh, ISpread<Vector2D> UniOut, ISpread<int> Indices, I)
 *              {
 *                      var vertices = mesh.Vertices;
 *                      int vCount = vertices.Count;
 *
 *              }
 */
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            SpreadMax          = SpreadUtils.SpreadMax(Fvert, FInput, FIsH, FMaxAngle, FMinAngle, FMaxArea, FConDel, FSplit, FSteiner, FBmark, FSmooth, FSmoothLimit, Freg, FRegInd, FConSeg);
            FOutput.SliceCount = SpreadMax;
            FVmark.SliceCount  = SpreadMax;
//			FMesh.SliceCount = SpreadMax;
            FRmark.SliceCount = SpreadMax;
            FInd.SliceCount   = SpreadMax;

            int index = 0;

            if (FCal[0])
            {
                List <int> shift = new List <int>();
                shift.Add(0);


                for (int meshID = 0; meshID < SpreadMax; meshID++)
                {
                    var polygon = new Polygon();

                    for (int contourID = 0; contourID < Fvert[meshID].SliceCount; contourID++)
                    {
                        int vertexcount = 0;



                        if (Fvert[meshID][contourID] != 0)
                        {
                            vertexcount = Fvert[meshID][contourID];
                        }
                        else
                        {
                            vertexcount = FInput[meshID].SliceCount;
                        }

                        ISpread <Vertex> vcsSpread = new Spread <Vertex>();
                        vcsSpread.SliceCount = vertexcount;



                        for (int i = 0; i < vertexcount; i++)
                        {
                            vcsSpread[i] = new Vertex(FInput[meshID][index + i].x, FInput[meshID][index + i].y, FBmark[meshID][index + i]);
                        }

                        if (vertexcount > 1)
                        {
                            if (FConSeg[meshID][contourID])
                            {
                                for (int segID = 0; segID < vertexcount - 1; segID++)
                                {
                                    polygon.Add(new Segment(vcsSpread[segID], vcsSpread[segID + 1]), true);
                                }
                            }
                            else
                            {
                                polygon.Add(new Contour(vcsSpread, contourID + 1), FIsH[meshID][contourID]);
                            }
                        }
                        else
                        {
                            polygon.Add(vcsSpread[0]);
                        }



                        index += vertexcount;
                    }

                    var quality = new QualityOptions()
                    {
                        MinimumAngle = FMinAngle[meshID], MaximumAngle = FMaxAngle[meshID], SteinerPoints = FSteiner[meshID]
                    };
                    if (Freg[meshID])
                    {
                        for (int regionID = 0; regionID < FRegInd[meshID].SliceCount; regionID++)
                        {
                            polygon.Regions.Add(new RegionPointer(FRegInd[meshID][regionID].x, FRegInd[meshID][regionID].x, FRegMark[meshID][regionID]));
                        }
                    }
                    else
                    {
                        quality.MaximumArea = FMaxArea[meshID][0];
                    }


                    // Triangulate the polygon
                    var options = new ConstraintOptions()
                    {
                        ConformingDelaunay = FConDel[meshID], SegmentSplitting = FSplit[meshID]
                    };
                    if (FSmooth[meshID])
                    {
                        options = new ConstraintOptions()
                        {
                            ConformingDelaunay = true, SegmentSplitting = FSplit[meshID]
                        }
                    }
                    ;



                    var mesh = polygon.Triangulate(options, quality);

                    if (Freg[meshID])
                    {
                        foreach (var t in mesh.Triangles)
                        {
                            // Set area constraint for all triangles
                            t.Area = FMaxArea[meshID][t.Label - 1];
                        }
                        // Use per triangle area constraint for next refinement
                        quality.VariableArea = true;


                        // Refine mesh to meet area constraint.
                        mesh.Refine(quality, FConDel[meshID]);
                    }

                    // Do some smoothing.
                    if (FSmooth[meshID])
                    {
                        (new SimpleSmoother()).Smooth(mesh, FSmoothLimit[meshID]);
                    }

                    mesh.Renumber();


                    int triangleCount = mesh.Triangles.Count;
                    int SliceOut      = triangleCount * 3;
                    int vertexCount   = mesh.Vertices.Count;



                    var vertices  = mesh.Vertices.ToSpread();
                    var triangles = mesh.Triangles.ToSpread();

                    FRmark[meshID] = new Spread <int>();

                    FInd[meshID].SliceCount = SliceOut;

                    if (FUni[meshID])
                    {
                        shift.Add(shift[meshID] + vertexCount * (Convert.ToInt32(FShift[0])));

                        FOutput[meshID].SliceCount = vertexCount;
                        FVmark[meshID].SliceCount  = vertexCount;
                        FRmark[meshID].SliceCount  = vertexCount;
                        //			FMesh[meshID] = mesh;



                        for (int i = 0; i < triangleCount; i++)
                        {
                            for (int tri = 0; tri < 3; tri++)
                            {
                                FInd[meshID][i * 3 + tri] = triangles[i].GetVertexID(tri) + shift[meshID];
                                if (triangles[i].Label >= FRmark[meshID][triangles[i].GetVertexID(tri)])
                                {
                                    FRmark[meshID][triangles[i].GetVertexID(tri)] = triangles[i].Label;
                                }
                            }
                        }

                        for (int j = 0; j < vertexCount; j++)
                        {
                            FOutput[meshID][j] = new Vector2D(vertices[j].X, vertices[j].Y);
                            FVmark[meshID][j]  = vertices[j].Label;
                        }



/*					List<int> OldIndices = new List<int>();
 *                                      List<int> NewIndices = new List<int>();
 *
 *                                      for (int s=0; s<FConSeg[meshID].SliceCount;s++){
 *                                              if (FConSeg[meshID][s]){
 *                                                      int startindex=0;
 *
 *                                                      int first=0;
 *                                                      for (int u=0; u<s;u++){
 *                                                              startindex+=Fvert[meshID][u];
 *                                                      }
 *
 *                                                      //only check for points on segments, excluding start and end points
 *
 *                                                      for (int segPID=1; segPID<Fvert[meshID][s]-1;segPID++){
 *                                                              int counter=0;
 *                                                              for (int vertID=0;vertID<vertexCount;vertID++){
 *                                                                      if (vertices[vertID].X==FInput[meshID][startindex+segPID].x && vertices[vertID].Y==FInput[meshID][startindex+segPID].y){
 *                                                                              counter++;
 *                                                                              if (counter>1){
 *                                                                                      OldIndices.Add(vertID);
 *                                                                                      NewIndices.Add(first);
 *                                                                              }
 *                                                                              else{
 *                                                                                      first = vertID;
 *                                                                              }
 *                                                                      }
 *                                                              }
 *                                                      }
 *
 *                                              for (int indexID=0; indexID<OldIndices.Count;indexID++){
 *
 *                                                      FInd[meshID].Select(num => num == OldIndices[indexID] ? NewIndices[indexID] : num);
 *                                                      }
 *                                              }
 *                                              }
 */
                        //remove duplicate points which do not belong to any triangle

                        List <int> GarbageIndex = new List <int>();
                        for (int vecID = 0; vecID < FOutput[meshID].SliceCount; vecID++)
                        {
                            bool isPart = false;

                            isPart = FInd[meshID].Contains(vecID);

                            if (!isPart)
                            {
                                GarbageIndex.Add(vecID);
                            }
                        }


                        GarbageIndex.Reverse();
                        for (int vecID = 0; vecID < GarbageIndex.Count; vecID++)
                        {
                            FOutput[meshID].RemoveAt(GarbageIndex[vecID]);
                        }
                        for (int g = 0; g < FInd[meshID].SliceCount; g++)
                        {
                            for (int h = 0; h < GarbageIndex.Count; h++)
                            {
                                if (FInd[meshID][g] >= GarbageIndex[h])
                                {
                                    int r = FInd[meshID][g] - 1;
                                    FInd[meshID][g] = r < 0 ? r + FOutput[meshID].SliceCount : r;
                                }                                 //can be -1?
                            }
                        }
                    }
                    else
                    {
                        shift.Add(shift[meshID] + SliceOut * (Convert.ToInt32(FShift[0])));

                        FOutput[meshID].SliceCount = SliceOut;
                        FVmark[meshID].SliceCount  = SliceOut;
                        FRmark[meshID].SliceCount  = SliceOut;

                        for (int i = 0; i < triangleCount; i++)
                        {
                            for (int tri = 0; tri < 3; tri++)
                            {
                                FOutput[meshID][i * 3 + tri] = new Vector2D(triangles[i].GetVertex(tri).X, triangles[i].GetVertex(tri).Y);
                                FVmark[meshID][i * 3 + tri]  = triangles[i].GetVertex(tri).Label;
                                FRmark[meshID][i * 3 + tri]  = triangles[i].Label;
                                FInd[meshID][i * 3 + tri]    = i * 3 + tri + +shift[meshID];
                            }
                        }
                    }
                }
            }
        }
    }
예제 #34
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private List <ISport> XMLParse1()
        {
            List <ISport> sport         = new List <ISport>();
            string        urlPathSport  = string.Empty;
            string        urlPathLeague = string.Empty;
            string        urlPathFeed   = string.Empty;

            urlPathSport = Constant.SourceXML.PINNACLESPORTSURL;
            if (urlPathSport.IndexOf("http://") > -1)
            {
                urlPathLeague = Constant.SourceXML.PINNACLELEAGUEURL;
                urlPathFeed   = Constant.SourceXML.PINNACLEFEEDURL;
            }
            else
            {
                string[] arrPlitUrl = urlPathSport.Split('_');
                string   timetick   = arrPlitUrl[2].Replace(".xml", "");
                urlPathLeague = arrPlitUrl[0] + "_league_{0}_" + timetick + ".xml";
                urlPathFeed   = arrPlitUrl[0] + "_feed_{0}_{1}_" + timetick + ".xml";
            }


            //sport
            XmlTextReader readerSport = new XmlTextReader(urlPathSport);

            // Skip non-significant whitespace
            readerSport.WhitespaceHandling = WhitespaceHandling.Significant;
            XPathDocument  doc = new XPathDocument(readerSport, XmlSpace.Preserve);
            XPathNavigator nav = doc.CreateNavigator();

            XPathExpression exprSport;

            exprSport = nav.Compile("/rsp/sports/sport");
            XPathNodeIterator iteratorSport = nav.Select(exprSport);

            try
            {
                // Loop all sports
                while (iteratorSport.MoveNext())
                {
                    XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone();
                    int            feedContentSport    = Convert.ToInt32(_sportNameNavigator.GetAttribute("feedContents", ""));
                    if (feedContentSport > 0)
                    {
                        ISport _sport = new Sport();
                        _sport.ID   = Convert.ToInt32(_sportNameNavigator.GetAttribute("id", ""));
                        _sport.Name = _sportNameNavigator.Value;
                        //Add sport to List
                        // sports.Add(_sport);
                        //league- event
                        XmlTextReader readerLeague = new XmlTextReader(string.Format(urlPathLeague, _sport.ID));
                        readerLeague.WhitespaceHandling = WhitespaceHandling.Significant;
                        XPathDocument  docLeague = new XPathDocument(readerLeague, XmlSpace.Preserve);
                        XPathNavigator navLeague = docLeague.CreateNavigator();

                        XPathExpression exprLeague;
                        exprLeague = navLeague.Compile("/rsp/leagues/league");
                        XPathNodeIterator iteratorLeague = navLeague.Select(exprLeague);
                        // Loop all Leagues in each sport
                        while (iteratorLeague.MoveNext())
                        {
                            XPathNavigator _eventNameNavigator = iteratorLeague.Current.Clone();
                            int            feedContentLeague   = Convert.ToInt32(_sportNameNavigator.GetAttribute("feedContents", ""));
                            if (feedContentLeague > 0)
                            {
                                ILeague _league = new League();
                                _league.ID   = Convert.ToInt32(_eventNameNavigator.GetAttribute("id", ""));
                                _league.Name = _eventNameNavigator.Value;
                                //Add the current League to the latest sport
                                sports[sports.Count - 1].Leagues.Add(_league);

                                //match - home team - awayteam
                                XmlTextReader readerMatch = new XmlTextReader(string.Format(urlPathFeed, _sport.ID, _league.ID));
                                readerMatch.WhitespaceHandling = WhitespaceHandling.Significant;
                                XPathDocument  docMatch = new XPathDocument(readerMatch, XmlSpace.Preserve);
                                XPathNavigator navMatch = docMatch.CreateNavigator();

                                XPathExpression exprematch;
                                exprematch = navMatch.Compile("/rsp/fd/sports/sport/leagues/league");
                                XPathNodeIterator iteratorMatch = navMatch.Select(exprematch);
                                // Loop in each League
                                while (iteratorMatch.MoveNext())
                                {
                                    XPathNavigator _matchNameNavigator = iteratorMatch.Current.Clone();

                                    XPathExpression exprematchEvent;
                                    exprematchEvent = _matchNameNavigator.Compile("events/event");
                                    XPathNodeIterator iteratorMatchEvent = _matchNameNavigator.Select(exprematchEvent);
                                    while (iteratorMatchEvent.MoveNext())
                                    {
                                        //  _matchId++;
                                        XPathNavigator _matchEventNameNavigator = iteratorMatchEvent.Current.Clone();
                                        IMatch         _match = new Match();
                                        _match.ID = Convert.ToInt32(_matchEventNameNavigator.GetAttribute("id", ""));;
                                        //_match.eventId = _eventId;
                                        //_match.nameMatch = _matchNameNavigator.GetAttribute("name", "");
                                        _match.HomeTeam      = _matchEventNameNavigator.SelectSingleNode("homeTeam").SelectSingleNode("name").Value;
                                        _match.AwayTeam      = _matchEventNameNavigator.SelectSingleNode("awayTeam").SelectSingleNode("name").Value;
                                        _match.StartDateTime = Convert.ToDateTime(_matchEventNameNavigator.SelectSingleNode("startDateTime").Value);
                                        // Add the match into current League


                                        // Loop all in Periods
                                        if (_matchEventNameNavigator.HasChildren)
                                        {
                                            XPathExpression exprebet;
                                            exprebet = _matchEventNameNavigator.Compile("periods/period");
                                            XPathNodeIterator iteratorBet = _matchEventNameNavigator.Select(exprebet);
                                            //Loop each period
                                            while (iteratorBet.MoveNext())
                                            {
                                                //  _betId++;
                                                XPathNavigator _betNameNavigator = iteratorBet.Current.Clone();
                                                IPeriod        _period           = new Period();
                                                _period.Description = _betNameNavigator.SelectSingleNode("description").Value;;

                                                // Add period to Match

                                                //handicap
                                                XPathExpression exprehandicap;
                                                exprehandicap = _matchEventNameNavigator.Compile("spreads/spread");
                                                XPathNodeIterator iteratorHandicap = _matchEventNameNavigator.Select(exprehandicap);
                                                //total
                                                XPathExpression expretotal;
                                                expretotal = _matchEventNameNavigator.Compile("totals/total");
                                                XPathNodeIterator iteratorTotal = _matchEventNameNavigator.Select(expretotal);
                                                //moneyline
                                                XPathExpression expremoneyline;
                                                expremoneyline = _matchEventNameNavigator.Compile("moneyLine");
                                                XPathNodeIterator iteratorMoneyLine = _matchEventNameNavigator.Select(expremoneyline);

                                                while (iteratorHandicap.MoveNext())
                                                {
                                                    XPathNavigator _choiceNameNavigator = iteratorHandicap.Current.Clone();
                                                    ISpread        _spread = new Spread();
                                                    _spread.AwaySpread = float.Parse(_choiceNameNavigator.SelectSingleNode("awaySpread").Value);
                                                    _spread.AwayPrice  = float.Parse(_choiceNameNavigator.SelectSingleNode("awayPrice").Value);
                                                    _spread.HomeSpread = float.Parse(_choiceNameNavigator.SelectSingleNode("homeSpread").Value);
                                                    _spread.HomePrice  = float.Parse(_choiceNameNavigator.SelectSingleNode("homePrice").Value);
                                                    _period.Spreads.Add(_spread);
                                                }

                                                while (iteratorTotal.MoveNext())
                                                {
                                                    XPathNavigator _choiceNameNavigator = iteratorTotal.Current.Clone();
                                                    ITotal         _total = new Total();
                                                    _total.Point      = float.Parse(_choiceNameNavigator.SelectSingleNode("points").Value);
                                                    _total.OverPrice  = float.Parse(_choiceNameNavigator.SelectSingleNode("overPrice").Value);
                                                    _total.UnderPrice = float.Parse(_choiceNameNavigator.SelectSingleNode("underPrice").Value);
                                                    _period.Totals.Add(_total);
                                                }

                                                while (iteratorMoneyLine.MoveNext())
                                                {
                                                    XPathNavigator _choiceNameNavigator = iteratorMoneyLine.Current.Clone();
                                                    IMoneyLine     _moneyline           = new MoneyLine();

                                                    _moneyline.AwayPrice = float.Parse(_choiceNameNavigator.SelectSingleNode("awayPrice").Value);
                                                    _moneyline.HomePrice = float.Parse(_choiceNameNavigator.SelectSingleNode("homePrice").Value);
                                                    _moneyline.DrawPrice = float.Parse(_choiceNameNavigator.SelectSingleNode("drawPrice").Value);
                                                    _period.MoneyLines.Add(_moneyline);
                                                }

                                                _match.Periods.Add(_period);
                                            }

                                            _league.Matches.Add(_match);
                                        }
                                    }
                                }

                                _sport.Leagues.Add(_league);
                            }
                        }
                        sport.Add(_sport);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                sports = null;
            }
            return(sport);
        }
예제 #35
0
        // **********************************************************************

        void StockReader(Stream stream)
        {
            int    n   = br.ReadUInt16();
            String rrr = "";

            for (int i = 0; i < n; i++)
            {
                int p = br.ReadInt32();
                int v = br.ReadInt32();

                if (v == 0)
                {
                    rawQuotes.Remove(p);
                }
                else if (rawQuotes.ContainsKey(p))
                {
                    rawQuotes[p] = v;
                }
                else
                {
                    rawQuotes.Add(p, v);
                }
            }

            if (stream != null && stream.IsActive)
            {
                Quote[] quotes = new Quote[rawQuotes.Count];

                int i = rawQuotes.Count - 1;

                Spread spread = new Spread();

                foreach (KeyValuePair <int, int> kvp in rawQuotes)
                {
                    quotes[i].Price = kvp.Key;

                    if (kvp.Value > 0)
                    {
                        quotes[i].Volume = kvp.Value;

                        if (spread.Ask > 0)
                        {
                            quotes[i].Type = QuoteType.Ask;
                        }
                        else
                        {
                            quotes[i].Type = QuoteType.BestAsk;

                            int j = i + 1;

                            if (j < quotes.Length)
                            {
                                quotes[j].Type = QuoteType.BestBid;
                                spread         = new Spread(quotes[i].Price, quotes[j].Price);
                            }
                        }
                    }
                    else
                    {
                        quotes[i].Volume = -kvp.Value;
                        quotes[i].Type   = QuoteType.Bid;
                    }
                    rrr = rrr + " " + quotes[i].Price.ToString() + " " + quotes[i].Volume.ToString() + " " + quotes[i].Type.ToString() + "\n";

                    i--;
                }
                MainWindow.Res(rrr);

                if (StockHandler != null)
                {
                    StockHandler(quotes, spread);
                }
            }
        }
예제 #36
0
        public void Evaluate(int SpreadMax)
        {
            if (FInput.IsChanged || FKeys.IsChanged)
            {
                //delete and dispose all inputs
                foreach (var element in FBufferWriters)
                {
                    if (element != null)
                    {
                        element.Dispose();
                    }
                }

                FBufferWriters.SliceCount = SpreadMax;
                for (int i = 0; i < SpreadMax; i++)
                {
                    if (FInput[i] != null)
                    {
                        FBufferWriters[i] = (new BufferWriterSignal(FInput[i], FKeys[i].Name, FPreviewSizeIn[i]));
                    }
                }

                FBufferPreviewOut.SliceCount        = SpreadMax;
                FCurrentWritePositionOut.SliceCount = SpreadMax;
            }

            //output value
            for (int i = 0; i < SpreadMax; i++)
            {
                var bufferWriter = FBufferWriters[i];
                if (bufferWriter != null)
                {
                    if (FSetWritePositionIn[i])
                    {
                        bufferWriter.SetWritePosition(FWritePositionIn[i]);
                    }

                    if (FClearIn[i])
                    {
                        bufferWriter.Clear();
                    }

                    bufferWriter.DoWrite     = FWriteIn[i];
                    bufferWriter.PreviewSize = FPreviewSizeIn[i];

                    FCurrentWritePositionOut[i] = bufferWriter.WritePosition;
                    var     spread = FBufferPreviewOut[i];
                    float[] val    = bufferWriter.Preview;
                    //FBufferReaders[i].GetLatestValue(out val);
                    if (val != null)
                    {
                        if (spread == null)
                        {
                            spread = new Spread <float>(val.Length);
                        }
                        spread.SliceCount = val.Length;
                        spread.AssignFrom(val);
                    }
                }
                else
                {
                    FBufferPreviewOut[i].SliceCount = 0;
                }
            }
        }
예제 #37
0
파일: Buffer.cs 프로젝트: mechaz/vvvv-sdk
        public void Evaluate(int SpreadMax)
        {
            //create new buffer on startup
            if (FFirstFrame)
            {
                FOutput[0] = new Spread <T>(1);
            }

            //return null if one of the control inputs is null
            if (FIndex.IsAnyEmpty(FDoInsert, FFrameCount, FReset))
            {
                FOutput.SliceCount = 0;
                FPhase.SliceCount  = 0;
                return;
            }

            //get buffer size
            var frameCount = FFrameCount[0];

            if (FReset[0]) //set all slices to default
            {
                FOutput.SliceCount = frameCount;
                for (int i = 0; i < frameCount; i++)
                {
                    FOutput[i] = FDefault[i].Clone() as ISpread <T>;
                }
            }

            //set slice count
            if (FOutput.SliceCount > frameCount)
            {
                FOutput.RemoveRange(frameCount, FOutput.SliceCount - frameCount);
            }
            else if (FOutput.SliceCount < frameCount)
            {
                for (int i = FOutput.SliceCount; i < frameCount; i++)
                {
                    FOutput.Add(new Spread <T>(1));
                }
            }

            SpreadMax = Math.Max(Math.Max(FInput.SliceCount, FIndex.SliceCount), FDoInsert.SliceCount);

            //set phase slice count
            FPhase.SliceCount = SpreadMax;

            //per slice
            for (int i = 0; i < SpreadMax; i++)
            {
                var bufferCounter = FIndex[i];
                bufferCounter %= Math.Max(frameCount, 1);

                if (FDoInsert[i])
                {
                    FOutput[bufferCounter] = FInput[i].Clone() as ISpread <T>;
                    FPhase[i] = frameCount > 1 ? bufferCounter / (double)(frameCount - 1) : 0;
                }
            }

            FFirstFrame = false;
        }
예제 #38
0
        public ISpread <Frame> Preload(
            ISpread <int> visibleFrameIndices,
            ISpread <int> preloadFrameNrs,
            int bufferSize,
            EX9.Format preferedFormat,
            out int frameCount,
            out double durationIO,
            out double durationTexture,
            out int unusedFrames,
            ref ISpread <bool> loadedFrames)
        {
            var files = FFiles;

            frameCount      = files.Count;
            durationIO      = 0.0;
            durationTexture = 0.0;
            unusedFrames    = 0;

            // Nothing to do
            if (frameCount == 0)
            {
                loadedFrames.SliceCount = 0;
                return(new Spread <Frame>(0));
            }

            // Map frame numbers to file names
            var preloadFiles = preloadFrameNrs.Select(
                frameNr =>
            {
                var fileName = files[VMath.Zmod(frameNr, files.Count)];
                return(CreateFrameInfo(fileName, bufferSize, preferedFormat));
            })
                               .ToArray();

            // Dispose previously loaded frames
            foreach (var file in FPreloadedFrames.Keys.ToArray())
            {
                if (!preloadFiles.Contains(file))
                {
                    var frame = FPreloadedFrames[file];
                    Dispose(frame);
                }
            }

            // Ensure that there are as much dequeues as enqueues (or we'll run out of memory)
            while (FScheduledFrameInfos.Count > preloadFrameNrs.SliceCount)
            {
                var frame     = Dequeue();
                var frameInfo = frame.Metadata;
                if (!preloadFiles.Contains(frameInfo) || frameInfo.IsCanceled)
                {
                    // Not needed anymore
                    Dispose(frame);
                    unusedFrames++;
                }
                else
                {
                    FPreloadedFrames.Add(frameInfo, frame);
                }
            }

            // Cancel unused scheduled frames
            foreach (var frameInfo in FScheduledFrameInfos.Where(fi => !fi.IsCanceled))
            {
                if (!preloadFiles.Contains(frameInfo))
                {
                    frameInfo.Cancel();
                }
            }

            // Schedule new frames
            foreach (var file in preloadFiles)
            {
                if (!IsScheduled(file) && !IsPreloaded(file))
                {
                    Enqueue(file);
                }
            }

            // Write the "is loaded" state
            loadedFrames.SliceCount = preloadFrameNrs.SliceCount;
            for (int i = 0; i < loadedFrames.SliceCount; i++)
            {
                var file = preloadFiles[i];
                if (!IsPreloaded(file))
                {
                    var frameInfo = FScheduledFrameInfos.First(fi => fi == file);
                    loadedFrames[i] = frameInfo.IsLoaded;
                }
                else
                {
                    loadedFrames[i] = true;
                }
            }

            // Wait for the visible frames (and dipose unused ones)
            var visibleFrames = new Spread <Frame>(0);
            // Map frame numbers to file names
            var visibleFiles = preloadFiles.Length > 0
                ? visibleFrameIndices.Select(i => preloadFiles[VMath.Zmod(i, preloadFiles.Length)])
                : Enumerable.Empty <FrameInfo>();

            foreach (var file in visibleFiles)
            {
                while (!IsPreloaded(file))
                {
                    var frame     = Dequeue();
                    var frameInfo = frame.Metadata;
                    if (!preloadFiles.Contains(frameInfo) || frameInfo.IsCanceled)
                    {
                        // Not needed anymore
                        Dispose(frame);
                        unusedFrames++;
                    }
                    else
                    {
                        FPreloadedFrames.Add(frameInfo, frame);
                    }
                }
                var visibleFrame     = FPreloadedFrames[file];
                var visibleFrameInfo = visibleFrame.Metadata;
                durationIO      += visibleFrameInfo.DurationIO;
                durationTexture += visibleFrameInfo.DurationTexture;
                visibleFrames.Add(visibleFrame);
            }

            // Release textures of non visible frames
            foreach (var frame in FPreloadedFrames.Values.Where(f => !visibleFrames.Contains(f)))
            {
                frame.Dispose();
            }

            return(visibleFrames);
        }
예제 #39
0
        public async Task <IActionResult> Reading(int deckId, string name)
        {
            var user = await GetCurrentUserAsync();

            var    applicationDbContext = _context.Card.Include(c => c.CardType);
            Random rand           = new Random();
            var    randomizedList = from item in applicationDbContext
                                    orderby rand.Next()
                                    select item;

            List <Reading> readingViewModelList = new List <Reading>();

            Reading readingViewModel = new Reading()
            {
                Cards            = await randomizedList.Take(11).ToListAsync(),
                OrdinalPositions = await _context.OrdinalPosition.ToListAsync(),
                OrdinalComments  = await _context.OrdinalComment.Where(oc => oc.User.Id == user.Id).ToListAsync(),
                CardComments     = await _context.CardComment.Where(cc => cc.User.Id == user.Id).ToListAsync()
            };

            Spread dummySpread = new Spread()
            {
                Name   = name,
                UserId = user.Id
            };

            _context.Add(dummySpread);
            await _context.SaveChangesAsync();


            int count = 0;

            foreach (var card in readingViewModel.Cards)
            {
                int    ordinalId     = count + 1;
                Random rnd           = new Random();
                int    cardDirection = rnd.Next(1, 3);

                if (cardDirection % 2 == 0)
                {
                    card.CardDirection = true;
                }
                else
                {
                    card.CardDirection = false;
                }
                SavedSpread dummySavedSpread = new SavedSpread()
                {
                    SpreadId          = dummySpread.SpreadId,
                    CardId            = card.CardId,
                    OrdinalPositionId = ordinalId,
                    CardDirection     = card.CardDirection,
                };
                _context.Add(dummySavedSpread);
                await _context.SaveChangesAsync();

                count++;
            }

            readingViewModel.SpreadId = dummySpread.SpreadId;
            readingViewModelList.Add(readingViewModel);

            return(View(readingViewModelList.AsEnumerable()));
        }
예제 #40
0
        /// <summary>
        /// Copies the <paramref name="fromData"/> to the given <paramref name="buffer"/> on GPU memory.
        /// </summary>
        /// <typeparam name="TData">The type of the T data.</typeparam>
        /// <param name="buffer">The <see cref="Buffer"/>.</param>
        /// <param name="commandList">The <see cref="CommandList"/>.</param>
        /// <param name="fromData">The data to copy from.</param>
        /// <param name="offsetInBytes">The offset in bytes to write to.</param>
        /// <exception cref="ArgumentException"></exception>
        /// <remarks>
        /// See the unmanaged documentation about Map/UnMap for usage and restrictions.
        /// </remarks>
        /// <returns>The GPU buffer.</returns>
        public static unsafe Texture SetData <TData>(this Texture texture, CommandList commandList, Spread <TData> fromData, int arraySlice, int mipSlice, ResourceRegion?region) where TData : struct
        {
            var immutableArray = fromData._array;
            var array          = Unsafe.As <ImmutableArray <TData>, TData[]>(ref immutableArray);

            texture.SetData(commandList, array, arraySlice, mipSlice, region);
            return(texture);
        }
예제 #41
0
        // **********************************************************************



        public void AddStock(Quote[] quotes, Spread spread, Recorder fff)
        {
            fff.PutStock(quotes, spread);
        }
예제 #42
0
        // method called each frame in vvvv
        public void Evaluate(int SpreadMax)
        {
            //if (Element.SliceCount == 0) return;

            if (!Element.IsChanged && !ConfigChanged && !XPathNamePin.IsChanged)
            {
                return;
            }

            Elements.SliceCount = Element.SliceCount;


            for (int i = 0; i < Element.SliceCount; i++)
            {
                try
                {
                    var element = Element[i];

                    if (!string.IsNullOrEmpty(XPathNamePin[0]) && element != null)
                    {
                        Elements[i] = element.XPathSelectElements(XPathNamePin[0], NamespaceResolver[0]).ToSpread();
                    }
                    else
                    {
                        Elements[i] = new Spread <XElement>(0);
                    }
                }
                catch (Exception e)
                {
                    Elements[i] = new Spread <XElement>(0);
                    FLogger.Log(e);
                }
            }

            var allElements = Elements.SelectMany(spread => spread).ToArray();

            // set slicecount to all element hits
            ElementsName.SliceCount = allElements.Length;

            #region process names
            int j = 0;
            foreach (var element in allElements)
            {
                ElementsName[j] = element.Name.ToString();
                j++;
            }
            #endregion process names

            #region process queries
            foreach (var query in FQueries.Values)
            {
                var queryExistsPin = query.QueryExistsContainer.IOObject;
                var queryPin       = query.QueryContainer.IOObject;
                var firstPin       = query.FirstContainer.IOObject;
                var allPin         = query.AllContainer.IOObject;

                queryExistsPin.Length = allElements.Length;
                queryPin.Length       = allElements.Length;
                firstPin.Length       = allElements.Length;
                allPin.Length         = allElements.Length;

                using (var queryExistsWriter = queryExistsPin.GetWriter())
                    using (var queryWriter = queryPin.GetWriter())
                        using (var firstWriter = firstPin.GetWriter())
                            using (var allWriter = allPin.GetWriter())
                            {
                                foreach (var element in allElements)
                                {
                                    XObject xobj = null;
                                    IEnumerable <XObject> xobjEnumerable = null;
                                    try
                                    {
                                        var node = (IEnumerable)element.XPathEvaluate(query.Name, NamespaceResolver[0]);
                                        xobjEnumerable = node.Cast <XObject>();
                                        xobj           = xobjEnumerable.FirstOrDefault();
                                    }
                                    catch (XPathException xe)
                                    {
                                        FLogger.Log(xe);
                                    }
                                    if (xobj != null)
                                    {
                                        if (xobj.NodeType == XmlNodeType.Attribute)
                                        {
                                            var attr = xobj as XAttribute;
                                            queryExistsWriter.Write(true);
                                            queryWriter.Write(attr.Value);
                                            firstWriter.Write(new XElement("NIL"));
                                            allWriter.Write(new MemoryIOStream <XElement>(0));
                                        }
                                        else
                                        {
                                            var el = xobj as XElement;
                                            queryExistsWriter.Write(true);
                                            queryWriter.Write(el.Value);
                                            firstWriter.Write(el);
                                            allWriter.Write(xobjEnumerable.Cast <XElement>().ToStream());
                                        }
                                    }
                                    else
                                    {
                                        queryWriter.Write("");
                                        queryExistsWriter.Write(false);
                                        firstWriter.Write(new XElement("NIL"));
                                        allWriter.Write(new MemoryIOStream <XElement>(0));
                                    }
                                }
                            }
            }
            #endregion process queries

            ConfigChanged = false;
        }
		public static unsafe Spread<double> GetPixelAsDoubles(CVImage source, uint column, uint row)
		{
			TColorFormat format = source.ImageAttributes.ColorFormat;
			uint channelCount = (uint)ChannelCount(format);

			if (channelCount == 0)
			{
				return new Spread<double>(0);
			}

			uint width = (uint)source.Width;
			uint height = (uint)source.Height;
			Spread<double> output = new Spread<double>((int)channelCount);

			row %= height;
			column %= width;

			switch (ChannelFormat(format))
			{
				case TChannelFormat.Byte:
					{
						byte* d = (byte*)source.Data.ToPointer();
						for (uint channel = 0; channel < channelCount; channel++)
						{
							output[(int)channel] = (double)d[(column + row * width) * channelCount + channel];
						}
						break;
					}

				case TChannelFormat.Float:
					{
						float* d = (float*)source.Data.ToPointer();
						for (uint channel = 0; channel < channelCount; channel++)
						{
							output[(int)channel] = (double)d[(column + row * width) * channelCount + channel];
						}
						break;
					}

				case TChannelFormat.UShort:
					{
						ushort* d = (ushort*)source.Data.ToPointer();
						for (uint channel = 0; channel < channelCount; channel++)
						{
							output[(int)channel] = (double)d[(column + row * width) * channelCount + channel];
						}
						break;
					}
			}
			return output;
		}
예제 #44
0
 public void OnImportsSatisfied()
 {
     FBuffer            = new Spread <Struct>(0);
     FOutput.SliceCount = 0;
 }
예제 #45
0
    private static void SpreadTo(int i, int x, int y)
    {
        cells[i] = false;

        var spread = default(Spread);

        if (spreadCount >= spreads.Count)
        {
            spread = new Spread(); spreads.Add(spread);
        }
        else
        {
            spread = spreads[spreadCount];
        }

        spreadCount += 1;

        spread.i = i;
        spread.x = x;
        spread.y = y;

        splitGroup.AddPixel(x, y);
    }
예제 #46
0
 public ProcessEnum(Spread <T> Processes)
 {
     FProcesses = Processes;
 }
예제 #47
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Spread.Model.Article_type model)
 {
     dal.Add(model);
     return dal.GetMaxID("Id");
 }
예제 #48
0
        private static string model = "yolov2-voc.weights"; //YOLOv2 544x544

        public static YOLODescriptor Detect(Mat image, float threshold, bool enabled)
        {
            SpreadBuilder <Rect>   rectSB             = Spread.CreateBuilder <Rect>();
            SpreadBuilder <float>  confidenceSB       = Spread.CreateBuilder <float>();
            SpreadBuilder <int>    detectedClassSB    = Spread.CreateBuilder <int>();
            SpreadBuilder <float>  classProbabilitySB = Spread.CreateBuilder <float>();
            SpreadBuilder <string> labelSB            = Spread.CreateBuilder <string>();

            if (enabled && image != DefaultMat.Damon)
            {
                var w = image.Width;
                var h = image.Height;
                //setting blob, parameter are important
                var blob = CvDnn.BlobFromImage(image, 1 / 255.0, new Size(544, 544), new Scalar(), true, false);
                if (net == null || net.IsDisposed)
                {
                    net = CvDnn.ReadNetFromDarknet(cfg, model);
                }
                net.SetInput(blob, "data");

                //forward model
                var prob = net.Forward();

                /* YOLO2 VOC output
                 * 0 1 : center                    2 3 : w/h
                 * 4 : confidence                  5 ~24 : class probability */
                const int prefix = 5;   //skip 0~4

                for (int i = 0; i < prob.Rows; i++)
                {
                    var matchConfidence = prob.At <float>(i, 4);
                    if (matchConfidence > threshold)
                    {
                        //get classes probability
                        Point min, max;
                        Cv2.MinMaxLoc(prob.Row[i].ColRange(prefix, prob.Cols), out min, out max);
                        var classes     = max.X;
                        var probability = prob.At <float>(i, classes + prefix);

                        if (probability > threshold) //more accuracy
                        {
                            //get center and width/height
                            var centerX = prob.At <float>(i, 0) * w;
                            var centerY = prob.At <float>(i, 1) * h;
                            var width   = prob.At <float>(i, 2) * w;
                            var height  = prob.At <float>(i, 3) * h;
                            var x1      = (centerX - width / 2) < 0 ? 0 : centerX - width / 2; //avoid left side over edge
                            //org.Rectangle(new Point(centerX - width / 2, centerY - height / 2), new Point(centerX + width / 2, centerY + height / 2), Colors[classes], 2);
                            rectSB.Add(new Rect(new Point(x1, centerY - height / 2), new Size(width, height)));
                            confidenceSB.Add(matchConfidence);
                            detectedClassSB.Add(classes);
                            classProbabilitySB.Add(probability);
                            labelSB.Add(Labels[classes]);
                        }
                    }
                }
            }

            YOLODescriptor result = new YOLODescriptor();

            result.confidence       = confidenceSB.ToSpread();
            result.detectedClass    = detectedClassSB.ToSpread();
            result.classProbability = classProbabilitySB.ToSpread();
            result.classLabel       = labelSB.ToSpread();
            result.rectangles       = rectSB.ToSpread <Rect>();

            return(result);
        }
예제 #49
0
		public AsValueProcessor()
		{
			Output = new Spread<double>(1);
		}
예제 #50
0
        public ISpread <Frame> Preload(
            ISpread <int> visibleFrameIndices,
            ISpread <int> preloadFrameNrs,
            int bufferSize,
            out int frameCount,
            out double durationIO,
            out double durationTexture,
            out int unusedFrames,
            ref ISpread <bool> loadedFrames)
        {
            frameCount      = FFiles.Length;
            durationIO      = 0.0;
            durationTexture = 0.0;
            unusedFrames    = 0;

            // Nothing to do
            if (FFiles.Length == 0)
            {
                loadedFrames.SliceCount = 0;
                return(new Spread <Frame>(0));
            }

            // Map frame numbers to file names
            var preloadFiles = preloadFrameNrs.Select(frameNr => FFiles[VMath.Zmod(frameNr, FFiles.Length)]).ToArray();

            // Dispose previously loaded frames
            foreach (var file in FPreloadedFrames.Keys.ToArray())
            {
                if (!preloadFiles.Contains(file))
                {
                    var frame = FPreloadedFrames[file];
                    Dispose(frame);
                }
            }

            // Ensure that there are as much dequeues as enqueues (or we'll run out of memory)
            while (FScheduledFrameInfos.Count > preloadFrameNrs.SliceCount)
            {
                var frame     = Dequeue();
                var frameInfo = frame.Metadata;
                if (!preloadFiles.Contains(frameInfo.Filename) || frameInfo.IsCanceled)
                {
                    // Not needed anymore
                    Dispose(frame);
                    unusedFrames++;
                }
                else
                {
                    FPreloadedFrames.Add(frameInfo.Filename, frame);
                }
            }

            // Cancel unused scheduled frames
            foreach (var frameInfo in FScheduledFrameInfos.Where(fi => !fi.IsCanceled))
            {
                if (!preloadFiles.Contains(frameInfo.Filename))
                {
                    frameInfo.Cancel();
                }
            }

            // Free resources if there're no frames to preload and we didn't free them yet
            if (preloadFiles.Length == 0 && !FClearedMemoryPool)
            {
                FMemoryPool.Clear();
                // Remember that we cleared the pool
                FClearedMemoryPool = true;
            }

            // Schedule new frames
            foreach (var file in preloadFiles)
            {
                if (!IsScheduled(file) && !IsPreloaded(file))
                {
                    var frameInfo = CreateFrameInfo(file, bufferSize);
                    Enqueue(frameInfo);
                }
                // We're back using resources from the pool -> not clean anymore
                FClearedMemoryPool = false;
            }

            // Write the "is loaded" state
            loadedFrames.SliceCount = preloadFrameNrs.SliceCount;
            for (int i = 0; i < loadedFrames.SliceCount; i++)
            {
                var file = preloadFiles[i];
                if (!IsPreloaded(file))
                {
                    var frameInfo = FScheduledFrameInfos.First(fi => fi.Filename == file);
                    loadedFrames[i] = frameInfo.IsLoaded;
                }
                else
                {
                    loadedFrames[i] = true;
                }
            }

            // Wait for the visible frames (and dipose unused ones)
            var visibleFrames = new Spread <Frame>(0);
            // Map frame numbers to file names
            var visibleFiles = preloadFiles.Length > 0 ? visibleFrameIndices.Select(i => preloadFiles[VMath.Zmod(i, preloadFiles.Length)]) : Enumerable.Empty <string>();

            foreach (var file in visibleFiles)
            {
                while (!IsPreloaded(file))
                {
                    var frame     = Dequeue();
                    var frameInfo = frame.Metadata;
                    if (!preloadFiles.Contains(frameInfo.Filename) || frameInfo.IsCanceled)
                    {
                        // Not needed anymore
                        Dispose(frame);
                        unusedFrames++;
                    }
                    else
                    {
                        FPreloadedFrames.Add(frameInfo.Filename, frame);
                    }
                }
                var visibleFrame     = FPreloadedFrames[file];
                var visibleFrameInfo = visibleFrame.Metadata;
                durationIO      += visibleFrameInfo.DurationIO;
                durationTexture += visibleFrameInfo.DurationTexture;
                visibleFrames.Add(visibleFrame);
            }

            // Release textures of non visible frames
            foreach (var frame in FPreloadedFrames.Values.Where(f => !visibleFrames.Contains(f)))
            {
                frame.Dispose();
            }

            return(visibleFrames);
        }
예제 #51
0
        private List <MidiEvent> CreateTabTrack(List <ZObject> tabTracks, string trackName)
        {
            const int AUDIO_EFFECT = 127;
            const int CHORD        = 126;
            const int EVENT_PHRASE = 125; // Event/phrase
            const int SPREAD       = 124;
            const int WHAMMY       = 123;

            const int TAB_BASS_START = 79;
            //const int TAB_RESERVED_START = 71;
            const int TAB_TREMELO_START       = 63;
            const int TAB_PALM_MUTE_START     = 55;
            const int TAB_EXTENDED_START      = 47;
            const int TAB_VIBRATO_START       = 39;
            const int TAB_BEND_STRENGTH_START = 31;
            const int TAB_BEND_START          = 23;
            const int TAB_TYPE_START          = 15;
            const int TAB_NOTE_START          = 7;

            List <MidiEvent> track = new List <MidiEvent>();

            track.Add(new NAudio.Midi.TextEvent(trackName, MetaEventType.SequenceTrackName, 0));
            if (tabTracks.Count <= 0)
            {
                return(track);
            }

            Tab tab = tabTracks.FirstOrDefault(x => x is Tab) as Tab;

            if (tab != null)
            {
                foreach (TabEntry entry in tab.Events)
                {
                    long start        = GetAbsoluteTime(entry.Start);
                    long end          = GetAbsoluteTime(entry.End);
                    int  stringNumber = entry.StringNumber - 1;

                    // Playable notes
                    track.Add(new NoteEvent(start, 1 + (int)entry.Finger, MidiCommandCode.NoteOn, TAB_NOTE_START - stringNumber, 100 + entry.FretNumber));
                    track.Add(new NoteEvent(end, 1 + (int)entry.Finger, MidiCommandCode.NoteOff, TAB_NOTE_START - stringNumber, 100 + entry.FretNumber));

                    // Note type (Modifier)
                    if (entry.NoteType > 0)
                    {
                        track.Add(new NoteEvent(start, (int)entry.NoteType, MidiCommandCode.NoteOn, TAB_TYPE_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, (int)entry.NoteType, MidiCommandCode.NoteOff, TAB_TYPE_START - stringNumber, 100));
                    }

                    // Bend type
                    if (entry.BendType > 0)
                    {
                        track.Add(new NoteEvent(start, (int)entry.BendType, MidiCommandCode.NoteOn, TAB_BEND_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, (int)entry.BendType, MidiCommandCode.NoteOff, TAB_BEND_START - stringNumber, 100));
                    }

                    // Bend strength
                    if (entry.BendStrength != 0.0f)
                    {
                        // Should be increments of 0.25f
                        int value = (int)(entry.BendStrength / 0.25f);

                        track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, TAB_BEND_STRENGTH_START - stringNumber, 100 + value));
                        track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, TAB_BEND_STRENGTH_START - stringNumber, 100 + value));
                    }

                    // Vibrato type
                    if (entry.VibratoType > 0)
                    {
                        track.Add(new NoteEvent(start, (int)entry.VibratoType, MidiCommandCode.NoteOn, TAB_VIBRATO_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, (int)entry.VibratoType, MidiCommandCode.NoteOff, TAB_VIBRATO_START - stringNumber, 100));
                    }

                    // Extended note
                    if (entry.ExtendedNote)
                    {
                        track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, TAB_EXTENDED_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, TAB_EXTENDED_START - stringNumber, 100));
                    }

                    // Palm mute
                    if (entry.PalmMute)
                    {
                        track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, TAB_PALM_MUTE_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, TAB_PALM_MUTE_START - stringNumber, 100));
                    }

                    // Extended note
                    if (entry.Tremelo)
                    {
                        track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, TAB_TREMELO_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, TAB_TREMELO_START - stringNumber, 100));
                    }

                    // Bass type
                    if (entry.BassType > 0)
                    {
                        track.Add(new NoteEvent(start, (int)entry.BassType, MidiCommandCode.NoteOn, TAB_BASS_START - stringNumber, 100));
                        track.Add(new NoteEvent(end, (int)entry.BassType, MidiCommandCode.NoteOff, TAB_BASS_START - stringNumber, 100));
                    }
                }
            }

            AudioEffect aEffect = tabTracks.FirstOrDefault(x => x is AudioEffect) as AudioEffect;

            if (aEffect != null)
            {
                foreach (AudioEffectEntry entry in aEffect.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    track.Add(new NAudio.Midi.TextEvent($"a \"{entry.EffectPath}\"", MetaEventType.TextEvent, start));
                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, AUDIO_EFFECT, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, AUDIO_EFFECT, 100));
                }
            }

            Chord chord = tabTracks.FirstOrDefault(x => x is Chord) as Chord;

            if (chord != null)
            {
                foreach (var entry in chord.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    track.Add(new NAudio.Midi.TextEvent($"c \"{entry.EventName}\"", MetaEventType.TextEvent, start));
                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, CHORD, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, CHORD, 100));
                }
            }

            Event ev = tabTracks.FirstOrDefault(x => x is Event) as Event;

            if (ev != null)
            {
                foreach (var entry in ev.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    if (entry.EventName.Value != "Phrase")
                    {
                        // Should always be a phrase but idk...
                        track.Add(new NAudio.Midi.TextEvent($"e \"{entry.EventName}\"", MetaEventType.TextEvent, start));
                    }

                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, EVENT_PHRASE, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, EVENT_PHRASE, 100));
                }
            }

            Spread spread = tabTracks.FirstOrDefault(x => x is Spread) as Spread;

            if (spread != null)
            {
                foreach (SpreadEntry entry in spread.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    // Should be increments of 0.25f
                    int value = (int)((entry.Speed - 1.0f) / 0.25f);

                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, SPREAD, 100 + value));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, SPREAD, 100 + value));
                }
            }

            Whammy whammy = tabTracks.FirstOrDefault(x => x is Whammy) as Whammy;

            if (whammy != null)
            {
                foreach (WhammyEntry entry in whammy.Events)
                {
                    long start = GetAbsoluteTime(entry.Start);
                    long end   = GetAbsoluteTime(entry.End);

                    track.Add(new NoteEvent(start, 1, MidiCommandCode.NoteOn, WHAMMY, 100));
                    track.Add(new NoteEvent(end, 1, MidiCommandCode.NoteOff, WHAMMY, 100));
                }
            }

            // Sort by absolute time (And ensure track name is first event)
            track.Sort((x, y) => (int)(x is NAudio.Midi.TextEvent &&
                                       ((NAudio.Midi.TextEvent)x).MetaEventType == MetaEventType.SequenceTrackName
                                       ? int.MinValue : x.AbsoluteTime - y.AbsoluteTime));

            // Adds end track
            track.Add(new MetaEvent(MetaEventType.EndTrack, 0, track.Last().AbsoluteTime));
            return(track);
        }
예제 #52
0
 public MultiSineSignal(ISpread <float> frequency, ISpread <float> gain)
 {
     Frequencies = frequency;
     Gains       = gain;
     Phases      = new Spread <float>();
 }