예제 #1
0
 public void SetData(JControlOutputData comdata, JControlOutputData adadata, string f1, string f2)
 {
     if (comdata != null)
     {
         Communicator = JWCCommunicatorFactory.CreateCommunicator(f1);
         Communicator.InputProperty(comdata);
     }
     if (adadata != null)
     {
         Adapter = JWCCommunicatorFactory.CreateAdapter(f2);
         Adapter.InputProperty(adadata);
     }
 }
예제 #2
0
        void fm_comsetting_OnStepChanged(int laststep, int nextstep, WizardEventArg e)
        {
            if (laststep == 1)
            {
                if (lst_com.SelectedItem == null)
                {
                    MessageBox.Show("你必须选择一个通信器!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                    e.Cancel = true;
                    return;
                }
                MyListItem item = (MyListItem)lst_com.SelectedItem;
                if (Communicator == null || Communicator.GetType().FullName != item.FullName)
                {
                    Communicator = JWCCommunicatorFactory.CreateCommunicator(item.FullName);
                }

                ComAdPropManager man = new ComAdPropManager(stk_com_prop, txt_comhelp);
                man.RefreshComPropList(Communicator);
            }
            else if (laststep == 3)
            {
                if (lst_ada.SelectedItem == null)
                {
                    MessageBox.Show("你必须选择一个适配器!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                    e.Cancel = true;
                    return;
                }
                MyListItem item = (MyListItem)lst_ada.SelectedItem;
                if (Adapter == null || Adapter.GetType().FullName != item.FullName)
                {
                    Adapter = JWCCommunicatorFactory.CreateAdapter(item.FullName);
                }
                ComAdPropManager man = new ComAdPropManager(stk_ada_prop, txt_adahelp);
                man.RefreshComPropList(Adapter);
            }
        }
예제 #3
0
        void fm_comsetting_Loaded(object sender, RoutedEventArgs e)
        {
            SetStepLbls(CurrStep);

            string old_comfullname = null;

            if (Communicator != null)
            {
                old_comfullname = Communicator.GetType().FullName;
            }
            int idx = 0, s_idx = 0;
            var lst = JWCCommunicatorFactory.GetAllComs();

            foreach (var pai in lst)
            {
                MyListItem item = new MyListItem();
                item.FullName = pai.Key;
                Type tp = pai.Value;
                JWCCommDescAttribute attr = (JWCCommDescAttribute)Attribute.GetCustomAttribute(tp, typeof(JWCCommDescAttribute));
                item.FName       = attr.FriendlyName;
                item.Description = attr.Description;
                lst_com.Items.Add(item);
                if (old_comfullname != null && old_comfullname.Equals(item.FullName))
                {
                    s_idx = idx;
                }
                idx++;
            }
            if (this.Communicator != null)
            {
                lst_com.SelectedIndex = s_idx;
            }
            idx = s_idx = 0;

            //Init adapter listbox
            if (Adapter != null)
            {
                old_comfullname = Adapter.GetType().FullName;
            }
            var lst2 = JWCCommunicatorFactory.GetAllAdapters();

            foreach (var pai in lst2)
            {
                MyListItem item = new MyListItem();
                item.FullName = pai.Key;
                Type tp = pai.Value;
                JWCAdapterDescAttribute attr = (JWCAdapterDescAttribute)Attribute.GetCustomAttribute(tp, typeof(JWCAdapterDescAttribute));
                item.FName       = attr.FriendlyName;
                item.Description = attr.Description;
                lst_ada.Items.Add(item);
                if (old_comfullname != null && old_comfullname.Equals(item.FullName))
                {
                    s_idx = idx;
                }
                idx++;
            }
            if (this.Adapter != null)
            {
                lst_ada.SelectedIndex = s_idx;
            }
        }
예제 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SetRunFilePath();
            if (!System.IO.File.Exists(Filepath))
            {
                return;
            }

            JWCSerializer <JWCSaveFile> jse = new JWCSerializer <JWCSaveFile>();
            JWCSaveFile file = jse.Deserialize(this.Filepath);
            Color       cl   = Color.FromArgb(file.BackColor[0], file.BackColor[1], file.BackColor[2], file.BackColor[3]);

            Communicator = JWCCommunicatorFactory.CreateCommunicator(file.ComName);
            if (Communicator == null)
            {
                MessageBox.Show("创建通信器失败!这可能是由于没有导入相关插件导致的。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }
            Communicator.InputProperty(file.Communicator);
            Adaptor = JWCCommunicatorFactory.CreateAdapter(file.AdaName);
            if (Adaptor == null)
            {
                MessageBox.Show("创建适配器失败!这可能是由于没有导入相关插件导致的。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }
            Adaptor.InputProperty(file.ComAdapter);
            Adaptor.SetCommunicator(Communicator);

            foreach (var s in file.AllControls)
            {
                string     fullname = s["FullName"].ToString();
                JWCControl jc       = JWCControlFactory.CreateInstance(fullname);
                if (jc == null)
                {
                    MessageBox.Show("读入控件失败!这可能是由于没有导入相关插件导致的。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                    this.Close();
                    return;
                }
                jc.InputProperty(s);
                jc.IsEditMode = false;
                jc.Init(false);
                jc.Parent = grid_main;
                grid_main.Children.Add(jc);
                IDataSender se = jc as IDataSender;
                if (se != null)
                {
                    Adaptor.AppendSender(se);
                }
                IDataReceiver re = jc as IDataReceiver;
                if (re != null)
                {
                    Adaptor.AppendReceiver(re);
                }
            }
            this.Height = grid_main.Height = file.Height;
            this.Width  = grid_main.Width = file.Width;
            SetBg(file.BgUsePic, cl, file.BackGroundPic);
            Communicator.Initialization();
            Adaptor.Initialization();
            Communicator.Start();
        }