public static XPropertyList PropertyList(this XPropertyGrid grid) { if (_propertyListField != null) { return(_propertyListField.GetValue(grid) as XPropertyList); } else if (_propertyListProp != null) { return(_propertyListProp.GetValue(grid, null) as XPropertyList); } return(null); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RuntimeEditor)); this.txtType = new System.Windows.Forms.TextBox(); this.txtToString = new System.Windows.Forms.TextBox(); this.btnCollapseAll = new System.Windows.Forms.Button(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.btnRefresh = new System.Windows.Forms.Button(); this.windowFinder = new GSharp.UI.Controls.RuntimeProperty.WindowFinder(); this.propertyGrid = new GSharp.UI.Controls.RuntimeProperty.XPropertyGrid(); this.SuspendLayout(); // // txtType // this.txtType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txtType.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtType.Location = new System.Drawing.Point(32, 0); this.txtType.Name = "txtType"; this.txtType.ReadOnly = true; this.txtType.Size = new System.Drawing.Size(292, 20); this.txtType.TabIndex = 1; this.txtType.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.toolTip.SetToolTip(this.txtType, "Object Type"); // // txtToString // this.txtToString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txtToString.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtToString.Location = new System.Drawing.Point(32, 20); this.txtToString.Name = "txtToString"; this.txtToString.ReadOnly = true; this.txtToString.Size = new System.Drawing.Size(252, 20); this.txtToString.TabIndex = 2; this.txtToString.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.toolTip.SetToolTip(this.txtToString, "Object.ToString()"); // // btnCollapseAll // this.btnCollapseAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnCollapseAll.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnCollapseAll.Location = new System.Drawing.Point(288, 22); this.btnCollapseAll.Name = "btnCollapseAll"; this.btnCollapseAll.Size = new System.Drawing.Size(16, 16); this.btnCollapseAll.TabIndex = 3; this.btnCollapseAll.Text = "-"; this.toolTip.SetToolTip(this.btnCollapseAll, "Collapse All"); this.btnCollapseAll.Click += new System.EventHandler(this.btnCollapseAll_Click); // // btnRefresh // this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnRefresh.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnRefresh.Location = new System.Drawing.Point(306, 22); this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(16, 16); this.btnRefresh.TabIndex = 4; this.btnRefresh.Text = "*"; this.toolTip.SetToolTip(this.btnRefresh, "Refresh"); this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); // // windowFinder // this.windowFinder.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("windowFinder.BackgroundImage"))); this.windowFinder.Location = new System.Drawing.Point(0, 4); this.windowFinder.Name = "windowFinder"; // TODO: Beim Generieren des Codes für "" ist die Ausnahme "Ungültiger primitiver Typ: System.IntPtr. Verwenden Sie CodeObjectCreateExpression." aufgetreten. this.windowFinder.Size = new System.Drawing.Size(32, 32); this.windowFinder.TabIndex = 0; this.toolTip.SetToolTip(this.windowFinder, "WindowFinder - click & drag to select any .Net window from any process."); this.windowFinder.ActiveWindowChanged += new System.EventHandler(this.windowFinder_ActiveWindowChanged); this.windowFinder.ActiveWindowSelected += new System.EventHandler(this.windowFinder_ActiveWindowSelected); // // propertyGrid // this.propertyGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.propertyGrid.CommandsActiveLinkColor = System.Drawing.SystemColors.ActiveCaption; this.propertyGrid.CommandsDisabledLinkColor = System.Drawing.SystemColors.ControlDark; this.propertyGrid.CommandsLinkColor = System.Drawing.SystemColors.ActiveCaption; this.propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar; this.propertyGrid.Location = new System.Drawing.Point(1, 44); this.propertyGrid.Name = "propertyGrid"; this.propertyGrid.PropertySort = System.Windows.Forms.PropertySort.Alphabetical; this.propertyGrid.Size = new System.Drawing.Size(322, 309); this.propertyGrid.TabIndex = 0; this.propertyGrid.SelectRequest += new GSharp.UI.Controls.RuntimeProperty.XPropertyGrid.SelectedObjectRequestHandler(this.propertyGrid_SelectRequest); // // RuntimeEditor // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(324, 354); this.Controls.Add(this.btnRefresh); this.Controls.Add(this.btnCollapseAll); this.Controls.Add(this.txtToString); this.Controls.Add(this.txtType); this.Controls.Add(this.windowFinder); this.Controls.Add(this.propertyGrid); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "RuntimeEditor"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Runtime Editor"; this.ResumeLayout(false); this.PerformLayout(); }
private static void Parse(string message) { XPropertyGrid grid = CamBamUI.MainUI.ObjectProperties; GRBLMachinePlugin.Log(message, message.StartsWith("<")); if (_firstParse && message.StartsWith("Grbl")) { string[] greetz = message.Split(' '); if (greetz.Length > 1) { GrblVersion = greetz[1]; GrblIsV1 = GrblVersion.CompareTo("1.1a") >= 0; _this.VersionLabel.Text = GrblVersion; _this.VersionLabel.ForeColor = GrblIsV1 ? Color.LimeGreen : (GrblVersion.CompareTo("0.8") >= 0 ? Color.Orange : Color.Red); } _firstParse = false; WriteCOMPort("$$"); WriteCOMPort("$N"); _this.StatusTimer.Enabled = true; } if (message.StartsWith("<") && message.EndsWith(">")) { if (!GrblIsV1) { //Version < 1.1 ==> "<Idle,MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000>" char[] charmessage = message.ToCharArray(); charmessage[message.IndexOf(",MPos:")] = '|'; charmessage[message.IndexOf(",WPos:")] = '|'; message = new string(charmessage); // ==> "<Idle|MPos:0.000,0.000,0.000|WPos:0.000,0.000,0.000>" } string[] report = message.Split('<', '|', '>'); if (report.Length > 2) { // report[0] = "" // report[1] = Idle string[] states = report[1].Split(':'); GRBLMachinePlugin.Stat((GRBLMachinePlugin.MachineState)Enum.Parse(typeof(GRBLMachinePlugin.MachineState), states[0], true), states.Length > 1 ? int.Parse(states[1]) : -1); if (report.Length > 3) // report[2] = MPos:0.000,0.000,0.00 { string[] pos = report[2].Split(':', ','); PosType type = PosType.Unknown; double x = double.NaN; double y = double.NaN; double z = double.NaN; if (pos.Length > 0) { switch (pos[0].ToUpper()) { case "MPOS": type = PosType.MachineCoordinates; break; case "WPOS": type = PosType.WorkCoordinates; break; } } if (pos.Length > 1) { x = double.Parse(pos[1], EN_US); } if (pos.Length > 2) { y = double.Parse(pos[2], EN_US); } if (pos.Length > 3) { z = double.Parse(pos[3], EN_US); } GRBLMachinePlugin.Pos(type, x, y, z); if (report.Length > 4) // report[3] = WPos:0.000,0.000,0.000 { string[] speeds = report[3].Split(':', ','); switch (speeds[0].ToUpper()) { case "F": GRBLMachinePlugin.Speeds(double.Parse(speeds[1], EN_US), 0); break; case "FS": GRBLMachinePlugin.Speeds(double.Parse(speeds[1], EN_US), int.Parse(speeds[2], EN_US)); break; case "WPOS": { double wx = double.NaN; double wy = double.NaN; double wz = double.NaN; if (speeds.Length > 1) { wx = double.Parse(speeds[1], EN_US); } if (speeds.Length > 2) { wy = double.Parse(speeds[2], EN_US); } if (speeds.Length > 3) { wz = double.Parse(speeds[3], EN_US); } if (!double.IsNaN(wx) && !double.IsNaN(x)) { wx = (x - wx); } if (!double.IsNaN(wy) && !double.IsNaN(y)) { wy = (y - wy); } if (!double.IsNaN(wz) && !double.IsNaN(z)) { wz = (z - wz); } GRBLMachinePlugin.Pos(PosType.WCO, wx, wy, wz); } break; } if (report.Length > 5) { pos = report[4].Split(':', ','); switch (pos[0].ToUpper()) { case "WCO": type = PosType.Unknown; x = double.NaN; y = double.NaN; z = double.NaN; if (pos.Length > 0) { type = (PosType)Enum.Parse(typeof(PosType), pos[0], true); } if (pos.Length > 1) { x = double.Parse(pos[1], EN_US); } if (pos.Length > 2) { y = double.Parse(pos[2], EN_US); } if (pos.Length > 3) { z = double.Parse(pos[3], EN_US); } GRBLMachinePlugin.Pos(type, x, y, z); break; case "OV": break; } } } } } } else if (message.Equals("ok", StringComparison.OrdinalIgnoreCase)) { lock (_writeQueue) { if (_writeQueue.Count == 0) { _writeSemaphore.Reset(BUFMAX); } else { int n = _writeQueue.Dequeue(); for (int i = 0; i != n; i++) { _writeSemaphore.Release(); } } } GRBLMachinePlugin.Respond(GRBLMachinePlugin.Response.ok); } else if (message.StartsWith("error", StringComparison.OrdinalIgnoreCase)) { string[] error = message.Split(':'); int code = (error.Length > 1 && GrblIsV1) ? int.Parse(error[1]) : 0; if (code > 0) { GRBLMachinePlugin.Log(ErrorDict[code]); } ClearWriteQueue(); GRBLMachinePlugin.Respond(GRBLMachinePlugin.Response.error, code); } else if (message.StartsWith("alarm", StringComparison.OrdinalIgnoreCase)) { string[] alarm = message.Split(':'); int code = (alarm.Length > 1 && GrblIsV1) ? int.Parse(alarm[1]) : 0; if (code > 0) { GRBLMachinePlugin.Log(AlarmDict[code]); } ClearWriteQueue(); GRBLMachinePlugin.Respond(GRBLMachinePlugin.Response.alarm, code); GRBLMachinePlugin.Stat(GRBLMachinePlugin.MachineState.Alarm, code); } else if (message.StartsWith("$N")) { string[] dollar = message.Split('='); switch (dollar[0]) { case "$N0": GRBLMachinePlugin.Props.Startup1 = dollar[1]; break; //Startup Block 0 case "$N1": GRBLMachinePlugin.Props.Startup2 = dollar[1]; break; //Startup Block 0 } if (grid.SelectedObject == GRBLMachinePlugin.Props) { grid.Refresh(); } } else if (message.StartsWith("$")) { string[] dollar = message.Split('=', ';', '('); double val = double.Parse(dollar[1], EN_US); switch (dollar[0]) { case "$0": GRBLMachinePlugin.Props.StepPulseTime = (int)val; break; //(Step pulse time, microseconds) case "$1": GRBLMachinePlugin.Props.StepIdleDelay = (int)val; break; //(Step idle delay, milliseconds) case "$2": GRBLMachinePlugin.Props.StepPulseInvert = (InvertMask)val; break; //(Step pulse invert, mask) case "$3": GRBLMachinePlugin.Props.StepDirectionInvert = (InvertMask)val; break; //(Step direction invert, mask) case "$4": GRBLMachinePlugin.Props.InvertStepEnablePin = val != 0; break; //(Invert step enable pin, boolean) case "$5": GRBLMachinePlugin.Props.InvertLimitPins = val != 0; break; //(Invert limit pins, boolean) case "$6": GRBLMachinePlugin.Props.InvertProbePin = val != 0; break; //(Invert probe pin, boolean) case "$10": GRBLMachinePlugin.Props.StatusReportOptions = (int)val; break; //(Status report options, mask) case "$11": GRBLMachinePlugin.Props.JunctionDeviation = val; break; //(Junction deviation, millimeters) case "$12": GRBLMachinePlugin.Props.ArcTolerance = val; break; //(Arc tolerance, millimeters) case "$13": GRBLMachinePlugin.Props.ReportInInches = (InchMM)val; GRBLMachinePlugin.PropertyChange("ReportInInches", (InchMM)val); break; //(Report in inches, boolean) case "$20": GRBLMachinePlugin.Props.SoftLimitsEnable = (EnabledDisabled)val; break; //(Soft limits enable, boolean) case "$21": GRBLMachinePlugin.Props.HardLimitsEnable = (EnabledDisabled)val; break; //(Hard limits enable, boolean) case "$22": GRBLMachinePlugin.Props.HomingCycleEnable = (EnabledDisabled)val; GRBLMachinePlugin.PropertyChange("HomingCycleEnable", (EnabledDisabled)val); break; //(Homing cycle enable, boolean) case "$23": GRBLMachinePlugin.Props.HomingDirectionInvert = (InvertMask)val; break; //(Homing direction invert, mask) case "$24": GRBLMachinePlugin.Props.HomingLocateFeedRate = val; break; //(Homing locate feed rate, mm/min) case "$25": GRBLMachinePlugin.Props.HomingSearchSeekRate = val; break; //(Homing search seek rate, mm/min) case "$26": GRBLMachinePlugin.Props.HomingSwitchDebounceDelay = (int )val; break; //(Homing switch debounce delay, milliseconds) case "$27": GRBLMachinePlugin.Props.HomingSwitchPullOffDistance = val; break; //(Homing switch pull-off distance, millimeters) case "$30": GRBLMachinePlugin.Props.MaximumSpindleSpeed = (int)val; break; //(Maximum spindle speed, RPM) case "$31": GRBLMachinePlugin.Props.MinimumSpindleSpeed = (int)val; break; //(Minimum spindle speed, RPM) case "$32": GRBLMachinePlugin.Props.LaserModeEnable = (EnabledDisabled)val; GRBLMachinePlugin.PropertyChange("LaserModeEnable", (EnabledDisabled)val); break; //(Laser-mode enable, boolean) case "$100": GRBLMachinePlugin.Props.X.Resolution = val; break; //(X-axis travel resolution, step/mm) case "$101": GRBLMachinePlugin.Props.Y.Resolution = val; break; //(Y-axis travel resolution, step/mm) case "$102": GRBLMachinePlugin.Props.Z.Resolution = val; break; //(Z-axis travel resolution, step/mm) case "$110": GRBLMachinePlugin.Props.X.MaximumRate = val; break; //(X-axis maximum rate, mm/min) case "$111": GRBLMachinePlugin.Props.Y.MaximumRate = val; break; //(Y-axis maximum rate, mm/min) case "$112": GRBLMachinePlugin.Props.Z.MaximumRate = val; break; //(Z-axis maximum rate, mm/min) case "$120": GRBLMachinePlugin.Props.X.Acceleration = val; break; //(X-axis acceleration, mm/sec^2) case "$121": GRBLMachinePlugin.Props.Y.Acceleration = val; break; //(Y-axis acceleration, mm/sec^2) case "$122": GRBLMachinePlugin.Props.Z.Acceleration = val; break; //(Z-axis acceleration, mm/sec^2) case "$130": GRBLMachinePlugin.Props.X.AxisMaximumTravel = val; GRBLMachinePlugin.PropertyChange("AxisMaximumTravel", val); break; //(X-axis maximum travel, millimeters) case "$131": GRBLMachinePlugin.Props.Y.AxisMaximumTravel = val; GRBLMachinePlugin.PropertyChange("AxisMaximumTravel", val); break; //(Y-axis maximum travel, millimeters) case "$132": GRBLMachinePlugin.Props.Z.AxisMaximumTravel = val; GRBLMachinePlugin.PropertyChange("AxisMaximumTravel", val); break; //(Z-axis maximum travel, millimeters) default: break; } if (grid.SelectedObject == GRBLMachinePlugin.Props) { grid.Refresh(); } } }