Пример #1
0
        private void ItemSaveToButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem        item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse  = item.Tag as RequestSendFileEventArgs;

            // FolderBrowserDialog fbd = new FolderBrowserDialog();
            // if (fbd.ShowDialog() == DialogResult.OK)
            ////{
            rse.Path = "E:\\CMSRec\\" + rse.TraFransfersFileStart.FileName.Substring(0, rse.TraFransfersFileStart.FileName.LastIndexOf("."));
            DirectoryInfo dir = new DirectoryInfo(rse.Path);

            dir.Create();
            AppendLog(string.Format(
                          "同意接收文件 {0}。",
                          rse.TraFransfersFileStart.FileName), false);
            ControlTag tag = new ControlTag(
                rse.TraFransfersFileStart.MD5,
                rse.TraFransfersFileStart.FileName,
                rse.RemoteIP);

            item.Tag                = tag;
            item.Style              = FileTransfersItemStyle.Receive;
            item.CancelButtonClick += new EventHandler(ItemCancelButtonClick);
            item.Start();

            udpReceiveFile.AcceptReceive(rse);
            // }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="regex"></param>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        private FrameworkElement CreateDictionaryControl(string name, string regex, object dictionary)
        {
            DictionaryControl dictControl = new()
            {
                Tag = new ControlTag(name, regex)
            };

            FillDictionary(dictionary, dictControl);
            return(dictControl);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="regex"></param>
        /// <param name="isReadonly"></param>
        /// <param name="boolValue"></param>
        /// <returns></returns>
        private FrameworkElement CreateCheckBox(string name, string regex, bool?isReadonly, bool boolValue)
        {
            CheckBox checkbox = new()
            {
                Style     = Application.Current.Resources["BaseCheckboxStyle"] as Style,
                Tag       = new ControlTag(name, regex),
                IsEnabled = isReadonly ?? true,
                IsChecked = boolValue
            };

            return(checkbox);
        }
Пример #4
0
 // POST: api/cliente
 public IHttpActionResult Post([FromBody] Tag value)
 {
     try
     {
         ControlTag.devolverInstancia().grabar(value);
         return(Ok(value));
     }
     catch (UsuarioException ex)
     {
         throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest, ex.errores));
     }
 }
Пример #5
0
        private void ItemCancelButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem item = sender as FileTransfersItem;
            ControlTag        tag  = item.Tag as ControlTag;

            udpReceiveFile.CancelReceive(tag.MD5, tag.RemoteIP);
            fileTansfersContainer.RemoveItem(item);
            item.Dispose();
            AppendLog(string.Format(
                          "取消接收文件 {0}。",
                          tag.FileName), false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="regex"></param>
        /// <param name="stringArray"></param>
        /// <returns></returns>
        private FrameworkElement CreateListControl(string name, string regex, string[] stringArray)
        {
            ListControl list = new()
            {
                Tag = new ControlTag(name, regex)
            };

            foreach (string item in stringArray)
            {
                list.AddItem(item);
            }
            return(list);
        }
Пример #7
0
 private void updatePage1234(object sender, PLCInterfaceEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         try
         {
             ControlTag.GetValueFromGroupBuffer(e.CyclicControlBuffer);
             SetpointX888 = (float)ControlTag.Value;
         }
         catch
         { }
     }
                                     ));
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="regex"></param>
        /// <param name="isReadonly"></param>
        /// <param name="stringValue"></param>
        /// <param name="styleName"></param>
        /// <returns></returns>
        private FrameworkElement CreateTextbox(string name, string regex, bool?isReadonly, string stringValue, string styleName)
        {
            TextBox textBox = new()
            {
                Style      = Application.Current.Resources[styleName] as Style,
                Tag        = new ControlTag(name, regex),
                IsReadOnly = isReadonly ?? false,
                Text       = stringValue ?? ""
            };

            return(textBox);
        }

        #endregion
    }
Пример #9
0
        private void ItemSaveButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem        item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse  = item.Tag as RequestSendFileEventArgs;

            rse.Path = Application.StartupPath;
            AppendLog(string.Format(
                          "同意接收文件 {0}。",
                          rse.TraFransfersFileStart.FileName), false);
            ControlTag tag = new ControlTag(
                rse.TraFransfersFileStart.MD5,
                rse.TraFransfersFileStart.FileName,
                rse.RemoteIP);

            item.Tag                = tag;
            item.Style              = FileTransfersItemStyle.Receive;
            item.CancelButtonClick += new EventHandler(ItemCancelButtonClick);
            item.Start();

            udpReceiveFile.AcceptReceive(rse);
        }
Пример #10
0
 private void updatePage123(object sender, PLCInterfaceEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         try
         {
             ControlTag.GetValueFromGroupBuffer(e.CyclicStatusBuffer);
             if ((bool)ControlTag.Value)
             {
                 label123.Background = OnColor;
             }
             else
             {
                 label123.Background = OffColor;
             }
         }
         catch
         {
         }
     }
                                     ));
 }
Пример #11
0
        private void ItemSaveToButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem        item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse  = item.Tag as RequestSendFileEventArgs;
            FolderBrowserDialog      fbd  = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                rse.Path = fbd.SelectedPath;
                AppendLog(string.Format(
                              "同意接收文件 {0}。",
                              rse.TraFransfersFileStart.FileName), false);
                ControlTag tag = new ControlTag(
                    rse.TraFransfersFileStart.MD5,
                    rse.TraFransfersFileStart.FileName,
                    rse.RemoteIP);
                item.Tag                = tag;
                item.Style              = FileTransfersItemStyle.Receive;
                item.CancelButtonClick += new EventHandler(ItemCancelButtonClick);
                item.Start();

                udpReceiveFile.AcceptReceive(rse);
            }
        }
Пример #12
0
 public ControlGroupDivTag(string labelText, string bodyText) : this(labelText)
 {
     ControlTag.Add("div").AddClass("control-label").Text(bodyText);
 }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e) {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.
            DevicesListView.Items.Clear();
            if (e.Parameter != null) {
                try {
                    Room room = (Room)e.Parameter;
                    RoomTextBlock.Text = "Room " + room.Name;
                    Rect.Fill = new SolidColorBrush(Color.FromArgb(15,15,23,0));

                    if (App.connected) {

                        App.proxy.Invoke<String>("getDevices",room.ID).ContinueWith(async task => {
                            String result = task.Result;
                            ICollection<Models.Device> devices = JsonConvert.DeserializeObject<ICollection<Models.Device>>(result);
                            App.devices = devices;
                            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => {
                                
                                if (App.devices != null) {
                                    
                                    ChooseAnotherTextBlock.Visibility = Visibility.Visible;
                                    foreach (Device b in App.devices) {

                                        switch (b.DeviceType){
                                            case DeviceType.DIMMER:
                                                Slider slider = new Slider();
                                                slider.MinWidth = 280;
                                                slider.Margin = new Thickness(10, 0, 10, 0);
                                                slider.Header = b.Name;
                                                slider.Minimum = 0;
                                                slider.Maximum = 255;
                                                ControlTag tag = new ControlTag();
                                                tag.deviceID = b.ID;
                                                tag.changing = false;
                                                slider.Tag = tag;
                                                slider.ValueChanged += slider_ValueChanged;
                                                slider.PointerCaptureLost += slider_PointerCaptureLost;
                                                DevicesListView.Items.Add(slider);
                                                App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => {
                                                    int value = task2.Result;
                                                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                                                        slider.Value = value;
                                                        ((ControlTag)slider.Tag).lastValue = value;
                                                    });
                                                });
                                                break;
                                            case DeviceType.POWER_SWITCH:
                                                ToggleSwitch newSwitch = new ToggleSwitch();
                                                newSwitch.Header = b.Name;
                                                newSwitch.MinWidth = 280;
                                                tag = new ControlTag();
                                                tag.deviceID = b.ID;
                                                tag.changing = false;
                                                newSwitch.Tag = tag;
                                                newSwitch.Toggled += newSwitch_Toggled;
                                                DevicesListView.Items.Add(newSwitch);
                                                App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => {
                                                    int value = task2.Result;
                                                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                                                        if (value == 0) {
                                                            newSwitch.IsOn = false;
                                                        } else {
                                                            newSwitch.IsOn = true;
                                                        }
                                                    });
                                                });
                                                break;
                                            case DeviceType.THERMOMETER:
                                                TextBlock NameTextBlock = new TextBlock();
                                                NameTextBlock.FontSize = 24;
                                                NameTextBlock.Text = b.Name;
                                                tag = new ControlTag();
                                                tag.deviceID = -1;
                                                tag.changing = false;
                                                NameTextBlock.Tag = tag;
                                                TextBlock tempTextBlock = new TextBlock();
                                                tempTextBlock.FontSize = 20;
                                                tempTextBlock.Text = "0";
                                                tempTextBlock.MinWidth = 300;
                                                tempTextBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
                                                tempTextBlock.TextAlignment = TextAlignment.Center;
                                                tag = new ControlTag();
                                                tag.deviceID = b.ID;
                                                tag.changing = false;
                                                tempTextBlock.Tag = tag;
                                                DevicesListView.Items.Add(NameTextBlock);
                                                DevicesListView.Items.Add(tempTextBlock);
                                                App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => {
                                                    int value = task2.Result;
                                                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                                                        tempTextBlock.Text = value.ToString();
                                                    });
                                                });
                                                break;
                                        }
                                    }
                                }
                                if (App.devices == null || App.devices.Count == 0) {
                                    TextBlock textBlock2 = new TextBlock();
                                    textBlock2.FontSize = 24;
                                    textBlock2.Text = "It's empty here";
                                    DevicesListView.IsEnabled = false;
                                    DevicesListView.Items.Add(textBlock2);
                                }
                            });
                        });

                    }
                    ChooseRoomLabel.Visibility = Visibility.Collapsed;
                } catch (InvalidCastException) {
                    ChooseRoomLabel.Visibility = Visibility.Visible;
                    RoomTextBlock.Text = "";
                    ChooseAnotherTextBlock.Visibility = Visibility.Collapsed;
                    Rect.Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                }

            } else {
                Rect.Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                ChooseRoomLabel.Visibility = Visibility.Visible;
                RoomTextBlock.Text = "";
                ChooseAnotherTextBlock.Visibility = Visibility.Collapsed;
            }

        }
Пример #14
0
 // DELETE: api/ApiCliente/5
 public void Delete(int id)
 {
     ControlTag.devolverInstancia().eliminar(id);
 }
Пример #15
0
        // PUT: api/cliente/5
        public void Put(int id, [FromBody] Tag value)
        {
            var espacio = ControlTag.devolverInstancia().devolver(id);

            ControlTag.devolverInstancia().grabar(value);
        }
Пример #16
0
 // GET: api/cliente/5
 public Tag Get(int id)
 {
     return(ControlTag.devolverInstancia().devolver(id));
 }
Пример #17
0
 // GET: api/cliente
 public IEnumerable <Tag> Get()
 {
     return(ControlTag.devolverInstancia().devolverTodos());
 }