Esempio n. 1
0
        public static TabPage Create(SettingCategory category, ToolTip toolTip, ContextMenuStrip contextMenu,
                                     Action <ISettingControl> settingControlFunc)
        {
            var tabPage = new TabPage(category.Name)
            {
                AutoScroll = true
            };
            TableLayoutPanel layout = new TableLayoutPanel
            {
                Dock        = DockStyle.Top,
                ColumnCount = 1,
                AutoSize    = true
            };

            foreach (var setting in category.Settings.Values)
            {
                var settingControl = CreateSettingControl(toolTip, setting);
                if (settingControl != null)
                {
                    settingControl.Control.Dock             = DockStyle.Fill;
                    settingControl.Control.ContextMenuStrip = contextMenu;
                    layout.Controls.Add(settingControl.Control);
                    settingControlFunc.Invoke(settingControl);
                }
            }
            tabPage.Controls.Add(layout);
            return(tabPage);
        }
Esempio n. 2
0
        private void InitForModify()
        {
            SettingCategoryInfo dataById = SettingCategory.GetDataById(base.OpID);

            this.TextBox1.Text = dataById.CateName;
            this.TextBox2.Text = dataById.CateDesc;
        }
Esempio n. 3
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         SettingCategoryInfo settingCategoryInfo = new SettingCategoryInfo();
         if (base.IsEdit)
         {
             settingCategoryInfo = SettingCategory.GetDataById(base.OpID);
         }
         settingCategoryInfo.CateName      = WebUtils.GetString(this.TextBox1.Text);
         settingCategoryInfo.CateDesc      = WebUtils.GetString(this.TextBox2.Text);
         settingCategoryInfo.IsUsing       = true;
         settingCategoryInfo.AutoTimeStamp = System.DateTime.Now;
         if (string.IsNullOrEmpty(settingCategoryInfo.CateName))
         {
             base.ShowMsg("Tên loại Cấu hình không thể để trống");
         }
         else if (string.IsNullOrEmpty(settingCategoryInfo.CateDesc))
         {
             base.ShowMsg("Tên hiển thị không thể để trống");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 if (SettingCategory.Add(settingCategoryInfo) > 0)
                 {
                     CacheUtils.Del("JsonLeeCMS_CacheForGetSettingCategory");
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "Thêm cấu hình tùy chỉnh [" + settingCategoryInfo.CateDesc + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("Thêm cấu hình tùy chỉnh thất bại");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (SettingCategory.Update(settingCategoryInfo))
                 {
                     CacheUtils.Del("JsonLeeCMS_CacheForGetSettingCategory");
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "Sửa đổi các cấu hình tùy chỉnh [" + settingCategoryInfo.CateDesc + "] thành công");
                     MessageUtils.DialogCloseAndParentReload(this);
                 }
                 else
                 {
                     base.ShowMsg("Sửa đổi các cấu hình tùy chỉnh thất bại");
                 }
             }
         }
     }
 }
Esempio n. 4
0
 protected void lnk_Delete_Click(object sender, System.EventArgs e)
 {
     if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
     {
         base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
     }
     else
     {
         int @int = WebUtils.GetInt((sender as LinkButton).CommandArgument);
         SettingCategoryInfo cacheSettingCategory = SettingCategory.GetCacheSettingCategory(@int);
         if (cacheSettingCategory == null)
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Không tìm thấy dữ liệu, dữ liệu không tồn tại hoặc đã bị xóa ");
         }
         else if (SettingCategory.ExistsChildSetting(cacheSettingCategory.AutoID))
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Không thể bị xóa, bao gồm các thiết lập tùy chỉnh");
         }
         else if (SettingCategory.Delete(cacheSettingCategory.AutoID))
         {
             CacheUtils.Del("JsonLeeCMS_CacheForGetSettingCategory");
             this.BindData();
             PageBase.log.AddEvent(base.LoginAccount.AccountName, "Xóa các thiết lập tùy chỉnh [" + cacheSettingCategory.CateName + "] thành công");
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thành công");
         }
         else
         {
             base.ShowAjaxMsg(this.UpdatePanel1, "Thao tác thất bại");
         }
     }
 }
Esempio n. 5
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.cate = SettingCategory.GetDataById(WebUtils.GetQueryInt("cateid"));
     if (!base.IsPostBack)
     {
         this.BindData();
     }
 }
Esempio n. 6
0
        public static SettingsData ReadFromFile(SettingCategory category, string file)
        {
            var data = new SettingsData(category){
                Provenance = file
            };

            ReadFromFile(file, data);

            return data;
        }
Esempio n. 7
0
        public XmlSettingsData(XmlElement element)
        {
            _category = (SettingCategory)(element.HasAttribute("category")
                                               ? Enum.Parse(typeof(SettingCategory), element.GetAttribute("category"))
                                               : SettingCategory.core);

            element.SelectNodes("add").OfType <XmlElement>().Each(elem =>
            {
                _values.Add(elem.GetAttribute("key"), elem.GetAttribute("value"));
            });
        }
        public static SettingsData ReadFromFile(SettingCategory category, string file)
        {
            var data = new SettingsData(category)
            {
                Provenance = file
            };

            ReadFromFile(file, data);

            return(data);
        }
Esempio n. 9
0
        public static SettingsData ReadFromFile(SettingCategory category, string file)
        {
            var data = new SettingsData(category)
            {
                Provenance = file
            };

            StringPropertyReader.ForFile(file).ReadProperties((key, value) => data[key] = value);

            return(data);
        }
Esempio n. 10
0
        private void BindData()
        {
            int    recordCount = 0;
            int    num         = 0;
            string strSort     = " AutoID ASC ";

            this.SinGooPager1.PageSize = WebUtils.GetInt(this.drpPageSize.SelectedValue);
            this.Repeater1.DataSource  = SettingCategory.GetPagerList(this.GetCondition(), strSort, this.SinGooPager1.PageIndex, this.SinGooPager1.PageSize, ref recordCount, ref num);
            this.Repeater1.DataBind();
            this.SinGooPager1.RecordCount = recordCount;
        }
Esempio n. 11
0
        public XmlSettingsData(XmlElement element)
        {
            _category = (SettingCategory) (element.HasAttribute("category")
                                               ? Enum.Parse(typeof (SettingCategory), element.GetAttribute("category"))
                                               : SettingCategory.core);

            element.SelectNodes("add").OfType<XmlElement>().Each(elem =>
            {
                _values.Add(elem.GetAttribute("key"), elem.GetAttribute("value"));
            });
        }
Esempio n. 12
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.cate = SettingCategory.GetCacheSettingCategory(WebUtils.GetQueryInt("cateid"));
     if (this.cate == null)
     {
         base.ShowMsg("Không tìm thấy cấu hình này, cấu hình không tồn tại hoặc đã bị xóa");
     }
     else if (!base.IsPostBack)
     {
         this.BindData();
     }
 }
Esempio n. 13
0
        private void SetSettingsCategoryPanel(SettingCategory cat)
        {
            switch (cat)
            {
            case SettingCategory.CODE_REPEATER:

                break;

            case SettingCategory.ID_GENERATOR:

                break;
            }
        }
Esempio n. 14
0
        // Constructor
        public formSettings(SettingCategory category)
        {
            InitializeComponent();

            if ((int)category < tabControlSettings.TabCount)
            {
                tabControlSettings.SelectedIndex = (int)category;
            }

            // Refresh
            checkBoxAutoRefresh.Checked = Properties.Settings.Default.AutoRefresh;
            numericUpDownRefreshEvery.SetValue(Properties.Settings.Default.RefreshEvery);
            checkBoxForegroundOnly.Checked = Properties.Settings.Default.ForegroundOnly;
            numericUpDownForceNamesEvery.SetValue(Properties.Settings.Default.ForceNamesEvery);
        }
Esempio n. 15
0
 private void BindCate()
 {
     this.DropDownList2.DataSource     = SettingCategory.GetCacheSettingCategoryList();
     this.DropDownList2.DataTextField  = "CateDesc";
     this.DropDownList2.DataValueField = "AutoID";
     this.DropDownList2.DataBind();
     if (this.cate != null)
     {
         ListItem listItem = this.DropDownList2.Items.FindByValue(this.cate.AutoID.ToString());
         if (listItem != null)
         {
             listItem.Selected          = true;
             this.DropDownList2.Enabled = false;
         }
     }
 }
Esempio n. 16
0
        public SettingItemAttribute(SettingCategory settingCategory,
                                    string displayName,
                                    string introduction,
                                    bool restartRequired,
                                    object defultValue)
        {
            if (!Enum.IsDefined(typeof(SettingCategory), settingCategory))
            {
                throw new ArgumentOutOfRangeException(nameof(settingCategory),
                                                      "Value should be defined in the SettingCategory enum.");
            }


            SettingCategory = settingCategory;
            DisplayName     = displayName ?? throw new ArgumentNullException(nameof(displayName));
            Introduction    = introduction ?? throw new ArgumentNullException(nameof(introduction));
            RestartRequired = restartRequired;
            DefultValue     = defultValue ?? throw new ArgumentNullException(nameof(defultValue));
        }
Esempio n. 17
0
        private void CreateCategory(SettingCategory settingCategory)
        {
            category = settingCategory;
            var childCount = Content.transform.childCount;
            var categoryUi = Instantiate(Category);

            categoryUi.GetComponentInChildren <Text>().text = category.ToString();
            if (childCount == 0)
            {
                CreateEmptyGridItem();
                categoryUi.transform.SetParent(Content.transform);
                CreateEmptyGridItem();
                return;
            }
            var currentColumn = childCount % _columnCount;

            CreateEmptyGridItem(4 - currentColumn);
            categoryUi.transform.SetParent(Content.transform);
            CreateEmptyGridItem();
        }
Esempio n. 18
0
        private void AddCheckBox(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, string name, I18N.I18NString label, bool isChecked, bool isDefaultChecked)
        {
            StackPanel inputPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
            };

            CheckBox cb = new CheckBox
            {
                Name      = name,
                Content   = new Run(I18N.Get(label)),
                Margin    = new Thickness(10),
                IsChecked = isChecked
            };

            cb.Checked += (object sender, RoutedEventArgs e) =>
            {
                HLVRSettingsManager.TrySetSetting(settingcategories, category, name, true);
            };
            cb.Unchecked += (object sender, RoutedEventArgs e) =>
            {
                HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false);
            };
            cb.Indeterminate += (object sender, RoutedEventArgs e) =>
            {
                HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false);
            };
            inputPanel.Children.Add(cb);

            panel.Children.Add(inputPanel);
        }
Esempio n. 19
0
 public override IEnumerable <Type> GetSettingViewsForCategory(SettingCategory category) => category switch
 {
        public static SettingsData ReadFromFile(SettingCategory category, string file)
        {
            var data = new SettingsData(category)
            {
                Provenance = file
            };

            StringPropertyReader.ForFile(file).ReadProperties((key, value) => data[key] = value);

            return data;
        }
 public SettingsData(SettingCategory category) : this(new Dictionary<string, object>())
 {
     Category = category;
 }
Esempio n. 22
0
 public InMemorySettingsData(SettingCategory category)
 {
     Category = category;
 }
Esempio n. 23
0
 protected ProfileBase(SettingCategory category, string provenance)
 {
     _data = new SettingsData(category){
         Provenance = provenance
     };
 }
Esempio n. 24
0
 public SettingsData(SettingCategory category) : this(category, new Dictionary <string, string>())
 {
 }
Esempio n. 25
0
 public SettingsData(SettingCategory category, IDictionary <string, string> substitutions)
 {
     _substitutions = substitutions;
     Category       = category;
 }
 public SettingsData(SettingCategory category)
 {
     Category = category;
 }
 public SettingsData(SettingCategory category)
 {
     Category = category;
 }
 public AppSettingsSettingSource(SettingCategory category)
 {
     _category = category;
 }
Esempio n. 29
0
 public ExportSettingViewAttribute(SettingCategory category = SettingCategory.Misc) => Category = category;
Esempio n. 30
0
 public abstract IEnumerable <Type> GetSettingViewsForCategory(SettingCategory category);
Esempio n. 31
0
 public InMemorySettingsData(SettingCategory category)
 {
     Category = category;
 }
Esempio n. 32
0
 public override IEnumerable <Type> GetSettingViewsForCategory(SettingCategory category)
 => settingViews.Where(x => x.Value == category).Select(x => x.Key);
Esempio n. 33
0
 private void GetCustomSettingCateXML()
 {
     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
     System.Collections.Generic.IList <SettingCategoryInfo> cacheSettingCategoryList = SettingCategory.GetCacheSettingCategoryList();
     if (cacheSettingCategoryList != null && cacheSettingCategoryList.Count > 0)
     {
         foreach (SettingCategoryInfo current in cacheSettingCategoryList)
         {
             stringBuilder.Append(string.Concat(new object[]
             {
                 "{id:'",
                 current.AutoID.ToString(),
                 "',name:'",
                 current.CateDesc,
                 "',isParent:false,'iconSkin':'leaf','click':\"AppendVal(",
                 current.AutoID,
                 ",'",
                 current.CateName,
                 "')\"},"
             }));
         }
     }
     base.Response.Write("[" + stringBuilder.ToString().TrimEnd(new char[]
     {
         ','
     }) + "]");
 }
Esempio n. 34
0
 public SettingsData(SettingCategory category) : this(new Dictionary <string, object>())
 {
     Category = category;
 }
Esempio n. 35
0
        protected void AddCategory(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, OrderedDictionary <string, Setting> settings)
        {
            if (category.Dependency != null && !category.Dependency.IsSatisfied())
            {
                return;
            }

            StackPanel categoryPanel = new StackPanel()
            {
                Orientation = Orientation.Vertical,
                Margin      = new Thickness(20),
            };

            AddTitle(categoryPanel, category.Title);
            AddDescription(categoryPanel, category.Description);

            int numOfSettings = 0;

            foreach (var setting in settings)
            {
                if (setting.Value.Dependency != null && !setting.Value.Dependency.IsSatisfied())
                {
                    continue;
                }

                switch (setting.Value.Type)
                {
                case SettingType.BOOLEAN:
                    AddCheckBox(settingcategories, categoryPanel, category, setting.Key, setting.Value.Description, setting.Value.IsTrue(), !setting.Value.DefaultValue.Equals("0"));
                    break;

                default:
                    AddInput(settingcategories, categoryPanel, category, setting.Key, setting.Value.Description, setting.Value);
                    break;
                }

                numOfSettings++;
            }

            if (numOfSettings > 0)
            {
                panel.Children.Add(categoryPanel);
            }
        }
Esempio n. 36
0
 public SettingsData(SettingCategory category)
     : this(category, new Dictionary<string, string>())
 {
 }
Esempio n. 37
0
        private void AddInput(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, string name, I18N.I18NString label, Setting value)
        {
            StackPanel inputPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(5),
            };

            inputPanel.Children.Add(new TextBlock()
            {
                TextWrapping = TextWrapping.NoWrap,
                Padding      = new Thickness(5),
                Margin       = new Thickness(5),
                Focusable    = true,
                MinWidth     = 150,
                Text         = I18N.Get(label)
            });

            if (value.AllowedValues.Count == 0)
            {
                var textbox = MakeTextBox(value);
                textbox.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    HLVRSettingsManager.TrySetSetting(settingcategories, category, name, textbox.Text);
                };
                inputPanel.Children.Add(textbox);

                if (value.Type == SettingType.SPEED || value.Type == SettingType.DISTANCE)
                {
                    var meterTextbox = MakeTextBox(value);
                    meterTextbox.Text = UnitToMeter(textbox.Text);
                    bool preventinfiniteloop = false;
                    textbox.TextChanged += (object sender, TextChangedEventArgs e) =>
                    {
                        if (preventinfiniteloop)
                        {
                            return;
                        }
                        preventinfiniteloop = true;
                        meterTextbox.Text   = UnitToMeter(textbox.Text);
                        preventinfiniteloop = false;
                    };
                    meterTextbox.TextChanged += (object sender, TextChangedEventArgs e) =>
                    {
                        if (preventinfiniteloop)
                        {
                            return;
                        }
                        preventinfiniteloop = true;
                        textbox.Text        = MeterToUnit(meterTextbox.Text);
                        preventinfiniteloop = false;
                    };
                    inputPanel.Children.Add(CreateMiniText(value.Type == SettingType.SPEED ? "units/s" : "units"));
                    inputPanel.Children.Add(meterTextbox);
                    inputPanel.Children.Add(CreateMiniText(value.Type == SettingType.SPEED ? "cm/s" : "cm"));

                    inputPanel.Children.Add(CreateDefaultLabel(value.DefaultValue + "/" + UnitToMeter(value.DefaultValue)));
                }
                else
                {
                    inputPanel.Children.Add(CreateDefaultLabel(value.DefaultValue));
                }
            }
            else
            {
                var combobox = new ComboBox()
                {
                    MinWidth = 200,
                };
                int             index         = 0;
                int             selectedIndex = 0;
                I18N.I18NString defaultValue  = null;
                foreach (var allowedValue in value.AllowedValues)
                {
                    var comboboxitem = new ComboBoxItem()
                    {
                    };
                    comboboxitem.Content = allowedValue.Value;
                    combobox.Items.Add(comboboxitem);
                    if (allowedValue.Key.Equals(value.Value))
                    {
                        selectedIndex = index;
                    }
                    if (allowedValue.Key.Equals(value.DefaultValue))
                    {
                        defaultValue = allowedValue.Value;
                    }
                    index++;
                }
                combobox.SelectedIndex     = selectedIndex;
                combobox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
                {
                    HLVRSettingsManager.TrySetSetting(settingcategories, category, name, ((I18N.I18NString)(combobox.SelectedValue as ComboBoxItem).Content).Key);
                };
                inputPanel.Children.Add(combobox);

                if (defaultValue != null)
                {
                    inputPanel.Children.Add(CreateDefaultLabel(I18N.Get(defaultValue)));
                }
            }

            panel.Children.Add(inputPanel);
        }
Esempio n. 38
0
 public SettingsData(SettingCategory category, IDictionary<string, string> substitutions)
 {
     _substitutions = substitutions;
     Category = category;
 }
Esempio n. 39
0
 public AppSettingsSettingSource(SettingCategory category)
 {
     _category = category;
 }
Esempio n. 40
0
 public UiElementAttribute(string label, string description, SettingCategory category = SettingCategory.General)
 {
     Label       = label;
     Description = description;
     Category    = category;
 }