Ejemplo n.º 1
0
    void AddEmptyInitialItem()
    {
        TimelineItem newPairButton = Instantiate(emptyIinitialItem);

        newPairButton.transform.SetParent(container);
        newPairButton.transform.localScale = Vector3.one;
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Process the timeline collection notification.
        /// </summary>
        /// <param name="notification">Notification payload.</param>
        /// <param name="service">Authorized Mirror service.</param>
        private void HandleTimelineNotification(Notification notification, MirrorService service)
        {
            foreach (UserAction action in notification.UserActions)
            {
                if (action.Type == "SHARE")
                {
                    TimelineItem item = service.Timeline.Get(notification.ItemId).Fetch();

                    item.Text         = "Thanks for sharing: " + item.Text;
                    item.Notification = new NotificationConfig()
                    {
                        Level = "DEFAULT"
                    };

                    service.Timeline.Update(item, item.Id).Fetch();
                    // Only handle the first successful action.
                    break;
                }
                else
                {
                    Console.WriteLine(
                        "I don't know what to do with this notification: " + action.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        public void Handle(TimelineMessage message)
        {
            TimelineItem obj = new TimelineItem()
            {
                ClientId   = message.ClientId,
                EventType  = message.EventType,
                EventName  = message.EventName,
                UserId     = message.UserId,
                UserName   = message.UserName,
                UserType   = message.UserType,
                Title      = message.Title,
                Decription = message.Decription,
                ImageUrl   = message.ImageUrl,
                DetailUrl  = message.DetailUrl,
                LinkUrl    = message.LinkUrl,
                UserUrl    = message.UserUrl,
                SiteName   = message.SiteName,
                SiteUrl    = message.SiteUrl,
                ActionTime = message.ActionTime,
                Keywords   = message.Keywords
            };

            try
            {
                provider.SaveActivity(obj);
            }
            catch (Exception ex)
            {
                LogHelper.Logger.Error(ex, "Save Timeline Item Failure");
            }
        }
Ejemplo n.º 4
0
 private StructureViewDragDropHandler.HittestResult Hittest(Point position)
 {
     StructureViewDragDropHandler.HittestResult hittestResult = new StructureViewDragDropHandler.HittestResult();
     if (this.StructureView.TimelineItemManager != null)
     {
         double indentMultiplier = this.StructureView.IndentMultiplier;
         int    num = (int)Math.Floor((position.X - indentMultiplier) / this.StructureView.IndentMultiplier);
         IList <TimelineItem> list = (IList <TimelineItem>) this.StructureView.TimelineItemManager.ItemList;
         if (list != null)
         {
             for (int index = list.Count - 1; index >= 0; --index)
             {
                 TimelineItem timelineItem = list[index];
                 if (timelineItem != null && timelineItem.Depth <= num)
                 {
                     ElementTimelineItem elementTimelineItem = timelineItem as ElementTimelineItem;
                     bool flag = elementTimelineItem != null && elementTimelineItem.Element.IsContainer;
                     hittestResult.allowDropInside = flag || timelineItem.Depth <= num - 1;
                     hittestResult.candidateItem   = timelineItem;
                     break;
                 }
             }
         }
     }
     return(hittestResult);
 }
Ejemplo n.º 5
0
        private List <TimelineItem> CreateRandomTimelineItems(int count)
        {
            var random    = new Random(count);
            var items     = new List <TimelineItem>();
            var converter = new HexStringToColorConverter();

            TimeSpan residualDuration = Timeline.End - Timeline.Start;

            DateTime start = DateTime.Now;

            for (int i = 0; i < count; ++i)
            {
                // generate end
                var end = start.AddMinutes(random.Next(15, 30));

                // create item
                TimelineItem item = CreateTimelineItem(DesignTime.Factory.GetRandomImageName(random),
                                                       start, end, (Color)converter.Convert(DesignTime.Factory.CreateRandomColor(random), typeof(Color), null, null));

                // update start
                start = start.AddMinutes(random.Next(30, 60));

                // add to items
                items.Add(item);
            }

            // sort w.r.t. time
            items.Sort((a, b) => a.Start.CompareTo(b.Start));

            return(items);
        }
Ejemplo n.º 6
0
        public bool SaveActivity(TimelineItem obj)
        {
            Assert.IsNotNull(obj);

            TimelineItemInfo info = new TimelineItemInfo()
            {
                ClientId   = obj.ClientId,
                EventType  = obj.EventType,
                EventName  = obj.EventName,
                UserId     = obj.UserId,
                UserName   = obj.UserName,
                UserType   = obj.UserType,
                Title      = obj.Title,
                Decription = obj.Decription,
                ImageUrl   = obj.ImageUrl,
                DetailUrl  = obj.DetailUrl,
                LinkUrl    = obj.LinkUrl,
                UserUrl    = obj.UserUrl,
                SiteName   = obj.SiteName,
                SiteUrl    = obj.SiteUrl,
                ActionTime = obj.ActionTime,
                Keywords   = obj.Keywords
            };

            bool result = false;
            var  chanel = CreateChannel();

            chanel.Call(p =>
            {
                result = p.SaveActivity(info);
            });

            return(result);
        }
Ejemplo n.º 7
0
 public DragDropContext(IDataObject data, TimelineItem target, TimelineDropEffects allowedEffects)
 {
     this.Data           = data;
     this.Target         = target;
     this.AllowedEffects = allowedEffects;
     this.Descriptor     = new TimelineDragDescriptor(this);
 }
Ejemplo n.º 8
0
        public void BundlingCards(string pAuthorizationCode, string pEmail)
        {
            IAuthenticator authenticator = Login(pAuthorizationCode, pEmail, String.Empty);
            MirrorService  service       = BuildService(authenticator);
            TimelineItem   item          = new TimelineItem();

            item.BundleId      = "1";
            item.IsBundleCover = true;
            StaticCard.AddHtml(item, "<div><img src='http://cdn.screenrant.com/wp-content/uploads/Oliver-Stone-Breaking-Bad.jpg' /> </div>");

            TimelineItem item2 = new TimelineItem();

            item2.BundleId = "1";
            StaticCard.AddHtml(item2, "<div><img src='http://images.amcnetworks.com/amctv.com/wp-content/uploads/2014/04/BB-explore-S4-980x551-clean.jpg' /> </div>");

            TimelineItem item3 = new TimelineItem();

            item3.BundleId = "1";
            StaticCard.AddHtml(item3, "<div><img src='http://cdn.self-titledmag.com/wp-content/uploads/2011/10/breaking-bad-will-return-to-amc-in-august.jpg' /> </div>");


            service.Timeline.Insert(item).Fetch();
            service.Timeline.Insert(item2).Fetch();
            service.Timeline.Insert(item3).Fetch();
        }
Ejemplo n.º 9
0
        private void TimelineDeleteAnnotation_Click(object sender, EventArgs e)
        {
            Annotation annotation = this.get_annotation(this.TimelineGrid.SelectedElement, this.TimelineGrid.SelectedPoint);

            if (annotation == null || MessageBox.Show("Delete annotation '" + annotation.Title + "': are you sure?", "Labyrinth", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            TimelineItem timelineItem1 = (TimelineItem)null;

            foreach (TimelineItem timelineItem2 in this.TimelineGrid.SelectedPoint.Items)
            {
                if (timelineItem2.Annotation == annotation)
                {
                    timelineItem1 = timelineItem2;
                    break;
                }
            }
            if (timelineItem1 == null)
            {
                return;
            }
            this.TimelineGrid.SelectedPoint.Items.Remove(timelineItem1);
            this.UpdateData();
            this.OnTimelineModified(new TimelineEventArgs(this.fTimeline));
        }
        /// <summary>
        /// Inserts a timeline item.
        /// </summary>
        /// <param name="controller">Controller calling this method.</param>
        /// <returns>Status message.</returns>
        private static String InsertItem(MainController controller)
        {
            TimelineItem item = new TimelineItem()
            {
                Text         = controller.Request.Form.Get("message"),
                Notification = new NotificationConfig()
                {
                    Level = "DEFAULT"
                }
            };
            String mediaLink = controller.Request.Form.Get("imageUrl");

            if (!String.IsNullOrEmpty(mediaLink))
            {
                Stream stream = null;
                if (mediaLink.StartsWith("/"))
                {
                    stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
                }
                else
                {
                    HttpWebRequest  request  = WebRequest.Create(mediaLink) as HttpWebRequest;
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    stream = response.GetResponseStream();
                }

                controller.Service.Timeline.Insert(item, stream, "image/jpeg").Upload();
            }
            else
            {
                controller.Service.Timeline.Insert(item).Fetch();
            }

            return("A timeline item has been inserted.");
        }
        public void PostOcjenaWP(Ocjena o)
        {
            if (o.Id > 0)
            {
                Ocjena original = db.Ocjenas.Find(o.Id);
                original.DatumOcjene = DateTime.Now;
                original.OcjenaIznos = o.OcjenaIznos;
                original.Opis        = o.Opis;

                db.SaveChanges();
            }
            else
            {
                o.DatumOcjene = DateTime.Now;
                db.Ocjenas.Add(o);
                db.SaveChanges();

                TimelineItem t = new TimelineItem();
                t.EventDate        = DateTime.Now;
                t.EventDescription = " je ocjenio";
                t.IsOcjena         = true;
                t.KnjigaID         = o.KnjigaID;
                t.KorisnikID       = o.KorisnikID;

                db.TimelineItems.Add(t);
                db.SaveChanges();
            }
        }
        public OcjenaVM PostOcjena(OcjenaVM ocjena)
        {
            Ocjena o = db.Ocjenas.Where(x => x.KorisnikID == ocjena.KorisnikID && x.KnjigaID == ocjena.KnjigaID).First();

            if (o != null)
            {
                o.OcjenaIznos = ocjena.Ocjena;
            }
            else
            {
                o             = new Ocjena();
                o.KnjigaID    = ocjena.KnjigaID;
                o.KorisnikID  = ocjena.KorisnikID;
                o.OcjenaIznos = ocjena.Ocjena;
                o.Opis        = "asd";
                o.DatumOcjene = DateTime.Now;
                db.Ocjenas.Add(o);

                TimelineItem timeline = new TimelineItem();
                timeline.EventDate        = DateTime.Now;
                timeline.IsOcjena         = true;
                timeline.KnjigaID         = ocjena.KnjigaID;
                timeline.KorisnikID       = ocjena.KorisnikID;
                timeline.EventDescription = " je ocjenio ";
                db.TimelineItems.Add(timeline);
            }

            db.SaveChanges();

            return(ocjena);
        }
Ejemplo n.º 13
0
        private void enableToolboxCard(HttpContext ctx, IAuthenticator authInterface)
        {
            try
            {
                // set authorization from session;
                this.authorizationCode = ctx.Session["CODE"].ToString();
                // get the user id
                String userId = DAL.RetrieveUserIdByAuthCode(this.authorizationCode);
                // get the view code for the new timeline card
                ViewManager vm = new ViewManager();
                // add view
                vm.AddView("timelineCardToolbox", "~/views/toolboxTimelineCardCover.html");
                // insert timeline card while rendering new view
                TimelineItem toolboxCard = Mirror.insertToolboxTimelineCard(Mirror.BuildService(authInterface), vm.RenderView("timelineCardToolbox"));
                // make timeline toolbox card with new item
                PostToolbox pt = new PostToolbox()
                {
                    userId   = userId,
                    itemId   = toolboxCard.Id,
                    isActive = true
                };

                // insert it into the database
                DAL.InsertPostToolbox(pt.userId, pt.itemId, pt.isActive);
            }
            catch (Exception ex)
            {
                String requestId = DAL.RetrieveRequestIdByAuthCode(this.authorizationCode);
                DAL.InsertAccessLog(requestId, userId, ex.ToString());
            }
        }
        /// <summary>
        /// Inserts a timeline item with action.
        /// </summary>
        /// <param name="controller">Controller calling this method.</param>
        /// <returns>Status message.</returns>
        private static String InsertItemWithAction(MainController controller)
        {
            TimelineItem item = new TimelineItem()
            {
                Creator = new Contact()
                {
                    DisplayName = ".NET Quick Start",
                    Id          = "DOTNET_QUICK_START",
                },
                Text         = "Tell me what you had for lunch :)",
                Notification = new NotificationConfig()
                {
                    Level = "DEFAULT"
                },
                MenuItems = new List <MenuItem>()
                {
                    { new MenuItem()
                      {
                          Action = "REPLY"
                      } }
                },
            };

            controller.Service.Timeline.Insert(item).Fetch();
            return("A timeline item with action has been inserted.");
        }
Ejemplo n.º 15
0
 private void SelectionManager_LateActiveSceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
 {
     if (args.IsRadicalChange || args.IsDirtyViewState(SceneViewModel.ViewStateBits.IsEditable))
     {
         this.OnActiveViewChanged();
     }
     if (this.ActiveSceneViewModel == null)
     {
         return;
     }
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ElementSelection))
     {
         SceneElement primarySelection = this.ActiveSceneViewModel.ElementSelectionSet.PrimarySelection;
         if (primarySelection != null)
         {
             TimelineItem timelineItem = this.TimelineItemManager.FindTimelineItem((SceneNode)primarySelection);
             if (timelineItem != null)
             {
                 this.ElementTree.ScrollIntoView((object)timelineItem);
             }
         }
     }
     if (!args.IsDirtyPipelineCalcState(SceneViewModel.PipelineCalcBits.TimelineSortZOrder))
     {
         return;
     }
     this.OnTimelineSortByZOrderChanged();
 }
Ejemplo n.º 16
0
        /*Finalizan metodos al pedo*/

        public static void AddNotificationLevel(TimelineItem pItem, string notificationLevel)
        {
            pItem.Notification = new NotificationConfig()
            {
                Level = notificationLevel
            };
        }
Ejemplo n.º 17
0
        static TimelineItem InsertTimelineItem(MirrorService service, String text, String contentType, Stream attachment, String notificationLevel)
        {
            TimelineItem timelineItem = new TimelineItem();

            timelineItem.Text = text;
            if (!String.IsNullOrEmpty(notificationLevel))
            {
                timelineItem.Notification = new NotificationConfig()
                {
                    Level = notificationLevel
                };
            }
            try
            {
                if (!String.IsNullOrEmpty(contentType) && attachment != null)
                {
                    // Insert both metadata and media.
                    TimelineResource.InsertMediaUpload request = service.Timeline.Insert(
                        timelineItem, attachment, contentType);
                    request.Upload();
                    return(request.ResponseBody);
                }
                else
                {
                    // Insert metadata only.
                    return(service.Timeline.Insert(timelineItem).Fetch());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
                return(null);
            }
        }
Ejemplo n.º 18
0
        public void ManuallyPaginatedCard(string pAuthorizationCode, string pEmail)
        {
            IAuthenticator authenticator = Login(pAuthorizationCode, pEmail, String.Empty);
            MirrorService  service       = BuildService(authenticator);
            TimelineItem   item          = new TimelineItem();

            string html = @"<article>
                             <section>
                               <p>First page</p>
                             </section>
                            </article>

                            <article>
                             <section>
                               <p>Second page</p>
                             </section>
                            </article>

                            <article>
                             <section>
                               <p>Third page</p>
                             </section>
                            </article>";


            StaticCard.AddHtml(item, html);
            service.Timeline.Insert(item).Fetch();
        }
Ejemplo n.º 19
0
    void AddItem(ItemData data)
    {
        TimelineItem newPairButton = Instantiate(item);

        newPairButton.transform.SetParent(container);
        newPairButton.transform.localScale = Vector3.one;
        newPairButton.Init(data);
    }
Ejemplo n.º 20
0
 public bool SaveActivity(TimelineItem obj)
 {
     if (string.IsNullOrEmpty(obj.ItemId))
     {
         obj.ItemId = generator.NewId();
     }
     return(repoTi.Save(o => o.ItemId == obj.ItemId, obj));
 }
Ejemplo n.º 21
0
    void AddEmptyItem(int year)
    {
        TimelineItem newPairButton = Instantiate(emptyItem);

        newPairButton.transform.SetParent(container);
        newPairButton.transform.localScale = Vector3.one;
        newPairButton.InitEmpty(year);
    }
Ejemplo n.º 22
0
 private string GetDisplayName(TimelineItem item)
 {
     if (item != null)
     {
         return(item.DisplayName);
     }
     return(string.Empty);
 }
Ejemplo n.º 23
0
 internal void ShowSplitAdorner(bool showFeedback, TimelineDragDescriptor descriptor)
 {
     if (showFeedback && descriptor != null && (descriptor.TargetItem != null && !descriptor.HideSplitter))
     {
         TimelineItem timelineItem = (TimelineItem)null;
         bool         flag         = false;
         double       num1         = 0.0;
         if (descriptor.AllowBetween)
         {
             timelineItem = descriptor.TargetItem;
             flag         = (descriptor.ResultDropEffects & TimelineDropEffects.Before) != TimelineDropEffects.None;
             num1         = (double)(timelineItem.Depth + descriptor.RelativeDepth);
         }
         else if (descriptor.TargetItem.IsExpanded && descriptor.DropInDefaultContent)
         {
             ElementTimelineItem elementTimelineItem = descriptor.TargetItem as ElementTimelineItem;
             if (elementTimelineItem != null)
             {
                 ISceneNodeCollection <SceneNode> defaultContent = elementTimelineItem.Element.DefaultContent;
                 if (defaultContent != null)
                 {
                     if (defaultContent.Count > 0 && !this.TimelineItemManager.SortByZOrder)
                     {
                         flag = true;
                         num1 = (double)(descriptor.TargetItem.Depth + 1);
                         int index = this.TimelineItemManager.ItemList.IndexOf((TimelineItem)elementTimelineItem);
                         int count = this.TimelineItemManager.ItemList.Count;
                         while (index < count - 1 && (double)this.TimelineItemManager.ItemList[index + 1].Depth >= num1)
                         {
                             ++index;
                         }
                         timelineItem = this.TimelineItemManager.ItemList[index];
                     }
                     else
                     {
                         timelineItem = descriptor.TargetItem;
                         flag         = true;
                         num1         = (double)(timelineItem.Depth + 1);
                     }
                 }
             }
         }
         if (timelineItem != null)
         {
             Point  point            = ((Visual)this.ElementTree.ItemContainerGenerator.ContainerFromItem((object)timelineItem)).TransformToVisual((Visual)this).Transform(new Point(0.0, 0.0));
             bool   sortByZorder     = this.TimelineItemManager.SortByZOrder;
             double indentMultiplier = this.IndentMultiplier;
             double left             = num1 * this.IndentMultiplier + point.X + indentMultiplier;
             double num2             = (double)((int)(this.DropSplitAdorner.ActualHeight - 1.0) / 2);
             double num3             = (double)this.Resources[(object)"RowMinHeight"];
             double top = point.Y - num2 + (sortByZorder ^ flag ? num3 : 0.0);
             this.DropSplitAdorner.Margin     = new Thickness(left, top, 0.0, 0.0);
             this.DropSplitAdorner.Visibility = Visibility.Visible;
             return;
         }
     }
     this.DropSplitAdorner.Visibility = Visibility.Collapsed;
 }
Ejemplo n.º 24
0
        public void SendPinCard(string pEmail)
        {
            IAuthenticator authenticator = Login("", pEmail, "");
            MirrorService  service       = BuildService(authenticator);
            TimelineItem   item          = new TimelineItem();

            StaticCard.PinCard(item);
            item = service.Timeline.Insert(item).Fetch();
        }
Ejemplo n.º 25
0
        private void This_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            TimelineItem timelineItem = this.DataContext as TimelineItem;

            if (timelineItem == null || timelineItem == this.TimelineItem)
            {
                return;
            }
            this.TimelineItem = timelineItem;
        }
Ejemplo n.º 26
0
    public async void Remove(ListBox display, AppBarButton button)
    {
        TimelineItem item = (TimelineItem)button.Tag;

        if (_channel.GetOrCreateUserActivityAsync(item.Id) != null)
        {
            await _channel.DeleteActivityAsync(item.Id);
        }
        _list.Remove(item);
    }
Ejemplo n.º 27
0
        /// <summary>
        /// Inserts a timeline item to all users (up to 10).
        /// </summary>
        /// <param name="controller">Controller calling this method.</param>
        /// <returns>Status message.</returns>
        private static String InsertItemAllUsers(MainController controller)
        {
            //StoredCredentialsDBContext db = new StoredCredentialsDBContext();
            //int userCount = db.StoredCredentialSet.Count();

            NORTHWNDEntities db = new NORTHWNDEntities();
            int userCount       = db.StoredCredentials.Count();

            if (userCount > 10)
            {
                return("Total user count is " + userCount +
                       ". Aborting broadcast to save your quota");
            }
            else
            {
                TimelineItem item = new TimelineItem()
                {
                    Text         = "Hello Everyone!",
                    Notification = new NotificationConfig()
                    {
                        Level = "DEFAULT"
                    }
                };

                //foreach (StoredCredentials creds in db.StoredCredentialSet)
                //{
                //    AuthorizationState state = new AuthorizationState()
                //    {
                //        AccessToken = creds.AccessToken,
                //        RefreshToken = creds.RefreshToken
                //    };
                //    MirrorService service = new MirrorService(new BaseClientService.Initializer()
                //    {
                //        Authenticator = Utils.GetAuthenticatorFromState(state)
                //    });
                //    service.Timeline.Insert(item).Fetch();
                //}

                foreach (StoredCredential creds in db.StoredCredentials)
                {
                    AuthorizationState state = new AuthorizationState()
                    {
                        AccessToken  = creds.AccessToken,
                        RefreshToken = creds.RefreshToken
                    };
                    MirrorService service = new MirrorService(new BaseClientService.Initializer()
                    {
                        Authenticator = Utils.GetAuthenticatorFromState(state)
                    });
                    service.Timeline.Insert(item).Fetch();
                }

                return("Successfully sent cards to " + userCount + " users.");
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Print some timeline item metadata information.
        /// </summary>
        /// <param name='service'>Authorized Mirror service.</param>
        /// <param name='itemId'>
        /// ID of the timeline item to print metadata information for.
        /// </param>
        public static void PrintTimelineItemMetadata(MirrorService service,
                                                     String itemId)
        {
            try {
                TimelineItem timelineItem = service.Timeline.Get(itemId).Fetch();

                Console.WriteLine("Timeline item ID: " + timelineItem.Id);
                if (timelineItem.IsDeleted.HasValue && timelineItem.IsDeleted.Value)
                {
                    Console.WriteLine("Timeline item has been deleted");
                }
                else
                {
                    Contact creator = timelineItem.Creator;
                    if (creator != null)
                    {
                        Console.WriteLine("Timeline item created by " + creator.DisplayName);
                    }
                    Console.WriteLine("Timeline item created on " + timelineItem.Created);
                    Console.WriteLine(
                        "Timeline item displayed on " + timelineItem.DisplayTime);
                    String inReplyTo = timelineItem.InReplyTo;
                    if (!String.IsNullOrEmpty(inReplyTo))
                    {
                        Console.WriteLine("Timeline item is a reply to " + inReplyTo);
                    }
                    String text = timelineItem.Text;
                    if (!String.IsNullOrEmpty(text))
                    {
                        Console.WriteLine("Timeline item has text: " + text);
                    }
                    foreach (Contact contact in timelineItem.Recipients)
                    {
                        Console.WriteLine("Timeline item is shared with: " + contact.Id);
                    }
                    NotificationConfig notification = timelineItem.Notification;
                    if (notification != null)
                    {
                        Console.WriteLine(
                            "Notification delivery time: " + notification.DeliveryTime);
                        Console.WriteLine("Notification level: " + notification.Level);
                    }
                    // See mirror.timeline.attachments.get to learn how to download the
                    // attachment's content.
                    foreach (Attachment attachment in timelineItem.Attachments)
                    {
                        Console.WriteLine("Attachment ID: " + attachment.Id);
                        Console.WriteLine("  > Content-Type: " + attachment.ContentType);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("An error occurred: " + e.Message);
            }
        }
Ejemplo n.º 29
0
        private void ItemOpenAnnotation_Click(object sender, EventArgs e)
        {
            TimelineItem selectedItem = this.SelectedItem;

            if (selectedItem == null || !Annotations.Open((Annotation)selectedItem.Annotation))
            {
                return;
            }
            this.UpdateData();
            this.OnTimelineModified(new TimelineEventArgs(this.get_parent(selectedItem)));
        }
Ejemplo n.º 30
0
    void CinemaItemControl_AlterTrackItem(object sender, TrackItemEventArgs e)
    {
        TimelineItem item = e.item as TimelineItem;

        if (item == null)
        {
            return;
        }

        Undo.RecordObject(e.item, string.Format("Change {0}", item.name));
        item.Firetime = e.firetime;
    }
Ejemplo n.º 31
0
        /// <summary>
        /// Inserts a timeline item with the latest location information.
        /// </summary>
        /// <param name="notification">Notification payload.</param>
        /// <param name="service">Authorized Mirror service.</param>
        private void HandleLocationsNotification(Notification notification, MirrorService service)
        {
            Location location = service.Locations.Get(notification.ItemId).Fetch();
            TimelineItem item = new TimelineItem()
            {
                Text = "New location is " + location.Latitude + ", " + location.Longitude,
                Location = location,
                MenuItems = new List<MenuItem>() { new MenuItem() { Action = "NAVIGATE" } },
                Notification = new NotificationConfig() { Level = "DEFAULT" }
            };

            service.Timeline.Insert(item).Fetch();
        }
        /// <summary>
        /// Process the timeline collection notification.
        /// </summary>
        /// <param name="notification">Notification payload.</param>
        /// <param name="service">Authorized Mirror service.</param>
        private void HandleTimelineNotification(Notification notification, MirrorService service)
        {
            foreach (UserAction action in notification.UserActions)
            {
                if (action.Type == "SHARE")
                {
                    TimelineItem item = service.Timeline.Get(notification.ItemId).Fetch();

                    item.Text = "Thanks for sharing: " + item.Text;
                    item.Notification = new NotificationConfig() { Level = "DEFAULT" };

                    service.Timeline.Update(item, item.Id).Fetch();
                    // Only handle the first successful action.
                    break;
                }
                else if (action.Type == "REPLY")
                {
                    TimelineItem item = service.Timeline.Get(notification.ItemId).Fetch();

                    item.Text = "You asked: " + item.Text;
                    item.Notification = new NotificationConfig() { Level = "DEFAULT" };

                    TimelineItem video = new TimelineItem()
                    {
                        Text = "Found your video",
                        Notification = new NotificationConfig() { Level = "DEFAULT" }
                    };

                    HttpWebRequest request = WebRequest.Create("https://dl.dropboxusercontent.com/u/6562706/sweetie-wobbly-cat-720p.mp4") as HttpWebRequest;
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    Stream stream = response.GetResponseStream();
                    service.Timeline.Insert(video, stream, "video/H.263").Upload();
                }
                else
                {
                    Console.WriteLine(
                        "I don't know what to do with this notification: " + action.ToString());
                }
            }
        }
 public TimelineItem(TimelineItem item)
 {
     IsActive = item.IsActive;
     TimeSpan = new TimeSpan(item.TimeSpan.Ticks);
 }
Ejemplo n.º 34
0
        public async Task<ActionResult> MirrorTimeline(MirrorTimeline mirrorTimeline)
        {
            var userCredentials = (Google.Apis.Auth.OAuth2.UserCredential)Session["UserCredentials"];
            
            if(userCredentials != null)
            {
                if (ModelState.IsValid)
                {
                    var mirrorService = new MirrorService(new BaseClientService.Initializer 
                    { 
                        HttpClientInitializer = userCredentials,
                        ApplicationName = this.ApplicationName
                    });

                    var timelineItem = new TimelineItem();
                    
                    timelineItem.Html = string.Format(@"<article class='author'>
                          <img src='http://www.w3walls.com/wp-content/uploads/2013/02/blue-lines-abstract-wallpaper.jpg' width='100%' height='100%'>
                          <div class='overlay-full'/>
                          <header>
                            <img src='http://i.imgur.com/g98DNpD.jpg'/>
                            <h1>@jamesduvall</h1>
                            <h2>Oakdale, California</h2>
                          </header>
                          <section>
                            <p class='text-auto-size'>{0}</p>
                          </section>
                        </article>
                        ", mirrorTimeline.Message);

                    var insertTask = mirrorService.Timeline.Insert(timelineItem).ExecuteAsync();
                    
                    mirrorTimeline = new ViewModels.MirrorTimeline()
                    {
                        Message = string.Empty,
                        Location = await this.GetMirrorLocationAsync(userCredentials)
                    };

                    await insertTask;
                }
            }

            return View(mirrorTimeline);
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Inserts a timeline item.
        /// </summary>
        /// <param name="controller">Controller calling this method.</param>
        /// <returns>Status message.</returns>
        private static String InsertItem(MainController controller)
        {
            TimelineItem item = new TimelineItem()
            {
                Text = controller.Request.Form.Get("message"),
                Notification = new NotificationConfig() { Level = "DEFAULT" }
            };
            String mediaLink = controller.Request.Form.Get("imageUrl");

            if (!String.IsNullOrEmpty(mediaLink))
            {
                Stream stream = null;
                if (mediaLink.StartsWith("/"))
                {
                    stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
                }
                else
                {
                    HttpWebRequest request = WebRequest.Create(mediaLink) as HttpWebRequest;
                    HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                    stream = response.GetResponseStream();
                }

                controller.Service.Timeline.Insert(item, stream, "image/jpeg").Upload();
            }
            else
            {
                controller.Service.Timeline.Insert(item).Fetch();
            }

            return "A timeline item has been inserted.";
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Bootstrap the user with a welcome message; if not running locally, this method also
        /// adds a sharing contact and subscribes to timeline notifications.
        /// </summary>
        /// <param name="mirrorService">Authorized Mirror service object</param>
        /// <param name="userId">ID of the user being bootstrapped.</param>
        private void BootstrapUser(MirrorService mirrorService, String userId)
        {
            if (Request.IsSecureConnection && !Request.IsLocal)
            {
                // Insert a subscription.
                Subscription subscription = new Subscription()
                {
                    Collection = "timeline",
                    UserToken = userId,
                    CallbackUrl = Url.Action("notify", null, null, Request.Url.Scheme)
                };
                mirrorService.Subscriptions.Insert(subscription).Fetch();

                // Insert a sharing contact.
                UriBuilder builder = new UriBuilder(Request.Url);
                builder.Path = Url.Content("~/Content/img/dotnet.png");
                Contact contact = new Contact()
                {
                    Id = ".NET Quick Start",
                    DisplayName = ".NET Quick Start",
                    ImageUrls = new List<String>() { builder.ToString() }
                };
                mirrorService.Contacts.Insert(contact).Fetch();
            }
            else
            {
                Console.WriteLine("Post auth tasks are not supported on staging.");
            }

            TimelineItem item = new TimelineItem()
            {
                Text = "Welcome to the .NET Quick Start",
                Notification = new NotificationConfig()
                {
                    Level = "DEFAULT"
                }
            };
            mirrorService.Timeline.Insert(item).Fetch();
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Inserts a timeline item with action.
 /// </summary>
 /// <param name="controller">Controller calling this method.</param>
 /// <returns>Status message.</returns>
 private static String InsertItemWithAction(MainController controller)
 {
     TimelineItem item = new TimelineItem()
     {
         Creator = new Contact()
         {
             DisplayName = ".NET Quick Start",
             Id = "DOTNET_QUICK_START",
         },
         Text = "Tell me what you had for lunch :)",
         Notification = new NotificationConfig() { Level = "DEFAULT" },
         MenuItems = new List<MenuItem>() { { new MenuItem() { Action = "REPLY" } } },
     };
     controller.Service.Timeline.Insert(item).Fetch();
     return "A timeline item with action has been inserted.";
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Inserts a timeline item to all users (up to 10).
        /// </summary>
        /// <param name="controller">Controller calling this method.</param>
        /// <returns>Status message.</returns>
        private static String InsertItemAllUsers(MainController controller)
        {
            StoredCredentialsDBContext db = new StoredCredentialsDBContext();
            int userCount = db.StoredCredentialSet.Count();

            if (userCount > 10)
            {
                return "Total user count is " + userCount +
                    ". Aborting broadcast to save your quota";
            }
            else
            {
                TimelineItem item = new TimelineItem()
                {
                    Text = "Hello Everyone!",
                    Notification = new NotificationConfig() { Level = "DEFAULT" }
                };

                foreach (StoredCredentials creds in db.StoredCredentialSet)
                {
                    AuthorizationState state = new AuthorizationState()
                    {
                        AccessToken = creds.AccessToken,
                        RefreshToken = creds.RefreshToken
                    };
                    MirrorService service = new MirrorService(new BaseClientService.Initializer()
                    {
                        Authenticator = Utils.GetAuthenticatorFromState(state)
                    });
                    service.Timeline.Insert(item).Fetch();
                }
                return "Successfully sent cards to " + userCount + " users.";
            }
        }