Example #1
0
    void OpenTerms(OpenType _type, string _terms)
    {
        switch (_type)
        {
        case OpenType.Defalut:
            openTerms = null;
            break;

        case OpenType.Precedence:
            openTerms    = new int[1];
            openTerms[0] = int.Parse(_terms);
            break;

        case OpenType.Level:
            openTerms    = new int[1];
            openTerms[0] = int.Parse(_terms);
            break;

        case OpenType.Rank:
            StringSplit(ref openTerms, _terms);
            break;

        case OpenType.GetItem:
            StringSplit(ref openTerms, _terms);
            break;
        }
    }
        public Result SetOpenType(OpenType type)
        {
            Assert.SdkRequires(type == OpenType.Normal || type == OpenType.Internal);

            switch (type)
            {
            case OpenType.Normal:
                if (_isNormalStorageOpened)
                {
                    return(ResultFs.TargetLocked.Log());
                }

                _isNormalStorageOpened = true;
                return(Result.Success);

            case OpenType.Internal:
                if (_isInternalStorageOpened)
                {
                    return(ResultFs.TargetLocked.Log());
                }

                _isInternalStorageOpened      = true;
                _isInternalStorageInvalidated = false;
                return(Result.Success);

            default:
                Abort.UnexpectedDefault();
                return(Result.Success);
            }
        }
Example #3
0
        internal void openInit(OpenType type, params object[] o)
        {
            mIsRealPlane     = true;
            mInitOver        = false;
            mInitDelayAction = null;
            mMainPlane       = this.gameObject.GetComponent <FCUniversalPanel>();
            mIsClose         = false;
            mArgs            = o;
            if (type != OpenType.OT_Normal)
            {
                openPool(type, o);
            }
            else
            {
                ScriptsTime.BeginTag("_plane");
                Init(o);
                ScriptsTime._ShowTimeTag("_plane", this.GetType().Name + "打开消耗");
            }

            mInitOver = true;
            if (mInitDelayAction != null)
            {
                mInitDelayAction();
            }
        }
Example #4
0
        public void CollectionMapperCanHandleMappingArrayToArray()
        {
            OpenTypeKind mapsTo;

            Assert.IsTrue(mapper.CanHandle(typeof(int[]), out mapsTo, CanHandle));
            Assert.AreEqual(OpenTypeKind.ArrayType, mapsTo);

            OpenType mappedType = mapper.MapType(typeof(int[]), MapType);

            Assert.AreEqual(OpenTypeKind.ArrayType, mappedType.Kind);

            ArrayType arrayType = (ArrayType)mappedType;

            Assert.AreEqual(1, arrayType.Dimension);
            Assert.AreEqual(SimpleType.Integer, arrayType.ElementType);

            int[] value = new int[] { 1, 2, 3 };

            object mappedValue = mapper.MapValue(typeof(int[]), mappedType, value, MapValue);

            Assert.IsTrue(mappedValue is int[]);
            int[] array = (int[])mappedValue;
            Assert.AreEqual(3, array.Length);
            Assert.AreEqual(1, array[0]);
            Assert.AreEqual(2, array[1]);
            Assert.AreEqual(3, array[2]);
        }
Example #5
0
        public void CollectionMapperCanHandleMappingCollectionToArray()
        {
            OpenType mappedType = mapper.MapType(typeof(IEnumerable <int>), MapType);

            Assert.AreEqual(OpenTypeKind.ArrayType, mappedType.Kind);

            ArrayType arrayType = (ArrayType)mappedType;

            Assert.AreEqual(1, arrayType.Dimension);
            Assert.AreEqual(SimpleType.Integer, arrayType.ElementType);

            List <int> value = new List <int>();

            value.Add(1);
            value.Add(2);
            value.Add(3);

            object mappedValue = mapper.MapValue(typeof(IEnumerable <int>), mappedType, value, MapValue);

            Assert.IsTrue(mappedValue is int[]);
            int[] array = (int[])mappedValue;
            Assert.AreEqual(3, array.Length);
            Assert.AreEqual(1, array[0]);
            Assert.AreEqual(2, array[1]);
            Assert.AreEqual(3, array[2]);
        }
Example #6
0
 public MoneyEdit(ConnectionSettings connectionSettings, OpenType type, int id = 0)
 {
     _connectionSettings = connectionSettings;
     this.type           = type;
     InitializeComponent();
     if (type == OpenType.View)
     {
         Save.Visibility         = Visibility.Hidden;
         ID.IsReadOnly           = true;
         DateVal.IsEnabled       = false;
         SummVal.IsReadOnly      = true;
         SummValPayed.IsReadOnly = true;
     }
     else
     {
         Save.Visibility         = Visibility.Visible;
         ID.IsReadOnly           = true;
         DateVal.IsEnabled       = true;
         SummVal.IsReadOnly      = false;
         SummValPayed.IsReadOnly = true;
     }
     if (type != OpenType.New)
     {
         FillData(id);
     }
 }
Example #7
0
        protected DataFile_Base(NiceSystemInfo niceSystem, OpenType openType)
        {
            this.niceSystem = niceSystem;
            switch (openType)
            {
            case OpenType.ForUpdate_CreateIfNotThere:
                _forUpdate = true;
                _stream    = AnyServerFile.GetForUpdate_CreateIfNeeded(GetFullPath(), this);
                break;

            case OpenType.ReadOnly_CreateIfNotThere:
                _forUpdate = false;
                _stream    = AnyServerFile.GetForReadOnly(GetFullPath());
                if (_stream == null)
                {
                    _forUpdate = true;
                    _stream    = AnyServerFile.GetForUpdate_CreateIfNeeded(GetFullPath(), this);
                }
                else
                {
                    NetFrom(new BinaryReader(_stream));
                }
                break;
            }
        }
Example #8
0
 public static object FormatValue(OpenType openType, object value)
 {
     if (openType.Kind == OpenTypeKind.SimpleType)
     {
         return(FormatSimpleValue(openType, value));
     }
     if (openType.Kind == OpenTypeKind.TabularType)
     {
         var tabularValue = (ITabularData)value;
         var tabularType  = (TabularType)openType;
         return(tabularValue.Values.Select(x => FormatCompositeValue(tabularType.RowType, x)).ToArray());
     }
     if (openType.Kind == OpenTypeKind.CompositeType)
     {
         var compositeValue = (ICompositeData)value;
         var compositeType  = (CompositeType)openType;
         return(FormatCompositeValue(compositeType, compositeValue));
     }
     if (openType.Kind == OpenTypeKind.ArrayType)
     {
         var arrayType  = (ArrayType)openType;
         var arrayValue = (IEnumerable)value;
         return(arrayValue.Cast <object>().Select(x => FormatSimpleValue(arrayType.ElementType, x)).ToArray());
     }
     throw new NotSupportedException(string.Format("Open type kind {0} is not supported", openType.Kind));
 }
Example #9
0
    void FromIntToOpenType(int _type)
    {
        switch (_type)
        {
        case 0:
            openType = OpenType.Defalut;
            break;

        case 1:
            openType = OpenType.Precedence;
            break;

        case 2:
            openType = OpenType.Level;
            break;

        case 3:
            openType = OpenType.Rank;
            break;

        case 4:
            openType = OpenType.GetItem;
            break;

        default:
            openType = OpenType.Defalut;
            break;
        }
    }
Example #10
0
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        float height        = 0;
        var   nodePanelProp = property.FindPropertyRelative("nodePanel");

        if (nodePanelProp == null || nodePanelProp.objectReferenceValue == null)
        {
            height += EditorGUIUtility.singleLineHeight;
        }
        else
        {
            height += 2 * EditorGUIUtility.singleLineHeight;
            var obj      = new SerializedObject(nodePanelProp.objectReferenceValue);
            var typeProp = obj.FindProperty("openType");

            OpenType type = (OpenType)typeProp.intValue;

            if ((type & OpenType.ByToggle) == OpenType.ByToggle)
            {
                height += EditorGUIUtility.singleLineHeight;
            }
            if ((type & OpenType.ByButton) == OpenType.ByButton)
            {
                height += EditorGUIUtility.singleLineHeight;
            }
        }

        return(height);
    }
Example #11
0
 /// <summary>
 /// Maps value.
 /// </summary>
 /// <param name="clrType"></param>
 /// <param name="mappedType"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public object MapValue(Type clrType, OpenType mappedType, object value)
 {
     lock (_typeCache)
     {
         return(MapValueImpl(clrType, mappedType, value));
     }
 }
Example #12
0
        public frmOpenFile(string startPath = "", OpenType oType = OpenType.File, bool MultiFileSelect = false)
        {
            log = new Logger(LoggerType.Console_File, "THANOS.frmOpenFile");

            openType       = oType;
            startupPath    = startPath;
            useMultiSelect = MultiFileSelect;

            InitializeComponent();

            switch (oType)
            {
            case OpenType.File:
                Size              = new Size(/*637; 416*/ 637, 416);
                Text              = "Open File";
                btnDrive.Enabled  = false;
                btnSelDir.Enabled = false;
                break;

            case OpenType.Folder:
                Size             = new Size(/*637; 416*/ 343, 416);
                Text             = "Open Folder";
                btnDrive.Enabled = false;
                break;

            case OpenType.Drive:
                Size = new Size(/*637; 416*/ 115, 416);
                Text = "";
                break;
            }
        }
 private void AddType(OpenType type, Action <Type> funcAddType)
 {
     if (type is OpenType.ExactMatch x)
     {
         funcAddType(x.ExactType);
     }
 }
Example #14
0
        private void Open(double price, double qty, OpenType ot, SecurityInfo si, TickData td, string tr)
        {
            PolicyResultEventArgs arg = new PolicyResultEventArgs();

            arg.PolicyName1 = this.policyName;
            arg.SecInfo     = si;
            arg.IsReal      = currentTick.IsReal;
            OpenPoint op = new OpenPoint();

            op.SecInfo             = si;
            op.OpenTime            = td.Time;
            op.OpenPrice           = price;
            op.OpenType            = ot;
            op.OpenQty             = qty;
            op.DealQty             = 0;
            op.Openop              = true;
            op.FirstTradePriceType = parameter.EnterOrderPriceType;
            op.CancelLimitTime     = parameter.EnterOrderWaitSecond;
            op.ReEnterPecentage    = parameter.ReEnterPercent;

            TradePoints tp = new TradePoints(op, 0);

            tp.Fee      = parameter.Fee;
            tp.TpRemark = tr;
            /////////////add//////////////////////
            tp.IsReal = arg.IsReal;
            this.tps.TryAdd(tp.TradeGuid, tp);
            arg.PairePoint   = tp;
            arg.PolicyObject = this;
            arg.Tickdata     = td;
            RaiseResult(arg);
        }
        private static MBeanParameterInfo CreateMBeanParameterInfo(ParameterInfo info)
        {
            Descriptor descriptor = new Descriptor();
            OpenType   openType   = OpenType.CreateOpenType(info.ParameterType);

            descriptor.SetField(OpenTypeDescriptor.Field, openType);
            object[] tmp = info.GetCustomAttributes(typeof(OpenMBeanAttributeAttribute), false);
            if (tmp.Length > 0)
            {
                OpenMBeanAttributeAttribute attr = (OpenMBeanAttributeAttribute)tmp[0];
                if (attr.LegalValues != null && (attr.MinValue != null || attr.MaxValue != null))
                {
                    throw new OpenDataException("Cannot specify both min/max values and legal values.");
                }
                IComparable defaultValue = (IComparable)attr.DefaultValue;
                OpenInfoUtils.ValidateDefaultValue(openType, defaultValue);
                descriptor.SetField(DefaultValueDescriptor.Field, defaultValue);
                if (attr.LegalValues != null)
                {
                    OpenInfoUtils.ValidateLegalValues(openType, attr.LegalValues);
                    descriptor.SetField(LegalValuesDescriptor.Field, attr.LegalValues);
                }
                else
                {
                    OpenInfoUtils.ValidateMinMaxValue(openType, defaultValue, attr.MinValue, attr.MaxValue);
                    descriptor.SetField(MinValueDescriptor.Field, attr.MinValue);
                    descriptor.SetField(MaxValueDescriptor.Field, attr.MaxValue);
                }
            }
            return(new MBeanParameterInfo(info.Name,
                                          InfoUtils.GetDescrition(info.Member, info, "MBean operation parameter", info.Name),
                                          openType.Representation.AssemblyQualifiedName, descriptor));
        }
Example #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="prp"></param>
 /// <param name="type"></param>
 /// <param name="character"></param>
 /// <param name="PropIndex">在角色背包里面的位置</param>
 public void Open(BaseAdditionalAttribute prp, OpenType type, CharacterAttribute character, int PropIndex)
 {
     this.character = character;
     this.openType  = type;
     this.attribute = prp;
     this.PropIndex = PropIndex;
     base.Open();
 }
Example #17
0
        private static string FormatSimpleValue(OpenType openType, object value)
        {
            var typeConverter = TypeDescriptor.GetConverter(openType.Representation);

// ReSharper disable PossibleNullReferenceException
            return(typeConverter.ConvertToInvariantString(value));
// ReSharper restore PossibleNullReferenceException
        }
        /// <summary>
        /// Rule to provide an IValueBinder from a resolved attribute.
        /// IValueBinder will let you have an OnCompleted hook that is invoked after the user function completes.
        /// </summary>
        /// <typeparam name="TType">An Open Type. This rule is only applied if the parameter type matches the open type</typeparam>
        /// <param name="builder">Builder function to create a IValueBinder given a resolved attribute and the user parameter type. </param>
        /// <returns>A binding provider that applies these semantics.</returns>
        public FluentBinder BindToValueProvider <TType>(Func <TAttribute, Type, Task <IValueBinder> > builder)
        {
            var ot           = OpenType.FromType <TType>();
            var nameResolver = _nameResolver;
            var binder       = new ItemBindingProvider <TAttribute>(_configuration, nameResolver, builder, ot);

            return(Bind(binder));
        }
Example #19
0
 protected virtual object MapValue(Type clrType, OpenType mappedType, object value)
 {
     if (mappedType.Kind == OpenTypeKind.SimpleType)
      {
     return value;
      }
      return Mapper.MapValue(clrType, mappedType, value, MapValue);
 }
Example #20
0
 protected virtual object MapValue(Type clrType, OpenType mappedType, object value)
 {
     if (mappedType.Kind == OpenTypeKind.SimpleType)
     {
         return(value);
     }
     return(Mapper.MapValue(clrType, mappedType, value, MapValue));
 }
Example #21
0
    void SetShareType(ShareType nShareType, OpenType nOpenType)
    {
        if (PlayerFrameLogic.Instance() != null)
        {
            PlayerFrameLogic.Instance().PlayerFrameHeadOnClick();
        }
        ClearUp();
        m_nShareType = nShareType;
        m_nOpenType  = nOpenType;

        int JoinSet = 0, shareSet = 0;

        for (int i = 0; i < REWARD_ITEMCOUNT_MAX; i++)
        {
            Tab_ShareReward reward = TableManager.GetShareRewardByID((int)m_nShareType, 0);
            if (null == reward)
            {
                continue;
            }
            int nTargetType = reward.GetTargetTypebyIndex(i);
            int nItemID     = reward.GetItemDataIdbyIndex(i);
            if ((int)RewardTargetType.TARGETTYPE_JOIN_USER == nTargetType)
            {
                if (JoinSet < m_JoinRewardItem.Length)
                {
                    m_JoinRewardItem[JoinSet].InitItem(nItemID);
                    JoinSet++;
                }
            }
            else if ((int)RewardTargetType.TARGETTYPE_SHARE_USER == nTargetType)
            {
                if (shareSet < m_ShareRewardItem.Length)
                {
                    m_ShareRewardItem[shareSet].InitItem(nItemID);
                    shareSet++;
                }
            }
        }

        if (OpenType.OpenType_ActiviteCode == m_nOpenType)
        {
            m_ActiviteGameObject.SetActive(true);
        }
        else if (OpenType.OpenType_Share == m_nOpenType)
        {
            m_ShareGameObject.SetActive(true);
        }
        else
        {
            LogModule.ErrorLog("ShareWindow OpenType Invalid");
        }
        if (ShareType.ShareType_NanGua == m_nShareType)
        {
            m_labelDesc.text = StrDictionary.GetClientDictionaryString("#{3102}");
            UpdateRewardCount();
        }
    }
 public OpenArgs(double price, double qty, OpenType ot, SecurityInfo si, TickData td, string tr)
 {
     this.price    = price;
     this.qty      = qty;
     this.opentype = ot;
     this.si       = si;
     this.tickdata = td;
     this.tr       = tr;
 }
        /// <summary>
        /// Add a builder function that returns a converter. This can use <see cref="Microsoft.Azure.WebJobs.Host.Bindings.OpenType"/>  to match against an
        /// open set of types. The builder can then do one time static type checking and code gen caching before
        /// returning a converter function that is called on each invocation.
        /// The types passed to that converter are gauranteed to have matched against the TSource and TDestination parameters.
        /// </summary>
        /// <typeparam name="TSource">Source type. Can be a concrete type or a <see cref="OpenType"/></typeparam>
        /// <typeparam name="TDestination">Destination type. Can be a concrete type or a <see cref="OpenType"/></typeparam>
        /// <typeparam name="TAttribute">Attribute on the binding.
        /// If this is <see cref="System.Attribute"/>, then it applies to any attribute.
        /// Else it applies to the specific TAttribte.</typeparam>
        /// <param name="converterBuilder">A function that is invoked if-and-only-if there is a compatible type match for the
        /// source and destination types. It then produce a converter function that can be called many times </param>
        public void AddConverter <TSource, TDestination, TAttribute>(
            FuncConverterBuilder converterBuilder)
            where TAttribute : Attribute
        {
            var openTypeSource = OpenType.FromType <TSource>();
            var openTypeDest   = OpenType.FromType <TDestination>();

            AddOpenConverter <TAttribute>(openTypeSource, openTypeDest, converterBuilder);
        }
Example #24
0
 public QuestData()
 {
     id        = 0;
     length    = 0;
     name      = null;
     content   = null;
     openType  = OpenType.Defalut;
     clearType = ClearType.Defalut;
 }
Example #25
0
 private void Reload()
 {
     type = OpenType.Edit;
     PayList.Items.Clear();
     PayPanels      = new Dictionary <string, DockPanel>();
     Pays           = new Dictionary <string, Pay>();
     SummField.Text = "0";
     FillData(Id);
 }
Example #26
0
 protected override object MapValue(Type clrType, OpenType mappedType, object value)
 {
     if (mappedType.TypeName == "TestCollectionElement")
     {
         return(new CompositeDataSupport((CompositeType)mappedType, new string[] { "IntValue", "StringValue" },
                                         new object[] { ((TestCollectionElement)value).IntValue,
                                                        ((TestCollectionElement)value).StringValue }));
     }
     return(base.MapValue(clrType, mappedType, value));
 }
Example #27
0
        private void Open(OpenType type)
        {
            try
            {
                var config = LogManager.Configuration;
                if (config == null)
                {
                    return;
                }

                var target = config
                             .ConfiguredNamedTargets
                             .OfType <AsyncTargetWrapper>()
                             .Where(f => f.WrappedTarget is FileTarget)
                             .Select(f => f.WrappedTarget as FileTarget)
                             .FirstOrDefault();

                if (target == null)
                {
                    return;
                }

                var filename = SimpleLayout.Evaluate(target.FileName.ToString());

                if (!string.IsNullOrEmpty(filename))
                {
                    filename = filename.Replace("'", string.Empty);
                    switch (type)
                    {
                    case OpenType.LogFolder:
                        var folder = Path.GetDirectoryName(filename);
                        _logger.Info($"Opening log folder {folder}..");

                        if (folder != null)
                        {
                            Process.Start(folder);
                        }
                        return;

                    case OpenType.LogFile:
                        _logger.Info($"Opening log file {filename}..");
                        Process.Start(filename);
                        return;

                    default:
                        throw new Exception("Open Type not found");
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error($"Open command for {type} failed..");
                _logger.Error(exception.ToString());
            }
        }
 private void OpenFileDirectlyCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (this.OpenFileDirectlyCheckBox.Checked)
     {
         openType = OpenType.Directly;
     }
     else
     {
         openType = OpenType.SelectInExplorer;
     }
 }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dl = new System.Windows.Forms.FolderBrowserDialog();

            if(dl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Path = dl.SelectedPath;
                Type = OpenType.New;
                Close();
            }
        }
Example #30
0
 public OpenArgs(double price, double qty, OpenType ot, SecurityInfo si, TickData td, double zhuidan, string tr, bool beiDong = true)
 {
     this.price    = price;
     this.qty      = qty;
     this.opentype = ot;
     this.si       = si;
     this.tickdata = td;
     this.tr       = tr;
     this.zhuidan  = zhuidan;
     this.beiDong  = beiDong;
 }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dl = new System.Windows.Forms.OpenFileDialog();

            if (dl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Path = dl.FileName;
                Type = OpenType.Existing;
                Close();
            }
        }
 // Helper for enforcing  that a delegate can only handle concrete types, not open types.
 static void VerifyNotOpenTypes <T1, T2>()
 {
     if (OpenType.IsOpenType <T1>() || OpenType.IsOpenType <T2>())
     {
         throw new InvalidOperationException($"Use AddOpenConverter to add a converter for open types.");
     }
     if (typeof(T1) == typeof(T2))
     {
         throw new InvalidOperationException($"Converter source and desitnation types must be different (${typeof(T1).Name}).");
     }
 }
        public Result Initialize(ref ReferenceCountedDisposable <IFileSystem> baseFileSystem, U8Span path, OpenMode mode,
                                 OpenType type)
        {
            Result rc = Initialize(ref baseFileSystem, path, mode);

            if (rc.IsFailure())
            {
                return(rc);
            }

            return(SetOpenType(type));
        }
        public MarkdownEditor(string path, OpenType type)
        {
            if(type == OpenType.New)
            {
                Project = new Project(NewProject(path));
            }
            else
            {
                Project = new Project(path);
            }

            renderer = new Renderer();
        }
Example #35
0
 // Main Form
 public MainForm()
 {
     InitializeComponent();
     position = 0;
     word = "";
     font = new Font("Segoe UI", 18);
     buffer = new List<string>();
     //p_buffer = new List<string>();
     //pp_buffer = new List<string>();
     timer = new Timer();
     timer.Tick += new EventHandler(timer_Tick);
     timer.Enabled = false;
     rewind_timer = new Timer();
     rewind_timer.Tick += new EventHandler(rewind_timer_Tick);
     timer.Enabled = false;
     condition = Condition.EmptyFile;
     speed = 60000 / 200;
     RenderMultiColorsLabel("Welcome! :)", pictureBox_show, font);
     button_show.Enabled = false;
     //button_rewind.Enabled = false;
     opened = OpenType.None;
 }
 protected override object MapValue(Type clrType, OpenType mappedType, object value)
 {
     if (mappedType.TypeName == "TestCollectionElement")
      {
     return new CompositeDataSupport((CompositeType)mappedType, new string[] { "IntValue", "StringValue" },
                                     new object[] {((TestCollectionElement) value).IntValue,
                                     ((TestCollectionElement) value).StringValue});
      }
      return base.MapValue(clrType, mappedType, value);
 }
Example #37
0
 private RegistryKey OpenConfigKey(OpenType openType)
 {
     bool writable = openType == OpenType.Write;
     var r = Registry.CurrentUser.OpenSubKey(@"software\sinland\VkApps\SnzShop", writable) ??
             Registry.CurrentUser.CreateSubKey(@"software\sinland\VkApps\SnzShop");
     return r;
 }
Example #38
0
 // In order to Open the File with appropriate extension
 public void Open(string file_name, string file_ext)
 {
     switch (file_ext)
     {
         case ".txt":
             {
                 if (txt_sr != null)
                     txt_sr.Close();
                 txt_sr = new StreamReader(file_name, Encoding.GetEncoding(1251));
                 opened = OpenType.Txt;
                 ReadTxt();
             }
             break;
         case ".fb2":
             {
                 // some code for fb2
                 //opened = OpenType.Fb2;
                 opened = OpenType.None;
             }
             break;
         case ".epub":
             {
                 Epub epub = new Epub(file_name);
                 epub_sr = new StringReader(epub.GetContentAsPlainText());
                 opened = OpenType.Epub;
                 ReadEpub();
             }
             break;
         default:
             {
                 opened = OpenType.None;
             }
             break;
     }
 }
        public TabInfo Open(string file, OpenType type, bool addToMRU = true, bool alwaysNew = false)
        {
            if (type == OpenType.File) {
                if (!Path.IsPathRooted(file)) {
                    file = Path.GetFullPath(file);
                }
                //Add this file to the recent files list
                if (addToMRU) {
                    Settings.AddRecentFile(file);
                }
                UpdateRecentList();
                //If this is an int, decompile
                if (string.Compare(Path.GetExtension(file), ".int", true) == 0) {
                    var compiler = new Compiler();
                    string decomp = compiler.Decompile(file);
                    if (decomp == null) {
                        MessageBox.Show("Decompilation of '" + file + "' was not successful", "Error");
                        return null;
                    } else {
                        file = decomp;
                        type = OpenType.Text;
                    }
                } else {
                    //Check if the file is already open
                    for (int i = 0; i < tabs.Count; i++) {
                        if (string.Compare(tabs[i].filepath, file, true) == 0) {
                            tabControl1.SelectTab(i);
                            return tabs[i];
                        }
                    }
                }
            }
            //Create the text editor and set up the tab
            ICSharpCode.TextEditor.TextEditorControl te = new ICSharpCode.TextEditor.TextEditorControl();
            te.ShowVRuler = false;
            te.Document.FoldingManager.FoldingStrategy = new CodeFolder();
            te.IndentStyle = IndentStyle.Smart;
            te.ConvertTabsToSpaces = Settings.tabsToSpaces;
            te.TabIndent = Settings.tabSize;
            te.Document.TextEditorProperties.IndentationSize = Settings.tabSize;
            if (type == OpenType.File)
                te.LoadFile(file, false, true);
            else if (type == OpenType.Text)
                te.Text = file;
            if (type == OpenType.File && string.Compare(Path.GetExtension(file), ".msg", true) == 0)
                te.SetHighlighting("msg");
            else
                te.SetHighlighting("ssl"); // Activate the highlighting, use the name from the SyntaxDefinition node.
            te.TextChanged += textChanged;
            te.ActiveTextAreaControl.TextArea.MouseDown += delegate(object a1, MouseEventArgs a2) {
                if (a2.Button == MouseButtons.Left)
                    UpdateEditorToolStripMenu();
                lbAutocomplete.Hide();
            };
            te.ActiveTextAreaControl.TextArea.KeyPress += KeyPressed;
            te.HorizontalScroll.Visible = false;

            te.ActiveTextAreaControl.TextArea.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs a2) {
                if (lbAutocomplete.Visible) {
                    if ((a2.KeyCode == Keys.Down || a2.KeyCode == Keys.Up || a2.KeyCode == Keys.Tab)) {
                        lbAutocomplete.Focus();
                        lbAutocomplete.SelectedIndex = 0;
                    } else if (a2.KeyCode == Keys.Escape) {
                        lbAutocomplete.Hide();
                    }
                } else {
                    if (toolTipAC.Active && a2.KeyCode != Keys.Left && a2.KeyCode != Keys.Right)
                        toolTipAC.Hide(panel1);
                }
            };

            TabInfo ti = new TabInfo();
            ti.textEditor = te;
            ti.changed = false;
            if (type == OpenType.File && !alwaysNew) {
                ti.filepath = file;
                ti.filename = Path.GetFileName(file);
            } else {
                ti.filepath = null;
                ti.filename = unsaved;
            }
            ti.index = tabControl1.TabCount;
            te.ActiveTextAreaControl.TextArea.ToolTipRequest += new ToolTipRequestEventHandler(TextArea_ToolTipRequest);
            te.ContextMenuStrip = editorMenuStrip;

            tabs.Add(ti);
            TabPage tp = new TabPage(ti.filename);
            tp.Controls.Add(te);
            te.Dock = DockStyle.Fill;

            tabControl1.TabPages.Add(tp);
            if (type == OpenType.File & !alwaysNew) {
                tp.ToolTipText = ti.filepath;
                System.String ext = Path.GetExtension(file).ToLower();
                if (ext == ".ssl" || ext == ".h") {
                    ti.shouldParse = true;
                    ti.needsParse = true;
                    if (Settings.autoOpenMsgs && ti.filepath != null)
                        AssossciateMsg(ti, false);
                }
            }
            if (tabControl1.TabPages.Count > 1) {
                tabControl1.SelectTab(tp);
            } else {
                tabControl1_Selected(null, null);
            }
            return ti;
        }