Exemple #1
0
        public VFunction(string name)
        {
            this.name = name;

            BackColor = ColorSettings.Get("Function");

            funName = new CustomLabel(name, ColorSettings.Get("FunctionName"))
            {
                Parent   = this,
                Location = new Point(BorderPadding, BorderPadding)
            };

            vstatements  = new List <DraggableControl>();
            varguments   = new List <VVariable>();
            vvariables   = new List <VVariable>();
            placeholders = new List <ArgumentPlaceholder>
            {
                new ArgumentPlaceholder(this)
                {
                    Parent = this
                }
            };

            addArgBtn = new Button
            {
                Text   = "+",
                Parent = this,
                Size   = new Size(20, 20)
            };
            addArgBtn.Click += (object sender, EventArgs e) =>
            {
                if (name == Const.MainFunName)
                {
                    MessageBox.Show("Главная подпрограмма не принимает аргументов.");
                    return;
                }
                var argName = "arg" + varguments.Count;
                AddArgument(argName);
            };

            addVarBtn = new Button
            {
                Text   = "+",
                Parent = this,
                Size   = new Size(20, 20)
            };
            addVarBtn.Click += (object sender, EventArgs e) =>
            {
                var varName = "var" + vvariables.Count;
                AddVariable(varName);
            };

            UpdateSize();
        }
Exemple #2
0
        public VReturnStatement()
        {
            BackColor = ColorSettings.Get("ReturnStatement");
            Size      = new Size(100, Const.EXPR_HEIGHT);

            argPlaceHolder        = new ArgumentPlaceholder(this);
            argPlaceHolder.Parent = this;
            retLabel = new CustomLabel("вернуть ", BackColor);
            Controls.Add(retLabel);

            UpdateSize();
        }
Exemple #3
0
        public ElementPanel(Action <DraggableControl> onAddFunctionToWorkspace,
                            Dictionary <string, Func <DraggableControl> > elements)
        {
            Width       = Const.ELEMENT_PANEL_WIDTH;
            Dock        = DockStyle.Right;
            BackColor   = ColorSettings.Get("ElementPanel");
            BorderStyle = BorderStyle.FixedSingle;
            OnAddFunctionToWorkspace = onAddFunctionToWorkspace;

            foreach (var control in elements)
            {
                AddBtn(control.Key, control.Value);
            }
        }
Exemple #4
0
        public VSetVariable()
        {
            BackColor = ColorSettings.Get("SetVariable");
            Size      = new Size(100, Const.EXPR_HEIGHT);

            argPlaceHolder        = new ArgumentPlaceholder(this);
            argPlaceHolder.Parent = this;
            varPlaceHolder        = new ArgumentPlaceholder(this);
            varPlaceHolder.Parent = this;

            eqLabel = new CustomLabel(" = ", BackColor);
            Controls.Add(eqLabel);

            UpdateSize();
        }
Exemple #5
0
        public VStringConst(string str)
        {
            this.str = str;

            BackColor = ColorSettings.Get("StringConst");
            lbl       = new CustomLabel(str, BackColor);
            Controls.Add(lbl);
            UpdateSize();
            lbl.Location = new Point(Const.TAB_SIZE / 2, Const.TAB_SIZE / 2);

            lbl.MouseDoubleClick += (sender, e) =>
            {
                this.str = DiverseUtilExtensions.ShowDialog("Введите новое значение", "Новое значение");
                lbl.Text = this.str;
                this.UpdateRecSize();
            };
        }
Exemple #6
0
        public VBinaryOp(IFunctionDeclaration functionDeclaration)
        {
            function = functionDeclaration;
            symbol   = functionDeclaration.name;

            firstArgPlaceHolder  = new ArgumentPlaceholder(this);
            secondArgPlaceHolder = new ArgumentPlaceholder(this);

            firstArgPlaceHolder.Parent  = this;
            secondArgPlaceHolder.Parent = this;

            OpSymbol        = new CustomLabel(symbol, BackColor);
            OpSymbol.Parent = this;

            UpdateSize();

            BackColor = ColorSettings.Get("BinaryOp");
        }
Exemple #7
0
        public VCondStatement(string condType)
        {
            condTypeLabel = new CustomLabel(condType, ColorSettings.Get("CondLabel"))
            {
                Parent   = this,
                Location = new Point(5, 5)
            };

            controlStatements = new List <DraggableControl>();
            placeholders      = new List <ArgumentPlaceholder>
            {
                new ArgumentPlaceholder(this).With(_ => { _.Parent = this; })
            };

            condPlaceholder = new ArgumentPlaceholder(this)
            {
                Parent   = this,
                Location = new Point(25, 5)
            };

            UpdateSize();
        }
Exemple #8
0
        public VVariable(string name, VFunction parentFunc) : base(name, Color.Red)
        {
            varName         = name;
            this.parentFunc = parentFunc;

            BackColor = ColorSettings.Get("Variable");
            Size      = new Size(20, 20);

            VariableRefs = new List <VVariableRef>();

            MouseDoubleClick += (sender, e) =>
            {
                var newName = DiverseUtilExtensions.ShowDialog("Введите имя переменной", "Переименование");
                if (newName.Trim().Length == 0)
                {
                    return;
                }

                varName = newName;
                Text    = newName;
                foreach (var varRef in VariableRefs)
                {
                    varRef.UpdateName();
                }
            };

            MouseClick += (sender, e) =>
            {
                if (ModifierKeys == Keys.Control)
                {
                    CreateVVariableRef();
                }
                if (ModifierKeys == Keys.Shift)
                {
                    parentFunc.RemoveArgument(this);
                }
            };
        }
Exemple #9
0
 public void ResetColor()
 {
     BackColor = ColorSettings.Get("ArgumentPlaceholder");
 }
Exemple #10
0
 public ArgumentPlaceholder(IPlaceholderContainer parent)
 {
     this.parent = parent;
     Size        = new Size(15, 15);
     BackColor   = ColorSettings.Get("ArgumentPlaceholder");
 }
Exemple #11
0
 public VWhileStatement(IWhileStatement whileStatement) : base("выполнять пока", whileStatement)
 {
     BackColor = ColorSettings.Get("WhileStatement");
 }
Exemple #12
0
 public VIfStatement(IIfStatement ifStatement) : base("если", ifStatement)
 {
     BackColor = ColorSettings.Get("IfStatement");
 }
Exemple #13
0
 public VIfStatement() : base("если")
 {
     BackColor = ColorSettings.Get("IfStatement");
 }
Exemple #14
0
 public WorkspacePanel()
 {
     Dock      = DockStyle.Fill;
     BackColor = ColorSettings.Get("WorkspacePanel");
 }
Exemple #15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var pen = new Pen(ColorSettings.Get("ElementBorder"), 3);

            e.Graphics.DrawRectangle(pen, new Rectangle(1, 1, Width - 3, Height - 3));
        }