Exemple #1
0
 void LoadTest(string fileName)
 {
     try
     {
         DesignControl.Lock(true);
         Program.Test.Pages = new List <Page>();
         DesignControl.InitializeTest();
         using (var fs = new FileStream(fileName, FileMode.Open))
         {
             using (var archive = new GZipStream(fs, CompressionMode.Decompress))
             {
                 var xmlSerial = new XmlSerializer(typeof(Test));
                 Program.Test = (Test)xmlSerial.Deserialize(archive);
             }
         }
         Program.Test.Deserialize(DesignControl);
         openFileName = fileName;
         Setup();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error trying to open " + fileName + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         DesignControl.Lock(false);
         DesignControl.PropertyFocus(Program.Test);
     }
 }
        /// <summary>
        /// Can the client do the command?</summary>
        /// <param name="commandTag">Command</param>
        /// <returns>True iff client can do the command</returns>
        public bool CanDoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return(false);
            }

            DesignControl activeControl = m_renderView.ViewControl;

            if (activeControl == null)
            {
                return(false);
            }

            switch ((Command)commandTag)
            {
            case Command.Fit:
            case Command.RenderSmooth:
            case Command.RenderWireFrame:
            case Command.RenderOutlined:
            case Command.RenderLight:
            case Command.RenderBackFace:
            case Command.RenderCycle:
                return(true);

            case Command.RenderTextured:
                return((activeControl.RenderState.RenderMode & RenderMode.Smooth) != 0);
            }

            return(false);
        }
Exemple #3
0
 private void init()
 {
     design = new DesignControl((ScrollableControl)this);
     design.IsShowPropertyForm = false;
     design.IsDrawGrid         = false;
     design.IsShowTip          = false;
 }
        private void frmElementTemplate_Load(object sender, EventArgs e)
        {
            _dcInstance = _eleType.Assembly.CreateInstance(_eleType.FullName) as DesignControl;

            panel1.Controls.Add(_dcInstance);


            _dcInstance.Dock = DockStyle.Fill;
            _dcInstance.Init(_winKey, _dbHelper, _dataCenter, _stationInfo, _loginUser, _pars, _sysLog);


            listView1.Clear();

            _templateDir = Dir.GetAppTemplateDir() + @"\" + _originalName;

            if (Directory.Exists(_templateDir))
            {
                string[] files = Directory.GetFiles(_templateDir);

                foreach (string file in files)
                {
                    FileInfo fi = new FileInfo(file);

                    listView1.Items.Add(fi.Name);
                }
            }
        }
Exemple #5
0
 private void NewTest()
 {
     openFileName = "";
     Program.Test = new Test();
     Program.Test.Pages.Add(new Page(Program.Test));
     DesignControl.InitializeTest();
     Setup();
 }
Exemple #6
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (listView1.SelectedItems.Count <= 0)
                {
                    propertyGrid1.SelectedObject = null;
                    return;
                }

                ClearSelectionElements();

                DesignControlInstanceInfo dci = listView1.SelectedItems[0].Tag as DesignControlInstanceInfo;

                TypeDescriptor.AddAttributes(dci, new Attribute[] { new ReadOnlyAttribute(true) });
                propertyGrid1.SelectedObject = dci;

                if (dci.Instance != null)
                {
                    DesignComponent dcmpt = dci.Instance as DesignComponent;

                    if (dcmpt != null)
                    {
                        //后台组件
                        ListViewItem[] lviComponents = _bizMain.listView1.Items.Find(dci.ModuleName, false);
                        if (lviComponents.Length > 0)
                        {
                            lviComponents[0].Selected = true;
                        }
                    }
                    else
                    {
                        DesignControl dc = dci.Instance as DesignControl;
                        if (dc != null)
                        {
                            LayoutControl lc = dc.Parent as LayoutControl;
                            if (lc != null)
                            {
                                LayoutControlItem lci = lc.GetItemByControl(dc);

                                if (lci != null)
                                {
                                    lc.ShowCustomizationForm();

                                    lci.Selected = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
        public string ShowTemplateImport(DesignControl element, IWin32Window owner)
        {
            //dynamic obj = type.Assembly.CreateInstance(type);
            _templateFullName = "";

            _eleType      = element.GetType();
            _originalName = element.OriginalModule;

            this.ShowDialog(owner);

            return(_templateFullName);
        }
Exemple #8
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="design">当前控件设计类</param>
        public frmProperty(DesignControl design)
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();
            this.design = design;
            this.cboControlList.Items.Clear();
//			this.cboControlList.Items.Add(Neusoft.FrameWork.WinForms.Controls.DesignControl.GetFullName(design.ContainerBox,"",this.design.ContainerBox.Name));//design.ContainerBox.Name + " " + design.ContainerBox.GetType().FullName);
            this.AddComboBoxItem(design.ContainerBox, true);

            if (this.cboControlList.Items.Count > 0)
            {
                this.cboControlList.SelectedIndex = 0;
            }

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
        /// <summary>
        /// Updates command state for given command</summary>
        /// <param name="commandTag">Command</param>
        /// <param name="state">Command state to update</param>
        public void UpdateCommand(object commandTag, Sce.Atf.Applications.CommandState state)
        {
            if (commandTag is Command)
            {
                DesignControl activeControl = m_renderView.ViewControl;
                if (activeControl == null)
                {
                    return;
                }

                switch ((Command)commandTag)
                {
                case Command.RenderSmooth:
                    state.Check = (activeControl.RenderState.RenderMode & RenderMode.Smooth) != 0;
                    break;

                case Command.RenderWireFrame:
                    state.Check = (activeControl.RenderState.RenderMode & RenderMode.Wireframe) != 0;
                    break;

                case Command.RenderOutlined:
                    state.Check = (activeControl.RenderState.RenderMode & RenderMode.Smooth) != 0 &&
                                  (activeControl.RenderState.RenderMode & RenderMode.Wireframe) != 0;
                    break;

                case Command.RenderTextured:
                    state.Check = (activeControl.RenderState.RenderMode & RenderMode.Textured) != 0;
                    break;

                case Command.RenderLight:
                    state.Check = ((activeControl.RenderState.RenderMode & RenderMode.Lit) != 0);
                    break;

                case Command.RenderBackFace:
                    state.Check = ((activeControl.RenderState.RenderMode & RenderMode.CullBackFace) == 0);
                    break;
                }
            }
        }
Exemple #10
0
 /// <summary>
 /// Construct render view</summary>
 public RenderView()
 {
     m_scene         = new Scene();
     m_designControl = new DesignControl(m_scene);
 }
Exemple #11
0
        private void BindControlData()
        {
            listView1.Items.Clear();

            foreach (DesignControlInstanceInfo dci in _dynamicControls.Values)
            {
                string category = "";

                string imgKey = dci.OriginalModule;

                ListViewItem lvi = null;
                if (dci.Instance != null)
                {
                    DesignControl dc = dci.Instance as DesignControl;

                    if (imageList1.Images.ContainsKey(imgKey) == false)
                    {
                        if (dci.ToolImg != null)
                        {
                            imageList1.Images.Add(imgKey, dci.ToolImg);
                        }
                        else
                        {
                            imageList1.Images.Add(imgKey, GetControlIcon(dc));
                        }
                    }

                    category = dc.Category;
                    if (string.IsNullOrEmpty(category))
                    {
                        if (dc as DesignComponent != null)
                        {
                            category = "后台组件";
                        }
                        else
                        {
                            category = "业务组件";
                        }
                    }

                    string visible = (dc.Visible) ? "可见" : "不可见";

                    if (dc.Parent == _bizMain)
                    {
                        if (dc as DesignComponent != null)
                        {
                            visible = "后台";
                        }
                        else
                        {
                            visible = "被遮挡";
                        }
                    }

                    lvi = new ListViewItem(new string[] { dc.Name, dc.ModuleName, dc.OriginalModule, category, "有效", visible, dci.ModuleFile });

                    lvi.Name = dc.Name;
                }
                else
                {
                    if (imageList1.Images.ContainsKey(imgKey) == false)
                    {
                        if (dci.ToolImg != null)
                        {
                            imageList1.Images.Add(imgKey, dci.ToolImg);
                        }
                        else
                        {
                            imageList1.Images.Add(dci.OriginalModule, Properties.Resources.gear);
                        }
                    }

                    category = dci.Category;
                    if (string.IsNullOrEmpty(category))
                    {
                        category = "业务组件";
                    }

                    lvi = new ListViewItem(new string[] { dci.InstanceName, dci.ModuleName, dci.OriginalModule, category, "无效", "不可见", dci.ModuleFile });

                    lvi.Name = dci.InstanceName;
                }


                lvi.ImageKey = dci.OriginalModule;
                lvi.Tag      = dci;

                listView1.Items.Add(lvi);
            }


            listView1.View = View.Details;
            labCount.Text  = "组件数量:" + listView1.Items.Count;

            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
        }
        /// <summary>
        /// Do a command</summary>
        /// <param name="commandTag">Command</param>
        public void DoCommand(object commandTag)
        {
            if (commandTag is Command)
            {
                DesignControl control = m_renderView.ViewControl;
                switch ((Command)commandTag)
                {
                case Command.Fit:
                    m_renderView.Fit();
                    break;

                case Command.RenderSmooth:
                    control.RenderState.RenderMode &= ~RenderMode.Wireframe;
                    control.RenderState.RenderMode |= (RenderMode.Smooth | RenderMode.SolidColor |
                                                       RenderMode.Lit | RenderMode.CullBackFace | RenderMode.Textured);
                    control.Invalidate();
                    break;

                case Command.RenderWireFrame:
                    control.RenderState.RenderMode |= (RenderMode.Wireframe | RenderMode.WireframeColor);
                    control.RenderState.RenderMode &= ~(RenderMode.Smooth | RenderMode.SolidColor |
                                                        RenderMode.Lit | RenderMode.Textured | RenderMode.CullBackFace);
                    control.Invalidate();
                    break;

                case Command.RenderOutlined:
                    control.RenderState.RenderMode |= (RenderMode.Wireframe | RenderMode.Smooth |
                                                       RenderMode.Lit | RenderMode.WireframeColor | RenderMode.SolidColor |
                                                       RenderMode.CullBackFace | RenderMode.Textured);
                    control.Invalidate();
                    break;

                case Command.RenderTextured:
                    control.RenderState.RenderMode ^= RenderMode.Textured;
                    control.Invalidate();
                    break;

                case Command.RenderLight:
                    control.RenderState.RenderMode ^= RenderMode.Lit;
                    control.Invalidate();
                    break;

                case Command.RenderBackFace:
                    control.RenderState.RenderMode ^= RenderMode.CullBackFace;
                    control.Invalidate();
                    break;

                case Command.RenderCycle:
                    RenderState renderState = control.RenderState;
                    if ((renderState.RenderMode & RenderMode.Smooth) != 0 &&
                        (renderState.RenderMode & RenderMode.Wireframe) != 0)
                    {
                        // outlined -> smooth
                        goto case Command.RenderSmooth;
                    }
                    else if ((renderState.RenderMode & RenderMode.Smooth) != 0)
                    {
                        // smooth -> wireframe
                        goto case Command.RenderWireFrame;
                    }
                    else
                    {
                        // wireframe -> outlined
                        goto case Command.RenderOutlined;
                    }
                }
            }
        }
Exemple #13
0
        public void ShowTemplateExport(DesignControl element, IWin32Window owner)
        {
            _exportEle = element;

            this.ShowDialog(owner);
        }