public bool initForm()
        {
            if (initDataNode != null)
            {
                StartForm.RestoreWindowPosition(myForm, initDataNode);


                foreach (XmlNode node in initDataNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    default:
                        if ((node.Name.Length >= 5) && (node.Name.Substring(0, 5) == "Form_"))
                        {
                            string propname = node.Name.Substring(5);
                            string value    = node.Attributes["value"].InnerText;
                            System.Reflection.PropertyInfo info = myForm.GetType().GetProperty(propname);
                            setData(info, myForm, propname, value);
                        }
                        break;
                    }
                }
                return(true);
            }
            return(false);
        }
Example #2
0
 public GenericProperties(XmlNode initData, Form Owner)
 {
     ownerForm  = Owner;
     _Form_Text = StartForm.newWindowName();
     if (initData != null)
     {
         loadProperties(initData, Owner, this);
     }
 }
Example #3
0
 private void PropertiesForm_Load(object sender, EventArgs e)
 {
     StartForm.RestoreWindowPosition(this, initNode);
     if (constants.MonoRunning)
     {                                                 // dropdown buttons are missing on mono without this (don't ask me why)
         propertyGrid1.Width  = ClientSize.Width - 4;  //propertyGrid1.Width - 1;
         propertyGrid1.Height = ClientSize.Height - 4; //propertyGrid1.Height - 4;
         propertyGrid1.Refresh();
     }
 }
 public formManager(Form form, StartForm main, XmlNode initnode, string description, GenericProperties formsettings)
 {
     formDesc          = description;
     mainForm          = main;
     initDataNode      = initnode;
     settings          = formsettings;
     myForm            = form;
     form.FormClosing += targetFormClosing;
     form.Shown       += target_Shown;
 }
        public digitalDisplayForm(StartForm parent, XmlNode initData)
        {
            InitializeComponent();
            _display = new YDigitalDisplay(rendererCanvas, LogManager.Log);
            _display.getCaptureParameters = constants.getCaptureParametersCallback;
            _display.DisableRedraw();
            _display.valueFormater = valueFormater;
            noDataSourcepanel      = _display.addMessagePanel();
            noDataSourcepanel.text = "No data source configured\n"
                                     + " 1 - Make sure you have a Yoctopuce sensor connected.\n"
                                     + " 2 - Do a right-click on this window.\n"
                                     + " 3 - Choose \"Configure this digital display\" to bring up the properties editor.\n"
                                     + " 4 - Choose a data source\n";


            prop     = new digitalDisplayFormProperties(initData, this);
            manager  = new formManager(this, parent, initData, "digital display", prop);
            mainForm = parent;

            if (AnnotationPanelCount == 0)
            {
                foreach (var p in typeof(digitalDisplayFormProperties).GetProperties())
                {
                    string name = p.Name;
                    if (name.StartsWith("display_annotationPanels"))
                    {
                        AnnotationPanelCount++;
                    }
                }
            }
            for (int i = 0; i < AnnotationPanelCount; i++)
            {
                _display.addAnnotationPanel();
            }

            _display.setPatchAnnotationCallback(AnnotationCallback);

            initDataNode = initData;
            prop.ApplyAllProperties(this);
            if (!manager.initForm())
            {
                Rectangle s = Screen.FromControl(this).Bounds;
                this.Location = new Point((s.Width - this.Width) >> 1, (s.Height - this.Height) >> 1);
            }
            YDataRenderer.minMaxCheckDisabled = true;
            try { prop.ApplyAllProperties(_display); }
            catch (TargetInvocationException e) { LogManager.Log("DigitalDisplay initialization raised an exception (" + e.InnerException.Message + ")"); }
            YDataRenderer.minMaxCheckDisabled = false;



            manager.configureContextMenu(this, contextMenuStrip1, showConfiguration, switchConfiguration, capture);
            _display.resetRefrenceSize();
            _display.AllowPrintScreenCapture          = true;
            _display.proportionnalValueChangeCallback = manager.proportionalValuechanged;
            _display.resizeRule = Proportional.ResizeRule.RELATIVETOBOTH;
            _display.AllowRedraw();
            _display.OnDblClick += RendererCanvas_DoubleClick;
            if (constants.OSX_Running)
            {
                _display.OnRightClick += rendererCanvas_RightClick;
            }
        }
        public GraphForm(StartForm parent, XmlNode initData)
        {
            InitializeComponent();
            seriesProperties = new List <ChartSerie>();
            _cartesianChart  = new YGraph(rendererCanvas, LogManager.Log);
            _cartesianChart.getCaptureParameters = constants.getCaptureParametersCallback;
            _cartesianChart.DisableRedraw();

            noDataSourcepanel      = _cartesianChart.addMessagePanel();
            noDataSourcepanel.text = "No data source configured\n"
                                     + " 1 - Make sure you have a Yoctopuce sensor connected.\n"
                                     + " 2 - Do a right-click on this window.\n"
                                     + " 3 - Choose \"Configure this graph\" to bring up the properties editor.\n"
                                     + " 4 - Choose a data source\n";

            offLineSourcesPanel               = _cartesianChart.addMessagePanel();
            offLineSourcesPanel.bgColor       = System.Drawing.Color.FromArgb(192, 255, 192, 192);
            offLineSourcesPanel.borderColor   = System.Drawing.Color.DarkRed;
            offLineSourcesPanel.font.color    = System.Drawing.Color.DarkRed;
            offLineSourcesPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.RIGHT;
            offLineSourcesPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP;



            captureRunningPanel               = _cartesianChart.addMessagePanel();
            captureRunningPanel.bgColor       = System.Drawing.Color.FromArgb(240, 200, 255, 193);;
            captureRunningPanel.borderColor   = System.Drawing.Color.DarkGreen;
            captureRunningPanel.font.color    = System.Drawing.Color.DarkGreen;
            captureRunningPanel.panelHrzAlign = MessagePanel.HorizontalAlignPos.LEFT;
            captureRunningPanel.panelVrtAlign = MessagePanel.VerticalAlignPos.TOP;


            _cartesianChart.setPatchAnnotationCallback(AnnotationCallback);


            foreach (var p in typeof(YaxisDescription).GetProperties())
            {
                if (p.Name.StartsWith("zones"))
                {
                    ZoneCountPerYaxis++;
                }
            }

            foreach (var p in typeof(XaxisDescription).GetProperties())
            {
                if (p.Name.StartsWith("markers"))
                {
                    MarkerCountPerXaxis++;
                }
            }



            foreach (var p in typeof(GraphFormProperties).GetProperties())
            {
                string name = p.Name;
                if (name.StartsWith("Graph_series"))
                {
                    SeriesCount++;
                }
            }

            if (YAxisCount == 0)
            {
                AnnotationPanelCount = 0;
                foreach (var p in typeof(GraphFormProperties).GetProperties())
                {
                    string name = p.Name;
                    if (name.StartsWith("Graph_yAxes"))
                    {
                        YAxisCount++;
                    }
                    if (name.StartsWith("Graph_annotationPanel"))
                    {
                        AnnotationPanelCount++;
                    }
                }
            }


            for (int i = 0; i < YAxisCount; i++)
            {
                YAxis axis = _cartesianChart.addYAxis();
                for (int j = 0; j < ZoneCountPerYaxis; j++)
                {
                    axis.AddZone();
                }
            }

            markers = new List <Marker>();
            for (int i = 0; i < MarkerCountPerXaxis; i++)
            {
                Marker m = _cartesianChart.xAxis.AddMarker();
                m.xposition = TimeConverter.ToUnixTime(DateTime.UtcNow) + i * 60;
                markers.Add(m);
            }



            for (int i = 0; i < AnnotationPanelCount; i++)
            {
                _cartesianChart.addAnnotationPanel();
            }

            prop = new GraphFormProperties(initData, this);

            for (int i = 0; i < SeriesCount; i++)
            {
                seriesProperties.Add((ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null));
                _cartesianChart.addSerie();
            }
            _cartesianChart.yAxes[0].visible = true;

            offlineMessages = new String[SeriesCount];
            showOffline     = new bool[SeriesCount];

            manager      = new formManager(this, parent, initData, "graph", prop);
            mainForm     = parent;
            initDataNode = initData;
            prop.ApplyAllProperties(this);
            if (!manager.initForm())
            {
                Rectangle s = Screen.FromControl(this).Bounds;
                this.Location = new Point((s.Width - this.Width) >> 1, (s.Height - this.Height) >> 1);
            }

            YDataRenderer.minMaxCheckDisabled = true;
            try { prop.ApplyAllProperties(_cartesianChart); }
            catch (TargetInvocationException e) { LogManager.Log("Graph initialization raised an exception (" + e.InnerException.Message + ")"); }
            YDataRenderer.minMaxCheckDisabled = false;

            manager.configureContextMenu(this, contextMenuStrip1, showConfiguration, switchConfiguration, capture);
            _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged;

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie s = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                s.Init(this, i);
                if (s.DataSource_source != null)
                {
                    SourceChanged(i, s.DataSource_source);
                }
            }

            for (int i = 0; i < YAxisCount; i++)
            {
                _cartesianChart.yAxes[i].AxisChanged   = AxisParamtersChangedAutomatically;
                _cartesianChart.yAxes[i].AllowAutoShow = true;
            }
            _cartesianChart.resetRefrenceSize();
            _cartesianChart.AllowPrintScreenCapture          = true;
            _cartesianChart.proportionnalValueChangeCallback = manager.proportionalValuechanged;
            _cartesianChart.setMarkerCaptureCallbacks(MarkedCaptureStarted, MarkedCaptureStopped);
            _cartesianChart.AllowRedraw();
            deleteMarkeOption = new ToolStripMenuItem("Disable all markers", Resources.disable_marker, disableAllMarkers);
            contextMenuStrip1.Items.Insert(2, deleteMarkeOption);
            markersMenu = new ToolStripMenuItem("Place markers", Resources.add_marker);
            contextMenuStrip1.Items.Insert(2, markersMenu);
            Pen          pIcon        = new Pen(Color.DarkRed);
            SolidBrush   bIcon        = new SolidBrush(Color.LightYellow);
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            Font font1 = new Font("Arial", 9, FontStyle.Regular, GraphicsUnit.Pixel);

            for (int i = 0; i < markers.Count; i++)
            {
                int index = i;

                Bitmap   bm = new Bitmap(16, 16);
                Graphics gr = Graphics.FromImage(bm);
                gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gr.FillEllipse(bIcon, new Rectangle(1, 1, 14, 14));
                gr.DrawEllipse(pIcon, new Rectangle(1, 1, 14, 14));
                gr.DrawString((i + 1).ToString(), font1, Brushes.Black, new Rectangle(1, 1, 16, 16), stringFormat);
                markersMenu.DropDownItems.Add(new ToolStripMenuItem("Place marker #" + (i + 1).ToString(), bm, (object sender, EventArgs e) => { startMarkerCapture(index); }));
                gr.Dispose();
            }
            pIcon.Dispose();
            bIcon.Dispose();
            markersMenu.DropDownOpening += updateMakerList;
            contextMenuStrip1.Items.Insert(2, new ToolStripSeparator());
            contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Clear dataloggers", Resources.cleardatalogger, clearDataLogger));
            contextMenuStrip1.Items.Insert(2, new ToolStripMenuItem("Reset data view", Resources.resetdataview, resetDataView));
            contextMenuStrip1.Items.Insert(2, new ToolStripSeparator());
            contextMenuStrip1.Opening += ContextMenuStrip1_Opening;


            _cartesianChart.OnDblClick += rendererCanvas_DoubleClick;
            if (constants.OSX_Running)
            {
                _cartesianChart.OnRightClick += rendererCanvas_RightClick;
            }
        }