Exemple #1
0
	void OnGUI()
	{
		replaceType = (ReplaceType)EditorGUILayout.EnumPopup(replaceType);

		GUILayout.Space(10);
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("Loc suffix", GUILayout.Width(100));
		EditorGUILayout.TextField( nameSuffix);
		if (GUILayout.Button("Create", GUILayout.Width(80)))
		{
			createPrefab = false;
			var created = Create(GetSelectGameObjects(), CreateLoc, replaceType);
			if (created != null)
			{
				Selection.objects = created.ToArray();
			}
		}
		EditorGUILayout.EndHorizontal();


		GUILayout.Space(5);
		EditorGUILayout.BeginHorizontal();
		selectPrefab = EditorGUILayout.ObjectField(selectPrefab, typeof(GameObject), true) as GameObject;
		if (GUILayout.Button("Create", GUILayout.Width(80)))
		{
			createPrefab = true;
			var created = Create(GetSelectGameObjects(), CreateLoc, replaceType);
			if (created != null){
				Selection.objects = created.ToArray();
			}
		}
		EditorGUILayout.EndHorizontal();

	}
Exemple #2
0
 public static RawlerBase TagClear(this RawlerBase rawler, ReplaceType replece)
 {
     return(rawler.Add(new TagClear()
     {
         ReplaceType = replece
     }));
 }
Exemple #3
0
        private static void DoRegister(string name, object content, ReplaceType replaceType, bool overwrite)
        {
            CheckOrFixName(ref name);
            Logger.Log(LogLevel.Info, "Trying to register " + name);
            if (File.Exists(_assetsPath + name) && !overwrite)
            {
                Logger.Log(LogLevel.Error, "Error: File already exists, overwrite not specified");
                throw new ArgumentException("File already exists, overwrite not specified.", nameof(name));
            }

            try
            {
                if (replaceType != ReplaceType.Text)
                {
                    if (replaceType == ReplaceType.Bytes)
                    {
                        File.WriteAllBytes(_assetsPath + name, content as byte[] ?? throw new InvalidOperationException());
                    }
                }
                else
                {
                    File.WriteAllText(_assetsPath + name, content as string, Encoding.UTF8);
                }
                Logger.Log(LogLevel.Info, "File registered");
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Error registering file");
                LogException(ex);
                throw;
            }
        }
        public int Create(string templateName, WeightType weightType, ReplaceType replaceType, int futuresCopies, double marketCapOpt, string benchmarkId, int userId)
        {
            var dbCommand = _dbHelper.GetStoredProcCommand(SP_Create);

            _dbHelper.AddInParameter(dbCommand, "@TemplateName", System.Data.DbType.String, templateName);
            //_dbHelper.AddInParameter(dbCommand, "@Status", System.Data.DbType.Int32, status);
            _dbHelper.AddInParameter(dbCommand, "@WeightType", System.Data.DbType.Int32, (int)weightType);
            _dbHelper.AddInParameter(dbCommand, "@ReplaceType", System.Data.DbType.Int32, (int)replaceType);
            _dbHelper.AddInParameter(dbCommand, "@FuturesCopies", System.Data.DbType.Int32, futuresCopies);
            _dbHelper.AddInParameter(dbCommand, "@MarketCapOpt", System.Data.DbType.Decimal, marketCapOpt);
            _dbHelper.AddInParameter(dbCommand, "@BenchmarkId", System.Data.DbType.String, benchmarkId);
            _dbHelper.AddInParameter(dbCommand, "@CreatedDate", System.Data.DbType.DateTime, DateTime.Now);
            _dbHelper.AddInParameter(dbCommand, "@CreatedUserId", System.Data.DbType.Int32, userId);

            _dbHelper.AddReturnParameter(dbCommand, "@return", System.Data.DbType.Int32);

            int ret        = _dbHelper.ExecuteNonQuery(dbCommand);
            int templateId = -1;

            if (ret > 0)
            {
                templateId = (int)dbCommand.Parameters["@return"].Value;
            }

            return(templateId);
        }
Exemple #5
0
        private static object GetFileContent(string name, ReplaceType replaceType, bool getFoundFile)
        {
            if (getFoundFile)
            {
                CheckOrFixName(ref name, DumpFileExtension);
            }
            else
            {
                CheckOrFixName(ref name);
            }

            if (!File.Exists(_assetsPath + name))
            {
                throw new ArgumentException("File does not exist.", nameof(name));
            }

            if (replaceType == ReplaceType.Text)
            {
                return(File.ReadAllText(_assetsPath + name, Encoding.UTF8));
            }
            if (replaceType == ReplaceType.Bytes)
            {
                return(File.ReadAllBytes(_assetsPath + name));
            }
            return(null);
        }
Exemple #6
0
        public void UpdateTextFonts(IEnumerable <string> fontFamilies, ReplaceType replaceType)
        {
            // Wordfile write stream.
            Random rand = new Random();

            InitializeFontFamilies(fontFamilies);

            using (var doc = WordprocessingDocument.Open(FileName, true))
            {
                Body body = doc.MainDocumentPart.Document.Body;

                //Get all paragraphs
                var paragraphs = body.Descendants <Paragraph>().ToList();
                foreach (var paragraph in paragraphs)
                {
                    switch (replaceType)
                    {
                    case ReplaceType.Paragraph:
                        ExtractPerParagraph(rand, paragraph);
                        break;

                    case ReplaceType.Letter:
                        ExtractPerLetter(rand, paragraph);
                        break;

                    default:
                        throw new Exception("Replace type is not supported.");
                    }
                }

                ApplyDocumentChanges(doc);
            }
        }
        public void ApplyTypes(ConstructionArea area, JSONNode node)
        {
            Log.Write("Appling Types " + node.ToString());
            ReplaceType type = new ReplaceType(node);

            area.ConstructionType = (IConstructionType) new ReplacerSpecial(type);
            area.IterationType    = (IIterationType) new TopToBottom(area);
        }
 public string HtmlSpecialCharsDecode( string s, ReplaceType r )
 {
     if ( r == ReplaceType.CharacterCode || r == ReplaceType.Both )
         s = numeric.Replace( s, new MatchEvaluator( rep ) );
     if ( r == ReplaceType.HtmlEntity || r == ReplaceType.Both )
         foreach ( var x in ReversedEntities.Keys.Where( o => s.Contains( o ) ).ToArray() )
             s = s.Replace( x, ReversedEntities[ x ].ToString() );
     return s;
 }
Exemple #9
0
        // used to be private
        internal Replacer(Identifier oldName, Node newNode)
        {
            this.oldName = oldName;
            this.newNode = newNode;

            if (newNode is Expression)
                replaceType = ReplaceType.Identifier;
            else if (newNode is Block)
                replaceType = ReplaceType.LabeledStatement;
            else
                throw new ArgumentException("Replacer: newNode must be Expression or Block");
        }
 public StringReplaceConverter(ReplaceType kind)
 {
     if ((kind & ReplaceType.Comma) == ReplaceType.Comma)
         init(",", "");
     if ((kind & ReplaceType.DoubleQuote) == ReplaceType.DoubleQuote)
         init("\"", "");
     if ((kind & ReplaceType.Newline) == ReplaceType.Newline)
     {
         init("\n", "");
         init(Environment.NewLine, "");
         init("\r", "");
     }
 }
        static void ReplaceLineOrValue(FileInfo fileToRead, ReplaceType type, Replacement[] replacements, string oldValue = null)
        {
            var fileName = fileToRead.FullName;
            Trace.TraceInformation("Reading config file '{0}'.", fileName);

            if (!File.Exists(fileName))
            {
                Trace.TraceError("The file to modify does not exis '{0}'.", fileName);
                return;
            }

            var lines = new List<string>();

            using (var file = new StreamReader(fileName))
            {
                while (!file.EndOfStream)
                {
                    var line = file.ReadLine();

                    if (line == null) continue;

                    var replacement = replacements.SingleOrDefault(rep => IsMatch(rep, line));
                    if (replacement != null)
                    {
                        Trace.TraceInformation(
                            "Found match for <{0}> on line #{1}. The line was <{2}> and was replaced with <{3}>.",
                            replacement.PatternToFind,
                            lines.Count + 1,
                            line,
                            replacement.LineToInsert);
                        if(type == ReplaceType.Line)
                        line = replacement.LineToInsert;

                        if(type == ReplaceType.Value && oldValue != null)
                            line = line.Replace(oldValue, replacement.LineToInsert);
                    }

                    lines.Add(line);
                }
            }

            using (var file = new StreamWriter(fileName, false))
            {
                foreach (string line in lines)
                {
                    file.WriteLine(line);
                }
            }

            Trace.TraceInformation("Config file '{0}' written.", fileName);
        }
Exemple #12
0
        public static RenameProcessor Build(SearchType searchType, string searchString, bool searchCaseSensitive,
                                            ReplaceType replaceType, string replaceString)
        {
            INameAnalyzer nameAnalyzer = null;

            switch (searchType)
            {
            case SearchType.WhiteSpace: { nameAnalyzer = new WhiteSpaceAnalyzer();    break; }

            case SearchType.Special:    { nameAnalyzer = new SpecialEndingAnalyzer(); break; }

            case SearchType.Characters:
            {
                var splitParts = searchString.Split(',')
                                 .Select(split => split.Trim());

                var isMultiSearch = false;

                if (splitParts.Count() > 1)
                {
                    if (splitParts.All(split => split.StartsWith("\"") && split.EndsWith("\"")))
                    {
                        isMultiSearch = true;
                    }
                }

                if (isMultiSearch)
                {
                    nameAnalyzer = new MultiStringAnalyzer(searchString, searchCaseSensitive);
                }
                else
                {
                    nameAnalyzer = new SingleStringAnalyzer(searchString, searchCaseSensitive);
                }
                break;
            }
            }

            INameRefactorer nameRefactorer = null;

            switch (replaceType)
            {
            case ReplaceType.Delete:     { nameRefactorer = new StringRefactorer("");            break; }

            case ReplaceType.WhiteSpace: { nameRefactorer = new StringRefactorer(" ");           break; }

            case ReplaceType.Characters: { nameRefactorer = new StringRefactorer(replaceString); break; }
            }

            return(new RenameProcessor(nameAnalyzer, nameRefactorer));
        }
Exemple #13
0
        public FindReplaceDialogHelper(ReplaceType findType, string findText, Regex regEx, string replaceText, int startLineIndex)
        {
            FindReplaceType = findType;
            _findText       = findText;

            _replaceText = replaceText;
            if (_replaceText != null)
            {
                _replaceText = RegexUtils.FixNewLine(_replaceText);
            }

            _regEx          = regEx;
            _findTextLength = findText.Length;
            StartLineIndex  = startLineIndex;
        }
Exemple #14
0
    public static void ReplaceAndDisplaceElement(int gameCell, SimHashes new_element, CellElementEvent ev, float mass, float temperature = -1f, byte disease_idx = byte.MaxValue, int disease_count = 0, int callbackIdx = -1)
    {
        int elementIndex = GetElementIndex(new_element);

        if (elementIndex != -1)
        {
            Element     element      = ElementLoader.elements[elementIndex];
            float       num          = (temperature == -1f) ? element.defaultValues.temperature : temperature;
            int         elementIdx   = elementIndex;
            float       temperature2 = num;
            byte        disease_idx2 = disease_idx;
            ReplaceType replace_type = ReplaceType.ReplaceAndDisplace;
            ModifyCell(gameCell, elementIdx, temperature2, mass, disease_idx2, disease_count, replace_type, false, callbackIdx);
        }
    }
        public FindReplaceDialogHelper(ReplaceType findType, string findText, Regex regEx, string replaceText, int startLineIndex)
        {
            FindReplaceType = findType;
            _findText       = findText;

            _replaceText = replaceText;
            if (_replaceText != null)
            {
                _replaceText = _replaceText.Replace("\\n", Environment.NewLine);
            }

            _regEx          = regEx;
            _findTextLength = findText.Length;
            StartLineIndex  = startLineIndex;
        }
        private static void ReplaceValue(StringBuilder sb, string key, string?value, ReplaceType replaceType)
        {
            var startIndex = IndexOf(sb, key, out var length, removeLeadingSlash: replaceType == ReplaceType.ValueBracesAndLeadingSlash);

            if (startIndex != -1)
            {
                if (replaceType == ReplaceType.ValueOnly)
                {
                    sb.Remove(startIndex + 1, length - 2);
                    sb.Insert(startIndex + 1, value);
                }
                else
                {
                    sb.Remove(startIndex, length);
                    sb.Insert(startIndex, value?.ToLowerInvariant() ?? string.Empty);
                }
            }
Exemple #17
0
 public StringReplaceConverter(ReplaceType kind)
 {
     if ((kind & ReplaceType.Comma) == ReplaceType.Comma)
     {
         init(",", "");
     }
     if ((kind & ReplaceType.DoubleQuote) == ReplaceType.DoubleQuote)
     {
         init("\"", "");
     }
     if ((kind & ReplaceType.Newline) == ReplaceType.Newline)
     {
         init("\n", "");
         init(Environment.NewLine, "");
         init("\r", "");
     }
 }
Exemple #18
0
        public FindReplaceDialogHelper(ReplaceType findType, string findText, Regex regEx, string replaceText, int startLineIndex)
        {
            ReplaceText     = string.Empty;
            FindReplaceType = findType;
            FindText        = findText;

            ReplaceText = replaceText;
            if (ReplaceText != null)
            {
                ReplaceText = RegexUtils.FixNewLine(ReplaceText);
            }

            _regEx          = regEx;
            FindTextLength  = findText.Length;
            StartLineIndex  = startLineIndex;
            MatchInOriginal = false;
        }
Exemple #19
0
        public ReplaceType GetFindType()
        {
            var result = new ReplaceType();

            if (radioButtonNormal.Checked)
            {
                result.FindType = FindType.Normal;
            }
            else if (radioButtonCaseSensitive.Checked)
            {
                result.FindType = FindType.CaseSensitive;
            }
            else
            {
                result.FindType = FindType.RegEx;
            }
            result.WholeWord = checkBoxWholeWord.Checked;
            return(result);
        }
Exemple #20
0
        public static string GetReplaceType(ReplaceType replaceType)
        {
            string replaceTypeName = string.Empty;

            switch (replaceType)
            {
            case ReplaceType.StockReplace:
                replaceTypeName = "个股替代";
                break;

            case ReplaceType.TemplateReplace:
                replaceTypeName = "模板替代";
                break;

            default:
                break;
            }

            return(replaceTypeName);
        }
Exemple #21
0
 /// <summary>
 /// 判断是否都不为空,如果是,则进行替换,如果是,则return
 /// </summary>
 private void ReplaceContent()
 {
     if (VoList.Count > 0 && DicType.Count > 0)
     {
         try
         {
             ReplaceType replaceType = new ReplaceType();
             replaceType.VoList  = VoList;
             replaceType.DicType = DicType;
             replaceType.ReplaceListContent();
             VoList = replaceType.VoList;
         }
         catch (System.Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         return;
     }
 }
        public static string HtmlDecode(string s, ReplaceType r = ReplaceType.Both)
        {
            switch (r)
            {
            case ReplaceType.CharacterCode:
                return(Numeric.Replace(s, RepEvaluator));

            case ReplaceType.HtmlEntity:
            {
                var sb = new StringBuilder(s);
                foreach (var x in ReversedEntities.Keys)
                {
                    if (s.Contains(x))
                    {
                        sb.Replace(x, ReversedEntities[x]);
                    }
                }
                return(sb.ToString());
            }

            case ReplaceType.Both:
            {
                //todo:
                s = Numeric.Replace(s, RepEvaluator);
                var sb = new StringBuilder(s);
                foreach (var x in ReversedEntities.Keys)
                {
                    if (s.Contains(x))
                    {
                        sb.Replace(x, ReversedEntities[x]);
                    }
                }
                return(sb.ToString());
            }
            }
            return(s);
        }
        public static Cell[] SpecialReplaceRow(int row, int colCount, Cell[] currentPopulation, Cell[] newPopulation, ReplaceType replaceType)
        {
            switch (replaceType)
            {
            case ReplaceType.ReplaceAll:
            {
                for (int col = 0; col < colCount; col++)
                {
                    SetAtGrid(currentPopulation, row, col, colCount, GetAtGrid(newPopulation, 0, col, colCount));
                }
                return(currentPopulation);
            }

            case ReplaceType.ReplaceWorstInNeighbourhood:
            case ReplaceType.ReplaceOneParent:
            {
                for (int col = 0; col < colCount; col++)
                {
                    Cell  offSpring = GetAtGrid(newPopulation, 0, col, colCount);
                    Point toReplace = offSpring.ToReplace;

                    offSpring.Location = toReplace;
                    SetAtGrid(currentPopulation, toReplace.Y, toReplace.X, colCount, offSpring);
                }

                return(currentPopulation);
            }

            default:
                throw new Exception("BAD REPLACE TYPE.");
            }
        }
Exemple #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReplacePattern"/> class.
 /// </summary>
 public ReplacePattern()
 {
     this.ReplaceType = ReplaceType.Regex;
 }
Exemple #25
0
 public unsafe static void ModifyCell(int gameCell, int elementIdx, float temperature, float mass, byte disease_idx, int disease_count, ReplaceType replace_type = ReplaceType.None, bool do_vertical_solid_displacement = false, int callbackIdx = -1)
 {
     if (Grid.IsValidCell(gameCell))
     {
         Element element = ElementLoader.elements[elementIdx];
         if (element.maxMass == 0f && mass > element.maxMass)
         {
             Debug.LogWarningFormat("Invalid cell modification (mass greater than element maximum): Cell={0}, EIdx={1}, T={2}, M={3}, {4} max mass = {5}", gameCell, elementIdx, temperature, mass, element.id, element.maxMass);
             mass = element.maxMass;
         }
         if (temperature < 0f || temperature > 10000f)
         {
             Debug.LogWarningFormat("Invalid cell modification (temp out of bounds): Cell={0}, EIdx={1}, T={2}, M={3}, {4} default temp = {5}", gameCell, elementIdx, temperature, mass, element.id, element.defaultValues.temperature);
             temperature = element.defaultValues.temperature;
         }
         if (temperature == 0f && mass > 0f)
         {
             Debug.LogWarningFormat("Invalid cell modification (zero temp with non-zero mass): Cell={0}, EIdx={1}, T={2}, M={3}, {4} default temp = {5}", gameCell, elementIdx, temperature, mass, element.id, element.defaultValues.temperature);
             temperature = element.defaultValues.temperature;
         }
         ModifyCellMessage *ptr = stackalloc ModifyCellMessage[1];
         ptr->cellIdx      = gameCell;
         ptr->callbackIdx  = callbackIdx;
         ptr->temperature  = temperature;
         ptr->mass         = mass;
         ptr->elementIdx   = (byte)elementIdx;
         ptr->replaceType  = (byte)replace_type;
         ptr->diseaseIdx   = disease_idx;
         ptr->diseaseCount = disease_count;
         ptr->addSubType   = (byte)((!do_vertical_solid_displacement) ? 1 : 0);
         Sim.SIM_HandleMessage(-1252920804, sizeof(ModifyCellMessage), (byte *)ptr);
     }
 }
Exemple #26
0
 public ReplacerSpecial(ReplaceType type)
 {
     this.digType   = type.dig;
     this.buildType = type.place;
 }
Exemple #27
0
        private static object DoReplace(TextAsset asset, ReplaceType replaceType)
        {
            object obj  = null;
            var    text = "";

            if (replaceType != ReplaceType.Text)
            {
                if (replaceType == ReplaceType.Bytes)
                {
                    try
                    {
                        RestoreMethodStart(_originalBytesLocation, _originalBytesCode);
                        obj = asset.bytes;
                        Memory.WriteJump(_originalBytesLocation, _replacementBytesLocation);
                        text = "bytes";
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogLevel.Error, "Error getting bytes");
                        LogException(ex);
                        throw;
                    }
                }
            }
            else
            {
                try
                {
                    RestoreMethodStart(_originalTextLocation, _originalTextCode);
                    obj = asset.text;
                    Memory.WriteJump(_originalTextLocation, _replacementTextLocation);
                    text = "text";
                }
                catch (Exception ex2)
                {
                    Logger.Log(LogLevel.Error, "Error getting text");
                    LogException(ex2);
                    throw;
                }
            }

            var name = Path.Combine(_assetsPath, asset.name);
            var replacementFilePath = name + ReplacementFileExtension;

            if (File.Exists(replacementFilePath))
            {
                if (ReplacingEnabled.Value)
                {
                    Logger.Log(LogLevel.Info, "Replacing " + text + " in " + name);
                    try
                    {
                        if (replaceType != ReplaceType.Text)
                        {
                            if (replaceType == ReplaceType.Bytes)
                            {
                                obj = File.ReadAllBytes(replacementFilePath);
                            }
                        }
                        else
                        {
                            obj = File.ReadAllText(replacementFilePath, Encoding.UTF8);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Log(LogLevel.Error, string.Concat("Error replacing ", text, " in ", name, ", using original"));
                        LogException(e);
                    }
                }
            }
            else
            {
                if (DumpingEnabled.Value)
                {
                    var dumpFilePath = name + DumpFileExtension;
                    if (!File.Exists(dumpFilePath))
                    {
                        Logger.Log(LogLevel.Info, "File " + replacementFilePath + " not found, creating 'found' file");
                        try
                        {
                            if (replaceType != ReplaceType.Text)
                            {
                                if (replaceType == ReplaceType.Bytes)
                                {
                                    File.WriteAllBytes(dumpFilePath, obj as byte[] ?? throw new InvalidOperationException());
                                }
                            }
                            else
                            {
                                File.WriteAllText(dumpFilePath, obj as string, Encoding.UTF8);
                            }
                        }
                        catch (Exception e2)
                        {
                            Logger.Log(LogLevel.Error, "Error creating file: " + dumpFilePath);
                            LogException(e2);
                        }
                    }

                    if (File.Exists(replacementFilePath))
                    {
                        obj = DoReplace(asset, replaceType);
                    }
                }
            }
            return(obj);
        }
 public static string HtmlDecode( string s, ReplaceType r = ReplaceType.Both ) {
     switch ( r ) {
         case ReplaceType.CharacterCode:
             return Numeric.Replace( s, RepEvaluator );
         case ReplaceType.HtmlEntity:
             { 
                 var sb = new StringBuilder( s );
                 foreach ( var x in ReversedEntities.Keys ) if ( s.Contains( x ) ) sb.Replace( x, ReversedEntities[ x ] );
                 return sb.ToString();
             }
         case ReplaceType.Both:
             {
                 //todo: 
                 s = Numeric.Replace( s, RepEvaluator );
                 var sb = new StringBuilder( s );
                 foreach ( var x in ReversedEntities.Keys ) if ( s.Contains( x ) ) sb.Replace( x, ReversedEntities[ x ] );
                 return sb.ToString();
             }
     }
     return s;
 }
Exemple #29
0
 public static RawlerBase TagClear(this RawlerBase rawler,ReplaceType replece)
 {
     return rawler.Add(new TagClear() { ReplaceType = replece });
 }
        public void SetNext()
        {
            //LockControls = false;
            string idT = GetIDsThu();
            _doLichPhatSong = DALichPhatSongNew.I.LoadAll(-2);

            _rootLichPhatSong = null;
            _isAdd = true;
            btnCreateDetail.Text = "Tạo chi tiết LPS  >>";

            var qr = new QueryBuilder(@"select first 1 ngay_phat_song from ql_lich_phat_song_ct lpsct
                 inner join ql_lich_phat_song lps on lps.lps_id=lpsct.lps_id
                where extract(weekday from ngay_phat_song) in(" + idT + ") and 1=1");
            qr.add(QL_LICH_PHAT_SONG_CT.NGAY_PHAT_SONG, Operator.GreaterEqual, NgayPhatCuoi.DateTime, DbType.DateTime);
            qr.addID("lps." + QL_LICH_PHAT_SONG.KENH_PHAT, KenhPhat._getSelectedID());
            qr.add(string.Format("extract(hour from {0})", "LPS." + QL_LICH_PHAT_SONG.GIO_PHAT_SONG), Operator.Equal, GioPhat.Time.Hour, DbType.Int32);
            qr.add(string.Format("extract(minute from {0})", "LPS." + QL_LICH_PHAT_SONG.GIO_PHAT_SONG), Operator.Equal, GioPhat.Time.Minute, DbType.Int32);
            qr.setDescOrderBy(QL_LICH_PHAT_SONG_CT.NGAY_PHAT_SONG);
            var ds = HelpDB.getDatabase().LoadDataSet(qr);
            var thus = AppCtrl.GetThuTrongTuan(ThuTrongTuan._getSelectedIDs());
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                NgayBatDau.DateTime = AppCtrl.GetNextDate((DateTime)ds.Tables[0].Rows[0][0], thus);
            }

            else
                NgayBatDau.DateTime = AppCtrl.GetNextDate(NgayPhatCuoi.DateTime, thus);

            _replaceType = ReplaceType.NONE;
            NgayPhatCuoi.EditValue = null;
            SoNgayPhat.EditValue = null;
            GhiChu.Text = "";
            NoiDung._setSelectedID(-1);
            TenGoc.Text = "";
            Category.Text = "";
            TongTapPhat.EditValue = null;
            TongTapCT.EditValue = null;
            NuocSX._setSelectedIDs(new long[] { -1 });
            NamSX.EditValue = null;
            TietMuc._setSelectedID(-1);
            PostMaster._setSelectedID(-1);
            ThoiLuong.Text = "";
            // LockControls = false;
            _dsDetail.Clear();
            gridControlDetail.DataSource = _dsDetail.Tables[0];
            btnNext.Enabled = false;
            btnDelete.Enabled = false;
            btnCopy.Enabled = false;
            Title.Text = "TẠO MỚI LỊCH PHÁT SÓNG";
            ColStart.Visible = false;

            NgayBatDau.Properties.ReadOnly = false;
            KenhPhat.MainCtrl.Properties.ReadOnly = false;
            ThuTrongTuan.Properties.ReadOnly = false;
            GioPhat.Properties.ReadOnly = false;

            _error.ClearErrors();
            groupBox1.Visible = false;
        }
 public FrmLichPhatSonNew(DOLichPhatSongNew sourceLichPhatSong, DOLichPhatSongNew saveOrDeleteLichPhatSong, IPhieuFix parentFix, ReplaceType replaceType)
 {
     _bkGioPhat = null;
     _replaceType = replaceType;
     _parentFix = parentFix;
     _sourceLichPhatSong = sourceLichPhatSong;
     _saveOrDeleteLichPhatSong = saveOrDeleteLichPhatSong;
     if (sourceLichPhatSong == null)
         _replaceType = ReplaceType.NONE;
     Init("-2", true);
 }
 public void SetCopy()
 {
     _doLichPhatSong.LPS_ID = -1;
     _doLichPhatSong.INSERT_LPS_ID = -1;
     _replaceType = ReplaceType.NONE;
     _isAdd = true;
     _rootLichPhatSong = null;
     NgayBatDau.Properties.ReadOnly = false;
     KenhPhat.MainCtrl.Properties.ReadOnly = false;
     ThuTrongTuan.Properties.ReadOnly = false;
     GioPhat.Properties.ReadOnly = false;
     _doLichPhatSong.DSDetail.AcceptChanges();
     Title.Text = "TẠO LỊCH PHÁT SÓNG (COPY)";
     btnCreateDetail.Text = "Tạo chi tiết LPS >>";
     btnNext.Enabled = false;
     btnCopy.Enabled = false;
     Info.Enabled = false;
     _error.SetError(GioPhat, "Đây là lịch copy, có nên thay đổi giờ phát cho khác với lịch gốc(?)", ErrorType.Information);
     _error.SetIconAlignment(GioPhat, ErrorIconAlignment.MiddleRight);
     foreach (DataRow r in _dsDetail.Tables[0].Rows)
     {
         r[QL_LICH_PHAT_SONG_CT.LPS_CT_ID] = DBNull.Value;
         r[QL_LICH_PHAT_SONG_CT.LPS_ID] = DBNull.Value;
     }
     GioPhat.BackColor = Color.Pink;
     GioPhat.EditValueChanged += GioPhatEditValueChanged;
 }
        /// <summary>
        /// Replace Prefix[name] strings with values from Resources, Configs etc
        /// </summary>
        private static string ReplaceRegEx(string pInput, ReplaceType pReplaceType)
        {
            //Log4Net
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            string patternBase   = @"(?<={0}\[)(.*?)(?=\])";
            string patternPrefix = string.Empty;
            string pattern       = string.Empty;
            string result        = pInput;
            string nodeValue     = string.Empty;
            Func <string, string> funcGetValue = null;

            switch (pReplaceType)
            {
            case ReplaceType.Config:
                patternPrefix = "Cfg";
                if (pInput.Contains(string.Format("{0}[", patternPrefix)))
                {
                    funcGetValue = (x) => GlobalFramework.Settings[x];
                }
                break;

            case ReplaceType.Resource:
                patternPrefix = "Resx";
                if (pInput.Contains(string.Format("{0}[", patternPrefix)))
                {
                    funcGetValue = (x) => Resx.ResourceManager.GetString(x);
                }
                break;

            case ReplaceType.Evaluation:
                patternPrefix = "Eval";
                if (pInput.Contains(string.Format("{0}[", patternPrefix)))
                {
                    funcGetValue = (x) => GetEvaluationResult(x);
                }
                break;

            case ReplaceType.EvaluationDebug:
                patternPrefix = "EvalDebug";
                if (pInput.Contains(string.Format("{0}[", patternPrefix)))
                {
                    funcGetValue = (x) => GetEvaluationResult(x, true);
                }
                break;

            default:
                break;
            }

            pattern = string.Format(patternBase, patternPrefix);
            MatchCollection matchCollection = Regex.Matches(pInput, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase);

            foreach (Match match in matchCollection)
            {
                try
                {
                    nodeValue = funcGetValue(match.Value);
                    if (nodeValue != string.Empty)
                    {
                        result = result.Replace(string.Format("{0}[{1}]", patternPrefix, match), nodeValue);
                    }
                    //if (_debug) _log.Debug(string.Format("item[{0}]: [{1}]=[{2}] result={3}", Enum.GetName(typeof(ReplaceType), pReplaceType), match, nodeValue, result));
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            return(result);
        }
Exemple #34
0
	List<GameObject> Create(Transform[] oriTs, CreateNewObjectHandler CreateNewDo,  ReplaceType replaceType){
		
		List<GameObject> results = new List<GameObject>();
		foreach (Transform t in oriTs)
		{
			GameObject[] objs = CreateNewDo(t);
			if (objs == null)
			{
				return null;
			}
			
			results.AddRange(objs);
			foreach (GameObject obj in objs)
			{
				obj.transform.localScale = t.lossyScale;
				obj.transform.rotation = t.rotation;
				obj.transform.position = t.position;

				switch (replaceType)
				{
					case  ReplaceType.None:
						break;
					case ReplaceType.BeChild:
						obj.transform.parent = t;
						break;
					case ReplaceType.BeParent:
						obj.transform.parent = t.transform.parent;
						t.transform.parent = obj.transform;
						break;
					case ReplaceType.Replace:
						obj.transform.parent = t.transform.parent;
						GameObject.DestroyImmediate(t.gameObject);
						break;
					default: break;
				}
				
			}
		}
		return results;
	}
 private static bool Prefix(int gameCell, int elementIdx, float temperature, float mass, byte disease_idx, int disease_count, ReplaceType replace_type, bool do_vertical_solid_displacement, int callbackIdx)
 {
     SimMessages_Utils.Log(MethodBase.GetCurrentMethod(),
                           gameCell, elementIdx, temperature, mass, disease_idx, disease_count, replace_type, do_vertical_solid_displacement, callbackIdx);
     return(true);
 }
        public string ReplaceWithCode(string _string, ReplaceType _type)
        {
            try
            {
                if (_type == ReplaceType.Convert)
                {
                    var regex = new Regex("[']");
                    _string = regex.Replace(_string, code_pelica);

                    regex   = new Regex("[,]");
                    _string = regex.Replace(_string, code_virgula);

                    regex   = new Regex("[!]");
                    _string = regex.Replace(_string, code_exclamacao);

                    regex   = new Regex("[@]");
                    _string = regex.Replace(_string, code_arroba);

                    regex   = new Regex("[#]");
                    _string = regex.Replace(_string, code_cardinal);

                    regex   = new Regex("[*]");
                    _string = regex.Replace(_string, code_asterisco);

                    regex   = new Regex("[£]");
                    _string = regex.Replace(_string, code_libra);

                    regex   = new Regex("[€]");
                    _string = regex.Replace(_string, code_euro);

                    regex   = new Regex("[$]");
                    _string = regex.Replace(_string, code_dollar);

                    regex   = new Regex("[§]");
                    _string = regex.Replace(_string, code_paragrafo);

                    regex   = new Regex("[%]");
                    _string = regex.Replace(_string, code_percentagem);

                    regex   = new Regex("[&]");
                    _string = regex.Replace(_string, code_e);

                    regex   = new Regex("[{]");
                    _string = regex.Replace(_string, code_par_bico_e);

                    regex   = new Regex("[}]");
                    _string = regex.Replace(_string, code_par_bico_d);

                    regex   = new Regex("[[]");
                    _string = regex.Replace(_string, code_par_liso_e);

                    regex   = new Regex("[]]");
                    _string = regex.Replace(_string, code_par_liso_d);

                    regex   = new Regex("[(]");
                    _string = regex.Replace(_string, code_par_curvo_e);

                    regex   = new Regex("[)]");
                    _string = regex.Replace(_string, code_par_curvo_d);

                    regex   = new Regex("[=]");
                    _string = regex.Replace(_string, code_igual);

                    regex   = new Regex("[<]");
                    _string = regex.Replace(_string, code_seta_e);

                    regex   = new Regex("[>]");
                    _string = regex.Replace(_string, code_seta_d);

                    regex   = new Regex("[«]");
                    _string = regex.Replace(_string, code_setas_e);

                    regex   = new Regex("[»]");
                    _string = regex.Replace(_string, code_setas_d);

                    regex   = new Regex("[.]");
                    _string = regex.Replace(_string, code_ponto);

                    regex   = new Regex(@"[\\]");
                    _string = regex.Replace(_string, code_barra_e);

                    regex   = new Regex("[/]");
                    _string = regex.Replace(_string, code_barra_d);



                    return(_string);
                }
                else
                {
                    var regex = new Regex(code_pelica);
                    _string = regex.Replace(_string, "'");

                    regex   = new Regex(code_virgula);
                    _string = regex.Replace(_string, ",");

                    regex   = new Regex(code_exclamacao);
                    _string = regex.Replace(_string, "!");

                    regex   = new Regex(code_arroba);
                    _string = regex.Replace(_string, "@");

                    regex   = new Regex(code_cardinal);
                    _string = regex.Replace(_string, "#");

                    regex   = new Regex(code_asterisco);
                    _string = regex.Replace(_string, code_asterisco);

                    regex   = new Regex(code_libra);
                    _string = regex.Replace(_string, "£");

                    regex   = new Regex(code_euro);
                    _string = regex.Replace(_string, "€");

                    regex   = new Regex(code_dollar);
                    _string = regex.Replace(_string, "$");

                    regex   = new Regex(code_paragrafo);
                    _string = regex.Replace(_string, "§");

                    regex   = new Regex(code_percentagem);
                    _string = regex.Replace(_string, "%");

                    regex   = new Regex(code_e);
                    _string = regex.Replace(_string, "&");

                    regex   = new Regex(code_par_bico_e);
                    _string = regex.Replace(_string, "{");

                    regex   = new Regex(code_par_bico_d);
                    _string = regex.Replace(_string, "}");

                    regex   = new Regex(code_par_liso_e);
                    _string = regex.Replace(_string, "[");

                    regex   = new Regex(code_par_liso_d);
                    _string = regex.Replace(_string, "]");

                    regex   = new Regex(code_par_curvo_e);
                    _string = regex.Replace(_string, "(");

                    regex   = new Regex(code_par_curvo_d);
                    _string = regex.Replace(_string, ")");

                    regex   = new Regex(code_igual);
                    _string = regex.Replace(_string, "=");

                    regex   = new Regex(code_seta_e);
                    _string = regex.Replace(_string, "<");

                    regex   = new Regex(code_seta_d);
                    _string = regex.Replace(_string, ">");

                    regex   = new Regex(code_setas_e);
                    _string = regex.Replace(_string, "«");

                    regex   = new Regex(code_setas_d);
                    _string = regex.Replace(_string, "»");

                    regex   = new Regex(code_ponto);
                    _string = regex.Replace(_string, ".");

                    regex   = new Regex(code_barra_e);
                    _string = regex.Replace(_string, @"\");

                    regex   = new Regex(code_barra_d);
                    _string = regex.Replace(_string, "/");



                    return(_string);
                }
            }
            catch (Exception exception)
            {
                tools.Exception(exception);
                return(null);
            }
        }