示例#1
0
        private void Eval_VC_PM_First(TCPPacketReader packet)
        {
            VoicePlayerInboundItem item = new VoicePlayerInboundItem(packet, this.crypto, this.EndPoint);

            VoicePlayer.Inbound.RemoveAll(x => x.Ident == item.Ident && x.EndPoint.Equals(this.EndPoint));

            if (item.Received)
            {
                item.Save();

                if (!String.IsNullOrEmpty(item.FileName))
                {
                    VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG);
                    VoicePlayer.Records.Add(vc);
                    User u = this.users.Find(x => x.Name == vc.Sender);

                    if (u != null)
                    {
                        if (!u.Ignored)
                        {
                            if (ScriptEvents.OnVoiceClipReceiving(this, u, true))
                            {
                                this.Panel.PMTextReceived(this, u, vc.Sender, GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.BlackBG) + "--- \\\\voice_clip_#" + vc.ShortCut + " " + StringTemplate.Get(STType.Messages, 8).Replace("+x", vc.Sender), null, PMTextReceivedType.Announce);
                                ScriptEvents.OnVoiceClipReceived(this, u, true);
                            }
                        }
                    }
                }
            }
            else
            {
                VoicePlayer.Inbound.Add(item);
            }
        }
        public VoicePlayerItem ToVoicePlayerItem(uint sc, bool b)
        {
            VoicePlayerItem item = new VoicePlayerItem(sc, b);

            item.EndPoint = this.EndPoint;
            item.FileName = this.FileName;
            item.Ident    = this.Ident;
            item.Sender   = this.Sender;
            return(item);
        }
示例#3
0
        protected override void OnLinkClicked(LinkClickedEventArgs e)
        {
            base.OnLinkClicked(e);

            if (e.LinkText.StartsWith("\\\\arlnk://"))
            {
                DecryptedHashlink hashlink = Hashlink.DecodeHashlink(e.LinkText.Substring(10));

                if (hashlink != null)
                {
                    this.HashlinkClicked(hashlink, EventArgs.Empty);
                }
            }
            else if (e.LinkText.StartsWith("\\\\cb0t://script/?file="))
            {
                String str = e.LinkText.Substring(22);

                if (!String.IsNullOrEmpty(str))
                {
                    Scripting.ScriptManager.InstallScript(str);
                }
            }
            else if (e.LinkText.StartsWith("\\\\voice_clip_#"))
            {
                String vc_check  = e.LinkText.Substring(14);
                uint   vc_finder = 0;

                if (uint.TryParse(vc_check, out vc_finder))
                {
                    VoicePlayerItem vc = VoicePlayer.Records.Find(x => x.ShortCut == vc_finder);

                    if (vc != null)
                    {
                        vc.Auto = false;
                        VoicePlayer.QueueItem(vc);
                    }
                }
            }
            else
            {
                String check = e.LinkText.ToUpper();

                if (check.StartsWith("HTTP://") || check.StartsWith("HTTPS://") || check.StartsWith("WWW."))
                {
                    Scripting.JSOutboundTextItem cb = new Scripting.JSOutboundTextItem();
                    cb.Type     = Scripting.JSOutboundTextItemType.Link;
                    cb.Text     = e.LinkText;
                    cb.EndPoint = this.EndPoint;
                    Scripting.ScriptManager.PendingUIText.Enqueue(cb);
                }
            }
        }
示例#4
0
        private void Eval_VC_Chunk(TCPPacketReader packet)
        {
            String sender = packet.ReadString(this.crypto);
            uint   ident  = packet;
            int    index  = VoicePlayer.Inbound.FindIndex(x => x.EndPoint.Equals(this.EndPoint) && x.Ident == ident);

            byte[] chunk = packet;

            if (index > -1)
            {
                VoicePlayerInboundItem item = VoicePlayer.Inbound[index];
                item.AddChunk(chunk);

                if (item.Received)
                {
                    VoicePlayer.Inbound.RemoveAt(index);
                    item.Save();

                    if (!String.IsNullOrEmpty(item.FileName))
                    {
                        VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG);
                        VoicePlayer.Records.Add(vc);
                        User u = this.users.Find(x => x.Name == vc.Sender);

                        if (u != null)
                        {
                            if (!u.Ignored)
                            {
                                if (ScriptEvents.OnVoiceClipReceiving(this, u, false))
                                {
                                    if (this.CanAutoPlayVC)
                                    {
                                        vc.Auto = true;
                                        VoicePlayer.QueueItem(vc);
                                    }
                                    else
                                    {
                                        this.Panel.ShowVoice(vc.Sender, vc.ShortCut);
                                    }

                                    ScriptEvents.OnVoiceClipReceived(this, u, false);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#5
0
        private void Eval_VC_First(TCPPacketReader packet)
        {
            VoicePlayerInboundItem item = new VoicePlayerInboundItem(packet, this.crypto, this.EndPoint);

            VoicePlayer.Inbound.RemoveAll(x => x.Ident == item.Ident && x.EndPoint.Equals(this.EndPoint));

            if (item.Received)
            {
                item.Save();

                if (!String.IsNullOrEmpty(item.FileName))
                {
                    VoicePlayerItem vc = item.ToVoicePlayerItem(++VoicePlayer.NEXT_SHORTCUT, this.BlackBG);
                    VoicePlayer.Records.Add(vc);
                    User u = this.users.Find(x => x.Name == vc.Sender);

                    if (u != null)
                    {
                        if (!u.Ignored)
                        {
                            if (ScriptEvents.OnVoiceClipReceiving(this, u, false))
                            {
                                if (this.CanAutoPlayVC)
                                {
                                    vc.Auto = true;
                                    VoicePlayer.QueueItem(vc);
                                }
                                else
                                {
                                    this.Panel.ShowVoice(vc.Sender, vc.ShortCut);
                                }

                                ScriptEvents.OnVoiceClipReceived(this, u, false);
                            }
                        }
                    }
                }
            }
            else
            {
                VoicePlayer.Inbound.Add(item);
            }
        }
示例#6
0
        public static void Tick(Form1 form)
        {
            if (State == VoicePlayerState.Available)
            {
                VoicePlayerItem item = null;

                lock (padlock)
                    if (PlaybackQueue.Count > 0)
                    {
                        item = PlaybackQueue[0];
                        PlaybackQueue.RemoveAt(0);
                    }

                if (item != null)
                {
                    String path    = Path.Combine(Settings.VoicePath, item.FileName + ".wav");
                    int    success = 0;
                    mciSendString("open \"" + path + "\" type mpegvideo alias " + PLAYBACK_DEVICE_NAME, null, 0, IntPtr.Zero);
                    success = mciSendString("set " + PLAYBACK_DEVICE_NAME + " output " + AudioHelpers.GetPlaybackIdent(), null, 0, IntPtr.Zero);
                    success = mciSendString("play " + PLAYBACK_DEVICE_NAME + " notify", null, 0, form.Handle);

                    if (success == 0)
                    {
                        State = VoicePlayerState.Busy;

                        if (item.Auto)
                        {
                            Room room = RoomPool.Rooms.Find(x => x.EndPoint.Equals(item.EndPoint));

                            if (room != null)
                            {
                                room.Panel.ShowVoice(item.Sender, item.ShortCut);
                            }
                        }
                    }
                }
            }
        }
示例#7
0
        private void CTXItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Equals(this.ctx.Items[0]))
            {
                if (this.img_data != null)
                {
                    byte[] tmp = this.img_data;
                    this.ctx.Hide();
                    SharedUI.SaveFile.Filter           = "Image|*.png";
                    SharedUI.SaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    SharedUI.SaveFile.FileName         = String.Empty;

                    if (SharedUI.SaveFile.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            File.WriteAllBytes(SharedUI.SaveFile.FileName, tmp);
                        }
                        catch { }
                    }
                }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[1]))
            {
                if (this.img_data != null)
                {
                    byte[] tmp = this.img_data;
                    this.ctx.Hide();
                    this.EditScribbleClicked(tmp, EventArgs.Empty);
                }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[2]))
            {
                VoicePlayerItem item = VoicePlayer.Records.Find(x => x.ShortCut == this.vc_sc);
                this.ctx.Hide();
                SharedUI.SaveFile.Filter           = "Wav|*.wav";
                SharedUI.SaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
                SharedUI.SaveFile.FileName         = String.Empty;

                if (SharedUI.SaveFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        if (item != null)
                        {
                            String org_path = Path.Combine(Settings.VoicePath, item.FileName + ".wav");
                            File.Copy(org_path, SharedUI.SaveFile.FileName);
                        }
                    }
                    catch { }
                }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[3]))
            {
                this.Clear();

                while (this.CanUndo)
                {
                    this.ClearUndo();
                }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[4]))
            {
                try
                {
                    File.WriteAllLines(Settings.DataPath + "export.txt", this.Lines);
                    Process.Start("notepad.exe", Settings.DataPath + "export.txt");
                }
                catch { }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[5]))
            {
                try
                {
                    if (this.SelectionLength == 0)
                    {
                        Clipboard.SetText(this.Text);
                    }
                    else
                    {
                        Clipboard.SetText(this.Text.Substring(this.SelectionStart, this.SelectionLength));
                    }
                }
                catch { }
            }
            else if (e.ClickedItem.Equals(this.ctx.Items[6]))
            {
                if (this.IsPaused)
                {
                    this.IsPaused = false;

                    while (this.paused_items.Count > 0)
                    {
                        PausedItem item = this.paused_items[0];
                        this.paused_items.RemoveAt(0);

                        switch (item.Type)
                        {
                        case PausedItemType.Announce:
                            this.ShowAnnounceText(item.Text);
                            break;

                        case PausedItemType.Emote:
                            this.ShowEmoteText(item.Name, item.Text, null);
                            break;

                        case PausedItemType.PM:
                            this.ShowPMText(item.Name, item.Text, null);
                            break;

                        case PausedItemType.Public:
                            this.ShowPublicText(item.Name, item.Text, null);
                            break;

                        case PausedItemType.Server:
                            this.ShowServerText(item.Text);
                            break;
                        }
                    }

                    this.paused_items = new List <PausedItem>();
                    this.ShowAnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.IsBlack) + "--- " + StringTemplate.Get(STType.OutBox, 6));
                }
                else
                {
                    this.ShowAnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Server, this.IsBlack) + "--- " + StringTemplate.Get(STType.OutBox, 7));
                    this.IsPaused = true;
                }
            }
        }
示例#8
0
 public static void QueueItem(VoicePlayerItem item)
 {
     lock (padlock)
         PlaybackQueue.Add(item);
 }