コード例 #1
0
        protected void Add(ISettingItem item)
        {
            if (item.IsHidden == false)
            {
                items.Add(item);
            }

            if (item is ISettingValue)
            {
                if (item.IsHidden == false)
                {
                    settings.Add(item as ISettingValue);
                }

                AllValues.Add(item as ISettingValue);
            }
            else if (item is SettingCategrory)
            {
                if (item.IsHidden == false)
                {
                    settings.AddRange((item as SettingCategrory).settings);
                }

                AllValues.AddRange((item as SettingCategrory).AllValues);
            }
        }
コード例 #2
0
        public CefBrowserProvider(IHttpProxy proxy, IShellContextService shellContextService, ISettingsManager settings)
        {
            this.proxy = proxy;
            this.shellContextService = shellContextService;

            clearCacheOnStartup = settings.Register("cef.clear_cache_on_startup", false);
        }
コード例 #3
0
        /// <summary>
        /// Configures the unique UDP connection.
        /// </summary>
        /// <param name="connectionInfo">The connection information.</param>
        /// <param name="reporter">The reporter.</param>
        /// <param name="timeout">The timeout in milliseconds.</param>
        /// <param name="retryLimit">The retry limit.</param>
        /// <returns>UdpConnectionInfo.</returns>
        /// <exception cref="System.Exception">Device send IP address and/or port could not be configured for unique connection.</exception>
        /// <autogeneratedoc />
        /// <remarks>
        /// The device may not respond for up to 5 seconds. The total retry period must therefore be greater than 5 seconds.
        /// </remarks>
        public static UdpConnectionInfo ConfigureUniqueUdpConnection(UdpConnectionInfo connectionInfo, IReporter reporter = null, int timeout = 500, int retryLimit = 20)
        {
            UdpConnectionInfo uniqueConnectionInfo = UdpConnectionInfo.CreateUniqueConnectionInfo(connectionInfo);

            Connection uniqueConnection = new Connection(uniqueConnectionInfo);

            try
            {
                if (reporter != null)
                {
                    uniqueConnection.Error     += reporter.OnError;
                    uniqueConnection.Exception += reporter.OnException;
                    uniqueConnection.Info      += reporter.OnInfo;
                    uniqueConnection.Message   += reporter.OnMessage;
                }

                // connect using the correct receive Port
                uniqueConnection.Connect();

                uniqueConnection.Settings.WifiSendIPAddress.Value = uniqueConnectionInfo.AdapterIPAddress;
                uniqueConnection.Settings.WifiSendPort.Value      = (ushort)uniqueConnectionInfo.ReceivePort;

                ISettingItem[] settingsToBeWritten = new ISettingItem[] { uniqueConnection.Settings.WifiSendIPAddress, uniqueConnection.Settings.WifiSendPort };

                int retryCount = 0;

                while (true)
                {
                    if (uniqueConnection.Settings.Write(settingsToBeWritten, reporter, timeout, 0) == CommunicationProcessResult.Success)
                    {
                        break;
                    }
                    else if (retryCount++ <= retryLimit)
                    {
                        Commands.Send(uniqueConnection, Command.Apply, 0, 0);
                    }
                    else
                    {
                        throw new Exception("Device send IP address and/or port could not be configured for unique connection.");
                    }
                }
            }
            finally
            {
                uniqueConnection.Close();

                if (reporter != null)
                {
                    uniqueConnection.Error     -= reporter.OnError;
                    uniqueConnection.Exception -= reporter.OnException;
                    uniqueConnection.Info      -= reporter.OnInfo;
                    uniqueConnection.Message   -= reporter.OnMessage;
                }
            }

            return(uniqueConnectionInfo);
        }
コード例 #4
0
ファイル: MyViewModel.cs プロジェクト: eustachywieczorek/RRR
 public async Task ExecuteSetting(ISettingItem o)
 {
     if (o != null)
     {
         try {
             await o.Execute(this.Container, this.NS);
         }
         catch (Exception e) {
             throw e;
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the SettingItem class.
        /// </summary>
        /// <param name="settingId">The setting ID.</param>
        public SettingItem(string settingId)
        {
            string dllPath = GetSettingDll(settingId);

            if (dllPath == null)
            {
                throw new SettingFailedException("No such setting");
            }

            this.settingItem = this.GetSettingItem(settingId, dllPath);
            this.SettingType = this.settingItem.Type;
        }
コード例 #6
0
ファイル: SettingItem.cs プロジェクト: krisYanachkov/windows
        /// <summary>
        /// Initializes a new instance of the SettingItem class.
        /// </summary>
        /// <param name="settingId">The setting ID.</param>
        /// <param name="dryRun">true to make Invoke and SetValue methods do nothing.</param>
        public SettingItem(string settingId, bool dryRun = false, bool async = false)
        {
            this.async  = async;
            this.dryRun = dryRun;
            string dllPath = this.GetSettingDll(settingId);

            if (dllPath == null)
            {
                throw new SettingFailedException("No such setting");
            }

            this.settingItem = this.GetSettingItem(settingId, dllPath);
            this.SettingType = this.settingItem.Type;
        }
コード例 #7
0
        /// <summary>
        /// Wait for <code>IsUpdating</code> to be false
        /// </summary>
        /// <param name="item"></param>
        /// <param name="timeoutInSeconds">The longeset time to wait for</param>
        /// <returns>Whether the item completed updated within the allotted time</returns>
        public static Task <(bool, long)> WaitForUpdate(this ISettingItem item, int timeoutInSeconds)
        {
            var task = new Task <(bool, long)>(() =>
            {
                var timeoutInMilliseconds = timeoutInSeconds * 1000;
                var watch = new Stopwatch();
                watch.Start();
                while (item.IsUpdating && watch.ElapsedMilliseconds < timeoutInMilliseconds)
                {
                    // Busy wait for the first 50ms and then sleep for 50ms intervals
                    if (watch.ElapsedMilliseconds > 50)
                    {
                        Thread.Sleep(50);
                    }
                }
                return(!item.IsUpdating, watch.ElapsedMilliseconds);
            });

            task.Start();
            return(task);
        }
コード例 #8
0
        /// <summary>
        /// Returns a new field set with legend for a new settings group
        /// </summary>
        /// <param name="currentItem">
        /// The settings item
        /// </param>
        /// <returns>
        /// Fieldset control
        /// </returns>
        private static HtmlGenericControl CreateNewFieldSet(ISettingItem currentItem)
        {
            // start a new fieldset
            var fieldset = new HtmlGenericControl("fieldset");

            fieldset.Attributes.Add(
                "class", string.Concat("SettingsTableGroup ", currentItem.Group.ToString().ToLower()));

            // create group legend
            var legend = new HtmlGenericControl("legend");

            legend.Attributes.Add("class", "SubSubHead");
            var legendText = new Localize
            {
                TextKey = currentItem.Group.ToString(), Text = currentItem.GroupDescription
            };

            legend.Controls.Add(legendText);
            fieldset.Controls.Add(legend);

            return(fieldset);
        }
コード例 #9
0
 /// <summary>
 /// Inserts or updates the setting.
 /// </summary>
 /// <param name="settingItem">
 /// The setting item.
 /// </param>
 /// <remarks>
 /// </remarks>
 public void Upsert(ISettingItem settingItem)
 {
     UpdatePortalSetting(this.PortalID, settingItem.EnglishName, Convert.ToString(settingItem.Value));
 }
コード例 #10
0
 /// <summary>
 /// Inserts or updates the setting.
 /// </summary>
 /// <param name="settingItem">
 /// The setting item.
 /// </param>
 /// <remarks>
 /// </remarks>
 public void Upsert(ISettingItem settingItem)
 {
     UpdatePageSettings(this.PageID, settingItem.EnglishName, settingItem.Value.ToString());
 }
コード例 #11
0
        /// <summary>
        /// Returns one settings row that contains a cell for help, a cell for setting item
        ///     name and a cell for setting item and validators.
        /// </summary>
        /// <param name="currentSetting">
        /// The current setting.
        /// </param>
        /// <param name="currentItem">
        /// The current item.
        /// </param>
        /// <returns>
        /// A table row.
        /// </returns>
        private TableRow CreateOneSettingRow(string currentSetting, ISettingItem currentItem)
        {
            // the table row is going to have three cells
            var row = new TableRow();

            // cell for help icon and description
            var helpCell = new TableCell();
            Image img;

            if (currentItem.Description.Length > 0)
            {
                var myimg = ((Page)this.Page).CurrentTheme.GetImage("Buttons_Help", "Help.gif");
                img = new Image
                    {
                        ImageUrl = myimg.ImageUrl,
                        Height = myimg.Height,
                        Width = myimg.Width,
                        AlternateText = currentItem.Description
                    };

                // Jminond: added netscape tooltip support
                img.Attributes.Add("title", General.GetString(currentSetting + "_DESCRIPTION"));
                img.ToolTip = General.GetString(currentSetting + "_DESCRIPTION"); // Fixed key for simplicity
            }
            else
            {
                // Jes1111 - 17/12/2004
                img = new Image
                    {
                        Width = Unit.Pixel(25),
                        ImageUrl = ((Page)this.Page).CurrentTheme.GetImage("Spacer", "Spacer.gif").ImageUrl
                    };
            }

            helpCell.Controls.Add(img);

            // add help cell to the row
            row.Cells.Add(helpCell);

            // Setting Name cell
            var nameCell = new TableCell();
            nameCell.Attributes.Add("width", "20%");
            nameCell.CssClass = "SubHead";

            nameCell.Text = currentItem.EnglishName.Length == 0
                                ? General.GetString(currentSetting, currentSetting + "<br />Key Not In Resources")
                                : General.GetString(currentItem.EnglishName, currentItem.EnglishName);

            // add name cell to the row
            row.Cells.Add(nameCell);

            // Setting Control cell
            var settingCell = new TableCell();
            settingCell.Attributes.Add("width", "80%");
            settingCell.CssClass = "st-control";

            StringBuilder script = new StringBuilder();
            script.Append("<script language=\"javascript\" type=\"text/javascript\">");
            //script.AppendFormat("$.extend($.ui.multiselect, { locale: { addAll: '{0}', removeAll: '{1}', itemsCount: '{2}' }});", "Agregar todo", "Remover todooooo", "items seleccionados");
            script.Append("$.extend($.ui.multiselect, { locale: { addAll: '");
            script.AppendFormat("{0}",General.GetString("ADD_ALL", "Add all", null));
            script.Append("',removeAll: '");
            script.AppendFormat("{0}", General.GetString("REMOVE_ALL", "Remove all", null));
            script.Append("',itemsCount: '");
            script.AppendFormat("{0}", General.GetString("ITEMS_SELECTED", "items selected", null));
            script.Append("' }});$(function(){ $.localise('ui-multiselect', {path: 'aspnet_client/jQuery/'});");
            script.Append("$(\".multiselect\").multiselect({sortable: false, searchable: false});}); </script>");

            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "jqueryMultiselect", script.ToString());

            Control editControl;
            try
            {
                editControl = currentItem.EditControl;
                editControl.ID = currentSetting; // Jes1111
                editControl.EnableViewState = true;
            }
            catch (Exception)
            {
                editControl = new LiteralControl("There was an error loading this control");

                // LogHelper.Logger.Log(Appleseed.Framework.LogLevel.Warn, "There was an error loading '" + currentItem.EnglishName + "'", ex);
            }

            settingCell.Controls.Add(editControl);

            // TODO: WHAT IS THIS?
            // nameText.LabelForControl = editControl.ClientID;

            // Add control to edit controls collection
            this.EditControls.Add(currentSetting, editControl);

            // Validators
            settingCell.Controls.Add(new LiteralControl("<br />"));

            // Required
            // TODO : Whhn we bring back ELB easy list box, we need to put this back
            /*
            if (currentItem.Required && !(editControl is ELB.EasyListBox))
            {
                RequiredFieldValidator req = new RequiredFieldValidator();
                req.ErrorMessage =General.GetString("SETTING_REQUIRED", "%1% is required!", req).Replace("%1%", currentSetting);
                req.ControlToValidate = currentSetting;
                req.CssClass = "Error";
                req.Display = ValidatorDisplay.Dynamic;
                req.EnableClientScript = true;
                settingCell.Controls.Add(req);
            }
            */

            // Range Validator
            if (currentItem.MinValue != 0 || currentItem.MaxValue != 0)
            {
                var rang = new RangeValidator();

                switch (currentItem.Value.GetType().Name.ToLowerInvariant())
                {
                    case "string":
                        rang.Type = ValidationDataType.String;
                        break;

                    case "int":
                        rang.Type = ValidationDataType.Integer;
                        break;

                    // case PropertiesDataType.Currency:
                    //     rang.Type = ValidationDataType.Currency;
                    //     break;
                    case "datetime":
                        rang.Type = ValidationDataType.Date;
                        break;

                    case "double":
                        rang.Type = ValidationDataType.Double;
                        break;
                }

                if (currentItem.MinValue >= 0 && currentItem.MaxValue >= currentItem.MinValue)
                {
                    rang.MinimumValue = currentItem.MinValue.ToString();

                    if (currentItem.MaxValue == 0)
                    {
                        rang.ErrorMessage =
                            General.GetString(
                                "SETTING_EQUAL_OR_GREATER", "%1% must be equal or greater than %2%!", rang).Replace(
                                    "%1%", currentSetting).Replace("%2%", currentItem.MinValue.ToString());
                    }
                    else
                    {
                        rang.MaximumValue = currentItem.MaxValue.ToString();
                        rang.ErrorMessage =
                            General.GetString("SETTING_BETWEEN", "%1% must be between %2% and %3%!", rang).Replace(
                                "%1%", currentSetting).Replace("%2%", currentItem.MinValue.ToString()).Replace(
                                    "%3%", currentItem.MaxValue.ToString());
                    }
                }

                rang.ControlToValidate = currentSetting;
                rang.CssClass = "Error";
                rang.Display = ValidatorDisplay.Dynamic;
                rang.EnableClientScript = true;
                settingCell.Controls.Add(rang);
            }

            // add setting cell into the row
            row.Cells.Add(settingCell);

            // all done send it back
            return row;
        }
コード例 #12
0
 /// <summary>
 /// Inserts or updates the setting.
 /// </summary>
 /// <param name="settingItem">
 /// The setting item.
 /// </param>
 /// <remarks>
 /// </remarks>
 public void Upsert(ISettingItem settingItem)
 {
     UpdatePageSettings(this.PageID, settingItem.EnglishName, settingItem.Value.ToString());
 }
コード例 #13
0
 public StringEditorViewModel(ISettingItem item)
 {
     this.SettingItem = item;
 }
コード例 #14
0
 public OnOffEditorViewModel(ISettingItem item)
 {
     this.SettingItem = item;
 }
コード例 #15
0
ファイル: SettingsTable.cs プロジェクト: wforney/portal
        /// <summary>
        /// Returns one settings row that contains a cell for help, a cell for setting item
        ///     name and a cell for setting item and validators.
        /// </summary>
        /// <param name="currentSetting">
        /// The current setting.
        /// </param>
        /// <param name="currentItem">
        /// The current item.
        /// </param>
        /// <returns>
        /// A table row.
        /// </returns>
        private TableRow CreateOneSettingRow(string currentSetting, ISettingItem currentItem)
        {
            // the table row is going to have three cells
            var row = new TableRow();

            // cell for help icon and description
            var   helpCell = new TableCell();
            Image img;

            if (currentItem.Description.Length > 0)
            {
                var myimg = ((Page)this.Page).CurrentTheme.GetImage("Buttons_Help", "Help.gif");
                img = new Image
                {
                    ImageUrl      = myimg.ImageUrl,
                    Height        = myimg.Height,
                    Width         = myimg.Width,
                    AlternateText = currentItem.Description
                };

                // Jminond: added netscape tooltip support
                img.Attributes.Add("title", General.GetString(currentSetting + "_DESCRIPTION"));
                img.ToolTip = General.GetString(currentSetting + "_DESCRIPTION"); // Fixed key for simplicity
            }
            else
            {
                // Jes1111 - 17/12/2004
                img = new Image
                {
                    Width    = Unit.Pixel(25),
                    ImageUrl = ((Page)this.Page).CurrentTheme.GetImage("Spacer", "Spacer.gif").ImageUrl
                };
            }

            helpCell.Controls.Add(img);

            // add help cell to the row
            row.Cells.Add(helpCell);

            // Setting Name cell
            var nameCell = new TableCell();

            nameCell.Attributes.Add("width", "20%");
            nameCell.CssClass = "SubHead";

            nameCell.Text = currentItem.EnglishName.Length == 0
                                ? General.GetString(currentSetting, currentSetting + "<br />Key Not In Resources")
                                : General.GetString(currentItem.EnglishName, currentItem.EnglishName);

            // add name cell to the row
            row.Cells.Add(nameCell);

            // Setting Control cell
            var settingCell = new TableCell();

            settingCell.Attributes.Add("width", "80%");
            settingCell.CssClass = "st-control";

            StringBuilder script = new StringBuilder();

            script.Append("<script language=\"javascript\" type=\"text/javascript\">");
            //script.AppendFormat("$.extend($.ui.multiselect, { locale: { addAll: '{0}', removeAll: '{1}', itemsCount: '{2}' }});", "Agregar todo", "Remover todooooo", "items seleccionados");
            script.Append("$.extend($.ui.multiselect, { locale: { addAll: '");
            script.AppendFormat("{0}", General.GetString("ADD_ALL", "Add all", null));
            script.Append("',removeAll: '");
            script.AppendFormat("{0}", General.GetString("REMOVE_ALL", "Remove all", null));
            script.Append("',itemsCount: '");
            script.AppendFormat("{0}", General.GetString("ITEMS_SELECTED", "items selected", null));
            script.Append("' }});$(function(){ $.localise('ui-multiselect', {path: 'aspnet_client/jQuery/'});");
            script.Append("$(\".multiselect\").multiselect({sortable: false, searchable: false});}); </script>");

            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "jqueryMultiselect", script.ToString());


            Control editControl;

            try
            {
                editControl    = currentItem.EditControl;
                editControl.ID = currentSetting; // Jes1111
                editControl.EnableViewState = true;
            }
            catch (Exception)
            {
                editControl = new LiteralControl("There was an error loading this control");

                // LogHelper.Logger.Log(Appleseed.Framework.LogLevel.Warn, "There was an error loading '" + currentItem.EnglishName + "'", ex);
            }

            settingCell.Controls.Add(editControl);

            // TODO: WHAT IS THIS?
            // nameText.LabelForControl = editControl.ClientID;

            // Add control to edit controls collection
            this.EditControls.Add(currentSetting, editControl);

            // Validators
            settingCell.Controls.Add(new LiteralControl("<br />"));

            // Required
            // TODO : Whhn we bring back ELB easy list box, we need to put this back

            /*
             * if (currentItem.Required && !(editControl is ELB.EasyListBox))
             * {
             *  RequiredFieldValidator req = new RequiredFieldValidator();
             *  req.ErrorMessage =General.GetString("SETTING_REQUIRED", "%1% is required!", req).Replace("%1%", currentSetting);
             *  req.ControlToValidate = currentSetting;
             *  req.CssClass = "Error";
             *  req.Display = ValidatorDisplay.Dynamic;
             *  req.EnableClientScript = true;
             *  settingCell.Controls.Add(req);
             * }
             */

            // Range Validator
            if (currentItem.MinValue != 0 || currentItem.MaxValue != 0)
            {
                var rang = new RangeValidator();

                switch (currentItem.Value.GetType().Name.ToLowerInvariant())
                {
                case "string":
                    rang.Type = ValidationDataType.String;
                    break;

                case "int":
                case "int16":
                case "int32":
                case "int64":
                    rang.Type = ValidationDataType.Integer;
                    break;

                // case PropertiesDataType.Currency:
                //     rang.Type = ValidationDataType.Currency;
                //     break;
                case "datetime":
                    rang.Type = ValidationDataType.Date;
                    break;

                case "double":
                    rang.Type = ValidationDataType.Double;
                    break;
                }

                if (currentItem.MinValue >= 0 && currentItem.MaxValue >= currentItem.MinValue)
                {
                    rang.MinimumValue = currentItem.MinValue.ToString();

                    if (currentItem.MaxValue == 0)
                    {
                        rang.ErrorMessage =
                            General.GetString(
                                "SETTING_EQUAL_OR_GREATER", "%1% must be equal or greater than %2%!", rang).Replace(
                                "%1%", General.GetString(currentSetting)).Replace("%2%", currentItem.MinValue.ToString());
                    }
                    else
                    {
                        rang.MaximumValue = currentItem.MaxValue.ToString();
                        rang.ErrorMessage =
                            General.GetString("SETTING_BETWEEN", "%1% must be between %2% and %3%!", rang).Replace(
                                "%1%", General.GetString(currentSetting)).Replace("%2%", currentItem.MinValue.ToString()).Replace(
                                "%3%", currentItem.MaxValue.ToString());
                    }
                }

                rang.ControlToValidate  = currentSetting;
                rang.CssClass           = "Error";
                rang.Display            = ValidatorDisplay.Dynamic;
                rang.EnableClientScript = true;
                settingCell.Controls.Add(rang);
            }

            // add setting cell into the row
            row.Cells.Add(settingCell);

            // all done send it back
            return(row);
        }
コード例 #16
0
 /// <summary>
 /// Inserts or updates the setting.
 /// </summary>
 /// <param name="settingItem">
 /// The setting item.
 /// </param>
 /// <remarks>
 /// </remarks>
 public void Upsert(ISettingItem settingItem)
 {
     UpdateModuleSetting(this.ModuleID, settingItem.EnglishName, settingItem.Value.ToString());
 }
コード例 #17
0
 /// <summary>
 /// Inserts or updates the setting.
 /// </summary>
 /// <param name="settingItem">
 /// The setting item.
 /// </param>
 /// <remarks>
 /// </remarks>
 public void Upsert(ISettingItem settingItem)
 {
     UpdateModuleSetting(this.ModuleID, settingItem.EnglishName, settingItem.Value.ToString());
 }
コード例 #18
0
        /// <summary>
        /// Returns a new field set with legend for a new settings group
        /// </summary>
        /// <param name="currentItem">
        /// The settings item
        /// </param>
        /// <returns>
        /// Fieldset control
        /// </returns>
        private static HtmlGenericControl CreateNewFieldSet(ISettingItem currentItem)
        {
            // start a new fieldset
            var fieldset = new HtmlGenericControl("fieldset");
            fieldset.Attributes.Add(
                "class", string.Concat("SettingsTableGroup ", currentItem.Group.ToString().ToLower()));

            // create group legend
            var legend = new HtmlGenericControl("legend");
            legend.Attributes.Add("class", "SubSubHead");
            var legendText = new Localize
                {
                   TextKey = currentItem.Group.ToString(), Text = currentItem.GroupDescription
                };
            legend.Controls.Add(legendText);
            fieldset.Controls.Add(legend);

            return fieldset;
        }
コード例 #19
0
ファイル: Manager.cs プロジェクト: wforney/portal
 /// <summary>
 /// Sets the specified setting name.
 /// </summary>
 /// <param name="settingHolder">The setting holder.</param>
 /// <param name="settingItem">The setting item.</param>
 /// <remarks></remarks>
 public void Set(ISettingHolder settingHolder, ISettingItem settingItem)
 {
     settingHolder.Upsert(settingItem);
 }
コード例 #20
0
ファイル: DebugSettingView.xaml.cs プロジェクト: lyu0912/ing
 public DebugSettingView(UWPHttpProviderSelector selector)
 {
     DebugData     = selector.Settings.Debug;
     DebugProvider = selector.Current as DebugHttpProvider;
     InitializeComponent();
 }
コード例 #21
0
 public AccountEditorViewModel(ISettingItem item)
 {
     this.SettingItem = item;
 }