Esempio n. 1
0
        public MainViewModel(PluginManager pluginManager)
        {
            _pluginManager = pluginManager;
            Panels         = new MTObservableCollection <IrcViewModel>();

            System.Windows.DependencyObject dep = new System.Windows.DependencyObject();
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(dep))
            {
                //Executes in Design mode. Use for mockups.
                Panels.Add(new ServerViewModel());
                return;
            }

            Settings.Default.SettingsSaving    += Default_SettingsSaving;
            ServerManager.Instance.ServerAdded += Instance_ServerCreated;

            LoadSettings();

            List <ServerSettings> servers = IrcSettingsManager.Instance.GetAutoConnectServers();

            if (servers.Count == 0)
            {
            }

            foreach (ServerSettings server in servers)
            {
                if (server.Nick == null)
                {
                    server.Nick = Settings.Default.FirstNick;
                }

                Server newServer = ServerManager.Instance.Create(new ConnectionArgs(server.Nick, server.Url, server.Ssl));
                newServer.JoinSelf += Server_JoinSelf;
                newServer.Connect();
            }

            _pluginManager.LoadPlugins(Path.Combine(Environment.CurrentDirectory, "plugins"));
            //PluginManager.LoadPlugins(Settings.Default.UserPluginDirectory);
            RandomMessages.Load();
        }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            Settings.Default.SettingsSaving    += Default_SettingsSaving;
            ServerManager.Instance.ServerAdded += Instance_ServerCreated;

            windowManagerTreeView.AfterSelect += windowManagerTreeView_AfterSelect;

            serversMenuItem.Visible = false;

#if DEBUG
            serversMenuItem.Visible = true;
#endif

            LoadSettings();

            if (MessageBox.Show("Do you wish to connect?", "Debug", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //hack
            {
                foreach (ServerSettings server in IrcSettingsManager.Instance.GetAutoConnectServers())
                {
                    if (server.Nick == null)
                    {
                        server.Nick = Settings.Default.FirstNick;
                    }

                    Server newServer = ServerManager.Instance.Create(new ConnectionArgs(server.Nick, server.Url, server.Ssl));
                    newServer.Connect();
                }
            }

            if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "plugins")))
            {
                Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "plugins"));
            }

            _pluginManager.LoadPlugins(Path.Combine(Environment.CurrentDirectory, "plugins"));
            _pluginManager.LoadPlugins(Settings.Default.UserPluginDirectory);
            RandomMessages.Load();

            base.OnLoad(e);
        }