Пример #1
0
 void CCTVLock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (this.Canvas.FindName("cctvctl")!=null)
         return;
      Control ctl = sender as Control;
     CCTVBindingData data=ctl.DataContext as CCTVBindingData;
     CCTVControl cctv = new CCTVControl(data.MjpegCgiString, data.UserName, data.Password);
     cctv.Name = data.CCTVName;
     cctv.Width=400;
     cctv.Height=300;
    Interaction.GetBehaviors(cctv).Add(new Microsoft.Expression.Interactivity.Layout.MouseDragElementBehavior());
    cctv.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
   cctv.VerticalAlignment= System.Windows.VerticalAlignment.Top;
   this.Canvas.Children.Add(cctv);
     //throw new NotImplementedException();
 }
Пример #2
0
        async void PlaceCCTV()
        {
            //CCTV temp = new CCTV();
            //temp.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            //temp.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            //temp.SetValue(Grid.MarginProperty, new Thickness(625, 500, 0, 0));
            //this.Canvas.Children.Add(temp);
            //return;

            if (IsExit)
                return;
            var q = from n in db.GetTblCCTVConfigQuery() where  n.PlaneID == this.PlaneID select n;
            var res = await db.LoadAsync<tblCCTVConfig>(q);

            foreach (tblCCTVConfig tbl in res)
            {

               
                CCTV item = new CCTV();
                item.Name = "CCTV" + tbl.CCTVID;
                

                item.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                item.VerticalAlignment = System.Windows.VerticalAlignment.Top;




                // this.Canvas.DataContext = item.DataContext = tbl;



                
                item.SetValue(Grid.MarginProperty, new Thickness(tbl.X, tbl.Y, 0, 0));
               // CompositeTransform transform = new CompositeTransform() { Rotation = tbl.Rotation, ScaleX = tbl.ScaleX, ScaleY = tbl.ScaleY };
               // item.RenderTransform = transform;
                CCTVBindingData bindingdata=null;
                
                if (CCTVBindingDatas == null)
                    return;
             
                  bindingdata=CCTVBindingDatas.FirstOrDefault(n => n.CCTVID==tbl.CCTVID );
                item.UserName = bindingdata.UserName;
                item.Password = bindingdata.Password;
                item.Url = bindingdata.MjpegCgiString;
                 
                item.DataContext =   bindingdata;
                item.MouseLeftButtonDown += CCTVLock_MouseLeftButtonDown;


                this.Canvas.Children.Add(item);
               
             //   CCTVLock_MouseLeftButtonDown(item, null);
               
                


            }

            CCTVBindingData cctvdata = CCTVBindingDatas.FirstOrDefault();
            if (cctvdata == null)
                return;
            if (IsExit)
                return;
            CCTVControl cctv = new CCTVControl(cctvdata.MjpegCgiString, cctvdata.UserName, cctvdata.Password);
            cctv.Name = "cctvctl"+cctvdata.CCTVName;
         //   cctv.Width = 400;
          //  cctv.Width = 300;
            cctv.Height = 200;
          //  Interaction.GetBehaviors(cctv).Add(new Microsoft.Expression.Interactivity.Layout.MouseDragElementBehavior());
            cctv.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            cctv.VerticalAlignment = System.Windows.VerticalAlignment.Top;
          //  this.Canvas.Children.Add(cctv);
            cctv.Margin = new Thickness(5,35,0,0);
            cctv.IsEnableCloseButton = false;
            Grid.SetRow(cctv, 0);
            Grid.SetColumn(cctv, 1);
            LayoutRoot.Children.Add(cctv);
        }