Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyBinding{T}"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="propertyPath">The property path.</param>
 public PropertyBinding(object?source, BindingMode mode, PropertyPath?propertyPath)
 {
     _bindingHelper = new BindingHelper(this);
     BindingOperations.SetBinding(_bindingHelper, BindingHelper.ValueProperty, new Binding {
         Path = propertyPath, Source = source, Mode = mode
     });
 }
Exemplo n.º 2
0
        public static void SelectOne(this TreeView treeView, object item, bool isValue)
        {
            ApplyActionToAllTreeViewItems(treeView, itemsControl =>
            {
                var equalItem = itemsControl.Header;
                if (isValue)
                {
                    equalItem = BindingHelper.Eval <object>(equalItem, treeView.SelectedValuePath);
                }

                if (equalItem.Equals(item))
                {
                    itemsControl.IsSelected = true;
                    itemsControl.BringIntoView();
                    itemsControl.Focus();

                    return;
                }
                else
                {
                    itemsControl.IsSelected = false;
                }

                var wasExpanded         = itemsControl.IsExpanded;
                itemsControl.IsExpanded = true;

                UIHelper.WaitForPriority(DispatcherPriority.ContextIdle);

                itemsControl.IsExpanded = wasExpanded;
            });
        }
Exemplo n.º 3
0
        protected override void OnElementAttached(LabelEx element)
        {
            base.OnElementAttached(element);

            SetSize(double.NaN, double.NaN);

            BindingHelper.SetBinding(
                Model, PLabel.ForegroundProperty,
                element, LabelEx.ForegroundProperty);

            BindingHelper.SetBinding(
                Model, PLabel.TextProperty,
                element, LabelEx.ContentProperty);

            BindingHelper.SetBinding(
                Model, PLabel.HorizontalTextAlignmentProperty,
                element, LabelEx.HorizontalContentAlignmentProperty,
                converter: hConverter);

            BindingHelper.SetBinding(
                Model, PLabel.VerticalTextAlignmentProperty,
                element, LabelEx.VerticalContentAlignmentProperty,
                converter: vConverter);

            BindingHelper.SetBinding(
                element, LabelEx.FontSizeProperty,
                Model, PLabel.FontSizeProperty);

            Model.Text = "텍스트";
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called when the <c>DataContext</c> property of the <see cref="TargetControl"/> has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        public virtual void OnTargetControlDataContextChanged(object sender, DependencyPropertyValueChangedEventArgs e)
        {
            Log.Debug("DataContext of TargetControl '{0}' has changed to '{1}'", TargetControl.GetType().Name, ObjectToStringHelper.ToTypeString(TargetControl.DataContext));

            var dataContext = TargetControl.DataContext;

            if (dataContext == null)
            {
                return;
            }

            if (BindingHelper.IsSentinelObject(dataContext))
            {
                return;
            }

            if (ViewModel == dataContext)
            {
                return;
            }

            if (dataContext.GetType().IsAssignableFromEx(ViewModelType))
            {
                // Use the view model from the data context, probably set manually
                ViewModel = (IViewModel)dataContext;
            }
        }
Exemplo n.º 5
0
        private void BindToViewModel()
        {
            bindingSource.DataSource = viewModel;
            searchNumber.DataBindings.Add("Editvalue", bindingSource, "SearchNumber");
            elementNumber.DataBindings.Add("Text", bindingSource, "ElementNumber");

            elementType.DataBindings.Add(
                BindingHelper.CreateOneWayReadToString("Text", bindingSource, "ElementType",
                                                       (value) =>
            {
                return((string)localizedAllPartTypes[(int)value]);
            }));

            inspections.DataBindings.Add("DataSource", bindingSource, "InspectionTestResults");

            inspectorsDataSource.DataSource      = viewModel.Inspectors;
            inspectorsDataSource.ListChanged    += (s, eve) => IsModified = true;
            inspectorSelectionControl.DataSource = inspectorsDataSource;
            var inspectorsPopup = new PopupContainerControl();

            inspectorsPopup.Controls.Add(inspectorSelectionControl);
            inspectorSelectionControl.Dock                        = DockStyle.Fill;
            inspectorsPopupContainerEdit.PopupControl             = inspectorsPopup;
            inspectorsPopupContainerEdit.PopupControl.MaximumSize = inspectorsPopup.MaximumSize;
        }
Exemplo n.º 6
0
        public void WaybillSourceSettings(uint supplierId)
        {
            var supplier = DbSession.Load <Supplier>(supplierId);
            var source   = supplier.WaybillSource ?? new WaybillSource(supplier);

            if (IsPost)
            {
                source.session = DbSession;
                Bind(source, "source");
                if (supplier.WaybillSource == null)
                {
                    supplier.WaybillSource = source;
                }
                source.EMailFrom = source.Emails.Implode();
                if (IsValid(source))
                {
                    DbSession.Save(source);
                    Notify("Сохранено");
                    RedirectToAction("WaybillSourceSettings", new { supplierId = source.Id });
                }
                else
                {
                    Error("Ошибка сохранения", PropertyBag);
                }
            }
            var sourceTypes = BindingHelper.GetDescriptionsDictionary(typeof(WaybillSourceType));

            sourceTypes.Remove((int)WaybillSourceType.Http);
            PropertyBag["supplier"]    = supplier;
            PropertyBag["source"]      = source;
            PropertyBag["sourceTypes"] = sourceTypes;
        }
Exemplo n.º 7
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            leftValueBox   = GetTemplateChild <TextBox>("PART_leftValueBox");
            topValueBox    = GetTemplateChild <TextBox>("PART_topValueBox");
            rightValueBox  = GetTemplateChild <TextBox>("PART_rightValueBox");
            bottomValueBox = GetTemplateChild <TextBox>("PART_bottomValueBox");

            BindingHelper.SetBinding(
                thicknessBidner, ElementThicknessBinder.LeftProperty,
                leftValueBox, TextBox.TextProperty);

            BindingHelper.SetBinding(
                thicknessBidner, ElementThicknessBinder.TopProperty,
                topValueBox, TextBox.TextProperty);

            BindingHelper.SetBinding(
                thicknessBidner, ElementThicknessBinder.RightProperty,
                rightValueBox, TextBox.TextProperty);

            BindingHelper.SetBinding(
                thicknessBidner, ElementThicknessBinder.BottomProperty,
                bottomValueBox, TextBox.TextProperty);
        }
        public string GetSelectedItemsText()
        {
            switch (SelectionMode)
            {
            case SelectionMode.Single:
                if (ReadLocalValue(DisplayMemberPathProperty) != DependencyProperty.UnsetValue || ReadLocalValue(SelectedItemStringFormatProperty) != DependencyProperty.UnsetValue)
                {
                    return(BindingHelper.Eval(SelectedItem, DisplayMemberPath ?? "", SelectedItemStringFormat)?.ToString());
                }
                else
                {
                    return(SelectedItem?.ToString());
                }

            case SelectionMode.Multiple:
            case SelectionMode.Extended:
                IEnumerable <object> values;

                if (ReadLocalValue(DisplayMemberPathProperty) != DependencyProperty.UnsetValue || ReadLocalValue(SelectedItemStringFormatProperty) != DependencyProperty.UnsetValue)
                {
                    values = ((IEnumerable <object>)DisplaySelectedItems)?.Select(o => BindingHelper.Eval(o, DisplayMemberPath ?? string.Empty, SelectedItemStringFormat));
                }
                else
                {
                    values = (IEnumerable <object>)DisplaySelectedItems;
                }

                return(values is null ? null : string.Join(Separator ?? string.Empty, values));

            default:
                return(null);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Generates the partial view for a new list item
        /// </summary>
        /// <param name="propertyName">name of the property the input element is generated for</param>
        /// <param name="itemCount">how many items exist already</param>
        /// <param name="serverIndex">if it's a server property, which one</param>
        /// <returns></returns>
        public IActionResult GetNewListItem(string propertyName, int itemCount, int serverIndex = -1)
        {
            if (Client.Level < SharedLibraryCore.Database.Models.EFClient.Permission.Owner)
            {
                return(Unauthorized());
            }

            // todo: maybe make this cleaner in the future
            if (propertyName.StartsWith("Servers") && serverIndex < 0)
            {
                return(PartialView("_ServerItem", new ApplicationConfiguration()
                {
                    Servers = Enumerable.Repeat(new ServerConfiguration(), itemCount + 1).ToArray()
                }));
            }

            var model = new BindingHelper()
            {
                Properties      = propertyName.Split("."),
                ItemIndex       = itemCount,
                ParentItemIndex = serverIndex
            };

            return(PartialView("_ListItem", model));
        }
Exemplo n.º 10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            valueBox = GetTemplateChild <SubmitTextBox>("PART_valueBox");

            if (this.Value is double)
            {
                Binding b = BindingHelper.SetBinding(
                    this, ValueProperty,
                    valueBox, TextBox.TextProperty,
                    converter: ResourceManager.GetConverter("DoubleToString"));

                b.ValidationRules.Add(new DoubleRule());
            }
            else
            {
                BindingHelper.SetBinding(
                    this, ValueProperty,
                    valueBox, TextBox.TextProperty);
            }

            if (!this.IsStable)
            {
                valueBox.Text = "";
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Binds the <see cref="IModInfo"/>'s view model to the control.
        /// </summary>
        /// <param name="p_vmlModInfo">The view model to bind to the control.</param>
        protected void BindModInfo(ModInfoVM p_vmlModInfo)
        {
            tbxAuthor.DataBindings.Clear();
            tbxDescription.DataBindings.Clear();
            tbxName.DataBindings.Clear();
            tbxVersion.DataBindings.Clear();
            tbxWebsite.DataBindings.Clear();

            BindingHelper.CreateFullBinding(tbxAuthor, () => tbxAuthor.Text, p_vmlModInfo, () => p_vmlModInfo.Author);
            BindingHelper.CreateFullBinding(tbxDescription, () => tbxDescription.Text, p_vmlModInfo, () => p_vmlModInfo.Description);
            BindingHelper.CreateFullBinding(tbxName, () => tbxName.Text, p_vmlModInfo, () => p_vmlModInfo.ModName);
            BindingHelper.CreateFullBinding(tbxVersion, () => tbxVersion.Text, p_vmlModInfo, () => p_vmlModInfo.HumanReadableVersion);
            BindingHelper.CreateFullBinding(tbxWebsite, () => tbxWebsite.Text, p_vmlModInfo, () => p_vmlModInfo.Website);
            pbxScreenshot.Image = p_vmlModInfo.Screenshot;

            ckbLockAuthor.Visible      = false;
            ckbLockDescription.Visible = false;
            ckbLockName.Visible        = false;
            ckbLockScreenshot.Visible  = false;
            ckbLockVersion.Visible     = false;
            ckbLockWebsite.Visible     = false;

            p_vmlModInfo.Errors.ErrorChanged -= ModInfo_ErrorChanged;
            p_vmlModInfo.Errors.ErrorChanged += new EventHandler <ErrorEventArguments>(ModInfo_ErrorChanged);
        }
        private async Task _start()
        {
            _log.Debug("Запуск сервера в интерактивном режиме");

            //InitIoC();

            //// после успешного соединения инициализируем общие настройки, если таковые не были проиницилизированы ранее
            //SettingsStore.InitializeCommonSettings();
            //SettingsStore.CheckConfigSettings();

            //using (var db = new Database())
            //{
            //    DataCache.InitDataCache(db);
            //}

            // еще нет соединения с клиентами - нужно организовать связь
            var binding     = BindingHelper.GetTcpBinding();
            var baseAddress = new Uri(Settings.Default.BaseAddress);

            _clientServiceHost = new ServiceHost(_service, baseAddress);
            _clientServiceHost.AddServiceEndpoint(typeof(IService), binding, baseAddress);

            if (binding.Security.Mode == SecurityMode.Transport)
            {
                InitializeCertificate();
            }

            foreach (var endPoint in _clientServiceHost.Description.Endpoints)
            {
                endPoint.Behaviors.Add(new ServiceEndpointBehavior());
            }

            _clientServiceHost.Description.Behaviors.Add(new WCFErrorHandler(_log));
            _clientServiceHost.Open();
        }
Exemplo n.º 13
0
 private void PresenterUnregistered(object sender, InstanceRegistryEventArgs <Presenter> e)
 {
     foreach (LevelLayerPresenter layer in _layerPresenters.Values)
     {
         BindingHelper.TryBind(layer, e.Type, null);
     }
 }
Exemplo n.º 14
0
        protected override void OnAttachedComponentModel()
        {
            base.OnAttachedComponentModel();

            BindingHelper.SetBinding(
                Model, PFunction.FunctionNameProperty,
                this, HeaderProperty);
        }
Exemplo n.º 15
0
        protected virtual void OnTargetPropertyBinding()
        {
            SetValue(ValueProperty, GetTargetValue());

            BindingHelper.SetBinding(
                Target, TargetDependencyProperty,
                this, ValueProperty);
        }
 private void OnPropertyChanged(Expression <Func <object> > property)
 {
     if (PropertyChanged != null)
     {
         PropertyChanged(this,
                         new PropertyChangedEventArgs(BindingHelper.Name(property)));
     }
 }
Exemplo n.º 17
0
        protected override void OnAttachedComponentModel()
        {
            base.OnAttachedComponentModel();

            BindingHelper.SetBinding(
                this.Model, PTargetable.PropertyProperty,
                this, BaseProperty.SelectedPropertyProperty);
        }
Exemplo n.º 18
0
        protected override void OnAttachedComponentModel()
        {
            base.OnAttachedComponentModel();

            BindingHelper.SetBinding(
                this.Model.ValueBinder, PBinder.IsDirectValueProperty,
                valueCheckBox, CheckBox.IsCheckedProperty);
        }
Exemplo n.º 19
0
 public string FormatPartDescription(string description, Period period)
 {
     if (IsSpecialLangCase(description))
     {
         return(description.Replace("{0}", period.GetPeriodName().ToLower()));
     }
     return(description.Replace("{0}", BindingHelper.GetDescription(period.Interval).ToLower()));
 }
Exemplo n.º 20
0
        protected void bindReson()
        {
            string    sql = "select * from Tb_GoodsReturnReson with(nolock) where isHidden=0 order by typeId";
            SqlHelper sp  = LocalSqlHelper.WH;
            DataTable dt  = sp.ExecDataTable(sql);

            BindingHelper.BindDDL(ddreson, dt, "typeName", "typeName");
        }
Exemplo n.º 21
0
 public CplVersionConditionEditor(List <KeyValuePair <string, string> > p_lstVersionNames)
 {
     InitializeComponent();
     cbxVersionName.DataSource    = p_lstVersionNames;
     cbxVersionName.DisplayMember = "Key";
     cbxVersionName.ValueMember   = "Value";
     BindingHelper.CreateFullBinding(pnlEditVersion, () => pnlEditVersion.Enabled, this, () => Selected);
 }
Exemplo n.º 22
0
        /// <summary>
        /// 绑定投诉原因
        /// </summary>

        public static void bindReason(DropDownList dd)
        {
            string    sql = "select * from Tb_ComplaintType with(nolock) where isHidden=0 order by typeId";
            SqlHelper sp  = LocalSqlHelper.WH;
            DataTable dt  = sp.ExecDataTable(sql);

            BindingHelper.BindDDL(dd, dt, "typeName", "typeId");
        }
        /// <summary>
        /// A sinmple consturctor that initializes the object with the given values.
        /// </summary>
        /// <param name="p_gsgSettings">The settings group whose settings will be editable with this view.</param>
        public GeneralSettingsPage(GeneralSettingsGroup p_gsgSettings)
        {
            SettingsGroup = p_gsgSettings;
            InitializeComponent();

            cbxProgramUpdateCheckInterval.DataSource = Enum.GetValues(typeof(DaysInterval))
                                                       .Cast <DaysInterval>()
                                                       .Select(p => new { Value = (int)p, Key = p.ToString() })
                                                       .ToList();
            cbxProgramUpdateCheckInterval.DisplayMember = "Key";
            cbxProgramUpdateCheckInterval.ValueMember   = "Value";

            foreach (GeneralSettingsGroup.FileAssociationSetting fasFileAssociation in p_gsgSettings.FileAssociations)
            {
                CheckBox ckbFileAssociation = new CheckBox();
                ckbFileAssociation.Tag      = fasFileAssociation;
                ckbFileAssociation.Text     = String.Format("Associate with {0} (*{1}) files", fasFileAssociation.Description, fasFileAssociation.Extension);
                ckbFileAssociation.AutoSize = true;
                BindingHelper.CreateFullBinding(ckbFileAssociation, () => ckbFileAssociation.Checked, fasFileAssociation, () => fasFileAssociation.IsAssociated);
                flpFileAssociations.Controls.Add(ckbFileAssociation);
            }
            BindingHelper.CreateFullBinding(ckbShellExtensions, () => ckbShellExtensions.Checked, p_gsgSettings, () => p_gsgSettings.AddShellExtensions);
            BindingHelper.CreateFullBinding(ckbAssociateURL, () => ckbAssociateURL.Checked, p_gsgSettings, () => p_gsgSettings.AssociateNxmUrl);

            BindingHelper.CreateFullBinding(ckbCheckForUpdates, () => ckbCheckForUpdates.Checked, p_gsgSettings, () => p_gsgSettings.CheckForUpdatesOnStartup);
            BindingHelper.CreateFullBinding(ckbAddMissingInfo, () => ckbAddMissingInfo.Checked, p_gsgSettings, () => p_gsgSettings.AddMissingModInfo);
            BindingHelper.CreateFullBinding(ckbScanSubfolders, () => ckbScanSubfolders.Checked, p_gsgSettings, () => p_gsgSettings.ScanSubfoldersForMods);
            BindingHelper.CreateFullBinding(ckbOverrideLocalNames, () => ckbOverrideLocalNames.Checked, p_gsgSettings, () => p_gsgSettings.OverrideLocalModNames);
            BindingHelper.CreateFullBinding(ckbCloseManagerAfterGameLaunch, () => ckbCloseManagerAfterGameLaunch.Checked, p_gsgSettings, () => p_gsgSettings.CloseModManagerAfterGameLaunch);
            BindingHelper.CreateFullBinding(ckbShowSidePanel, () => ckbShowSidePanel.Checked, p_gsgSettings, () => p_gsgSettings.ShowSidePanel);
            BindingHelper.CreateFullBinding(ckbSkipReadmeFiles, () => ckbSkipReadmeFiles.Checked, p_gsgSettings, () => p_gsgSettings.SkipReadmeFiles);
            BindingHelper.CreateFullBinding(ckbHideModUpdateWarningIcon, () => ckbHideModUpdateWarningIcon.Checked, p_gsgSettings, () => p_gsgSettings.HideModUpdateWarningIcon);

            BindingHelper.CreateFullBinding(cbxProgramUpdateCheckInterval, () => cbxProgramUpdateCheckInterval.SelectedValue, p_gsgSettings, () => p_gsgSettings.UpdateCheckInterval);

            BindingHelper.CreateFullBinding(tbxTraceLogDirectory, () => tbxTraceLogDirectory.Text, p_gsgSettings, () => p_gsgSettings.TraceLogPath);
            BindingHelper.CreateFullBinding(tbxTempPathDirectory, () => tbxTempPathDirectory.Text, p_gsgSettings, () => p_gsgSettings.TempPath);

            try
            {
                if (!p_gsgSettings.CanAssociateFiles)
                {
                    gbxAssociations.Enabled = false;
                    ttpTip.SetToolTip(gbxAssociations, String.Format("Run {0} as Administrator to change these settings.", p_gsgSettings.EnvironmentInfo.Settings.ModManagerName));
                }
            }
            catch (MissingMethodException ex)
            {
                string strErrorMessage = string.Format("Looks like you have a broken or incomplete .Net Framework!" + Environment.NewLine +
                                                       "You need to install .NetFramework 4.5.2 or 4.6 . " + Environment.NewLine +
                                                       "You could alse be required to download the latest Windows updates" + Environment.NewLine + Environment.NewLine +
                                                       "{0} will be unable to run until you do that and will now close.", SettingsGroup.EnvironmentInfo.Settings.ModManagerName);
                MessageBox.Show(strErrorMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                System.Environment.Exit(0);
            }

            ckbCloseManagerAfterGameLaunch.Text = String.Format(ckbCloseManagerAfterGameLaunch.Text, p_gsgSettings.EnvironmentInfo.Settings.ModManagerName);
        }
#pragma warning restore SA1202 // Elements must be ordered by access

        private static void OnTrackChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            d.SetValue(EventsPropertyKey, new ObservableCollection <object>());
            _ = BindingHelper.Bind(d, HasErrorProperty)
                .OneWayTo(d, Validation.HasErrorProperty);
            _ = BindingHelper.Bind(d, ErrorsProperty)
                .OneWayTo(d, Validation.ErrorsProperty);
            Validation.AddErrorHandler(d, (o, args) => GetEvents((DependencyObject)o).Add(args));
        }
        private static void SetMemberTypeFrom(this GroupDescriptor descriptor, object item)
        {
            if (!descriptor.Member.HasValue())
            {
                return;
            }

            descriptor.MemberType = BindingHelper.ExtractMemberTypeFromObject(item, descriptor.Member);
        }
Exemplo n.º 26
0
 public Settings()
 {
     InitializeComponent();
     Loaded += delegate
     {
         SetSettings();
         BindingHelper.SetItemSourceViaEnum(AutoUpdateComboBox, typeof(QuandlConfig.AutoUpdateFrequencies));
     };
 }
 public MonorailMailer PayerRegistred(Payer payer)
 {
     GeneralizationPropertyChanged(payer, payer.Comment);
     To         = "[email protected], [email protected]";
     IsBodyHtml = true;
     Template   = "PropertyChanged_html";
     Subject    = String.Format("Зарегистрирован {0}", BindingHelper.GetDescription(payer).ToLower());
     return(this);
 }
Exemplo n.º 28
0
        public static void BindClassList(DropDownList DropDownList, int type_id)
        {
            string    sql    = "SELECT type_id,type_name FROM ProductType with(nolock) order by sort_order";
            SqlHelper helper = LocalSqlHelper.WH;
            DataTable dt     = helper.ExecDataTable(sql);

            BindingHelper.BindDDL(DropDownList, dt, "type_name", "type_id", false);
            DropDownList.SelectedValue = type_id.ToString();
        }
Exemplo n.º 29
0
        public static void BindAgentList(DropDownList DownList, int Agent_id)
        {
            string    sql    = "SELECT Agent_id,Agent_name FROM Tb_Agent order by Agent_id desc";
            SqlHelper helper = LocalSqlHelper.WH;
            DataTable dt     = helper.ExecDataTable(sql);

            BindingHelper.BindDDL(DownList, dt, "Agent_name", "Agent_id", false);
            DownList.SelectedValue = Agent_id.ToString();
        }
Exemplo n.º 30
0
        public static void BindBrandList(DropDownList DownList, string BrandName)
        {
            string    sql    = "SELECT brand_name FROM Tb_brand order by brand_name desc";
            SqlHelper helper = LocalSqlHelper.WH;
            DataTable dt     = helper.ExecDataTable(sql);

            BindingHelper.BindDDL(DownList, dt, "brand_name", "brand_name", false);
            DownList.SelectedValue = BrandName;
        }
Exemplo n.º 31
0
        protected virtual void OnItemsSource2DChanged(IEnumerable oldValue, IEnumerable newValue)
        {
            // Multi Dimensional Arrays with more than 2 dimensions
            // crash on iList[0].
            if (newValue != null && newValue is IList && newValue.GetType().Name.IndexOf("[,,", StringComparison.Ordinal) == -1)
            {
                var type = newValue.GetType();
                var elementType = newValue.GetType().GetElementType();

                var iList = newValue as IList;
                bool multiDimensionalArray = type.IsArray && type.GetArrayRank() == 2;
                if (multiDimensionalArray) // 2D MultiDimensional Array
                {
                    var bindingHelper = new BindingHelper();
                    var method = typeof(BindingHelper).GetMethod("GetBindableMultiDimensionalArray");
                    var generic = method.MakeGenericMethod(elementType);
                    ItemsSource = generic.Invoke(bindingHelper, new object[] { newValue }) as DataView;
                }
                else
                {
                    if (iList.Count == 0)
                    {
                        ItemsSource = null;
                        return;
                    }
                    if (iList[0] is IList) // 2D List
                    {
                        var iListRow1 = iList[0] as IList;
                        if (iListRow1.Count == 0)
                        {
                            ItemsSource = null;
                            return;
                        }
                        var listType = iListRow1[0].GetType();
                        var bindingHelper = new BindingHelper();
                        var method = typeof(BindingHelper).GetMethod("GetBindable2DViewFromIList");
                        var generic = method.MakeGenericMethod(listType);
                        ItemsSource = generic.Invoke(bindingHelper, new object[] { iList }) as DataView;
                    }
                    else // 1D List
                    {
                        var listType = iList[0].GetType();
                        var bindingHelper = new BindingHelper();
                        var method = typeof(BindingHelper).GetMethod("GetBindable1DViewFromIList");
                        var generic = method.MakeGenericMethod(listType);
                        ItemsSource = generic.Invoke(bindingHelper, new object[] { iList }) as DataView;
                    }
                }
            }
            else
            {
                ItemsSource = null;
            }
        }
        /// <summary>
        /// Setup binding between GUI element (like TextBox or ComboBox)
        /// and gauge element
        /// </summary>
        /// <param name="guiElement"></param>
        /// <param name="valueProperty"></param>
        /// <param name="gaugeElement"></param>
        /// <param name="gaugeProperty"></param>
        protected void SetupBinding(FrameworkElement guiElement,
            DependencyProperty valueProperty,
            FrameworkElement gaugeElement,
            DependencyProperty gaugeProperty,
            IValueConverter converter,
            object converterParameter)
        {
            BindingHelper helper = new BindingHelper();
            Binding binding = new Binding();
            binding.Source = helper;
            binding.Path = new PropertyPath("Value");
            binding.Mode = BindingMode.TwoWay;
            binding.Converter = converter;
            binding.ConverterParameter = converterParameter;
            guiElement.SetBinding(valueProperty, binding);

            binding = new Binding();
            binding.Source = helper;
            binding.Path = new PropertyPath("Value");
            gaugeElement.SetBinding(gaugeProperty, binding);
        }