示例#1
0
        public ActionResult Translate(string culture, ProductModel model, string @return)
        {
            var product     = CurrentInstance.Database.Repository <Product>().Find(model.Id);
            var productType = product.ProductType;
            var controls    = FormControls.Controls().ToList();

            var translations = new List <PropertyTranslation>();

            translations.Add(new PropertyTranslation("Name", product.Name, model.Name));

            foreach (var definition in productType.CustomFieldDefinitions)
            {
                var field   = model.CustomFields.FirstOrDefault(c => c.FieldName == definition.Name);
                var control = controls.Find(c => c.Name == definition.ControlType);

                if (!control.IsSelectionList && !control.IsValuesPredefined)
                {
                    var originalField = product.CustomFields.FirstOrDefault(f => f.FieldName == definition.Name);
                    translations.Add(new PropertyTranslation("CustomFields[" + field.FieldName + "]", originalField == null ? null : originalField.FieldValue, field.FieldValue));
                }
            }

            _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), new EntityKey(typeof(Product), model.Id), translations);

            foreach (var variant in model.Variants)
            {
                var originalVariant = product.Variants.FirstOrDefault(v => v.Id == variant.Id);
                var variantKey      = new EntityKey(typeof(ProductVariant), variant.Id);
                _translationStore.AddOrUpdate(CultureInfo.GetCultureInfo(culture), variantKey, GetVariantTranslations(variant, originalVariant, productType, controls));
            }

            return(AjaxForm().RedirectTo(@return));
        }
示例#2
0
 private void txt_SearchCst_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_SearchCst.Text))
     {
         FormControls.BindData(dgv_Customers, command: defaultCustomersCommand);
     }
 }
示例#3
0
 private void txt_Search_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_Search.Text))
     {
         FormControls.BindData(dgv_Products, command: defaultProductsCommand);
     }
 }
示例#4
0
        //Connects tp the given server to get the database names.
        private async void btn_export_connect_Click(object sender, EventArgs e)
        {
            FormControls.EnableLoadingIcon();
            FormControls.ToggleAllElements(false);

            string exportConnectionString = _dbExporter.GetExportConnectionString();

            if (await Utilities.TestConnection(exportConnectionString, true))
            {
                databaseNamesFull = await _dbExporter.GetDatabaseNames(exportConnectionString);
            }

            userDatabaseNames = databaseNamesFull.Where(x => !_systemDatabaseNames.Contains(x.ToLower())).ToList();

            if (userDatabaseNames.Count == 0)
            {
                return;
            }

            Config.AddUpdateSetting("Export_ServerName", txtbx_export_server_name.Text);
            Config.AddUpdateSetting("Export_Username", txtbx_export_username.Text);
            Config.AddUpdateSetting("Export_Password", txtbx_export_password.Text);

            //Clear the database items that are currently showing.
            FormControls.UpdateDatabasesCheckedList(userDatabaseNames);
            FormControls.EnableLoadingIcon(false);
        }
        protected override void MapProperty(System.Reflection.PropertyInfo targetProperty, object source, object target, Type sourceType, Type targetType, string propertyPath, MappingContext context)
        {
            var model   = target as ProductVariant;
            var variant = source as Kooboo.Commerce.Products.ProductVariant;

            if (targetProperty.Name == "VariantFields" && context.Includes.Includes(propertyPath))
            {
                var product     = context.ApiContext.Database.Repository <Kooboo.Commerce.Products.Product>().Find(variant.ProductId);
                var productType = product.ProductType;

                var controls = FormControls.Controls().ToList();

                foreach (var definition in productType.VariantFieldDefinitions)
                {
                    var field      = variant.VariantFields.FirstOrDefault(f => f.FieldName == definition.Name);
                    var fieldModel = new CustomField
                    {
                        FieldName  = definition.Name,
                        FieldLabel = productType.GetText("VariantFieldDefinitions[" + definition.Name + "].Label", context.ApiContext.Culture),
                        FieldValue = field == null ? null : field.FieldValue
                    };

                    if (String.IsNullOrEmpty(fieldModel.FieldLabel))
                    {
                        fieldModel.FieldLabel = definition.Label;
                    }

                    if (field != null)
                    {
                        var control = controls.Find(c => c.Name == definition.ControlType);
                        if (!control.IsSelectionList && !control.IsValuesPredefined)
                        {
                            fieldModel.FieldText = variant.GetText("VariantFields[" + definition.Name + "]", context.ApiContext.Culture);
                        }
                        else
                        {
                            if (control.IsSelectionList)
                            {
                                fieldModel.FieldText = productType.GetText("VariantFieldDefinitions[" + definition.Name + "].SelectionItems[" + fieldModel.FieldValue + "]", context.ApiContext.Culture);
                            }
                            else
                            {
                                fieldModel.FieldText = productType.GetText("VariantFieldDefinitions[" + definition.Name + "].DefaultValue", context.ApiContext.Culture);
                            }
                        }
                    }

                    if (String.IsNullOrEmpty(fieldModel.FieldText))
                    {
                        fieldModel.FieldText = fieldModel.FieldValue;
                    }

                    model.VariantFields.Add(fieldModel);
                }
            }
            else
            {
                base.MapProperty(targetProperty, source, target, sourceType, targetType, propertyPath, context);
            }
        }
示例#6
0
        //Starts the process of exporting and importing.
        private async void btn_start_Click(object sender, EventArgs e)
        {
            FormControls.ToggleStartButton(false);
            List <string> databaseNames = new List <string>();

            FormControls.ClearOutputToApp();

            for (int i = 0; i < checkedListBox_databases.CheckedItems.Count; i++)
            {
                databaseNames.Add(checkedListBox_databases.CheckedItems[i].ToString());
            }

            string exportConnection = _dbExporter.GetExportConnectionString();
            string importConnection = _dbImporter.GetImportConnectionString();

            if (!await Utilities.TestConnection(exportConnection) || !await Utilities.TestConnection(importConnection))
            {
                return;
            }

            if (await _dbExporter.ExportDatabases(databaseNames, exportConnection))
            {
                await _dbImporter.ImportDatabases(databaseNames, importConnection);
            }

            FormControls.ToggleAllElements(true);
            FormControls.ToggleStartButton(true);
        }
示例#7
0
        private void ShowSuggestions(string textInTheField)
        {
            // find all the items in suggestion that match the current text
            var foundItems = ReturnSuggestionsMatches(textInTheField);

            if (foundItems.Count > 0)
            {
                //show suggestions list
                _suggestionsList.Items.Clear();
                // ReSharper disable once CoVariantArrayConversion
                _suggestionsList.Items.AddRange(foundItems.ToArray());
                _suggestionsList.Visible        = true;
                _suggestionsList.Location       = new Point(Location.X, Location.Y + Height);
                _suggestionsList.Size           = new Size(Size.Width, foundItems.Count >= MaxItemsInSuggestionsList ? (MaxItemsInSuggestionsList + 1) * _suggestionsList.ItemHeight : (foundItems.Count + 1) * _suggestionsList.ItemHeight);
                _suggestionsList.IntegralHeight = true;
                FormControls.RemoveControlByKey(_suggestionsList.Name, _parentForm.Controls);
                _parentForm.Controls.Add(_suggestionsList);
                _suggestionsList.BringToFront();
            }
            else
            {
                //hide suggestions list
                HideSuggestionsList();
            }
        }
示例#8
0
        //Clear dynamic elements when new file is opened
        private void ClearDynamicElements()
        {
            var cleared = false;

            while (!cleared)
            {
                foreach (Control tempControl in Controls)
                {
                    if (tempControl.Name.ToLower().StartsWith("dynamictest"))
                    {
                        FormControls.RemoveControlByKey(tempControl.Name, Controls);
                    }
                }

                cleared = true;
                foreach (Control tempControl in Controls)
                {
                    if (!tempControl.Name.ToLower().StartsWith("dynamictest"))
                    {
                        continue;
                    }
                    cleared = false;
                    break;
                }
            }
        }
示例#9
0
 private void btn_SelectCst_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgv_Customers.SelectedRows.Count == 1)
         {
             SqlCommand getCustomer = new SqlCommand("select customer_id, type, orders_number from customer where customer_id = '" + dgv_Customers.CurrentRow.Cells[0].Value + "'", FormControls.DbConnection);
             customer = new Customer();
             using (SqlDataReader customerReader = getCustomer.ExecuteReader())
             {
                 while (customerReader.Read())
                 {
                     customer.CustomerId = (int)customerReader["customer_id"];
                     customer.Type       = customerReader["type"].ToString();
                     customer.OrdersNum  = (int)customerReader["orders_number"];
                 }
             }
             cstIsSelected = true;
             FormControls.ShowFields(false, btn_SelectCst, gb_SelectCst, dgv_Customers, label9, txt_SearchCst);
         }
         else
         {
             MessageBox.Show("Please select one customer!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        internal RequestForm(IHasRequestForm container)
        {
            Container = container;

            Properties = new FormProperties(this);

            Controls = new FormControls(this);
        }
示例#11
0
 private void txt_SearchCst_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(txt_Search.Text))
     {
         SqlCommand command = new SqlCommand("select * from customer where name LIKE '" + txt_SearchCst.Text + "%' OR surname LIKE '" + txt_SearchCst.Text + "%' OR address LIKE '" + txt_SearchCst.Text + "%' OR phone_number = '" + txt_SearchCst.Text + "' OR email = '" + txt_SearchCst.Text + "' OR type = '" + txt_SearchCst.Text + "'", FormControls.DbConnection);
         FormControls.BindData(dgv_Customers, command: command);
     }
 }
示例#12
0
 private void txt_Search_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(txt_Search.Text))
     {
         SqlCommand command = new SqlCommand("select * from product where product_id = '" + txt_Search.Text + "' OR name LIKE '" + txt_Search.Text + "%' OR brand = '" + txt_Search.Text + "' OR type = '" + txt_Search.Text + "' OR subtype = '" + txt_Search.Text + "'", FormControls.DbConnection);
         FormControls.BindData(dgv_Products, command: command);
     }
 }
示例#13
0
        private List <ProductVariantModel> GetVariants(Product product, ProductType productType, string culture)
        {
            var controls = FormControls.Controls().ToList();
            var models   = new List <ProductVariantModel>();

            foreach (var variant in product.Variants)
            {
                var variantKey  = new EntityKey(typeof(ProductVariant), variant.Id);
                var translation = _translationStore.Find(CultureInfo.GetCultureInfo(culture), variantKey);

                var model = new ProductVariantModel
                {
                    Id    = variant.Id,
                    Sku   = variant.Sku,
                    Price = variant.Price
                };

                foreach (var fieldDefinition in productType.VariantFieldDefinitions)
                {
                    // field might be null because admin can add new fields to product types when products already exist
                    var field    = variant.VariantFields.FirstOrDefault(f => f.FieldName == fieldDefinition.Name);
                    var control  = controls.Find(c => c.Name == fieldDefinition.ControlType);
                    var compared = new CustomFieldModel
                    {
                        FieldName  = fieldDefinition.Name,
                        FieldText  = control.GetFieldDisplayText(fieldDefinition, field == null ? null : field.FieldValue),
                        FieldValue = field == null ? null : field.FieldValue
                    };

                    var translated = new CustomFieldModel
                    {
                        FieldName  = compared.FieldName,
                        FieldText  = compared.FieldText,
                        FieldValue = compared.FieldValue
                    };

                    var diff = new CustomFieldModel
                    {
                        FieldName = compared.FieldName
                    };

                    // If the field value is entered in product editing page, then it's always the field value that get translated
                    if (translation != null && !control.IsSelectionList && !control.IsValuesPredefined)
                    {
                        translated.FieldText  = translation.GetTranslatedText("VariantFields[" + fieldDefinition.Name + "]");
                        translated.FieldValue = translated.FieldText;

                        diff.FieldText = DiffHelper.GetDiffHtml(translation.GetOriginalText("VariantFields[" + fieldDefinition.Name + "]"), field == null ? null : field.FieldValue);
                    }

                    model.VariantFields.Add(new TranslationTuple <CustomFieldModel>(compared, diff, translated));
                }

                models.Add(model);
            }

            return(models);
        }
示例#14
0
 private void NewOrder_Load(object sender, EventArgs e)
 {
     order             = new Order(DateTime.Now);
     gb_NewCst.Enabled = false;
     FormControls.HideDGVColumns(dgv_Customers.Columns[0], dgv_Customers.Columns[7], dgv_Products.Columns[2]);
     FormControls.SetComboboxDefaultValue(cBoxType);
     FormControls.BindData(dgv_Customers, command: defaultCustomersCommand);
     FormControls.BindData(dgv_Products, command: defaultProductsCommand);
 }
示例#15
0
        private void SetupsVariablesAddForm()
        {
            UpdateOutputFileSuggestions(OutputFile, FormType);
            OutputFile.SelectedIndex = _selectedIndex;
            foreach (var fileName in FilesAndFolderStructure.GetShortSavedFiles(FolderType.Root))
            {
                var add = true;
                if (RobotAutomationHelper.GlobalVariables.Count != 0)
                {
                    foreach (var temp in RobotAutomationHelper.GlobalVariables)
                    {
                        if (!temp.ToString().Equals(FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Root)))
                        {
                            continue;
                        }
                        add = false;
                        break;
                    }
                }
                if (add)
                {
                    RobotAutomationHelper.GlobalVariables.Add(new Variables(new List <string>(), FilesAndFolderStructure.ConcatFileNameToFolder(fileName, FolderType.Root)));
                }
            }

            ActiveControl    = AddVariablesLabel;
            CurrentVariables = new Variables(new List <string>(), "");

            foreach (var temp in RobotAutomationHelper.GlobalVariables)
            {
                if (temp.ToString().Equals(FilesAndFolderStructure.ConcatFileNameToFolder(OutputFile.Items[OutputFile.SelectedIndex].ToString(), FolderType.Root)))
                {
                    CurrentVariables = temp.DeepClone();
                    break;
                }
            }

            _variablesCounter = 0;
            if (CurrentVariables.VariableNames.Count == 0)
            {
                FormControls.AddControl("Button", "DynamicStep" + _variablesCounter + "AddVariable",
                                        _variablesCounter,
                                        new Point(KeywordFieldConsts.LabelX - HorizontalScroll.Value, InitialYValue + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                        new Size(KeywordFieldConsts.AddKeywordWidth, KeywordFieldConsts.FieldsHeight),
                                        "+",
                                        Color.Black,
                                        AddVariableToTheForm,
                                        this);
                return;
            }
            foreach (var unused in CurrentVariables.VariableNames)
            {
                _variablesCounter++;
                AddVariableField();
            }
        }
示例#16
0
        private void AddTestCaseField(TestCase testCase, int testCasesCounter, int index)
        {
            FormControls.AddControl("TextBox", "DynamicTest" + index + "Name",
                                    testCasesCounter,
                                    new Point(30 - HorizontalScroll.Value, InitialYValue + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(280, 20),
                                    testCase.Name.Trim(),
                                    Color.Black,
                                    null,
                                    this);
            FormControls.AddControl("Label", "DynamicTest" + index + "Label",
                                    testCasesCounter,
                                    new Point(10 - HorizontalScroll.Value, InitialYValue + 3 + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(20, 20),
                                    testCasesCounter + ".",
                                    Color.Black,
                                    null,
                                    this);
            FormControls.AddControl("CheckBox", "DynamicTest" + index + "CheckBox",
                                    testCasesCounter,
                                    new Point(325 - HorizontalScroll.Value, InitialYValue + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(20, 20),
                                    "Add",
                                    Color.Black,
                                    null,
                                    this);

            var implementationText = TestCases[testCasesCounter - 1].Implemented? "Edit Implementation" : "Add Implementation";

            FormControls.AddControl("Button", "DynamicTest" + index + "AddImplementation",
                                    testCasesCounter,
                                    new Point(345 - HorizontalScroll.Value, InitialYValue + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(120, 20),
                                    implementationText,
                                    Color.Black,
                                    InstantiateAddTestCaseForm,
                                    this);

            FormControls.AddControl("Button", "DynamicTest" + index + "AddTestCase",
                                    testCasesCounter,
                                    new Point(470 - HorizontalScroll.Value, InitialYValue + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(20, 20),
                                    "+",
                                    Color.Black,
                                    InstantiateNameAndOutputForm,
                                    this);
            FormControls.AddControl("Button", "DynamicTest" + index + "RemoveTestCase",
                                    testCasesCounter,
                                    new Point(490 - HorizontalScroll.Value, InitialYValue + (testCasesCounter - 1) * 25 - VerticalScroll.Value),
                                    new Size(20, 20),
                                    "-",
                                    Color.Black,
                                    RemoveTestCaseFromProject,
                                    this);
        }
示例#17
0
 public IEnumerable <SelectListItem> GetSelectListItems(RequestContext requestContext, string filter = null)
 {
     foreach (var item in FormControls.Controls())
     {
         yield return(new SelectListItem
         {
             Text = item.Name,
             Value = item.Name
         });
     }
 }
示例#18
0
 //When checked shows all of the system databases.
 private void chckbx_show_system_databases_CheckedChanged(object sender, EventArgs e)
 {
     if (chckbx_show_system_databases.Checked)
     {
         FormControls.UpdateDatabasesCheckedList(databaseNamesFull);
     }
     else
     {
         FormControls.UpdateDatabasesCheckedList(userDatabaseNames);
     }
 }
        public static void Write(this FormControls formControls, CSideWriter writer, int propertyIndentation)
        {
            writer.BeginSection("CONTROLS");

            foreach (var formControl in formControls)
            {
                formControl.Write(writer, propertyIndentation);
            }

            writer.EndSection();
        }
示例#20
0
        /// <summary>
        /// Assign the Main and Detail grid valules and create cell click events
        /// </summary>
        /// <param name="masterDataGrid"></param>
        /// <param name="detailDataGrid"></param>
        /// <param name="columnIndexs"></param>
        /// <param name="eventtype"></param>
        /// <param name="types"></param>
        /// <param name="DetailTable"></param>
        /// <param name="FilterColumn"></param>
        public void DGVMasterGridClickEvents(DataGridView masterDataGrid, DataGridView detailDataGrid, int columnIndexs,
                                             EventTypes eventtype, FormControls types, DataTable DetailTable, String FilterColumn)
        {
            LocationDataGrid = masterDataGrid;
            RoomDataGrid     = detailDataGrid;
            gridColumnIndex  = columnIndexs;
            DetailgridDT     = DetailTable;
            FilterColumnName = FilterColumn;

            LocationDataGrid.CellContentClick += new DataGridViewCellEventHandler(LocationDataGrid_CellContentClick_Event);
            LocationDataGrid.CellFormatting   += new DataGridViewCellFormattingEventHandler(LocationDataGrid_CellFormatting);
        }
示例#21
0
        private void SetupControls()
        {
            FControls = new FormControls();

            FControls.SessionNameLbl                  = sessionNameLbl;
            FControls.PoolScoreChart                  = poolScoreChart;
            FControls.CurrentBestLowestScoreLbl       = currentBestLowestScoreLbl;
            FControls.CurrentBestFirstNameLbl         = currentBestFirstNameLbl;
            FControls.CurrentBestLastNameLbl          = currentBestLastNameLbl;
            FControls.CurrentBestDirectDescendentsLbl = currentBestDirectDescendentsLbl;

            FControls.GenerationLbl            = generationLbl;
            FControls.GoatBestFirstNameLbl     = goatBestFirstNameLbl;
            FControls.GoatBestLastNameLbl      = goatBestLastNameLbl;
            FControls.GoatBestLowestScoreLbl   = goatBestLowestScoreLbl;
            FControls.GoatDirectDescendentsLbl = goatDirectDescendentsLbl;
            FControls.RunsCompletedLbl         = runsCompletedLbl;
            FControls.RetiredNumberLbl         = retiredNumberLbl;
            FControls.TicksPerChromosome       = ticksPerChromosomeLbl;

            FControls.ConfigImmigrationRateLbl   = configImmigrationRateLbl;
            FControls.ConfigImmigrationLbl       = configImmigrationLbl;
            FControls.ConfigScoringLbl           = configScoringLbl;
            FControls.ConfigDuplicationLbl       = configDuplicationLbl;
            FControls.ConfigPoolSizeLbl          = configPoolSizeLbl;
            FControls.ConfigIterationsLbl        = configIterationsLbl;
            FControls.ConfigCrossoverRateLbl     = configCrossoverRateLbl;
            FControls.ConfigMutationRateLbl      = configMutationRateLbl;
            FControls.ConfigElitismRateLbl       = configElitismRateLbl;
            FControls.ConfigMaxLifeLbl           = configMaxLifeLbl;
            FControls.ConfigChildrenPerCoupleLbl = configChildrenPerCoupleLbl;
            FControls.ConfigParentSelectionLbl   = configParentSelectionLbl;
            FControls.ConfigCrossoverLbl         = configCrossoverLbl;
            FControls.ConfigMutationLbl          = configMutationLbl;
            FControls.ConfigRetirementLbl        = configRetirementLbl;
            FControls.MillisecondsPerGeneration  = msPerGenerationLbl;
            FControls.SolutionNameLbl            = solutionNameLbl;

            FControls.Family1Lbl         = family1Lbl;
            FControls.Family2Lbl         = family2Lbl;
            FControls.Family3Lbl         = family3Lbl;
            FControls.Family4Lbl         = family4Lbl;
            FControls.Family5Lbl         = family5Lbl;
            FControls.Family1ProgressBar = lastName1ProgressBar;
            FControls.Family2ProgressBar = lastName2ProgressBar;
            FControls.Family3ProgressBar = lastName3ProgressBar;
            FControls.Family4ProgressBar = lastName4ProgressBar;
            FControls.Family5ProgressBar = lastName5ProgressBar;

            FControls.TaskRepoQueuedTasks  = tasksInQueueLbl;
            FControls.TaskRepoFinishedRuns = runsToInsertLbl;
        }
 // Removes TextBox / Label / Add implementation / Add and remove keyword / Params
 protected void RemoveKeywordField(int keywordIndex, bool removeFromList)
 {
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "Name", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "Label", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "AddImplementation", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "AddKeyword", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "RemoveKeyword", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + keywordIndex + "Params", Controls);
     if (removeFromList)
     {
         ThisFormKeywords.RemoveAt(keywordIndex - 1);
     }
 }
示例#23
0
        //Used to test the connection to the import server.
        private async void btn_import_connect_Click(object sender, EventArgs e)
        {
            FormControls.EnableLoadingIcon();

            if (!await Utilities.TestConnection(_dbImporter.GetImportConnectionString(), false, true))
            {
                return;
            }

            Config.AddUpdateSetting("Import_ServerType", cmbbx_import_server_type.SelectedItem.ToString());
            Config.AddUpdateSetting("Import_ServerName", txtbx_import_server_name.Text);
            Config.AddUpdateSetting("Import_Username", txtbx_import_username.Text);
            Config.AddUpdateSetting("Import_Password", txtbx_import_password.Text);
        }
 public void ShowKeywordContent()
 {
     FormControls.RemoveControlByKey(ContentName.Name, Controls);
     FormControls.AddControl("TextWithList", "DynamicStep1Name",
                             1,
                             new Point(32 - HorizontalScroll.Value, 24 - VerticalScroll.Value),
                             new Size(KeywordFieldConsts.NameWidth, KeywordFieldConsts.FieldsHeight),
                             "",
                             Color.Black,
                             null,
                             this);
     Controls["DynamicStep1Name"].TextChanged += KeywordName_TextChanged;
     ((TextWithList)Controls["DynamicStep1Name"]).MaxItemsInSuggestionsList = 5;
     ShowDialog();
 }
示例#25
0
        /// <summary>
        ///     Применить настройку внешнего вида для объекта из таблицы настроек по умолчанию
        /// </summary>
        /// <param name="form">Форма на которой находится объект</param>
        /// <param name="name">Название объекта</param>
        /// <param name="control">Объект</param>
        public static void AcceptDefaultLayoutForControl(this Form form, string name, Control control)
        {
            ISupportXtraSerializer sxs = null;
            var gc = control as GridControl;

            if (gc != null)
            {
                sxs = gc.MainView;
            }
            else
            {
                var pv = control as PivotGridControl;
                if (pv != null)
                {
                    sxs = pv;
                }
                else
                {
                    var tl = control as TreeList;
                    if (tl != null)
                    {
                        sxs = tl;
                    }
                }
            }
            if (sxs == null)
            {
                return;
            }
            using (var db = new ApplicationEntitie(0))
            {
                var tableName = form.Name + "." + name;
                var defLayout = db.DefaultLayouts.FirstOrDefault(dl => dl.TableName == tableName);
                if (defLayout == null)
                {
                    MessageWindow.GetInstance("Для данной формы не найдено начальное состояние.");
                    return;
                }
                sxs.RestoreLayoutSerializingFromStream(defLayout.Layout);
            }
            var tuner = control.GetControlTuner() as ILayoutTuner;

            if (tuner != null)
            {
                tuner.LoadPropertiesFromXml(control, FormControls.XmlDocumentFromStrinList(form.GetXmlSettings()));
            }
        }
示例#26
0
 private void OutputFile_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_variablesCounter == 0)
     {
         FormControls.RemoveControlByKey("DynamicStep" + 0 + "AddVariable", Controls);
     }
     if (OutputFile.SelectedIndex == -1 || _selectedIndex == OutputFile.SelectedIndex)
     {
         return;
     }
     _selectedIndex = OutputFile.SelectedIndex;
     for (var i = _variablesCounter; i > 0; i--)
     {
         RemoveVariableField(i, true, false);
     }
     SetupsVariablesAddForm();
 }
示例#27
0
        protected void AddVariableField()
        {
            var settingsLabel = 0;

            if (FormType == FormType.Settings)
            {
                settingsLabel = KeywordFieldConsts.SettingsLabelWidth - KeywordFieldConsts.LabelWidth;
            }

            FormControls.AddControl("TextBox", "DynamicStep" + _variablesCounter + "Name",
                                    _variablesCounter,
                                    new Point(settingsLabel + KeywordFieldConsts.NameX - HorizontalScroll.Value, InitialYValue + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                    new Size(KeywordFieldConsts.NameWidth, KeywordFieldConsts.FieldsHeight),
                                    CurrentVariables.VariableNames[_variablesCounter - 1].Trim(),
                                    Color.Black,
                                    null,
                                    this);

            FormControls.AddControl("Label", "DynamicStep" + _variablesCounter + "Label",
                                    _variablesCounter,
                                    new Point(KeywordFieldConsts.LabelX - HorizontalScroll.Value, InitialYValue + 3 + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                    new Size(settingsLabel + KeywordFieldConsts.LabelWidth, KeywordFieldConsts.FieldsHeight),
                                    (FormType == FormType.Settings) ? KeywordFieldConsts.LabelNames[_variablesCounter - 1] : _variablesCounter + ".",
                                    Color.Black,
                                    null,
                                    this);

            FormControls.AddControl("Button", "DynamicStep" + _variablesCounter + "AddVariable",
                                    _variablesCounter,
                                    new Point(settingsLabel + KeywordFieldConsts.AddKeywordX - HorizontalScroll.Value, InitialYValue + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                    new Size(KeywordFieldConsts.AddKeywordWidth, KeywordFieldConsts.FieldsHeight),
                                    "+",
                                    Color.Black,
                                    AddVariableToTheForm,
                                    this);
            FormControls.AddControl("Button", "DynamicStep" + _variablesCounter + "RemoveVariable",
                                    _variablesCounter,
                                    new Point(settingsLabel + KeywordFieldConsts.RemoveKeywordX - HorizontalScroll.Value, InitialYValue + (_variablesCounter - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                                    new Size(KeywordFieldConsts.RemoveKeywordWidth, KeywordFieldConsts.FieldsHeight),
                                    "-",
                                    Color.Black,
                                    RemoveVariableFromThisForm,
                                    this);
        }
示例#28
0
        public MainForm()
        {
            InitializeComponent();
            FormControls _controls = new FormControls(this);

            picBx_loadingicon.Visible = false;
            btn_cancel.Visible        = false;
            btn_start.Enabled         = false;

            FormControls.GetExportSettings();
            FormControls.GetImportSettings();

            _backupFolderPath = $"{txtbx_export_output_folder.Text}\\";

            if (!string.IsNullOrEmpty(_backupFolderPath))
            {
                _dbExporter = new DatabaseExporter(_backupFolderPath);
                _dbImporter = new DatabaseImporter(_backupFolderPath);
            }
        }
示例#29
0
        public void AddVariableToTheForm(object sender, EventArgs e)
        {
            TextFieldsToCurrentVariablesNames();
            if (_variablesCounter == 0)
            {
                FormControls.RemoveControlByKey("DynamicStep" + 0 + "AddVariable", Controls);
            }
            _variablesCounter++;
            var variableIndex = int.Parse(((Button)sender).Name.Replace("DynamicStep", "").Replace("AddVariable", ""));

            if (CurrentVariables.VariableNames.Count != 0)
            {
                CurrentVariables.VariableNames.Insert(variableIndex, "");
            }
            else
            {
                CurrentVariables.VariableNames.Add("");
            }
            AddVariableField();
            AssignNamesFromCurrentVariablesToTextFields();
        }
示例#30
0
 protected void RemoveVariableField(int variableIndex, bool removeFromList, bool removeButton)
 {
     FormControls.RemoveControlByKey("DynamicStep" + variableIndex + "Name", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + variableIndex + "Label", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + variableIndex + "AddVariable", Controls);
     FormControls.RemoveControlByKey("DynamicStep" + variableIndex + "RemoveVariable", Controls);
     if (removeFromList)
     {
         CurrentVariables.VariableNames.RemoveAt(variableIndex - 1);
     }
     if (!removeButton || CurrentVariables.VariableNames.Count > 1)
     {
         return;
     }
     FormControls.AddControl("Button", "DynamicStep" + 0 + "AddVariable",
                             _variablesCounter,
                             new Point(KeywordFieldConsts.LabelX - HorizontalScroll.Value, InitialYValue + (0 - 1) * KeywordFieldConsts.VerticalDistanceBetweenKeywords - VerticalScroll.Value),
                             new Size(KeywordFieldConsts.AddKeywordWidth, KeywordFieldConsts.FieldsHeight),
                             "+",
                             Color.Black,
                             AddVariableToTheForm,
                             this);
 }
示例#31
0
        public void AddFormControl(FormBlock fblock)
        {
            int fwidth = 900;
            int row_top = 20;

            if (_formBlocks == null)
                _formBlocks = new FormControls();

            _formBlocks.Add(fblock);

            if (_controls_row_cnt == 0)
            {
                if (_formBlocks.Count > 0)
                {
                    int width = 0;
                    for (int i = (_formBlocks.Count - 1) - _controls_per_row_cnt; i < _formBlocks.Count; i++)
                    {
                        width += _formBlocks[i].BlockControl.Width;
                    }

                    if (width > fwidth)
                    {
                        fblock.BlockLabel.Top = (_controls_row_cnt + 1) + 60;
                        fblock.BlockControl.Top = (_controls_row_cnt + 1) + 80;
                        fblock.BlockLabel.Left = 10;
                        fblock.BlockControl.Left = 10;
                        _controls_row_cnt++;
                        _controls_per_row_cnt = 0;
                    }
                    else
                    {
                        if (_controls_per_row_cnt == 0)
                            fblock.BlockControl.Left = 10;
                        if (_controls_per_row_cnt == 1)
                            fblock.BlockControl.Left = (width - fblock.BlockControl.Width) + 20;
                        if (_controls_per_row_cnt > 1)
                            fblock.BlockControl.Left += 10;
                        fblock.BlockLabel.Left = fblock.BlockControl.Left;
                        fblock.BlockControl.Top = 30;
                        fblock.BlockLabel.Top = fblock.BlockControl.Top - 20;
                        if (fblock.BlockCB != null)
                        {
                            fblock.BlockCB.Top = fblock.BlockLabel.Top;
                            fblock.BlockCB.Left = fblock.BlockLabel.Left + fblock.BlockLabel.Width + 10;
                        }
                    }
                }
            }
            else//--Если больше 1й строки
            {
                int width = 0;
                if (_controls_per_row_cnt > 0)
                {
                    for (int i = (_formBlocks.Count - 1) - _controls_per_row_cnt; i < _formBlocks.Count; i++)
                    {
                        width += _formBlocks[i].BlockControl.Width;
                        row_top = _formBlocks[i-1].BlockControl.Top;
                    }
                }
                else
                {
                    width = _formBlocks[_formBlocks.Count - 1].BlockControl.Width;
                    int idx = _formBlocks.Count - 2;
                    if (_formBlocks.Count >= 2)
                        if (_formBlocks[idx].BlockControl.Height + _formBlocks[idx].BlockControl.Top > row_top)
                            row_top = _formBlocks[idx].BlockControl.Height + _formBlocks[idx].BlockControl.Top + 20;
                }

                if (width > 900)
                {
                    _controls_per_row_cnt = 0;
                    _controls_row_cnt++;
                    row_top = _formBlocks[_formBlocks.Count - 2].BlockControl.Top + _formBlocks[_formBlocks.Count - 2].BlockControl.Height + 20;
                }
                if (width > 800 && width < 900)
                {
                    if (_controls_per_row_cnt >= 1 && width < 900)
                    {
                        fblock.BlockControl.Left = (width - fblock.BlockControl.Width) + 20;
                        fblock.BlockControl.Left += 10;
                    }
                    fblock.BlockLabel.Left = fblock.BlockControl.Left;
                    int blockheight = 0;
                    if (_formBlocks.Count >= 2 && _controls_row_cnt > 1)
                        blockheight = _formBlocks[_formBlocks.Count - (_controls_per_row_cnt + 2)].BlockControl.Height + _formBlocks[_formBlocks.Count - (_controls_per_row_cnt + 2)].BlockControl.Top;
                    else
                        blockheight = 60;
                    fblock.BlockControl.Top = blockheight + 20;
                    fblock.BlockLabel.Top = fblock.BlockControl.Top - 20;
                    if (fblock.BlockCB != null)
                    {
                        fblock.BlockCB.Top = fblock.BlockLabel.Top;
                        fblock.BlockCB.Left = fblock.BlockLabel.Left + fblock.BlockLabel.Width + 10;
                    }
                    _controls_row_cnt++;
                    _controls_per_row_cnt = -1;
                    row_top = 0;
                }
                else
                {
                    int offset = _controls_per_row_cnt * 10;
                    if (_controls_per_row_cnt == 0)
                        fblock.BlockControl.Left = 10;
                    if (_controls_per_row_cnt == 1)
                        fblock.BlockControl.Left = (width - fblock.BlockControl.Width) + 20;
                    if (_controls_per_row_cnt > 1)
                        fblock.BlockControl.Left = (width - fblock.BlockControl.Width) + offset;
                    fblock.BlockLabel.Left = fblock.BlockControl.Left;
                    fblock.BlockControl.Top = row_top;
                    fblock.BlockLabel.Top = fblock.BlockControl.Top - 20;
                    if (fblock.BlockCB != null)
                    {
                        fblock.BlockCB.Top = fblock.BlockLabel.Top;
                        fblock.BlockCB.Left = fblock.BlockLabel.Left + fblock.BlockLabel.Width + 10;
                    }
                }
            }

            fblock.Visible = true;
            /*fblock.BlockLabel.BringToFront();
            fblock.BlockControl.BringToFront();*/
            _controls_per_row_cnt++;
        }