コード例 #1
0
        public ComTempSensorCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            EnviromentCanvas.EnvSetableList.Add(this);

            Width = 130; Height = 60;
            AddClickPoint(new RemoveClickPoint(0, 0, this));

            SetupBackgrountStyle();

            Label titleLabel = new Label()
            {
                Margin           = new Thickness(20, 1, 0, 0),
                Content          = "温度传感器",
                FontSize         = 20,
                IsHitTestVisible = false
            };

            Children.Add(titleLabel);



            comCanvas = new ComCanvas(30, 40, global, tempSensor);
            AddClickPoint(comCanvas);

            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Start();
        }
コード例 #2
0
        public WLPackageDisplayCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            Width      = 40 + WLPackageDev.PACKAGE_SIZE * 30;
            Height     = 40;
            Background = Brushes.DarkGreen;
            //title
            Children.Add(new Label()
            {
                Content          = "PackageDisplay(DEBUG)",
                Margin           = new Thickness(40, 0, 0, 0),
                IsHitTestVisible = false
            });
            //remove button
            AddClickPoint(new RemoveClickPoint(0, 0, this));

            //signal
            signal = new WirelessSignal(global.rootcvs, dev, 20, 20);
            Children.Add(signal);

            dev.OnPackageArrive = (b) => {
                string s = "";
                foreach (byte bt in b)
                {
                    s += bt.ToString() + " ";
                }
                DisplayLabel.Content = s;
            };

            Children.Add(DisplayLabel);

            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Start();
        }
コード例 #3
0
        public WirelessComDevCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            Height = 60;
            Width  = 180;
            SetupBackgrountStyle();

            //Remove
            AddClickPoint(new RemoveClickPoint(0, 0, this));

            //Title
            Children.Add(new Label()
            {
                Margin           = new Thickness(40, 5, 0, 0),
                IsHitTestVisible = false,
                Content          = "WirelessDev<->Com"
            });

            //WLCom


            //ComBase
            AddClickPoint(ComCanvas = new ComCanvas(40, 40, global, WLCom.comBase));

            //signal
            Children.Add(signal = new WirelessSignal(global.rootcvs, WLCom, 20, 20));
            //timer
            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Start();
        }
コード例 #4
0
        public ComRealDevCanvas(ComRealDevSetthings setthings, GlobalGUIManager global) : base(global.rootcvs)
        {
            this.global = global;

            Width  = 140;
            Height = 140;

            SetupBackgrountStyle();
            //title canvas
            Children.Add(new Label()
            {
                Margin           = new Thickness(20, 0, 0, 0),
                Content          = "RealCom",
                Foreground       = Brushes.Black,
                IsHitTestVisible = false,
                FontSize         = 18
            });
            //info canvas
            Children.Add(new Label()
            {
                Margin           = new Thickness(10, 30, 0, 0),
                IsHitTestVisible = false,
                Content          = String.Format("Com info:\nName:{0}\n" +
                                                 "bundrate:{1}\n" +
                                                 "databits:{2}\n" +
                                                 "stopbits:{3}\n" +
                                                 "parity:{4}", setthings.portName, setthings.baudrate, setthings.databits,
                                                 setthings.stopBits.ToString(), setthings.parity.ToString()),
                Foreground = Brushes.Black
            });

            try
            {
                com = new ComRealDev(setthings);
            }catch (Exception e)
            {
                //创建错误,清理退出
                Remove();
                throw e;
            }


            AddClickPoint(new RemoveClickPoint(0, 0, this));

            AddClickPoint(comCvs = new ComCanvas(100, 40, global, com));

            AddClickPoint(openButton);
            openButton.OnClickEvent  += ComOpen;
            warrButton.OnClickEvent  += ComOpen;
            closeButton.OnClickEvent += ComClose;
        }
コード例 #5
0
        public VtmDevCanvas(GlobalGUIManager global, String binpath) : base(global.rootcvs)
        {
            this.global = global;

            Width  = 500;
            Height = 360;
            SetupBackgrountStyle();

            AddClickPoint(new RemoveClickPoint(3, 3, this));
            AddClickPoint(RunButton);

            Children.Add(StatusLabel);
            //Dev
            dev = new VtmDev(binpath);
            //ComCanvas
            for (int i = 0; i < coms.Length; i++)
            {
                coms[i] = new ComCanvas(30 + 50 * i, 270, global, dev.GetComPortBase(i));
                AddClickPoint(coms[i]);
            }

            //title
            Children.Add(new Label()
            {
                Content          = "VTM-C",
                FontSize         = 30,
                Foreground       = Brushes.SlateBlue,
                Margin           = new Thickness(20, 290, 0, 0),
                IsHitTestVisible = false
            });


            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(50);

            RunButton.OnClickEvent += Run;

            //BlackModule
            BlackModule = VtmModule.BlackModule.NewBlackModules(this, global);
            foreach (var m in BlackModule)
            {
                Children.Add(m.Value);
                m.Value.FitPosition(m.Key);
            }

            /*
             * //LedModule
             * AddModule(typeof(LedModule));
             */
        }
コード例 #6
0
ファイル: ComLedCanvas.cs プロジェクト: frto027/IotSimulate
        public ComLedCanvas(GlobalGUIManager manager) : base(manager.rootcvs)
        {
            Width  = 100;
            Height = 80;


            SetupBackgrountStyle();

            Children.Add(new Label()
            {
                IsHitTestVisible = false,
                Content          = "ComLed",
                FontSize         = 16,
                Margin           = new Thickness(18, 0, 0, 0)
            });


            AddClickPoint(new RemoveClickPoint(3, 3, this));

            L1 = new Label()
            {
                Foreground       = Brushes.Red,
                Margin           = new Thickness(5, 20, 0, 0),
                FontSize         = 28,
                IsHitTestVisible = false
            };
            L2 = new Label()
            {
                Foreground       = Brushes.Red,
                Margin           = new Thickness(25, 20, 0, 0),
                FontSize         = 28,
                IsHitTestVisible = false
            };
            Lcount = new Label()
            {
                Margin = new Thickness(10, 55, 0, 0)
            };

            Children.Add(L1);
            Children.Add(L2);
            Children.Add(Lcount);

            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick    += Update;

            timer.Start();

            //添加一个Com口连接点
            AddClickPoint(comCanvas = new ComCanvas(60, 40, manager, led.com));
        }
コード例 #7
0
ファイル: ComCanvas.cs プロジェクト: frto027/IotSimulate
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="x">x偏移</param>
        /// <param name="y">y偏移</param>
        /// <param name="globalGUIManager">全局对象</param>
        /// <param name="comBase">绑定的串口</param>
        public ComCanvas(double x, double y, GlobalGUIManager globalGUIManager, ComBase comBase) : base(x, y, globalGUIManager)
        {
            Width      = 30;
            Height     = 10;
            Background = Brushes.DimGray;

            Children.Add(GetCircleByOffset(0));
            Children.Add(GetCircleByOffset(-PointMargin));
            Children.Add(GetCircleByOffset(PointMargin));

            DragCanvas.MouseMoveAction += Update;

            this.ComBase = comBase;
        }
コード例 #8
0
        public WirelessComHostCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            Width  = 250;
            Height = 60;

            SetupBackgrountStyle();

            rootcvs = global.rootcvs;
            maskcvs = global.maskcvs;
            //Title
            Children.Add(new Label()
            {
                IsHitTestVisible = false,
                Margin           = new Thickness(30, 5, 0, 0),
                Content          = "wireless(host) <-> com"
            });
            //Remove
            AddClickPoint(new RemoveClickPoint(0, 0, this));
            //Combase
            ComCanvas = new ComCanvas(30, 30, global, WLComHost.comBase);
            AddClickPoint(ComCanvas);

            //Range
            maskcvs.Children.Add(RangeCanvas = new Canvas()
            {
                Margin     = new Thickness(0, 0, 0, 0),
                Background = new DrawingBrush()
                {
                    Drawing = new GeometryDrawing()
                    {
                        Pen      = new Pen(Brushes.Red, 0.2),
                        Geometry = RangeGeometry = new EllipseGeometry(),
                        Brush    = new SolidColorBrush(Color.FromArgb(60, 100, 100, 10))
                    },
                },
                IsHitTestVisible = false
            });
            UpdateRange();

            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Start();
        }
コード例 #9
0
        public ComVirtualIncCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            //初始化一个TitleCvs用于显示标题
            Children.Add(new Label()
            {
                IsHitTestVisible = false,
                Content          = "VirIncCom",
                FontSize         = 20,
                Margin           = new Thickness(25, 0, 0, 0)
            });

            Height = 80;
            Width  = 140;

            SetupBackgrountStyle();

            AddClickPoint(new RemoveClickPoint(3, 3, this));

            AddClickPoint(comCanvas = new ComCanvas(100, 35, global, com));

            AddClickPoint(Button = new ClickEventPoint(10, 30)
            {
                Height = 40,
                Width  = 60,
            });

            Button.Children.Add(new Label()
            {
                Margin           = new Thickness(0, 0, 0, 0),
                IsHitTestVisible = false,
                FontSize         = 20,
                Content          = "Send",
                Foreground       = Brushes.Green,
            });

            Button.SetupBackgrountStyle();

            Button.OnClickEvent += SendData;

            Children.Add(nextLabel);
            UpdateNextLabel();
        }
コード例 #10
0
        public WLPackageSendCanvas(GlobalGUIManager global) : base(global.rootcvs)
        {
            Width      = 20 + textBoxes.Length * WindowDistance + 20;
            Height     = 60;
            Background = Brushes.DarkGreen;
            //title
            Children.Add(new Label()
            {
                IsHitTestVisible = false, Content = "Wireless Package Sender", Margin = new Thickness(30, 0, 0, 0)
            });
            //remove
            AddClickPoint(new RemoveClickPoint(0, 0, this));

            for (int i = 0; i < textBoxes.Length; i++)
            {
                textBoxes[i] = new NumberOnlyTextBox()
                {
                    Margin = new Thickness(20 + WindowDistance * i, 20, 0, 0),
                    Width  = WindowDistance,
                };
                Children.Add(textBoxes[i]);
            }

            ClickEventPoint clickEventPoint = new ClickEventPoint(20, 40)
            {
                Width = 10, Height = 10, Background = Brushes.LightGreen
            };

            clickEventPoint.OnClickEvent += Submit;
            AddClickPoint(clickEventPoint);

            signal = new WirelessSignal(global.rootcvs, dev, 20, 20);
            Children.Add(signal);

            timer.Tick    += Update;
            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Start();
        }
コード例 #11
0
        public EnviromentCanvas(GlobalGUIManager manager) : base(manager.rootcvs)
        {
            Width  = 200;
            Height = 80;
            SetupBackgrountStyle(Colors.Black, Colors.Orange);

            rootcvs = manager.rootcvs;

            AddClickPoint(new RemoveClickPoint(0, 0, this));

            Children.Add(new Label()
            {
                Content          = "Enviroment",
                FontSize         = 16,
                Margin           = new Thickness(20, 0, 0, 0),
                Foreground       = Brushes.Blue,
                IsHitTestVisible = false
            });

            Label tempTipLabel = new Label()
            {
                Content          = "Temp:",
                Margin           = new Thickness(0, 20, 0, 0),
                IsHitTestVisible = false
            };

            Children.Add(tempTipLabel);
            Children.Add(tempSlider);
            Children.Add(tempLabel);

            Label lightTipLabel = new Label()
            {
                Content          = "Light:",
                Margin           = new Thickness(0, 40, 0, 0),
                IsHitTestVisible = false
            };

            Children.Add(lightTipLabel);
            Children.Add(lightSlider);
            Children.Add(lightLabel);

            updateTimer.Tick    += Update;
            updateTimer.Interval = TimeSpan.FromMilliseconds(200);
            updateTimer.Start();

            Children.Add(new Canvas()
            {
                IsHitTestVisible = false,
                Margin           = new Thickness(-maxDistance, -maxDistance, 0, 0),
                Width            = 2 * maxDistance, Height = 2 * maxDistance,
                Background       = new DrawingBrush()
                {
                    Drawing = new GeometryDrawing()
                    {
                        Geometry = new EllipseGeometry(new Point(200, 200), 200, 200),
                        Pen      = new Pen(Brushes.Black, 1)
                        {
                            DashStyle = new DashStyle(new double[] { 8, 6, 6, 6 }, 0)
                        },
                        Brush = Brushes.Transparent
                    }
                }
            });
        }