Ejemplo n.º 1
0
 public void AddControl(JWCControl ctrl)
 {
     ctrl.Parent      = grid_main;
     ctrl.OnGotFocus += xx_OnGotFocus;
     grid_main.Children.Add(ctrl);
     AllCtrls.Add(ctrl);
 }
Ejemplo n.º 2
0
        public void RefreshPropList(JWCControl ctrl)
        {
            _PropPanel.Children.Clear();
            Type tp = ctrl.GetType();
            bool cl = false;

            foreach (PropertyInfo pi in tp.GetProperties())
            {
                if (Attribute.IsDefined(pi, typeof(PropDiscribeAttribute)))
                {
                    PropDiscribeAttribute pat = pi.GetCustomAttributes(typeof(PropDiscribeAttribute), true)[0] as PropDiscribeAttribute;
                    APropItem             itm = PropItemFactory.GetPropItem(pat, ctrl, pi);
                    var  showitm = itm.GetControl();
                    Grid grd     = new Grid();
                    grd.Background = cl ? color1 : color2;
                    cl             = !cl;
                    grd.Children.Add(showitm);
                    _PropPanel.Children.Add(grd);
                    itm.TimeToShowHelpString += itm_TimeToShowHelpString;
                    if (pi.Name == "Name")
                    {
                        itm.OnPropValueChanged += itm_OnPropValueChanged;
                    }
                    else if (pi.Name == "Size")
                    {
                        this.SetSizeFun = itm.SetPropShowValue;
                    }
                    else if (pi.Name == "Margin")
                    {
                        this.SetMarginFun = itm.SetPropShowValue;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void CopySelecting()
 {
     if (_Selecting_Ctrl == null)
     {
         return;
     }
     _ClipBoard = _Selecting_Ctrl;
 }
Ejemplo n.º 4
0
 public void UnSelectControl()
 {
     if (_Selecting_Ctrl != null)
     {
         _Selecting_Ctrl.LoseFocus();
     }
     _Selecting_Ctrl = null;
     if (OnSelectionChanged != null)
     {
         OnSelectionChanged(false, grid_main);
     }
 }
Ejemplo n.º 5
0
 public void RefreshCurrName(JWCControl ctrl)
 {
     //string fn = GetJWCCFullName(ctrl);
     //string name = string.IsNullOrEmpty(ctrl.Name)?"[无名称]":ctrl.Name;
     //_Indicator.Dispatcher.Invoke(
     //    (Action)(delegate()
     //            {
     //                _Indicator.Content = string.Format("{0}({1})", name, fn);
     //            })
     //    );
     _CombInd.SelectedItem = null;
     _CombInd.SelectedItem = ctrl;
 }
Ejemplo n.º 6
0
        void itm_OnPropValueChanged(APropItem sender, IPropGWAble arg1, PropertyInfo arg2, object arg3)
        {
            JWCControl jc = arg1 as JWCControl;

            if (jc == null)
            {
                return;
            }
            if (jc.Focused)
            {
                RefreshCurrName(jc);
            }
        }
Ejemplo n.º 7
0
        private void cmb_allc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            JWCControl ctrl = cmb_allc.SelectedItem as JWCControl;

            if (ctrl == null)
            {
                return;
            }
            if (ctrl == stage.SelectedControl)
            {
                return;
            }
            ctrl.GetFocus();
        }
Ejemplo n.º 8
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);
     }
 }
Ejemplo n.º 9
0
        void xx_OnGotFocus(object obj)
        {
            if (_Selecting_Ctrl != null)
            {
                _Selecting_Ctrl.OnMovedOrResized -= _Selecting_Ctrl_OnMovedOrResized;
                _Selecting_Ctrl.LoseFocus();
            }

            _Selecting_Ctrl = obj as JWCControl;
            _Selecting_Ctrl.OnMovedOrResized += _Selecting_Ctrl_OnMovedOrResized;
            if (OnSelectionChanged != null)
            {
                OnSelectionChanged(true, obj);
            }
        }
Ejemplo n.º 10
0
 void stage_SelectionChanged(bool arg1, object arg2)
 {
     if (arg1)
     {
         JWCControl jc = arg2 as JWCControl;
         if (object.ReferenceEquals(jc, null))
         {
             return;
         }
         pm.RefreshCurrName(jc);
         pm.RefreshPropList(jc);
     }
     else
     {
         pm.RefreshStageProp(stage);
     }
 }
Ejemplo n.º 11
0
        public void PasteSelecting()
        {
            if (_ClipBoard == null)
            {
                return;
            }
            JWCControl jc = (JWCControl)Activator.CreateInstance(_ClipBoard.GetType());

            jc.InputProperty(_ClipBoard.OutputProperty());
            jc.IsEditMode = true;
            double    left = jc.Margin.Left + 20;
            double    top  = jc.Margin.Top + 20;
            Thickness th   = new Thickness((int)left, (int)top, 0, 0);

            jc.Margin = th;
            AddControl(jc);
            jc.GetFocus();
        }
Ejemplo n.º 12
0
        void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //Dispose all componet
            if (Communicator != null)
            {
                Communicator.Stop(false);
                Communicator.Dispose();
            }

            foreach (var c in grid_main.Children)
            {
                JWCControl jc = c as JWCControl;
                if (jc != null)
                {
                    jc.DeInit(false);
                }
            }
        }
Ejemplo n.º 13
0
        public void SaveFile(string fname)
        {
            List <JControlOutputData> lst = new List <JControlOutputData>();

            foreach (var c in stage.AllControls)
            {
                JWCControl jc = c as JWCControl;
                if (jc == null)
                {
                    continue;
                }
                lst.Add(jc.OutputProperty());
            }

            JWCSaveFile file = new JWCSaveFile();

            file.Width         = (int)stage.MainStage.Width;
            file.Height        = (int)stage.MainStage.Height;
            file.AllControls   = lst;
            file.BgUsePic      = stage.BgUsePic;
            file.BackGroundPic = stage.BgFilename;
            Color cl = stage.BgColor;

            file.BackColor = new byte[4] {
                cl.A, cl.R, cl.G, cl.B
            };

            file.Communicator = commu;
            file.ComAdapter   = adapter;
            file.ComName      = ComFname;
            file.AdaName      = AdaFname;

            file.Version = Assembly.GetExecutingAssembly().GetName().Version;

            JWCSerializer <JWCSaveFile> jse = new JWCSerializer <JWCSaveFile>();

            jse.Serialize(file, fname);
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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();
        }
Ejemplo n.º 16
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")
            {
            }
        }
Ejemplo n.º 17
0
        private string GetJWCCFullName(JWCControl ctrl)
        {
            Type tp = ctrl.GetType();

            return(tp.FullName);
        }
Ejemplo n.º 18
0
 public void RemoveCtonrol(JWCControl ctrl)
 {
     grid_main.Children.Remove(ctrl);
     AllCtrls.Remove(ctrl);
 }