public void WaitMessagesCountInOneOfChats(int count)
 {
     while (Chat1.GetMessagesCount() < count && Chat2.GetMessagesCount() < count)
     {
         DoEvents();
     }
 }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Chat1 chat1 = db.Chat1.Find(id);

            db.Chat1.Remove(chat1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "ChatID,UserID,ChatMessage,DateTimeStamp")] Chat1 chat1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chat1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "Email", chat1.UserID);
     return(View(chat1));
 }
Ejemplo n.º 4
0
        private async void Initialize(string path)
        {
            _path = path;
            ThemePreview.Initialize(path);

            var flags = TelegramTheme.Light;

            var file = await StorageFile.GetFileFromPathAsync(path);

            var lines = await FileIO.ReadLinesAsync(file);

            foreach (var line in lines)
            {
                if (line.StartsWith("name: "))
                {
                    TitleLabel.Text = line.Substring("name: ".Length);
                }
                else if (line.StartsWith("parent: "))
                {
                    flags = (TelegramTheme)int.Parse(line.Substring("parent: ".Length));
                }
            }

            LayoutRoot.RequestedTheme = flags == TelegramTheme.Light ? ElementTheme.Light : ElementTheme.Dark;

            Chat1.Mockup(new ChatTypePrivate(), 0, "Eva Summer", string.Empty, "Reminds me of a Chinese proverb...", false, 0, false, true, DateTime.Now);
            Chat2.Mockup(new ChatTypePrivate(), 1, "Alexandra Smith", string.Empty, "This is amazing!", false, 2, false, false, DateTime.Now.AddHours(-1));
            Chat3.Mockup(new ChatTypePrivate(), 2, "Mike Apple", "😄 " + Strings.Resources.AttachSticker, string.Empty, false, 2, true, false, DateTime.Now.AddHours(-2), true);
            Chat4.Mockup(new ChatTypeSupergroup(), 3, "Evening Club", "Eva: " + Strings.Resources.AttachPhoto, string.Empty, false, 0, false, false, DateTime.Now.AddHours(-3));
            Chat5.Mockup(new ChatTypeSupergroup(), 4, "Old Pirates", "Max: ", "Yo-ho-ho!", false, 0, false, false, DateTime.Now.AddHours(-4));
            Chat6.Mockup(new ChatTypePrivate(), 5, "Max Bright", string.Empty, "How about some coffee?", true, 0, false, false, DateTime.Now.AddHours(-5));
            Chat7.Mockup(new ChatTypePrivate(), 6, "Natalie Parker", string.Empty, "OK, great)", true, 0, false, false, DateTime.Now.AddHours(-6));

            Photo.Source  = PlaceholderHelper.GetNameForUser(Strings.Resources.ThemePreviewTitle, 30);
            Title.Text    = Strings.Resources.ThemePreviewTitle;
            Subtitle.Text = string.Format("{0} {1} {2}", Strings.Resources.LastSeen, Strings.Resources.TodayAt, Converter.ShortTime.Format(DateTime.Now.AddHours(-1)));

            Message1.Mockup(new MessagePhoto(new Photo(false, null, new[] { new PhotoSize("i", TdExtensions.GetLocalFile("Assets\\Mockup\\theme_preview_image.jpg"), 500, 302, new int[0]) }), new FormattedText(), false), Strings.Resources.ThemePreviewLine4, false, DateTime.Now.AddSeconds(-25), true, true);
            Message2.Mockup(Strings.Resources.ThemePreviewLine1, true, DateTime.Now, true, false);
            //Message3.Mockup(Strings.Resources.FontSizePreviewLine1, Strings.Resources.FontSizePreviewName, Strings.Resources.FontSizePreviewReply, false, DateTime.Now.AddSeconds(-25));
            Message3.Mockup(new MessageVoiceNote(new VoiceNote(3, new byte[]
            {
                0, 0, 163, 198, 43, 17, 250, 248, 127, 155, 85, 58, 159, 230, 164, 212, 185, 247, 73, 42,
                173, 66, 165, 69, 41, 251, 255, 242, 127, 223, 113, 133, 237, 148, 243, 30, 127, 184, 206, 183, 234,
                108, 175, 168, 250, 207, 114, 229, 233, 154, 35, 254, 21, 66, 99, 134, 141, 92, 159, 2
            }, "audio/ogg", null, null), new FormattedText(), true), true, DateTime.Now.AddSeconds(-25), false, true);
            Message4.Mockup(Strings.Resources.ThemePreviewLine3, Strings.Resources.ThemePreviewLine3Reply, Strings.Resources.ThemePreviewLine1, false, DateTime.Now.AddSeconds(-25), true, false);
            Message5.Mockup(new MessageAudio(new Audio(4 * 60 + 3, Strings.Resources.ThemePreviewSongTitle, Strings.Resources.ThemePreviewSongPerformer, "preview.mp3", "audio/mp3", null, null, null, null), new FormattedText()), false, DateTime.Now, false, true);
            Message6.Mockup(Strings.Resources.ThemePreviewLine2, true, DateTime.Now, true, true);

            PrimaryButtonText   = Strings.Resources.ApplyTheme;
            SecondaryButtonText = Strings.Resources.Cancel;
        }
        public void WaitSubstringInMessageInAnyChat(string substring)
        {
            Task task1 = Task.Run(() =>
            {
                Chat1.WaitSubstringInMessage(substring);
            });
            Task task2 = Task.Run(() =>
            {
                Chat2.WaitSubstringInMessage(substring);
            });

            Task.WaitAny(new Task[] { task1, task2 });
        }
Ejemplo n.º 6
0
        //note you got a LOT of red squiggles when it was printed on multiple lines.
        //not sure why but you removed breaks just to be safe.

        // GET: Chat1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chat1 chat1 = db.Chat1.Find(id);

            if (chat1 == null)
            {
                return(HttpNotFound());
            }
            return(View(chat1));
        }
Ejemplo n.º 7
0
        // GET: Chat1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Chat1 chat1 = db.Chat1.Find(id);

            if (chat1 == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "Email", chat1.UserID);
            return(View(chat1));
        }
Ejemplo n.º 8
0
        public void Free()
        {
            if (IsFree)
            {
                return;
            }

            StopCallForwarding();
            Chat1?.Free();
            Chat1 = null;
            Chat2?.Free();
            Chat2 = null;
            BotScenario?.Free();
            BotScenario            = null;
            ConversationController = null;
            IsFree = true;
        }
Ejemplo n.º 9
0
        public void FindCompanions()
        {
            Task task1 = Task.Run(() =>
            {
                Chat1.StartConversation(Settings.ChatSettings1);
            });
            Task task2 = Task.Run(() =>
            {
                Chat2.StartConversation(Settings.ChatSettings2);
            });
            bool finish = false;

            while (!finish && Status == TwoChatsHandlerStatus.Working)
            {
                finish = task1.Wait(200) && task2.Wait(200);
            }
        }
Ejemplo n.º 10
0
 void FinishConversation(bool isCompleted)
 {
     Chat1.FinishConversation();
     Chat2.FinishConversation();
     Status = isCompleted? TwoChatsHandlerStatus.Complete : TwoChatsHandlerStatus.UntimelyFinished;
 }
Ejemplo n.º 11
0
 public void UpdateChatsInfo()
 {
     isTalk1 = Chat1.IsStillTalking();
     isTalk2 = Chat2.IsStillTalking();
 }
Ejemplo n.º 12
0
 public void OnCallback(TwoChatsHandlerCallbackArgs args)
 {
     Chat1.OnCallback(args.ChatHandlerCallbackArgs1);
     Chat2.OnCallback(args.ChatHandlerCallbackArgs2);
     args.IsCompleted = isCompleted;
 }