예제 #1
0
 public Page(Block block, double X, double Y)
 {
     InitializeComponent();
     links     = new List <Link>();
     PositionX = X;
     PositionY = Y;
     Datablock = block;
     Name      = Datablock.name;
     Type      = Datablock.typename;
 }
예제 #2
0
        /// <summary>
        /// добавление блока
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WorkPlace_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ToolBoxTree.SelectedItem is TextBlock)
            {
                Block block;
                if (!(((TextBlock)ToolBoxTree.SelectedItem).DataContext is Block))
                {
                    KeyValuePair <Guid, string> blockTypeInfo = (KeyValuePair <Guid, string>)((TextBlock)ToolBoxTree.SelectedItem).DataContext;
                    block = new Block()
                    {
                        name           = "Пустой",
                        id             = Guid.NewGuid(),
                        blockEntryId   = Guid.NewGuid(),
                        links          = new ObservableCollection <BlockLink>(),
                        settings       = new _BlockSettings(),
                        settingsString = "",
                        typeid         = blockTypeInfo.Key,
                        typename       = blockTypeInfo.Value
                    };
                }
                else
                {
                    block = (Block)((TextBlock)ToolBoxTree.SelectedItem).DataContext;
                    block.blockEntryId = Guid.NewGuid();
                }



                block.isVerification = (Nodes.Count == 0);

                ShowBlockSettings(block);

                Page node = new Page(block, e.GetPosition(WorkPlace).X, e.GetPosition(WorkPlace).Y);

                node.MouseLeftButtonDown  += new MouseButtonEventHandler(node_MouseLeftButtonDown);
                node.MouseLeftButtonUp    += new MouseButtonEventHandler(node_MouseLeftButtonUp);
                node.MouseMove            += new MouseEventHandler(node_MouseMove);
                node.MouseRightButtonDown += new MouseButtonEventHandler(node_MouseRightButtonDown);

                WorkPlace.Children.Add(node);

                if (node.Datablock.isVerification)
                {
                    node.IsRoot = true;
                }
                Nodes.Add(node);
                CurrNode = node;
            }

            //var client = new RouteDBServiceClient();
        }
예제 #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            Block buffBlock = new Block();

            buffBlock.id                  = Guid.NewGuid();
            this.EmptyBlockGuid           = buffBlock.id;
            buffBlock.settings            = new _BlockSettings();
            buffBlock.settings.Conditions = new ObservableCollection <_Condition>();

            _Condition buffer;

            foreach (var item in PropertiesBar.Children)
            {
                if (item.GetType() == typeof(MultiValueParam))
                {
                    buffer = ((MultiValueParam)item).GetData();
                    if (buffer != null)
                    {
                        buffBlock.settings.Conditions.Add(((MultiValueParam)item).GetData());
                    }
                }
                if (item.GetType() == typeof(SingleValueParam))
                {
                    buffer = ((SingleValueParam)item).GetData();
                    if (buffer != null)
                    {
                        buffBlock.settings.Conditions.Add(((SingleValueParam)item).GetData());
                    }
                }
                if (item.GetType() == typeof(TextBlock) && ((TextBlock)item).Name == "blockType")
                {
                    buffBlock.typeid   = (Guid)((TextBlock)item).DataContext;
                    buffBlock.typename = ((TextBlock)item).Text;
                }
                if (item.GetType() == typeof(TextBox) && ((TextBox)item).Name == "blockName")
                {
                    buffBlock.name = ((TextBox)item).Text;
                }
            }

            try
            {
                client.CreateNewBlockAsync(buffBlock);
                PropertiesBar.Children.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        private void ShowBlockSettings(Block block)
        {
            PropertiesBar.Children.Clear();
            ParamsInBlock curBlockParams = BlockParams[block.typename];

            if (block.name == "Пустой")
            {
                TextBlock blockType = new TextBlock();
                blockType.Name        = "blockType";
                blockType.Text        = block.typename;
                blockType.DataContext = block.typeid;
                blockType.FontWeight  = FontWeights.Bold;
                PropertiesBar.Children.Add(blockType);

                TextBlock name = new TextBlock();
                name.Text     = "Назовите блок";
                name.FontSize = 14;
                name.Margin   = new Thickness(1, 5, 1, 5);
                PropertiesBar.Children.Add(name);

                TextBox options = new TextBox();
                options.Text       = block.name;
                options.Name       = "blockName";
                options.Margin     = new Thickness(1, 0, 1, 5);
                options.FontWeight = FontWeights.Bold;
                PropertiesBar.Children.Add(options);

                foreach (var item in curBlockParams.Params)
                {
                    if (item.Value.listParam)
                    {
                        PropertiesBar.Children.Add(
                            new MultiValueParam(
                                new _Condition()
                        {
                            Operation = "Не использовать", Property = item.Value.name, Value = ""
                        }
                                , item.Value));
                    }
                    else
                    {
                        PropertiesBar.Children.Add(
                            new SingleValueParam(
                                new _Condition()
                        {
                            Operation = "Не использовать", Property = item.Value.name, Value = ""
                        }
                                , item.Value));
                    }
                }

                Button SaveButton = new Button();
                SaveButton.Content = "Save";
                SaveButton.Height  = 70;
                SaveButton.Margin  = new Thickness(3);
                SaveButton.Click  += new RoutedEventHandler(SaveButton_Click);
                PropertiesBar.Children.Add(SaveButton);
            }
            else
            {
                TextBlock options = new TextBlock();
                options.Text       = "Block properties: " + block.name;
                options.FontWeight = FontWeights.Bold;
                PropertiesBar.Children.Add(options);

                if (block.settings.Conditions != null)
                {
                    foreach (var item in block.settings.Conditions)
                    {
                        BaseParam curParam = curBlockParams.Params[item.Property];

                        if (curParam.listParam)
                        {
                            PropertiesBar.Children.Add(new MultiValueParam(item, curParam));
                        }
                        else
                        {
                            PropertiesBar.Children.Add(new SingleValueParam(item, curParam));
                        }
                    }
                }
            }
        }
예제 #5
0
 public void UpdateData(Block Datablock)
 {
     this.Datablock = Datablock;
     Name           = Datablock.name;
     Type           = Datablock.typename;
 }