//---------------------------------------------------------------------
 /// <summary>
 /// Construct the
 /// </summary>
 /// <param name="owner">
 /// The parent form.
 /// </param>
 public AllJoynSetup(ChatForm owner)
 {
     _owner = owner;
     InitializeComponent();
     this.Hide();
     _alljoyn = new AllJoynChatComponant();
     InterfaceName = _alljoyn.InterfaceName;
     NamePrefix = _alljoyn.NamePrefix;
     ObjectPath = _alljoyn.ObjectPath;
 }
        public void CalculateTextAndEmotes()
        {
            listOfImagesToDraw.Clear();
            listOfTextToDraw.Clear();

            int border  = 5;
            int tStart  = border;
            int yoffset = 0;

            int highest = 0;
            int lowest  = int.MaxValue;

            bool exists = false;

            foreach (var currentBadge in badges)
            {
                exists = true;
                var theLocation = new Point(tStart, PanelBorder);
                listOfImagesToDraw.Add(new Tuple <ImageAndInts, Point>(new ImageAndInts()
                {
                    img = currentBadge
                }, theLocation));
                tStart += currentBadge.Size.Width + border;
                if (currentBadge.Height > highest)
                {
                    highest = currentBadge.Height;
                }
            }

            var UserNameColor = (Color)cc.ConvertFromString(twitchMessage.color == "" ? ChatForm.getRandomColor() : twitchMessage.color);

            ForeColor = IsAction ? UserNameColor : ForeColor;
            Brush foreColorBrush = new SolidBrush(ForeColor);
            Brush usernameBrush  = new SolidBrush(UserNameColor);

            string usernameText = twitchMessage.display_name + (twitchMessage.username != twitchMessage.display_name.ToLower() ? " (" + twitchMessage.username + ")" : "");
            Size   s            = GetTextSize(usernameText, Font);
            var    location     = new Point(tStart, PanelBorder + (exists ? badges[0].Size.Height / 2 - s.Height / 2 : 0));

            yoffset = location.Y;
            if (location.Y < lowest)
            {
                lowest = location.Y;
            }
            listOfTextToDraw.Add(new Tuple <string, Point, Color>(usernameText, location, UserNameColor));
            //TextRenderer.DrawText(e.Graphics, usernameText, Font, location, UserNameColor, BackColor, TextFormatFlags.NoPadding);

            string text        = twitchMessage.message;
            Size   theTextSize = GetTextSize(text, Font);

            int currentOffset = 0;
            int theWidth      = DesiredWidth - 2 * border;

            int lastX = location.X + s.Width;

            bool first = true;

            for (int i = 0; i < emotes.Count + 1; i++)
            {
                var    thing      = i != emotes.Count ? emotes.Values[i] : new ImageAndInts() /* To avoid errors on compile time */;
                var    theTuple   = thing.ints;
                int    next       = i != emotes.Count ? thing.ints.Item1 : text.Length;
                string offsetText = text.Substring(currentOffset > text.Length - 1 ? text.Length - 1 : currentOffset, (next - currentOffset < 0 ? 0 : next - currentOffset));
                if (first)
                {
                    first      = false;
                    offsetText = ": " + offsetText;
                }
                if (offsetText.Length > 0)
                {
                    if (offsetText[0] == ' ')
                    {
                        offsetText = offsetText.Substring(1);
                    }
                }
                if (offsetText.Length > 0)
                {
                    if (offsetText[offsetText.Length - 1] == ' ')
                    {
                        offsetText = offsetText.Substring(0, offsetText.Length - 1);
                    }
                }
                currentOffset = i != emotes.Count ? thing.ints.Item2 + 1 : 0 /* this 0 shouldn't matter beacuse we're exiting the loop */;

                List <string> args = new List <string>(offsetText.Split(' '));

                string current = "";
                for (int x = 0; x < args.Count; x++)
                {
                    bool   wasInside = false;
                    string old       = current;
                    current += args[x];
                    Size currentTextWidth = GetTextSize(current, Font);
                    if (currentTextWidth.Width + lastX > theWidth)
                    {
                        wasInside = true;
                        Size currentArgsWidth = GetTextSize(args[x], Font);
                        if (currentArgsWidth.Width > theWidth)
                        {
                            string gurrent = "";
                            for (int j = 0; j < args[x].Length; j++)
                            {
                                string anotherold = gurrent;
                                gurrent += args[x][j];
                                if (GetTextSize(gurrent + old, Font).Width + lastX > theWidth)
                                {
                                    j = j < 0 ? 0 : j;
                                    args.Insert(x + 1, args[x].Substring(j));
                                    args[x] = args[x].Substring(0, j);
                                    old    += anotherold;
                                    x++;
                                    break;
                                }
                            }
                        }
                        if (old != "")
                        {
                            x--;
                        }
                        listOfTextToDraw.Add(new Tuple <string, Point, Color>(old, new Point(lastX, yoffset), ForeColor));
                        //TextRenderer.DrawText(e.Graphics, old, Font, new Point(lastX, yoffset), ForeColor, BackColor, TextFormatFlags.NoPadding);
                        yoffset += theTextSize.Height + (28 / 2 - theTextSize.Height / 2);
                        lastX    = border;
                        current  = "";
                    }
                    if (x == args.Count - 1)
                    {
                        if (currentTextWidth.Height + yoffset > highest)
                        {
                            highest = currentTextWidth.Height + yoffset;
                        }
                        if (current != "" && current != " ")
                        {
                            listOfTextToDraw.Add(new Tuple <string, Point, Color>(current, new Point(lastX, yoffset), ForeColor));
                            //TextRenderer.DrawText(e.Graphics, current, Font, new Point(lastX, yoffset), ForeColor, BackColor, TextFormatFlags.NoPadding);
                            lastX += GetTextSize(current, Font).Width;
                        }
                    }
                    else if (!wasInside)
                    {
                        current += " ";
                    }
                }
                if (i != emotes.Count)
                {
                    if (thing.img == null)
                    {
                        return;
                    }
                    Size theSize = thing.preferredSize.Width != 0 && thing.preferredSize.Height != 0 ? thing.preferredSize : new Size(thing.img.Size.Width, thing.img.Size.Height);
                    if (lastX + theSize.Width > theWidth)
                    {
                        lastX    = border;
                        yoffset += theTextSize.Height + (28 / 2 - theTextSize.Height / 2);
                    }
                    var pa = new Point(lastX + EmoteSpacing, yoffset + theTextSize.Height / 2 - theSize.Height / 2);
                    if (pa.Y < lowest)
                    {
                        lowest = pa.Y;
                    }
                    listOfImagesToDraw.Add(new Tuple <ImageAndInts, Point>(thing, pa));
                    //e.Graphics.DrawImage(thing.img, pa.X, pa.Y, theSize.Width, theSize.Height);
                    if (yoffset + theSize.Height + theTextSize.Height / 2 - theSize.Height / 2 > highest)
                    {
                        highest = yoffset + theSize.Height + theTextSize.Height / 2 - theSize.Height / 2;
                    }
                    lastX += theSize.Width;
                    lastX += 2 * EmoteSpacing;
                }
                else
                {
                    break;
                }
            }
            if (lowest < PanelBorder)
            {
                List <Tuple <ImageAndInts, Point> > tempList = new List <Tuple <ImageAndInts, Point> >();
                foreach (var t in listOfImagesToDraw)
                {
                    tempList.Add(new Tuple <ImageAndInts, Point>(t.Item1, new Point(t.Item2.X, t.Item2.Y + Math.Abs(lowest) + PanelBorder)));
                }
                listOfImagesToDraw = tempList;
                List <Tuple <string, Point, Color> > tempList2 = new List <Tuple <string, Point, Color> >();
                foreach (var t in listOfTextToDraw)
                {
                    tempList2.Add(new Tuple <string, Point, Color>(t.Item1, new Point(t.Item2.X, t.Item2.Y + Math.Abs(lowest) + PanelBorder), t.Item3));
                }
                listOfTextToDraw = tempList2;
            }
            DrawContent(CreateGraphics());
            Size = new Size(DesiredWidth * 2, Math.Max(highest - lowest + 2 * PanelBorder, 28));
        }
Exemple #3
0
        private void Receive()
        {
            byte[]        buffer = new byte[1024];
            int           bytesRead;
            StringBuilder message = new StringBuilder();


            while (true)
            {
                try
                {
                    bytesRead = networkStream.Read(buffer, 0, 1024);
                    message.Clear();
                    message.AppendFormat("{0}", Encoding.Unicode.GetString(buffer, 0, bytesRead));
                }
                catch
                {
                }

                if (message.Length > 0)
                {
                    Console.WriteLine(message);
                    switch (message.ToString())
                    {
                    case "Connect":
                        break;

                    case "Disconnect":
                        this.Disconnect();
                        break;

                    case "Command":
                        commandConnection = new CommandConnection();
                        commandConnection.Start();
                        break;

                    case "Command Closed":
                        commandConnection.Disconnect();
                        break;

                    case "Video":
                        videoConnection = new VideoConnection();
                        videoConnection.Start();
                        break;

                    case "Video Closed":
                        videoConnection.Disconnect();
                        break;

                    case "Screen":
                        screenConnection = new ScreenConnection();
                        screenConnection.Start();
                        break;

                    case "Screen Closed":
                        screenConnection.Disconnect();
                        break;

                    case "FileManage":
                        if (!isFileManageConnected)
                        {
                            DrivAndDireInfo.StartConnection_Creation();
                            DrivAndDireInfo.GetDrivesInfo(Dns.GetHostName());
                            DrivAndDireInfo.SendDrivesInfo();
                            FileOperation.StartFileConnection_Operation();
                            Thread receiveThread      = new Thread(DrivAndDireInfo.Receive);
                            Thread receiveOpCmdThread = new Thread(FileOperation.ReceiveOperationCommand);
                            //receiveThread.IsBackground = true;
                            receiveThread.Start();
                            receiveOpCmdThread.Start();
                        }
                        break;

                    case "FileManage Closed":
                        break;

                    case "Chat":
                        ChatForm chatForm = new ChatForm();
                        chatForm.SetConnect();
                        chatForm.ShowDialog();
                        break;

                    case "Chat Closed":
                        break;

                    case "PushScreen":
                        PushScreenForm pushForm = new PushScreenForm();
                        pushForm.SetConnect();
                        pushForm.ShowDialog();
                        break;

                    case "PushScreen Closed":
                        //form.Disconnect();
                        break;
                    }
                }
            }
        }
Exemple #4
0
 private void ChatButton_Click(object sender, EventArgs e)
 {
     _chatForm = new ChatForm();
     _chatForm.Show(ParentForm);
 }
 public GraphicalInterfaceController(ProgramController programControl, ChatForm chatForm)
 {
     this.programControl = programControl;
     this.chatForm = chatForm;
     Initialize();
 }
Exemple #6
0
        void do_fileOutter_FileResponseReceived(TransferingProject project, bool agreeReceive)
        {
            ChatForm form = this.GetChatForm(project.DestUserID);

            form.FlashChatWindow(true);
        }
        private void EnsureShowAndPlaceNonChartWindow(NonChartWindowSettings wndSets)
        {
            var wnd = MdiChildren.FirstOrDefault(c => c is IMdiNonChartWindow &&
                                                 ((IMdiNonChartWindow)c).WindowCode == wndSets.Window);

            if (wnd == null)
            {
                // создать окно
                if (wndSets.Window == NonChartWindowSettings.WindowCode.Account)
                {
                    wnd = new AccountMonitorForm {
                        MdiParent = this
                    }
                }
                ;

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.RobotTest)
                {
                    wnd = new RoboTesterForm();
                    ((RoboTesterForm)wnd).OnRobotResultsBoundToCharts += OnRobotResultsBoundToCharts;
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.Profit)
                {
                    wnd = new AccountTradeResultsForm {
                        InstantCalculation = false
                    }
                }
                ;

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.Chat)
                {
                    wnd = new ChatForm();
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.Quotes)
                {
                    wnd = new QuoteTableForm();
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.Subscription)
                {
                    wnd = new SubscriptionForm();
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.WebBrowser)
                {
                    wnd = new BrowserForm();
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.RiskForm)
                {
                    wnd = new RiskSetupForm();
                }

                else if (wndSets.Window == NonChartWindowSettings.WindowCode.WalletForm)
                {
                    wnd = new WalletForm();
                }

                SetupNonMdiForm((IMdiNonChartWindow)wnd);
                wnd.Show();
            }
            else
            {
                wnd.Focus();
            }

            // установить окну положенные размеры
            wnd.Location    = wndSets.WindowPos;
            wnd.Size        = wndSets.WindowSize;
            wnd.WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), wndSets.WindowState);
            ((IMdiNonChartWindow)wnd).WindowInnerTabPageIndex = wndSets.CurrentTabIndex;
        }
 /// <summary>
 /// Determines if the chatintermediary contains the specific chatform.
 /// </summary>
 /// <param name="cf">A chatform object.</param>
 public bool Contains(ChatForm cf)
 {
     return (cf == m_chatform);
 }
Exemple #9
0
 public UserChat(UserInfo userInfo, ChatForm chatForm, ServerListener serverListener=null)
 {
     this.userInfo = userInfo;
     this.chatForm = chatForm;
     this.serverListener = serverListener;
 }
Exemple #10
0
        public void HandleInformation(string sourceUserID, int informationType, byte[] info)
        {
            if (!this.initialized)
            {
                return;
            }

            #region 需要twinkle的消息
            if (informationType == InformationTypes.Chat || informationType == InformationTypes.OfflineMessage || informationType == InformationTypes.OfflineFileResultNotify ||
                informationType == InformationTypes.Vibration || informationType == InformationTypes.VideoRequest || informationType == InformationTypes.AgreeVideo ||
                informationType == InformationTypes.RejectVideo || informationType == InformationTypes.HungUpVideo || informationType == InformationTypes.DiskRequest ||
                informationType == InformationTypes.AgreeDisk || informationType == InformationTypes.RejectDisk || informationType == InformationTypes.RemoteHelpRequest ||
                informationType == InformationTypes.AgreeRemoteHelp || informationType == InformationTypes.RejectRemoteHelp || informationType == InformationTypes.CloseRemoteHelp ||
                informationType == InformationTypes.TerminateRemoteHelp ||
                informationType == InformationTypes.AudioRequest || informationType == InformationTypes.RejectAudio || informationType == InformationTypes.AgreeAudio ||
                informationType == InformationTypes.HungupAudio ||
                informationType == InformationTypes.FriendAddedNotify)
            {
                if (informationType == InformationTypes.FriendAddedNotify)
                {
                    GGUser owner = CompactPropertySerializer.Default.Deserialize <GGUser>(info, 0); // 0922
                    this.globalUserCache.CurrentUser.AddFriend(owner.ID, this.globalUserCache.CurrentUser.DefaultFriendCatalog);
                    this.globalUserCache.OnFriendAdded(owner);                                      //自然会添加 好友条目
                    sourceUserID = owner.UserID;
                }

                object tag = null;
                if (informationType == InformationTypes.OfflineMessage)
                {
                    byte[]         bChatBoxContent = null;
                    OfflineMessage msg             = CompactPropertySerializer.Default.Deserialize <OfflineMessage>(info, 0);
                    if (msg.InformationType == InformationTypes.Chat) //目前只处理离线的聊天消息
                    {
                        sourceUserID    = msg.SourceUserID;
                        bChatBoxContent = msg.Information;
                        byte[] decrypted = bChatBoxContent;
                        if (GlobalResourceManager.Des3Encryption != null)
                        {
                            decrypted = GlobalResourceManager.Des3Encryption.Decrypt(bChatBoxContent);
                        }

                        ChatMessageRecord record = new ChatMessageRecord(sourceUserID, this.rapidPassiveEngine.CurrentUserID, decrypted, false);
                        GlobalResourceManager.ChatMessageRecordPersister.InsertChatMessageRecord(record);
                        ChatBoxContent content = CompactPropertySerializer.Default.Deserialize <ChatBoxContent>(decrypted, 0);
                        tag = new Parameter <ChatBoxContent, DateTime>(content, msg.Time);
                    }
                }

                if (informationType == InformationTypes.OfflineFileResultNotify)
                {
                    OfflineFileResultNotifyContract contract = CompactPropertySerializer.Default.Deserialize <OfflineFileResultNotifyContract>(info, 0);
                    sourceUserID = contract.AccepterID;
                }

                GGUser user = this.globalUserCache.GetUser(sourceUserID);
                this.notifyIcon.PushFriendMessage(sourceUserID, informationType, info, tag);
                return;
            }
            #endregion

            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric <string, int, byte[]>(this.HandleInformation), sourceUserID, informationType, info);
            }
            else
            {
                try
                {
                    if (informationType == InformationTypes.InputingNotify)
                    {
                        ChatForm form = this.chatFormManager.GetForm(sourceUserID);
                        if (form != null)
                        {
                            form.OnInptingNotify();
                        }
                        return;
                    }

                    if (informationType == InformationTypes.FriendRemovedNotify)
                    {
                        string friendID = System.Text.Encoding.UTF8.GetString(info);
                        this.globalUserCache.RemovedFriend(friendID);
                        return;
                    }

                    if (informationType == InformationTypes.UserInforChanged)
                    {
                        GGUser user = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <GGUser>(info, 0);
                        this.globalUserCache.AddOrUpdateUser(user);
                        return;
                    }

                    if (informationType == InformationTypes.UserStatusChanged)
                    {
                        UserStatusChangedContract contract = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <UserStatusChangedContract>(info, 0);
                        this.globalUserCache.ChangeUserStatus(contract.UserID, (UserStatus)contract.NewStatus);
                    }

                    if (informationType == InformationTypes.SystemNotify4AllOnline)
                    {
                        SystemNotifyContract contract = CompactPropertySerializer.Default.Deserialize <SystemNotifyContract>(info, 0);
                        SystemNotifyForm     form     = new SystemNotifyForm(contract.Title, contract.Content);
                        form.Show();
                        return;
                    }

                    if (informationType == InformationTypes.SystemNotify4Group)
                    {
                        SystemNotifyContract contract = CompactPropertySerializer.Default.Deserialize <SystemNotifyContract>(info, 0);
                        SystemNotifyForm     form     = new SystemNotifyForm(contract.Title, contract.Content);
                        form.Show();
                        return;
                    }
                }
                catch (Exception ee)
                {
                    GlobalResourceManager.Logger.Log(ee, "MainForm.HandleInformation", ESBasic.Loggers.ErrorLevel.Standard);
                    MessageBox.Show(ee.Message);
                }
            }
        }
Exemple #11
0
 public void ExitChatter()
 {
     Chatter = null;
 }
        private void Receive()
        {
            byte[] buffer = new byte[1024];
            int bytesRead;
            StringBuilder message = new StringBuilder();

            while (true)
            {
                try
                {
                    bytesRead = networkStream.Read(buffer, 0, 1024);
                    message.Clear();
                    message.AppendFormat("{0}", Encoding.Unicode.GetString(buffer, 0, bytesRead));
                }
                catch
                {

                }

                if (message.Length > 0)
                {
                    Console.WriteLine(message);
                    switch (message.ToString())
                    {
                        case "Connect":
                            break;
                        case "Disconnect":
                            this.Disconnect();
                            break;
                        case "Command":
                            commandConnection = new CommandConnection();
                            commandConnection.Start();
                            break;
                        case "Command Closed":
                            commandConnection.Disconnect();
                            break;
                        case "Video":
                            videoConnection = new VideoConnection();
                            videoConnection.Start();
                            break;
                        case "Video Closed":
                            videoConnection.Disconnect();
                            break;
                        case "Screen":
                            screenConnection = new ScreenConnection();
                            screenConnection.Start();
                            break;
                        case "Screen Closed":
                            screenConnection.Disconnect();
                            break;
                        case "FileManage":
                            if (!isFileManageConnected)
                            {
                                DrivAndDireInfo.StartConnection_Creation();
                                DrivAndDireInfo.GetDrivesInfo(Dns.GetHostName());
                                DrivAndDireInfo.SendDrivesInfo();
                                FileOperation.StartFileConnection_Operation();
                                Thread receiveThread = new Thread(DrivAndDireInfo.Receive);
                                Thread receiveOpCmdThread = new Thread(FileOperation.ReceiveOperationCommand);
                                //receiveThread.IsBackground = true;
                                receiveThread.Start();
                                receiveOpCmdThread.Start();
                            }
                            break;
                        case "FileManage Closed":
                            break;
                        case "Chat":
                            ChatForm chatForm = new ChatForm();
                            chatForm.SetConnect();
                            chatForm.ShowDialog();
                            break;
                        case "Chat Closed":
                            break;
                        case "PushScreen":
                            PushScreenForm pushForm = new PushScreenForm();
                            pushForm.SetConnect();
                            pushForm.ShowDialog();
                            break;
                        case "PushScreen Closed":
                            //form.Disconnect();
                            break;
                    }
                }
            }
        }
Exemple #13
0
 private void chatButton_Click(object sender, EventArgs e)
 {
     chatform = new ChatForm(bikeID, doctorClient);
     chatform.Show();
     chatform.BringToFront();
 }
Exemple #14
0
 // делегат для ожидания соединения
 public SocketServer(int port, ChatForm chatForm)
 {
     this.chatForm = chatForm;
     this.port     = port;
 }
Exemple #15
0
 public void OnChat(object sender, ChatForm chat)
 {
     Debug.Log(chat.Nickname);
     Debug.Log(chat.Message);
 }
 public ProgramController(ChatForm chatForm)
 {
     this.chatForm = chatForm;
     InitiateController();
 }
        /// <summary>
        /// Creates an instance.
        /// </summary>
        /// <param name="chatform"></param>
        public void Create(string friendsUserId, string currentUserId, ChildNode cn)
        {
            //Set the chatform and dump the offline message into the new chatform.
            if (m_chatform == null)
            {
                m_chatform = new ChatForm(friendsUserId, currentUserId, cn);

                if (m_offlineChat != null)
                    m_chatform.WriteMessageToChatLog(m_offlineChat);
            }
        }
Exemple #18
0
 // делегат для ожидания соединения
 public SocketServer(int port, ChatForm chatForm)
 {
     this.chatForm = chatForm;
     this.port = port;
 }
Exemple #19
0
        private static void NewClient()
        {
            var frm = new ChatForm();

            frm.ShowDialog();
        }
Exemple #20
0
        /// <summary>
        /// 채팅 메시지 보내기
        /// </summary>
        /// <param name="chat"></param>
        public void Chat(ChatForm chat)
        {
            var json = JsonConvert.SerializeObject(chat);

            _io.Emit(SocketEvent.CHATTING, json);
        }