WorkbenchMemento(XmlElement element, IXmlConvertable defaultLayoutMemento)
            : base()
        {
            try {
                string[] boundstr = element.Attributes["bounds"].InnerText.Split(new char [] { ',' });

                bounds = new Rectangle(Int32.Parse(boundstr[0]), Int32.Parse(boundstr[1]),
                                       Int32.Parse(boundstr[2]), Int32.Parse(boundstr[3]));
            } catch {
            }

            try {
                windowstate = (Gdk.WindowState)Enum.Parse(typeof(Gdk.WindowState), element.Attributes["formwindowstate"].InnerText);
            } catch {
            }

            /*if (element.Attributes["defaultformwindowstate"] != null) {
                defaultwindowstate = (FormWindowState)Enum.Parse(typeof(FormWindowState), element.Attributes["defaultformwindowstate"].InnerText);
            }*/

            try {
                fullscreen  = Boolean.Parse(element.Attributes["fullscreen"].InnerText);
            } catch {
            }

            if (element.FirstChild is XmlElement && defaultLayoutMemento != null) {
                XmlElement e = (XmlElement) element.FirstChild;
                this.layoutMemento = (IXmlConvertable) defaultLayoutMemento.FromXmlElement (e);
            } else {
                this.layoutMemento = defaultLayoutMemento;
            }
        }
Exemple #2
0
        public void ShowView(IViewContent content)
        {
            workbench.ViewContentCollection.Add(content);

            if (propertyService.GetProperty("NetFocus.DataStructure.LoadDocumentProperties", true) && content is IMementoCapable)
            {
                try
                {
                    IXmlConvertable memento = workbench.GetStoredMemento(content);
                    if (memento != null)
                    {
                        ((IMementoCapable)content).SetMemento(memento);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Can't get/set memento : " + e.ToString());
                }
            }

            content.Control.Dock    = DockStyle.None;
            content.Control.Visible = true;
            tabControl.Visible      = true;
            tabControl.BringToFront();

            tabControl.AddViewContentToTabPage(content);

            content.CloseEvent += new EventHandler(CloseWindowEvent);

            OnActiveViewContentChanged(this, null);
        }
Exemple #3
0
        public override void Run()
        {
            Form f = (Form)WorkbenchSingleton.Workbench;

            foreach (string file in SplashScreenForm.GetRequestedFileList())
            {
                try
                {
                    IFileService fileService = (IFileService)ServiceManager.Services.GetService(typeof(IFileService));
                    fileService.OpenFile(file);
                    IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
                    if (viewContent != null)
                    {
                        viewContent.ViewSelected -= AlgorithmManager.Algorithms.ClearPadsHandler;
                        viewContent.ViewSelected += AlgorithmManager.Algorithms.ClearPadsHandler;
                        viewContent.SelectView();
                        AlgorithmManager.Algorithms.Timer.Enabled = false;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("不能打开文件: {0} 出现错误 :\n{1}", file, e.ToString());
                }
            }
            Application.Run(f);

            // 退出程序后,最后保存工作台的状态.
            PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));

            if (WorkbenchSingleton.Workbench is IMementoCapable)
            {
                IXmlConvertable workbenchStatus = ((IMementoCapable)WorkbenchSingleton.Workbench).CreateMemento();
                propertyService.SetProperty(workbenchMemento, workbenchStatus);
            }
        }
        public IXmlConvertable GetStoredMemento(IViewContent content)
        {
            if (content != null && content.ContentName != null)
            {
                PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));

                string directory = propertyService.ConfigDirectory + "temp";
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                string fileName     = content.ContentName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
                string fullFileName = directory + Path.DirectorySeparatorChar + fileName;
                // check the file name length because it could be more than the maximum length of a file name
                FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
                if (fileUtilityService.IsValidFileName(fullFileName) && File.Exists(fullFileName))
                {
                    IXmlConvertable prototype = ((IMementoCapable)content).CreateMemento();
                    XmlDocument     doc       = new XmlDocument();
                    doc.Load(fullFileName);

                    return((IXmlConvertable)prototype.FromXmlElement((XmlElement)doc.DocumentElement.ChildNodes[0]));
                }
            }
            return(null);
        }
Exemple #5
0
 public PropertyNode(string name, string type, IXmlConvertable value)
 {
     this.Name                 = name;
     this.Type                 = type;
     this.ValueOrReference     = value;
     this.AdditionalAttributes = new List <XAttribute>();
 }
 public PropertyNode(string name, string type, IXmlConvertable value)
 {
     this.Name = name;
     this.Type = type;
     this.ValueOrReference = value;
     this.AdditionalAttributes = new List<XAttribute>();
 }
Exemple #7
0
        public void SetMemento(IXmlConvertable memento)
        {
            IProperties properties = (IProperties)memento;

            string[] bookMarks = properties.GetProperty("Bookmarks").ToString().Split(',');
            foreach (string mark in bookMarks)
            {
                if (mark != null && mark.Length > 0)
                {
                    textEditorControl.Document.BookmarkManager.Marks.Add(Int32.Parse(mark));
                }
            }

            textEditorControl.ActiveTextAreaControl.Caret.Position = ((TextEditorControl)this.Control).Document.OffsetToPosition(Math.Min(((TextEditorControl)this.Control).Document.TextLength, Math.Max(0, properties.GetProperty("CaretOffset", ((TextEditorControl)this.Control).ActiveTextAreaControl.Caret.Offset))));

            if (((TextEditorControl)this.Control).Document.HighlightingStrategy.Name != properties.GetProperty("HighlightingLanguage", ((TextEditorControl)this.Control).Document.HighlightingStrategy.Name))
            {
                IHighlightingStrategy highlightingStrategy = HighlightingManager.Manager.FindHighlighterByName(properties.GetProperty("HighlightingLanguage", ((TextEditorControl)this.Control).Document.HighlightingStrategy.Name));
                if (highlightingStrategy != null)
                {
                    textEditorControl.Document.HighlightingStrategy = highlightingStrategy;
                }
            }
            textEditorControl.ActiveTextAreaControl.TextArea.TextViewMargin.FirstVisibleLine = properties.GetProperty("VisibleLine", 0);

            textEditorControl.Document.FoldingManager.DeserializeFromString(properties.GetProperty("Foldings", ""));
        }
        public void SetMemento(IXmlConvertable xmlMemento)
        {
            if (xmlMemento != null)
            {
                WorkbenchMemento memento = (WorkbenchMemento)xmlMemento;

                Bounds             = normalBounds = memento.Bounds;
                WindowState        = memento.WindowState;
                defaultWindowState = memento.DefaultWindowState;
                FullScreen         = memento.FullScreen;
            }
        }
        public override void Run()
        {
            IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent;

            if (content != null && content.ContentName != null)
            {
                IXmlConvertable memento = null;
                if (content is IMementoCapable)
                {
                    memento = ((IMementoCapable)content).CreateMemento();
                }
                content.LoadFile(content.ContentName);

                if (memento != null)
                {
                    ((IMementoCapable)content).SetMemento(memento);
                }
            }
        }
        public void StoreMemento(IViewContent content)
        {
            if (content.ContentName == null)
            {
                return;
            }
            PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
            string          directory       = propertyService.ConfigDirectory + "temp";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<?xml version=\"1.0\"?>\n<Mementoable/>");

            XmlAttribute fileAttribute = doc.CreateAttribute("file");

            fileAttribute.InnerText = content.ContentName;
            doc.DocumentElement.Attributes.Append(fileAttribute);


            IXmlConvertable memento = ((IMementoCapable)content).CreateMemento();

            doc.DocumentElement.AppendChild(memento.ToXmlElement(doc));

            string             fileName           = content.ContentName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
            FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
            // check the file name length because it could be more than the maximum length of a file name
            string fullFileName = directory + Path.DirectorySeparatorChar + fileName;

            if (fileUtilityService.IsValidFileName(fullFileName))
            {
                fileUtilityService.ObservedSave(new NamedFileOperationDelegate(doc.Save), fullFileName, FileErrorPolicy.ProvideAlternative);
            }
        }
 public void SetMemento(IXmlConvertable memento)
 {
     ((TreeViewPadMemento)memento).Restore (this);
 }
		public void SetMemento(IXmlConvertable memento)
		{
			IProperties properties = (IProperties)memento;
			string[] bookMarks = properties.GetProperty("Bookmarks").ToString().Split(',');
			foreach (string mark in bookMarks) 
			{
				if (mark != null && mark.Length > 0) 
				{
					textEditorControl.Document.BookmarkManager.Marks.Add(Int32.Parse(mark));
				}
			}
			
			textEditorControl.ActiveTextAreaControl.Caret.Position =  ((TextEditorControl)this.Control).Document.OffsetToPosition(Math.Min(((TextEditorControl)this.Control).Document.TextLength, Math.Max(0, properties.GetProperty("CaretOffset", ((TextEditorControl)this.Control).ActiveTextAreaControl.Caret.Offset))));

			if (((TextEditorControl)this.Control).Document.HighlightingStrategy.Name != properties.GetProperty("HighlightingLanguage", ((TextEditorControl)this.Control).Document.HighlightingStrategy.Name)) 
			{
				IHighlightingStrategy highlightingStrategy = HighlightingManager.Manager.FindHighlighterByName(properties.GetProperty("HighlightingLanguage", ((TextEditorControl)this.Control).Document.HighlightingStrategy.Name));
				if (highlightingStrategy != null) 
				{
					textEditorControl.Document.HighlightingStrategy = highlightingStrategy;
				}
			}
			textEditorControl.ActiveTextAreaControl.TextArea.TextViewMargin.FirstVisibleLine = properties.GetProperty("VisibleLine", 0);
			
			textEditorControl.Document.FoldingManager.DeserializeFromString(properties.GetProperty("Foldings", ""));

		}
Exemple #13
0
        public static object ChangeType(XmlSchemaType xmlType, object value, SequenceType type,
                                        XmlNameTable nameTable, XmlNamespaceManager nsmgr)
        {
            if (type.TypeCode == XmlTypeCode.AnyAtomicType || xmlType.TypeCode == type.TypeCode)
            {
                return(value);
            }
            try
            {
                switch (xmlType.TypeCode)
                {
                case XmlTypeCode.String:
                case XmlTypeCode.UntypedAtomic:
                    switch (type.TypeCode)
                    {
                    case XmlTypeCode.UntypedAtomic:
                        return(new UntypedAtomic(value.ToString()));

                    case XmlTypeCode.String:
                        return(value.ToString());

                    case XmlTypeCode.DateTime:
                        return(DateTimeValue.Parse(value.ToString()));

                    case XmlTypeCode.Date:
                        return(DateValue.Parse(value.ToString()));

                    case XmlTypeCode.Time:
                        return(TimeValue.Parse(value.ToString()));

                    case XmlTypeCode.GYearMonth:
                        return(GYearMonthValue.Parse(value.ToString()));

                    case XmlTypeCode.GYear:
                        return(GYearValue.Parse(value.ToString()));

                    case XmlTypeCode.GMonth:
                        return(GMonthValue.Parse(value.ToString()));

                    case XmlTypeCode.GMonthDay:
                        return(GMonthDayValue.Parse(value.ToString()));

                    case XmlTypeCode.GDay:
                        return(GDayValue.Parse(value.ToString()));

                    case XmlTypeCode.Duration:
                        return(DurationValue.Parse(value.ToString()));

                    case XmlTypeCode.QName:
                        if (xmlType.TypeCode == XmlTypeCode.UntypedAtomic)
                        {
                            throw new XPath2Exception("XPTY0004", Properties.Resources.XPTY0004,
                                                      new SequenceType(xmlType, XmlTypeCardinality.One, null), type);
                        }
                        return(QNameValue.Parse(value.ToString(), nsmgr));

                    case XmlTypeCode.Notation:
                        return(NotationValue.Parse(value.ToString(), nsmgr));

                    case XmlTypeCode.AnyUri:
                        return(new AnyUriValue(value.ToString()));

                    default:
                    {
                        string text = value.ToString();
                        object res  = type.SchemaType.Datatype.ParseValue(text, nameTable, nsmgr);
                        switch (type.TypeCode)
                        {
                        case XmlTypeCode.Integer:
                        case XmlTypeCode.PositiveInteger:
                        case XmlTypeCode.NegativeInteger:
                        case XmlTypeCode.NonPositiveInteger:
                        case XmlTypeCode.NonNegativeInteger:
                            return((Integer)Convert.ToDecimal(res));

                        case XmlTypeCode.DayTimeDuration:
                            return(new DayTimeDurationValue((TimeSpan)res));

                        case XmlTypeCode.YearMonthDuration:
                            return(new YearMonthDurationValue((TimeSpan)res));

                        case XmlTypeCode.HexBinary:
                            return(new HexBinaryValue((byte[])res));

                        case XmlTypeCode.Base64Binary:
                            if (text.EndsWith("==") && (text.Length < 3 || "AQgw".IndexOf(text[text.Length - 3]) == -1))
                            {
                                throw new XPath2Exception("FORG0001", Properties.Resources.FORG0001, value);
                            }
                            return(new Base64BinaryValue((byte[])res));

                        case XmlTypeCode.Idref:
                            if (type.SchemaType == SequenceType.XmlSchema.IDREFS)
                            {
                                return(new IDREFSValue((string[])res));
                            }
                            goto default;

                        case XmlTypeCode.NmToken:
                            if (type.SchemaType == SequenceType.XmlSchema.NMTOKENS)
                            {
                                return(new NMTOKENSValue((string[])res));
                            }
                            goto default;

                        case XmlTypeCode.Entity:
                            if (type.SchemaType == SequenceType.XmlSchema.ENTITIES)
                            {
                                return(new ENTITIESValue((string[])res));
                            }
                            goto default;

                        default:
                            return(res);
                        }
                    }
                    }

                case XmlTypeCode.Boolean:
                    switch (type.TypeCode)
                    {
                    case XmlTypeCode.Decimal:
                    case XmlTypeCode.Float:
                    case XmlTypeCode.Double:
                    case XmlTypeCode.Integer:
                    case XmlTypeCode.NonPositiveInteger:
                    case XmlTypeCode.NegativeInteger:
                    case XmlTypeCode.Long:
                    case XmlTypeCode.Int:
                    case XmlTypeCode.Short:
                    case XmlTypeCode.Byte:
                    case XmlTypeCode.NonNegativeInteger:
                    case XmlTypeCode.UnsignedLong:
                    case XmlTypeCode.UnsignedInt:
                    case XmlTypeCode.UnsignedShort:
                    case XmlTypeCode.UnsignedByte:
                    case XmlTypeCode.PositiveInteger:
                        return(ChangeType(value, type.ItemType));

                    case XmlTypeCode.String:
                        return(XPath2Convert.ToString((bool)value));

                    case XmlTypeCode.UntypedAtomic:
                        return(new UntypedAtomic(XPath2Convert.ToString((bool)value)));
                    }
                    break;

                case XmlTypeCode.Integer:
                case XmlTypeCode.NonPositiveInteger:
                case XmlTypeCode.NegativeInteger:
                case XmlTypeCode.Long:
                case XmlTypeCode.Int:
                case XmlTypeCode.Short:
                case XmlTypeCode.Byte:
                case XmlTypeCode.NonNegativeInteger:
                case XmlTypeCode.UnsignedLong:
                case XmlTypeCode.UnsignedInt:
                case XmlTypeCode.UnsignedShort:
                case XmlTypeCode.UnsignedByte:
                case XmlTypeCode.PositiveInteger:
                case XmlTypeCode.Decimal:
                case XmlTypeCode.Float:
                case XmlTypeCode.Double:
                    switch (type.TypeCode)
                    {
                    case XmlTypeCode.String:
                        return(ToString(value));

                    case XmlTypeCode.UntypedAtomic:
                        return(new UntypedAtomic(ToString(value)));

                    case XmlTypeCode.Boolean:
                        return(CoreFuncs.BooleanValue(value));

                    case XmlTypeCode.AnyUri:
                        throw new XPath2Exception("XPTY0004", Properties.Resources.XPTY0004,
                                                  new SequenceType(xmlType, XmlTypeCardinality.One, null), type);

                    default:
                        return(ChangeType(value, type.ItemType));
                    }

                default:
                {
                    IXmlConvertable convert = value as IXmlConvertable;
                    if (convert != null)
                    {
                        return(convert.ValueAs(type, nsmgr));
                    }
                    if (type.TypeCode == XmlTypeCode.String)
                    {
                        return(ToString(value));
                    }
                    if (type.TypeCode == XmlTypeCode.UntypedAtomic)
                    {
                        return(new UntypedAtomic(ToString(value)));
                    }
                    return(type.SchemaType.Datatype.ChangeType(value, type.ValueType));
                }
                }
            }
            catch (XmlSchemaException ex)
            {
                throw new XPath2Exception(ex.Message, ex);
            }
            catch (InvalidCastException)
            {
                throw new XPath2Exception("XPTY0004", Properties.Resources.XPTY0004,
                                          new SequenceType(xmlType, XmlTypeCardinality.One, null), type);
            }
            catch (FormatException)
            {
                throw new XPath2Exception("XPTY0004", Properties.Resources.XPTY0004,
                                          new SequenceType(xmlType, XmlTypeCardinality.One, null), type);
            }
            throw new XPath2Exception("XPTY0004", Properties.Resources.XPTY0004,
                                      new SequenceType(xmlType, XmlTypeCardinality.One, null), type);
        }
        public void SetMemento(IXmlConvertable xmlMemento)
        {
            if (xmlMemento != null) {
                WorkbenchMemento memento = (WorkbenchMemento)xmlMemento;

                normalBounds = memento.Bounds;
                Move (normalBounds.X, normalBounds.Y);
                Resize (normalBounds.Width, normalBounds.Height);
                if (memento.WindowState == Gdk.WindowState.Maximized) {
                    Maximize ();
                } else if (memento.WindowState == Gdk.WindowState.Iconified) {
                    Iconify ();
                }
                //GdkWindow.State = memento.WindowState;
                FullScreen = memento.FullScreen;

                if (layout != null && memento.LayoutMemento != null)
                    layout.SetMemento (memento.LayoutMemento);
            }
            Decorated = true;
        }
		public void SetMemento(IXmlConvertable xmlMemento)
		{
			if (xmlMemento != null) 
			{
				WorkbenchMemento memento = (WorkbenchMemento)xmlMemento;
				
				Bounds      = normalBounds = memento.Bounds;
				WindowState = memento.WindowState;
				defaultWindowState = memento.DefaultWindowState;
				FullScreen  = memento.FullScreen;
			}
		}
 public void SetMemento(IXmlConvertable memento)
 {
     initialized = true;
     SdiWorkbenchLayoutMemento m = (SdiWorkbenchLayoutMemento) memento;
     toolbarFrame.SetStatus (m.Status);
 }
 public void SetMemento(IXmlConvertable memento)
 {
     //			IProperties properties = (IProperties)memento;
     //			BookmarkManagerMemento bookmarkMemento = (BookmarkManagerMemento)properties.GetProperty("Bookmarks", textAreaControl.Document.BookmarkManager.CreateMemento());
     //			bookmarkMemento.CheckMemento(textAreaControl.Document);
     //			textAreaControl.Document.BookmarkManager.SetMemento(bookmarkMemento);
     //			textAreaControl.Document.Caret.Offset = Math.Min(textAreaControl.Document.TextLength, Math.Max(0, properties.GetProperty("CaretOffset", textAreaControl.Document.Caret.Offset)));
     //			textAreaControl.Document.SetDesiredColumn();
     //			textAreaControl.FirstVisibleColumn    = Math.Min(textAreaControl.Document.TotalNumberOfLines, Math.Max(0, properties.GetProperty("VisibleLine", textAreaControl.FirstVisibleColumn)));
     //			textAreaControl.FirstVisibleRow       = Math.Max(0, properties.GetProperty("VisibleColumn", textAreaControl.FirstVisibleRow));
     ////			textAreaControl.Document.Properties   = (IProperties)properties.GetProperty("Properties",    textAreaControl.Properties);
     //			IHighlightingStrategy highlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(properties.GetProperty("HighlightingLanguage", textAreaControl.Document.HighlightingStrategy.Name));
     //
     //			if (highlightingStrategy != null) {
     //				textAreaControl.Document.HighlightingStrategy = highlightingStrategy;
     //			}
     //
     //			// insane check for cursor position, may be required for document reload.
     //			int lineNr = textAreaControl.Document.GetLineNumberForOffset(textAreaControl.Document.Caret.Offset);
     //			LineSegment lineSegment = textAreaControl.Document.GetLineSegment(lineNr);
     //			textAreaControl.Document.Caret.Offset = Math.Min(lineSegment.Offset + lineSegment.Length, textAreaControl.Document.Caret.Offset);
     //
     //			textAreaControl.OptionsChanged();
     //			textAreaControl.Refresh();
 }