public StringEditor(PropertyLabel label, PropertyItem property) : base(property) { if (property.PropertyType == typeof(Char)) { if ((char)property.Value == '\0') property.Value = ""; } property.PropertyChanged += property_PropertyChanged; property.ValueError += property_ValueError; textBox = new TextBox { Height = 20, Foreground = Property.CanWrite ? Brushes.Black : Brushes.Gray, BorderThickness = new Thickness(0), Margin = new Thickness(0), IsReadOnly = !Property.CanWrite }; if (null != property.Value) textBox.Text = property.Value.ToString(); if (Property.CanWrite) textBox.TextChanged += Control_TextChanged; Content = textBox; GotFocus += StringValueEditor_GotFocus; }
/// <summary> /// Constructor /// </summary> /// <param name="label"></param> /// <param name="property"></param> public DateTimeEditor(PropertyLabel label, PropertyItem property) : base(property) { currentValue = property.Value; property.PropertyChanged += property_PropertyChanged; property.ValueError += property_ValueError; contentPanel = new StackPanel(); this.Content = contentPanel; datePicker = new DatePicker { Visibility = Visibility.Visible, Margin = new Thickness(0), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch }; datePicker.CalendarOpened += dtp_CalendarOpened; datePicker.CalendarClosed += dtp_CalendarClosed; datePicker.LostFocus += dtp_LostFocus; contentPanel.Children.Add(datePicker); datePicker.Focus(); this.ShowTextBox(); }
/// <summary> /// Constructor /// </summary> /// <param name="label"></param> /// <param name="property"></param> public ComboBoxEditorBase(PropertyLabel label, PropertyItem property) : base(property) { currentValue = property.Value; property.PropertyChanged += property_PropertyChanged; property.ValueError += property_ValueError; cbo = new ComboBox { Visibility = Visibility.Collapsed, Margin = new Thickness(0), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch }; cbo.DropDownOpened += cbo_DropDownOpened; cbo.LostFocus += cbo_LostFocus; this.InitializeCombo(); pnl = new StackPanel(); pnl.Children.Add(cbo); this.ShowTextBox(); this.Content = pnl; }
public BrushEditor(PropertyLabel label, PropertyItem property) : base(property) { currentValue = property.Value; property.PropertyChanged += property_PropertyChanged; property.ValueError += property_ValueError; contentPanel = new StackPanel(); this.Content = contentPanel; ShowTextBox(); }
public ButtonEditor(PropertyLabel label, PropertyItem property) : base(property) { var button = new Button { Content = "..." }; button.Click += (sender, e) => MessageBox.Show("Custom dialog comes here..."); this.Content = button; }
IEnumerator <object> ManageLabelFocus() { while (true) { if (PropertyLabel.Input.WasMousePressed()) { PropertyLabel.SetFocus(); } yield return(null); } }
IEnumerator <object> ManageFocusTask() { while (true) { if (PropertyLabel.IsFocused()) { editor.SetFocus(); } flatFillPresenter.Color = editor.IsFocused() ? Theme.Colors.SelectedBackground : Theme.Colors.GrayBackground; yield return(null); } }
private void Property_Label_MouseRightButtonDown(object sender, MouseEventArgs e) { if (editMode == false) { return; } PropertyLabel propLabel = (PropertyLabel)sender; AddControl addControl = new AddControl(); AddControlPropertyLabel cmi = new AddControlPropertyLabel(gCurrentScreen, propLabel.screenObject.Name); addControl.Content = cmi; addControl.Width = cmi.Width + 80; addControl.Height = cmi.Height + 80; addControl.Owner = this; addControl.ShowDialog(); Load_Screen(gCurrentScreen); }
IEnumerator <object> ManageLabelTask() { while (true) { var popupMenu = PropertyLabel.Input.WasMouseReleased(1); if (popupMenu || PropertyLabel.Input.WasMouseReleased(0)) { PropertyLabel.SetFocus(); } PropertyLabel.Color = PropertyLabel.IsFocused() ? Theme.Colors.KeyboardFocusBorder : Theme.Colors.BlackText; if (popupMenu) { // Wait until the label actually change its color. yield return(null); yield return(null); ShowPropertyContextMenu(); } if (PropertyLabel.IsFocused()) { if (Command.Copy.WasIssued()) { Command.Copy.Consume(); Copy(); } if (Command.Paste.WasIssued()) { Command.Paste.Consume(); Paste(); } if (resetToDefault.WasIssued()) { resetToDefault.Consume(); var defaultValue = EditorParams.DefaultValueGetter(); if (defaultValue != null) { SetProperty(defaultValue); } } } yield return(null); } }
public override void OnAwake() { base.OnAwake(); RectTransform.LayoutChanged += OnLayoutChanged; // Create parent container RectTransform.Size = new Point(170f, (Parent as UIElement).RectTransform.Height); Background.SliceType = SliceType.ThreeHorizontal; // container.Background.Source = ResourceManager.ImageFromFile(alignment == Alignment.Left ? AssetLibrary.UI.HeaderSlantedLeft : AssetLibrary.UI.HeaderSlantedRight); // Create inner container content = SceneObject.Instantiate <UIElement>(this); content.RectTransform.Size = new Point(RectTransform.Width - 60f, RectTransform.Height - 10f); // Properties that appear on either the left or right Properties = SceneObject.Instantiate <UIElement>(content); Properties.RectTransform.Size = new Point(content.RectTransform.Width, content.RectTransform.Height); PropertyName = Properties.AddComponent <Text>(); PropertyName.ApplyStyle(AssetLibrary.TextStyles.HudProperty); PropertyLabel = Properties.AddComponent <Text>(); PropertyLabel.ApplyStyle(AssetLibrary.TextStyles.HudValue); // Icon iconContainer = SceneObject.Instantiate <UIElement>(content); iconContainer.RectTransform.Size = new Point(20f, 20f); icon = iconContainer.AddComponent <Image>(); // Set default values PropertyName.Content = "LABEL"; PropertyLabel.Content = "0000"; }
public StringEditor(PropertyLabel label, PropertyItem property) : base(property) { if (property.PropertyType == typeof(Char)) { if ((char)property.Value == '\0') { property.Value = ""; } } property.PropertyChanged += property_PropertyChanged; property.ValueError += property_ValueError; textBox = new TextBox { Height = 20, Foreground = Property.CanWrite ? Brushes.Black : Brushes.Gray, BorderThickness = new Thickness(0), Margin = new Thickness(0), IsReadOnly = !Property.CanWrite }; if (null != property.Value) { textBox.Text = property.Value.ToString(); } if (Property.CanWrite) { textBox.TextChanged += Control_TextChanged; } Content = textBox; GotFocus += StringValueEditor_GotFocus; }
/// <summary> /// Adds a component to this object. /// </summary> /// <param name="component"></param> public bool AddComponent(ObjectComponent component) { #if WINDOWS if (!CheckAttributes(component)) return false; // Check existing components attributes: foreach (var cmp in components) { System.Reflection.MemberInfo info = cmp.GetType(); object[] attributes = info.GetCustomAttributes(true); for (int i = 0; i < attributes.Length; i++) { if (attributes[i] is Unique) { if ((attributes[i] as Unique).Options == Unique.UniqueOptions.Explicit) { if (component.GetType() == cmp.GetType()) return false; } else { if (component.GetType().IsAssignableFrom(cmp.GetType()) || cmp.GetType().IsAssignableFrom(component.GetType())) return false; var baseA = component.GetType().BaseType; var baseB = cmp.GetType().BaseType; while (true) { if (baseA == typeof(ExtendedObjectComponent) || baseB == typeof(ExtendedObjectComponent) || baseA == typeof(ObjectComponent) || baseB == typeof(ObjectComponent)) { break; } else if (baseA == baseB) { return false; } else if (baseA.IsAssignableFrom(baseB) || baseB.IsAssignableFrom(baseA)) { return false; } baseA = baseA.BaseType; baseB = baseB.BaseType; } } } } } #endif // This component is already assigned? if (!this.componentValues.ContainsKey(component.GetType().FullName)) { this.componentValues[component.GetType().FullName] = new Dictionary<PropertyLabel, object>(new PropertyLabel.EqualityComparer()); } else { // Component already added, nothing to do here, return. return false; } component.Transform = this.transform; component.Name = component.GetType().Name; this.components.Add(component); this.componentReferences.Add(component.GetType().FullName); // Get through all the properties in the component and assign them #if WINDOWS List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetProperties()); #elif WINRT List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetRuntimeProperties()); #endif foreach (PropertyInfo propInfo in props) { PropertyLabel label = new PropertyLabel(propInfo.PropertyType.FullName, propInfo.Name); this.componentValues[component.GetType().FullName][label] = propInfo.GetValue(component, null); } if (!SceneManager.IsEditor) { component.Initialize(); } else if (SceneManager.IsEditor && component is ExtendedObjectComponent) { component.Initialize(); } return true; }
public EnumEditor(PropertyLabel label, PropertyItem property) : base(label, property) { }
private void LoadControl(OSAE.OSAEObject obj) { this.Dispatcher.Invoke((Action)(() => { String sStateMatch = ""; #region CONTROL STATE IMAGE if (obj.Type == "CONTROL STATE IMAGE") { StateImage stateImageControl = new StateImage(obj); foreach (OSAE.OSAEObjectProperty p in obj.Properties) { try { if (p.Value.ToLower() == stateImageControl.CurState.ToLower()) { sStateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } catch (Exception ex) { this.Log.Error("Error finding object ", ex); return; } } try { int dZ = Int32.Parse(obj.Property("ZOrder").Value); stateImageControl.MouseRightButtonDown += new MouseButtonEventHandler(State_Image_MouseRightButtonDown); stateImageControl.Location.X = Double.Parse(obj.Property(sStateMatch + " X").Value); stateImageControl.Location.Y = Double.Parse(obj.Property(sStateMatch + " Y").Value); canGUI.Children.Add(stateImageControl); Canvas.SetLeft(stateImageControl, stateImageControl.Location.X); Canvas.SetTop(stateImageControl, stateImageControl.Location.Y); Canvas.SetZIndex(stateImageControl, dZ); stateImages.Add(stateImageControl); controlTypes.Add(typeof(StateImage)); stateImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (Exception ex) { this.Log.Error("Error updating screenObject", ex); return; } } #endregion #region CONTROL PROPERTY LABEL else if (obj.Type == "CONTROL PROPERTY LABEL") { this.Log.Debug("Loading PropertyLabelControl: " + obj.Name); try { PropertyLabel pl = new PropertyLabel(obj); pl.MouseRightButtonDown += new MouseButtonEventHandler(Property_Label_MouseRightButtonDown); canGUI.Children.Add(pl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); pl.Location.X = Double.Parse(obj.Property("X").Value); pl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(pl, pl.Location.X); Canvas.SetTop(pl, pl.Location.Y); Canvas.SetZIndex(pl, dZ); propLabels.Add(pl); controlTypes.Add(typeof(PropertyLabel)); pl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (Exception ex) { this.Log.Error("Error updating PropertyLabelControl", ex); return; } } #endregion #region CONTROL STATIC LABEL else if (obj.Type == "CONTROL STATIC LABEL") { this.Log.Debug("Loading PropertyLabelControl: " + obj.Name); try { OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj); canGUI.Children.Add(sl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); sl.Location.X = Double.Parse(obj.Property("X").Value); sl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(sl, sl.Location.X); Canvas.SetTop(sl, sl.Location.Y); Canvas.SetZIndex(sl, dZ); staticLabels.Add(sl); controlTypes.Add(typeof(OSAE.UI.Controls.StaticLabel)); sl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (Exception ex) { this.Log.Error("Error updating PropertyLabelControl", ex); return; } } #endregion #region CONTROL TIMER LABEL else if (obj.Type == "CONTROL TIMER LABEL") { this.Log.Debug("Loading PropertyTimerControl: " + obj.Name); try { OSAE.UI.Controls.TimerLabel tl = new OSAE.UI.Controls.TimerLabel(obj); canGUI.Children.Add(tl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); tl.Location.X = Double.Parse(obj.Property("X").Value); tl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(tl, tl.Location.X); Canvas.SetTop(tl, tl.Location.Y); Canvas.SetZIndex(tl, dZ); timerLabels.Add(tl); controlTypes.Add(typeof(OSAE.UI.Controls.TimerLabel)); tl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (Exception ex) { this.Log.Error("Error updating PropertyTimerControl", ex); return; } } #endregion #region CONTROL CLICK IMAGE else if (obj.Type == "CONTROL CLICK IMAGE") { try { ClickImage ClickImageControl = new ClickImage(obj); ClickImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Click_Image_MouseRightButtonDown); canGUI.Children.Add(ClickImageControl); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(ClickImageControl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(ClickImageControl, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(ClickImageControl, dZ); ClickImageControl.Location.X = dX; ClickImageControl.Location.Y = dY; clickImages.Add(ClickImageControl); controlTypes.Add(typeof(ClickImage)); ClickImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Click Image: " + myerror.Message); } } #endregion #region CONTROL NAVIGATION IMAGE else if (obj.Type == "CONTROL NAVIGATION IMAGE") { try { NavigationImage navImageControl = new NavigationImage(obj.Property("Screen").Value, obj); navImageControl.MouseLeftButtonUp += new MouseButtonEventHandler(Navigaton_Image_MouseLeftButtonUp); navImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Navigaton_Image_MouseRightButtonDown); canGUI.Children.Add(navImageControl); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(navImageControl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(navImageControl, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(navImageControl, dZ); navImageControl.Location.X = dX; navImageControl.Location.Y = dY; navImages.Add(navImageControl); controlTypes.Add(typeof(NavigationImage)); navImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message); } } #endregion #region CONTROL CAMERA VIEWER else if (obj.Type == "CONTROL CAMERA VIEWER") { try { string stream = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value; VideoStreamViewer vsv = new VideoStreamViewer(stream, obj); canGUI.Children.Add(vsv); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(vsv, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(vsv, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(vsv, dZ); vsv.Location.X = dX; vsv.Location.Y = dY; cameraViewers.Add(vsv); controlTypes.Add(typeof(VideoStreamViewer)); vsv.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Camera Viewer: " + myerror.Message); } } #endregion #region USER CONTROL else if (obj.Type == "USER CONTROL") { string sUCType = obj.Property("Control Type").Value; if (sUCType == "USER CONTROL WEATHER") { Weather wc = new Weather(obj); canGUI.Children.Add(wc); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(wc, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(wc, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(wc, dZ); wc.Location.X = dX; wc.Location.Y = dY; userControls.Add(wc); controlTypes.Add(typeof(Weather)); wc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } } #endregion #region CONTROL BROWSER else if (obj.Type == "CONTROL BROWSER") { this.Log.Debug("Loading BrowserControl: " + obj.Name); try { OSAE.UI.Controls.BrowserFrame bf = new OSAE.UI.Controls.BrowserFrame(obj); bf.MouseRightButtonDown += new MouseButtonEventHandler(Broswer_Control_MouseRightButtonDown); //OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj); canGUI.Children.Add(bf); int dZ = Int32.Parse(obj.Property("ZOrder").Value); bf.Location.X = Double.Parse(obj.Property("X").Value); bf.Location.Y = Double.Parse(obj.Property("Y").Value); bf.Width = Double.Parse(obj.Property("Width").Value); bf.Height = Double.Parse(obj.Property("Height").Value); Canvas.SetLeft(bf, bf.Location.X); Canvas.SetTop(bf, bf.Location.Y); Canvas.SetZIndex(bf, dZ); browserFrames.Add(bf); controlTypes.Add(typeof(OSAE.UI.Controls.BrowserFrame)); // bf.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (Exception ex) { this.Log.Error("Error updating BrowserControl", ex); return; } } #endregion })); }
public BooleanEditor(PropertyLabel label, PropertyItem property) : base(label, property) { }
/// <summary> /// Save the current state of this object components. /// </summary> public void SaveComponentValues() { foreach (ObjectComponent component in this.components) { try { #if WINDOWS List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetProperties()); #elif WINRT List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetRuntimeProperties()); #endif foreach (PropertyInfo propInfo in props) { PropertyLabel label = new PropertyLabel(propInfo.PropertyType.FullName, propInfo.Name); //if(propInfo.GetValue(component, null).GetType().IsSerializable) componentValues[component.GetType().FullName][label] = propInfo.GetValue(component, null); } } catch (Exception ex) { Console.WriteLine("SaveComponentValues(): " + ex.Message); } } foreach (GameObject gameObject in children) gameObject.SaveComponentValues(); }
void CreateUIElement(Type t, PropertyInfo p, string name) { DropdownAttribute dp = p.GetCustomAttribute <DropdownAttribute>(); LevelEditorAttribute le = p.GetCustomAttribute <LevelEditorAttribute>(); CurveEditorAttribute ce = p.GetCustomAttribute <CurveEditorAttribute>(); SliderAttribute sl = p.GetCustomAttribute <SliderAttribute>(); FileSelectorAttribute fsl = p.GetCustomAttribute <FileSelectorAttribute>(); HidePropertyAttribute hp = p.GetCustomAttribute <HidePropertyAttribute>(); ColorPickerAttribute cp = p.GetCustomAttribute <ColorPickerAttribute>(); TitleAttribute ti = p.GetCustomAttribute <TitleAttribute>(); TextInputAttribute tinp = p.GetCustomAttribute <TextInputAttribute>(); GraphParameterEditorAttribute gpe = p.GetCustomAttribute <GraphParameterEditorAttribute>(); ParameterMapEditorAttribute pme = p.GetCustomAttribute <ParameterMapEditorAttribute>(); PromoteAttribute pro = p.GetCustomAttribute <PromoteAttribute>(); //handle very special stuff //exposed constant parameter variable names if (gpe != null) { if (node is Graph) { Graph g = node as Graph; GraphParameterEditor inp = new GraphParameterEditor(g, g.Parameters); Stack.Children.Add(inp); elementLookup[name] = inp; } } //for graph instance exposed parameters from underlying graph else if (pme != null) { if (node is GraphInstanceNode) { GraphInstanceNode gin = node as GraphInstanceNode; ParameterMap pm = new ParameterMap(gin.GraphInst, gin.Parameters); Stack.Children.Add(pm); elementLookup[name] = pm; } } string title = name; if (ti != null) { title = ti.Title; } PropertyInfo op = null; //we don't create an element for this one //as it is hidden if (hp != null) { return; } try { if (ce != null) { op = node.GetType().GetProperty(ce.OutputProperty); } } catch (Exception e) { Console.WriteLine(e.StackTrace); } if (t.Equals(typeof(Vector4))) { if (cp != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); ColorSelect cs = new ColorSelect(p, node); Stack.Children.Add(cs); elementLookup[name] = cs; } } else if (t.Equals(typeof(string[]))) { if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); DropDown inp = new DropDown((string[])p.GetValue(node), node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(bool))) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); ToggleControl tg = new ToggleControl(name, p, node); Stack.Children.Add(tg); elementLookup[name] = tg; } else if (t.Equals(typeof(string))) { if (tinp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); PropertyInput ip = new PropertyInput(p, node); Stack.Children.Add(ip); elementLookup[name] = ip; } else if (fsl != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); FileSelector inp = new FileSelector(p, node, fsl.Filter); Stack.Children.Add(inp); elementLookup[name] = inp; } else if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); object[] names = dp.Values; DropDown inp = new DropDown(names, node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } } if (t.Equals(typeof(float))) { if (sl != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberSlider inp = new NumberSlider(sl, p, node); Stack.Children.Add(inp); elementLookup[name] = inp; } else { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberInput inp = new NumberInput(NumberInputType.Float, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(int))) { if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); //do a dropdown object[] names = dp.Values; DropDown inp = new DropDown(names, node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } else if (sl != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberSlider inp = new NumberSlider(sl, p, node); Stack.Children.Add(inp); elementLookup[name] = inp; } else { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberInput inp = new NumberInput(NumberInputType.Int, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(MultiRange))) { if (le != null) { UILevels lv = null; if (node is Node) { Node nd = (Node)node; if (nd.Inputs.Count > 0 && nd.Inputs[0].Input != null) { var n = nd.Inputs[0].Input.Node; byte[] result = n.GetPreview(n.Width, n.Height); RawBitmap bit = null; if (result != null) { bit = new RawBitmap(n.Width, n.Height, result); } lv = new UILevels(bit, node, p); } else { lv = new UILevels(null, node, p); } Stack.Children.Add(lv); elementLookup[name] = lv; } } } else if (op != null && ce != null) { UICurves cv = new UICurves(p, op, node); Stack.Children.Add(cv); elementLookup[name] = cv; } else if (t.IsEnum) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); string[] names = Enum.GetNames(t); DropDown inp = new DropDown(names, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } }
private void LoadControl(OSAE.OSAEObject obj) { this.Dispatcher.Invoke((Action)(() => { String sStateMatch = ""; #region CONTROL STATE IMAGE if (obj.Type == "CONTROL STATE IMAGE") { StateImage stateImageControl = new StateImage(obj); foreach (OSAE.OSAEObjectProperty p in obj.Properties) { if (p.Value.ToLower() == stateImageControl.CurState.ToLower()) { sStateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' ')); } } int dZ = Int32.Parse(obj.Property("ZOrder").Value); stateImageControl.Location.X = Double.Parse(obj.Property(sStateMatch + " X").Value); stateImageControl.Location.Y = Double.Parse(obj.Property(sStateMatch + " Y").Value); canGUI.Children.Add(stateImageControl); Canvas.SetLeft(stateImageControl, stateImageControl.Location.X); Canvas.SetTop(stateImageControl, stateImageControl.Location.Y); Canvas.SetZIndex(stateImageControl, dZ); stateImages.Add(stateImageControl); controlTypes.Add(typeof(StateImage)); stateImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } #endregion #region CONTROL PROPERTY LABEL else if (obj.Type == "CONTROL PROPERTY LABEL") { logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false); PropertyLabel pl = new PropertyLabel(obj); canGUI.Children.Add(pl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); pl.Location.X = Double.Parse(obj.Property("X").Value); pl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(pl, pl.Location.X); Canvas.SetTop(pl, pl.Location.Y); Canvas.SetZIndex(pl, dZ); propLabels.Add(pl); controlTypes.Add(typeof(PropertyLabel)); pl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } #endregion #region CONTROL STATIC LABEL else if (obj.Type == "CONTROL STATIC LABEL") { logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false); OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj); canGUI.Children.Add(sl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); sl.Location.X = Double.Parse(obj.Property("X").Value); sl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(sl, sl.Location.X); Canvas.SetTop(sl, sl.Location.Y); Canvas.SetZIndex(sl, dZ); staticLabels.Add(sl); controlTypes.Add(typeof(OSAE.UI.Controls.StaticLabel)); sl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } #endregion #region CONTROL TIMER LABEL else if (obj.Type == "CONTROL TIMER LABEL") { logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false); OSAE.UI.Controls.TimerLabel tl = new OSAE.UI.Controls.TimerLabel(obj); canGUI.Children.Add(tl); int dZ = Int32.Parse(obj.Property("ZOrder").Value); tl.Location.X = Double.Parse(obj.Property("X").Value); tl.Location.Y = Double.Parse(obj.Property("Y").Value); Canvas.SetLeft(tl, tl.Location.X); Canvas.SetTop(tl, tl.Location.Y); Canvas.SetZIndex(tl, dZ); timerLabels.Add(tl); controlTypes.Add(typeof(OSAE.UI.Controls.TimerLabel)); tl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } #endregion #region CONTROL METHOD IMAGE else if (obj.Type == "CONTROL METHOD IMAGE") { try { MethodImage methodImageControl = new MethodImage(obj); canGUI.Children.Add(methodImageControl); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(methodImageControl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(methodImageControl, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(methodImageControl, dZ); methodImageControl.Location.X = dX; methodImageControl.Location.Y = dY; methodImages.Add(methodImageControl); controlTypes.Add(typeof(MethodImage)); methodImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message); } } #endregion #region CONTROL NAVIGATION IMAGE else if (obj.Type == "CONTROL NAVIGATION IMAGE") { try { NavigationImage navImageControl = new NavigationImage(obj.Property("Screen").Value, obj); navImageControl.MouseLeftButtonUp += new MouseButtonEventHandler(Navigaton_Image_MouseLeftButtonUp); canGUI.Children.Add(navImageControl); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(navImageControl, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(navImageControl, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(navImageControl, dZ); navImageControl.Location.X = dX; navImageControl.Location.Y = dY; navImages.Add(navImageControl); controlTypes.Add(typeof(NavigationImage)); navImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message); } } #endregion #region CONTROL CAMERA VIEWER else if (obj.Type == "CONTROL CAMERA VIEWER") { try { string stream = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value; VideoStreamViewer vsv = new VideoStreamViewer(stream, obj); canGUI.Children.Add(vsv); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(vsv, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(vsv, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(vsv, dZ); vsv.Location.X = dX; vsv.Location.Y = dY; cameraViewers.Add(vsv); controlTypes.Add(typeof(VideoStreamViewer)); vsv.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } catch (MySqlException myerror) { MessageBox.Show("GUI Error Load Camera Viewer: " + myerror.Message); } } #endregion #region USER CONTROL else if (obj.Type == "USER CONTROL") { string sUCType = obj.Property("Control Type").Value; if (sUCType == "USER CONTROL WEATHER") { Weather wc = new Weather(obj); canGUI.Children.Add(wc); OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder"); OSAE.OSAEObjectProperty pX = obj.Property("X"); OSAE.OSAEObjectProperty pY = obj.Property("Y"); Double dX = Convert.ToDouble(pX.Value); Canvas.SetLeft(wc, dX); Double dY = Convert.ToDouble(pY.Value); Canvas.SetTop(wc, dY); int dZ = Convert.ToInt32(pZOrder.Value); Canvas.SetZIndex(wc, dZ); wc.Location.X = dX; wc.Location.Y = dY; userControls.Add(wc); controlTypes.Add(typeof(Weather)); wc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove); } } #endregion })); }
private void LoadComponentValues(ObjectComponent component) { // The component is assigned? if (!componentValues.ContainsKey(component.GetType().FullName)) return; #if WINDOWS List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetProperties()); //foreach (PropertyInfo pinfo in props) //{ // Console.WriteLine("c:" + component.Transform.gameObject + " b: " + pinfo.Name); //} #elif WINRT List<PropertyInfo> props = new List<PropertyInfo>(component.GetType().GetRuntimeProperties()); //foreach (PropertyInfo pinfo in props) //{ // Debug.WriteLine("cc: " + component.GetType().Name + " c:" + component.Transform.gameObject + " b: " + pinfo.Name); // Debug.WriteLine("VALUE: " + pinfo.GetValue(component, null)); //} #endif foreach (PropertyInfo propInfo in props) { try { #if WINRT bool found = false; foreach (var item in componentValues[component.GetType().FullName]) { if (item.Key.Name == propInfo.Name && item.Key.TypeName == propInfo.PropertyType.FullName) { propInfo.SetValue(component, componentValues[component.GetType().FullName][item.Key], null); found = true; break; } } if (!found) { PropertyLabel label = new PropertyLabel(propInfo.PropertyType.FullName, propInfo.Name); this.componentValues[component.GetType().FullName][label] = propInfo.GetValue(component, null); } #elif WINDOWS // dummy label PropertyLabel label = new PropertyLabel(propInfo.PropertyType.FullName, propInfo.Name); // There is a place to store the component value? if (!componentValues[component.GetType().FullName].ContainsKey(label)) { this.componentValues[component.GetType().FullName][label] = propInfo.GetValue(component, null); } else { propInfo.SetValue(component, componentValues[component.GetType().FullName][label], null); } #endif } catch (Exception ex) { Debug.WriteLine("Property not loaded: " + ex.ToString()); } } }