コード例 #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();
        }
コード例 #2
0
ファイル: VReturnStatement.cs プロジェクト: PShuvaev/vpl
        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();
        }
コード例 #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);
            }
        }
コード例 #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();
        }
コード例 #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();
            };
        }
コード例 #6
0
ファイル: VBinaryOp.cs プロジェクト: PShuvaev/vpl
        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");
        }
コード例 #7
0
ファイル: VCondStatement.cs プロジェクト: PShuvaev/vpl
        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();
        }
コード例 #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);
                }
            };
        }
コード例 #9
0
ファイル: ArgumentPlaceholder.cs プロジェクト: PShuvaev/vpl
 public void ResetColor()
 {
     BackColor = ColorSettings.Get("ArgumentPlaceholder");
 }
コード例 #10
0
ファイル: ArgumentPlaceholder.cs プロジェクト: PShuvaev/vpl
 public ArgumentPlaceholder(IPlaceholderContainer parent)
 {
     this.parent = parent;
     Size        = new Size(15, 15);
     BackColor   = ColorSettings.Get("ArgumentPlaceholder");
 }
コード例 #11
0
 public VWhileStatement(IWhileStatement whileStatement) : base("выполнять пока", whileStatement)
 {
     BackColor = ColorSettings.Get("WhileStatement");
 }
コード例 #12
0
 public VIfStatement(IIfStatement ifStatement) : base("если", ifStatement)
 {
     BackColor = ColorSettings.Get("IfStatement");
 }
コード例 #13
0
 public VIfStatement() : base("если")
 {
     BackColor = ColorSettings.Get("IfStatement");
 }
コード例 #14
0
ファイル: WorkspacePanel.cs プロジェクト: PShuvaev/vpl
 public WorkspacePanel()
 {
     Dock      = DockStyle.Fill;
     BackColor = ColorSettings.Get("WorkspacePanel");
 }
コード例 #15
0
ファイル: DraggableControl.cs プロジェクト: PShuvaev/vpl
        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));
        }