示例#1
0
        private void DesignerElementDoubleClick(object sender, ElementEventArgs e)
        {
            if (!(e.Element is DiagramBlock))
            {
                return;
            }
            var diagramBlock = (DiagramBlock)e.Element;
            var block        = (BlockBase)diagramBlock.State;

            block.CurrentDirectory = CurrentDirectory;

            BlockSetupBaseForm setupForm;

            if (block.ProcessingType == BlockBase.ProcessingTypeEnum.Export)
            {
                setupForm = new BlockSetupTextForm(ApplicationUtils.GetResourceString(block.Name), ref block);
            }
            else
            {
                setupForm = new BlockSetupPlotForm(ApplicationUtils.GetResourceString(block.Name), ref block);
            }
            setupForm.ShowDialog(this);
            if (setupForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            _propertiesWindow.PropertyGrid.SelectedObject = setupForm.Block;
            _propertiesWindow.PropertyGrid.Refresh();
            _outputWindow.Block = setupForm.Block;
            _outputWindow.Refresh();
            diagramBlock.Refresh(ApplicationUtils.GetResourceImage("img" + setupForm.Block.GetAssemblyClassName() + "Mini", 30, 20), ApplicationUtils.GetResourceString(setupForm.Block.Name), setupForm.Block, setupForm.Block.InputNodes.ToArray(), setupForm.Block.OutputNodes.ToArray(), typeof(BlockOutputNode).GetProperty("ShortName"));
            if (setupForm.InputConnectionsChanged || setupForm.OutputConnectionsChanged)
            {
                var links = Designer.Document.Elements.GetArray();
                foreach (var element in links)
                {
                    var link = element as BaseLinkElement;
                    if (link == null)
                    {
                        continue;
                    }
                    if (link.Connector1.ParentElement == diagramBlock || link.Connector2.ParentElement == diagramBlock)  //if (setupForm.OutputConnectionsChanged && link.Connector1.ParentElement == diagramBlock || setupForm.InputConnectionsChanged && link.Connector2.ParentElement == diagramBlock)
                    {
                        Designer.Document.DeleteLink(link, false);
                    }
                }
            }
            diagramBlock.Invalidate();
            diagramBlock.State = setupForm.Block;
            DocumentModel.Touch();
        }
示例#2
0
        private void LoadMemberFromBlock(ICollection <Member> members, Type type)
        {
            var block     = (BlockBase)Activator.CreateInstance(type);
            var blockName = type.Name;
            var member    = members.FirstOrDefault(m => m.Name == blockName && m.Type == "Block");

            if (member == null)
            {
                member = new Member
                {
                    Name         = blockName,
                    Type         = "Block",
                    FriendlyName = ApplicationUtils.GetResourceString(block.Name),
                    Category     = BlockBase.GetProcessingTypeName(block.ProcessingType)
                };
                members.Add(member);
            }
            if (block.HasParameters())
            {
                LoadBlockParameters(block, member);
            }
            SaveBlockImage(block, type, blockName, block.GetAssemblyClassName());
        }
示例#3
0
        private void UpdateGraph()
        {
            var pane = GraphControl.GraphPane;

            if (pane.CurveList.Count > 0)
            {
                pane.CurveList.Clear();
            }
            if (Block == null)
            {
                return;
            }
            Block.Execute();
            var outputNode = Block.OutputNodes.FirstOrDefault(it => it.Name == ShowOutputList.Text);

            if (outputNode == null || outputNode.Object == null || outputNode.Object.Count == 0)
            {
                NoDataLabel.Visible = true;
                GraphControl.Invalidate();
                GraphControl.Refresh();
                return;
            }
            NoDataLabel.Visible = false;
            var index = ShowOutputSignal.SelectedIndex;

            if (index == -1 || index > outputNode.Object.Count - 1)
            {
                index = 0;
            }
            var signal  = outputNode.Object[index];
            var samples = signal.GetSamplesPair().ToList();

            var yAxys = new ZedGraph.PointPairList();

            yAxys.AddRange(samples.Select(it => new ZedGraph.PointPair(it[1], it[0])));
            pane.AddCurve(outputNode.Name, yAxys, Color.Red, ZedGraph.SymbolType.None);

            if (signal.CustomPlot != null && signal.CustomPlot.Length > 0)
            {
                if (signal.CustomPlot.Length == 2)
                {
                    var minValue = signal.Samples.Min() * 1.1;
                    var maxValue = signal.Samples.Max() * 1.1;

                    var area = new ZedGraph.PointPairList {
                        { signal.CustomPlot[0], minValue }, { signal.CustomPlot[0], maxValue },
                        { signal.CustomPlot[0], maxValue }, { signal.CustomPlot[1], maxValue },
                        { signal.CustomPlot[1], maxValue }, { signal.CustomPlot[1], minValue },
                        { signal.CustomPlot[1], minValue }, { signal.CustomPlot[0], minValue }
                    };
                    pane.AddCurve(DesignerResources.PreviousSize, area, Color.Orange, ZedGraph.SymbolType.None);
                }
            }

            pane.Legend.IsVisible      = false;
            pane.Title.Text            = ApplicationUtils.GetResourceString(outputNode.Name);
            pane.XAxis.Title.IsVisible = false;
            pane.YAxis.Title.IsVisible = false;
            if (!pane.IsZoomed && samples.Count() != 0)
            {
                pane.XAxis.Scale.Min = samples.ElementAt(0)[1];
                pane.XAxis.Scale.Max = samples.ElementAt(samples.Count() - 1)[1];
            }
            GraphControl.AxisChange();
            GraphControl.Invalidate();
            GraphControl.Refresh();
        }
示例#4
0
        private void RefreshSelectedDiagramBlock()
        {
            var diagramBlock = Designer.Document.SelectedElements[0] as DiagramBlock;

            if (diagramBlock == null)
            {
                return;
            }
            var block = (BlockBase)diagramBlock.State;

            block.CurrentDirectory = CurrentDirectory;
            diagramBlock.Refresh(ApplicationUtils.GetResourceImage("img" + block.GetAssemblyClassName() + "Mini", 30, 20), ApplicationUtils.GetResourceString(block.Name), block, block.InputNodes.ToArray(), block.OutputNodes.ToArray(), typeof(BlockOutputNode).GetProperty("ShortName"));
        }
示例#5
0
 private void LoadBlocks(QCompositeItemBase composite, BlockBase.ProcessingTypeEnum processingType)
 {
     foreach (var type in WaveletStudio.Utils.GetTypes("WaveletStudio.Blocks").Where(t => t.BaseType == typeof(BlockBase)).OrderBy(BlockBase.GetName))
     {
         var block = (BlockBase)Activator.CreateInstance(type);
         block.CurrentDirectory = CurrentDirectory;
         if (block.ProcessingType != processingType || type == typeof(GenerateSignalBlock))
         {
             continue;
         }
         var item = QControlUtils.CreateCompositeItem(type.FullName, "img" + block.GetAssemblyClassName(), ApplicationUtils.GetResourceString(block.Name));
         item.ItemActivated += (sender, args) => CreateBlock(((QCompositeItem)sender).ItemName);
         composite.Items.Add(item);
     }
 }