Ejemplo n.º 1
0
        public bool SaveLayoutToXml()
        {
            String realPath = UIProject.Instance().GetRealFile(this.renderBase1.panelPath);

            if (File.Exists(realPath))
            {
                this.renderBase1.saveLayoutToXml(realPath);
                return(true);
            }
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.FilterIndex = 1;
            dialog.Filter      = "xml文件(*.xml)|*.xml";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }
            realPath = dialog.FileName;
            if (UIProject.Instance().FileInProject(realPath))
            {
                this.renderBase1.saveLayoutToXml(realPath);
                EventManager.RaiserEvent(Constant.ResourceChange, this, null);
                return(true);
            }
            MessageBox.Show("请选择项目底下的文件");
            return(false);
        }
Ejemplo n.º 2
0
        public static Image FromFileInc(String path)
        {
            String relativePath = UIProject.Instance().GetRelativePath(path);
            Image  image        = null;

            if (imageFactory.ContainsKey(relativePath))
            {
                ImageInner inner = imageFactory[relativePath];
                inner.count++;
                image = inner.image;
            }
            else
            {
                try
                {
                    image = Image.FromFile(UIProject.Instance().GetRealFile(path));
                }
                catch
                {
                    image = null;
                }
                if (image != null)
                {
                    imageFactory.Add(relativePath, new ImageInner(image, 1, relativePath));
                }
            }
            return(image);
        }
Ejemplo n.º 3
0
        public void SetScenePath(String path)
        {
            this.renderBase1.SetScenePath(path);
            this.Text    = "Name:" + this.renderBase1.panelPath;
            this.TabText = this.renderBase1.panelPath;
            String absPath = UIProject.Instance().GetRealFile(path);
            String content = FileHelper.GetFullContent(absPath);

            SetSceneByContent(content);
        }
Ejemplo n.º 4
0
        public VMAgenda(Agenda model)
        {
            _project                   = new UIProject();
            _agenda                    = model;
            InsertPersonDialog         = new VMInsertPerson(this);
            InsertPersonDialog.Visible = Visibility.Collapsed;


            _personsLists = new MirrorList <VMPerson, Person>(_agenda.Persons, this);
            _personsLists.SubmitUndoItem +=
                new SubmitUndoItemCollectionChanged(ComandoComponentChanged);
        }
Ejemplo n.º 5
0
        private void menuItemNew_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            folderBrowserDialog.Description = "请选择文件路径";
            DialogResult result = folderBrowserDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                UIProject.Instance().openProjectPath(folderBrowserDialog.SelectedPath);
            }
        }
Ejemplo n.º 6
0
        private IDockContent GetContentFromPersistString(string persistString)
        {
            if (persistString == typeof(ObjectDock).ToString())
            {
                return(m_objectDock);
            }
            else if (persistString == typeof(ResourceDock).ToString())
            {
                return(m_resourceDock);
            }
            else if (persistString == typeof(PropDock).ToString())
            {
                return(m_propDock);
            }
            else if (persistString == typeof(ImagePreViewDock).ToString())
            {
                return(m_imagePreViewDock);
            }
            else if (persistString == typeof(AnimateDock).ToString())
            {
                return(m_animateDock);
            }
            else
            {
                // DummyDoc overrides GetPersistString to add extra information into persistString.
                // Any DockContent may override this value to add any needed information for deserialization.

                string[] parsedStrings = persistString.Split(new char[] { ',' });
                if (parsedStrings.Length != 3)
                {
                    return(null);
                }

                if (parsedStrings[0] != typeof(RenderDock).ToString() || parsedStrings[2] == string.Empty)
                {
                    return(null);
                }
                if (!File.Exists(UIProject.Instance().GetRealFile(parsedStrings[2])))
                {
                    return(null);
                }
                RenderDock dummyDoc = FindRenderByTabText(parsedStrings[1]);
                if (dummyDoc != null)
                {
                    return(null);
                }
                dummyDoc         = new RenderDock();
                dummyDoc.TabText = parsedStrings[1];
                dummyDoc.SetScenePath(parsedStrings[2]);
                return(dummyDoc);
            }
        }
Ejemplo n.º 7
0
 public void reloadTree()
 {
     try
     {
         this.treeView1.Nodes.Clear();
         TreeNode node = new TreeNode(UIProject.Instance().projectName);
         node.SelectedImageIndex = node.ImageIndex = ImageIndexProject;
         this.treeView1.Nodes.Add(node);
         GetFiles(UIProject.Instance().getProjectPath(), node);
         node.Expand();
     }
     catch { }
 }
Ejemplo n.º 8
0
        public static void releaseImage(String path)
        {
            String relativePath = UIProject.Instance().GetRelativePath(path);

            if (imageFactory.ContainsKey(relativePath))
            {
                ImageInner inner = imageFactory[relativePath];
                if (--inner.count == 0)
                {
                    inner.image.Dispose();
                    imageFactory.Remove(relativePath);
                }
            }
        }
Ejemplo n.º 9
0
        public static void loadViewToScene(String path, RenderScene scene)
        {
            scene.removeAllChild();
            String   absPath = UIProject.Instance().GetRealFile(path);
            String   content = FileHelper.GetFullContent(absPath);
            XElement xml     = XmlHelper.Parse(content);

            if (xml == null)
            {
                return;
            }
            scene.getAttrByXml(xml);
            scene.Refresh();
        }
Ejemplo n.º 10
0
 private void Item_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.Clear(Color.Gray);
     if (drawImage == null)
     {
     }
     else
     {
         Size curSize = this.Size;
         curSize.Height -= 40;
         e.Graphics.DrawImage(drawImage, calcDrawRect(curSize, drawImage));
         Font   font    = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
         String content = String.Format("大小:{1}*{2}\r\n路径:{0}", UIProject.Instance().GetRelativePath(this.drawIcon), drawImage.Width, drawImage.Height);
         e.Graphics.DrawString(content, font, Brushes.Black, new Rectangle(0, curSize.Height, curSize.Width, 40));
     }
 }
Ejemplo n.º 11
0
        private void menuItemOpen_Click(object sender, System.EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            DialogResult        result = folderBrowserDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                String configFile = folderBrowserDialog.SelectedPath + "/.project";
                if (!File.Exists(configFile))
                {
                    MessageBox.Show("该项目不存在");
                    return;
                }
                UIProject.Instance().openProjectPath(folderBrowserDialog.SelectedPath);
            }
        }
Ejemplo n.º 12
0
        public MainForm()
        {
            InitializeComponent();

            CreateStandardControls();

            UIProject.Instance().openDefaultProject();

            DynamicObj.initDynamic();
            m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);

            vS2012ToolStripExtender1.DefaultRenderer = _system;
            vS2012ToolStripExtender1.VS2012Renderer  = _custom;

            EventManager.RegisterAudience(Constant.OpenLayoutEvent, new EventHandler <object>(this.OpenRender));
            EventManager.RegisterAudience(Constant.StatusInfoChange, new EventHandler <object>(this.StatusInfoChange));
            EventManager.RegisterAudience(Constant.ProjectChange, new EventHandler <object>(this.ProjectChange));
        }
Ejemplo n.º 13
0
        private void OpenRender(object sender, object e)
        {
            String path = e as String;

            if (path == null)
            {
                return;
            }
            String     panelPath = UIProject.Instance().GetRelativePath(path);
            RenderDock dock      = FindRender(panelPath);

            if (dock != null)
            {
                dock.Show();
                return;
            }
            RenderDock renderDoc = new RenderDock();

            renderDoc.SetScenePath(path);
            renderDoc.Show(dockPanel);
        }
Ejemplo n.º 14
0
        private static RenderBase generateViewByPath(String path, RenderBase parent = null)
        {
            String   absPath = UIProject.Instance().GetRealFile(path);
            String   content = FileHelper.GetFullContent(absPath);
            XElement xml     = XmlHelper.Parse(content);

            if (xml == null)
            {
                return(null);
            }
            if (parent != null && path.Length > 0 && parent.checkParentPathNest(UIProject.Instance().GetRelativePath(absPath)))
            {
                throw new NestException(UIProject.Instance().GetRelativePath(absPath));
            }
            xml.SetAttributeValue("Name", Constant.TypePanel);
            RenderBase render = generateViewByXml(xml, parent);

            if (render is TDPanel)
            {
                (render as TDPanel).panelPath = UIProject.Instance().GetRelativePath(absPath);
            }
            return(render);
        }
Ejemplo n.º 15
0
        private static RenderBase generateViewByXml(XElement xml, RenderBase parent)
        {
            if (xml == null)
            {
                return(null);
            }
            RenderBase item = null;

            String name = XmlHelper.GetString(xml, "Name");
            String path = XmlHelper.GetString(xml, "Path");

            if (name.Length > 0)
            {
                if (parent != null && path.Length > 0 && parent.checkParentPathNest(path))
                {
                    throw new NestException(UIProject.Instance().GetRelativePath(path));
                }
                item = generateItemByName(name, path, parent);
                if (item == null)
                {
                    return(item);
                }
                item.getAttrByXml(xml);
                //XElement child = xml.Element("Child");
                //if (child != null)
                //{
                //    foreach (XElement element in child.Elements("Node"))
                //    {
                //        generateViewByXml(element, item);
                //    }
                //}
                item.loadComplete();
            }

            return(item);
        }
Ejemplo n.º 16
0
 public void SetScenePath(String path)
 {
     this.panelPath          = UIProject.Instance().GetRelativePath(path);
     this.renderDock.TabText = FileHelper.GetFileName(this.panelPath);
 }
Ejemplo n.º 17
0
 // create new project and open it
 private void projectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UILogic.UIProject p = new UIProject();
     p.ShowDialog();
     this.init();
 }
Ejemplo n.º 18
0
        void propertyGrid1_DragDrop(object sender, DragEventArgs e)
        {
            ControlDDData      data             = e.Data.GetData(typeof(ControlDDData)) as ControlDDData;
            object             propertyGridView = GetPropertyGridView(this.propGrid);
            GridItemCollection allGridEntries   = GetAllGridEntries(propertyGridView);
            int        top        = GetTop(propertyGridView);
            int        itemHeight = GetCachedRowHeight(propertyGridView);
            VScrollBar scrollBar  = GetVScrollBar(propertyGridView);


            GridItem item = GetItemAtPoint(allGridEntries, top, itemHeight, scrollBar.Value, this.propGrid.PointToClient(new Point(e.X, e.Y)));

            if (item != null && item.PropertyDescriptor != null && this.propGrid.SelectedObject is CustomProperty)
            {
                Attribute attr = item.PropertyDescriptor.Attributes[typeof(ImageAttribute)];
                if (attr != null)
                {
                    item.PropertyDescriptor.SetValue((this.propGrid.SelectedObject as CustomProperty).GetPropertyOwner(null), UIProject.Instance().GetRelativePath(data.controlData as String));
                }
            }
            this.propGrid.Refresh();
        }