Inheritance: MonoBehaviour
        public ComboBoxWindow()
            : base(GuiManager.Cursor)
        {
            GuiManager.AddWindow(this);
            ScaleX = 12;
            ScaleY = 9;
            this.Closing += GuiManager.RemoveWindow;
            
            mTextField = new TextField();
            mTextField.SetDimensions(-2, -8, 1, 23, 0);
            mTextField.Z = 100;
            mTextField.WindowParent = this;

            mComboBox = new ComboBox(mCursor);
            AddWindow(mComboBox);
            mComboBox.ScaleX = ScaleX - 2;
            mComboBox.ScaleY = 1.4f;
            mComboBox.SetPositionTL(ScaleX, 2 * ScaleY - 5);

            mCancelButton = new Button(mCursor);
            AddWindow(mCancelButton);
            mCancelButton.ScaleY = 1.5f;
            mCancelButton.Text = "Cancel";
            mCancelButton.SetPositionTL(2 * ScaleX - 5.2f, 2 * ScaleY - 2);
            mCancelButton.Click += GuiManager.RemoveWindow;

            mOkButton = new Button(mCursor);
            AddWindow(mOkButton);
            mOkButton.ScaleY = 1.5f;
            mOkButton.Text = "Ok";
            mOkButton.SetPositionTL(5.2f, 2 * ScaleY - 2);
        }
	void Start () {
		
		MovieClip overlay = new MovieClip( "uniSWF/Examples/common/swf/common_uniswf_overlay.swf:DemoOverlay" );
		stage.addChild( overlay );
		
		TextField txt = overlay.getChildByName<TextField>("txt");
		if( txt != null ) {
			txt.text = title;
		}
		
		MovieClip logo = overlay.getChildByName<MovieClip>("logo");
		logo.addEventListener( MouseEvent.CLICK, onLogoClick );
		
		Logger.instance.addEventListener( LogEvent.LOGEVENT, onLog );
		
		debug_txt = overlay.getChildByName<TextField>("debug_txt");
		
		if( !displayAtTop ) {
			overlay.y = Screen.height - overlay.height;
		}
		
		if( fadeAfter > 0 ) {
			Tweener.addTween( overlay, Tweener.Hash( "delay",fadeAfter, "time",3, "alpha",0 ) );
		}
	}
 public void GetAttributeValueStyleAsString()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         AssertStyleText(_element.GetAttributeValue("style").ToLowerInvariant());
                     });
 }
 public void ElementStyleCssText()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         AssertStyleText(_element.Style.CssText.ToLowerInvariant());
                     });
 }
Exemple #5
0
 public UnitFrame(Unit unit)
 {
     this.unit = unit;
     frame = new MovieClip ("Flash GUI/game_gui.swf:unit_frame");
     unit_name = frame.getChildByName("unit_name") as TextField;
     unit_name.text = "8====D";
     unit_name.colorTransform = Color.black;
 }
Exemple #6
0
        public void ShouldTrimTheText()
        {
            var mockINativeElement = new Mock<INativeElement>();
            mockINativeElement.Setup(x => x.GetAttributeValue("value")).Returns(" some text ");
            var textField = new TextField(new Mock<DomContainer>().Object, mockINativeElement.Object);

            Assert.That(textField.ToText(), Is.EqualTo("some text"));
        }
 public void ElementStyleToStringReturnsCssText()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         Console.WriteLine(_element.Style.ToString().ToLowerInvariant());
                         AssertStyleText(_element.Style.ToString().ToLowerInvariant());
                     });
 }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Ext.IsAjaxRequest)
                return;

            int spClientChannelID = Convert.ToInt32(this.Request.QueryString["ChannleClientID"]);

            SPClientChannelSettingWrapper settingWrapper = SPClientChannelSettingWrapper.FindById(spClientChannelID);

            this.hidChannelClientID.Text = settingWrapper.Id.ToString();

            this.txtChannelName.Text = settingWrapper.Name;

            this.txtChannelSubmitUrl.Text = settingWrapper.ChannelID.InterfaceUrl;

            this.lblChannelCode.Text = settingWrapper.ChannelCode;

            List<SPChannelParamsWrapper> channelParamsWrappers = settingWrapper.ChannelID.GetAllEnableParams();

            foreach (SPChannelParamsWrapper spChannelParamsWrapper in channelParamsWrappers)
            {
                Anchor anchor = new Anchor();
                anchor.Horizontal = "95%";
                TextField txt = new TextField();
                txt.ID = "txt" + spChannelParamsWrapper.Name;
                txt.FieldLabel = spChannelParamsWrapper.Name;

                if (spChannelParamsWrapper.ParamsMappingName == "linkid")
                {
                    txt.Value = "99999" +StringUtil.GetRandNumber(15);

                    hidLinkIDeName.Text = txt.ClientID;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "mobile")
                {
                    txt.Value = "135" + StringUtil.GetRandNumber(8);

                    hidMobileName.Text = txt.ClientID;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "cpid")
                {
                    if (!string.IsNullOrEmpty(settingWrapper.ChannelCode))
                        txt.Value = settingWrapper.ChannelCode;
                }

                if (spChannelParamsWrapper.ParamsMappingName == "ywid")
                {
                    if (!string.IsNullOrEmpty(settingWrapper.CommandCode))
                        txt.Value = settingWrapper.CommandCode;
                }

                anchor.Items.Add(txt);
                this.FormLayout1.Anchors.Add(anchor);
            }
        }
Exemple #9
0
 void Start()
 {
     ButtonField = Resources.Load("Prefabs/ButtonField") as GameObject;
     InfoField = new MovieClip("swf/Ellipse.swf:InfoField");
     InfoField.gotoAndStop(1);
     CannonName = InfoField.getChildByName<TextField>("CannonName");
     Cost = InfoField.getChildByName<TextField>("Cost");
     Info = InfoField.getChildByName<TextField>("Info");
 }
        public static void SetBackgroundGradient(
            StyleSet classStyleSet,
            Color backgroundGradientColor, 
            Color backgroundSelectedGradientColor, 
            Color backgroundSelectedInactiveGradientColor,
            Diagram diagram,
            string surfaceTitle)
        {
            #region Set background gradient style and shape attributes

            // Fill brush settings for background (Start gradient color).
            BrushSettings backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackground, backgroundBrush);
            // Selected state
            backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedGradientColor;            
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelected, backgroundBrush);
            // SelectedInactive state
            backgroundBrush = new BrushSettings();
            backgroundBrush.Color = backgroundSelectedInactiveGradientColor;
            classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackgroundSelectedInactive, backgroundBrush);
            
            // We should find a "Background" field created when we set the 
            // HasBackgroundGradient property to "true"
            AreaField background = diagram.FindShapeField("Background") as AreaField;
            if (background != null)
            {
                background.DefaultReflectParentSelectedState = true;
                //background.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, diagram.MaximumSize.Height / 2);
            }

            #endregion

            #region Set Diagram font and text attributes

            // Custom font styles for diagram title
            FontSettings fontSettings;
            fontSettings = new FontSettings();
            fontSettings.Style = FontStyle.Bold;
            fontSettings.Size = 9 / 72.0F;
            classStyleSet.OverrideFont(DiagramFonts.ShapeTitle, fontSettings);

            // Create a text field for the Diagram Title
            TextField textField = new TextField("DiagramTitle");
            textField.DefaultText = surfaceTitle;
            textField.DefaultVisibility = true;
            textField.DefaultAutoSize = true;
            textField.DefaultFontId = DiagramFonts.ShapeTitle;
            textField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.33);
            textField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.07);

            diagram.ShapeFields.Add(textField);

            #endregion
        }
Exemple #11
0
	protected void handleTouchKeyboardFocusIn( TextField txt  ) {
		
#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8			
 		// Set text for input change detection
	   	string prevText = txt.text;    
	    lastTxt = prevText;
	    
	    // Open keyboard on focus change
	    keyboard = TouchScreenKeyboard.Open(prevText, keyboardType );
	    
	    activeInput = txt;
#endif		
	}
        static void Main(string[] args)
        {
            string url = "http://google.com";
            TextField searchBox = new TextField(By.Name("q"));

            using (Browser browser = searchBox.Browser)
            {
                browser.Launch(BrowserType.IE).NavigateTo(url);
                searchBox.WaitUntilVisible(10);
                searchBox.Text = "selenium";
                searchBox.Submit();
                browser.Sleep(5);
            }
        }
        public void BackgroundColor()
        {
            ExecuteTest(browser =>
                            {
                                // GIVEN
                                _element = browser.TextField("Textarea1");

                                // WHEN
                                var backgroundColor = _element.Style.BackgroundColor;

                                // THEN
                                Assert.That(backgroundColor, Is.EqualTo(HtmlColor.Blue));
                            });
        }
        public void Color()
        {
            ExecuteTest(browser =>
                            {
                                // GIVEN
                                _element = browser.TextField("Textarea1");

                                // WHEN
                                var color = _element.Style.Color;

                                // THEN
                                Assert.That(color, Is.EqualTo(HtmlColor.White));
                            });
        }
	void Start ( ) {
		
		// 
		// Alter existing font
		
		// Add root with single textfield
		mc = new MovieClip( "uniSWF/Examples/Extra examples/ProgramaticTextFields/swf/programaticText.swf:Root" ) ;
		stage.addChild( mc );
		
		// Ensure player is not changing textfields on timeline
		mc.stop();
		
		 // Get textfield
		txt = mc.getChildByName<TextField>( "txt" );
		
		// Get format
		TextFormat format = txt.textFormat;
		
		// Set new format
		format.fontClassName = null;	// Clear class for bitmap fonts as this points to the exact font_size_filters assets
		format.size = 30;
		
		// Set format
		txt.textFormat = format;
		
		
		
		//
		// Add new textfield using font and size ( must be exported )		
		format = new TextFormat();
		format.font = "Times Bold";
		format.color = Color.green;
		format.size = 64;
		BitmapTextField bmpTxt = new BitmapTextField( );
		bmpTxt.width = 500;
		bmpTxt.height = 200;
		bmpTxt.textFormat = format;		
		bmpTxt.text = "Text set from code";
		bmpTxt.y = 100;
		bmpTxt.x = 10;
		
		bmpTxt.type = TextFieldType.INPUT;
		
		bmpTxt.addCharColor( 5, 8, Color.cyan );
		bmpTxt.addCharColor( 14, 17, Color.red );
		
		bmpTxt.appendText( ", Appended text" );
		stage.addChild( bmpTxt );		
	}
Exemple #16
0
	protected void handleTouchKeyboardFocusOut( TextField txt  ) {
		
		
#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8	
	    if( keyboard != null ) {
	    	if( keyboard.active ) {
	    		forceFocusNextFrame = true;
	    	}
	    }

	    // Clear target on focus change
	    activeInput = null;
	    keyboard = null;   
#endif		
		
	}
Exemple #17
0
        public MessageBox(Cursor cursor) : 
            base(cursor)
		{
            okButton = new Button(mCursor);
            AddWindow(okButton);
			this.HasMoveBar = true;
            this.HasCloseButton = true;
            Visible = false;
			textDisplay = new TextField();

			textDisplay.mAlignment = HorizontalAlignment.Left;

            
            //mTextRed = mTextGreen = mTextBlue = 20;

		}
        public BehaviorEditorSettingsControl() : base()
        {
            AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );

            AddChild( new Label( "Behavior ID:" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetHeight( 24.0f ) );            
            m_treeIdField = (TextField)AddChild( new TextField().SetMargin( 5.0f, 0, 5.0f, 0 ).SetWidth( 100.0f, MetricsUnits.Percentage ) );

            AddChild( new Label( "Output Path:" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetHeight( 24.0f ) );
            m_savePathField = ( TextField )AddChild( new TextField( EditorPrefs.HasKey( "BTE_SavePath" ) ? EditorPrefs.GetString( "BTE_SavePath" ) : "" ).SetMargin( 5.0f, 0.0f, 5.0f, 0.0f ).SetWidth( 100.0f, MetricsUnits.Percentage ) );

            m_generateButton = (Button )AddChild( new Button( "Generate Behavior" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetWidth( 100.0f, MetricsUnits.Percentage ) );
            m_loadXmlButton = ( Button )AddChild( new Button( "Load Layout" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetWidth( 100.0f, MetricsUnits.Percentage ) );
            m_saveXmlButton = ( Button )AddChild( new Button( "Save Layout" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetWidth( 100.0f, MetricsUnits.Percentage ) );
            m_newBehaviorButton = ( Button )AddChild( new Button( "New Behavior" ).SetMargin( 5.0f, 5.0f, 5.0f, 5.0f ).SetWidth( 100.0f, MetricsUnits.Percentage ) );

            m_generateButton.Enabled = false;
            m_treeIdField.ValueChange += m_treeIdField_ValueChange;
            m_savePathField.ValueChange += m_savePathField_ValueChange;
        }
Exemple #19
0
        public virtual void TestFloatNorms()
        {
            Directory dir = NewDirectory();
            MockAnalyzer analyzer = new MockAnalyzer(Random());
            analyzer.MaxTokenLength = TestUtil.NextInt(Random(), 1, IndexWriter.MAX_TERM_LENGTH);

            IndexWriterConfig config = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            Similarity provider = new MySimProvider(this);
            config.SetSimilarity(provider);
            RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, config);
            LineFileDocs docs = new LineFileDocs(Random());
            int num = AtLeast(100);
            for (int i = 0; i < num; i++)
            {
                Document doc = docs.NextDoc();
                float nextFloat = (float)Random().NextDouble();
                Field f = new TextField(FloatTestField, "" + nextFloat, Field.Store.YES);
                f.Boost = nextFloat;

                doc.Add(f);
                writer.AddDocument(doc);
                doc.RemoveField(FloatTestField);
                if (Rarely())
                {
                    writer.Commit();
                }
            }
            writer.Commit();
            writer.Dispose();
            AtomicReader open = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(dir));
            NumericDocValues norms = open.GetNormValues(FloatTestField);
            Assert.IsNotNull(norms);
            for (int i = 0; i < open.MaxDoc(); i++)
            {
                Document document = open.Document(i);
                float expected = Convert.ToSingle(document.Get(FloatTestField));
                Assert.AreEqual(expected, Number.IntBitsToFloat((int)norms.Get(i)), 0.0f);
            }
            open.Dispose();
            dir.Dispose();
            docs.Dispose();
        }
Exemple #20
0
	void ShowLevelComplete(int Level) {
        if (GameObject.Find("Main Camera").GetComponent<MovieClipOverlayCameraBehaviour>() == null)
        {
            return;
        }
        st = Camera.main.GetComponent<MovieClipOverlayCameraBehaviour>().stage;
      
        ChangeLevel = new MovieClip("swf/LevelPassed.swf:LevelUP");
        
 
       
        ChangeLevel.x = Screen.width / 2;
        ChangeLevel.y = Screen.height / 2;
        ChangeLevel.scaleX = (float)Screen.width / 2048;
        ChangeLevel.scaleY = ChangeLevel.scaleX;

        Text = ChangeLevel.getChildByName<TextField>("Layer1");
        Text.text = "Level  " + Level.ToString();
        st.addChild(ChangeLevel);
        ChangeLevel.gotoAndPlay(1);
        Playing = true;
	}
    //
    void CreateFields()
    {
      iRecordingField = new RecordingField();

      if (SupportsGraphics)
      {
        //Create fields for testing our graphics support.
        //Currently not used in production environment
        iBitmapField = new BitmapField(null,0,0,1,2);
        iBitmapField.RowSpan = 2;
        iTextFieldTop = new TextField("",ContentAlignment.MiddleCenter,1,0);
        iTextFieldBottom = new TextField("", ContentAlignment.MiddleCenter, 1, 1);
        iTextFieldSingleLine = new TextField("", ContentAlignment.MiddleCenter, 0, 0);

        iFields = new DataField[] { iRecordingField, iBitmapField, iTextFieldTop, iTextFieldBottom };
      }
      else
      {
        //Just make sure both fields are instantiated
        iTextFieldTop = new TextField("", ContentAlignment.MiddleCenter, 0, 0);
        iTextFieldBottom = new TextField("", ContentAlignment.MiddleCenter, 0, 1);
        iTextFieldSingleLine = new TextField("", ContentAlignment.MiddleCenter, 0, 0);

        if (SharpLibDisplay.Settings.Instance.SingleLine)
        {
          //Single line mode
          iFields = new DataField[] { iRecordingField, iTextFieldSingleLine };
        }
        else
        {
          //Two lines mode use both fields
          iFields = new DataField[] { iRecordingField, iTextFieldTop, iTextFieldBottom };
        }
      }

      iClient.CreateFields(iFields);
    }
        public void GetAttributeValueBackgroundColorByOriginalHTMLattributename()
        {
            ExecuteTest(browser =>
                            {
                                // GIVEN
                                _element = browser.TextField("Textarea1");

                                // WHEN
                                var backgroundColor = _element.Style.GetAttributeValue("background-color");

                                // THEN
                                Assert.That(new HtmlColor(backgroundColor), Is.EqualTo(HtmlColor.Blue));
                            });
        }
        public static GuiWidget CreatePropertyEditor(EditableProperty property, UndoBuffer undoBuffer, PPEContext context, ThemeConfig theme)
        {
            var object3D             = property.Item;
            var propertyGridModifier = property.Item as IPropertyGridModifier;

            GuiWidget rowContainer = null;

            // Get reflected property value once, then test for each case below
            var propertyValue = property.Value;

            void RegisterValueChanged(UIField field, Func <string, object> valueFromString, Func <object, string> valueToString = null)
            {
                field.ValueChanged += (s, e) =>
                {
                    var newValue = field.Value;
                    var oldValue = property.Value.ToString();
                    if (valueToString != null)
                    {
                        oldValue = valueToString(property.Value);
                    }

                    //field.Content
                    if (undoBuffer != null)
                    {
                        undoBuffer.AddAndDo(new UndoRedoActions(() =>
                        {
                            property.SetValue(valueFromString(oldValue));
                            object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                            propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                        },
                                                                () =>
                        {
                            property.SetValue(valueFromString(newValue));
                            object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                            propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                        }));
                    }
                    else
                    {
                        property.SetValue(valueFromString(newValue));
                        object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                        propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                    }
                };
            }

            // create a double editor
            if (propertyValue is double doubleValue)
            {
                var field = new DoubleField(theme);
                field.Initialize(0);
                field.DoubleValue = doubleValue;
                RegisterValueChanged(field, (valueString) => { return(double.Parse(valueString)); });

                void RefreshField(object s, InvalidateArgs e)
                {
                    if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
                    {
                        double newValue = (double)property.Value;
                        if (newValue != field.DoubleValue)
                        {
                            field.DoubleValue = newValue;
                        }
                    }
                }

                object3D.Invalidated += RefreshField;
                field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField;

                rowContainer = CreateSettingsRow(property, field);
            }
            else if (propertyValue is Color color)
            {
                var field = new ColorField(theme, object3D.Color);
                field.Initialize(0);
                field.ValueChanged += (s, e) =>
                {
                    property.SetValue(field.Color);
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };

                rowContainer = CreateSettingsRow(property, field);
            }
            else if (propertyValue is Vector2 vector2)
            {
                var field = new Vector2Field(theme);
                field.Initialize(0);
                field.Vector2 = vector2;
                RegisterValueChanged(field,
                                     (valueString) => { return(Vector2.Parse(valueString)); },
                                     (value) =>
                {
                    var s = ((Vector2)value).ToString();
                    return(s.Substring(1, s.Length - 2));
                });
                rowContainer = CreateSettingsColumn(property, field);
            }
            else if (propertyValue is Vector3 vector3)
            {
                var field = new Vector3Field(theme);
                field.Initialize(0);
                field.Vector3 = vector3;
                RegisterValueChanged(field,
                                     (valueString) => { return(Vector3.Parse(valueString)); },
                                     (value) =>
                {
                    var s = ((Vector3)value).ToString();
                    return(s.Substring(1, s.Length - 2));
                });
                rowContainer = CreateSettingsColumn(property, field);
            }
            else if (propertyValue is DirectionVector directionVector)
            {
                var field = new DirectionVectorField(theme);
                field.Initialize(0);
                field.SetValue(directionVector);
                field.ValueChanged += (s, e) =>
                {
                    property.SetValue(field.DirectionVector);
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };

                rowContainer = CreateSettingsRow(property, field);
            }
            else if (propertyValue is DirectionAxis directionAxis)
            {
                rowContainer = CreateSettingsColumn(property);
                var newDirectionVector = new DirectionVector()
                {
                    Normal = directionAxis.Normal
                };
                var row1   = CreateSettingsRow("Axis".Localize());
                var field1 = new DirectionVectorField(theme);
                field1.Initialize(0);
                field1.SetValue(newDirectionVector);
                row1.AddChild(field1.Content);

                rowContainer.AddChild(row1);

                // the direction axis
                // the distance from the center of the part
                // create a double editor
                var field2 = new Vector3Field(theme);
                field2.Initialize(0);
                field2.Vector3 = directionAxis.Origin - property.Item.Children.First().GetAxisAlignedBoundingBox().Center;
                var row2 = CreateSettingsColumn("Offset", field2);

                // update this when changed
                EventHandler <InvalidateArgs> updateData = (s, e) =>
                {
                    field2.Vector3 = ((DirectionAxis)property.Value).Origin - property.Item.Children.First().GetAxisAlignedBoundingBox().Center;
                };
                property.Item.Invalidated += updateData;
                field2.Content.Closed     += (s, e) =>
                {
                    property.Item.Invalidated -= updateData;
                };

                // update functions
                field1.ValueChanged += (s, e) =>
                {
                    property.SetValue(new DirectionAxis()
                    {
                        Normal = field1.DirectionVector.Normal,
                        Origin = property.Item.Children.First().GetAxisAlignedBoundingBox().Center + field2.Vector3
                    });
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };
                field2.ValueChanged += (s, e) =>
                {
                    property.SetValue(new DirectionAxis()
                    {
                        Normal = field1.DirectionVector.Normal,
                        Origin = property.Item.Children.First().GetAxisAlignedBoundingBox().Center + field2.Vector3
                    });
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };

                rowContainer.AddChild(row2);
            }
            else if (propertyValue is SelectedChildren childSelector)
            {
                var showAsList = property.PropertyInfo.GetCustomAttributes(true).OfType <ShowAsListAttribute>().FirstOrDefault() != null;
                if (showAsList)
                {
                    UIField field = new ChildrenSelectorListField(property, theme);

                    field.Initialize(0);
                    RegisterValueChanged(field,
                                         (valueString) =>
                    {
                        var childrenSelector = new SelectedChildren();
                        foreach (var child in valueString.Split(','))
                        {
                            childrenSelector.Add(child);
                        }
                        return(childrenSelector);
                    });

                    rowContainer = CreateSettingsRow(property, field);
                }
                else                 // show the subtract editor for boolean subtract and subtract and replace
                {
                    rowContainer = CreateSettingsColumn(property);
                    if (property.Item is OperationSourceContainerObject3D sourceContainer)
                    {
                        rowContainer.AddChild(CreateSourceChildSelector(childSelector, sourceContainer, theme));
                    }
                    else
                    {
                        rowContainer.AddChild(CreateSelector(childSelector, property.Item, theme));
                    }
                }
            }
            else if (propertyValue is ImageBuffer imageBuffer)
            {
                rowContainer = CreateSettingsColumn(property);
                rowContainer.AddChild(CreateImageDisplay(imageBuffer, property.Item, theme));
            }
#if !__ANDROID__
            else if (propertyValue is List <string> stringList)
            {
                var selectedItem = ApplicationController.Instance.DragDropData.SceneContext.Scene.SelectedItem;

                var field = new SurfacedEditorsField(theme, selectedItem);
                field.Initialize(0);
                field.ListValue     = stringList;
                field.ValueChanged += (s, e) =>
                {
                    property.SetValue(field.ListValue);
                };

                rowContainer = CreateSettingsColumn(property, field);

                rowContainer.Descendants <HorizontalSpacer>().FirstOrDefault()?.Close();
            }
#endif
            // create a int editor
            else if (propertyValue is int intValue)
            {
                var field = new IntField(theme);
                field.Initialize(0);
                field.IntValue = intValue;
                RegisterValueChanged(field, (valueString) => { return(int.Parse(valueString)); });

                void RefreshField(object s, InvalidateArgs e)
                {
                    if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
                    {
                        int newValue = (int)property.Value;
                        if (newValue != field.IntValue)
                        {
                            field.IntValue = newValue;
                        }
                    }
                }

                object3D.Invalidated += RefreshField;
                field.Content.Closed += (s, e) => object3D.Invalidated -= RefreshField;

                rowContainer = CreateSettingsRow(property, field);
            }
            // create a bool editor
            else if (propertyValue is bool boolValue)
            {
                var field = new ToggleboxField(theme);
                field.Initialize(0);
                field.Checked = boolValue;

                RegisterValueChanged(field,
                                     (valueString) => { return(valueString == "1"); },
                                     (value) => { return(((bool)(value)) ? "1" : "0"); });
                rowContainer = CreateSettingsRow(property, field);
            }
            // create a string editor
            else if (propertyValue is string stringValue)
            {
                var field = new TextField(theme);
                field.Initialize(0);
                field.SetValue(stringValue, false);
                field.Content.HAnchor = HAnchor.Stretch;
                RegisterValueChanged(field, (valueString) => valueString);
                rowContainer = CreateSettingsRow(property, field);

                var label = rowContainer.Children.First();

                if (field is TextField)
                {
                    var spacer = rowContainer.Children.OfType <HorizontalSpacer>().FirstOrDefault();
                    spacer.HAnchor = HAnchor.Absolute;
                    spacer.Width   = Math.Max(0, 100 - label.Width);
                }
            }
            // create a char editor
            else if (propertyValue is char charValue)
            {
                var field = new CharField(theme);
                field.Initialize(0);
                field.SetValue(charValue.ToString(), false);
                field.ValueChanged += (s, e) =>
                {
                    property.SetValue(Convert.ToChar(field.Value));
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };

                rowContainer = CreateSettingsRow(property, field);
            }
            // create an enum editor
            else if (property.PropertyType.IsEnum)
            {
                UIField field;
                var     iconsAttribute = property.PropertyInfo.GetCustomAttributes(true).OfType <IconsAttribute>().FirstOrDefault();
                if (iconsAttribute != null)
                {
                    field = new IconEnumField(property, iconsAttribute, theme)
                    {
                        InitialValue = propertyValue.ToString()
                    };
                }
                else
                {
                    field = new EnumField(property, theme);
                }

                field.Initialize(0);
                RegisterValueChanged(field,
                                     (valueString) =>
                {
                    return(Enum.Parse(property.PropertyType, valueString));
                });

                field.ValueChanged += (s, e) =>
                {
                    property.SetValue(Enum.Parse(property.PropertyType, field.Value));
                    object3D?.Invalidate(new InvalidateArgs(context.item, InvalidateType.Properties));
                    propertyGridModifier?.UpdateControls(new PublicPropertyChange(context, property.PropertyInfo.Name));
                };

                rowContainer = CreateSettingsRow(property, field, theme);
            }
            // Use known IObject3D editors
            else if (propertyValue is IObject3D item &&
                     ApplicationController.Instance.Extensions.GetEditorsForType(property.PropertyType)?.FirstOrDefault() is IObject3DEditor iObject3DEditor)
            {
                rowContainer = iObject3DEditor.Create(item, theme);
            }

            // remember the row name and widget
            context.editRows.Add(property.PropertyInfo.Name, rowContainer);

            return(rowContainer);
        }
        static SettingsProvider UIElementSettingsProvider()
        {
            var provider = new SettingsProvider("Project/Hierarchy", SettingsScope.Project)
            {
                label = "Hierarchy",

                activateHandler = (searchContext, rootElement) =>
                {
                    Editor editor   = Editor.CreateEditor(GetAssets());
                    var    settings = editor.target as HierarchySettings;

                    float TITLE_MARGIN_TOP    = 10;
                    float TITLE_MARGIN_BOTTOM = 4;
                    float CONTENT_MARGIN_LEFT = 10;

                    Label hierarchyTitle = new Label("Hierarchy");
                    hierarchyTitle.StyleFontSize(20);
                    hierarchyTitle.StyleMargin(10, 0, 2, 2);
                    hierarchyTitle.StyleFont(FontStyle.Bold);
                    rootElement.Add(hierarchyTitle);


                    ScrollView scrollView = new ScrollView();
                    rootElement.Add(scrollView);

                    VerticalLayout verticalLayout = new VerticalLayout();
                    verticalLayout.StylePadding(8, 8, 8, 8);
                    scrollView.Add(verticalLayout);

                    Label Object = new Label("Object");
                    Object.StyleFont(FontStyle.Bold);
                    Object.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(Object);

                    Hierarchy2.Toggle displayObjectIcon = new Hierarchy2.Toggle("Display Object Icon",
                                                                                settings.displayObjectIcon,
                                                                                Justify.FlexStart,
                                                                                (evt) =>
                    {
                        settings.displayObjectIcon = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayObjectIcon));
                    });
                    displayObjectIcon.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayObjectIcon);

                    Hierarchy2.Toggle displayCustomObjectIcon = new Hierarchy2.Toggle("Display Custom Icon",
                                                                                      settings.displayCustomObjectIcon,
                                                                                      Justify.FlexStart,
                                                                                      (evt) =>
                    {
                        settings.displayCustomObjectIcon = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayCustomObjectIcon));
                    });
                    displayCustomObjectIcon.StyleMarginLeft(CONTENT_MARGIN_LEFT * 2);
                    verticalLayout.Add(displayCustomObjectIcon);
                    displayCustomObjectIcon.StyleDisplay(settings.displayObjectIcon);
                    displayObjectIcon.RegisterValueChangedCallback((evt) =>
                    {
                        displayCustomObjectIcon.StyleDisplay(evt.newValue);
                    });

                    Hierarchy2.Toggle displayDirtyTrack = new Hierarchy2.Toggle("Display Dirty Track [EXPERIMENTAL]",
                                                                                settings.displayDirtyTrack,
                                                                                Justify.FlexStart,
                                                                                (evt) =>
                    {
                        settings.displayDirtyTrack = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayDirtyTrack));
                    });
                    displayDirtyTrack.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayDirtyTrack);

                    Label View = new Label("View");
                    View.StyleFont(FontStyle.Bold);
                    View.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(View);

                    Hierarchy2.Toggle displayRowBackground = new Hierarchy2.Toggle("Display RowBackground",
                                                                                   settings.displayRowBackground,
                                                                                   Justify.FlexStart,
                                                                                   (evt) =>
                    {
                        settings.displayRowBackground = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayRowBackground));
                    });
                    displayRowBackground.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayRowBackground);

                    Hierarchy2.Toggle displayTreeView = new Hierarchy2.Toggle("Display TreeView",
                                                                              settings.displayTreeView,
                                                                              Justify.FlexStart,
                                                                              (evt) =>
                    {
                        settings.displayTreeView = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayTreeView));
                    });
                    displayTreeView.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayTreeView);

                    Hierarchy2.Toggle displayGrid = new Hierarchy2.Toggle("Display Grid",
                                                                          settings.displayGrid,
                                                                          Justify.FlexStart,
                                                                          (evt) =>
                    {
                        settings.displayGrid = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayGrid));
                    });
                    displayGrid.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayGrid);

                    Label Components = new Label("Components");
                    Components.StyleFont(FontStyle.Bold);
                    Components.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(Components);

                    Hierarchy2.Toggle displayComponents = new Hierarchy2.Toggle("Display Components Icon",
                                                                                settings.displayComponents,
                                                                                Justify.FlexStart,
                                                                                (evt) =>
                    {
                        settings.displayComponents = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayComponents));
                    });
                    displayComponents.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayComponents);

                    EnumField componentAlignment = new EnumField(settings.componentAlignment);
                    componentAlignment.label = "Component Alignment";
                    componentAlignment.RegisterValueChangedCallback((evt) =>
                    {
                        settings.componentAlignment = (ElementAlignment)evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.componentAlignment));
                    });
                    componentAlignment.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(componentAlignment);

                    EnumField componentDisplayMode = new EnumField(settings.componentDisplayMode);
                    componentDisplayMode.label = "Component Display Mode";
                    componentDisplayMode.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(componentDisplayMode);

                    TextField componentListInput = new TextField();
                    componentListInput.value = string.Join(" ", settings.components);
                    componentListInput.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(componentListInput);
                    componentListInput.RegisterValueChangedCallback((evt) =>
                    {
                        settings.components = evt.newValue.Split(' ');
                        settings.OnSettingsChanged(nameof(settings.components));
                    });
                    componentDisplayMode.RegisterValueChangedCallback((evt) =>
                    {
                        settings.componentDisplayMode = (ComponentDisplayMode)evt.newValue;
                        switch (settings.componentDisplayMode)
                        {
                        case ComponentDisplayMode.Below:
                            componentListInput.StyleDisplay(true);
                            break;

                        case ComponentDisplayMode.Ignore:
                            componentListInput.StyleDisplay(true);
                            break;

                        case ComponentDisplayMode.All:
                            componentListInput.StyleDisplay(false);
                            break;

                        case ComponentDisplayMode.ScriptOnly:
                            componentListInput.StyleDisplay(false);
                            break;
                        }

                        settings.OnSettingsChanged(nameof(settings.componentDisplayMode));
                    });

                    var componentSizeEnum = ComponentSize.Normal;
                    switch (settings.componentSize)
                    {
                    case 12:
                        componentSizeEnum = ComponentSize.Small;
                        break;

                    case 14:
                        componentSizeEnum = ComponentSize.Normal;
                        break;

                    case 16:
                        componentSizeEnum = ComponentSize.Large;
                        break;
                    }

                    EnumField componentSize = new EnumField(componentSizeEnum);
                    componentSize.label = "Component Size";
                    componentSize.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    componentSize.RegisterValueChangedCallback((evt) =>
                    {
                        switch (evt.newValue)
                        {
                        case ComponentSize.Small:
                            settings.componentSize = 12;
                            break;

                        case ComponentSize.Normal:
                            settings.componentSize = 14;
                            break;

                        case ComponentSize.Large:
                            settings.componentSize = 16;
                            break;
                        }

                        settings.OnSettingsChanged(nameof(settings.componentSize));
                    });
                    verticalLayout.Add(componentSize);

                    IntegerField componentSpacing = new IntegerField();
                    componentSpacing.label = "Component Spacing";
                    componentSpacing.value = settings.componentSpacing;
                    componentSpacing.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    componentSpacing.RegisterValueChangedCallback((evt) =>
                    {
                        settings.componentSpacing = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.componentSpacing));
                    });
                    verticalLayout.Add(componentSpacing);

                    Label TagAndLayer = new Label("Tag And Layer");
                    TagAndLayer.StyleFont(FontStyle.Bold);
                    TagAndLayer.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(TagAndLayer);

                    Hierarchy2.Toggle displayTag = new Hierarchy2.Toggle("Display Tag",
                                                                         settings.displayTag,
                                                                         Justify.FlexStart,
                                                                         (evt) =>
                    {
                        settings.displayTag = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayTag));
                    });
                    displayTag.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayTag);

                    Hierarchy2.Toggle applyTagTargetAndChild = new Hierarchy2.Toggle(
                        "Apply Child Tag When Parent Tag Change",
                        settings.applyTagTargetAndChild,
                        Justify.FlexStart,
                        (evt) =>
                    {
                        settings.applyTagTargetAndChild = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.applyTagTargetAndChild));
                    });
                    applyTagTargetAndChild.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(applyTagTargetAndChild);

                    EnumField tagAlignment = new EnumField(settings.tagAlignment);
                    tagAlignment.label = "Tag Alignment";
                    tagAlignment.RegisterValueChangedCallback((evt) =>
                    {
                        settings.tagAlignment = (ElementAlignment)evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.tagAlignment));
                    });
                    tagAlignment.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(tagAlignment);

                    Hierarchy2.Toggle displayLayer = new Hierarchy2.Toggle("Display Layer",
                                                                           settings.displayLayer,
                                                                           Justify.FlexStart,
                                                                           (evt) =>
                    {
                        settings.displayLayer = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.displayLayer));
                    });
                    displayLayer.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(displayLayer);

                    Hierarchy2.Toggle applyLayerTargetAndChild = new Hierarchy2.Toggle(
                        "Apply Child Layer When Parent Layer Change",
                        settings.applyLayerTargetAndChild,
                        Justify.FlexStart,
                        (evt) =>
                    {
                        settings.applyLayerTargetAndChild = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.applyLayerTargetAndChild));
                    });
                    applyLayerTargetAndChild.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(applyLayerTargetAndChild);

                    EnumField layerAlignment = new EnumField(settings.layerAlignment);
                    layerAlignment.label = "Layer Alignment";
                    layerAlignment.RegisterValueChangedCallback((evt) =>
                    {
                        settings.layerAlignment = (ElementAlignment)evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.layerAlignment));
                    });
                    layerAlignment.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(layerAlignment);

                    Label advanced = new Label("Advanced");
                    advanced.StyleFont(FontStyle.Bold);
                    advanced.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(advanced);

                    Hierarchy2.Toggle onlyDisplayWhileMouseHovering = new Hierarchy2.Toggle(
                        "Only Display While Mouse Hovering",
                        settings.onlyDisplayWhileMouseEnter,
                        Justify.FlexStart,
                        (evt) =>
                    {
                        settings.onlyDisplayWhileMouseEnter = evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.onlyDisplayWhileMouseEnter));
                    });
                    onlyDisplayWhileMouseHovering.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                    verticalLayout.Add(onlyDisplayWhileMouseHovering);

                    EnumFlagsField contentMaskEnumFlags = new EnumFlagsField(settings.contentDisplay);
                    contentMaskEnumFlags.StyleDisplay(onlyDisplayWhileMouseHovering.value);
                    contentMaskEnumFlags.label = "Content Mask";
                    onlyDisplayWhileMouseHovering.RegisterValueChangedCallback((evt) =>
                    {
                        contentMaskEnumFlags.StyleDisplay(evt.newValue);
                    });
                    contentMaskEnumFlags.RegisterValueChangedCallback((evt) =>
                    {
                        settings.contentDisplay = (ContentDisplay)evt.newValue;
                        settings.OnSettingsChanged(nameof(settings.contentDisplay));
                    });
                    verticalLayout.Add(contentMaskEnumFlags);

                    Label Theme = new Label("Theme");
                    Theme.StyleFont(FontStyle.Bold);
                    Theme.StyleMargin(0, 0, TITLE_MARGIN_TOP, TITLE_MARGIN_BOTTOM);
                    verticalLayout.Add(Theme);

                    if (EditorApplication.isPlayingOrWillChangePlaymode)
                    {
                        EditorHelpBox themeWarningPlaymode =
                            new EditorHelpBox("This setting only available on edit mode.", MessageType.Info);
                        verticalLayout.Add(themeWarningPlaymode);
                    }
                    else
                    {
                        EditorHelpBox selectionColorHelpBox = new EditorHelpBox(
                            "Theme selection color require editor assembly recompile to take affect.\nBy selecting any script, right click -> Reimport. it will force the editor to recompile.",
                            MessageType.Info);
                        selectionColorHelpBox.StyleDisplay(false);
                        verticalLayout.Add(selectionColorHelpBox);

                        ColorField colorRowEven = new ColorField("Row Even");
                        colorRowEven.value = settings.usedTheme.colorRowEven;
                        colorRowEven.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorRowEven.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorRowEven = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorRowEven = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorRowEven);

                        ColorField colorRowOdd = new ColorField("Row Odd");
                        colorRowOdd.value = settings.usedTheme.colorRowOdd;
                        colorRowOdd.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorRowOdd.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorRowOdd = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorRowOdd = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorRowOdd);

                        ColorField colorGrid = new ColorField("Grid Color");
                        colorGrid.value = settings.usedTheme.colorGrid;
                        colorGrid.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorGrid.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorGrid = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorGrid = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorGrid);

                        ColorField colorTreeView = new ColorField("TreeView");
                        colorTreeView.value = settings.usedTheme.colorTreeView;
                        colorTreeView.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorTreeView.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorTreeView = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorTreeView = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorTreeView);

                        ColorField colorLockIcon = new ColorField("Lock Icon");
                        colorLockIcon.value = settings.usedTheme.colorLockIcon;
                        colorLockIcon.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorLockIcon.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorLockIcon = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorLockIcon = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorLockIcon);

                        ColorField tagColor = new ColorField("Tag Text");
                        tagColor.value = settings.usedTheme.tagColor;
                        tagColor.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        tagColor.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.tagColor = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.tagColor = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(tagColor);

                        ColorField layerColor = new ColorField("Layer Text");
                        layerColor.value = settings.usedTheme.layerColor;
                        layerColor.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        layerColor.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.layerColor = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.layerColor = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(layerColor);

                        ColorField colorHeaderTitle = new ColorField("Header Title");
                        colorHeaderTitle.value = settings.usedTheme.colorHeaderTitle;
                        colorHeaderTitle.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorHeaderTitle.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorHeaderTitle = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorHeaderTitle = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorHeaderTitle);

                        ColorField colorHeaderBackground = new ColorField("Header Background");
                        colorHeaderBackground.value = settings.usedTheme.colorHeaderBackground;
                        colorHeaderBackground.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        colorHeaderBackground.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.colorHeaderBackground = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.colorHeaderBackground = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(colorHeaderBackground);

                        ColorField comSelBGColor = new ColorField("Component Selection");
                        comSelBGColor.value = settings.usedTheme.comSelBGColor;
                        comSelBGColor.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        comSelBGColor.RegisterValueChangedCallback((evt) =>
                        {
                            if (EditorGUIUtility.isProSkin)
                            {
                                settings.professionalTheme.comSelBGColor = evt.newValue;
                            }
                            else
                            {
                                settings.personalTheme.comSelBGColor = evt.newValue;
                            }

                            settings.OnSettingsChanged();
                        });
                        verticalLayout.Add(comSelBGColor);

                        // ColorField selectionColor = new ColorField("Selection");
                        // selectionColor.value = settings.usedTheme.selectionColor;
                        // selectionColor.StyleMarginLeft(CONTENT_MARGIN_LEFT);
                        // selectionColor.RegisterValueChangedCallback((evt) =>
                        // {
                        //     if (EditorGUIUtility.isProSkin)
                        //         settings.professionalTheme.selectionColor = evt.newValue;
                        //     else
                        //         settings.personalTheme.selectionColor = evt.newValue;
                        //
                        //     selectionColorHelpBox.StyleDisplay(true);
                        //     settings.OnSettingsChanged();
                        // });
                        // verticalLayout.Add(selectionColor);
                    }
                },

                keywords = new HashSet <string>(new[] { "Hierarchy" })
            };

            return(provider);
        }
        private void BuildUI()
        {
            menuItemNew      = new MenuItem();
            menuItemNew.Id   = "menuItemNew";
            menuItemNew.Text = "New";

            menuItemOpen      = new MenuItem();
            menuItemOpen.Id   = "menuItemOpen";
            menuItemOpen.Text = "Open...";

            menuItemSave      = new MenuItem();
            menuItemSave.Id   = "menuItemSave";
            menuItemSave.Text = "Save";

            menuItemSaveAs      = new MenuItem();
            menuItemSaveAs.Id   = "menuItemSaveAs";
            menuItemSaveAs.Text = "Save As...";

            var menuSeparator1 = new MenuSeparator();

            menuItemQuit      = new MenuItem();
            menuItemQuit.Id   = "menuItemQuit";
            menuItemQuit.Text = "Quit";

            menuItemFile      = new MenuItem();
            menuItemFile.Id   = "menuItemFile";
            menuItemFile.Text = "File";
            menuItemFile.Items.Add(menuItemNew);
            menuItemFile.Items.Add(menuItemOpen);
            menuItemFile.Items.Add(menuItemSave);
            menuItemFile.Items.Add(menuItemSaveAs);
            menuItemFile.Items.Add(menuSeparator1);
            menuItemFile.Items.Add(menuItemQuit);

            menuItemAbout      = new MenuItem();
            menuItemAbout.Id   = "menuItemAbout";
            menuItemAbout.Text = "About";

            menuItemHelp      = new MenuItem();
            menuItemHelp.Id   = "menuItemHelp";
            menuItemHelp.Text = "Help";
            menuItemHelp.Items.Add(menuItemAbout);

            mainMenu = new HorizontalMenu();
            mainMenu.DrawLinesColor      = Color.White;
            mainMenu.Id                  = "mainMenu";
            mainMenu.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            mainMenu.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            mainMenu.Items.Add(menuItemFile);
            mainMenu.Items.Add(menuItemHelp);

            textArea                   = new TextField();
            textArea.Text              = "";
            textArea.TextColor         = Color.White;
            textArea.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            textArea.MessageTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            textArea.Multiline           = true;
            textArea.Id                  = "textArea";
            textArea.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            textArea.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            textArea.CanFocus            = true;

            var scrollPane1 = new ScrollPane();

            scrollPane1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            scrollPane1.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            scrollPane1.GridPositionY       = 1;
            scrollPane1.ClipToBounds        = true;
            scrollPane1.CanFocus            = true;
            scrollPane1.Child = textArea;


            DrawLinesColor = Color.White;
            RowsProportions.Add(new Proportion());
            RowsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.Grid.ProportionType.Fill,
            });
            Id = "Root";
            HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            Widgets.Add(mainMenu);
            Widgets.Add(scrollPane1);
        }
Exemple #26
0
    void InitTileSetGenerator(VisualElement root)
    {
        tileSetSpriteFolderPathField = root.Query <TextField>("tile-set-sprite-folder-path-field").First();
        tileRuleJsonPathField        = root.Query <TextField>("tile-rule-json-path-field").First();

        loadTileSetSpriteButton = root.Query <Button>("load-tile-set-sprite-folder-button").First();
        loadTileRuleJsonButton  = root.Query <Button>("load-tile-rule-json-button").First();
        autoGenerateButton      = root.Query <Button>("auto-generate-button").First();

        buildJsonFormatButton = root.Query <Button>("build-format-button").First();

        loadTileSetSpriteButton.clickable.clicked += () =>
        {
            var spritesFolderAbsolutePath = EditorUtility.OpenFolderPanel("Open Sprite Folder", "", "");
            var relativePath = Path.ConvertAbsoluteToUnityRelativePath(spritesFolderAbsolutePath);

            tileSetSpriteFolderPathField.value = relativePath;
        };

        loadTileRuleJsonButton.clickable.clicked += () =>
        {
            var jsonFileAbsolutePath = EditorUtility.OpenFilePanel("Open Json Rule", "", "json");
            var relativePath         = Path.ConvertAbsoluteToUnityRelativePath(jsonFileAbsolutePath);
            if (System.IO.Path.GetExtension(relativePath) != ".json")
            {
                Debug.LogError("Json 형식이 아닙니다");
                return;
            }

            tileRuleJsonPathField.value = relativePath;
        };

        autoGenerateButton.clickable.clicked += () =>
        {
            var tileSet = AutoTileRuleGenerator.Genearte(tileSetSpriteFolderPathField.value, tileRuleJsonPathField.value);
            if (tileSet == null)
            {
                return;
            }

            var absoluteSavePath = EditorUtility.SaveFilePanel("Save TileSet", Application.dataPath, "NewTileSet", TILE_SET_EXTENTION);
            var relativeSavePath = Path.ConvertAbsoluteToUnityRelativePath(absoluteSavePath);
            if (string.IsNullOrEmpty(relativeSavePath))
            {
                return;
            }

            AssetDatabase.CreateAsset(tileSet, relativeSavePath);
            EditorUtility.DisplayDialog("SucessMessage", "생성 완료", "OK");
        };

        buildJsonFormatButton.clickable.clicked += () =>
        {
            var absoluteSavePath = EditorUtility.SaveFilePanel("Save Rule", Application.dataPath, "NewJsonRule", "json");
            if (string.IsNullOrEmpty(absoluteSavePath))
            {
                return;
            }

            AutoTileRuleGenerator.SaveJsonFormat(absoluteSavePath);
            EditorUtility.DisplayDialog("SucessMessage", "생성 완료", "OK");
        };
    }
 private void CommitNewEvent(TextField textField)
 {
     base.Close();
 }
Exemple #28
0
        private void BuildUI()
        {
            var textBlock1 = new TextBlock();

            textBlock1.Text              = "Class Name:";
            textBlock1.TextColor         = Color.White;
            textBlock1.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            textBlock1.Id            = "";
            textBlock1.GridPositionY = 1;

            _textClassName                   = new TextField();
            _textClassName.Text              = "";
            _textClassName.TextColor         = Color.White;
            _textClassName.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textClassName.MessageTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textClassName.Id = "_textClassName";
            _textClassName.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _textClassName.GridPositionX       = 1;
            _textClassName.GridPositionY       = 1;
            _textClassName.CanFocus            = true;

            var textBlock2 = new TextBlock();

            textBlock2.Text              = "Output Path:";
            textBlock2.TextColor         = Color.White;
            textBlock2.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            textBlock2.GridPositionY = 2;

            _textOutputPath                   = new TextField();
            _textOutputPath.Text              = "";
            _textOutputPath.TextColor         = Color.White;
            _textOutputPath.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textOutputPath.MessageTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textOutputPath.Id = "_textOutputPath";
            _textOutputPath.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _textOutputPath.GridPositionX       = 1;
            _textOutputPath.GridPositionY       = 2;
            _textOutputPath.CanFocus            = true;

            _buttonChangeOutputPath           = new Button();
            _buttonChangeOutputPath.Text      = "Change...";
            _buttonChangeOutputPath.TextColor = Color.White;
            _buttonChangeOutputPath.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _buttonChangeOutputPath.ContentVerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _buttonChangeOutputPath.Id            = "_buttonChangeOutputPath";
            _buttonChangeOutputPath.GridPositionX = 2;
            _buttonChangeOutputPath.GridPositionY = 2;

            var textBlock3 = new TextBlock();

            textBlock3.Text              = "Namespace:";
            textBlock3.TextColor         = Color.White;
            textBlock3.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };

            _textNamespace                   = new TextField();
            _textNamespace.Text              = "";
            _textNamespace.TextColor         = Color.White;
            _textNamespace.DisabledTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textNamespace.MessageTextColor = new Color
            {
                B           = 170,
                G           = 170,
                R           = 170,
                A           = 255,
                PackedValue = 4289374890,
            };
            _textNamespace.Id = "_textNamespace";
            _textNamespace.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _textNamespace.GridPositionX       = 1;
            _textNamespace.CanFocus            = true;


            DrawLinesColor = Color.White;
            ColumnSpacing  = 8;
            RowSpacing     = 8;
            ColumnsProportions.Add(new Proportion());
            ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.Grid.ProportionType.Fill,
            });
            ColumnsProportions.Add(new Proportion());
            RowsProportions.Add(new Proportion());
            RowsProportions.Add(new Proportion());
            RowsProportions.Add(new Proportion());
            Id                  = "Root";
            WidthHint           = 800;
            HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            Widgets.Add(textBlock1);
            Widgets.Add(_textClassName);
            Widgets.Add(textBlock2);
            Widgets.Add(_textOutputPath);
            Widgets.Add(_buttonChangeOutputPath);
            Widgets.Add(textBlock3);
            Widgets.Add(_textNamespace);
        }
Exemple #29
0
    private void SetupControls()
    {
        var expandButton = new Button {Text = GetCollapsedButtonString(), LayoutOptions = new[] {GUILayout.Width(30)}};
        expandButton.Clicked = () =>
                                   {
                                       _collapsed = !_collapsed;
                                       expandButton.Text = GetCollapsedButtonString();
                                   };
        var supersampleAmount = new TextField<int>
                                    {
                                        Value = _settings.SupersampleAmount,
                                        Caption = "    Supersample: ",
                                        Validator = x => x > 0
                                    };
        var screenshotButton = new Button
                                   {
                                       Text = "Screenshot",
                                       LayoutOptions = new[] {GUILayout.Width(85)},
                                       Clicked = () => Screenshot()
                                   };
        _screenshotToggle = new ToggleButton
                                   {
                                       Caption = "Screenshot",
                                       Visible = false,
                                       LayoutOptions = new[] {GUILayout.Width(85)},
                                       OnToggled = x => Screenshot()
                                   };

        var toggleAutoHideUI = new Toggle
                                   {
                                       Caption = "             Autohide UI: ",
                                       Value = _settings.AutoHideUI,
                                       OnToggled = x =>
                                                       {
                                                           _settings.AutoHideUI = x;
                                                           _settings.Save();
                                                       }
                                   };

        var autoIntervalAmount = new TextField<int>
                                     {
                                         Value = _settings.AutoIntervalDelayInSeconds,
                                         Caption = "               Interval: ",
                                         Validator = x => x > 0
                                     };

        var toggleAutoInterval = new Toggle
                                     {
                                         Caption = "           Auto Interval: ",
                                         Value = _autoIntervalEnabled,
                                         OnToggled = x =>
                                                         {
                                                             _autoIntervalEnabled = x;

                                                             screenshotButton.Visible = !x;
                                                             _screenshotToggle.Visible = x;

                                                             if (!x)
                                                             {
                                                                 _screenshotToggle.Value = false;
                                                                 _autoIntervalStopwatch.Reset();
                                                             }
                                                         }
                                     };

        var setButton = new SetButton
                            {
                                LayoutOptions = new[] {GUILayout.Height(25)},
                                SettableObjects = new List<ISettable> {supersampleAmount, autoIntervalAmount},
                                Clicked = () =>
                                              {
                                                  _settings.SupersampleAmount = supersampleAmount.Value;
                                                  _settings.AutoIntervalDelayInSeconds = autoIntervalAmount.Value;
                                                  _settings.Save();
                                              }
                            };

        _expandedControls = new List<AControl>
                                {
                                    new BeginVertical(),
                                    new BeginHorizontal(),
                                    screenshotButton,
                                    _screenshotToggle,
                                    expandButton,
                                    new EndHorizontal(),
                                    toggleAutoHideUI,
                                    toggleAutoInterval,
                                    new BeginVertical(true),
                                    supersampleAmount,
                                    autoIntervalAmount,
                                    setButton,
                                    new EndVertical(),
                                    new EndVertical()
                                };

        _collapsedControls = new List<AControl>
                                 {
                                     new BeginHorizontal(),
                                     screenshotButton,
                                     expandButton,
                                     new EndHorizontal()
                                 };

        _expandedLayoutOptions = new[] {GUILayout.Width(180), GUILayout.ExpandHeight(true)};
        _collapsedLayoutOptions = new[] {GUILayout.Width(120), GUILayout.Height(60)};
    }
Exemple #30
0
        public FileDialog(ustring title, ustring prompt, ustring nameFieldLabel, ustring message) : base(title, Driver.Cols - 20, Driver.Rows - 5, null)
        {
            this.message = new Label(Rect.Empty, "MESSAGE" + message);
            var msgLines = Label.MeasureLines(message, Driver.Cols - 20);

            dirLabel = new Label("Directory: ")
            {
                X = 1,
                Y = 1 + msgLines
            };

            dirEntry = new TextField("")
            {
                X     = Pos.Right(dirLabel),
                Y     = 1 + msgLines,
                Width = Dim.Fill() - 1
            };
            Add(dirLabel, dirEntry);

            this.nameFieldLabel = new Label("Open: ")
            {
                X = 6,
                Y = 3 + msgLines,
            };
            nameEntry = new TextField("")
            {
                X     = Pos.Left(dirEntry),
                Y     = 3 + msgLines,
                Width = Dim.Fill() - 1
            };
            Add(this.nameFieldLabel, nameEntry);

            dirListView = new DirListView()
            {
                X      = 1,
                Y      = 3 + msgLines + 2,
                Width  = Dim.Fill() - 2,
                Height = Dim.Fill() - 2,
            };
            DirectoryPath = Path.GetFullPath(Environment.CurrentDirectory);
            Add(dirListView);
            dirListView.DirectoryChanged = (dir) => dirEntry.Text = dir;
            dirListView.FileChanged      = (file) => {
                nameEntry.Text = file;
            };

            this.cancel          = new Button("Cancel");
            this.cancel.Clicked += () => {
                canceled = true;
                Application.RequestStop();
            };
            AddButton(cancel);

            this.prompt = new Button(prompt)
            {
                IsDefault = true,
            };
            this.prompt.Clicked += () => {
                canceled = false;
                Application.RequestStop();
            };
            AddButton(this.prompt);

            // On success, we will set this to false.
            canceled = true;
        }
Exemple #31
0
        public override void Setup()
        {
            const int margin = 1;

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_Файл", new MenuItem [] {
                    new MenuItem("_Создать", "Creates new file", null),
                    new MenuItem("_Открыть", "", null),
                    new MenuItem("Со_хранить", "", null),
                    new MenuItem("_Выход", "", () => Application.RequestStop())
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", null),
                    new MenuItem("C_ut", "", null),
                    new MenuItem("_Paste", "", null)
                })
            });

            Top.Add(menu);

            var label = new Label("Button:")
            {
                X = margin, Y = margin
            };

            Win.Add(label);
            var button = new Button(" ~  s  gui.cs   master ↑10")
            {
                X = 15, Y = Pos.Y(label)
            };

            Win.Add(button);

            label = new Label("Button:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var button2 = new Button("Со_хранить")
            {
                X = 15, Y = Pos.Y(label), Width = Dim.Percent(50)
            };

            Win.Add(button2);

            label = new Label("CheckBox:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var checkBox = new CheckBox(" ~  s  gui.cs   master ↑10")
            {
                X = 15, Y = Pos.Y(label), Width = Dim.Percent(50)
            };

            Win.Add(checkBox);

            label = new Label("ComboBox:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var comboBox = new ComboBox(1, 1, 30, 5, new List <string> ()
            {
                "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить"
            })
            {
                X           = 15,
                Y           = Pos.Y(label),
                Width       = 30,
                ColorScheme = Colors.Error
            };

            Win.Add(comboBox);
            comboBox.Text = " ~  s  gui.cs   master ↑10";

            label = new Label("HexView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 2
            };
            Win.Add(label);
            var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(" ~  s  gui.cs   master ↑10 Со_хранить")))
            {
                X      = 15,
                Y      = Pos.Y(label),
                Width  = Dim.Percent(60),
                Height = 5
            };

            Win.Add(hexView);

            label = new Label("ListView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(hexView) + 1
            };
            Win.Add(label);
            var listView = new ListView(new List <string> ()
            {
                "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить"
            })
            {
                X           = 15,
                Y           = Pos.Y(label),
                Width       = Dim.Percent(60),
                Height      = 3,
                ColorScheme = Colors.Menu
            };

            Win.Add(listView);

            label = new Label("RadioGroup:")
            {
                X = Pos.X(label), Y = Pos.Bottom(listView) + 1
            };
            Win.Add(label);
            var radioGroup = new RadioGroup(new [] { "item #1", " ~  s  gui.cs   master ↑10", "Со_хранить" }, selected: 0)
            {
                X           = 15,
                Y           = Pos.Y(label),
                Width       = Dim.Percent(60),
                ColorScheme = Colors.Menu
            };

            Win.Add(radioGroup);

            label = new Label("TextField:")
            {
                X = Pos.X(label), Y = Pos.Bottom(radioGroup) + 1
            };
            Win.Add(label);
            var textField = new TextField(" ~  s  gui.cs   master ↑10 = Со_хранить")
            {
                X = 15, Y = Pos.Y(label), Width = Dim.Percent(60)
            };

            Win.Add(textField);

            label = new Label("TextView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(textField) + 1
            };
            Win.Add(label);
            var textView = new TextView()
            {
                X           = 15,
                Y           = Pos.Y(label),
                Width       = Dim.Percent(60),
                Height      = 3,
                ColorScheme = Colors.Menu,
                Text        = " ~  s  gui.cs   master ↑10\nСо_хранить",
            };

            Win.Add(textView);

            //label = new Label ("Charset:") {
            //	X = Pos.Percent(75) + 1,
            //	Y = 0,
            //};
            //Win.Add (label);
            //var charset = new Label ("") {
            //	X = Pos.Percent(75) + 1,
            //	Y = Pos.Y (label) + 1,
            //	Width = Dim.Fill (1),
            //	Height = Dim.Fill (),
            //	ColorScheme = Colors.Dialog
            //};
            //Win.Add (charset);

            // Move Win down to row 1, below menu
            Win.Y = 1;
            Top.LayoutSubviews();
        }
Exemple #32
0
    static void ShowEntries(View container)
    {
        var scrollView = new ScrollView(new Rect(50, 10, 20, 8))
        {
            ContentSize = new Size(20, 50),
            //ContentOffset = new Point (0, 0),
            ShowVerticalScrollIndicator   = true,
            ShowHorizontalScrollIndicator = true
        };

#if false
        scrollView.Add(new Box10x(0, 0));
#else
        var filler = new Filler(new Rect(0, 0, 40, 40));
        scrollView.Add(filler);
        scrollView.DrawContent = (r) => {
            scrollView.ContentSize = filler.GetContentSize();
        };
#endif

        // This is just to debug the visuals of the scrollview when small
        var scrollView2 = new ScrollView(new Rect(72, 10, 3, 3))
        {
            ContentSize = new Size(100, 100),
            ShowVerticalScrollIndicator   = true,
            ShowHorizontalScrollIndicator = true
        };
        scrollView2.Add(new Box10x(0, 0));
        var progress = new ProgressBar(new Rect(68, 1, 10, 1));
        bool timer(MainLoop caller)
        {
            progress.Pulse();
            return(true);
        }

        Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(300), timer);


        // A little convoluted, this is because I am using this to test the
        // layout based on referencing elements of another view:

        var login = new Label("Login: "******"Password: "******"")
        {
            X     = Pos.Right(password),
            Y     = Pos.Top(login),
            Width = 40
        };

        var passText = new TextField("")
        {
            Secret = true,
            X      = Pos.Left(loginText),
            Y      = Pos.Top(password),
            Width  = Dim.Width(loginText)
        };

        var tf = new Button(3, 19, "Ok");
        // Add some content
        container.Add(
            login,
            loginText,
            password,
            passText,
            new FrameView(new Rect(3, 10, 25, 6), "Options")
        {
            new CheckBox(1, 0, "Remember me"),
            new RadioGroup(1, 2, new ustring [] { "_Personal", "_Company" }),
        },
            new ListView(new Rect(59, 6, 16, 4), new string [] {
            "First row",
            "<>",
            "This is a very long row that should overflow what is shown",
            "4th",
            "There is an empty slot on the second row",
            "Whoa",
            "This is so cool"
        }),
            scrollView,
            scrollView2,
            tf,
            new Button(10, 19, "Cancel"),
            new TimeField(3, 20, DateTime.Now.TimeOfDay),
            new TimeField(23, 20, DateTime.Now.TimeOfDay, true),
            new DateField(3, 22, DateTime.Now),
            new DateField(23, 22, DateTime.Now, true),
            progress,
            new Label(3, 24, "Press F9 (on Unix, ESC+9 is an alias) or Ctrl+T to activate the menubar"),
            menuKeysStyle,
            menuAutoMouseNav

            );
        container.SendSubviewToBack(tf);
    }
Exemple #33
0
        private void FillSubGrid(ref int y, IReadOnlyList <Record> records)
        {
            for (var i = 0; i < records.Count; ++i)
            {
                var record = records[i];

                var hasSetter = record.HasSetter;
                if (_parentProperty != null && !_parentProperty.HasSetter)
                {
                    hasSetter = false;
                }

                var    value       = record.GetValue(_object);
                Widget valueWidget = null;

                var oldY = y;

                var propertyType = record.Type;

                Proportion rowProportion;
                if (record.ItemsProvider != null)
                {
                    var values = record.ItemsProvider.Items;

                    var cb = new ComboBox();
                    foreach (var v in values)
                    {
                        cb.Items.Add(new ListItem(v.ToString(), null, v));
                    }


                    cb.SelectedIndex = Array.IndexOf(values, value);
                    if (hasSetter)
                    {
                        cb.SelectedIndexChanged += (sender, args) =>
                        {
                            var item = cb.SelectedItem != null ? values[cb.SelectedIndex] : null;
                            record.SetValue(_object, item);
                            FireChanged(propertyType.Name);
                        };
                    }
                    else
                    {
                        cb.Enabled = false;
                    }

                    valueWidget = cb;
                }
                else if (propertyType == typeof(bool))
                {
                    var isChecked = (bool)value;
                    var cb        = new CheckBox
                    {
                        IsPressed = isChecked
                    };

                    if (hasSetter)
                    {
                        cb.Down += (sender, args) =>
                        {
                            record.SetValue(_object, true);
                            FireChanged(propertyType.Name);
                        };

                        cb.Up += (sender, args) =>
                        {
                            record.SetValue(_object, false);
                            FireChanged(propertyType.Name);
                        };
                    }
                    else
                    {
                        cb.Enabled = false;
                    }

                    valueWidget = cb;
                }
                else if (propertyType == typeof(Color) || propertyType == typeof(Color?))
                {
                    var subGrid = new Grid
                    {
                        ColumnSpacing       = 8,
                        HorizontalAlignment = HorizontalAlignment.Stretch
                    };

                    var isColor = propertyType == typeof(Color);

                    subGrid.ColumnsProportions.Add(new Proportion());
                    subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));

                    var color = Color.Transparent;
                    if (isColor)
                    {
                        color = (Color)value;
                    }
                    else if (value != null)
                    {
                        color = ((Color?)value).Value;
                    }

                    var image = new Image
                    {
                        TextureRegion2D   = DefaultAssets.WhiteRegion,
                        Color             = color,
                        VerticalAlignment = VerticalAlignment.Center,
                        WidthHint         = 32,
                        HeightHint        = 16
                    };

                    subGrid.Widgets.Add(image);

                    var button = new Button
                    {
                        Text = "Change...",
                        ContentHorizontalAlignment = HorizontalAlignment.Center,
                        Tag = value,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        GridPositionX       = 1
                    };

                    subGrid.Widgets.Add(button);

                    if (hasSetter)
                    {
                        button.Up += (sender, args) =>
                        {
                            var h = ColorChangeHandler;
                            if (h != null)
                            {
                                var newColor = h(image.Color);
                                if (!newColor.HasValue)
                                {
                                    return;
                                }

                                image.Color = newColor.Value;

                                if (isColor)
                                {
                                    record.SetValue(_object, newColor.Value);
                                }
                                else
                                {
                                    record.SetValue(_object, newColor);
                                }

                                FireChanged(propertyType.Name);
                            }
                        };
                    }
                    else
                    {
                        button.Enabled = false;
                    }

                    valueWidget = subGrid;
                }
                else if (propertyType.IsAssignableFrom(typeof(TextureRegion2D)))
                {
                }
                else if (propertyType.IsEnum)
                {
                    var values = Enum.GetValues(propertyType);

                    var cb = new ComboBox();
                    foreach (var v in values)
                    {
                        cb.Items.Add(new ListItem(v.ToString(), null, v));
                    }

                    cb.SelectedIndex = Array.IndexOf(values, value);

                    if (hasSetter)
                    {
                        cb.SelectedIndexChanged += (sender, args) =>
                        {
                            if (cb.SelectedIndex != -1)
                            {
                                record.SetValue(_object, cb.SelectedIndex);
                                FireChanged(propertyType.Name);
                            }
                        };
                    }
                    else
                    {
                        cb.Enabled = false;
                    }

                    valueWidget = cb;
                }
                else if (propertyType.IsNumericType() ||
                         (propertyType.IsNullablePrimitive() && propertyType.GetNullableType().IsNumericType()))
                {
                    var numericType = propertyType;
                    if (propertyType.IsNullablePrimitive())
                    {
                        numericType = propertyType.GetNullableType();
                    }

                    var spinButton = new SpinButton
                    {
                        Integer  = numericType.IsNumericInteger(),
                        Nullable = propertyType.IsNullablePrimitive(),
                        Value    = value != null ? (float)Convert.ChangeType(value, typeof(float)) : default(float?)
                    };

                    if (hasSetter)
                    {
                        spinButton.ValueChanged += (sender, args) =>
                        {
                            try
                            {
                                object result;

                                if (spinButton.Value != null)
                                {
                                    result = Convert.ChangeType(spinButton.Value.Value, numericType);
                                }
                                else
                                {
                                    result = null;
                                }

                                record.SetValue(_object, result);

                                if (record.Type.IsValueType)
                                {
                                    var tg = this;
                                    var pg = tg._parentGrid;
                                    while (pg != null && tg._parentProperty != null)
                                    {
                                        tg._parentProperty.SetValue(pg._object, tg._object);

                                        if (!tg._parentProperty.Type.IsValueType)
                                        {
                                            break;
                                        }

                                        tg = pg;
                                        pg = tg._parentGrid;
                                    }
                                }

                                FireChanged(record.Name);
                            }
                            catch (Exception)
                            {
                                // TODO: Rework this ugly type conversion solution
                            }
                        };
                    }
                    else
                    {
                        spinButton.Enabled = false;
                    }

                    valueWidget = spinButton;
                }
                else if (propertyType == typeof(string) || propertyType.IsPrimitive || propertyType.IsNullablePrimitive())
                {
                    var tf = new TextField
                    {
                        Text = value != null?value.ToString() : string.Empty
                    };

                    if (hasSetter)
                    {
                        tf.TextChanged += (sender, args) =>
                        {
                            try
                            {
                                object result;

                                if (propertyType.IsNullablePrimitive())
                                {
                                    if (string.IsNullOrEmpty(tf.Text))
                                    {
                                        result = null;
                                    }
                                    else
                                    {
                                        result = Convert.ChangeType(tf.Text, record.Type.GetNullableType());
                                    }
                                }
                                else
                                {
                                    result = Convert.ChangeType(tf.Text, record.Type);
                                }

                                record.SetValue(_object, result);

                                if (record.Type.IsValueType)
                                {
                                    var tg = this;
                                    var pg = tg._parentGrid;
                                    while (pg != null && tg._parentProperty != null)
                                    {
                                        tg._parentProperty.SetValue(pg._object, tg._object);

                                        if (!tg._parentProperty.Type.IsValueType)
                                        {
                                            break;
                                        }

                                        tg = pg;
                                        pg = tg._parentGrid;
                                    }
                                }

                                FireChanged(record.Name);
                            }
                            catch (Exception)
                            {
                                // TODO: Rework this ugly type conversion solution
                            }
                        };
                    }
                    else
                    {
                        tf.Enabled = false;
                    }

                    valueWidget = tf;
                }
                else if (typeof(IList).IsAssignableFrom(propertyType))
                {
                    var it = propertyType.FindGenericType(typeof(ICollection <>));
                    if (it != null)
                    {
                        var itemType = it.GenericTypeArguments[0];
                        if (value != null)
                        {
                            var items = (IList)value;

                            var subGrid = new Grid
                            {
                                ColumnSpacing       = 8,
                                HorizontalAlignment = HorizontalAlignment.Stretch
                            };

                            subGrid.ColumnsProportions.Add(new Proportion());
                            subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill));

                            var label = new TextBlock
                            {
                                VerticalAlignment = VerticalAlignment.Center,
                            };
                            UpdateLabelCount(label, items.Count);

                            subGrid.Widgets.Add(label);

                            var button = new Button
                            {
                                Text = "Change...",
                                ContentHorizontalAlignment = HorizontalAlignment.Center,
                                Tag = value,
                                HorizontalAlignment = HorizontalAlignment.Stretch,
                                GridPositionX       = 1
                            };

                            button.Up += (sender, args) =>
                            {
                                var collectionEditor = new CollectionEditor(items, itemType)
                                {
                                    ColorChangeHandler = ColorChangeHandler
                                };

                                var dialog = Dialog.CreateMessageBox("Edit", collectionEditor);

                                dialog.ButtonOk.Up += (o, eventArgs) =>
                                {
                                    collectionEditor.SaveChanges();
                                    UpdateLabelCount(label, items.Count);
                                };

                                dialog.ShowModal(Desktop);
                            };

                            subGrid.Widgets.Add(button);
                            valueWidget = subGrid;
                        }
                    }
                }
                else if (!(value is BitmapFont) && !(value is TextureRegion2D))
                {
                    // Subgrid
                    if (value != null)
                    {
                        var subGrid = new SubGrid(this, value, record.Name, DefaultCategoryName, record)
                        {
                            GridSpanX     = 2,
                            GridPositionY = y
                        };

                        Widgets.Add(subGrid);

                        rowProportion = new Proportion(ProportionType.Auto);
                        RowsProportions.Add(rowProportion);
                        ++y;

                        continue;
                    }

                    var tb = new TextBlock();
                    tb.ApplyTextBlockStyle(PropertyGridStyle.LabelStyle);
                    tb.Text = "null";

                    valueWidget = tb;
                }

                if (valueWidget == null)
                {
                    continue;
                }

                var nameLabel = new TextBlock
                {
                    Text = record.Name,
                    VerticalAlignment = VerticalAlignment.Center,
                    GridPositionX     = 0,
                    GridPositionY     = oldY
                };

                Widgets.Add(nameLabel);

                valueWidget.GridPositionX       = 1;
                valueWidget.GridPositionY       = oldY;
                valueWidget.HorizontalAlignment = HorizontalAlignment.Stretch;
                valueWidget.VerticalAlignment   = VerticalAlignment.Top;

                Widgets.Add(valueWidget);

                rowProportion = new Proportion(ProportionType.Auto);
                RowsProportions.Add(rowProportion);
                ++y;
            }
        }
        protected override void UpdateContents()
        {
            if (Node == null)
            {
                return;
            }

            foreach (var constraint in constraints)
            {
                constraint.Active = false;
                constraint.Dispose();
            }
            constraints.Clear();

            bool   selected           = Superview is NSTableRowView rowView && rowView.Selected;
            var    editable           = TreeView.GetCanEditNode(Node);
            var    textColor          = NSColor.ControlText;
            string evaluateStatusIcon = null;
            string valueButtonText    = null;
            var    showViewerButton   = false;
            Color? previewColor       = null;
            bool   showSpinner        = false;
            string strval;

            if (Node.IsUnknown)
            {
                if (TreeView.DebuggerService.Frame != null)
                {
                    strval = GettextCatalog.GetString("The name '{0}' does not exist in the current context.", Node.Name);
                }
                else
                {
                    strval = string.Empty;
                }
                evaluateStatusIcon = Ide.Gui.Stock.Warning;
            }
            else if (Node.IsError || Node.IsNotSupported)
            {
                evaluateStatusIcon = Ide.Gui.Stock.Warning;
                strval             = Node.Value ?? string.Empty;
                int i = strval.IndexOf('\n');
                if (i != -1)
                {
                    strval = strval.Substring(0, i);
                }
                textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueErrorText));
            }
            else if (Node.IsImplicitNotSupported)
            {
                strval    = string.Empty;             //val.Value; with new "Show Value" button we don't want to display message "Implicit evaluation is disabled"
                textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
                if (Node.CanRefresh)
                {
                    valueButtonText = GettextCatalog.GetString("Show Value");
                }
            }
            else if (Node.IsEvaluating)
            {
                strval      = GettextCatalog.GetString("Evaluating\u2026");
                showSpinner = true;

                textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
            }
            else if (Node.IsEnumerable)
            {
                if (Node is ShowMoreValuesObjectValueNode)
                {
                    valueButtonText = GettextCatalog.GetString("Show More");
                }
                else
                {
                    valueButtonText = GettextCatalog.GetString("Show Values");
                }
                strval = string.Empty;
            }
            else if (Node is AddNewExpressionObjectValueNode)
            {
                strval   = string.Empty;
                editable = false;
            }
            else
            {
                strval = TreeView.Controller.GetDisplayValueWithVisualisers(Node, out showViewerButton);

                if (TreeView.Controller.GetNodeHasChangedSinceLastCheckpoint(Node))
                {
                    textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueModifiedText));
                }

                var val = Node.GetDebuggerObjectValue();
                if (val != null && !val.IsNull && DebuggingService.HasGetConverter <Color> (val))
                {
                    try {
                        previewColor = DebuggingService.GetGetConverter <Color> (val).GetValue(val);
                    } catch {
                        previewColor = null;
                    }
                }
            }

            strval = strval.Replace("\r\n", " ").Replace("\n", " ");

            var views = new List <NSView> ();

            OptimalWidth = MarginSize;

            // First item: Status Icon -or- Spinner
            if (evaluateStatusIcon != null)
            {
                statusIcon.Image = GetImage(evaluateStatusIcon, Gtk.IconSize.Menu, selected);

                if (!statusIconVisible)
                {
                    AddSubview(statusIcon);
                    statusIconVisible = true;
                }

                constraints.Add(statusIcon.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(statusIcon.WidthAnchor.ConstraintEqualToConstant(ImageSize));
                constraints.Add(statusIcon.HeightAnchor.ConstraintEqualToConstant(ImageSize));
                views.Add(statusIcon);

                OptimalWidth += ImageSize;
                OptimalWidth += RowCellSpacing;
            }
            else if (statusIconVisible)
            {
                statusIcon.RemoveFromSuperview();
                statusIconVisible = false;
            }

            if (showSpinner)
            {
                if (!spinnerVisible)
                {
                    AddSubview(spinner);
                    spinner.StartAnimation(this);
                    spinnerVisible = true;
                }

                constraints.Add(spinner.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(spinner.WidthAnchor.ConstraintEqualToConstant(ImageSize));
                constraints.Add(spinner.HeightAnchor.ConstraintEqualToConstant(ImageSize));
                views.Add(spinner);

                OptimalWidth += ImageSize;
                OptimalWidth += RowCellSpacing;
            }
            else if (spinnerVisible)
            {
                spinner.RemoveFromSuperview();
                spinner.StopAnimation(this);
                spinnerVisible = false;
            }

            // Second Item: Color Preview
            if (previewColor.HasValue)
            {
                colorPreview.Layer.BackgroundColor = GetCGColor(previewColor.Value);

                if (!colorPreviewVisible)
                {
                    AddSubview(colorPreview);
                    colorPreviewVisible = true;
                }

                constraints.Add(colorPreview.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(colorPreview.WidthAnchor.ConstraintEqualToConstant(ImageSize));
                constraints.Add(colorPreview.HeightAnchor.ConstraintEqualToConstant(ImageSize));
                views.Add(colorPreview);

                OptimalWidth += colorPreview.Frame.Width;
                OptimalWidth += RowCellSpacing;
            }
            else if (colorPreviewVisible)
            {
                colorPreview.RemoveFromSuperview();
                colorPreviewVisible = false;
            }

            // Third Item: Value Button
            if (valueButtonText != null && !((MacObjectValueNode)ObjectValue).HideValueButton)
            {
                valueButton.Title = valueButtonText;
                UpdateFont(valueButton, -3);
                valueButton.SizeToFit();

                if (!valueButtonVisible)
                {
                    AddSubview(valueButton);
                    valueButtonVisible = true;
                }

                constraints.Add(valueButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                views.Add(valueButton);

                OptimalWidth += valueButton.Frame.Width;
                OptimalWidth += RowCellSpacing;
            }
            else if (valueButtonVisible)
            {
                valueButton.RemoveFromSuperview();
                valueButtonVisible = false;
            }

            // Fourth Item: Viewer Button
            if (showViewerButton)
            {
                if (!viewerButtonVisible)
                {
                    AddSubview(viewerButton);
                    viewerButtonVisible = true;
                }

                constraints.Add(viewerButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(viewerButton.WidthAnchor.ConstraintEqualToConstant(viewerButton.Image.Size.Width));
                constraints.Add(viewerButton.HeightAnchor.ConstraintEqualToConstant(viewerButton.Image.Size.Height));
                views.Add(viewerButton);

                OptimalWidth += viewerButton.Frame.Width;
                OptimalWidth += RowCellSpacing;
            }
            else if (viewerButtonVisible)
            {
                viewerButton.RemoveFromSuperview();
                viewerButtonVisible = false;
            }

            // Fifth Item: Text Value
            TextField.StringValue = strval;
            TextField.TextColor   = textColor;
            TextField.Editable    = editable;
            UpdateFont(TextField);
            TextField.SizeToFit();

            constraints.Add(TextField.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
            views.Add(TextField);

            // lay out our views...
            var leadingAnchor = LeadingAnchor;

            for (int i = 0; i < views.Count; i++)
            {
                var view = views[i];

                constraints.Add(view.LeadingAnchor.ConstraintEqualToAnchor(leadingAnchor, i == 0 ? MarginSize : RowCellSpacing));
                leadingAnchor = view.TrailingAnchor;
            }

            constraints.Add(TextField.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize));

            foreach (var constraint in constraints)
            {
                constraint.Active = true;
            }

            OptimalWidth += TextField.Frame.Width;
            OptimalWidth += MarginSize;
        }
Exemple #35
0
        public BuilderStyleSheets(
            BuilderPaneWindow paneWindow,
            BuilderViewport viewport,
            BuilderSelection selection,
            BuilderClassDragger classDragger,
            BuilderStyleSheetsDragger styleSheetsDragger,
            HighlightOverlayPainter highlightOverlayPainter,
            BuilderTooltipPreview tooltipPreview)
            : base(
                paneWindow,
                viewport,
                selection,
                classDragger,
                styleSheetsDragger,
                new BuilderStyleSheetsContextMenu(paneWindow, selection),
                viewport.styleSelectorElementContainer,
                false,
                highlightOverlayPainter,
                kToolbarPath)
        {
            m_TooltipPreview = tooltipPreview;
            if (m_TooltipPreview != null)
            {
                var helpTooltipTemplate  = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(kHelpTooltipPath);
                var helpTooltipContainer = helpTooltipTemplate.CloneTree();
                m_TooltipPreview.Add(helpTooltipContainer); // We are the only ones using it so just add the contents and be done.
            }

            viewDataKey = "builder-style-sheets";
            AddToClassList(BuilderConstants.ExplorerStyleSheetsPaneClassName);

            var parent = this.Q("new-selector-item");

            // Init text field.
            m_NewSelectorField     = parent.Q <BuilderNewSelectorField>("new-selector-field");
            m_NewSelectorTextField = m_NewSelectorField.textField;
            m_NewSelectorTextField.SetValueWithoutNotify(BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage);
            m_NewSelectorTextInputField = m_NewSelectorTextField.Q("unity-text-input");
            m_NewSelectorTextInputField.RegisterCallback <KeyDownEvent>(OnEnter, TrickleDown.TrickleDown);
            UpdateNewSelectorFieldEnabledStateFromDocument();

            m_NewSelectorTextInputField.RegisterCallback <FocusEvent>((evt) =>
            {
                var input = evt.target as VisualElement;
                var field = input.parent as TextField;
                m_FieldFocusedFromStandby = true;
                if (field.text == BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage || m_ShouldRefocusSelectorFieldOnBlur)
                {
                    m_ShouldRefocusSelectorFieldOnBlur = false;
                    field.value = BuilderConstants.UssSelectorClassNameSymbol;
                }

                ShowTooltip();
            });

            m_NewSelectorTextField.RegisterCallback <ChangeEvent <string> >((evt) =>
            {
                var field = evt.target as TextField;

                if (!m_FieldFocusedFromStandby)
                {
                    return;
                }

                m_FieldFocusedFromStandby = false;

                // We don't want the '.' we just inserted in the FocusEvent to be highlighted,
                // which is the default behavior.
                field.SelectRange(1, 1);
            });

            m_NewSelectorTextInputField.RegisterCallback <BlurEvent>((evt) =>
            {
                var input = evt.target as VisualElement;
                var field = input.parent as TextField;
                if (m_ShouldRefocusSelectorFieldOnBlur)
                {
                    field.schedule.Execute(PostEnterRefocus);
                    evt.PreventDefault();
                    evt.StopImmediatePropagation();
                    return;
                }

                if (string.IsNullOrEmpty(field.text) || field.text == BuilderConstants.UssSelectorClassNameSymbol)
                {
                    field.SetValueWithoutNotify(BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage);
                    m_PseudoStatesMenu.SetEnabled(false);
                }

                HideTooltip();
            });

            // Setup New USS Menu.
            m_AddUSSMenu = parent.Q <ToolbarMenu>("add-uss-menu");
            SetUpAddUSSMenu();

            // Setup pseudo states menu.
            m_PseudoStatesMenu = m_NewSelectorField.pseudoStatesMenu;

            // Update sub title.
            UpdateSubtitleFromActiveUSS();
        }
 public void GetAttributeValueOfUndefinedButValidAttribute()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         Assert.That(_element.Style.GetAttributeValue("backgroundImage"), Is.EqualTo("none"));
                     });
 }
Exemple #37
0
        /// <summary>
        /// 设置pdf图片水印
        /// </summary>
        /// <param name="imgPath">水印图片路径</param>
        /// <param name="filePath">需要添加水印的pdf文件</param>
        /// <param name="outfilePath">添加完成的pdf文件</param>
        /// <returns></returns>
        public static bool SetImgWaterMark(string imgInfoPath, string signImgPath, string filePath, string outfilePath)
        {
            PdfReader  pdfReader  = null;
            PdfStamper pdfStamper = null;
            FileStream fileStream = null;

            try
            {
                pdfReader  = new PdfReader(filePath);
                fileStream = new FileStream(outfilePath, FileMode.Create);
                pdfStamper = new PdfStamper(pdfReader, fileStream);
                int            total = pdfReader.NumberOfPages;
                Rectangle      psize = pdfReader.GetPageSize(1);
                PdfContentByte content;  //float width = psize.Width;   //595      //float height = psize.Height;  //841

                #region 添加水印信息
                //遮挡甲方身份证
                Image jia_identity = Image.GetInstance(imgInfoPath);
                jia_identity.SetAbsolutePosition(180, 695); //水印的位置
                content = pdfStamper.GetOverContent(2);     //要放置的页数
                content.AddImage(jia_identity);

                //遮挡乙方姓名
                Image yi_name = Image.GetInstance(imgInfoPath);
                yi_name.SetAbsolutePosition(210, 655);  //水印的位置
                //yi_name.ScalePercent(4f);  //图片比例
                content = pdfStamper.GetOverContent(2); //要放置的页数
                content.AddImage(yi_name);

                //遮挡乙方身份证
                Image yi_identity = Image.GetInstance(imgInfoPath);
                yi_identity.SetAbsolutePosition(180, 628); //水印的位置
                content = pdfStamper.GetOverContent(2);    //要放置的页数
                content.AddImage(yi_identity);

                //遮挡乙方电话
                Image yi_phone = Image.GetInstance(imgInfoPath);
                yi_phone.SetAbsolutePosition(180, 603);  //水印的位置
                content = pdfStamper.GetOverContent(2);  //要放置的页数
                content.AddImage(yi_phone);

                #endregion

                //遮挡乙方签名
                //设置文本域  iTextSharp.text.Rectangle(105, 100, 240, 125) 用来设置文本域的位置,四个参数分别为:llx、lly、urx、ury:
                //llx 为Left ,
                //lly 为Bottom,
                //urx 为Right,
                //ury 为Top       其中:Width = Right - Left     Heigth = Top - Bototom
                TextField yi_sign = new TextField(pdfStamper.Writer, new iTextSharp.text.Rectangle(460, 430, 540, 475), "date");
                yi_sign.BackgroundColor = BaseColor.WHITE;
                yi_sign.BorderWidth     = 1;
                yi_sign.BorderColor     = BaseColor.BLACK;
                yi_sign.BorderStyle     = 4;
                yi_sign.FontSize        = 11f;
                pdfStamper.AddAnnotation(yi_sign.GetTextField(), 9);
                pdfStamper.FormFlattening = true;

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                #region 释放资源
                if (pdfStamper != null)
                {
                    pdfStamper.Close();
                }
                if (pdfReader != null)
                {
                    pdfReader.Close();
                }
                if (fileStream != null)
                {
                    fileStream.Close();
                    fileStream.Dispose();
                }
                #endregion
            }
        }
Exemple #38
0
 public WebDriverTypeText(TextField textField)
 {
     _textField = textField;    
 }
Exemple #39
0
        internal void ShowModal()
        {
            var status = "Read (by you)";

            if (this.message.Side == MessageSide.Me)
            {
                status = this.message.SendMessageState.ToString().Replace("Untracable", "Untracked");
            }

            var labelStatus = new Label($"Status: {status}\n\nPlaintext:")
            {
                X      = Style.XLeftMargin,
                Y      = Style.YTopMargin,
                Height = 3,
                Width  = Dim.Fill()
            };

            bool hasLineBreaks = this.message.ThreadText.Contains("\r") || this.message.ThreadText.Contains("\n");

            View labelMessageText;

            if (!hasLineBreaks)
            {
                labelMessageText = new TextField
                {
                    X        = Style.XLeftMargin,
                    Y        = Pos.Bottom(labelStatus) + 1,
                    Width    = Dim.Fill(),
                    Height   = 9,
                    ReadOnly = true,
                    Text     = this.message.ThreadText
                };
            }
            else
            {
                labelMessageText = new TextView
                {
                    X        = Style.XLeftMargin,
                    Y        = Pos.Bottom(labelStatus) + 1,
                    Width    = Dim.Fill(),
                    Height   = 9,
                    ReadOnly = true,
                    Text     = this.message.ThreadText
                };
            }



            var technicalInfo = $"Encrypted Size: {this.message.TextCipher.Length} Bytes, Network Payload Hash: {this.message.NetworkPayloadHash}\n" +
                                $"Encryption: AES 256 Bit CBC Authenticated, Plaintext Compression: Deflate, Forward Secrecy: YES\n" +
                                $"Dynamic Public Key: {this.message.DynamicPublicKey.ToHexString()}\n" +
                                $"Dynamic Public Key ID: {this.message.DynamicPublicKeyId}, Private Key Hint: {this.message.PrivateKeyHint}";

            this.labelTechnicalInfo = new Label(technicalInfo)
            {
                X      = Pos.Left(labelStatus),
                Y      = Pos.Bottom(labelMessageText) + 1,
                Height = 4,
                Width  = Dim.Fill()
            };


            var buttonExport = new Button("Export")
            {
                X       = Pos.Left(this.labelTechnicalInfo),
                Y       = Pos.Bottom(this.labelTechnicalInfo) + 2,
                Clicked = () =>
                {
                    this.Export = true;
                    Application.RequestStop();
                }
            };

            var buttonCopy = new Button("Copy")
            {
                X       = Pos.Right(buttonExport) + 2,
                Y       = Pos.Bottom(this.labelTechnicalInfo) + 2,
                Clicked = () =>
                {
                    ClipboardService.SetText(this.message.ThreadText);
                }
            };

            var buttonCancel = new Button("Cancel")
            {
                X       = Pos.Right(buttonCopy) + 2,
                Y       = Pos.Bottom(this.labelTechnicalInfo) + 2,
                Clicked = Application.RequestStop
            };

            string title;

            if (this.message.Side == MessageSide.You)
            {
                title = $"Message from {this.contactName} ({this.contactId}), sent on {this.message.GetEncrytedDateUtc()} UTC";
            }
            else
            {
                title = $"Message to {this.contactName} ({this.contactId}), sent on {this.message.GetEncrytedDateUtc()} UTC";
            }

            this.Dialog.Title = title;

            this.Dialog.Add(labelStatus, labelMessageText, this.labelTechnicalInfo, buttonExport, buttonCopy,
                            buttonCancel);


            Application.Run(this.Dialog);
        }
Exemple #40
0
 public void SetUp()
 {
     _testRulesList = new List <ValidationRule <TextField> >();
     _textField     = new TextField(_testName, LabelPosition.AboveElement, _testLabel, _testRulesList);
 }
        private void init()
        {
            ValueField = (TextField)AddForm(new TextField(Vector2.Zero, (int)Font.MeasureString(Value.ToString()).X, Font, Value.ToString(), GetValueFromField));

            GetValueFromReferences();
        }
        public BlackboardFieldPropertyView(BlackboardField blackboardField, GraphData graph, AbstractShaderProperty property)
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/ShaderGraphBlackboard"));
            m_BlackboardField = blackboardField;
            m_Graph           = graph;
            m_Property        = property;

            if (!m_Graph.isSubGraph)
            {
                if (property.isExposable)
                {
                    m_ExposedToogle = new Toggle();
                    m_ExposedToogle.OnToggleChanged(evt =>
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change Exposed Toggle");
                        if (m_OnExposedToggle != null)
                        {
                            m_OnExposedToggle();
                        }
                        property.generatePropertyBlock = evt.newValue;
                        if (property.generatePropertyBlock)
                        {
                            m_BlackboardField.icon = BlackboardProvider.exposedIcon;
                        }
                        else
                        {
                            m_BlackboardField.icon = null;
                        }
                        DirtyNodes(ModificationScope.Graph);
                    });
                    m_ExposedToogle.value = property.generatePropertyBlock;
                    AddRow("Exposed", m_ExposedToogle);
                }

                m_ReferenceNameField = new TextField(512, false, false, ' ');
                m_ReferenceNameField.styleSheets.Add(Resources.Load <StyleSheet>("Styles/PropertyNameReferenceField"));
                AddRow("Reference", m_ReferenceNameField);
                m_ReferenceNameField.value     = property.referenceName;
                m_ReferenceNameField.isDelayed = true;
                m_ReferenceNameField.RegisterValueChangedCallback(newName =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Reference Name");
                    if (m_ReferenceNameField.value != m_Property.referenceName)
                    {
                        string newReferenceName        = m_Graph.SanitizePropertyReferenceName(newName.newValue, property.guid);
                        property.overrideReferenceName = newReferenceName;
                    }
                    m_ReferenceNameField.value = property.referenceName;

                    if (string.IsNullOrEmpty(property.overrideReferenceName))
                    {
                        m_ReferenceNameField.RemoveFromClassList("modified");
                    }
                    else
                    {
                        m_ReferenceNameField.AddToClassList("modified");
                    }

                    DirtyNodes(ModificationScope.Graph);
                    UpdateReferenceNameResetMenu();
                });

                if (!string.IsNullOrEmpty(property.overrideReferenceName))
                {
                    m_ReferenceNameField.AddToClassList("modified");
                }
            }

            // Key Undo callbacks for input fields
            EventCallback <KeyDownEvent> keyDownCallback = new EventCallback <KeyDownEvent>(evt =>
            {
                // Record Undo for input field edit
                if (m_UndoGroup == -1)
                {
                    m_UndoGroup = Undo.GetCurrentGroup();
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                }
                // Handle scaping input field edit
                if (evt.keyCode == KeyCode.Escape && m_UndoGroup > -1)
                {
                    Undo.RevertAllDownToGroup(m_UndoGroup);
                    m_UndoGroup = -1;
                    evt.StopPropagation();
                }
                // Dont record Undo again until input field is unfocused
                m_UndoGroup++;
                this.MarkDirtyRepaint();
            });
            EventCallback <FocusOutEvent> focusOutCallback = new EventCallback <FocusOutEvent>(evt =>
            {
                // Reset UndoGroup when done editing input field
                m_UndoGroup = -1;
            });

            if (property is Vector1ShaderProperty)
            {
                var floatProperty = (Vector1ShaderProperty)property;
                BuildVector1PropertyView(floatProperty);
            }
            else if (property is Vector2ShaderProperty)
            {
                var vectorProperty = (Vector2ShaderProperty)property;
                var field          = new Vector2Field {
                    value = vectorProperty.value
                };

                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);

                // Called after KeyDownEvent
                field.RegisterValueChangedCallback(evt =>
                {
                    // Only true when setting value via FieldMouseDragger
                    // Undo recorded once per dragger release
                    if (m_UndoGroup == -1)
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    }
                    vectorProperty.value = evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is Vector3ShaderProperty)
            {
                var vectorProperty = (Vector3ShaderProperty)property;
                var field          = new Vector3Field {
                    value = vectorProperty.value
                };

                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-z-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-z-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);

                // Called after KeyDownEvent
                field.RegisterValueChangedCallback(evt =>
                {
                    // Only true when setting value via FieldMouseDragger
                    // Undo recorded once per dragger release
                    if (m_UndoGroup == -1)
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    }
                    vectorProperty.value = evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is Vector4ShaderProperty)
            {
                var vectorProperty = (Vector4ShaderProperty)property;
                var field          = new Vector4Field {
                    value = vectorProperty.value
                };

                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-x-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-y-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-z-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-z-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);
                field.Q("unity-w-input").Q("unity-text-input").RegisterCallback <KeyDownEvent>(keyDownCallback);
                field.Q("unity-w-input").Q("unity-text-input").RegisterCallback <FocusOutEvent>(focusOutCallback);

                // Called after KeyDownEvent
                field.RegisterValueChangedCallback(evt =>
                {
                    // Only true when setting value via FieldMouseDragger
                    // Undo recorded once per dragger release
                    if (m_UndoGroup == -1)
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    }
                    vectorProperty.value = evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is ColorShaderProperty)
            {
                var colorProperty = (ColorShaderProperty)property;
                var colorField    = new ColorField {
                    value = property.defaultValue, showEyeDropper = false, hdr = colorProperty.colorMode == ColorMode.HDR
                };
                colorField.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    colorProperty.value = evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", colorField);
                if (!m_Graph.isSubGraph)
                {
                    var colorModeField = new EnumField((Enum)colorProperty.colorMode);
                    colorModeField.RegisterValueChangedCallback(evt =>
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change Color Mode");
                        if (colorProperty.colorMode == (ColorMode)evt.newValue)
                        {
                            return;
                        }
                        colorProperty.colorMode = (ColorMode)evt.newValue;
                        colorField.hdr          = colorProperty.colorMode == ColorMode.HDR;
                        colorField.MarkDirtyRepaint();
                        DirtyNodes();
                    });
                    AddRow("Mode", colorModeField);
                }
            }
            else if (property is TextureShaderProperty)
            {
                var textureProperty = (TextureShaderProperty)property;
                var field           = new ObjectField {
                    value = textureProperty.value.texture, objectType = typeof(Texture)
                };
                field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    textureProperty.value.texture = (Texture)evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
                if (!m_Graph.isSubGraph)
                {
                    var defaultModeField = new EnumField((Enum)textureProperty.defaultType);
                    defaultModeField.RegisterValueChangedCallback(evt =>
                    {
                        m_Graph.owner.RegisterCompleteObjectUndo("Change Texture Mode");
                        if (textureProperty.defaultType == (TextureShaderProperty.DefaultType)evt.newValue)
                        {
                            return;
                        }
                        textureProperty.defaultType = (TextureShaderProperty.DefaultType)evt.newValue;
                        DirtyNodes(ModificationScope.Graph);
                    });
                    void ToggleDefaultModeFieldEnabled()
                    {
                        defaultModeField.SetEnabled(!defaultModeField.enabledSelf);
                    }

                    m_OnExposedToggle += ToggleDefaultModeFieldEnabled;
                    AddRow("Mode", defaultModeField);
                }
            }
            else if (property is Texture2DArrayShaderProperty)
            {
                var textureProperty = (Texture2DArrayShaderProperty)property;
                var field           = new ObjectField {
                    value = textureProperty.value.textureArray, objectType = typeof(Texture2DArray)
                };
                field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    textureProperty.value.textureArray = (Texture2DArray)evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is Texture3DShaderProperty)
            {
                var textureProperty = (Texture3DShaderProperty)property;
                var field           = new ObjectField {
                    value = textureProperty.value.texture, objectType = typeof(Texture3D)
                };
                field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    textureProperty.value.texture = (Texture3D)evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is CubemapShaderProperty)
            {
                var cubemapProperty = (CubemapShaderProperty)property;
                var field           = new ObjectField {
                    value = cubemapProperty.value.cubemap, objectType = typeof(Cubemap)
                };
                field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    cubemapProperty.value.cubemap = (Cubemap)evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
            else if (property is BooleanShaderProperty)
            {
                var booleanProperty = (BooleanShaderProperty)property;
                EventCallback <ChangeEvent <bool> > onBooleanChanged = evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change property value");
                    booleanProperty.value = evt.newValue;
                    DirtyNodes();
                };
                var field = new Toggle();
                field.OnToggleChanged(onBooleanChanged);
                field.value = booleanProperty.value;
                AddRow("Default", field);
            }
            else if (property is Matrix2ShaderProperty)
            {
                var matrix2Property = (Matrix2ShaderProperty)property;
                var row0Field       = new Vector2Field {
                    value = matrix2Property.value.GetRow(0)
                };
                row0Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector2 row1          = matrix2Property.value.GetRow(1);
                    matrix2Property.value = new Matrix4x4()
                    {
                        m00 = evt.newValue.x,
                        m01 = evt.newValue.y,
                        m02 = 0,
                        m03 = 0,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = 0,
                        m13 = 0,
                        m20 = 0,
                        m21 = 0,
                        m22 = 0,
                        m23 = 0,
                        m30 = 0,
                        m31 = 0,
                        m32 = 0,
                        m33 = 0,
                    };
                    DirtyNodes();
                });
                AddRow("Default", row0Field);
                var row1Field = new Vector2Field {
                    value = matrix2Property.value.GetRow(1)
                };
                row1Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector2 row0          = matrix2Property.value.GetRow(0);
                    matrix2Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = 0,
                        m03 = 0,
                        m10 = evt.newValue.x,
                        m11 = evt.newValue.y,
                        m12 = 0,
                        m13 = 0,
                        m20 = 0,
                        m21 = 0,
                        m22 = 0,
                        m23 = 0,
                        m30 = 0,
                        m31 = 0,
                        m32 = 0,
                        m33 = 0,
                    };
                    DirtyNodes();
                });
                AddRow("", row1Field);
            }
            else if (property is Matrix3ShaderProperty)
            {
                var matrix3Property = (Matrix3ShaderProperty)property;
                var row0Field       = new Vector3Field {
                    value = matrix3Property.value.GetRow(0)
                };
                row0Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector3 row1          = matrix3Property.value.GetRow(1);
                    Vector3 row2          = matrix3Property.value.GetRow(2);
                    matrix3Property.value = new Matrix4x4()
                    {
                        m00 = evt.newValue.x,
                        m01 = evt.newValue.y,
                        m02 = evt.newValue.z,
                        m03 = 0,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = row1.z,
                        m13 = 0,
                        m20 = row2.x,
                        m21 = row2.y,
                        m22 = row2.z,
                        m23 = 0,
                        m30 = 0,
                        m31 = 0,
                        m32 = 0,
                        m33 = 0,
                    };
                    DirtyNodes();
                });
                AddRow("Default", row0Field);
                var row1Field = new Vector3Field {
                    value = matrix3Property.value.GetRow(1)
                };
                row1Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector3 row0          = matrix3Property.value.GetRow(0);
                    Vector3 row2          = matrix3Property.value.GetRow(2);
                    matrix3Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = row0.z,
                        m03 = 0,
                        m10 = evt.newValue.x,
                        m11 = evt.newValue.y,
                        m12 = evt.newValue.z,
                        m13 = 0,
                        m20 = row2.x,
                        m21 = row2.y,
                        m22 = row2.z,
                        m23 = 0,
                        m30 = 0,
                        m31 = 0,
                        m32 = 0,
                        m33 = 0,
                    };
                    DirtyNodes();
                });
                AddRow("", row1Field);
                var row2Field = new Vector3Field {
                    value = matrix3Property.value.GetRow(2)
                };
                row2Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector3 row0          = matrix3Property.value.GetRow(0);
                    Vector3 row1          = matrix3Property.value.GetRow(1);
                    matrix3Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = row0.z,
                        m03 = 0,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = row1.z,
                        m13 = 0,
                        m20 = evt.newValue.x,
                        m21 = evt.newValue.y,
                        m22 = evt.newValue.z,
                        m23 = 0,
                        m30 = 0,
                        m31 = 0,
                        m32 = 0,
                        m33 = 0,
                    };
                    DirtyNodes();
                });
                AddRow("", row2Field);
            }
            else if (property is Matrix4ShaderProperty)
            {
                var matrix4Property = (Matrix4ShaderProperty)property;
                var row0Field       = new Vector4Field {
                    value = matrix4Property.value.GetRow(0)
                };
                row0Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector4 row1          = matrix4Property.value.GetRow(1);
                    Vector4 row2          = matrix4Property.value.GetRow(2);
                    Vector4 row3          = matrix4Property.value.GetRow(3);
                    matrix4Property.value = new Matrix4x4()
                    {
                        m00 = evt.newValue.x,
                        m01 = evt.newValue.y,
                        m02 = evt.newValue.z,
                        m03 = evt.newValue.w,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = row1.z,
                        m13 = row1.w,
                        m20 = row2.x,
                        m21 = row2.y,
                        m22 = row2.z,
                        m23 = row2.w,
                        m30 = row3.x,
                        m31 = row3.y,
                        m32 = row3.z,
                        m33 = row3.w,
                    };
                    DirtyNodes();
                });
                AddRow("Default", row0Field);
                var row1Field = new Vector4Field {
                    value = matrix4Property.value.GetRow(1)
                };
                row1Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector4 row0          = matrix4Property.value.GetRow(0);
                    Vector4 row2          = matrix4Property.value.GetRow(2);
                    Vector4 row3          = matrix4Property.value.GetRow(3);
                    matrix4Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = row0.z,
                        m03 = row0.w,
                        m10 = evt.newValue.x,
                        m11 = evt.newValue.y,
                        m12 = evt.newValue.z,
                        m13 = evt.newValue.w,
                        m20 = row2.x,
                        m21 = row2.y,
                        m22 = row2.z,
                        m23 = row2.w,
                        m30 = row3.x,
                        m31 = row3.y,
                        m32 = row3.z,
                        m33 = row3.w,
                    };
                    DirtyNodes();
                });
                AddRow("", row1Field);
                var row2Field = new Vector4Field {
                    value = matrix4Property.value.GetRow(2)
                };
                row2Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector4 row0          = matrix4Property.value.GetRow(0);
                    Vector4 row1          = matrix4Property.value.GetRow(1);
                    Vector4 row3          = matrix4Property.value.GetRow(3);
                    matrix4Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = row0.z,
                        m03 = row0.w,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = row1.z,
                        m13 = row1.w,
                        m20 = evt.newValue.x,
                        m21 = evt.newValue.y,
                        m22 = evt.newValue.z,
                        m23 = evt.newValue.w,
                        m30 = row3.x,
                        m31 = row3.y,
                        m32 = row3.z,
                        m33 = row3.w,
                    };
                    DirtyNodes();
                });
                AddRow("", row2Field);
                var row3Field = new Vector4Field {
                    value = matrix4Property.value.GetRow(3)
                };
                row3Field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    Vector4 row0          = matrix4Property.value.GetRow(0);
                    Vector4 row1          = matrix4Property.value.GetRow(1);
                    Vector4 row2          = matrix4Property.value.GetRow(2);
                    matrix4Property.value = new Matrix4x4()
                    {
                        m00 = row0.x,
                        m01 = row0.y,
                        m02 = row0.z,
                        m03 = row0.w,
                        m10 = row1.x,
                        m11 = row1.y,
                        m12 = row1.z,
                        m13 = row1.w,
                        m20 = row2.x,
                        m21 = row2.y,
                        m22 = row2.z,
                        m23 = row2.w,
                        m30 = evt.newValue.x,
                        m31 = evt.newValue.y,
                        m32 = evt.newValue.z,
                        m33 = evt.newValue.w,
                    };
                    DirtyNodes();
                });
                AddRow("", row3Field);
            }
            else if (property is SamplerStateShaderProperty)
            {
                var samplerStateProperty = (SamplerStateShaderProperty)property;
                var filterField          = new EnumField(samplerStateProperty.value.filter);
                filterField.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    samplerStateProperty.value.filter = (TextureSamplerState.FilterMode)evt.newValue;
                    DirtyNodes(ModificationScope.Graph);
                });
                AddRow("Filter", filterField);
                var wrapField = new EnumField(samplerStateProperty.value.wrap);
                wrapField.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    samplerStateProperty.value.wrap = (TextureSamplerState.WrapMode)evt.newValue;
                    DirtyNodes(ModificationScope.Graph);
                });
                AddRow("Wrap", wrapField);
            }
            else if (property is GradientShaderProperty)
            {
                var gradientProperty = (GradientShaderProperty)property;
                var field            = new GradientField {
                    value = gradientProperty.value
                };
                field.RegisterValueChangedCallback(evt =>
                {
                    m_Graph.owner.RegisterCompleteObjectUndo("Change Property Value");
                    gradientProperty.value = evt.newValue;
                    DirtyNodes();
                });
                AddRow("Default", field);
            }
//            AddRow("Type", new TextField());
//            AddRow("Exposed", new Toggle(null));
//            AddRow("Range", new Toggle(null));
//            AddRow("Default", new TextField());
//            AddRow("Tooltip", new TextField());


            AddToClassList("sgblackboardFieldPropertyView");

            UpdateReferenceNameResetMenu();
        }
Exemple #43
0
        private async void NewMethod(Connection connection, ConnectionToAPI connectionToAPI, TextField inputLabel)
        {
            connection.InsertData(inputLabel.Text, await connectionToAPI.GetWord(inputLabel.Text));
            var messageBox = Dialog.CreateMessageBox("Adding information", "Topic added secuesfully");

            messageBox.ShowModal(_host);
        }
Exemple #44
0
        private void OnEnable()
        {
#if UNITY_2019_3_OR_NEWER
            _rootView = rootVisualElement;
#else
            _rootView = this.GetRootVisualContainer();
#endif
            _rootView.Add(new Label("Midi Settings")
            {
                style =
                {
                    fontSize     = 18,
                    marginTop    = 10,
                    marginBottom = 10,
                }
            });

            // Container for Device Name label and field
            VisualElement deviceNameContainer = new VisualElement()
            {
                style = { flexDirection = FlexDirection.Row }
            };
            _rootView.Add(deviceNameContainer);

            // Label for Field
            deviceNameContainer.Add(new Label("Device Name"));

            // Input Name Field
            _deviceNameField = new TextField()
            {
                isDelayed = true,
                value     = EditorPrefs.GetString(DEVICE_NAME_STRING),
                style     = { flexGrow = 1 },
            };
#if UNITY_2019_3_OR_NEWER
            _deviceNameField.RegisterValueChangedCallback(
#else
            _deviceNameField.OnValueChanged(
#endif
                evt => EditorPrefs.SetString(DEVICE_NAME_STRING, evt.newValue));

            // Get available device names
            VRCPortMidiInput midi = new VRCPortMidiInput();
            var deviceNames       = midi.GetDeviceNames().ToList();

            // Add blank device name to use if specified device not found
            deviceNames.Insert(0, "");
            string currentDeviceValue = EditorPrefs.GetString(DEVICE_NAME_STRING);
            string defaultValue       = deviceNames.Contains(currentDeviceValue) ? currentDeviceValue : "";

            // Create and add device popup
            var deviceNamePopupField = new PopupField <string>(deviceNames, defaultValue)
            {
                style = { flexGrow = 1 },
                name  = "midiDevicePopUp",
            };
#if UNITY_2019_3_OR_NEWER
            deviceNamePopupField.RegisterValueChangedCallback(
#else
            deviceNamePopupField.OnValueChanged(
#endif
                evt => EditorPrefs.SetString(DEVICE_NAME_STRING, evt.newValue));
            deviceNameContainer.Add(deviceNamePopupField);
        }
 public void Select()
 {
     TextField?.BecomeFirstResponder();
 }
Exemple #46
0
        /// <summary>
        /// Once RemoteConfigData and SyncTargets are retrieved, render them in the ScrollView.
        /// First show unmapped parameters in a list, ending in a TextField+Button to add a new
        /// unmapped parameter.
        /// Then show all the discovered SyncTargets in hierarchy view, and highlight which ones
        /// are not synced with RemoteConfig.
        /// </summary>
        public void RenderParameters()
        {
            InitHeaders();
            var offset = valueScrollView.scrollOffset;

            valueScrollView.Clear();
            topLevelElement = new TemplateContainer();
            valueScrollView.Add(topLevelElement);

            // Render unmapped targets, if any.
            var unmappedParamsSection = new TemplateContainer();

            // Create Unmapped Parameters header section.
            var unmappedParamsHeader = new Box();

            unmappedParamsHeader.AddToClassList(headersClassName);
            var unmappedLabel = new Label("Unmapped Parameters");

            unmappedParamsHeader.Add(unmappedLabel);
            unmappedParamsSection.Add(unmappedParamsHeader);
            foreach (var param in unmappedParams.OrderBy(p => p.Key))
            {
                var unmappedTarget = new UnmappedSyncElement(param);
                unmappedParamsSection.Add(unmappedTarget);
            }

            // Add a section with TextField and Button to create a new unmapped Parameter.
            var newKeyContainer = new TemplateContainer();

            newKeyContainer.AddToClassList(columnClassName);
            newKeyContainer.AddToClassList(rowClassName);
            var newUnmappedParamText = "New Unmapped Param";
            var newKeyField          = new TextField {
                value = newUnmappedParamText
            };

            newKeyContainer.Add(newKeyField);

            var newUnmappedButton = new Button(() => {
                if (string.IsNullOrWhiteSpace(newKeyField.value))
                {
                    Debug.LogWarning("Cannot create parameter with null/whitespace key.");
                    return;
                }
                if (RemoteConfigData.parameters.ContainsKey(newKeyField.value))
                {
                    Debug.LogWarning($"A parameter with key {newKeyField.value} already exists.");
                    return;
                }
                var newParam          = RemoteConfigData.GetOrCreateParameter(newKeyField.value);
                var newUnmappedTarget = new UnmappedSyncElement(newParam);
                // Insert the new unmapped key at the end of the unmapped keys list.
                var index = unmappedParamsSection.IndexOf(newKeyContainer);
                unmappedParamsSection.Insert(index, newUnmappedTarget);
                newKeyField.value = newUnmappedParamText;
                // Apply column sizing to newly created SyncTargetElement.
                newUnmappedTarget
                .Query(null, columnClassName)
                .ForEach(col => col.style.minWidth = col.style.maxWidth = columnSize);
            });

            newUnmappedButton.text = "+";
            newUnmappedButton.AddToClassList("flex-0");
            newKeyContainer.Add(newUnmappedButton);
            unmappedParamsSection.Add(newKeyContainer);
            topLevelElement.Add(unmappedParamsSection);

            // Create a SyncGroupElement for the top-level SyncTargetContainer. SyncGroupElement and
            // the various SyncTypeElement classes handle the logic for creating the hierarchy UI.
            topLevelSyncTarget = new SyncGroupElement(SyncTargets);
            topLevelElement.Add(topLevelSyncTarget);

            // Below the ScrollView area, show a set of buttons to sync to/from RC and reset local changes.
            buttonContainer.Clear();
            buttonContainer.Add(uploadButton);
            buttonContainer.Add(downloadButton);
            buttonContainer.Add(resetChangesButton);

            // Reset UI by scrolling to previous scroll position and sizing the newly created columns.
            valueScrollView.scrollOffset = offset;
            lastTabWidth = position.width;
            ResizeColumns();
        }
Exemple #47
0
        public override void Setup()
        {
            // Type text here: ______
            var editLabel = new Label("Type text here:")
            {
                X = 0,
                Y = 0,
            };

            Win.Add(editLabel);
            var edit = new TextField("")
            {
                X     = Pos.Right(editLabel) + 1,
                Y     = Pos.Top(editLabel),
                Width = Dim.Fill(2),
            };

            Win.Add(edit);

            // Last KeyPress: ______
            var keyPressedLabel = new Label("Last KeyPress:")
            {
                X = Pos.Left(editLabel),
                Y = Pos.Top(editLabel) + 2,
            };

            Win.Add(keyPressedLabel);
            var labelKeypress = new Label("")
            {
                X             = Pos.Left(edit),
                Y             = Pos.Top(keyPressedLabel),
                Width         = 20,
                TextAlignment = Terminal.Gui.TextAlignment.Centered,
                ColorScheme   = Colors.Error,
            };

            Win.Add(labelKeypress);

            Win.KeyPress += (a) => labelKeypress.Text = a.KeyEvent.ToString();

            // Key stroke log:
            var keyLogLabel = new Label("Key stroke log:")
            {
                X = Pos.Left(editLabel),
                Y = Pos.Top(editLabel) + 4,
            };

            Win.Add(keyLogLabel);
            var fakeKeyPress = new KeyEvent(Key.CtrlMask | Key.A, new KeyModifiers()
            {
                Alt   = true,
                Ctrl  = true,
                Shift = true
            });
            var maxLogEntry       = $"Key{"",-5}: {fakeKeyPress}".Length;
            var yOffset           = (Top == Application.Top ? 1 : 6);
            var keyStrokelist     = new List <string> ();
            var keyStrokeListView = new ListView(keyStrokelist)
            {
                X      = 0,
                Y      = Pos.Top(keyLogLabel) + yOffset,
                Width  = Dim.Percent(30),
                Height = Dim.Fill(),
            };

            keyStrokeListView.ColorScheme = Colors.TopLevel;
            Win.Add(keyStrokeListView);

            // ProcessKey log:
            var processKeyLogLabel = new Label("ProcessKey log:")
            {
                X = Pos.Right(keyStrokeListView) + 1,
                Y = Pos.Top(editLabel) + 4,
            };

            Win.Add(processKeyLogLabel);

            maxLogEntry = $"{fakeKeyPress}".Length;
            yOffset     = (Top == Application.Top ? 1 : 6);
            var processKeyListView = new ListView(((TestWindow)Win)._processKeyList)
            {
                X      = Pos.Left(processKeyLogLabel),
                Y      = Pos.Top(processKeyLogLabel) + yOffset,
                Width  = Dim.Percent(30),
                Height = Dim.Fill(),
            };

            processKeyListView.ColorScheme = Colors.TopLevel;
            Win.Add(processKeyListView);

            // ProcessHotKey log:
            // BUGBUG: Label is not positioning right with Pos, so using TextField instead
            var processHotKeyLogLabel = new Label("ProcessHotKey log:")
            {
                X = Pos.Right(processKeyListView) + 1,
                Y = Pos.Top(editLabel) + 4,
            };

            Win.Add(processHotKeyLogLabel);

            yOffset = (Top == Application.Top ? 1 : 6);
            var processHotKeyListView = new ListView(((TestWindow)Win)._processHotKeyList)
            {
                X      = Pos.Left(processHotKeyLogLabel),
                Y      = Pos.Top(processHotKeyLogLabel) + yOffset,
                Width  = Dim.Percent(20),
                Height = Dim.Fill(),
            };

            processHotKeyListView.ColorScheme = Colors.TopLevel;
            Win.Add(processHotKeyListView);

            // ProcessColdKey log:
            // BUGBUG: Label is not positioning right with Pos, so using TextField instead
            var processColdKeyLogLabel = new Label("ProcessColdKey log:")
            {
                X = Pos.Right(processHotKeyListView) + 1,
                Y = Pos.Top(editLabel) + 4,
            };

            Win.Add(processColdKeyLogLabel);

            yOffset = (Top == Application.Top ? 1 : 6);
            var processColdKeyListView = new ListView(((TestWindow)Win)._processColdKeyList)
            {
                X      = Pos.Left(processColdKeyLogLabel),
                Y      = Pos.Top(processColdKeyLogLabel) + yOffset,
                Width  = Dim.Percent(20),
                Height = Dim.Fill(),
            };

            Win.KeyDown  += (a) => KeyDownPressUp(a.KeyEvent, "Down");
            Win.KeyPress += (a) => KeyDownPressUp(a.KeyEvent, "Press");
            Win.KeyUp    += (a) => KeyDownPressUp(a.KeyEvent, "Up");

            void KeyDownPressUp(KeyEvent keyEvent, string updown)
            {
                var msg = $"Key{updown,-5}: {keyEvent}";

                keyStrokelist.Add(msg);
                keyStrokeListView.MoveDown();
                processKeyListView.MoveDown();
                processColdKeyListView.MoveDown();
                processHotKeyListView.MoveDown();
            }

            processColdKeyListView.ColorScheme = Colors.TopLevel;
            Win.Add(processColdKeyListView);
        }
Exemple #48
0
        public DebuggerSearchBar(DebuggerTreeView parent)
        {
            m_ParentTreeView = parent;
            m_FoundItems     = new List <SearchResultItem>();

            this.AddToClassList("unity-treeview-searchbar");

            m_FieldHelpLabel             = new Label("Search by type, name, or class");
            m_FieldHelpLabel.pickingMode = PickingMode.Ignore;
            m_FieldHelpLabel.AddToClassList("unity-treeview-searchbar-label");
            m_FieldHelpLabel.AddToClassList("unity-treeview-searchbar-label-help");
            Add(m_FieldHelpLabel);

            m_SearchTextField = new TextField();
            m_SearchTextField.AddToClassList("unity-treeview-searchbar-field");
            m_SearchTextField.RegisterValueChangedCallback(PerformSearch);
            m_SearchTextField.RegisterCallback <KeyDownEvent>((e) =>
            {
                var targetField = m_SearchTextField;
                if (e.keyCode == KeyCode.F3 || e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter)
                {
                    if (e.modifiers == EventModifiers.Shift)
                    {
                        SelectPrev();
                    }
                    else
                    {
                        SelectNext();
                    }
                }
                else if (e.keyCode == KeyCode.Escape)
                {
                    targetField.value = string.Empty;
                    targetField.visualInput.Blur();
                    m_ParentTreeView.ClearSearchResults();
                    m_ParentTreeView.Focus();
                }
            }, TrickleDown.TrickleDown);
            Add(m_SearchTextField);

            m_CountLabel = new Label();
            m_CountLabel.AddToClassList("unity-treeview-searchbar-label");
            m_CountLabel.AddToClassList("unity-treeview-searchbar-hidden");
            Add(m_CountLabel);

            var prevButton = new Button(SelectPrev)
            {
                text = "<"
            };

            prevButton.AddToClassList("unity-treeview-searchbar-button");
            prevButton.AddToClassList("unity-treeview-searchbar-button-prev");
            Add(prevButton);

            var nextButton = new Button(SelectNext)
            {
                text = ">"
            };

            nextButton.AddToClassList("unity-treeview-searchbar-button");
            nextButton.AddToClassList("unity-treeview-searchbar-button-next");
            Add(nextButton);
        }
 public void FontStyle()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         Assert.AreEqual("italic", _element.Style.FontStyle);
                     });
 }
Exemple #50
0
        private void Draw(CustomFunctionNode node)
        {
            var currentControls = this.Children().ToArray();

            for (int i = 0; i < currentControls.Length; i++)
            {
                currentControls[i].RemoveFromHierarchy();
            }

            m_Type = new EnumField(node.sourceType);
            m_Type.RegisterValueChangedCallback(s =>
            {
                if ((HlslSourceType)s.newValue != node.sourceType)
                {
                    node.owner.owner.RegisterCompleteObjectUndo("Change Function Type");
                    node.sourceType = (HlslSourceType)s.newValue;
                    Draw(node);
                    node.ValidateNode();
                    node.Dirty(ModificationScope.Graph);
                }
            });

            m_FunctionName = new TextField {
                value = node.functionName, multiline = false
            };
            m_FunctionName.RegisterCallback <FocusInEvent>(s =>
            {
                if (m_FunctionName.value == CustomFunctionNode.defaultFunctionName)
                {
                    m_FunctionName.value = "";
                }
            });
            m_FunctionName.RegisterCallback <FocusOutEvent>(s =>
            {
                if (m_FunctionName.value == "")
                {
                    m_FunctionName.value = CustomFunctionNode.defaultFunctionName;
                }
                else
                {
                    m_FunctionName.value = NodeUtils.ConvertToValidHLSLIdentifier(m_FunctionName.value);
                }

                if (m_FunctionName.value != node.functionName)
                {
                    node.owner.owner.RegisterCompleteObjectUndo("Change Function Name");
                    node.functionName = m_FunctionName.value;
                    node.ValidateNode();
                    node.Dirty(ModificationScope.Graph);
                }
            });

            string path = AssetDatabase.GUIDToAssetPath(node.functionSource);

            m_FunctionSource = new ObjectField()
            {
                value = AssetDatabase.LoadAssetAtPath <ShaderInclude>(path), objectType = typeof(ShaderInclude)
            };
            m_FunctionSource.RegisterValueChangedCallback(s =>
            {
                long localId;
                string guidString = string.Empty;
                if (s.newValue != null)
                {
                    AssetDatabase.TryGetGUIDAndLocalFileIdentifier((ShaderInclude)s.newValue, out guidString, out localId);
                }

                if (guidString != node.functionSource)
                {
                    node.owner.owner.RegisterCompleteObjectUndo("Change Function Source");
                    node.functionSource = guidString;
                    node.ValidateNode();
                    node.Dirty(ModificationScope.Graph);
                }
            });

            m_FunctionBody = new TextField {
                value = node.functionBody, multiline = true
            };
            m_FunctionBody.RegisterCallback <FocusInEvent>(s =>
            {
                if (m_FunctionBody.value == CustomFunctionNode.defaultFunctionBody)
                {
                    m_FunctionBody.value = "";
                }
            });
            m_FunctionBody.RegisterCallback <FocusOutEvent>(s =>
            {
                if (m_FunctionBody.value == "")
                {
                    m_FunctionBody.value = CustomFunctionNode.defaultFunctionBody;
                }

                if (m_FunctionBody.value != node.functionBody)
                {
                    node.owner.owner.RegisterCompleteObjectUndo("Change Function Body");
                    node.functionBody = m_FunctionBody.value;
                    node.ValidateNode();
                    node.Dirty(ModificationScope.Graph);
                }
            });

            VisualElement typeRow = new VisualElement()
            {
                name = "Row"
            };

            {
                typeRow.Add(new Label("Type"));
                typeRow.Add(m_Type);
            }
            Add(typeRow);
            VisualElement nameRow = new VisualElement()
            {
                name = "Row"
            };

            {
                nameRow.Add(new Label("Name"));
                nameRow.Add(m_FunctionName);
            }
            Add(nameRow);
            switch (node.sourceType)
            {
            case HlslSourceType.File:
                VisualElement sourceRow = new VisualElement()
                {
                    name = "Row"
                };
                {
                    sourceRow.Add(new Label("Source"));
                    sourceRow.Add(m_FunctionSource);
                }
                Add(sourceRow);
                break;

            case HlslSourceType.String:
                VisualElement bodyRow = new VisualElement()
                {
                    name = "Row"
                };
                {
                    bodyRow.Add(new Label("Body"));
                    bodyRow.style.height = 200;
                    bodyRow.Add(m_FunctionBody);
                }
                Add(bodyRow);
                break;
            }
        }
 public void GetAttributeValueOfUndefinedAndInvalidAttribute()
 {
     ExecuteTest(browser =>
                     {
                         _element = browser.TextField("Textarea1");
                         Assert.IsNull(_element.Style.GetAttributeValue("nonexistingattrib"));
                     });
 }
Exemple #52
0
 override protected void CreateDisplayObject()
 {
     _textField        = new TextField();
     _textField.gOwner = this;
     displayObject     = _textField;
 }
        public void Height()
        {
            ExecuteTest(browser =>
                            {
                                _element = browser.TextField("Textarea1");

                                if ((browser as FireFox) != null)
                                {
                                    Assert.That(_element.Style.Height.Equals("46px"));
                                }
                                else
                                {
                                    Assert.That(_element.Style.Height.Equals("50px"));
                                }

                            });
        }
 private void Cancel(TextField textField)
 {
     base.Close();
 }
Exemple #55
0
        private void InitializeWriteLine()
        {
            // show fps
            var fps = new TextField {
                textColor = 0xff0000, x = DefaultControlWidth / 2
            }.AttachTo(this).Do(t => EgoView.FramesPerSecondChanged += () => t.text = "fps: " + EgoView.FramesPerSecond);


            var dumperbg = new Shape().AttachTo(this);

            dumperbg.graphics.beginFill(0, 0.5);
            dumperbg.graphics.drawRect(0, DefaultControlHeight / 4, DefaultControlWidth, DefaultControlHeight / 2);

            var dumper = new TextField
            {
                width        = DefaultControlWidth,
                height       = DefaultControlHeight / 2,
                textColor    = 0xffff00,
                mouseEnabled = false,
                y            = DefaultControlHeight / 4,
            }.AttachTo(this);

            WriteLineControl = dumper;
            var dumper_queue = new Queue <string>();

            Action Update =
                delegate
            {
                dumper.text = "";

                foreach (var v in dumper_queue)
                {
                    dumper.appendText(v + Environment.NewLine);
                }
                ;
            };

            WriteLine =
                text =>
            {
                dumper_queue.Enqueue(text);

                while (dumper_queue.Count > 10)
                {
                    dumper_queue.Dequeue();
                }

                if (dumper.visible)
                {
                    Update();
                }
            };

            BooleanProperty CheatMode = true;

            CheatMode.ValueChangedTo +=
                value =>
            {
                dumperbg.visible        = value;
                dumper.visible          = value;
                fps.visible             = value;
                Keyboard_Cheats.Enabled = value;
            };

            if (global::ScriptCoreLib.ActionScript.flash.system.Capabilities.isDebugger)
            {
                var ButtonT = new KeyboardButton(stage)
                {
                    Groups = new[]
                    {
                        MovementArrows[Keyboard.T],
                    },
                    Up = CheatMode.Toggle
                };

                this.EgoView.WriteLine = this.WriteLine;
            }

            CheatMode.Toggle();
        }
Exemple #56
0
        public static void Draw()
        {
            Application.Init();

            var top = Application.Top;

            var win = new Window("Products")
            {
                X      = 0,
                Y      = 1,
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            top.Add(win);

            var menu = new MenuBar(new MenuBarItem[] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_Add Product", "", () => {
                        Action action = () => ProductWindow.Draw();
                        running       = action;
                        Application.RequestStop();
                    }),
                    null,
                    new MenuItem("_Close", "", () => {
                        running = MainApp;
                        Application.RequestStop();
                    }),
                }),
            });

            top.Add(menu);

            lblWarehouseID = new Label(1, 1, "Warehouse ID: ");

            txtWarehouseID = new TextField("")
            {
                X        = Pos.Right(lblWarehouseID),
                Y        = 1,
                Width    = Dim.Percent(40),
                KeyPress = async(e) =>
                {
                    if (e.KeyEvent.Key == Key.Enter)
                    {
                        await WarehouseProducts(txtWarehouseID.Text.ToString());
                    }
                }
            };

            lblResult = new Label("Result: ")
            {
                X = 1,
                Y = Pos.Bottom(txtWarehouseID) + 1
            };

            lstResult = new ListView()
            {
                X       = 1,
                Y       = Pos.Bottom(lblResult) + 1,
                Width   = Dim.Fill() - 1,
                Height  = Dim.Fill() - 1,
                Visible = false
            };

            lstResult.SelectedItemChanged += (ListViewItemEventArgs item) => {
                selectedResultsIndex = item.Item;
            };

            lstResult.OpenSelectedItem += (ListViewItemEventArgs item) => {
                var warehouseProduct = warehouseProducts[selectedResultsIndex];

                Action action = () => ProductWindow.Draw(warehouseProduct);
                running = action;
                Application.RequestStop();
            };

            lblSendingData = new Label("SENDING DATA TO SERVICE...")
            {
                Visible = false
            };

            progressBar = new ProgressBar()
            {
                Width   = 10,
                Visible = false
            };

            bool timer(MainLoop caller)
            {
                progressBar.Pulse();
                return(true);
            }

            Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(300), timer);

            top.LayoutComplete += (e) =>
            {
                lblSendingData.X = win.X;
                lblSendingData.Y = Pos.Bottom(win) - Pos.Top(win) - margin;
                progressBar.X    = Pos.Right(lblSendingData);
                progressBar.Y    = Pos.Bottom(win) - Pos.Top(win) - margin;
            };

            win.Add(lblWarehouseID, txtWarehouseID, lblResult, lstResult, lblSendingData, progressBar);

            txtWarehouseID.FocusFirst();

            Application.Run();
        }
Exemple #57
0
        public static string EmailRecordForm(String recordId)
        {
            TextField tFEmail = new TextField("email", "Email");

            lecoati.uMobile.umComponents.Form form = new lecoati.uMobile.umComponents.Form();

            form.primary = new Button("Send", new Call("EmailRecord", new string[] { recordId }));

            FormFieldset fieldSet = new FormFieldset(title: "Email record");
            form.AddFieldset(fieldSet);

            fieldSet.AddFormItem(tFEmail);

            return form.UmGo();
        }
Exemple #58
0
        public override void Setup()
        {
            // Add a label & text field so we can demo IsDefault
            var editLabel = new Label("TextField (to demo IsDefault):")
            {
                X = 0,
                Y = 0,
            };

            Win.Add(editLabel);
            var edit = new TextField("")
            {
                X     = Pos.Right(editLabel) + 1,
                Y     = Pos.Top(editLabel),
                Width = Dim.Fill(2),
            };

            Win.Add(edit);

            // This is the default button (IsDefault = true); if user presses ENTER in the TextField
            // the scenario will quit
            var defaultButton = new Button("Quit")
            {
                X = Pos.Center(),
                //TODO: Change to use Pos.AnchorEnd()
                Y         = Pos.Bottom(Win) - 3,
                IsDefault = true,
                Clicked   = () => Application.RequestStop(),
            };

            Win.Add(defaultButton);

            var y      = 2;
            var button = new Button(10, y, "Base Color")
            {
                ColorScheme = Colors.Base,
                Clicked     = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            };

            Win.Add(button);

            y += 2;
            Win.Add(new Button(10, y, "Error Color")
            {
                ColorScheme = Colors.Error,
                Clicked     = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            Win.Add(new Button(10, y, "Dialog Color")
            {
                ColorScheme = Colors.Dialog,
                Clicked     = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            Win.Add(new Button(10, y, "Menu Color")
            {
                ColorScheme = Colors.Menu,
                Clicked     = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            Win.Add(new Button(10, y, "TopLevel Color")
            {
                ColorScheme = Colors.TopLevel,
                Clicked     = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            Win.Add(new Button(10, y, "A super long button that will probably expose a bug in clipping or wrapping of text. Will it?")
            {
                Clicked = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            // Note the 'N' in 'Newline' will be the hotkey
            Win.Add(new Button(10, y, "a Newline\nin the button")
            {
                Clicked = () => MessageBox.Query(30, 7, "Message", "Question?", "Yes", "No")
            });

            y += 2;
            // BUGBUG: Buttons don't support specifying hotkeys with _?!?
            Win.Add(button = new Button(10, y, "Te_xt Changer")
            {
            });
            button.Clicked = () => button.Text += $"{y++}";

            Win.Add(new Button("Lets see if this will move as \"Text Changer\" grows")
            {
                X = Pos.Right(button) + 10,
                Y = y,
            });

            y += 2;
            Win.Add(new Button(10, y, "Delete")
            {
                ColorScheme = Colors.Error,
                Clicked     = () => Win.Remove(button)
            });

            y += 2;
            Win.Add(new Button(10, y, "Change Default")
            {
                Clicked = () => {
                    defaultButton.IsDefault = !defaultButton.IsDefault;
                    button.IsDefault        = !button.IsDefault;
                },
            });
        }
Exemple #59
0
        private void BuildFormPanel()
        {
            this.cbxReminder = new Checkbox  {
                Ref = "../../../hasReminder",
                BoxLabel = "Reminder:",
                DataIndex = "HasReminder",
                Checked = false
            };

            this.dfReminder = new DateField
            {
                Ref = "../../../reminder",
                Disabled = true,
                DataIndex = "Reminder",
                Width = 135
            };

            this.taskSubject = new TextField
            {
                AllowBlank = false,
                FieldLabel = "Task&nbsp;Subject",
                DataIndex = "Title",
                Anchor = "100%"
            };

            this.dueDate = new DateField
            {
                AllowBlank = false,
                FieldLabel = "Due Date",
                DataIndex = "DueDate",
                Width = 135
            };

            this.taskCategory = new DropDownField
              {
                  AllowBlank = false,
                  LazyInit = false,
                  FieldLabel = "Task List",
                  DataIndex = "Name",
                  Editable = false,
                  Mode = DropDownMode.ValueText,
                  Ref = "../../../taskCategory",
                  Component =
                  {
                      new TreePanel
                      {
                          Height = 150,
                          Shadow = ShadowMode.None,
                          UseArrows = true,
                          AutoScroll = true,
                          Animate = true,
                          RootVisible = false,
                          Cls = "tasks-tree",
                          Root =
                          {
                              new TreeNode("root")
                          },
                          SelectionModel =
                          {
                              new DefaultSelectionModel()
                          }
                      }
                  }
              };

            this.description = new HtmlEditor
            {
                HideLabel = true,
                DataIndex = "Description",
                Anchor = "100% -150",
                EnableSourceEdit = false,
                EnableFont = false
            };

            this.formPanel = new FormPanel
             {
                 Region = Ext.Net.Region.Center,
                 LabelWidth = 75,
                 ButtonAlign = Alignment.Right,
                 MinButtonWidth = 80,
                 BaseCls = "x-plain",
                 Ref = "taskForm",
                 Cls = "task-window", RenderFormElement = false,

                 CustomConfig =
                 {
                     new ConfigItem("margins", "10 10 5 10", ParameterMode.Value)
                 },

                 Items =
                 {
                     new BoxComponent
                     {
                         Hidden = true,
                         Ref = "../taskMessage",
                         AutoEl =
                         {
                             Cls = "taskMessage"
                         }
                     },
                     taskSubject,
                     new Container
                     {
                         Cls = "x-plain",
                         Layout = "Hbox",
                         Anchor = "100%",
                         Height = 30,
                         Items =
                         {
                             new Container
                             {
                                 Width = 250,
                                 Layout = "Form",
                                 Cls = "x-pain",
                                 Items =
                                 {
                                     dueDate
                                 }
                             },
                             new Container
                             {
                                 Flex = 1,
                                 Layout = "Form",
                                 Cls = "x-plain",
                                 LabelWidth = 55,
                                 Items =
                                 {
                                     taskCategory
                                 }
                             }
                         }
                     },
                     new BoxComponent
                     {
                         AutoEl =
                         {
                             Cls = "divider"
                         }
                     },
                     new Container
                     {
                         Layout = "HBox",
                         Anchor = "100%",
                         Cls = "x-plain",
                         Height = 30,
                         Items =
                         {
                             new Container
                             {
                                 Width = 80,
                                 Layout = "Form",
                                 Cls = "x-plain",
                                 HideLabels = true,
                                 Items =
                                 {
                                     cbxReminder
                                 }
                             },
                             new Container
                             {
                                 Flex = 1,
                                 Layout = "Form",
                                 Cls = "x-plain",
                                 HideLabels = true,
                                 Items =
                                 {
                                     dfReminder
                                 }
                             }
                         }
                     },
                     description
                 }
             };

            this.Buttons.Add(new Button ("OK"));
            this.Buttons.Add(new Button ("Cancel"));

            this.Items.Add(this.formPanel);
        }
Exemple #60
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_LockedElement                      = new Label("Asset is locked");
            m_LockedElement.style.color          = Color.white * 0.75f;
            m_LockedElement.style.position       = PositionType.Absolute;
            m_LockedElement.style.left           = 0f;
            m_LockedElement.style.right          = new StyleLength(0f);
            m_LockedElement.style.top            = new StyleLength(0f);
            m_LockedElement.style.bottom         = new StyleLength(0f);
            m_LockedElement.style.unityTextAlign = TextAnchor.MiddleCenter;
            var fontSize = 54f;

            m_LockedElement.style.fontSize      = new StyleLength(fontSize);
            m_LockedElement.style.paddingBottom = fontSize / 2f;
            m_LockedElement.style.paddingTop    = fontSize / 2f;
            m_LockedElement.style.display       = DisplayStyle.None;
            m_LockedElement.focusable           = true;
            m_LockedElement.RegisterCallback <KeyDownEvent>(e => e.StopPropagation());
            Add(m_LockedElement);

            m_AddButton.SetEnabled(false);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }