コード例 #1
0
        public override async void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            InputBox = GetTemplateChild(InputBoxName) as TextBox;

            if (InputBox != null)
            {
                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
                var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path   = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);

                HookUpEventForIsSubmitOnEnterKey();

                if (!ApplicationSpace.IsDesignMode)
                {
                    await DelayInputSelect();
                }
            }
        }
コード例 #2
0
        public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            if (InputBox != null)
            {
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
                var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path   = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);
                InputBox.TextChanged      -= InputBoxTextChanged;
                InputBox.SelectionChanged -= InputBoxSelectionChanged;

                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

                InputBox.TextChanged      += InputBoxTextChanged;
                InputBox.SelectionChanged += InputBoxSelectionChanged;
            }
        }
コード例 #3
0
ファイル: DataFlow.cs プロジェクト: ystallonne/Core2D
        public void Bind(TextShapeViewModel text, object db, object r)
        {
            var properties = (ImmutableArray <PropertyViewModel>)db;
            var record     = (RecordViewModel)r;
            var tbind      = TextBinding.Bind(text, properties, record);

            text.SetProperty(nameof(TextShapeViewModel.Text), tbind);
        }
コード例 #4
0
ファイル: DataFlow.cs プロジェクト: ag-csharp/Core2D
        /// <inheritdoc/>
        public void Bind(ITextShape text, object db, object r)
        {
            var properties = (ImmutableArray <IProperty>)db;
            var record     = (IRecord)r;
            var tbind      = TextBinding.Bind(text, properties, record);

            text.SetProperty(nameof(ITextShape.Text), tbind);
        }
コード例 #5
0
        /// <summary>
        /// Bind the text of a text view to a property using a value converter.
        /// </summary>
        /// <param name="bindings">The binding manager.</param>
        /// <param name="control">The text field.</param>
        /// <param name="output">A function that gets the property.</param>
        /// <param name="input">A function that sets the property.</param>
        /// <param name="converter">A custom value converter to string.</param>
        /// <typeparam name="TData">The type of the property.</typeparam>
        public static void BindText <TData>(this BindingManager bindings, TextView control, Func <TData> output, Action <TData> input, IValueConverter <string, TData> converter)
        {
            var textBinding = new TextBinding <TData>(control, output, input, converter);

            bindings.Bind(
                output,
                data => textBinding.UpdateTextView(data),
                textBinding);
        }
コード例 #6
0
ファイル: Layouter.cs プロジェクト: sillsdev/wesay
 private void BindMultiTextControlToField(MultiTextControl control,
                                          INotifyPropertyChanged multiTextToBindTo)
 {
     foreach (Control c in control.TextBoxes)
     {
         TextBinding binding = new TextBinding(multiTextToBindTo, ((IControlThatKnowsWritingSystem)c).WritingSystem.Id, c);
         binding.ChangeOfWhichItemIsInFocus += _detailList.OnBinding_ChangeOfWhichItemIsInFocus;
     }
 }
コード例 #7
0
        private void OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_listBox.SelectedIndex > -1 &&
                ((Option.OptionDisplayProxy)_listBox.SelectedItem).UnderlyingOption !=
                _currentOption)
            {
                SaveEditsToCurrentItem();
                var proxy = (Option.OptionDisplayProxy)_listBox.SelectedItem;
                splitContainer1.Panel2.Controls.Remove(_nameMultiTextControl);

                _currentOption = proxy.UnderlyingOption;
                var m = new MultiTextControl(
                    _currentField.WritingSystemIds,
                    _currentOption.Name,
                    _currentField.FieldName,
                    false,
                    BasilProject.Project.WritingSystems,
                    CommonEnumerations.VisibilitySetting.Visible,
                    _currentField.IsSpellCheckingEnabled, false,
                    WeSayWordsProject.Project.ServiceLocator
                    );
                m.SizeChanged += OnNameControlSizeChanged;
                m.Bounds       = _nameMultiTextControl.Bounds;
                m.Top          = _nameLabel.Top;
                m.BorderStyle  = BorderStyle.FixedSingle;
                m.Anchor       = _nameMultiTextControl.Anchor;
                m.TextChanged += OnNameChanged;

                _nameMultiTextControl = m;
                splitContainer1.Panel2.Controls.Add(m);

                /* user can't change this anymore. It was confusing to people an probably not needed
                 * _keyText.TextChanged -= OnKeyTextChanged;
                 * _keyText.Text = proxy.UnderlyingOption.Key;
                 * _keyText.TextChanged += OnKeyTextChanged;
                 */

                var justTextBoxes = from z in m.TextBoxes where z is IWeSayTextBox select z;
                foreach (IWeSayTextBox box in justTextBoxes)
                {
                    var binding = new TextBinding(
                        _currentOption.Name,
                        box.WritingSystem.Id,
                        (Control)box
                        );
                    //hooking on to this is more reliable, sequence-wise, than directly wiring to m.TextChanged
                    //JH (2011): Maybe so, but this doesn't fire until they tab away, and that's too late.
                    binding.DataTarget.PropertyChanged += DataTarget_PropertyChanged;
                }
                AdjustLocations();
                UpdateDisplay();
            }
        }
コード例 #8
0
        public void WidgetToTarget()
        {
            MultiText    text   = new MultiText();
            WeSayTextBox widget =
                new WeSayTextBox(WritingSystemDefinition.Parse("qaa-x-qaa"), null);

            var binding = new TextBinding(text, "vernacular", widget);

            widget.Text = "aaa";
            widget.Dispose();            //this is hard to test now, because the biding only fires when focus is lost or the target ui control goes away
            Assert.AreEqual("aaa", text["vernacular"]);
        }
コード例 #9
0
ファイル: BindingTests.cs プロジェクト: bbriggs/wesay
        public void WidgetToTarget()
        {
            MultiText text = new MultiText();
            WeSayTextBox widget =
                    new WeSayTextBox(new WritingSystem("vernacular", new Font("Arial", 12)), null);

            var binding = new TextBinding(text, "vernacular", widget);

            widget.Text = "aaa";
            widget.Dispose();//this is hard to test now, because the biding only fires when focus is lost or the target ui control goes away
            Assert.AreEqual("aaa", text["vernacular"]);
        }
コード例 #10
0
    public void Bind(TextShapeViewModel?text, object?db, object?r)
    {
        if (text is null)
        {
            return;
        }

        var properties = (ImmutableArray <PropertyViewModel>?)db;
        var record     = (RecordViewModel?)r;
        var value      = TextBinding.Bind(text, properties, record);

        text.SetProperty(nameof(TextShapeViewModel.Text), value);
    }
コード例 #11
0
ファイル: RadioButtonList.cs プロジェクト: daddycoding/Eto
        RadioButton CreateButton(object item)
        {
            var button = new RadioButton(controller);

            button.CheckedChanged += HandleCheckedChanged;
            button.Text            = TextBinding.GetValue(item);
            button.Tag             = item;
            button.Enabled         = base.Enabled;
            if (controller == null)
            {
                controller = button;
            }
            return(button);
        }
コード例 #12
0
    public override void OnInspectorGUI()
    {
        TextBinding cur = (TextBinding)target;

        GUI.enabled = !Application.isPlaying;

        cur.Reference = EditorGUILayout.ObjectField("Target", cur.Reference, typeof(Object), true);

        if (cur.Reference != null)
        {
            string[] Options = cur.Reference.GetType().GetFields().Select(d => d.Name).ToArray();

            cur.Format      = EditorGUILayout.TextField("Format", cur.Format);
            cur.ShowChanges = EditorGUILayout.Toggle("Value Change Animation?", cur.ShowChanges);

            cur.PropIndex = EditorGUILayout.Popup("Property", cur.PropIndex, Options);

            EditorUtility.SetDirty(target);
        }
        else
        {
            EditorGUILayout.HelpBox("Set a reference", MessageType.Error);
        }
    }
コード例 #13
0
ファイル: TextBindingEditor.cs プロジェクト: Hengle/Extention
 private void GeneralOptions(TextBinding script)
 {
     options = (from item in script.BindingScript.GetType().GetProperties()
                select item.Name).ToArray();
 }
コード例 #14
0
        protected void LoadWasm(WasmFile file, ContentsStore store = null, List <string> args = null)
        {
            if (store == null)
            {
                store = new ContentsStore();
            }

            var importer = new PredefinedImporter();

            var wasiFunctions = new List <string>()
            {
                //"proc_exit",
                "fd_prestat_get",
                "fd_prestat_dir_name",
                // "random_get",
                "abort",
            };

            importer.DefineFunction("proc_exit",
                                    new DelegateFunctionDefinition(
                                        new WasmValueType[] { WasmValueType.Int32 },
                                        new WasmValueType[] { },
                                        x => new object[0]
                                        ));
            importer.DefineFunction("clock_time_get",
                                    new DelegateFunctionDefinition(
                                        new WasmValueType[] { WasmValueType.Int32, WasmValueType.Int64, WasmValueType.Int32 },
                                        new WasmValueType[] { WasmValueType.Int32 },
                                        GetTime
                                        ));
            foreach (var wasiFunction in wasiFunctions)
            {
                importer.DefineFunction(wasiFunction,
                                        new DelegateFunctionDefinition(
                                            new WasmValueType[] { },
                                            new WasmValueType[] { },
                                            x => ReturnValue.FromObject(0)
                                            ));
            }
            importer.DefineFunction("random_get",
                                    new DelegateFunctionDefinition(
                                        ValueType.PointerAndPointer,
                                        ValueType.Int,
                                        x => ReturnValue.FromObject(0)
                                        ));

            var element = new Element()
            {
                GameObject = gameObject
            };

            // WASI functions
            if (args == null)
            {
                args = new List <string>();
            }
            var scriptName = "";

            args.Insert(0, scriptName);
            var envs        = new List <string>();
            var argsBinding = new ArgsBinding(element, store, args, envs);

            importer.IncludeDefinitions(argsBinding.Importer);

            var fileDescriptorBinding = new FileDescriptorBinding(element, store);

            importer.IncludeDefinitions(fileDescriptorBinding.Importer);


            // Spirare functions
            var debugBinding = new DebugBinding(element, store);

            importer.IncludeDefinitions(debugBinding.Importer);

            var gameObjectBinding = new GameObjectBinding(element, store, context, mainThread);

            importer.IncludeDefinitions(gameObjectBinding.Importer);

            var transformBinding = new TransformBinding(element, store, context, mainThread);

            importer.IncludeDefinitions(transformBinding.Importer);

            var physicsBinding = new PhysicsBinding(element, store, context, mainThread);

            importer.IncludeDefinitions(physicsBinding.Importer);

            var textBinding = new TextBinding(element, store, context, mainThread);

            importer.IncludeDefinitions(textBinding.Importer);

            var timeBinding = new TimeBinding(element, store);

            importer.IncludeDefinitions(timeBinding.Importer);

            try
            {
                module = ModuleInstance.Instantiate(file, importer);

                argsBinding.ModuleInstance           = module;
                fileDescriptorBinding.ModuleInstance = module;

                gameObjectBinding.ModuleInstance = module;
                debugBinding.ModuleInstance      = module;
                textBinding.ModuleInstance       = module;

                var exportedFunctions = module.ExportedFunctions;
                exportedFunctions.TryGetValue("start", out startFunction);
                exportedFunctions.TryGetValue("update", out updateFunction);
                exportedFunctions.TryGetValue("on_use", out onUseFunction);
                exportedFunctions.TryGetValue("on_select", out onSelectFunction);
                exportedFunctions.TryGetValue("on_equip", out onEquipFunction);
                exportedFunctions.TryGetValue("on_unequip", out onEquipFunction);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }