コード例 #1
0
        public static void Main()
        {
            Color blue = new RedColor();
            Color red = new BlueColor();

            var factory = new ColorFactory();
            var existingColor = factory.GetColor("blue");
            existingColor.Display();

            var newColor = factory.GetColor("red");
            newColor.Display();
        }
コード例 #2
0
        public EditRecipeProduct(int recipeCode, int productCode)
        {
            InitializeComponent();

            this.recipeCode  = recipeCode;
            this.productCode = productCode;

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Quantity label
            quantityLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Delete button
            editRecipeProductButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            editRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            editRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
        }
コード例 #3
0
ファイル: EditMeal.cs プロジェクト: UNWE/UNWE---Projects
        public EditMeal(string mealCode, string mealName, string quantity, string type, string portions, string calories, string date)
        {
            InitializeComponent();

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Edit button
            editButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Meal table
            meal.Rows[0].Cells[0].Value = mealCode;
            meal.Rows[0].Cells[1].Value = mealName;
            meal.Rows[0].Cells[2].Value = quantity;
            meal.Rows[0].Cells[3].Value = calories;
            meal.Rows[0].Cells[4].Value = type;
            meal.Rows[0].Cells[5].Value = portions;
            meal.Rows[0].Cells[6].Value = date;
        }
コード例 #4
0
ファイル: NewProduct.cs プロジェクト: UNWE/UNWE---Projects
 public NewProduct()
 {
     InitializeComponent();
     // Form settings
     this.Width           = FormWidth;
     this.Height          = FormHeight;
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     this.Text            = FormTitle;
     this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     // Content wrapper
     contentWrapper.BackColor = Color.White;
     contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
     contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
     // Center the wrapper within the parent form
     contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
     contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
     // Product name label
     productNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     productNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // Measurement unit label
     measurementUnitLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     measurementUnitLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // New product button
     newProductButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 20);
     newProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     newProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
     // Set tool tips
     this.toolTip.SetToolTip(productName, Constants.ProductNameToolTip);
     this.toolTip.SetToolTip(measurementUnit, Constants.MeasurementToolTip);
 }
コード例 #5
0
 public EditProduct(string productId, string productName, string measurementUnit, object date)
 {
     InitializeComponent();
     // Form settings
     this.Width           = FormWidth;
     this.Height          = FormHeight;
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     this.Text            = FormTitle;
     this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     // Content wrapper
     contentWrapper.BackColor = Color.White;
     contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
     contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
     // Center the wrapper within the parent form
     contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
     contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
     // Edit button
     editButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
     // Product table
     product.Rows[0].Cells[0].Value = productId;
     product.Rows[0].Cells[1].Value = productName;
     product.Rows[0].Cells[2].Value = measurementUnit;
     product.Rows[0].Cells[3].Value = date;
 }
コード例 #6
0
        public AllRecipes()
        {
            InitializeComponent();

            this.recipesBindingSource = new BindingSource();
            BindRecipesData();
            recipeCode.DataBindings.Add(new Binding("text", recipesBindingSource, "Код"));
            recipeName.DataBindings.Add(new Binding("text", recipesBindingSource, "Наименование"));

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Product label
            productLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            productLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Quantity label
            quantityLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Recipe code label
            recipeCodeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            recipeCodeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Recipe name label
            recipeNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            recipeNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Delete recipe button
            deleteRecipeButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            deleteRecipeButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            deleteRecipeButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Show add product panel button
            showAddProductPanelButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            showAddProductPanelButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            showAddProductPanelButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Delete recipe product button
            deleteRecipeProductButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            deleteRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            deleteRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Edit recipe product button
            editRecipeProductButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            editRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            editRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Add recipe product button
            addRecipeProductButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            addRecipeProductButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            addRecipeProductButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // New product panel
            FillProductsComboBox();
            newProductPanel.Hide();
        }
コード例 #7
0
        public SearchMeals()
        {
            InitializeComponent();

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Menu strip
            toolStrip.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            toolStrip.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            toolStrip.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Meal name label
            mealNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            mealNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Meal type label
            typeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            typeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Calories label
            caloriesLabel.Font              = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            caloriesLabel.ForeColor         = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label
            caloriesHelpFromLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            caloriesHelpFromLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor); // Calories label
            caloriesHelpToLabel.Font        = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            caloriesHelpToLabel.ForeColor   = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Quantity label
            quantityLabel.Font              = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor         = ColorFactory.GetColor(CommonColors.GreyFontColor);
            quantityHelpFromLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityHelpFromLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            quantityHelpToLabel.Font        = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityHelpToLabel.ForeColor   = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Search button
            searchButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            searchButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            searchButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Clear button
            clearFiltersButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
            clearFiltersButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            clearFiltersButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
        }
コード例 #8
0
ファイル: MainScreen.cs プロジェクト: UNWE/UNWE---Projects
 public MainScreen()
 {
     InitializeComponent();
     // Form settings
     this.Width           = FromWidth;
     this.Height          = FormHeight;
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     this.Text            = FormTitle;
     this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     // Main menu
     mainMenu.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
     mainMenu.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 12);
     mainMenu.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
 }
コード例 #9
0
        public AllMeals()
        {
            InitializeComponent();

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Meal code label
            mealCodeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            mealCodeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Meal name label
            mealNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            mealNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Quantity label
            quantityLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Calories label
            caloriesLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            caloriesLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Type label
            typeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            typeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Portions label
            portionsLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            portionsLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Modifiecation date label
            modificationDateLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            modificationDateLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Edit button
            editButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            editButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            editButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Delete button
            deleteButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            deleteButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            deleteButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
        }
コード例 #10
0
ファイル: Register.cs プロジェクト: UNWE/UNWE---Projects
 public Register()
 {
     InitializeComponent();
     // Form settings
     this.Width           = FormWidth;
     this.Height          = FormHeight;
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     this.Text            = FormTitle;
     this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     // Content wrapper
     contentWrapper.BackColor = Color.White;
     contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
     contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
     // Center the wrapper within the parent form
     contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
     contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
     // Enter label
     registerLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia);
     registerLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // Username label
     usernameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     usernameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // Password label
     passwordLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     passwordLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // First name label
     firstNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     firstNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // Last name label
     lastNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     lastNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // Register button
     registerButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 20);
     registerButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     registerButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
     // Passwod textbox
     password.PasswordChar = '*';
     password.MaxLength    = 20;
     // Cancel button
     cancelButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     cancelButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     cancelButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
 }
コード例 #11
0
ファイル: NewMeal.cs プロジェクト: UNWE/UNWE---Projects
        public NewMeal()
        {
            InitializeComponent();

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Meal name label
            mealNameLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            mealNameLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Quantity label
            quantityLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Calories label
            caloriesLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            caloriesLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Type label
            typeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            typeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Portions label
            portionsLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            portionsLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // New meal button button
            newMealButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            newMealButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            newMealButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Set tool tips
            this.toolTip.SetToolTip(mealName, Constants.MealNameToolTip);
            this.toolTip.SetToolTip(quantity, Constants.QuantityToolTip);
            this.toolTip.SetToolTip(calories, Constants.CaloriesToolTip);
            this.toolTip.SetToolTip(type, Constants.TypeToolTip);
            this.toolTip.SetToolTip(portions, Constants.PortionsToolTip);
        }
コード例 #12
0
        /// <summary>
        /// initialize the canvas with the maze
        /// </summary>
        private void InitializeMazeLabels()
        {
            // rectangles size
            double rectHeight = rectSizePX;
            double rectWidth  = rectSizePX;

            // player size
            player.Width  = rectWidth;
            player.Height = rectHeight;
            // distance from the top left corner of the canvas
            double distanceFromLeft = 0;
            double distanceFromTop  = 0;
            char   sign;

            // fill all the rows
            for (int i = 0; i < Rows; i++)
            {
                // reset the distance from the left for each row
                distanceFromLeft = 0;
                for (int j = 0; j < Cols; j++)
                {
                    // create new rectangle
                    Rectangle rectangle = new Rectangle();
                    rectangle.Width  = rectWidth;
                    rectangle.Height = rectHeight;
                    // set place on the canvas
                    Canvas.SetLeft(rectangle, distanceFromLeft);
                    Canvas.SetTop(rectangle, distanceFromTop);
                    sign = MazeString[i * Cols + j];
                    // set the color according to the char
                    rectangle.Fill = ColorFactory.GetColor(sign);
                    // add the rectangle to the canvas's children
                    mazeCanvas.Children.Add(rectangle);
                    distanceFromLeft = (distanceFromLeft + rectWidth);
                }
                // add the distance from the top for each row
                distanceFromTop = (distanceFromTop + rectHeight);
            }
            // position the player on the starting position
            PositionPlayer(MazeStartPoint.Row, MazeStartPoint.Col);
        }
コード例 #13
0
ファイル: NewRecipe.cs プロジェクト: UNWE/UNWE---Projects
        public NewRecipe()
        {
            InitializeComponent();

            // Form settings
            this.Width           = FormWidth;
            this.Height          = FormHeight;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Text            = FormTitle;
            this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            // Content wrapper
            contentWrapper.BackColor = Color.White;
            contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
            contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
            // Center the wrapper within the parent form
            contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
            contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
            // Recipe label
            recipeLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            recipeLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Product label
            productLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            productLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // Quantity label
            quantityLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
            quantityLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
            // New recipe button
            newRecipeButton.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 20);
            newRecipeButton.ForeColor = ColorFactory.GetColor(CommonColors.BackgroundGrey);
            newRecipeButton.BackColor = ColorFactory.GetColor(CommonColors.DarkGrey);
            // Fill combo boxes
            FillRecipeCombobox();
            recipe.SelectedIndex = 0;
            FillProductComboBox();
            // Set tooltips
            toolTip.SetToolTip(recipe, Constants.RecipeToolTip);
            toolTip.SetToolTip(product, Constants.ProductToolTip);
            toolTip.SetToolTip(quantity, Constants.RecipeProductQuantityToolTip);
        }
コード例 #14
0
 public AboutScreen()
 {
     InitializeComponent();
     // Form settings
     this.Width           = FormWidth;
     this.Height          = FormHeight;
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     this.Text            = FormTitle;
     this.BackColor       = ColorFactory.GetColor(CommonColors.BackgroundGrey);
     // Content wrapper
     contentWrapper.BackColor = Color.White;
     contentWrapper.Width     = (int)(FormWidth * Constants.WrapperSizeCoefficient);
     contentWrapper.Height    = (int)(FormHeight * Constants.WrapperSizeCoefficient);
     // Center the wrapper within the parent form
     contentWrapper.Left = (this.ClientSize.Width - contentWrapper.Width) / 2;
     contentWrapper.Top  = (this.ClientSize.Height - contentWrapper.Height) / 2;
     // Enter label
     aboutLabel.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia);
     aboutLabel.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
     // About box
     aboutBox.Text      = String.Format(Constants.AboutInformation, DeveloperName, FacultyNumber, Speciality, Stream, GroupNumber, Environment.NewLine);
     aboutBox.Font      = FontFactory.GetFont(CommonFonts.DefauldGeorgia, 16);
     aboutBox.ForeColor = ColorFactory.GetColor(CommonColors.GreyFontColor);
 }
コード例 #15
0
ファイル: Classic.cs プロジェクト: frolleshka/Patterns
 public void SetPixelColor(Point point, ColorDto ColorDto)
 {
     pixels[point.X, point.Y] = colorFacrtory.GetColor(ColorDto);
 }
コード例 #16
0
        // Singleton    done
        // Factory      done
        // Strategy     done
        // Observer     done

        // Adapter      done
        // Decorator    done
        // Facade       done
        // Command      done

        // Template Method - zaidimo temos
        // State - zaidimo busena
        // Proxy -
        // Iterator, Composite, Flyweight

        // Chain of Responsibility
        // Null Object - score null
        // Memento - restart/resume game
        // Visitor - when enemies die, they visit visitor
        // Interpreter - custom game mod



        public Form1()
        {
            InitializeComponent();
            instance = this;

            //Singleton and Adapter
            logger.LogMessage("Adapter Works!");
            guiLogger.LogMessage("Gui Logger Works!");

            pacman = new Classes.Pacman(false);
            MoveDown  moveDown  = new MoveDown(pacman);
            MoveUp    moveUp    = new MoveUp(pacman);
            MoveLeft  moveLeft  = new MoveLeft(pacman);
            MoveRight moveRight = new MoveRight(pacman);

            //Command
            pacman.Move(moveDown);
            pacman.Move(moveUp);
            pacman.Move(moveLeft);
            pacman.Move(moveRight);

            //Strategy
            Enemy enemy = new Enemy(new AiAmbusher());

            enemy.SelectStrategy();
            enemy.strategy = new AiRandom();
            enemy.SelectStrategy();

            //Observer
            pacman.Attach(enemy);
            pacman.State = true;

            //Abstract factory
            AbstractFactory candyFactory = new CandyFactory();
            ICandy          candy1       = candyFactory.GetCandy("small");

            candy1.CreateCandy();

            ICandy candy2 = candyFactory.GetCandy("big");

            candy2.CreateCandy();

            ICandy candy3 = candyFactory.GetCandy("cherry");

            candy3.CreateCandy();

            ICandy candy4 = candyFactory.GetCandy("BANANA");

            candy4.CreateCandy();

            AbstractFactory colorFactory = new ColorFactory();
            IColor          color1       = colorFactory.GetColor("yellow");

            color1.CreateColor();

            IColor color2 = colorFactory.GetColor("red");

            color2.CreateColor();

            //Facade
            FoodFacade food = new FoodFacade();

            food.CreateRedCherry();
            food.CreateRedSmall();
            food.CreateYellowBanana();
            food.CreateYellowBig();

            //Decorator with Template Method
            pacman.weapon = new Gun();
            Debug.WriteLine(pacman.weapon.Shoot());
            pacman.weapon = new Cannon(pacman.weapon);
            Debug.WriteLine(pacman.weapon.Shoot());
            pacman.weapon = new SpeedTrap(pacman.weapon);
            Debug.WriteLine(pacman.weapon.Shoot());

            // State
            // Changes game state from resumed to paused and vice versa
            StateContext stateContext = new StateContext();
            StateResumed stateResumed = new StateResumed();
            StatePaused  statePaused  = new StatePaused();

            stateResumed.Handle(stateContext);
            Console.WriteLine(stateContext.GetState().GetString());
            statePaused.Handle(stateContext);
            Console.WriteLine(stateContext.GetState().GetString());

            // Proxy
            // Loads background image for gameboard
            IBackgroundImage image = new ProxyBackgroundImage("Background1.jpg");

            image.Display();
            Console.WriteLine("");
            // Image will not be loaded from disk again
            image.Display();

            // Flyweight
            // Pattern used to generate obstacles based on their length

            for (int i = 0; i < 8; i++)
            {
                //Creating duplicate objects
                Obstacle obs = ObstacleFactory.GetObstacle(i < 4 ? i : i / 2);
                obs.SetX(4);
                obs.SetY(4);
                obs.SetRotation(0);
                obs.Draw();
            }

            // Chain of responsibility
            // For handling scores
            AllScoresHandler handler1 = new NullObject();
            AllScoresHandler handler2 = new BonusHandler();
            AllScoresHandler handler3 = new PointsHandler();

            handler1.SetNextHandler(handler2);
            handler2.SetNextHandler(handler3);
            int[] points = { 0, 15, 5, 10, -5, 16, 18, 0, 0, 13, 1, 2, 3 };
            foreach (int point in points)
            {
                handler1.HandleScore(point);
            }
            Console.WriteLine("Final points: " + Highscore.Instance.score);

            // Mediator
            // Implemented chatroom
            Chatroom chatroom = new Chatroom();

            Participant player     = new Participant("Player");
            Participant spectator1 = new Participant("Spectator1");
            Participant spectator2 = new Participant("Spectator2");

            chatroom.Register(player);
            chatroom.Register(spectator1);
            chatroom.Register(spectator2);

            player.Send("Spectator1", "Hello, spectator!");
            spectator1.Send("Player", "Hello, player!");
            spectator2.Send("Player", "Hey, don't forget me!");

            // Memento
            // Saving player score for later use
            CareTaker careTaker = new CareTaker();

            careTaker.Add(Highscore.Instance.SetMemento());
            Console.WriteLine("Memento saved state: " + careTaker.Get(0).GetScore());
            Highscore.Instance.score = 2222;
            careTaker.Add(Highscore.Instance.SetMemento());
            Console.WriteLine("Memento saved state: " + careTaker.Get(1).GetScore());
            Console.WriteLine("Restoring to first memento.");
            Highscore.Instance.SetMemento(careTaker.Get(0));
            Console.WriteLine("Restored score is: " + Highscore.Instance.score);

            // Interpreter
            // Eating yellow banana will binary shift your score to the left and add 10 points to the result
            Console.WriteLine("Score before interpreter: " + Highscore.Instance.score);
            Counter originalCounter = new ConcreteCounter(Highscore.Instance.score);
            Counter bananaCounter   = new ConcreteCounter(10);
            Counter counter         = new ShiftCounter(bananaCounter, originalCounter);

            Highscore.Instance.score = counter.Count();
            Console.WriteLine("Score before interpreter: " + Highscore.Instance.score);
        }