示例#1
0
        public SlideRelayToTapOperation(Slide slide, List <Note> noteList)
        {
            var tapList   = new List <SlideTap>();
            var relayList = noteList.Where(x => slide.Contains(x) && x is SlideRelay).ToList();

            relayList.ForEach(x => tapList.Add(new SlideTap(x)));
            Invoke += () =>
            {
                relayList.ForEach(x => slide.Remove(x));
                tapList.ForEach(x => slide.Add(x));
            };
            Undo += () =>
            {
                tapList.ForEach(x => slide.Remove(x));
                relayList.ForEach(x => slide.Add(x));
            };
        }
示例#2
0
 public AddStepNoteOperation(Slide slide, SlideRelay slideRelay)
 {
     Invoke += () =>
     {
         slide.Add(slideRelay);
     };
     Undo += () =>
     {
         slide.Remove(slideRelay);
     };
 }
示例#3
0
 public AddStepNoteOperation(Slide slide, SlideCurve slideCurve)
 {
     Invoke += () =>
     {
         slide.Add(slideCurve);
     };
     Undo += () =>
     {
         slide.Remove(slideCurve);
     };
 }
示例#4
0
 public CutSlideOperation(Model model, Slide slide, Note past, Note future)
 {
     #region 分割した手前側のSlideノーツを生成
     Slide before = new Slide();
     foreach (var note in slide.Where(x => x.Position.Tick < past.Position.Tick))
     {
         before.Add(note);
     }
     before.Add(new SlideEnd(past));
     #endregion
     #region 分割した奥側のSlideノーツを生成
     Slide after = new Slide();
     after.Add(new SlideBegin(future));
     foreach (var note in slide.Where(x => x.Position.Tick > future.Position.Tick))
     {
         after.Add(note);
     }
     #endregion
     Invoke += () =>
     {
         if (!slide.Any() || !before.Any() || !after.Any())
         {
             Logger.Warn("空のSlideが存在します。", true);
             return;
         }
         model.NoteBook.UnPut(slide);
         model.NoteBook.Put(before);
         model.NoteBook.Put(after);
     };
     Undo += () =>
     {
         if (!slide.Any() || !before.Any() || !after.Any())
         {
             Logger.Warn("空のSlideが存在します。", true);
             return;
         }
         model.NoteBook.Put(slide);
         model.NoteBook.UnPut(before);
         model.NoteBook.UnPut(after);
     };
 }
示例#5
0
 /// <summary>
 /// 2つのSlideは時間順的に正しくなるように与えられていることを前提とする。
 /// </summary>
 /// <param name="model"></param>
 /// <param name="past"></param>
 /// <param name="future"></param>
 public ConnectSlideOperation(Model model, Slide past, Slide future)
 {
     // 一応確認をしてアサートが出るようにはしておくか...
     System.Diagnostics.Debug.Assert(
         past.EndTick < future.StartTick,
         "Slideの位置関係が不適切です。");
     #region 結合したSlide(union)を作成
     Slide union = new Slide();
     var   end   = past.Find(x => x is SlideEnd);
     System.Diagnostics.Debug.Assert(end != null, "Slide終点が見つかりません。");
     foreach (var note in past.Where(x => x != end))
     {
         union.Add(note);
     }
     union.Add(new Note(end) as SlideTap);
     var begin = future.Find(x => x is SlideBegin);
     System.Diagnostics.Debug.Assert(begin != null, "Slide始点が見つかりません。");
     union.Add(new Note(begin) as SlideTap);
     foreach (var note in future.Where(x => x != begin))
     {
         union.Add(note);
     }
     #endregion
     Invoke += () =>
     {
         model.NoteBook.Put(union);
         model.NoteBook.UnPut(past);
         model.NoteBook.UnPut(future);
     };
     Undo += () =>
     {
         model.NoteBook.Put(past);
         model.NoteBook.Put(future);
         model.NoteBook.UnPut(union);
     };
 }
示例#6
0
 public ReplicateSlidePatternOperation(
     Model model, Slide slide, List <Note> pattern, int times, int tickInterval)
 {
     #region 複製したSlideを新規作成
     var after         = slide.DeepCopy();
     var patternLength =
         pattern.OrderBy(x => x.Position.Tick).Last().Position.Tick -
         pattern.OrderBy(x => x.Position.Tick).First().Position.Tick;
     for (int i = 1; i <= times; ++i)
     {
         var addPattern = ReplicatePattern(pattern);
         addPattern.ForEach(x =>
         {
             var tick = x.Position.Tick;
             tick    += i * (patternLength + tickInterval);
             x.RelocateOnly(new Position(x.Position.Lane, tick));
             slide.Add(x);
             var sameTick = slide.Find(y => y.Position.Tick == x.Position.Tick);
             if (sameTick != null)
             {
                 slide.Remove(sameTick);
             }
         });
     }
     var slideEnd = after.FindLast(x => x is SlideEnd);
     var endTap   = after.Last();
     if (slideEnd.Position.Tick <= endTap.Position.Tick)
     {
         slideEnd.RelocateOnly(endTap.Position);
         after.Remove(endTap);
     }
     #endregion
     Invoke += () =>
     {
         model.NoteBook.UnPut(slide);
         model.NoteBook.Put(after);
     };
     Undo += () =>
     {
         model.NoteBook.UnPut(after);
         model.NoteBook.Put(slide);
     };
 }
示例#7
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        Data objdata = new Data(Global.ConnectionSql);

        try
        {
            Slide obj = new Slide();
            obj.DataObject = objdata;
            HttpFileCollection httpFileCollection = Request.Files;
            for (int i = 0; i < httpFileCollection.Count; i++)
            {
                HttpPostedFile httpPostedFile = httpFileCollection[i];
                if (httpPostedFile.ContentLength > 0)
                {
                    obj.Images      = Global.GetConfigKey("ads") + httpPostedFile.FileName;
                    obj.Links       = txtlinks.Text.Trim();
                    obj.Tabs        = ddltabs.SelectedValue;
                    obj.Title       = string.Empty;
                    obj.UserCreated = Session["username"].ToString();
                    obj.IsDeleted   = false;
                    int iresult = Convert.ToInt32(obj.Add());
                    httpPostedFile.SaveAs(Server.MapPath("~/" + Global.GetConfigKey("ads")) + "/" + System.IO.Path.GetFileName(httpPostedFile.FileName));
                }
            }
            this.BindingData();
        }
        catch (Exception ex)
        {
            Global.WriteLogError("Update () " + ex);
            mpUpload.Show();
        }
        finally
        {
            objdata.DeConnect();
        }
    }
示例#8
0
        public void ContainsTest()
        {
            var book = new NoteBook();
            var tap  = new Tap();

            book.Put(tap);
            Assert.IsTrue(book.Contains(tap));
            Assert.AreEqual(true, book.Contains(tap as AirableNote));
            var airable = tap as AirableNote;

            Assert.AreEqual(true, book.Contains(airable));
            var note = airable as Note;

            Assert.AreEqual(true, book.Contains(note));

            var slide = new Slide();

            slide.Add(new SlideBegin());
            slide.Add(new SlideEnd());
            var rnd = new Random();

            for (int i = 0; i < 100; ++i)
            {
                switch (rnd.Next() % 3)
                {
                case 0: slide.Add(new SlideTap()); break;

                case 1: slide.Add(new SlideRelay()); break;

                case 2: slide.Add(new SlideCurve()); break;

                default: break;
                }
            }
            var sw = new Stopwatch();

            {
                sw.Start();
                var copy = new Slide(slide);
                sw.Stop();
                Debug.WriteLine($"Copy by constructor(Slide) : {sw.ElapsedMilliseconds} [ms]");
            }
            sw.Reset();
            {
                sw.Start();
                var copy = MyUtil.DeepCopy(slide);
                sw.Stop();
                Debug.WriteLine($"Copy by method(Slide) : {sw.ElapsedMilliseconds} [ms]");
            }
            // コピーコンストラクタの方法よりもディープコピーの方法のほうがだいたい10倍くらい早い(型を調べてるから当然ではあるけど)

            var target = new List <Position>();

            for (int i = 0; i < 10000; ++i)
            {
                target.Add(new Position(rnd.Next(), rnd.Next()));
            }
            sw.Reset();
            {
                sw.Start();
                var copy = new List <Position>(target);
                sw.Stop();
                Debug.WriteLine($"Copy by constructor(List<Position>) : {sw.ElapsedMilliseconds} [ms]");
            }
            sw.Reset();
            {
                sw.Start();
                var copy = MyUtil.DeepCopy(target);
                sw.Stop();
                Debug.WriteLine($"Copy by method(List<Position>) : {sw.ElapsedMilliseconds} [ms]");
            }
            // こっちだとディープコピーのほうが普通に遅い(Listのコンストラクタのほうは要素数10000でも0ms)

            sw.Reset();
            {
                sw.Start();
                foreach (var item in target)
                {
                    var copy = new Position(item);
                }
                sw.Stop();
                Debug.WriteLine($"Copy by constructor(Position) : {sw.ElapsedMilliseconds} [ms]");
            }
            sw.Reset();
            {
                sw.Start();
                foreach (var item in target)
                {
                    var copy = MyUtil.DeepCopy(item);
                }
                sw.Stop();
                Debug.WriteLine($"Copy by method(Position) : {sw.ElapsedMilliseconds} [ms]");
            }
            // これもコピーコンストラクタのほうが早い

            // 基本はコピーコンストラクタを使い、型を調べる必要があるならディープコピーのほうが良い?
        }