示例#1
0
    public TimeLinePage(XmlNodeList milestones, MenuElement menuElement)
    {
        _totalItemNum	= milestones.Count;
        _totalHeight	= (_totalItemNum - 1) * 25;
        _menuElement	= menuElement;

        texture	= _menuElement.GetTextureById("timelinebg");
        Debug.Log("w="+texture.width+", h="+texture.height);
        for (int i=0; i<_totalItemNum; i++){
            TimeLineItem item = new TimeLineItem(_menuElement);
            item.setLabel(_menuElement.GetTextureById(milestones[i].Attributes["time"].Value));

            addItem(item);

            Sprite itemImg	= new Sprite(_menuElement.GetTextureById(milestones[i].Attributes["pic"].Value));
            _itemImgAry.Add(itemImg);
            addChild(itemImg);

            Sprite itemTxt	= new Sprite(_menuElement.GetTextureById(milestones[i].Attributes["text"].Value));
            _itemTxtAry.Add(itemTxt);
            addChild(itemTxt);
            itemTxt.alpha	= 0.0f;
            itemTxt.y		= 640f;
            itemTxt.x		= (_texture.width-itemTxt.width)/2-20;
        }
        this.addEventListner(GuiEvent.CHANGE, new EventDispatcher.CallBack(selectChangeHandler));
        //this.addEventListner(GuiEvent.ENTER_FRAME,new EventDispatcher.CallBack(enterFrameHandler));
        selectItemByIndex(_totalItemNum-1);
    }
示例#2
0
        private void textBlock_QT_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TimeLineItem target = ((sender as Image).TemplatedParent as ContentPresenter).Content as TimeLineItem;

            if (target == null)
            {
                return;
            }

            if (target.Tweet.User.IsProtected)
            {
                MessageBox.Show("This user is protected.",
                                "Info.",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            string screenName = target.Tweet.User.ScreenName;
            string id         = target.Tweet.ToString();

            this.main.textBox_Tweet.Text += string.Format(@"https://twitter.com/{0}/status/{1}",
                                                          screenName,
                                                          id);
            this.main.textBox_Tweet.Focus();
        }
示例#3
0
        private async void textBlock_Fav_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                TimeLineItem target = ((sender as Image).TemplatedParent as ContentPresenter).Content as TimeLineItem;
                if (target == null)
                {
                    return;
                }

                long id = target.Tweet.Id;
                if (target.IsFav)
                {
                    await this.account.TokensData.Favorites.DestroyAsync(id);

                    target.IsFav = false;
                }
                else
                {
                    await this.account.TokensData.Favorites.CreateAsync(id);

                    target.IsFav = true;
                }
            }
            catch (TwitterException tex)
            {
                MessageBox.Show(tex.Message,
                                "Twitter Exception.",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
        }
示例#4
0
 private void RecordedInputUpdate(TimeLineItem timeLineItem)
 {
     if (TimeLine.InvokeRequired)
     {
         this.Invoke(new MethodInvoker(delegate { TimeLine.Items.Add(timeLineItem); }));
     }
 }
示例#5
0
        private async void textBlock_RT_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                TimeLineItem target = ((sender as Image).TemplatedParent as ContentPresenter).Content as TimeLineItem;
                if (target == null)
                {
                    return;
                }

                if (target.Tweet.User.IsProtected)
                {
                    MessageBox.Show("This user is protected.",
                                    "Info.",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                    return;
                }

                long id = target.Tweet.Id;
                await this.account.TokensData.Statuses.RetweetAsync(id);

                target.IsRetweeted = true;
            }
            catch (TwitterException tex)
            {
                MessageBox.Show(tex.Message,
                                "Twitter Exception.",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
        }
示例#6
0
        public async Task <IActionResult> Delete(int id)
        {
            UserAccess userAccess = await _context.UserAccessDb.SingleOrDefaultAsync(u => u.AccessId == id);

            if (userAccess != null)
            {
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.AsNoTracking().SingleOrDefaultAsync(p => p.Id == userAccess.ProgenyId);

                if (prog != null)
                {
                    // Check if user is allowed to delete users for this child.
                    string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail;
                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                Progeny progeny = await _dataService.GetProgeny(userAccess.ProgenyId);

                if (userAccess.AccessLevel == (int)AccessLevel.Private && progeny.IsInAdminList(userAccess.UserId))
                {
                    string[] adminList = progeny.Admins.Split(',');
                    progeny.Admins = "";
                    foreach (string adminItem in adminList)
                    {
                        if (!adminItem.Trim().ToUpper().Equals(userAccess.UserId.Trim().ToUpper()))
                        {
                            progeny.Admins = progeny.Admins + ", " + userAccess.UserId.ToUpper();
                        }
                    }
                    progeny.Admins = progeny.Admins.Trim(',');
                    await _dataService.UpdateProgenyAdmins(progeny);
                }

                _context.UserAccessDb.Remove(userAccess);
                await _context.SaveChangesAsync();

                await _dataService.RemoveUserAccess(userAccess.AccessId, userAccess.ProgenyId, userAccess.UserId);

                string       title    = "User removed for " + prog.NickName;
                UserInfo     userinfo = _context.UserInfoDb.SingleOrDefault(u => u.UserEmail.ToUpper() == User.GetEmail().ToUpper());
                string       message  = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " removed user: " + userAccess.UserId;
                TimeLineItem tItem    = new TimeLineItem();
                tItem.ProgenyId   = userAccess.ProgenyId;
                tItem.AccessLevel = 0;
                tItem.ItemId      = userAccess.AccessId.ToString();
                tItem.ItemType    = (int)KinaUnaTypes.TimeLineType.UserAccess;
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(NoContent());
            }

            return(NotFound());
        }
示例#7
0
        public async Task <IActionResult> Delete(int id)
        {
            TimeLineItem timeLineItem = await _context.TimeLineDb.SingleOrDefaultAsync(t => t.TimeLineId == id);

            if (timeLineItem != null)
            {
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.AsNoTracking().SingleOrDefaultAsync(p => p.Id == timeLineItem.ProgenyId);

                string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail;
                if (prog != null)
                {
                    // Check if user is allowed to delete timeline items for this child.
                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                _context.TimeLineDb.Remove(timeLineItem);
                await _context.SaveChangesAsync();

                await _dataService.RemoveTimeLineItem(timeLineItem.TimeLineId, timeLineItem.ItemType, timeLineItem.ProgenyId);

                return(NoContent());
            }

            return(NotFound());
        }
示例#8
0
        private async void ItemAppearingEvent(object sender, ItemVisibilityEventArgs e)
        {
            TimeLineItem tItem = e.Item as TimeLineItem;

            if (tItem == null)
            {
                return;
            }

            int progenyId = tItem.ProgenyId;

            if (progenyId != _viewModel.Progeny.Id)
            {
                return;
            }
            tItem.VisibleBefore = true;
            int itemsNotVisibleBeforeCount = _viewModel.TimeLineItems.Count(t => t.VisibleBefore == false);

            if (_viewModel.CanLoadMore && itemsNotVisibleBeforeCount < 30)
            {
                await LoadItems(_timeLineList.Count - _dateHeaderCount, _viewModel.Progeny.Id, _viewModel.UserInfo.Timezone);
            }

            if (_viewModel.CanShowMore)
            {
                ShowNextItem();
            }
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.timeLinePanel1.Items.Count == 0)
            {
                TimeLineItem item1 = new TimeLineItem();
                item1.DateFrom = new DateTime(2010, 1, 3, 10, 0, 0);
                item1.DateTo   = new DateTime(2010, 1, 3, 12, 0, 0);
                item1.Element  = new Button();

                TimeLineItem item2 = new TimeLineItem();
                item2.DateFrom = new DateTime(2010, 1, 3, 11, 00, 0);
                item2.DateTo   = new DateTime(2010, 1, 3, 12, 30, 0);
                item2.Element  = new ListBox();

                TimeLineItem item3 = new TimeLineItem();
                item3.DateFrom = new DateTime(2010, 1, 3, 10, 30, 0);
                item3.DateTo   = new DateTime(2010, 1, 5, 11, 30, 0);
                MarkerPanel markerPanel3 = new MarkerPanel()
                {
                    Horizontal = true, BackColor = SystemColors.ButtonHighlight
                };
                markerPanel3.Text = "SomeLogFileName.log";
                markerPanel3.ShowMarkersAsync(20, new Dictionary <int, Color>()
                {
                    { 1, Color.Red }, { 5, Color.Orange }, { 7, Color.Red }
                });
                item3.Element = markerPanel3;

                this.timeLinePanel1.Items.Add(item1);
                this.timeLinePanel1.Items.Add(item2);
                this.timeLinePanel1.Items.Add(item3);
            }
            this.timeLinePanel1.PixelsPerHour = this.trackBar1.Value;
            this.timeLinePanel1.RefreshContent();
        }
示例#10
0
        public TimeLine CreateTimeLine(PeriodSplitter.PeriodSplitter splitter, PeriodNameFormatter PeriodNameFormatter,
                                       BackgroundFormatter backgroundFormatter, string timeLineName, Brush timeLineColor)
        {
            if (splitter.MaxDate != GanttData.MaxDate || splitter.MinDate != GanttData.MinDate)
            {
                throw new ArgumentException("The timeline must have the same max and min -date as the chart");
            }

            var timeLineParts = splitter.Split();

            TimeLine timeline = new TimeLine();

            timeline.Name            = timeLineName;
            timeline.BackgroundColor = timeLineColor;
            foreach (var p in timeLineParts)
            {
                TimeLineItem item = new TimeLineItem()
                {
                    Name = PeriodNameFormatter(p), Start = p.Start, End = p.End.AddSeconds(-1)
                };
                item.BackgroundColor = backgroundFormatter(item);
                timeline.Items.Add(item);
            }

            ganttChartData.TimeLines.Add(timeline);
            return(timeline);
        }
示例#11
0
 public void SetStatuses(List <Status> statusList)
 {
     foreach (Status status in statusList)
     {
         TimeLineItem item = new TimeLineItem(status, this.account.ScreenName);
         this.timeLine.Add(item);
     }
 }
 private Brush DetermineBackground(TimeLineItem timeLineItem)
 {
     if (timeLineItem.End.Date.DayOfWeek == DayOfWeek.Saturday || timeLineItem.End.Date.DayOfWeek == DayOfWeek.Sunday)
     {
         return(new SolidColorBrush(Colors.LightBlue));
     }
     return(new SolidColorBrush(Colors.Transparent));
 }
示例#13
0
        public async Task <IActionResult> Delete(int id)
        {
            Location location = await _context.LocationsDb.SingleOrDefaultAsync(l => l.LocationId == id);

            if (location != null)
            {
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.AsNoTracking().SingleOrDefaultAsync(p => p.Id == location.ProgenyId);

                string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail;
                if (prog != null)
                {
                    // Check if user is allowed to delete locations for this child.
                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                TimeLineItem tItem = await _context.TimeLineDb.SingleOrDefaultAsync(t =>
                                                                                    t.ItemId == location.LocationId.ToString() &&
                                                                                    t.ItemType == (int)KinaUnaTypes.TimeLineType.Location);

                if (tItem != null)
                {
                    if (location.Date.HasValue)
                    {
                        tItem.ProgenyTime = location.Date.Value;
                    }

                    tItem.AccessLevel = location.AccessLevel;
                    _context.TimeLineDb.Remove(tItem);
                    await _context.SaveChangesAsync();

                    await _dataService.RemoveTimeLineItem(tItem.TimeLineId, tItem.ItemType, tItem.ProgenyId);
                }

                _context.LocationsDb.Remove(location);
                await _context.SaveChangesAsync();

                await _dataService.RemoveLocation(location.LocationId, location.ProgenyId);

                UserInfo userinfo = await _dataService.GetUserInfoByEmail(userEmail);

                string title   = "Location deleted for " + prog.NickName;
                string message = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " deleted a location for " + prog.NickName + ". Location: " + location.Name;
                tItem.AccessLevel = 0;
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(NoContent());
            }

            return(NotFound());
        }
示例#14
0
        private void chkPlaySound_CheckedChanged(object sender, EventArgs e)
        {
            TimeLineItem tlItem = ((TimeLineItem)TimeLine.SelectedItem);

            if (null != tlItem)
            {
                tlItem.PlaySound = chkPlaySound.Checked;
            }
        }
示例#15
0
        private void playTimeline()
        {
            sf4control.ResetLockupTimer();
            for (int i = 0; i < TimeLine.Items.Count; i++)
            {
                TimeLineItem item = (TimeLineItem)TimeLine.Items[i];

                //highlighting of current item
                DoThreadSafe(TimeLine, () =>
                {
                    TimeLine.TopIndex     = i - (TimeLine.ClientSize.Height / TimeLine.ItemHeight) / 2;
                    TimeLine.SelectedItem = item;
                });

                // if we aren't in a match (defined by being on a menu or pause is selected) the play timeline stops.
                if (sf4control.InMatch)
                {
                    item.Action(sf4control, chkSendInputs.Checked);
                }
                else
                {
                    // Get the last item in the list
                    i    = TimeLine.Items.Count - 1;
                    item = (TimeLineItem)TimeLine.Items[i];

                    //highlighting the last item.
                    DoThreadSafe(TimeLine, () =>
                    {
                        TimeLine.TopIndex     = i - (TimeLine.ClientSize.Height / TimeLine.ItemHeight) / 2;
                        TimeLine.SelectedItem = item;
                        //also kill loop
                        stopLoop();
                    });

                    string message = "The combo trainer has detected that SF4 didn't produce any new frames in the last 3 seconds. Make sure that\n\na) Street Fighter 4 is running and inside a match or training mode\nb) Street Fighter is not paused\nc) You are running the latest version of Street Fighter 4 AEv2012\nd) Stage Quality in your SF4 graphic settings is set to HIGH";

                    MessageBox.Show(message, "SF4 not advancing frames", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    break;
                }
            }


            //// Get the last item in the list
            //TimeLineItem lastItem = (TimeLineItem)TimeLine.Items[TimeLine.Items.Count - 1];

            ////highlighting the last item.
            //DoThreadSafe(TimeLine, () =>
            //{
            //    TimeLine.TopIndex = TimeLine.Items.Count - 1 - (TimeLine.ClientSize.Height / TimeLine.ItemHeight) / 2;
            //    TimeLine.SelectedItem = lastItem;
            //    //also kill loop
            //    stopLoop();
            //});
        }
示例#16
0
        public async Task <IActionResult> Delete(int id)
        {
            CalendarItem calendarItem = await _context.CalendarDb.SingleOrDefaultAsync(c => c.EventId == id);

            if (calendarItem != null)
            {
                string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail;
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.SingleOrDefaultAsync(p => p.Id == calendarItem.ProgenyId);

                if (prog != null)
                {
                    // Check if user is allowed to edit calendar items for this child.

                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                TimeLineItem tItem = await _context.TimeLineDb.SingleOrDefaultAsync(t =>
                                                                                    t.ItemId == calendarItem.EventId.ToString() && t.ItemType == (int)KinaUnaTypes.TimeLineType.Calendar);

                if (tItem != null)
                {
                    _context.TimeLineDb.Remove(tItem);
                    await _context.SaveChangesAsync();

                    await _dataService.RemoveTimeLineItem(tItem.TimeLineId, tItem.ItemType, tItem.ProgenyId);
                }

                _context.CalendarDb.Remove(calendarItem);
                await _context.SaveChangesAsync();

                await _dataService.RemoveCalendarItem(calendarItem.EventId, calendarItem.ProgenyId);


                UserInfo userinfo = await _dataService.GetUserInfoByEmail(userEmail);

                string title   = "Calendar item deleted for " + prog.NickName;
                string message = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " deleted a calendar item for " + prog.NickName;
                tItem.AccessLevel = 0;
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
示例#17
0
 private System.Windows.Media.Brush DetermineBackground(TimeLineItem timeLineItem)
 {
     if (timeLineItem.End.Date.DayOfWeek == DayOfWeek.Saturday || timeLineItem.End.Date.DayOfWeek == DayOfWeek.Sunday)
     {
         return(new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightBlue));
     }
     else
     {
         return(new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent));
     }
 }
示例#18
0
        public async Task <IActionResult> Delete(int id)
        {
            Measurement measurementItem = await _context.MeasurementsDb.SingleOrDefaultAsync(m => m.MeasurementId == id);

            if (measurementItem != null)
            {
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.AsNoTracking().SingleOrDefaultAsync(p => p.Id == measurementItem.ProgenyId);

                string userEmail = User.GetEmail() ?? Constants.DefaultUserEmail;
                if (prog != null)
                {
                    // Check if user is allowed to delete measurements for this child.
                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                TimeLineItem tItem = await _context.TimeLineDb.SingleOrDefaultAsync(t =>
                                                                                    t.ItemId == measurementItem.MeasurementId.ToString() && t.ItemType == (int)KinaUnaTypes.TimeLineType.Measurement);

                if (tItem != null)
                {
                    _context.TimeLineDb.Remove(tItem);
                    await _context.SaveChangesAsync();

                    await _dataService.RemoveTimeLineItem(tItem.TimeLineId, tItem.ItemType, tItem.ProgenyId);
                }

                _context.MeasurementsDb.Remove(measurementItem);
                await _context.SaveChangesAsync();

                await _dataService.RemoveMeasurement(measurementItem.MeasurementId, measurementItem.ProgenyId);

                UserInfo userinfo = await _dataService.GetUserInfoByEmail(userEmail);

                string title   = "Measurement deleted for " + prog.NickName;
                string message = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " deleted a measurement for " + prog.NickName + ". Measurement date: " + measurementItem.Date.Date.ToString("dd-MMM-yyyy");
                tItem.AccessLevel = 0;
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
示例#19
0
        public async Task <IActionResult> Delete(int id)
        {
            Sleep sleepItem = await _context.SleepDb.SingleOrDefaultAsync(s => s.SleepId == id);

            if (sleepItem != null)
            {
                string userEmail = User.GetEmail();
                // Check if child exists.
                Progeny prog = await _context.ProgenyDb.SingleOrDefaultAsync(p => p.Id == sleepItem.ProgenyId);

                if (prog != null)
                {
                    // Check if user is allowed to delete sleep for this child.

                    if (!prog.IsInAdminList(userEmail))
                    {
                        return(Unauthorized());
                    }
                }
                else
                {
                    return(NotFound());
                }

                TimeLineItem tItem = await _context.TimeLineDb.SingleOrDefaultAsync(t =>
                                                                                    t.ItemId == sleepItem.SleepId.ToString() && t.ItemType == (int)KinaUnaTypes.TimeLineType.Sleep);

                if (tItem != null)
                {
                    _context.TimeLineDb.Remove(tItem);
                    await _context.SaveChangesAsync();

                    await _dataService.RemoveTimeLineItem(tItem.TimeLineId, tItem.ItemType, tItem.ProgenyId);
                }

                _context.SleepDb.Remove(sleepItem);
                await _context.SaveChangesAsync();

                await _dataService.RemoveSleep(sleepItem.SleepId, sleepItem.ProgenyId);

                string   title    = "Sleep for " + prog.NickName + " deleted";
                UserInfo userinfo = _context.UserInfoDb.SingleOrDefault(u => u.UserEmail.ToUpper() == userEmail.ToUpper());
                string   message  = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " deleted a sleep item for " + prog.NickName + ". Sleep start: " + sleepItem.SleepStart.ToString("dd-MMM-yyyy HH:mm");
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
示例#20
0
        public async Task <IActionResult> Put(int id, [FromBody] Video value)
        {
            Video video = await _context.VideoDb.SingleOrDefaultAsync(v => v.VideoId == id);

            // Todo: more validation of the values
            if (video == null)
            {
                return(NotFound());
            }

            // Check if user should be allowed access.
            string     userEmail  = User.GetEmail() ?? Constants.DefaultUserEmail;
            UserAccess userAccess = _progenyDbContext.UserAccessDb.AsNoTracking().SingleOrDefault(u =>
                                                                                                  u.ProgenyId == video.ProgenyId && u.UserId.ToUpper() == userEmail.ToUpper());

            if (userAccess == null || userAccess.AccessLevel > 0)
            {
                return(Unauthorized());
            }

            video.Tags        = value.Tags;
            video.AccessLevel = value.AccessLevel;
            video.Author      = value.Author;
            video.VideoTime   = value.VideoTime;
            video.Duration    = value.Duration;
            video.Location    = value.Location;
            video.Longtitude  = value.Longtitude;
            video.Latitude    = value.Latitude;
            video.Altitude    = value.Altitude;
            _context.VideoDb.Update(video);
            await _context.SaveChangesAsync();

            await _dataService.SetVideo(video.VideoId);

            Progeny prog = await _dataService.GetProgeny(video.ProgenyId);

            UserInfo userinfo = await _dataService.GetUserInfoByEmail(User.GetEmail());

            string       title   = "Video Edited for " + prog.NickName;
            string       message = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " edited a video for " + prog.NickName;
            TimeLineItem tItem   = new TimeLineItem();

            tItem.ProgenyId   = video.ProgenyId;
            tItem.ItemId      = video.VideoId.ToString();
            tItem.ItemType    = (int)KinaUnaTypes.TimeLineType.Video;
            tItem.AccessLevel = video.AccessLevel;
            await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

            return(Ok(video));
        }
示例#21
0
        public async Task <IActionResult> Post([FromBody] Video model)
        {
            // Check if user should be allowed access.
            string     userEmail  = User.GetEmail() ?? Constants.DefaultUserEmail;
            UserAccess userAccess = _progenyDbContext.UserAccessDb.SingleOrDefault(u =>
                                                                                   u.ProgenyId == model.ProgenyId && u.UserId.ToUpper() == userEmail.ToUpper());

            if (userAccess == null || userAccess.AccessLevel > 0)
            {
                return(Unauthorized());
            }

            Video vid = await _context.VideoDb.SingleOrDefaultAsync(v =>
                                                                    v.VideoLink == model.VideoLink && v.ProgenyId == model.ProgenyId);

            if (vid == null)
            {
                CommentThread commentThread = new CommentThread();
                await _context.CommentThreadsDb.AddAsync(commentThread);

                await _context.SaveChangesAsync();

                model.CommentThreadNumber = commentThread.Id;

                await _context.VideoDb.AddAsync(model);

                await _context.SaveChangesAsync();

                await _dataService.SetVideo(model.VideoId);

                Progeny prog = await _dataService.GetProgeny(model.ProgenyId);

                UserInfo userinfo = await _dataService.GetUserInfoByEmail(User.GetEmail());

                string       title   = "New Video added for " + prog.NickName;
                string       message = userinfo.FirstName + " " + userinfo.MiddleName + " " + userinfo.LastName + " added a new video for " + prog.NickName;
                TimeLineItem tItem   = new TimeLineItem();
                tItem.ProgenyId   = model.ProgenyId;
                tItem.ItemId      = model.VideoId.ToString();
                tItem.ItemType    = (int)KinaUnaTypes.TimeLineType.Video;
                tItem.AccessLevel = model.AccessLevel;
                await _azureNotifications.ProgenyUpdateNotification(title, message, tItem, userinfo.ProfilePicture);

                return(Ok(model));
            }

            model = vid;

            return(Ok(model));
        }
示例#22
0
        public async Task <IActionResult> GetTimeLineItem(int id)
        {
            TimeLineItem result = await _dataService.GetTimeLineItem(id);

            string     userEmail  = User.GetEmail() ?? Constants.DefaultUserEmail;
            UserAccess userAccess = await _dataService.GetProgenyUserAccessForUser(result.ProgenyId, userEmail);

            if (userAccess != null || id == Constants.DefaultChildId)
            {
                return(Ok(result));
            }

            return(Unauthorized());
        }
示例#23
0
        /// <summary>
        /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }

            if (disposing)
            {
                TimeLineItem.DisposeRoadie();
            }

            base.Dispose(disposing);
        }
示例#24
0
        public void InsertStatus(Status status)
        {
            TimeLineItem item = new TimeLineItem(status, this.account.ScreenName);

            this.timeLine.Insert(0, item);

            if (this.mode == TimeLineMode.Mention)
            {
                // 通知
                string userName = string.Format("{0} / {1}", item.ScreenName2, item.Name);
                string text     = item.Text;
                this.main.TaskIcon.ShowBaloon(text, userName, NotifyMode.Reply);
            }
        }
示例#25
0
        private void textBlock_Reply_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TimeLineItem target = ((sender as Image).TemplatedParent as ContentPresenter).Content as TimeLineItem;

            if (target == null)
            {
                return;
            }

            this.main.ReplyTo = target.Tweet;
            this.main.ReplyToItem.Set(target.ScreenName, target.Tweet.Text);
            this.main.textBox_Tweet.Text += "@" + target.ScreenName + " ";
            this.main.textBox_Tweet.Focus();
        }
示例#26
0
        public async Task <TimeLineItem> SetTimeLineItem(int id)
        {
            TimeLineItem timeLineItem = await _context.TimeLineDb.AsNoTracking().SingleOrDefaultAsync(t => t.TimeLineId == id);

            await _cache.SetStringAsync(Constants.AppName + "timelineitem" + id, JsonConvert.SerializeObject(timeLineItem), _cacheOptionsSliding);

            await _cache.SetStringAsync(Constants.AppName + "timelineitembyid" + timeLineItem.ItemId + "type" + timeLineItem.ItemType, JsonConvert.SerializeObject(timeLineItem), _cacheOptionsSliding);

            List <TimeLineItem> timeLineList = await _context.TimeLineDb.AsNoTracking().Where(t => t.ProgenyId == timeLineItem.ProgenyId).ToListAsync();

            await _cache.SetStringAsync(Constants.AppName + "timelinelist" + timeLineItem.ProgenyId, JsonConvert.SerializeObject(timeLineList), _cacheOptionsSliding);

            return(timeLineItem);
        }
示例#27
0
        private void btnMoveUp_Click(object sender, EventArgs e)
        {
            int index = TimeLine.SelectedIndex;

            if (0 >= index)
            {
                return;
            }
            TimeLineItem tmp = (TimeLineItem)TimeLine.Items[index];

            TimeLine.Items[index]     = TimeLine.Items[index - 1];
            TimeLine.Items[index - 1] = tmp;
            TimeLine.SetSelected(index - 1, true);
            selectedTimeLineIndex = index - 1;
        }
示例#28
0
        private void image_Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TimeLineItem target = ((sender as Image).TemplatedParent as ContentPresenter).Content as TimeLineItem;

            if (target == null)
            {
                return;
            }

            long           id = (long)target.Tweet.User.Id;
            UserInfoWindow w  = new UserInfoWindow(this.account, id);

            w.Owner = this.main;
            w.Show();
        }
示例#29
0
        private void btnMoveDown_Click(object sender, EventArgs e)
        {
            int index = TimeLine.SelectedIndex;

            if (TimeLine.Items.Count - 1 == index || 0 > index)
            {
                return;
            }
            TimeLineItem tmp = (TimeLineItem)TimeLine.Items[index];

            TimeLine.Items[index]     = TimeLine.Items[index + 1];
            TimeLine.Items[index + 1] = tmp;
            TimeLine.SetSelected(index + 1, true);
            selectedTimeLineIndex = index + 1;
        }
        static internal TimeLineItemViewModel Deserialize(string stringValue)
        {
            //Deserialize actual timeline item
            TimeLineItem tmpTimeLineItem = TimeLineItem.Deserialize(stringValue);

            //Setup TimeLineItemViewModel
            TimeLineItemViewModel result = new TimeLineItemViewModel();

            result.TimeLineItem = tmpTimeLineItem;
            result.WaitFrames   = tmpTimeLineItem.GetFrameDuration();
            result.Description  = tmpTimeLineItem.Description;
            result.Index        = -1;
            result.PlaySound    = tmpTimeLineItem.PlaySound;

            return(result);
        }
示例#31
0
        private void btnAppend_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "SF4 Combo|*.cmb";
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string[] lines = System.IO.File.ReadAllLines(openFileDialog.FileName);

                foreach (String line in lines)
                {
                    TimeLine.Items.Add(TimeLineItem.Deserialize(line));
                }
            }
        }
    void NormalizeProbas( float newValue, TimeLineItem item, int sub )
    {
        item.behaviors[sub].probability = Mathf.Clamp01(newValue);
        float reminder = 1f - newValue;
        float sum = 0f;

        for (int l = 0; l < item.behaviors.Length; ++l)
        {
            if (sub == l)
                continue;
            sum += item.behaviors[l].probability;
        }
        for (int l = 0; l < item.behaviors.Length; ++l)
        {
            if (sub == l)
                continue;
            if (sum == 0f)
                item.behaviors[l].probability = reminder / (float)item.behaviors.Length;
            else
                item.behaviors[l].probability = reminder * item.behaviors[l].probability / sum;
            item.behaviors[l].probability = Mathf.Clamp01(item.behaviors[l].probability);
        }

        sum = 0f;
        for (int l = 0; l < item.behaviors.Length; ++l)
        {
            sum += item.behaviors[l].probability;
        }
        for (int l = 0; l < item.behaviors.Length; ++l)
        {
            if (sum == 0f)
                item.behaviors[l].probability = 1f / (float)item.behaviors.Length;
            else
                item.behaviors[l].probability /= sum;
            item.behaviors[l].probability = Mathf.Clamp01(item.behaviors[l].probability);
        }
    }
    void OnGUI()
    {
        if (randomIcon == null)
            Reinit();
        if( loopIcon == null )
            Reinit();
        if( breakIcon == null )
            Reinit();
        if (titleStyle == null)
            Reinit();
        if (roleStyle== null)
            Reinit();
        if (btStyle == null)
            Reinit();
        if (oddStyle == null)
            Reinit();
        if (evenStyle == null)
            Reinit();
        if (syncStyle == null)
            Reinit();

        if (popupStyle == null)
            Reinit();

        if (dropStyle == null)
            Reinit ();
        if (loopStyle == null)
            Reinit ();
        //Setup();
        if (Selection.activeGameObject == null)
            return;
        LifeSceneParameters target = Selection.activeGameObject.GetComponent<LifeSceneParameters>();
        if (target == null)
            return;
        if (target != lastEdit)
            Setup();
        if (skipNext == true && Event.current.type != EventType.layout )
        {
            return;
        }
        if (skipNext == true && Event.current.type == EventType.layout)
        {
            skipNext = false;
        }
        string name = target.name;
        GUI.skin.font = EditorStyles.boldFont;
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(name,titleStyle);
        GUILayout.EndHorizontal();
        LifeSceneTimeLine timeLine = target.timeLine;
        if (timeLine == null)
            timeLine = new LifeSceneTimeLine();
        target.timeLine = timeLine;

        if( msgProblematic != string.Empty )
        {
            EditorGUILayout.HelpBox( msgProblematic, MessageType.Error );
            return;
        }

        timeLine.Validate( target.roleParameters );
        Color current = Color.cyan;

        scrollPosition = GUILayout.BeginScrollView(scrollPosition);

        float fullHeight = -3;
        foreach (LifeSceneRoleTimeLine tl in target.timeLine.timeLineForRoles)
        {
            float h = GetTimeLineHeight(tl);
            if (h > 100)
                h += 20;
            fullHeight += h + 3;
        }

        foreach (LifeSceneRoleTimeLine tl in target.timeLine.timeLineForRoles)
        {
            GUI.backgroundColor = current;
            try
            {
                DrawTimeLine(target.timeLine, tl, fullHeight);
            }
            catch (System.ArgumentException)
            {
                break;
            }

            if (current == Color.cyan)
                current = Color.green;
            else
                current = Color.cyan;
            if( skipNext )
                break;
        }
        GUILayout.EndScrollView();

        if (Event.current.type == EventType.mouseUp )
        {
            Rect rc = GUILayoutUtility.GetLastRect ();
            if( rc.Contains( Event.current.mousePosition ) )
                if (hoverItem == null)
                {
                    if (configItem != null)
                        NormalizeProbas(configItem);

                    configItem = null;
                }
            selectedDropZone = new Rect();
            selectedTimeLine = null;
            hoverItem = null;
            RemoveEmpty(target.timeLine);
            RemoveEmptyColumns( target.timeLine );
            MergeSyncros(target.timeLine);
            CheckStartEnd( target.timeLine );
            Repaint();
        }
        if (hoverItem != null && Event.current.type == EventType.layout)
        {
            if (configItem != hoverItem)
                NormalizeProbas(configItem);
            configItem = hoverItem;
            configSubItem = subItem;
        }

        GUILayout.FlexibleSpace ();
        //GUILayout.Label(GUI.tooltip, titleStyle);
        if( Event.current.type == EventType.mouseDown )
            Repaint();

        if (Event.current.type == EventType.mouseDrag)
            Repaint();

        try
        {
            DrawSettings ();
        }
        catch( System.ArgumentException )
        {
        }
        catch( System.IndexOutOfRangeException )
        {
            configItem = null;
            configSubItem = -1;
        }
        if (PrefabUtility.GetPrefabParent (target.gameObject) != null)
            PrefabUtility.RecordPrefabInstancePropertyModifications (target);
    }
 void NormalizeProbas(TimeLineItem item)
 {
     if (item == null)
         return;
     if (item.kind != TimeLineItem.Kind.Multiple)
         return;
     if (item.isRandom)
         return;
     float sum = 0f;
     for (int l = 0; l < item.behaviors.Length; ++l)
     {
         sum += item.behaviors[l].probability;
     }
     for (int l = 0; l < item.behaviors.Length; ++l)
     {
         if (sum == 0f)
             item.behaviors[l].probability = 1f / (float)item.behaviors.Length;
         else
             item.behaviors[l].probability /= sum;
         item.behaviors[l].probability = Mathf.Clamp01(item.behaviors[l].probability);
     }
 }
    void ValidateTimeLine( RoleParameters rp, LifeSceneTimeLine timeLine)
    {
        // at least 1 sync point
        if( timeLine.mainTimeline == null )
        {
            timeLine.mainTimeline = new LifeSceneRoleTimeLine();
            timeLine.mainTimeline.sequence = new TimeLineItem[0];
        }
        if( timeLine.mainTimeline.sequence.Length == 0 )
        {
            ArrayUtility.Add(ref timeLine.mainTimeline.sequence, new TimeLineItem( CreateUID() ));
        }
        // remove timeline not associated with a role
        timeLine.timeLineForRoles = timeLine.timeLineForRoles.Where(tl => rp.Roles.Contains( tl.roleName) ).ToArray();
        // check each role has a timeLine
        foreach (string role in rp.Roles)
        {
            LifeSceneRoleTimeLine tl = timeLine.FindTimeLineForRole(role);
            // add one if none exists
            if (tl == null)
            {
                tl = new LifeSceneRoleTimeLine();
                tl.roleName = role;
                ArrayUtility.Add(ref timeLine.timeLineForRoles, tl);
            }
            if( tl.sequence == null )
                tl.sequence = new TimeLineItem[0];

            if( tl.sequence.Length == 0 )
            {
                foreach ( TimeLineItem main in timeLine.mainTimeline.sequence)
                {
                    TimeLineItem item;
                    if (main.kind == TimeLineItem.Kind.Syncro)
                        item = new TimeLineItem(main.syncID);
                    else
                        item = new TimeLineItem();
                    ArrayUtility.Add(ref tl.sequence, item);
                }
            }
        }
    }
    public void Setup()
    {
        msgProblematic = string.Empty;
        skipNext = false;
        selectedTimeLine = null;
        hoverItem = null;
        configItem = null;
        if (Selection.activeGameObject == null)
            return;
        LifeSceneParameters target = Selection.activeGameObject.GetComponent<LifeSceneParameters>();
        lastEdit = target;
        if (target == null)
            return;

        // make sure we have one and only one timeLine per role
        RoleParameters rp = target.roleParameters;
        LifeSceneTimeLine timeLine = target.timeLine;
        if (timeLine == null)
            timeLine = new LifeSceneTimeLine();
        target.timeLine = timeLine;
        ValidateTimeLine(rp, timeLine);

        btsForRoles.Clear();
        defaultBtForRoles.Clear ();

        if( target.roleParameters.Roles.Length == 0 )
        {
            msgProblematic = "No role defined\nCheck the Roles tab";
            return;
        }
        if( target.behaviorParameters.Behaviors.Length == 0 )
        {
            msgProblematic = "No behaviors defined\nCheck the Behaviors tab";
            return;
        }

        foreach (string role in target.roleParameters.Roles)
        {
            if( role == "" || role == null || role == string.Empty)
            {
                msgProblematic = "Empty role found\nCheck the Roles tab";
                return;
            }
            else if( btsForRoles.ContainsKey(role) == false )
            {
                btsForRoles.Add( role, new List<string>() );
                defaultBtForRoles.Add( role, 0 );
            }
            else
            {
                msgProblematic = "Duplicated roles found :"+role+"\nCheck the Roles tab";
                return;
            }
        }

        for( int i = 0; i< target.behaviorParameters.Behaviors.Length;++i )
        {

            string bt = target.behaviorParameters.Behaviors[i];
            string role = target.behaviorParameters.Roles[i];
            if( bt == "" || bt == null || bt == string.Empty)
            {
                msgProblematic = "Empty behavior found\nCheck the Behaviors tab";
                return;
            }
            if( role == "" || role == null || role == string.Empty)
            {
                msgProblematic = "Empty role associated with behavior "+bt+"\nCheck the Behaviors tab";
                return;
            }
            if( btsForRoles.ContainsKey(role) == true )
                btsForRoles[role].Add( bt );
            else
            {
                msgProblematic = "Inconsistent role found between the Roles tab and Behaviors tab\n"+role+" not found";
                return;
            }

        }
        foreach (string role in target.roleParameters.Roles)
        {
            btsForRoles[role] = btsForRoles[role].Distinct().ToList();
            if( btsForRoles[role].Count == 0 )
            {
                msgProblematic = "No Behaviors found for "+role;
                return;
            }
        }

        TypeRoleManager typeRole = TypeRoleManager.Instance;
        List<string> typeRoles = typeRole.typeRoles.ToList();

        timeLine.timeLineForRoles = timeLine.timeLineForRoles.OrderBy( tl =>
                                          {
            var idRole = target.roleParameters.Roles.ToList().FindIndex ( tr => tr == tl.roleName );
            var namedType = target.roleParameters.RolesType[idRole];
            var id = typeRoles.FindIndex( tr => tr == namedType );
            return id == -1 ? typeRoles.Count : id;
        } ).ToArray();
    }
    void DrawTimeLine( LifeSceneTimeLine timeLine, LifeSceneRoleTimeLine tl, float totalHeight )
    {
        float maxHeight = GetTimeLineHeight(tl);

        Color oldColor = GUI.backgroundColor;
        GUILayout.BeginHorizontal(oddStyle);
        float bottom = 100;

        GUILayout.BeginVertical(GUILayout.Width(200), GUILayout.ExpandWidth(false));
            Rect rcBox = GUILayoutUtility.GetRect( new GUIContent( tl.roleName ), roleStyle);
            GUI.Box( rcBox, tl.roleName, roleStyle);

            rcBox.x += rcBox.width - 18;
            rcBox.y += 1;
            rcBox.width = 18;
            rcBox.height = 18;
            GUI.backgroundColor = Color.red;
            if (GUI.Button( rcBox, "\u2718", EditorStyles.miniButton))
            {
                ArrayUtility.Clear(ref tl.sequence);
                foreach (TimeLineItem main in timeLine.mainTimeline.sequence)
                {
                    TimeLineItem item;
                    if (main.kind == TimeLineItem.Kind.Syncro)
                        item = new TimeLineItem(main.syncID);
                    else
                        item = new TimeLineItem();
                    ArrayUtility.Add(ref tl.sequence, item);
                }
                hoverItem = null;
                if (configItem != null)
                    NormalizeProbas(configItem);
                configItem = null;
                subItem = -1;
                configSubItem = -1;
                RemoveEmpty(timeLine);
                RemoveEmptyColumns(timeLine);
                MergeSyncros(timeLine);
                CheckStartEnd(timeLine);
                return;
            }
            GUI.backgroundColor = oldColor;

            List< string > bts = btsForRoles[tl.roleName];
            Rect btChoice = GUILayoutUtility.GetRect(new GUIContent(""), btStyle, GUILayout.Width(200), GUILayout.ExpandWidth(false));
            btChoice.width -= 20;
            if( Event.current.type == EventType.mouseDown && btChoice.Contains( Event.current.mousePosition ) && bts.Count > 0 )
            {
                selectedTimeLine = tl;
                hoverItem = new TimeLineItem(TimeLineItem.Kind.Single);
                hoverItem.behavior = new TimeLineBT(bts[defaultBtForRoles[tl.roleName]]);
                subItem = -1;
                if (configItem != null)
                    NormalizeProbas(configItem);
                configItem = null;
                configSubItem = -1;
            }
            if ( selectedTimeLine == tl && hoverItem != null && hoverItem.kind == TimeLineItem.Kind.Single && hoverItem.behavior.uriBT == bts [defaultBtForRoles [tl.roleName]])
            {
                GUI.backgroundColor = Color.magenta;
                if( Event.current.type == EventType.mouseUp && btChoice.Contains( Event.current.mousePosition ) )
                {
                    selectedTimeLine = null;
                    hoverItem = null;
                    subItem = -1;
                    if (configItem != null)
                        NormalizeProbas(configItem);
                    configItem = null;
                    configSubItem = -1;
                    TimeLineItem item = new TimeLineItem(TimeLineItem.Kind.Single);
                    item.behavior = new TimeLineBT(bts[defaultBtForRoles[tl.roleName]]);
                    AddItem(timeLine, tl, item);
                    RemoveEmpty(timeLine);
                    RemoveEmptyColumns(timeLine);
                    MergeSyncros(timeLine);
                    Event.current.Use();
                    return;
                }
            }
            if (bts.Count > 0)
            {
                GUI.Label(btChoice, bts[defaultBtForRoles[tl.roleName]], btStyle);
                btChoice.x += btChoice.width - 2;
                btChoice.width = 18;
                defaultBtForRoles[tl.roleName] = EditorGUI.Popup(btChoice, defaultBtForRoles[tl.roleName], bts.ToArray(), popupStyle);
            }
            else
            {
                GUI.Label(btChoice, "No BTs", btStyle);
            }

        //			GUI.backgroundColor = Color.red;
            if (maxHeight > 100)
            {
                bottom = rcBox.y+maxHeight+20;
                GUILayout.Space ( maxHeight-100+20);
            }
            else
                bottom = rcBox.y+maxHeight;
                //				GUILayout.Box( "", oddStyle, GUILayout.Height ( maxHeight-100+20)) ;
            GUI.backgroundColor = oldColor;
        GUILayout.EndVertical();

        if (hoverItem != null && hoverItem.kind == TimeLineItem.Kind.Syncro)
        {
            hoverItem = tl.sequence.Where(it => it.kind == TimeLineItem.Kind.Syncro && it.syncID == hoverItem.syncID).ToArray()[0];
            configItem = hoverItem;
        }

        for (int i = 0; i < tl.sequence.Length; ++i )
        {
            Rect dropZone = new Rect ();
            int iOrig = i;
            TimeLineItem item = tl.sequence[i];
            Rect rc = new Rect();
            int idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
            if ( item.kind == TimeLineItem.Kind.Syncro )
            {
                GUI.backgroundColor = Color.yellow;
                GUILayout.BeginVertical(GUILayout.Width(20));
                rc = GUILayoutUtility.GetRect(new GUIContent(""), syncStyle);
                rc.y = 6;
                //rc.height = 102 * timeLine.timeLineForRoles.Length + 3 * (timeLine.timeLineForRoles.Length-1);
                rc.height = totalHeight;
                if( configItem == item )
                    GUI.backgroundColor = Colors.PastelOrange;
                if (hoverItem == item)
                    GUI.backgroundColor = Color.red;
                GUI.Label(rc, new GUIContent("", item.syncID ), syncStyle);

                GUILayout.EndVertical();
                if(! (i == 0 || i == tl.sequence.Length - 1) )
                {
                    Rect b = rc;
                    b.x += 1;
                    b.y += 1;
                    b.width -= 2;
                    b.height = 20;
                    GUI.backgroundColor = Color.red;
                    if (GUI.Button(b, "\u2718", EditorStyles.miniButton))
                    {
                        hoverItem = null;
                        if (configItem != null)
                            NormalizeProbas(configItem);
                        configItem = null;
                        subItem = -1;
                        configSubItem = -1;
                        timeLine.mainTimeline.sequence[i] = new TimeLineItem();
                        foreach (LifeSceneRoleTimeLine t in timeLine.timeLineForRoles)
                            t.sequence[i] = new TimeLineItem();
                        RemoveEmpty(timeLine);
                        RemoveEmptyColumns(timeLine);
                        MergeSyncros(timeLine);
                    }
                    rc.y += 20;
                    rc.height -= 20;
                }
                if (Event.current.type == EventType.mouseDown)
                    if (rc.Contains(Event.current.mousePosition))
                        hoverItem = item;
                GUI.backgroundColor = oldColor;
            }
            else if (item.kind == TimeLineItem.Kind.Single)
            {

                GUILayout.BeginVertical(GUILayout.Width(200));
                float width = 200f;
                for (int k = i + 1; k < tl.sequence.Length; ++k)
                {
                    if (tl.sequence[k].kind == TimeLineItem.Kind.Empty)
                    {
                        i = k;
                        width += 4 + 200;
                    }
                    else
                        break;
                }

                rc = GUILayoutUtility.GetRect(new GUIContent(""), btStyle, GUILayout.Width(width));

                if( item.isLoopable )
                {
                    if( i == 0 || !tl.sequence[i-1].isLoopable )
                    {
                        float widthLoop = width;
                        for (int k = i + 1; k < tl.sequence.Length; ++k)
                        {
                            if (tl.sequence[k].kind == TimeLineItem.Kind.Syncro)
                                break;
                            widthLoop += 4 + 200;
                        }
                        if( widthLoop != width )
                        {
                            Rect loop = rc;
                            loop.width = widthLoop;
                            loop.height = 16;
                            loop.y = bottom - 18;
                            GUI.backgroundColor = GUI.backgroundColor.Darken();
                            GUI.Label ( loop, loopIcon, loopStyle );
                            GUI.backgroundColor = oldColor;
                        }
                    }
                }

                if( configItem == item )
                    GUI.backgroundColor = Colors.PastelOrange;
                if (hoverItem == item )
                    GUI.backgroundColor = Color.red;
                GUI.Label(rc,item.behavior.uriBT, btStyle);
                GUI.backgroundColor = oldColor;

                if( hoverItem != null && hoverItem != item && (hoverItem.kind == TimeLineItem.Kind.Single || (hoverItem.kind == TimeLineItem.Kind.Multiple && subItem != -1 ) ) )
                {
                    if( idSelected != -1 || selectedTimeLine == tl )
                    {
                        dropZone = rc;
                        dropZone.y = bottom-15;
                        dropZone.x += 40;
                        dropZone.width -= 80;
                        dropZone.height = 20;
                        if( selectedDropZone == dropZone )
                            GUI.backgroundColor = Color.red;
                        GUI.backgroundColor = GUI.backgroundColor.Darken(.5f);
                        GUI.Label( dropZone, "Drop to add", dropStyle );
                    }
                }
                GUI.backgroundColor = oldColor;

                GUILayout.EndVertical();

                Rect b = rc;
                b.height = 20;
                b.width = 18;
                b.x += rc.width - 20;
                b.y += 1;
                GUI.backgroundColor = Color.red;
                if (GUI.Button(b, "\u2718", EditorStyles.miniButton))
                {
                    hoverItem = null;
                    if (configItem != null)
                        NormalizeProbas(configItem);
                    configItem = null;
                    subItem = -1;
                    configSubItem = -1;
                    tl.sequence[iOrig] = new TimeLineItem();
                    RemoveEmpty( timeLine );
                    RemoveEmptyColumns( timeLine );
                    MergeSyncros(timeLine);
                    break;
                }

                GUI.backgroundColor = oldColor;
                b.y += 22;
                b.x += 1;
                b.width = 18;
                int currentIdx = ChoosenIdFromBtRole(tl.roleName, item.behavior.uriBT);
                int newIdx = EditorGUI.Popup(b, currentIdx, btsForRoles[tl.roleName].ToArray());
                if (newIdx == -1 || newIdx != currentIdx)
                {
                    if (newIdx == -1)
                        newIdx = 0;
                    item.behavior.uriBT = btsForRoles[tl.roleName][newIdx];
                }

                b= rc;
                b.width=16;
                b.x += 2;
                b.y += 2;
                if( item.behavior.loopable )
                {
                    GUI.Label(b , loopIcon );
                    b.y += 18;
                }
                if( item.behavior.interuptible )
                {
                    GUI.Label(b , breakIcon );
                }

                rc.width -= 21;

                if (Event.current.type == EventType.mouseDown)
                    if (rc.Contains(Event.current.mousePosition))
                        hoverItem = item;
                if (hoverItem != null && hoverItem.kind == TimeLineItem.Kind.Syncro)
                    rc.height = maxHeight;
                rc.width += 21;
                //rc.height = 100;
            }
            else if (item.kind == TimeLineItem.Kind.Empty)
            {
                GUILayout.BeginVertical(GUILayout.Width(200));

                float width = 200f;
                for (int k = i + 1; k < tl.sequence.Length; ++k)
                {
                    if (tl.sequence[k].kind == TimeLineItem.Kind.Empty)
                    {
                        i = k;
                        width += 4 + 200;
                    }
                    else
                        break;
                }

                if (Event.current.type == EventType.mouseDrag && hoverItem != null && hoverItem.kind == TimeLineItem.Kind.Syncro)
                {
                    rc = GUILayoutUtility.GetRect(new GUIContent(""), btStyle, GUILayout.Width(width));
                    GUI.Label(rc, "", btStyle);
                    rc.height = maxHeight;
                }
                else
                {
                    //rc = GUILayoutUtility.GetRect(new GUIContent(""), btStyle);
                //    GUILayout.Label("", btStyle, GUILayout.Width(width));
                    rc = GUILayoutUtility.GetRect(new GUIContent(""), btStyle, GUILayout.Width(width));
                    GUI.Label(rc, "", btStyle);
                }

                GUILayout.EndVertical();
            }
            else if (item.kind == TimeLineItem.Kind.Multiple)
            {

                GUI.backgroundColor = Color.grey;
                if( configItem == item && subItem == -1 )
                    GUI.backgroundColor = Colors.PastelOrange;
                if (hoverItem == item && subItem == -1)
                    GUI.backgroundColor = Color.red;

                float width = 180;
                for (int k = i + 1; k < tl.sequence.Length; ++k)
                {
                    if (tl.sequence[k].kind == TimeLineItem.Kind.Empty)
                    {
                        i = k;
                        width += 4 + 200;
                    }
                    else
                        break;
                }

                GUI.backgroundColor = oldColor;
                GUILayout.BeginVertical(oddStyle, GUILayout.Width(width+20f));
                GUILayout.Space (-2);
                rc = GUILayoutUtility.GetLastRect();

                if( item.isLoopable )
                {
                    if( i == 0 || !tl.sequence[i-1].isLoopable )
                    {
                        float widthLoop = width;
                        for (int k = i + 1; k < tl.sequence.Length; ++k)
                        {
                            if (tl.sequence[k].kind == TimeLineItem.Kind.Syncro)
                                break;
                            widthLoop += 4 + 200;
                        }
                        if( widthLoop != width )
                        {
                            Rect loop = rc;
                            loop.x -= 4;
                            loop.width = widthLoop+16;
                            loop.height = 16;
                            loop.y = bottom - 18;
                            GUI.backgroundColor = GUI.backgroundColor.Darken();
                            GUI.Label ( loop, loopIcon, loopStyle );
                            GUI.backgroundColor = oldColor;
                        }
                    }
                }

                for( int k = 0; k < item.behaviors.Length; ++k )
                {
                    Rect t = GUILayoutUtility.GetRect(new GUIContent(""), btStyle, GUILayout.Width(width));

                    t.x -= 6;
                    if( k == 0 )
                        rc = t;

                    GUI.backgroundColor = oldColor;
                    if( configItem == item && ( subItem == k || subItem == -1 ) )
                        GUI.backgroundColor = Colors.PastelOrange;
                    if (hoverItem == item && ( subItem == k || subItem == -1 ) )
                        GUI.backgroundColor = Color.red;
                    GUI.Label(t,item.behaviors[k].uriBT, btStyle);
                    Rect b = t;
                    b.height = 20;
                    b.width = 18;
                    b.x += t.width - 20;
                    b.y += 1;
                    GUI.backgroundColor = Color.red;
                    if (GUI.Button(b, "\u2718", EditorStyles.miniButton))
                    {
                        ArrayUtility.RemoveAt( ref item.behaviors, k );
                        if( item.behaviors.Length == 1 )
                            item.SwitchToSingle();
                        break;
                    }
                    GUI.backgroundColor = oldColor;
                    b.y += 22;
                    b.x += 1;
                    b.width = 18;
                    int currentIdx = ChoosenIdFromBtRole(tl.roleName, item.behaviors[k].uriBT);
                    int newIdx = EditorGUI.Popup(b, currentIdx, btsForRoles[tl.roleName].ToArray());
                    if (newIdx == -1 || newIdx != currentIdx)
                    {
                        if (newIdx == -1)
                            newIdx = 0;
                        item.behaviors[k].uriBT = btsForRoles[tl.roleName][newIdx];
                    }

                    b= t;
                    b.width=16;
                    b.x += 2;
                    b.y += 2;
                    if( item.behaviors[k].loopable )
                    {
                        GUI.Label(b , loopIcon );
                        b.y += 16;
                    }
                    if( item.behaviors[k].interuptible )
                    {
                        GUI.Label(b , breakIcon );
                        b.y += 16;
                    }

                    if (!item.isRandom)
                    {
                        b.width = t.width - 4 - 16;
                        b.y = t.y + 26;
                        b.height = 10;
                        float newVal = GUI.HorizontalSlider(b, item.behaviors[k].probability, 0f, 1f);
                        if (newVal != item.behaviors[k].probability)
                        {
                            if (configItem != null && configItem != item)
                                NormalizeProbas(configItem);
                            hoverItem = item;
                            subItem = k;
                            NormalizeProbas(newVal, item, k);
                        }

                    }
                    dropZone = t;

                    t.width -= 21;
                    if (Event.current.type == EventType.mouseDown)
                        if (t.Contains(Event.current.mousePosition))
                        {
                            hoverItem = item;
                            subItem = k;
                        }

                    GUILayout.Space(-3);
                }

                if( item.kind == TimeLineItem.Kind.Multiple ) // in case reverted to single !
                {
                    Rect old = rc;
                    rc.x += rc.width;
                    rc.height = 40*item.behaviors.Length;
                    rc.width = 20;

                    Rect bq = rc;
                    bq.height = 20;
                    bq.width = 18;
                    bq.y += 1;
                    GUI.backgroundColor = Color.red;
                    if (GUI.Button(bq, "\u2718", EditorStyles.miniButton))
                    {
                        hoverItem = null;
                        subItem = -1;
                        if (configItem != null )
                            NormalizeProbas(configItem);
                        configItem = null;
                        configSubItem = -1;
                        tl.sequence[iOrig] = new TimeLineItem();
                        RemoveEmpty( timeLine );
                        RemoveEmptyColumns( timeLine );
                        MergeSyncros(timeLine);
                        break;
                    }

                    bq.width=16;
                    //bq.x += 2;
                    bq.y += 20;
                    if( item.loopable )
                    {
                        GUI.Label(bq , loopIcon );
                        bq.y += 18;
                    }
                    if( item.interuptible )
                    {
                        GUI.Label(bq , breakIcon );
                        bq.y += 18;
                    }
                    if (item.isRandom)
                    {
                        GUI.Label(bq, randomIcon);
                        bq.y += 18;
                    }

                    rc.y+=20;
                    rc.height-=20;
                    if (Event.current.type == EventType.mouseDown)
                        if (rc.Contains(Event.current.mousePosition))
                        {
                            hoverItem = item;
                            subItem = -1;
                            if (configItem != null)
                                NormalizeProbas(configItem);
                            configItem = null;
                            configSubItem = -1;
                        }

                    rc = old;
                    rc.height = 40*item.behaviors.Length;
                    rc.width += 20;

                    GUI.backgroundColor = oldColor;
                    if( hoverItem != null && hoverItem != item && (hoverItem.kind == TimeLineItem.Kind.Single || (hoverItem.kind == TimeLineItem.Kind.Multiple && subItem != -1 ) ) )
                    {
                        if( idSelected != -1 || selectedTimeLine == tl )
                        {
                            dropZone.y = bottom-15;
                            dropZone.x += 40;
                            dropZone.width -= 60;
                            dropZone.height = 20;
                            if( selectedDropZone == dropZone )
                                GUI.backgroundColor = Color.red;
                            GUI.backgroundColor = GUI.backgroundColor.Darken(.5f);
                            GUI.Label( dropZone, "Drop to add", dropStyle );
                        }
                    }
                    GUI.backgroundColor = oldColor;
                    GUILayout.EndVertical();
                }
                else
                {
                    GUI.backgroundColor = oldColor;
                    GUILayout.EndVertical();
                }
            }

            if (Event.current.type == EventType.mouseDrag && hoverItem != null && selectedDropZone == dropZone && dropZone.Contains( Event.current.mousePosition) )
            {
                if( item.kind == TimeLineItem.Kind.Single )
                {
                    item.SwitchToMultiple();
                }
                if (hoverItem.kind == TimeLineItem.Kind.Multiple && subItem != -1)
                {
                    ArrayUtility.Add(ref item.behaviors, hoverItem.behaviors[subItem] );
                    ArrayUtility.RemoveAt(ref hoverItem.behaviors, subItem);
                    if (hoverItem.behaviors.Length == 1)
                        hoverItem.SwitchToSingle();
                }
                else
                {
                    ArrayUtility.Add(ref item.behaviors, hoverItem.behavior);
                    idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                    if( idSelected != -1 )
                        tl.sequence[idSelected] = new TimeLineItem();
                }
                RemoveEmpty(timeLine);
                RemoveEmptyColumns(timeLine);
                MergeSyncros(timeLine);
                hoverItem = null;
                subItem=-1;
                hoverItem = item;
                if( hoverItem.kind == TimeLineItem.Kind.Multiple )
                    subItem = hoverItem.behaviors.Length-1;
                if (configItem != null)
                    NormalizeProbas(configItem);
                configItem = null;
                configSubItem = -1;

            }
            if (Event.current.type == EventType.mouseDrag && hoverItem != null )
            {
                if( dropZone.Contains( Event.current.mousePosition ) && hoverItem.kind == TimeLineItem.Kind.Single && (hoverItem != item) )
                {
                    idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                    int id = ArrayUtility.IndexOf(tl.sequence, item);
                    if( idSelected != -1 || selectedTimeLine == tl )
                        if( idSelected != id )
                            selectedDropZone = dropZone;
                }
                else if (dropZone.Contains(Event.current.mousePosition) && hoverItem.kind == TimeLineItem.Kind.Multiple && subItem != -1 && (hoverItem != item))
                {
                    idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                    int id = ArrayUtility.IndexOf(tl.sequence, item);
                    if (idSelected != -1 || selectedTimeLine == tl)
                        if (idSelected != id)
                            selectedDropZone = dropZone;
                }
                if (!selectedDropZone.Contains(Event.current.mousePosition))
                    selectedDropZone = new Rect();
            }
            if (Event.current.type == EventType.mouseDrag && (hoverItem != item))
            {
                idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                if (idSelected != -1 || selectedTimeLine == tl )
                {
                    Rect left = rc;
                    left.width /= 2;
                    Rect right = rc;
                    right.width /= 2;
                    right.x += right.width;
                    if (right.Contains(Event.current.mousePosition))
                    {
                        if (idSelected == -1 )
                        {
                            AddItem(timeLine, tl, hoverItem);
                            skipNext = true;
                            RemoveEmpty(timeLine);
                            RemoveEmptyColumns(timeLine);
                            MergeSyncros(timeLine);
                            idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                        }
                        if (subItem != -1&& hoverItem.kind == TimeLineItem.Kind.Multiple)
                        {
                            TimeLineItem single = new TimeLineItem( TimeLineItem.Kind.Single );
                            single.behavior = new TimeLineBT(hoverItem.behaviors[subItem].uriBT);
                            single.behavior.loopable = hoverItem.behaviors[subItem].loopable;
                            single.behavior.interuptible = hoverItem.behaviors[subItem].interuptible;
                            ArrayUtility.RemoveAt(ref hoverItem.behaviors, subItem);
                            if (hoverItem.behaviors.Length == 1)
                                hoverItem.SwitchToSingle();

                            hoverItem = single;
                            subItem = -1;
                            AddItem(timeLine, tl, hoverItem);
                            RemoveEmpty(timeLine);
                            RemoveEmptyColumns(timeLine);
                            MergeSyncros(timeLine);
                            idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                        }
                        InsertRight(timeLine, tl, idSelected, i);

                        break;
                    }
                    if (left.Contains(Event.current.mousePosition))
                    {
                        if (idSelected == -1 )
                        {
                            AddItem(timeLine, tl, hoverItem);
                            skipNext = true;
                            RemoveEmpty(timeLine);
                            RemoveEmptyColumns(timeLine);
                            MergeSyncros(timeLine);
                            idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                        }
                        if (subItem != -1 && hoverItem.kind == TimeLineItem.Kind.Multiple)
                        {
                            TimeLineItem single = new TimeLineItem( TimeLineItem.Kind.Single );
                            single.behavior = new TimeLineBT(hoverItem.behaviors[subItem].uriBT);
                            single.behavior.loopable = hoverItem.behaviors[subItem].loopable;
                            single.behavior.interuptible = hoverItem.behaviors[subItem].interuptible;

                            ArrayUtility.RemoveAt(ref hoverItem.behaviors, subItem);
                            if (hoverItem.behaviors.Length == 1)
                                hoverItem.SwitchToSingle();

                            hoverItem = single;
                            subItem = -1;
                            AddItem(timeLine, tl, hoverItem);
                            RemoveEmpty(timeLine);
                            RemoveEmptyColumns(timeLine);
                            MergeSyncros(timeLine);
                            idSelected = ArrayUtility.IndexOf(tl.sequence, hoverItem);
                        }
                        InsertLeft(timeLine, tl, idSelected, i);
                        break;
                    }
                }
            }

        }
        GUILayout.EndHorizontal();
    }
 void AddItem(LifeSceneTimeLine timeLine, LifeSceneRoleTimeLine which, TimeLineItem item)
 {
     if( item.kind == TimeLineItem.Kind.Syncro )
         ArrayUtility.Add(ref timeLine.mainTimeline.sequence, new TimeLineItem( item.syncID ));
     else
         ArrayUtility.Add(ref timeLine.mainTimeline.sequence, new TimeLineItem());
     foreach (LifeSceneRoleTimeLine tl in timeLine.timeLineForRoles)
     {
         if( tl != which )
         {
             if (item.kind == TimeLineItem.Kind.Syncro)
                 ArrayUtility.Add(ref tl.sequence, new TimeLineItem( item.syncID ));
             else
                 ArrayUtility.Add(ref tl.sequence, new TimeLineItem());
         }
         else
             ArrayUtility.Add(ref tl.sequence, item );
     }
 }
示例#39
0
 private void RecordedInputUpdate(TimeLineItem timeLineItem)
 {
     if(TimeLine.InvokeRequired){
         this.Invoke(new MethodInvoker(delegate { TimeLine.Items.Add(timeLineItem);}));
     }
 }