Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();
            this.Hide();

            notifyIcon1.Icon = (System.Drawing.Icon)Resources.ResourceManager.GetObject(BLL.ClientManager.AppIcon);

            // ATTACH
            asociarAPWAbiertoToolStripMenuItem.DropDownItems.AddRange(
                BLL.ClientManager.Config.Cuentas.Select(p =>
                                                        new ToolStripMenuItem(p.Name ?? p.Login, BLL.ClientManager.GetIcon(p.Type), OnAttach)
            {
                Tag = p
            }
                                                        ).ToArray()
                );
            asociarAPWAbiertoToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());
            asociarAPWAbiertoToolStripMenuItem.DropDownItems.AddRange(
                BLL.ClientManager.Config.OpenAlls.Select(p =>
                                                         new ToolStripMenuItem("Attach " + p.Name, Resources.application_add.ToBitmap(), OnAttachAll)
            {
                Tag = p
            }
                                                         ).ToArray()
                );

            // OPEN
            abrirNuevoToolStripMenuItem.DropDownItems.AddRange(
                BLL.ClientManager.Config.Cuentas.Select(p =>
                                                        new ToolStripMenuItem(p.Name ?? p.Login, BLL.ClientManager.GetIcon(p.Type), OnAbrirNuevo)
            {
                Tag = p
            }
                                                        ).ToArray()
                );
            abrirNuevoToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());
            abrirNuevoToolStripMenuItem.DropDownItems.AddRange(
                BLL.ClientManager.Config.OpenAlls.Select(p =>
                                                         new ToolStripMenuItem("Open " + p.Name, Resources.application_add.ToBitmap(), OnOpenAll)
            {
                Tag = p
            }
                                                         ).ToArray()
                );

            // Party
            bPartys.DropDownItems.AddRange(
                BLL.DataManager.Partys.Select(p =>
                                              new ToolStripMenuItem(p.Name, Resources.cd_add.ToBitmap(), (sender, e) => {
                // busco el lider de party
                var client = BLL.ClientManager.Cuentas.SingleOrDefault(c => c.Config.Name == p.Lider);
                if (client == null)
                {
                    return;
                }

                var party = BLL.ClientManager.CreateParty(client);
                party.Invite(new string[] { p.Member1, p.Member2, p.Member3, p.Member4, p.Member5 }, true, true);
            })
            {
                Tag = p
            }
                                              ).ToArray()
                );

            // KEYBOARD
            Windows.API.ProcessManager.OnKeyboard(IntPtr.Zero, Keys.Shift | Keys.F12, (sender, e) =>
            {
                foreach (var cuenta in BLL.ClientManager.Cuentas)
                {
                    cuenta.Auto.StopAll();
                }
            });

            Windows.API.ProcessManager.OnKeyboard(IntPtr.Zero, Keys.Shift | Keys.F9, (sender, e) =>
            {
                foreach (var cuenta in BLL.ClientManager.Cuentas)
                {
                    cuenta.Auto.SetAutoFollow(!cuenta.Auto.IsAutoFollowRunning);
                }
            });

            // Win Modes
            RefreshWinModes();

            BLL.ClientManager.OnPartyCreated += (sender, party) => WinManager.AddParty(party);
            BLL.ClientManager.OnPartyDeleted += (sender, party) => WinManager.RemoveParty(party);
        }