Beispiel #1
0
        private void LoadFavourites()
        {
            List <byte> list = new List <byte>();

            try { list.AddRange(File.ReadAllBytes(Settings.DataPath + "favourites.dat")); }
            catch { }

            if (list.Count > 0)
            {
                UdpPacketReader buf = new UdpPacketReader(list.ToArray());
                list.Clear();
                list = null;

                while (buf.Remaining() > 0)
                {
                    FavouritesListItem item = new FavouritesListItem();
                    item.AutoJoin = buf.ReadByte() == 1;
                    item.IP       = buf.ReadIP();
                    item.Port     = buf.ReadUInt16();
                    item.Name     = buf.ReadString();
                    item.Topic    = buf.ReadString();
                    item.Password = buf.ReadString();
                    this.favs.Add(item);
                    ChannelListViewItem vitem = new ChannelListViewItem(null, 0);
                    this.gfx.RenderChannelListItem(vitem, item);
                    this.g_favs.Add(vitem);
                    this.channelListView2.Items.Add(vitem);
                }

                buf = null;
            }
        }
Beispiel #2
0
        public void UpdateFavouriteTopic(FavouritesListItem creds)
        {
            if (this.channelListView2.InvokeRequired)
            {
                this.channelListView2.BeginInvoke((Action)(() => this.UpdateFavouriteTopic(creds)));
            }
            else
            {
                String topic = creds.Topic;
                int    index = this.favs.FindIndex(x => x.IP.Equals(creds.IP) && x.Port == creds.Port);

                if (index > -1)
                {
                    if (topic != this.favs[index].Topic)
                    {
                        FavouritesListItem current = this.favs[index];
                        this.channelListView2.Items.RemoveAt(index);
                        this.g_favs[index].Dispose();
                        this.g_favs.RemoveAt(index);
                        this.favs.RemoveAt(index);
                        current.Topic = topic;
                        this.favs.Insert(index, current);
                        ChannelListViewItem vitem = new ChannelListViewItem(null, 0);
                        this.gfx.RenderChannelListItem(vitem, current);
                        this.g_favs.Insert(index, vitem);
                        this.channelListView2.Items.Insert(index, vitem);
                        this.SaveFavourites();
                    }
                }
            }
        }
Beispiel #3
0
        public FavouritesListItem ToFavouritesItem()
        {
            FavouritesListItem f = new FavouritesListItem();

            f.IP          = this.IP;
            f.Name        = this.Name;
            f.Port        = this.Port;
            f.Topic       = this.Topic;
            f.CountString = this.Users.ToString();
            return(f);
        }
        public FavouritesListItem Copy()
        {
            FavouritesListItem c = new FavouritesListItem();

            c.Name        = this.Name;
            c.Topic       = this.Topic;
            c.Port        = this.Port;
            c.IP          = this.IP;
            c.Password    = this.Password;
            c.AutoJoin    = this.AutoJoin;
            c.CountString = this.CountString;
            return(c);
        }
Beispiel #5
0
        private void contextMenuStrip2_Closing(object sender, ToolStripDropDownClosingEventArgs e)
        {
            if (this.channelListView2.SelectedIndices.Count > 0)
            {
                FavouritesListItem item = this.favs[this.channelListView2.SelectedIndices[0]];
                String             pass = this.toolStripTextBox2.Text;

                if (item.Password != pass)
                {
                    item.Password = pass;
                    this.SaveFavourites();
                }
            }
        }
Beispiel #6
0
        private void ExportHashlink(FavouritesListItem room)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(room.Name);
            sb.Append("arlnk://");
            sb.AppendLine(Hashlink.EncodeHashlink(room));

            try
            {
                File.WriteAllText(Settings.DataPath + "hashlink.txt", sb.ToString());
                Process.Start("notepad.exe", Settings.DataPath + "hashlink.txt");
            }
            catch { }
        }
Beispiel #7
0
 public ChannelButton(FavouritesListItem item)
 {
     this.read                  = (Bitmap)Properties.Resources.read.Clone();
     this.unread                = (Bitmap)Properties.Resources.unread.Clone();
     this.AutoSize              = false;
     this.ForeColor             = Color.Black;
     this.Image                 = this.read;
     this.ImageAlign            = ContentAlignment.MiddleLeft;
     this.ImageTransparentColor = Color.Magenta;
     this.Size                  = new Size(172, 28);
     this.Text                  = String.Empty;
     this.RoomName              = item.Name;
     this.ToolTipText           = item.Name;
     this.EndPoint              = new IPEndPoint(item.IP, item.Port);
     this.TextAlign             = ContentAlignment.MiddleLeft;
 }
Beispiel #8
0
        private void AddToFavourites(ChannelListItem room)
        {
            if (this.favs.Find(x => x.IP.Equals(room.IP) && x.Port == room.Port) != null)
            {
                return;
            }

            FavouritesListItem f = room.ToFavouritesItem();

            f.CountString = null;
            this.favs.Add(f);
            ChannelListViewItem vitem = new ChannelListViewItem(null, 0);

            this.gfx.RenderChannelListItem(vitem, f);
            this.g_favs.Add(vitem);
            this.channelListView2.Items.Add(vitem);
            this.SaveFavourites();
        }
Beispiel #9
0
        public void AddToFavourites(FavouritesListItem r)
        {
            FavouritesListItem room = r.Copy();

            room.CountString = null;

            if (this.favs.Find(x => x.IP.Equals(room.IP) && x.Port == room.Port) != null)
            {
                return;
            }

            this.favs.Add(room);
            ChannelListViewItem vitem = new ChannelListViewItem(null, 0);

            this.gfx.RenderChannelListItem(vitem, room);
            this.g_favs.Add(vitem);
            this.channelListView2.Items.Add(vitem);
            this.SaveFavourites();
        }
Beispiel #10
0
        public static String EncodeHashlink(FavouritesListItem room)
        {
            List <byte> list = new List <byte>();

            list.AddRange(new byte[20]);
            list.AddRange(Encoding.UTF8.GetBytes("CHATCHANNEL"));
            list.Add(0);
            list.AddRange(room.IP.GetAddressBytes());
            list.AddRange(BitConverter.GetBytes(room.Port));
            list.AddRange(room.IP.GetAddressBytes());
            list.AddRange(Encoding.UTF8.GetBytes(room.Name));
            list.Add(0);
            list.Add(0);

            byte[] buf = list.ToArray();
            buf = Zip.Compress(buf);
            buf = e67(buf, 28435);

            return(Convert.ToBase64String(buf));
        }
Beispiel #11
0
        public void RenderChannelListItem(ChannelListViewItem item, FavouritesListItem org)
        {
            using (Bitmap bmp = new Bitmap(154, 15))
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.Clear(Color.White);

                    String text    = org.Name;
                    char[] letters = text.ToCharArray();
                    int    x       = 0;

                    for (var i = 0; i < letters.Length; i++)
                    {
                        switch (letters[i])
                        {
                        case ' ':
                            x += 3;
                            break;

                        default:
                            int w = (int)Math.Round((double)g.MeasureString(letters[i].ToString(), this.t_font, 100, StringFormat.GenericTypographic).Width);

                            if ((w + x) < 154)
                            {
                                g.DrawString(letters[i].ToString(), this.t_font, Brushes.Black, new PointF(x, 0));
                            }

                            x += w;
                            break;
                        }

                        if (x >= 154)
                        {
                            break;
                        }
                    }

                    item.NameImg = new Bitmap(x + 2, 15);

                    using (Graphics g2 = Graphics.FromImage(item.NameImg))
                    {
                        g2.Clear(Color.Transparent);
                        g2.DrawImage(bmp, new Point(0, 0));
                    }
                }

            using (Bitmap bmp = new Bitmap(35, 15))
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.Clear(Color.White);

                    String text = org.CountString;

                    if (String.IsNullOrEmpty(text))
                    {
                        text = String.Empty;
                    }

                    char[] letters = text.ToCharArray();
                    int    x       = 0;

                    for (var i = 0; i < letters.Length; i++)
                    {
                        switch (letters[i])
                        {
                        case ' ':
                            x += 3;
                            break;

                        default:
                            int w = (int)Math.Round((double)g.MeasureString(letters[i].ToString(), this.t_font, 100, StringFormat.GenericTypographic).Width);

                            if ((w + x) < 35)
                            {
                                g.DrawString(letters[i].ToString(), this.t_font, Brushes.Black, new PointF(x, 0));
                            }

                            x += w;
                            break;
                        }

                        if (x >= 35)
                        {
                            break;
                        }
                    }

                    item.CountImg = new Bitmap(x + 2, 15);

                    using (Graphics g2 = Graphics.FromImage(item.CountImg))
                    {
                        g2.Clear(Color.Transparent);
                        g2.DrawImage(bmp, new Point(0, 0));
                    }
                }

            using (Bitmap bmp = new Bitmap(1024, 15))
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.Clear(Color.White);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBilinear;

                    String    text = org.Topic;
                    char[]    letters = text.ToCharArray();
                    int       x = 0;
                    bool      bold = false, italic = false, underline = false;
                    Color     fore_color = Color.Black;
                    int       color_finder;
                    EmojiItem emoji_item;

                    for (var i = 0; i < letters.Length; i++)
                    {
                        switch (letters[i])
                        {
                        case '\x0006':
                            bold = !bold;
                            break;

                        case '\x0007':
                            underline = !underline;
                            break;

                        case '\x0009':
                            italic = !italic;
                            break;

                        case '\x0003':
                            if (letters.Length >= (i + 3))
                            {
                                if (int.TryParse(text.Substring(i + 1, 2), out color_finder))
                                {
                                    fore_color = this.GetColorFromCode(color_finder);
                                    i         += 2;
                                }
                                else
                                {
                                    goto default;
                                }
                            }
                            else
                            {
                                goto default;
                            }
                            break;

                        case '\x0005':
                            if (letters.Length >= (i + 3))
                            {
                                if (int.TryParse(text.Substring(i + 1, 2), out color_finder))
                                {
                                    Color back_color = this.GetColorFromCode(color_finder);
                                    i += 2;

                                    using (SolidBrush brush = new SolidBrush(back_color))
                                        g.FillRectangle(brush, new Rectangle(x + 2, 0, 1024 - x - 2, 15));
                                }
                                else
                                {
                                    goto default;
                                }
                            }
                            else
                            {
                                goto default;
                            }
                            break;

                        case ' ':
                            x += underline ? 2 : (bold ? 4 : 3);

                            if (underline)
                            {
                                using (Font font = new Font(this.t_font, this.CreateFont(bold, italic, underline)))
                                    using (SolidBrush brush = new SolidBrush(fore_color))
                                        g.DrawString(" ", font, brush, new PointF(x, 0));
                            }
                            break;

                        case '(':
                        case ':':
                        case ';':
                            Emotic em = Emoticons.FindEmoticon(text.Substring(i).ToUpper());

                            if (em != null)
                            {
                                g.DrawImage(Emoticons.emotic[em.Index], new RectangleF(x + 2, 0, 15, 15));
                                x += 15;
                                i += (em.Shortcut.Length - 1);
                                break;
                            }
                            else
                            {
                                goto default;
                            }

                        case (char)35:
                        case (char)48:
                        case (char)49:
                        case (char)50:
                        case (char)51:
                        case (char)52:
                        case (char)53:
                        case (char)54:
                        case (char)55:
                        case (char)56:
                        case (char)57:
                        case (char)169:
                        case (char)174:
                        case (char)55356:
                        case (char)55357:
                        case (char)8252:
                        case (char)8265:
                        case (char)8482:
                        case (char)8505:
                        case (char)8596:
                        case (char)8597:
                        case (char)8598:
                        case (char)8599:
                        case (char)8600:
                        case (char)8601:
                        case (char)8617:
                        case (char)8618:
                        case (char)8986:
                        case (char)8987:
                        case (char)9193:
                        case (char)9194:
                        case (char)9195:
                        case (char)9196:
                        case (char)9200:
                        case (char)9203:
                        case (char)9410:
                        case (char)9642:
                        case (char)9643:
                        case (char)9654:
                        case (char)9664:
                        case (char)9723:
                        case (char)9724:
                        case (char)9725:
                        case (char)9726:
                        case (char)9728:
                        case (char)9729:
                        case (char)9742:
                        case (char)9745:
                        case (char)9748:
                        case (char)9749:
                        case (char)9757:
                        case (char)9786:
                        case (char)9800:
                        case (char)9801:
                        case (char)9802:
                        case (char)9803:
                        case (char)9804:
                        case (char)9805:
                        case (char)9806:
                        case (char)9807:
                        case (char)9808:
                        case (char)9809:
                        case (char)9810:
                        case (char)9811:
                        case (char)9824:
                        case (char)9827:
                        case (char)9829:
                        case (char)9830:
                        case (char)9832:
                        case (char)9851:
                        case (char)9855:
                        case (char)9875:
                        case (char)9888:
                        case (char)9889:
                        case (char)9898:
                        case (char)9899:
                        case (char)9917:
                        case (char)9918:
                        case (char)9924:
                        case (char)9925:
                        case (char)9934:
                        case (char)9940:
                        case (char)9962:
                        case (char)9970:
                        case (char)9971:
                        case (char)9973:
                        case (char)9978:
                        case (char)9981:
                        case (char)9986:
                        case (char)9989:
                        case (char)9992:
                        case (char)9993:
                        case (char)9994:
                        case (char)9995:
                        case (char)9996:
                        case (char)9999:
                        case (char)10002:
                        case (char)10004:
                        case (char)10006:
                        case (char)10024:
                        case (char)10035:
                        case (char)10036:
                        case (char)10052:
                        case (char)10055:
                        case (char)10060:
                        case (char)10062:
                        case (char)10067:
                        case (char)10068:
                        case (char)10069:
                        case (char)10071:
                        case (char)10084:
                        case (char)10133:
                        case (char)10134:
                        case (char)10135:
                        case (char)10145:
                        case (char)10160:
                        case (char)10175:
                        case (char)10548:
                        case (char)10549:
                        case (char)11013:
                        case (char)11014:
                        case (char)11015:
                        case (char)11035:
                        case (char)11036:
                        case (char)11088:
                        case (char)11093:
                        case (char)12336:
                        case (char)12349:
                        case (char)12951:
                        case (char)12953:
                            emoji_item = Emoji.GetEmoji24(letters, i);

                            if (emoji_item != null)
                            {
                                g.DrawImage(emoji_item.Image, new RectangleF(x + 2, 0, 15, 15));
                                x += 15;
                                i += (emoji_item.Length - 1);
                                break;
                            }
                            else
                            {
                                goto default;
                            }

                        default:
                            using (Font f = new Font(this.t_font, this.CreateFont(bold, italic, underline)))
                                using (SolidBrush brush = new SolidBrush(fore_color))
                                {
                                    int w = (int)Math.Round((double)g.MeasureString(letters[i].ToString(), f, 100, StringFormat.GenericTypographic).Width);
                                    g.DrawString(letters[i].ToString(), f, brush, new PointF(x, 0));
                                    x += w;
                                }
                            break;
                        }
                    }

                    item.TopicImg = new Bitmap(x + 2, 15);

                    using (Graphics g2 = Graphics.FromImage(item.TopicImg))
                    {
                        g2.Clear(Color.Transparent);
                        g2.DrawImage(bmp, new Point(0, 0));
                    }
                }
        }
Beispiel #12
0
        public RoomPanel(FavouritesListItem creds)
        {
            this.InitializeComponent();

            byte[]        c_bytes = creds.IP.GetAddressBytes().Concat(BitConverter.GetBytes(creds.Port)).ToArray();
            StringBuilder sb      = new StringBuilder();

            foreach (byte b in c_bytes)
            {
                sb.AppendFormat("{0:X2}", b);
            }

            this.cache_session          = WebCore.CreateWebSession(System.IO.Path.Combine(Settings.CachePath, sb.ToString()), new WebPreferences());
            this.webControl1.WebSession = this.cache_session;
            sb.Clear();

            this.toolStripDropDownButton1.DropDownDirection = ToolStripDropDownDirection.BelowLeft;
            this.Mode = ScreenMode.Main;
            this.accuTextBox1.Font    = new Font(Settings.GetReg <String>("global_font", "Tahoma"), 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            this.PMName               = String.Empty;
            this.MyName               = String.Empty;
            this.EndPoint             = new IPEndPoint(creds.IP, creds.Port);
            this.webControl1.EndPoint = this.EndPoint;
            this.topic = new Topic();
            this.b1    = (Bitmap)Emoticons.emotic[47].Clone();
            this.toolStripButton5.Image = this.b1;
            this.b2 = (Bitmap)Emoticons.emotic[48].Clone();
            this.toolStripButton6.Image = this.b2;
            this.b3 = (Bitmap)Properties.Resources.button3.Clone();
            this.toolStripButton7.Image = this.b3;
            this.b4 = (Bitmap)Properties.Resources.button4.Clone();
            this.toolStripButton8.Image = this.b4;
            this.b5 = (Bitmap)Properties.Resources.scribble.Clone();
            this.toolStripButton9.Image         = this.b5;
            this.toolStrip1.Renderer            = this.topic;
            this.toolStripButton1.Image         = (Bitmap)Properties.Resources.close.Clone();
            this.toolStripDropDownButton1.Image = (Bitmap)Properties.Resources.settings.Clone();
            this.toolStripDropDownButton1.DropDownItems.Add("Export hashlink");             //0
            this.toolStripDropDownButton1.DropDownItems.Add("Add to favourites");           //1
            this.toolStripDropDownButton1.DropDownItems.Add("Copy room name to clipboard"); //2
            this.toolStripDropDownButton1.DropDownItems.Add("Auto play voice clips");       //3
            this.toolStripDropDownButton1.DropDownItems.Add("Close sub tabs");              //4
            this.toolStripDropDownButton1.DropDownItems.Add(new ToolStripSeparator());
            this.toolStripDropDownButton1.DropDownItems[5].Visible = false;
            this.toolStrip2.Renderer = new ButtonBar();
            this.tab_imgs            = new ImageList();
            this.tab_imgs.ImageSize  = new Size(16, 16);
            this.tab_imgs.Images.Add((Bitmap)Properties.Resources.tab1.Clone());
            this.tab_imgs.Images.Add((Bitmap)Properties.Resources.tab_read.Clone());
            this.tab_imgs.Images.Add((Bitmap)Properties.Resources.tab_unread.Clone());
            this.tab_imgs.Images.Add((Bitmap)Properties.Resources.folder2.Clone());
            this.tabControl1.ImageList            = this.tab_imgs;
            this.tabPage1.ImageIndex              = 0;
            this.webControl1.HashlinkClicked     += this.LinkHashlinkClicked;
            this.webControl1.EditScribbleClicked += this.DoEditScribbleClicked;
            this.webControl1.NameClicked         += this.ScreenNameClicked;
            this.webControl1.IsMainScreen         = true;
            this.rc_ctx = new ContextMenuStrip();
            this.rc_ctx.Items.Add("Close");
            this.rc_ctx.ItemClicked            += this.CTXItemClicked;
            this.splitContainer1.SplitterMoved += this.SplitterMoved;
            this.SetUserlistWidth();
        }