Пример #1
0
        /// <summary>
        /// Renders the specified chat node to the client.
        /// </summary>
        /// <param name="node">The node to append.</param>
        /// <remarks>
        /// <para>The return value of this function is a reference to the outermost <see cref="HtmlElement">HtmlElement</see> constructed
        /// by this function.  It may create additional inner elements as needed.</para>
        /// </remarks>
        /// <returns>
        /// Returns an object instance of <see cref="HtmlElement">HtmlElement</see> that can be appended to the HTML document.
        /// </returns>
        public override Inline Render(ChatNode node)
        {
            IIconProvider provider = ProfileResourceProvider.GetForClient(null).Icons;

            ImageChatNode icn = node as ImageChatNode;

            if (icn != null)
            {
                InlineUIContainer result = new InlineUIContainer();
                Image             img    = new Image();
                img.Source  = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap((icn.Image as System.Drawing.Bitmap).GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                img.ToolTip = icn.Text;
                img.Width   = provider.IconSize.Width;
                img.Height  = provider.IconSize.Height;

                result.Child = img;

                if (icn.LinkUri != null)
                {
                    Hyperlink container = new Hyperlink(result);
                    container.NavigateUri = node.LinkUri;
                    container.ToolTip     = string.Format(CultureInfo.CurrentUICulture, "Link to {0}", node.LinkUri);

                    return(container);
                }

                return(result);
            }
            else
            {
                return(base.Render(node));
            }
        }
Пример #2
0
        public ClanListBoxItemRenderer()
        {
            ProfileResourceProvider prp = ProfileResourceProvider.GetForClient(null);

            if (!object.ReferenceEquals(prp, null))
            {
                m_provider = prp.Icons;
            }
        }
Пример #3
0
        public JinxBotClient(ClientProfile profile)
        {
            m_activePlugins = new Dictionary <ProfilePluginConfiguration, IJinxBotPlugin>();

            if (profile.SimulateClient)
            {
                m_client = new SimulatedBattleNetClient(profile);
            }
            else
            {
                m_client = new BattleNetClient(profile);
            }

            m_profile          = profile;
            m_resourceProvider = ProfileResourceProvider.RegisterProvider(m_client);
            m_cmdTranslator    = new CommandTranslator(this);

            bool hasSetCommandQueue = false;

            if (m_database == null)
            {
                m_database = new JinxBotDefaultDatabase();
            }

            // finally, initialize ui
            m_window = new ProfileDocument(this);

            // initialize plugins
            m_commandHandlers = new List <ICommandHandler>();
            foreach (ProfilePluginConfiguration pluginConfig in profile.PluginSettings)
            {
                hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, pluginConfig);
            }

            ProfilePluginConfiguration jsConfig = new ProfilePluginConfiguration
            {
                Assembly = "JinxBot.Plugins.Script.dll",
                Name     = "JavaScript Plugin",
                Settings = new ProfilePluginSettingConfiguration[0],
                Type     = "JinxBot.Plugins.Script.JinxBotJavaScriptPlugin"
            };

            hasSetCommandQueue = ProcessPlugin(hasSetCommandQueue, jsConfig);

            if (!hasSetCommandQueue)
            {
                m_client.CommandQueue = new TimedMessageQueue();
            }
        }
Пример #4
0
        internal ChannelListBoxItemRenderer()
        {
            ProfileResourceProvider prp = ProfileResourceProvider.GetForClient(null);

            if (!object.ReferenceEquals(prp, null))
            {
                m_provider = prp.Icons;
            }

            m_pingImg = new Bitmap(28, 14);
            Rectangle bounds = new Rectangle(0, 0, 28, 14);

            using (Graphics g = Graphics.FromImage(m_pingImg))
                using (LinearGradientBrush b = new LinearGradientBrush(bounds, Color.Black, Color.Black, 0, false))
                {
                    ColorBlend cb = new ColorBlend();
                    cb.Colors             = new Color[] { Color.LimeGreen, Color.Lime, Color.Yellow, Color.Orange, Color.OrangeRed, Color.Maroon };
                    cb.Positions          = new float[] { 0f, 0.1f, 0.4f, 0.6f, 0.9f, 1f };
                    b.InterpolationColors = cb;

                    g.FillRectangle(b, bounds);
                }
        }