private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { MainViewModel.Instance.DialogVM.IsDialogOpen = false; ComboBoxItem selectedItem = (sender as ComboBox).SelectedItem as ComboBoxItem; DemoType demoType = DemoType.BasicGuidance; switch (selectedItem.Content.ToString()) { case "Basic Guidance": demoType = DemoType.BasicGuidance; break; case "Remote Support": demoType = DemoType.RemoteSupport; break; case "Personal Shopper": demoType = DemoType.Personal_Shopper; break; case "Concierge": demoType = DemoType.Concierge; break; case "Collaboration": demoType = DemoType.Collaboration; MainViewModel.Instance.CollaborationVM.IsCalenderVisible = false; break; } MainViewModel.Instance.DemoState = demoType; }
public DemoBase( string description, string title, DemoType type ) { ArrayList types = new ArrayList(); types.Add( type ); Init( description, title, types ); }
public DemoSelector() { this.InitializeComponent(); Type[] types = GetDemos(); DemoType[] demoTypes = new DemoType[types.Length]; for (int index = 0; index < types.Length; ++index) { demoTypes[index] = new DemoType(types[index]); } Array.Sort <DemoType>(demoTypes, demoTypeComparer); Dictionary <string, ListViewGroup> groups = new Dictionary <string, ListViewGroup>(); lvDemos.Clear(); lvDemos.Columns.Add("Demo Names", lvDemos.Width - 24, HorizontalAlignment.Left); for (int index = 0; index < types.Length; ++index) { DemoType demoType = demoTypes[index]; PhysicsDemoAttribute att = demoType.DemoAttribute; ListViewGroup group; if (!groups.TryGetValue(att.Group, out group)) { group = new ListViewGroup(att.Group, HorizontalAlignment.Left); groups.Add(att.Group, group); lvDemos.Groups.Add(group); } ListViewItem item = new ListViewItem(att.Name, group); item.Tag = demoType; lvDemos.Items.Add(item); } }
public async Task Run(string demoType) { DemoType t = DemoType.None; int tInt = 0; if (int.TryParse(demoType, out tInt)) { t = (DemoType)tInt; } else { t = DemoType.None; //Console.WriteLine($"args[0]::{demoType}::"); foreach (var name in Enum.GetNames(typeof(DemoType))) { if (name.Equals(demoType, StringComparison.OrdinalIgnoreCase)) { if (!Enum.TryParse <DemoType>(name, false, out t)) { //Console.WriteLine($"Could not parse {demoType} to DemoType enum."); t = DemoType.None; } break; } } //Console.WriteLine($"Converted DemoType::{t}::"); } await Run(t); }
// constructors public Demographic(DemoType myType, int NumPeopleIn = 0) { MyDemoType = myType; NumPeople = NumPeopleIn; MyBaseTargetPop = (BaseTargetPop)Enum.Parse(typeof(BaseTargetPop), MyDemoType.ToString("g")); goodConsumeWeights = new Dictionary <GoodType, float>(); foreach (KeyValuePair <GoodType, float[]> goodPair in PeopleConsumptionWeights) { goodConsumeWeights.Add(goodPair.Key, goodPair.Value[(int)MyDemoType]); } goodProduceWeights = new Dictionary <GoodType, float>(); foreach (KeyValuePair <GoodType, float[]> goodPair in PeopleProductionWeights) { goodProduceWeights.Add(goodPair.Key, goodPair.Value[(int)MyDemoType]); } lastTickConsumed = new Dictionary <GoodType, float>(); lastTickProduced = new Dictionary <GoodType, float>(); Happiness = 100; Satisfaction = 100; Health = 100; Security = 100; Oppression = 0; TargetPop = 100; }
public static void Main(string[] args) { OscBundle bundle = CreateTestBundle(); DemoType demoType = GetDemoType(); ITransmitter transmitter; switch (demoType) { case DemoType.Udp: transmitter = new UdpTransmitter(); break; case DemoType.Tcp: transmitter = new TcpTransmitter(); break; case DemoType.Multicast: transmitter = new MulticastTransmitter(); break; default: throw new Exception("Unsupported transmitter type."); } transmitter.Start(bundle); // Stop the transmitter, and exit, when a key is pressed. Console.ReadKey(); transmitter.Stop(); }
/// <summary> /// Builds a top level node in the tree for a DemoType. /// </summary> /// <param name="type">The type of demo.</param> private void buildPrimaryNode(DemoType type) { TreeNode currNode = new TreeNode(TypeToName(type)); typeToNodeTable[type] = currNode; this.demoTree.Nodes.Add(currNode); }
public DemoBase(string description, string title, DemoType type) { ArrayList types = new ArrayList(); types.Add(type); Init(description, title, types); }
private void SwitchDemo() { if (Input.GetKeyDown(KeyCode.UpArrow)) { _demos[_currDemo].Disable(); _currDemo = _currDemo == DemoType.Ball ? DemoType.Planets : DemoType.Ball; _demos[_currDemo].Enable(); } }
public StockLineDrawBase(string description, string title, DemoType type, DemoType type2) { ArrayList types = new ArrayList(); types.Add(type); types.Add(type2); Init(description, title, types); }
public ControlModel(string title, Type content, DemoType type = DemoType.Demo, string xaml = "", string code = "", string tags = "") { Title = title; TitlePinyin = StringExtend.GetPinyin(title); Content = content; Type = type; Tags = tags; XAML = xaml; Code = code; }
public async Task Run(DemoType demoType) { Stopwatch watch = new Stopwatch(); Console.WriteLine($"Demo.Run starts: { DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"); watch.Start(); try { var uri = "http://bbon.me"; using (HttpClient client = GetHttpClient(demoType)) { client.Timeout = TimeSpan.FromSeconds(3); try { var requestMessage = new HttpRequestMessage(HttpMethod.Get, uri); var responseMessage = await client.SendAsync(requestMessage); if (responseMessage.IsSuccessStatusCode) { Console.WriteLine("Request succeed."); } else { Console.WriteLine("Request failed."); } } catch (AggregateException ex) { foreach (var e in ex.InnerExceptions) { Console.WriteLine($"Demo.Run Exception: {e.Message}"); } } catch (Exception ex) { Console.WriteLine($"Demo.Run: {ex.GetType().GetTypeInfo().FullName} {ex.Message}"); } } } catch (Exception ex) { Console.WriteLine($"Demo.Run: {ex.Message}"); } finally { watch.Stop(); Console.WriteLine($"Demo.Run ends: { DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}"); Console.WriteLine($"Demo.Run elapsed: { watch.Elapsed.TotalSeconds}"); } }
private List <PresentationItemViewModel> LoadPresentationItem(DemoType demoType) { var allPresentations = _presentationsRepository.GetAllPresentations(); if (allPresentations.Any()) { return(allPresentations.Where(item => item.DemoType == demoType).Select(item => new PresentationItemViewModel { Presentation = item }).ToList()); } return(new List <PresentationItemViewModel>()); }
public void ToString_IsOverriden() { var demoValue = new DemoType() { Id = 1, Text = "Some text", Password = "******", Time = DateTime.Now.Date.Add(TimeSpan.Parse("12:34:56")) }; Assert.Equal("Id: 1, Text: \"Some text\", Time: \"12:34\"", demoValue.ToString()); }
private void OnOpenDemoType(DemoType type) { if (_homeModel.DemoModels == null || _homeModel.DemoModels.Length == 0) { return; } IsOpened = true; ViewName = ResourcesMap.DemoTypeNameDic[type]; DemoList = _homeModel.DemoModels.Where(d => d.Type == type).Select(d => new DemoViewModel(d)); RaisePropertyChanged(nameof(DemoList)); }
private void OpenSelectFileDialog(DemoType demoType, string fileFilter, Action <string> callback) { var selectedFileName = OpenFileDialogHelper.OpenFileDialogWindow(fileFilter); if (string.IsNullOrEmpty(selectedFileName)) { return; } _presentationsRepository.AddPersentation(new PresentationInfo { FileFullPath = selectedFileName, CreateTime = DateTime.Now, DemoType = demoType }); callback?.Invoke(selectedFileName); }
void BuildPrimaryTree() { //foreach (string name in Enum.GetNames(typeof(DemoType))) foreach (string name in EnumHelper.GetNames <DemoType>()) { DemoType type = (DemoType)EnumHelper.Parse(typeof(DemoType), name); Alt.GUI.Temporary.Gwen.Control.TreeNode node = m_ExamplesTreeView.AddNode(TypeToName(type)); node.NormalTextColor = GroupColor; node.HoverTextColor = HoverColor; node.IsSelectable = false; typeToNodeTable[type] = node; } }
private void CreateOnboardingStory() { // This could be a deserialized object _demoStoryLine = new XambStoryline(); _customType = new DemoType { Count = 0, Description = "This is the custom type. change this text using text field" }; _demoStoryLine.AddStoryFrameAt(0, new XambStoryFrame { Actor = "demo", Content = "Click this button to start Demo", TransitionDelay = TimeSpan.FromSeconds(2) }); _demoStoryLine.AddStoryFrameAt(1, new XambStoryFrame { Actor = "entry", Content = "This is an entry field to enter some demo text", TransitionDelay = TimeSpan.FromSeconds(4) }); _demoStoryLine.AddStoryFrameAt(2, new XambStoryFrame { Actor = "end", Content = _customType, TransitionDelay = TimeSpan.FromSeconds(2) }); }
void SelectionChanged() { DemoType type; if (lvDemos.SelectedItems.Count == 0 || (type = lvDemos.SelectedItems[0].Tag as DemoType) == null) { //if nothing is selected; this.rtbDescription.Text = String.Empty; selected = null; bStart.Enabled = false; } else { this.rtbDescription.Text = type.DemoAttribute.Description; selected = type; bStart.Enabled = true; } }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = GetDemoType(); //IPAddress ipAddress = IPAddress.Loopback; //IPAddress ipAddress = IPAddress.Parse("192.168.1.118"); IPAddress ipAddress = IPAddress.Parse(Properties.Settings.Default.IPAddress); switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, ipAddress, Properties.Settings.Default.Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, ipAddress, Properties.Settings.Default.Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Properties.Settings.Default.Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.RegisterMethod(PingMethod); // used by TouchOSC oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Osc Receiver: " + demoType.ToString()); Console.WriteLine("with IP Address={0} on Port={1}", ipAddress, Properties.Settings.Default.Port); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); }
public static void Main(string[] args) { Dictionary <DemoType, Type> transmitters = new Dictionary <DemoType, Type>() { { DemoType.Udp, typeof(UdpTransmitter) }, { DemoType.Tcp, typeof(TcpTransmitter) }, { DemoType.Multicast, typeof(MulticastTransmitter) } }; DemoType demoType = GetDemoType(); ITransmitter transmitter = Activator.CreateInstance(transmitters[demoType]) as ITransmitter; OscBundle bundle = CreateTestBundle(); transmitter.Start(bundle); // Stop the transmitter, and exit, when a key is pressed. Console.ReadKey(); transmitter.Stop(); }
private HttpClient GetHttpClient(DemoType demoDescribe) { HttpClient client = null; HttpClientHandler clientHandler = new DelayHttpClientHandler(5); DelegatingHandler handler = null; switch (demoDescribe) { case DemoType.Timeout: handler = new DefaultTestHandler(clientHandler); break; case DemoType.Retry: handler = new RetryHandler(clientHandler, 3); break; default: throw new NotSupportedException(); } client = new HttpClient(handler); return(client); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = GetDemoType(); switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; oscServer.Start(); Console.WriteLine("Osc Receiver: " + demoType.ToString()); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); }
string TypeToName(DemoType type) { switch (type) { case DemoType.Pie: return("Pie"); case DemoType.General: default: return("General"); case DemoType.Bar: return("Bar"); case DemoType.Line: return("Line"); case DemoType.Special: return("Special Features"); case DemoType.Tutorial: return("Tutorial"); } }
public static void Main(string[] args) { Dictionary <DemoType, Type> transmitters = new Dictionary <DemoType, Type>() { { DemoType.Udp, typeof(UdpTransmitter) }, { DemoType.Tcp, typeof(TcpTransmitter) }, { DemoType.Multicast, typeof(MulticastTransmitter) } }; DemoType demoType = GetDemoType(); ITransmitter transmitter = Activator.CreateInstance(transmitters[demoType]) as ITransmitter; //OscBundle bundle = CreateTestBundle(); //transmitter.Start(bundle); IPEndPoint sourceEndPoint = new IPEndPoint(Program.ipAddress, Properties.Settings.Default.Port); OscMessage labelMessage = new OscMessage(sourceEndPoint, LabelMethod, "Hello"); transmitter.Start(labelMessage); // Stop the transmitter, and exit, when a key is pressed. Console.ReadKey(); transmitter.Stop(); }
private void button4_Click(object sender, EventArgs e) { SelectedDemo = DemoType.DJ; Close(); }
/// <summary> /// Generates a string name for a demo type. /// </summary> /// /// <param name="type">A DemoType</param> /// <returns>A name for the DemoType</returns> private string TypeToName( DemoType type ) { switch ( type ) { case DemoType.Pie: return "Pie"; case DemoType.General: default: return "General"; case DemoType.Bar: return "Bar"; case DemoType.Line: return "Line"; case DemoType.Special: return "Special Features"; case DemoType.Tutorial: return "Tutorial"; } }
/// <summary> /// Builds a top level node in the tree for a DemoType. /// </summary> /// <param name="type">The type of demo.</param> private void buildPrimaryNode( DemoType type ) { TreeNode currNode = new TreeNode( TypeToName( type ) ); typeToNodeTable[type] = currNode; this.demoTree.Nodes.Add( currNode ); }
public static void Main(string[] args) { OscServer oscServer; DemoType demoType = /*GetDemoType();*/ DemoType.Udp; switch (demoType) { case DemoType.Udp: oscServer = new OscServer(TransportType.Udp, IPAddress.Any, Port); break; case DemoType.Tcp: oscServer = new OscServer(TransportType.Tcp, IPAddress.Loopback, Port); break; case DemoType.Multicast: oscServer = new OscServer(IPAddress.Parse("224.25.26.27"), Port); break; default: throw new Exception("Unsupported receiver type."); } oscServer.FilterRegisteredMethods = false; oscServer.RegisterMethod(AliveMethod); oscServer.RegisterMethod(TestMethod); oscServer.RegisterMethod(MouseMethod); oscServer.BundleReceived += new EventHandler <OscBundleReceivedEventArgs>(oscServer_BundleReceived); oscServer.MessageReceived += new EventHandler <OscMessageReceivedEventArgs>(oscServer_MessageReceived); oscServer.ReceiveErrored += new EventHandler <ExceptionEventArgs>(oscServer_ReceiveErrored); oscServer.ConsumeParsingExceptions = false; handsets = new VirtualHandset[HANDSET_COUNT]; motorMin = new int[HANDSET_COUNT]; motorMax = new int[HANDSET_COUNT]; String[] comPorts = { "COM9", "COM4", "COM5", "COM6", "COM7", "COM8" }; for (int i = 0; i < HANDSET_COUNT; i++) { VirtualHandset handset = new VirtualHandset(); int result = handset.Connect(comPorts[i]); if (result != 0) { // -20 = virtual com port device not found (USB unplugged) // -30 = com port found but couldn't connect to hardware Console.WriteLine("error " + result + " opening " + comPorts[i]); continue; } VirtualHandset.ControlUnitSettings settings = new VirtualHandset.ControlUnitSettings(); result = handset.GetAllSettings(ref settings); if (result == 0) { Console.Write(comPorts[i] + ": OEM Information: " + (char)settings.OEMInformation[0] + " " + (char)settings.OEMInformation[1] + " " + (char)settings.OEMInformation[2] + " " + (char)settings.OEMInformation[3] + " (" + (settings.OEMInformation.Length - 4) + " more) "); } else { Console.WriteLine("error " + result + " getting control unit settings for " + comPorts[i]); continue; } int handsetIndex = 0; if ((char)settings.OEMInformation[0] == 'L') { handsetIndex = 0; } else if ((char)settings.OEMInformation[0] == 'R') { handsetIndex = 3; } else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[0] '" + (char)settings.OEMInformation[0] + "' (should be 'L' or 'R')"); continue; } if ((char)settings.OEMInformation[1] == '1') { handsetIndex += 0; } else if ((char)settings.OEMInformation[1] == '2') { handsetIndex += 1; } else if ((char)settings.OEMInformation[1] == '3') { handsetIndex += 2; } else { Console.WriteLine(comPorts[i] + ": invalid OEMInformation[1] '" + (char)settings.OEMInformation[1] + "' (should be '1', '2' or '3')"); continue; } handsets[handsetIndex] = handset; motorMin[handsetIndex] = settings.LowerLimit[0] + 1; // don't drive right to the very limit motorMax[handsetIndex] = settings.UpperLimit[0] - 1; // don't drive right to the very limit Console.WriteLine(" lower " + motorMin[handsetIndex] + " upper " + motorMax[handsetIndex]); Console.WriteLine(" -> assigning handset to index " + handsetIndex); // add event-handler for synchronizing the PC after driving //handsets[handsetIndex].OnSynchronizeAfterDriving += new VirtualHandset.OnSynchronizeAfterDrivingDelegate(onSynchronizeAfterDriving); } for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) { Console.WriteLine("handset " + i + " missing, filling in with dummy"); handsets[i] = new VirtualHandset(); } // moveMotorToPosition(i, INITIAL_POS); } oscServer.Start(); // figure out my ip address IPHostEntry host; string localIP = "?"; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { localIP = ip.ToString(); } } Console.WriteLine("Osc Receiver: " + demoType.ToString() + " listening on address " + localIP + " port " + Port); Console.WriteLine("Press any key to exit."); Console.ReadKey(); oscServer.Stop(); for (int i = 0; i < HANDSET_COUNT; i++) { if (handsets[i] == null) { continue; } handsets[i].Disconnect(); handsets[i].Dispose(); } }