예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var lst = JWCControlFactory.GetAllControls();

            foreach (var pai in lst)
            {
                CtrlListboxItem item = new CtrlListboxItem();
                item.FullName = pai.Key;
                Type jctp = pai.Value;
                JWCControlDescAttribute attr = (JWCControlDescAttribute)Attribute.GetCustomAttribute(jctp, typeof(JWCControlDescAttribute));
                if (attr == null)
                {
                    item.FName = item.FullName;
                }
                else
                {
                    item.FName = attr.FriendlyName;
                }
                if (attr == null || attr.Description == null || attr.Description.Length < 1)
                {
                    item.Description = "该控件无描述文本";
                }
                else
                {
                    item.Description = attr.Description;
                }
                lst_ctrls.Items.Add(item);
            }
        }
예제 #2
0
 public MainWindow()
 {
     InitializeComponent();
     this.Closing += MainWindow_Closing;
     JWCCommunicationLib.JWCCommunicatorFactory.LoadLibs(AppDomain.CurrentDomain.BaseDirectory + "\\Communicators");
     JWCControlFactory.LoadLibs(AppDomain.CurrentDomain.BaseDirectory + "\\Controls");
     this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
     this.Left    = 0;
     this.Top     = 0;
     this.Topmost = true;
 }
예제 #3
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (OnConfirmAdd != null)
     {
         CtrlListboxItem item = lst_ctrls.SelectedItem as CtrlListboxItem;
         if (item == null)
         {
             return;
         }
         JWCControl jc = JWCControlFactory.CreateInstance(item.FullName);
         jc.IsEditMode = true;
         jc.Init(true);
         OnConfirmAdd(jc);
     }
 }
예제 #4
0
        public void LoadFile(string fname)
        {
            JWCSerializer <JWCSaveFile> jse = new JWCSerializer <JWCSaveFile>();
            JWCSaveFile file = jse.Deserialize(fname);

            stage.ClearAll(file.Width, file.Height);

            foreach (var s in file.AllControls)
            {
                string     fullname = s["FullName"].ToString();
                JWCControl jc       = JWCControlFactory.CreateInstance(fullname);
                jc.InputProperty(s);
                jc.IsEditMode = true;
                jc.Init(true);
                stage.AddControl(jc);
            }
            Color cl = Color.FromArgb(file.BackColor[0], file.BackColor[1], file.BackColor[2], file.BackColor[3]);

            stage.SetBg(file.BgUsePic, cl, file.BackGroundPic);
            commu    = file.Communicator;
            adapter  = file.ComAdapter;
            ComFname = file.ComName;
            AdaFname = file.AdaName;
        }
예제 #5
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();
        }
예제 #6
0
 private void JWCCMainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     JWCControlFactory.LoadLibs(AppDomain.CurrentDomain.BaseDirectory + "\\Controls");
     JWCCommunicationLib.JWCCommunicatorFactory.LoadLibs(AppDomain.CurrentDomain.BaseDirectory + "\\Communicators");
 }
예제 #7
0
        private void ColorButton_Click(object sender, RoutedEventArgs e)
        {
            //setline1 = ((SolidColorBrush)((Rectangle)(sender as RadioButton).Content).Fill).Color;//要获得所选方块的颜色,需要将SolidColorBrush取Color
            if ((sender as RadioButton).Tag.ToString() == "1")
            {
                XXControl xx = new XXControl();
                xx.Margin = new Thickness(0, 0, 0, 0);
                xx.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                xx.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                xx.ShowPic             = true;
                xx.Width      = 350;
                xx.Height     = 350;
                xx.IsEditMode = true;
                xx.ZIndex     = 6;
                xx.Name       = "WC1";
                stage.AddControl(xx);
            }
            else if ((sender as RadioButton).Tag.ToString() == "2")
            {
                XXControl xx = new XXControl();
                xx.Margin = new Thickness(0, 0, 0, 0);
                xx.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                xx.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                xx.ShowPic             = true;
                xx.Width      = 150;
                xx.Height     = 150;
                xx.IsEditMode = true;
                xx.ZIndex     = 15;

                tempxx = xx;
            }
            else if ((sender as RadioButton).Tag.ToString() == "3")
            {
                XXControl xx = new XXControl();
                xx.ShowPic   = false;
                xx.ZIndex    = 33;
                xx.ForeColor = Colors.Pink;
                JControlOutputData dic = xx.OutputProperty();
                MessageBox.Show(dic["ForeColor"].ToString());

                JWCSerializer <JControlOutputData> ss = new JWCSerializer <JControlOutputData>();
                tempdata = ss.Serialize(dic);
            }
            else if ((sender as RadioButton).Tag.ToString() == "4")
            {
                JWCSerializer <JControlOutputData> ss = new JWCSerializer <JControlOutputData>();
                JControlOutputData oo = ss.Deserialize(tempdata);
                XXControl          xx = new XXControl();
                xx.InputProperty(oo);
                MessageBox.Show(xx.ForeColor.ToString());
                xx.Margin = new Thickness(0, 0, 0, 0);
                xx.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                xx.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                xx.Width      = 150;
                xx.Height     = 150;
                xx.IsEditMode = true;
                stage.AddControl(xx);
            }
            else if ((sender as RadioButton).Tag.ToString() == "5")
            {
                JWCControl xx = JWCControlFactory.CreateInstance("NanjingControls.DunWei");
                xx.Parent = grid_main;
                xx.Margin = new Thickness(0, 0, 0, 0);
                xx.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                xx.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                //xx.ShowPic = true;
                //xx.Width = 350;
                //xx.Height = 350;
                xx.IsEditMode = true;
                xx.ZIndex     = 6;
                stage.AddControl(xx);
            }
            else if ((sender as RadioButton).Tag.ToString() == "6")
            {
            }
        }