Пример #1
0
        internal Stepper(Cluster cluster, byte x, byte y)
        {
            if (cluster == null)
                throw new ArgumentNullException("cluster");
            if (x < 0 || x >= Cluster.Width)
                throw new ArgumentOutOfRangeException("x");
            if (y < 0 || y >= Cluster.Height)
                throw new ArgumentOutOfRangeException("y");

            this.Cluster = cluster;
            this.X = x;
            this.Y = y;
        }
        public ClusterControlDetailed(MainForm form, Cluster cluster)
        {
            if (cluster == null)
                throw new ArgumentNullException(nameof(cluster));

            this.Form = form;

            InitializeComponent();

            const int padding = 2; // Abstand zwischen zwei StepperControls
            int height = 0;

            steppers = new StepperControl[Cluster.Width * Cluster.Height];

            // im folgenden wird über X und Y Koordinaten eine Tabelle erzeugt
            for (int y = 0; y < Cluster.Height; y++)
            {
                Label labelRow = new Label();
                labelRow.Text = (Cluster.Height - y).ToString();
                labelRow.AutoSize = true;
                steppersPanel.Controls.Add(labelRow);

                for (int x = 0; x < Cluster.Width; x++)
                {
                    StepperControl stepper = new StepperControl(cluster.GetStepperByPosition(x, Cluster.Height - 1 - y));
                    steppersPanel.Controls.Add(stepper);

                    steppers[y * Cluster.Width + x] = stepper;

                    Label labelColumn = new Label();
                    labelColumn.Text = (x + 1).ToString();
                    labelColumn.AutoSize = true;
                    steppersPanel.Controls.Add(labelColumn);
                    labelColumn.Location = new Point(x * (stepper.Width + padding) + labelRow.Width + stepper.Width / 2 - labelColumn.Width / 2, 0);

                    stepper.Location = new Point(x * (stepper.Width + padding) + labelRow.Width, y * (stepper.Height + padding) + labelColumn.Height);
                    stepper.Click += (sender, e) =>
                    {
                        ShowStepper((StepperControl)sender);
                    };
                    height = stepper.Height + padding;
                }

                labelRow.Location = new Point(0, y * height + height / 2 - labelRow.Height / 2);
            }

            ShowCluster(cluster);
        }
Пример #3
0
        public void ShowCluster(Cluster cluster)
        {
            if (cluster == null)
                throw new ArgumentNullException("cluster");

            if (this.Cluster == cluster)
                return;

            this.Cluster = cluster;

            Text = string.Format("Cluster {0}, {1}", cluster.X + 1, cluster.Y + 1);

            if (ClusterControl == null)
            {
                ClusterControl = new ClusterControlDetailed(Form, cluster);
                ClusterControl.Dock = DockStyle.Fill;
                Controls.Add(ClusterControl);
            }
            else
                ClusterControl.ShowCluster(Cluster);
        }
Пример #4
0
 public ushort GetHeight(Cluster cluster, TimeSpan time, int x, int y)
 {
     return function(cluster, time, x, y);
 }
        public void ShowCluster(Cluster cluster)
        {
            if (cluster == null)
                throw new ArgumentNullException(nameof(cluster));

            if (CurrentCluster == cluster)
                return;

            // UI zurücksetzen
            ActiveControl = null;
            ShowStepper(null);
            ResetCurrentCluster();

            CurrentCluster = cluster;

            // neue UI zeigen
            for (int x = 0; x < Cluster.Width; x++)
                for (int y = 0; y < Cluster.Height; y++)
                    steppers[y * Cluster.Width + x].ShowStepper(CurrentCluster.GetStepperByPosition(x, Cluster.Height - 1 - y));
            UpdateClusterBox(cluster, EventArgs.Empty);

            // Events setzen
            cluster.OnPingChange += UpdateClusterBox;
            cluster.OnInfoChange += UpdateClusterBox;

            UpdateClusterHeight();
        }