OpenHardwareMonitor.GUI.MainForm.InitializePlotForm C# (CSharp) Méthode

InitializePlotForm() private méthode

private InitializePlotForm ( ) : void
Résultat void
        private void InitializePlotForm()
        {
            plotForm = new Form();
              plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
              plotForm.ShowInTaskbar = false;
              plotForm.StartPosition = FormStartPosition.Manual;
              this.AddOwnedForm(plotForm);
              plotForm.Bounds = new Rectangle {
            X = settings.GetValue("plotForm.Location.X", -100000),
            Y = settings.GetValue("plotForm.Location.Y", 100),
            Width = settings.GetValue("plotForm.Width", 600),
            Height = settings.GetValue("plotForm.Height", 400)
              };

              showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
              plotLocation = new UserRadioGroup("plotLocation", 0,
            new[] { plotWindowMenuItem, plotBottomMenuItem, plotRightMenuItem },
            settings);

              showPlot.Changed += delegate(object sender, EventArgs e) {
            if (plotLocation.Value == 0) {
              if (showPlot.Value && this.Visible)
            plotForm.Show();
              else
            plotForm.Hide();
            } else {
              splitContainer.Panel2Collapsed = !showPlot.Value;
            }
            treeView.Invalidate();
              };
              plotLocation.Changed += delegate(object sender, EventArgs e) {
            switch (plotLocation.Value) {
              case 0:
            splitContainer.Panel2.Controls.Clear();
            splitContainer.Panel2Collapsed = true;
            plotForm.Controls.Add(plotPanel);
            if (showPlot.Value && this.Visible)
              plotForm.Show();
            break;
              case 1:
            plotForm.Controls.Clear();
            plotForm.Hide();
            splitContainer.Orientation = Orientation.Horizontal;
            splitContainer.Panel2.Controls.Add(plotPanel);
            splitContainer.Panel2Collapsed = !showPlot.Value;
            break;
              case 2:
            plotForm.Controls.Clear();
            plotForm.Hide();
            splitContainer.Orientation = Orientation.Vertical;
            splitContainer.Panel2.Controls.Add(plotPanel);
            splitContainer.Panel2Collapsed = !showPlot.Value;
            break;
            }
              };

              plotForm.FormClosing += delegate(object sender, FormClosingEventArgs e) {
            if (e.CloseReason == CloseReason.UserClosing) {
              // just switch off the plotting when the user closes the form
              if (plotLocation.Value == 0) {
            showPlot.Value = false;
              }
              e.Cancel = true;
            }
              };

              EventHandler moveOrResizePlotForm = delegate(object sender, EventArgs e) {
            if (plotForm.WindowState != FormWindowState.Minimized) {
              settings.SetValue("plotForm.Location.X", plotForm.Bounds.X);
              settings.SetValue("plotForm.Location.Y", plotForm.Bounds.Y);
              settings.SetValue("plotForm.Width", plotForm.Bounds.Width);
              settings.SetValue("plotForm.Height", plotForm.Bounds.Height);
            }
              };
              plotForm.Move += moveOrResizePlotForm;
              plotForm.Resize += moveOrResizePlotForm;

              plotForm.VisibleChanged += delegate(object sender, EventArgs e) {
            Rectangle bounds = new Rectangle(plotForm.Location, plotForm.Size);
            Screen screen = Screen.FromRectangle(bounds);
            Rectangle intersection =
              Rectangle.Intersect(screen.WorkingArea, bounds);
            if (intersection.Width < Math.Min(16, bounds.Width) ||
            intersection.Height < Math.Min(16, bounds.Height)) {
              plotForm.Location = new Point(
            screen.WorkingArea.Width / 2 - bounds.Width / 2,
            screen.WorkingArea.Height / 2 - bounds.Height / 2);
            }
              };

              this.VisibleChanged += delegate(object sender, EventArgs e) {
            if (this.Visible && showPlot.Value && plotLocation.Value == 0)
              plotForm.Show();
            else
              plotForm.Hide();
              };
        }