Ejemplo n.º 1
0
        void AddNewCluster(object sender, EventArgs e)
        {
            ClusterConfiguration conf = this.EditCluster(null);

            if (conf == null)
            {
                return;
            }

            // you cannot have two cache clusters at the same time
            if (conf is CacheClusterConfiguration)
            {
                foreach (var name in ClusterConfiguration.GetKnownClusterNames())
                {
                    var config = ClusterConfiguration.KnownClusterByName(name);
                    if (config is CacheClusterConfiguration)
                    {
                        DialogResult res = MessageBox.Show("You cannot have two cache clusters at once: " + conf.Name + " and " + config.Name + "\nPress OK to use " + conf.Name + " instead of " + config.Name);
                        if (res == System.Windows.Forms.DialogResult.OK)
                        {
                            ClusterConfiguration.RemoveKnownCluster(config.Name);
                            (config as CacheClusterConfiguration).StopCaching();
                            (conf as CacheClusterConfiguration).StartCaching();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            ClusterConfiguration.AddKnownCluster(conf);
            this.AddClusterNameToMenu(conf.Name);
        }
Ejemplo n.º 2
0
        private void ConfigurationChanged(ClusterConfiguration conf)
        {
            if (conf == null)
            {
                return;
            }

            // you cannot have two cache clusters at the same time
            if (conf is CacheClusterConfiguration)
            {
                foreach (var name in ClusterConfiguration.GetKnownClusterNames())
                {
                    var config = ClusterConfiguration.KnownClusterByName(name);
                    if (config is CacheClusterConfiguration)
                    {
                        DialogResult res = MessageBox.Show("You cannot have two cache clusters at once: " + conf.Name + " and " + config.Name + "\nPress OK to use " + conf.Name + " instead of " + config.Name);
                        if (res == System.Windows.Forms.DialogResult.OK)
                        {
                            ClusterConfiguration.RemoveKnownCluster(config.Name);
                            (config as CacheClusterConfiguration).StopCaching();
                            (conf as CacheClusterConfiguration).StartCaching();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            ClusterConfiguration.AddKnownCluster(conf);
            this.AddClusterNameToMenu(conf.Name);
            this.Status("Added cluster " + conf.Name, StatusKind.OK);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Form is being loaded; restore settings.
        /// </summary>
        /// <param name="sender">Unused.</param>
        /// <param name="e">Unused.</param>
        private void ClusterBrowser_Load(object sender, EventArgs e)
        {
            this.formSettings = new ClusterBrowserSettings();
            Rectangle rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds;

            // set location only if it is inside
            if (rect.Contains(this.formSettings.Location))
            {
                this.Location = this.formSettings.Location;
            }
            bool maximized = this.formSettings.MaximizeWindow;

            if (maximized)
            {
                this.WindowState = FormWindowState.Maximized;
            }
            else
            {
                // then we care about the size
                this.Size = this.formSettings.Size;
            }
            this.autoRefreshToolStripMenuItem.Checked = this.formSettings.AutoRefresh;

            this.AddClusterNameToMenu("<add>");
            this.AddClusterNameToMenu("<scan>");

            ClusterConfiguration.ReconstructKnownCluster(this.formSettings.KnownClusters);

            int found = 0;
            IEnumerable <string> clusters = ClusterConfiguration.GetKnownClusterNames();

            foreach (string c in clusters)
            {
                this.AddClusterNameToMenu(c);
                var config = ClusterConfiguration.KnownClusterByName(c);
                if (config is CacheClusterConfiguration)
                {
                    (config as CacheClusterConfiguration).StartCaching();
                }
                found++;
            }

            if (found == 0)
            {
                // try to find them by scanning
                this.ScanClusters();
            }
        }