public ListViewItem ToListViewItem() { //TODO: What to do with multiple usage var usage = ""; var usagePage = (UsagePage)UsagePage; switch (usagePage) { case Hid.UsagePage.Consumer: usage = ((ConsumerControl)Usages[0]).ToString(); break; case Hid.UsagePage.WindowsMediaCenterRemoteControl: usage = ((WindowsMediaCenterRemoteControl)Usages[0]).ToString(); break; } var item = new ListViewItem(new[] { usage, UsagePage.ToString("X2"), UsageCollection.ToString("X2"), RepeatCount.ToString(), Time.ToString("HH:mm:ss:fff") }); return(item); }
public override string ToString() { return(string.Format("{0}<repeat{1},key{2}>:{3}", Type.ToString(), RepeatCount.ToString(), KeyNumber.ToString(), IterToString(Cards))); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Converts the excellon line into a GCode line and returns it /// </summary> /// <param name="stateMachine">the state machine with the configuration</param> /// <param name="gcLineList">a list of the equivalent gcode line object. This can be /// empty if there is no direct conversion</param> /// <returns>z success, nz fail</returns> public override int GetGCodeCmd(ExcellonFileStateMachine stateMachine, out List <GCodeCmd> gcLineList) { gcLineList = null; GCodeCmd_ZMove zLine = null; GCodeCmd_RapidMove rmLine = null; gcLineList = new List <GCodeCmd>(); int workingXCoord; int workingYCoord; int workingXOffset; int workingYOffset; if (RepeatCount < 0) { LogMessage("GetGCodeCmd (R) invalid repeat count of " + RepeatCount.ToString() + " on line " + LineNumber.ToString()); return(101); } // setup our offsets now workingXOffset = GetOffsetInPlotCoords_X(stateMachine); workingYOffset = GetOffsetInPlotCoords_Y(stateMachine); // now put out our loop for (int i = 0; i < RepeatCount; i++) { workingXCoord = stateMachine.LastPlotXCoord; workingYCoord = stateMachine.LastPlotYCoord; // calculate the new coordinate now workingXCoord += workingXOffset; workingYCoord += workingYOffset; // G00 rapid move tool head to the xOffset, yCoord rmLine = new GCodeCmd_RapidMove(workingXCoord, workingYCoord); gcLineList.Add(rmLine); stateMachine.LastXCoord = workingXCoord; stateMachine.LastYCoord = workingYCoord; // set the drill width float workingDrillWidth = stateMachine.LastDrillWidth * stateMachine.IsoPlotPointsPerAppUnit; // G00 - put the bit into the work piece zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForCut); zLine.SetGCodePlotDrillValues(workingXCoord, workingYCoord, workingDrillWidth); gcLineList.Add(zLine); // G00 - pull the bit out of the work piece zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForClear); zLine.SetGCodePlotDrillValues(workingXCoord, workingYCoord, workingDrillWidth); gcLineList.Add(zLine); } return(0); }
public void WriteToXml(System.Xml.XmlWriter writer) { writer.WriteStartElement("Parallel"); writer.WriteAttributeString("fixedDelay", FixedStartDelay.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteAttributeString("maxDelay", MaximumRandomStartDelay.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteAttributeString("repeatCount", RepeatCount.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteAttributeString("fixedIntermediateDelay", FixedIntermediateDelay.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteAttributeString("maxIntermediateDelay", MaximumRandomIntermediateDelay.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); DoWriteToXml(writer); writer.WriteEndElement(); }
/// <summary> /// Create a list view item describing this HidEvent /// </summary> /// <returns></returns> public ListViewItem ToListViewItem() { string usageText = ""; string inputReport = null; foreach (ushort usage in Usages) { if (usageText != "") { //Add a separator usageText += ", "; } //Try to get a name for that usage string name = ""; if (Enum.IsDefined(typeof(Hid.UsagePage), UsagePage)) { UsagePage usagePage = (UsagePage)UsagePage; try { name = Enum.GetName(Utils.UsageType(usagePage), usage); } catch { } } if (name == null || name.Equals("") || Device.IsGamePad) //Gamepad buttons do not belong to Usage enumeration, they are just ordinal { name = usage.ToString("X2"); } usageText += name; } // Get input report for generic HID events if (IsGeneric) { inputReport = InputReportString(); } //If we are a gamepad display axis and dpad values if (Device != null && Device.IsGamePad) { //uint dpadUsageValue = GetUsageValue((ushort)Hid.UsagePage.GenericDesktopControls, (ushort)Hid.Usage.GenericDesktop.HatSwitch); //usageText = dpadUsageValue.ToString("X") + " (dpad), " + usageText; if (usageText != "") { //Add a separator usageText += " (Buttons)"; } if (usageText != "") { //Add a separator usageText += ", "; } usageText += GetDirectionPadState().ToString(); //For each axis foreach (KeyValuePair <HIDP_VALUE_CAPS, uint> entry in UsageValues) { if (entry.Key.IsRange) { continue; } //Get our usage type Type usageType = Utils.UsageType((UsagePage)entry.Key.UsagePage); if (usageType == null) { //Unknown usage type //TODO: check why this is happening on Logitech rumble gamepad 2. //Probably some of our axis are hiding in there. continue; } //Get the name of our axis string name = Enum.GetName(usageType, entry.Key.NotRange.Usage); if (usageText != "") { //Add a separator usageText += ", "; } usageText += entry.Value.ToString("X") + " (" + name + ")"; } } //Handle keyboard events else if (IsKeyboard) { //Get the virtual key System.Windows.Forms.Keys vKey = (Keys)RawInput.keyboard.VKey; usageText = vKey.ToString() + " -"; //Get the key flag if (IsButtonUp) { usageText += " UP"; } else if (IsButtonDown) { usageText += " DOWN"; } if (RawInput.keyboard.Flags.HasFlag(RawInputKeyFlags.RI_KEY_E0)) { usageText += " E0"; } if (RawInput.keyboard.Flags.HasFlag(RawInputKeyFlags.RI_KEY_E1)) { usageText += " E1"; } if (HasModifierShift) { usageText += " SHIFT"; } if (HasModifierControl) { usageText += " CTRL"; } if (HasModifierAlt) { usageText += " ALT"; } if (HasModifierWindows) { usageText += " WIN"; } //Put our scan code into our input report field inputReport = "0x" + RawInput.keyboard.MakeCode.ToString("X4"); } //Now create our list item ListViewItem item = new ListViewItem(new[] { usageText, inputReport, UsagePageNameAndValue(), UsageCollectionNameAndValue(), RepeatCount.ToString(), Time.ToString("HH:mm:ss:fff"), IsBackground.ToString() }); return(item); }
public UIViewController GetViewController() { var network = new BooleanElement("Enable", EnableNetwork); var host = new EntryElement("Host Name", "name", HostName); host.KeyboardType = UIKeyboardType.ASCIICapable; var port = new EntryElement("Port", "name", HostPort.ToString()); port.KeyboardType = UIKeyboardType.NumberPad; var sort = new BooleanElement("Sort Names", SortNames); var repeat = new BooleanElement("Repeat", Repeat); var repeatCount = new EntryElement("Repeat Count", "repeat", RepeatCount.ToString()); var autoStart = new BooleanElement("Auto Start", AutoStart); var autoExit = new BooleanElement("Auto Exit", TerminateAfterExecution); var root = new RootElement("Options") { new Section("Remote Server") { network, host, port }, new Section("Display") { sort }, new Section("Repeat") { repeat, repeatCount }, new Section("Misc") { autoStart, autoExit } }; var dv = new DialogViewController(root, true) { Autorotate = true }; dv.ViewDisappearing += delegate { EnableNetwork = network.Value; HostName = host.Value; ushort p; if (UInt16.TryParse(port.Value, out p)) { HostPort = p; } else { HostPort = -1; } SortNames = sort.Value; int r; if (Int32.TryParse(repeatCount.Value, out r)) { RepeatCount = r; } else { RepeatCount = 0; } Repeat = repeat.Value; AutoStart = autoStart.Value; TerminateAfterExecution = autoExit.Value; var defaults = NSUserDefaults.StandardUserDefaults; defaults.SetBool(EnableNetwork, "network.enabled"); defaults.SetString(HostName ?? String.Empty, "network.host.name"); defaults.SetInt(HostPort, "network.host.port"); defaults.SetBool(SortNames, "display.sort"); defaults.SetBool(Repeat, "repeat.enabled"); defaults.SetInt(RepeatCount, "repeat.count"); defaults.SetBool(AutoStart, "misc.autostart"); defaults.SetBool(TerminateAfterExecution, "misc.autoexit"); }; return(dv); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Performs the action the plot requires based on the current context /// </summary> /// <param name="graphicsObj">a graphics object on which to plot</param> /// <param name="stateMachine">the excellon plot state machine</param> /// <param name="errorString">the error string we return on fail</param> /// <param name="errorValue">the error value we return on fail, z success, nz fail </param> /// <returns>an enum value indicating what next action to take</returns> public override PlotActionEnum PerformPlotExcellonAction(Graphics graphicsObj, ExcellonFileStateMachine stateMachine, ref int errorValue, ref string errorString) { int workingXCoord; int workingYCoord; int workingXOffset; int workingYOffset; if (RepeatCount < 0) { LogMessage("PerformPlotExcellonAction (R) invalid repeat count of " + RepeatCount.ToString() + " on line " + LineNumber.ToString()); errorValue = 101; errorString = "PerformPlotExcellonAction(R) invalid repeat count of " + RepeatCount.ToString() + " on line " + LineNumber.ToString(); return(PlotActionEnum.PlotAction_FailWithError); } // setup our offsets now workingXOffset = GetOffsetInPlotCoords_X(stateMachine); workingYOffset = GetOffsetInPlotCoords_Y(stateMachine); // set the drill width float workingDrillWidth = stateMachine.LastDrillWidth * stateMachine.IsoPlotPointsPerAppUnit; // remember this LastDrillWidth = stateMachine.LastDrillWidth; // now put out our loop for (int i = 0; i < RepeatCount; i++) { workingXCoord = stateMachine.LastPlotXCoord; workingYCoord = stateMachine.LastPlotYCoord; // calculate the new coordinate now workingXCoord += workingXOffset; workingYCoord += workingYOffset; stateMachine.LastPlotXCoord = workingXCoord; stateMachine.LastPlotYCoord = workingYCoord; stateMachine.LastXCoord = (float)(workingXCoord / stateMachine.IsoPlotPointsPerAppUnit); stateMachine.LastYCoord = (float)(workingYCoord / stateMachine.IsoPlotPointsPerAppUnit); MiscGraphicsUtils.FillEllipseCenteredOnPoint(graphicsObj, stateMachine.ExcellonHoleBrush, workingXCoord, workingYCoord, workingDrillWidth, workingDrillWidth); } errorValue = 0; errorString = "Successful End"; return(PlotActionEnum.PlotAction_Continue); }
protected override void Update(GameTime gameTime) { Update_Frame(); Debug.Add(string.Format("CurrentFrameIntervalIndex: {0}/{1}", CurrentFrameIntervalIndex, (FrameIntervals.Length - 1))); Debug.Add(string.Format("IsRepeating: {0} ({1}/{2})", (isRepeating ? "Yes" : "No"), CurrentRepeatCount, (RepeatCount == REPEAT_FOREVER ? "~" : RepeatCount.ToString()))); }
void IXmlSerializable.WriteXml(XmlWriter writer) { if (!string.IsNullOrEmpty(GatherUrl)) { writer.WriteAttributeString("gatherUrl", GatherUrl); } if (!string.IsNullOrEmpty(GatherMethod)) { writer.WriteAttributeString("gatherMethod", GatherMethod); } if (!string.IsNullOrEmpty(TerminatingDigits)) { writer.WriteAttributeString("terminatingDigits", TerminatingDigits); } if (!string.IsNullOrEmpty(Tag)) { writer.WriteAttributeString("tag", Tag); } if (MaxDigits.HasValue) { writer.WriteAttributeString("maxDigits", MaxDigits.ToString()); } writer.WriteAttributeString("interDigitTimeout", InterDigitTimeout.ToString()); if (!string.IsNullOrEmpty(Username)) { writer.WriteAttributeString("username", Username); } if (!string.IsNullOrEmpty(Password)) { writer.WriteAttributeString("password", Password); } if (!string.IsNullOrEmpty(FallbackUsername)) { writer.WriteAttributeString("fallbackUsername", FallbackUsername); } if (!string.IsNullOrEmpty(FallbackPassword)) { writer.WriteAttributeString("fallbackPassword", FallbackPassword); } if (!string.IsNullOrEmpty(GatherFallbackUrl)) { writer.WriteAttributeString("gatherFallbackUrl", GatherFallbackUrl); } if (!string.IsNullOrEmpty(GatherFallbackMethod)) { writer.WriteAttributeString("gatherFallbackMethod", GatherFallbackMethod); } writer.WriteAttributeString("firstDigitTimeout", FirstDigitTimeout.ToString()); if (RepeatCount.HasValue) { writer.WriteAttributeString("repeatCount", RepeatCount.ToString()); } if (SpeakSentence != null) { var ns = new XmlSerializerNamespaces(); ns.Add("", ""); var serializer = new XmlSerializer(SpeakSentence.GetType(), ""); serializer.Serialize(writer, SpeakSentence, ns); } if (PlayAudio != null) { var ns = new XmlSerializerNamespaces(); ns.Add("", ""); var serializer = new XmlSerializer(PlayAudio.GetType(), ""); serializer.Serialize(writer, PlayAudio, ns); } if (AudioProducers != null && AudioProducers.Count > 0) { var ns = new XmlSerializerNamespaces(); ns.Add("", ""); foreach (var verb in AudioProducers) { var serializer = new XmlSerializer(verb.GetType(), ""); serializer.Serialize(writer, verb, ns); } } }