public AddOrEditChannelWnd(ProxyChannelItem pi, bool isEdit)
 {
     InitializeComponent();
     IsEdit           = isEdit;
     _uiContext       = pi.Clone();
     _orgItem         = pi;
     this.DataContext = _uiContext;
     this.Title       = isEdit ? "Edit Channel" : "New Channel";
 }
Exemplo n.º 2
0
        private void BtnNew_Click(object sender, RoutedEventArgs e)
        {
            ProxyChannelItem    pi           = new ProxyChannelItem();
            AddOrEditChannelWnd addOrEditWnd = new AddOrEditChannelWnd(pi, false);

            if (addOrEditWnd.ShowDialog().Value)
            {
                _channelVMList.Add(pi);
                SaveConfig();
            }
        }
Exemplo n.º 3
0
        private void btnStopService_Click(object sender, RoutedEventArgs e)
        {
            ProxyChannelItem pi = (sender as FrameworkElement).DataContext as ProxyChannelItem;

            try
            {
                pi.StopService();
            }
            catch (Exception ex)
            {
                LocalMsgBox(ex.Message);
            }
        }
Exemplo n.º 4
0
 private void LoadConfig()
 {
     _channelVMList = new ObservableCollection <ProxyChannelItem>();
     if (File.Exists(_configFilePath))
     {
         string strJson = File.ReadAllText(_configFilePath, Encoding.UTF8);
         List <ProxyChannel> channelList = JsonConvert.DeserializeObject <List <ProxyChannel> >(strJson);
         foreach (ProxyChannel channel in channelList)
         {
             ProxyChannelItem pi = ProxyChannelItem.FromModel(channel);
             _channelVMList.Add(pi);
         }
     }
 }
Exemplo n.º 5
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            ProxyChannelItem selItem = dgChannel.SelectedItem as ProxyChannelItem;

            if (selItem == null)
            {
                LocalMsgBox("Please select the channel that you want to delete.");
                return;
            }
            if (selItem.IsRunning)
            {
                LocalMsgBox("Can not delete channel during running time.");
                return;
            }
            if (QuestionOKCancel("Are you sure to delete the channel?") == MessageBoxResult.Cancel)
            {
                return;
            }
            _channelVMList.Remove(selItem);
            SaveConfig();
        }
Exemplo n.º 6
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            ProxyChannelItem selItem = dgChannel.SelectedItem as ProxyChannelItem;

            if (selItem == null)
            {
                LocalMsgBox("Please select the channel that you want to edit.");
                return;
            }
            if (selItem.IsRunning)
            {
                LocalMsgBox("Can not edit channel during running time.");
                return;
            }
            AddOrEditChannelWnd addOrEditWnd = new AddOrEditChannelWnd(selItem, false);

            if (addOrEditWnd.ShowDialog().Value)
            {
                SaveConfig();
            }
        }