Exemple #1
1
        //減色パレット作成
        private void MakePaletteColor(int colorCount)
        {
            if (MyOriginPixels == null)
            {
                return;
            }

            SelectType selecter = (SelectType)ComboBoxSelectType.SelectedItem;
            SplitType  splitter = (SplitType)ComboBoxSplitType.SelectedItem;
            var        cube     = new Cube(MyOriginPixels);

            cube.Split(colorCount, selecter, splitter);//分割数指定でCube分割

            //Cubeから色取得して、色データ作成
            List <Color> colors = cube.GetColors((ColorSelectType)ComboBoxColorSelectType.SelectedItem);
            ObservableCollection <MyData> data = MakeDataContext(colors);

            MyColorDataList.Add(colors);

            //色データ表示用のlistboxを作成して表示
            ListBox list = CreateListBox();

            list.DataContext = data;
            //MyStackPanel.Children.Add(list);
            MyStackPanel.Children.Add(MakePanelPalette(list, colors.Count));
        }
Exemple #2
0
        /// <summary>
        /// 获取分表字段的值
        /// </summary>
        /// <param name="db"></param>
        /// <param name="entityInfo"></param>
        /// <param name="splitType"></param>
        /// <param name="entityValue"></param>
        /// <returns></returns>
        public object GetFieldValue(ISqlSugarClient db, EntityInfo entityInfo, SplitType splitType, object entityValue)
        {
            var splitColumn = entityInfo.Columns.FirstOrDefault(it => it.PropertyInfo.GetCustomAttribute <SplitFieldAttribute>() != null);
            var value       = splitColumn.PropertyInfo.GetValue(entityValue, null);

            return(value);
        }
        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            string    splitDescription = cboType.SelectedValue.ToString();
            SplitType split            = GetEnumValue <SplitType>(splitDescription);

            if (split == SplitType.Changed)
            {
                txtValue.Visible   = false;
                btnRemove.Location = new System.Drawing.Point(367, 2);
            }
            else
            {
                btnRemove.Location = new System.Drawing.Point(441, 2);
                txtValue.Visible   = true;
            }
            txtValue.Tag = txtValue.Visible;

            MemberInfo[]           infos        = typeof(SplitType).GetMember(split.ToString());
            DescriptionAttribute[] descriptions = null;
            if (infos.Length > 0)
            {
                descriptions = (DescriptionAttribute[])infos[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
            }
            if (descriptions != null && descriptions.Length > 0)
            {
                ToolTips.SetToolTip(cboType, descriptions[0].Description);
            }
            else
            {
                ToolTips.SetToolTip(cboType, string.Empty);
            }
        }
        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            string    splitDescription = cboType.SelectedValue.ToString();
            SplitType split            = GetEnumValue <SplitType>(splitDescription);

            if (split != SplitType.LevelExit && split != SplitType.LevelEnter)
            {
                txtLevel.Visible = false;
                txtLevel.Text    = string.Empty;
                cboType.Size     = new System.Drawing.Size(313, 21);
            }
            else
            {
                cboType.Size     = new System.Drawing.Size(207, 21);
                txtLevel.Visible = true;
            }
            txtLevel.Tag = txtLevel.Visible;

            MemberInfo[]           infos        = typeof(SplitType).GetMember(split.ToString());
            DescriptionAttribute[] descriptions = null;
            if (infos.Length > 0)
            {
                descriptions = (DescriptionAttribute[])infos[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
            }
            if (descriptions != null && descriptions.Length > 0)
            {
                ToolTips.SetToolTip(cboType, descriptions[0].Description);
            }
            else
            {
                ToolTips.SetToolTip(cboType, string.Empty);
            }
        }
 public AutoSplit(string name, SplitType type, short value, short difficulty)
 {
     Name       = name;
     Type       = type;
     Value      = value;
     Difficulty = difficulty;
 }
Exemple #6
0
        public override void WriteXml(XmlWriter writer)
        {
            base.WriteXml(writer);
            writer.WriteAttributeString("Separator", Separator);
            writer.WriteAttributeString("SplitType", SplitType.ToString());
            writer.WriteAttributeString("AsEnum", AsEnum.ToString());

            writer.WriteStartElement("Dictionary");
            writer.WriteAttributeString("Length", Dictionary.Length.ToString());
            for (int i = 0; i < Dictionary.Length; i++)
            {
                writer.WriteStartElement("item");
                writer.WriteValue(Dictionary[i]);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteStartElement("Exclude");
            writer.WriteAttributeString("Length", Exclude.Length.ToString());
            for (int i = 0; i < Exclude.Length; i++)
            {
                writer.WriteStartElement("item");
                writer.WriteValue(Exclude[i]);
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
Exemple #7
0
        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboType.SelectedValue == null || isLoading)
            {
                return;
            }

            SplitType nextControlType = (SplitType)cboType.SelectedValue;

            if (nextControlType == SplitType.ManualSplit || nextControlType == SplitType.GameStart)
            {
                txtValue.Visible = false;
                cboValue.Visible = false;
                UserSplit.Value  = string.Empty;
            }
            else
            {
                if (nextControlType != UserSplit.Type)
                {
                    switch (nextControlType)
                    {
                    case SplitType.Album: DefaultValue = SplitAlbumn.Any; break;

                    case SplitType.Track: DefaultValue = SplitTrack.Any; break;
                    }
                    UserSplit.Value = DefaultValue.ToString();
                }
                txtValue.Visible = false;
                cboValue.Visible = true;
            }
            UserSplit.Type = nextControlType;

            UpdateControls();
        }
        public void InitializeSettings(XmlNode node)
        {
            Settings.Autosplits.Clear();

            bool logInfo = GetXmlBoolItem(node, ".//LogInfo", false);

            chkLog.Checked    = logInfo;
            Log.EnableLogging = logInfo;

            XmlNodeList splitNodes = node.SelectNodes(".//Splits/Split");

            foreach (XmlNode splitNode in splitNodes)
            {
                string[] splitValues = splitNode.InnerText.Split('|');
                if (splitValues.Length == 2)
                {
                    SplitType type = SplitType.ManualSplit;
                    if (Enum.TryParse <SplitType>(splitValues[0], out type))
                    {
                        string value = splitValues[1];
                        Settings.Autosplits.Add(new Split()
                        {
                            Type = type, Value = value
                        });
                    }
                }
            }

            FixSplits();
        }
Exemple #9
0
 public Cube3(byte[] pixels, SelectType selectType, SplitType splitType)
 {
     Pixels = pixels;
     CubeList.Add(this);
     SelectType = selectType;
     SplitType  = splitType;
 }
Exemple #10
0
 private void AddCursorRect(Rect rect, SplitType splitType)
 {
     if (drawCursorEve != null)
     {
         drawCursorEve(rect, splitType);
     }
 }
Exemple #11
0
        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboType.SelectedValue == null || isLoading)
            {
                return;
            }

            SplitType nextControlType = (SplitType)cboType.SelectedValue;

            if (nextControlType == SplitType.ManualSplit || nextControlType == SplitType.GameStart || nextControlType == SplitType.GameEnd || nextControlType == SplitType.HealthToken)
            {
                txtValue.Visible = false;
                cboValue.Visible = false;
                UserSplit.Value  = string.Empty;
            }
            else
            {
                if (nextControlType != UserSplit.Type)
                {
                    switch (nextControlType)
                    {
                    case SplitType.AreaEnter:
                    case SplitType.AreaExit: DefaultValue = SplitArea.Windhill; break;
                    }
                    UserSplit.Value = DefaultValue.ToString();
                }
                txtValue.Visible = false;
                cboValue.Visible = true;
            }
            UserSplit.Type = nextControlType;

            UpdateControls();
        }
Exemple #12
0
        /// <summary>
        /// Cubeを分割してCubeのリスト作成
        /// </summary>
        /// <param name="count">分割数</param>
        /// <param name="select">分割するCubeを選択する方法</param>
        /// <param name="split">Cubeを分割する方法</param>
        public void Split(int count, SelectType select, SplitType split)
        {
            Cubes.Clear();
            Cubes.Add(this);
            var confirmCubes = new List <Cube>();//これ以上分割できないCube隔離用

            while (Cubes.Count + confirmCubes.Count < count)
            {
                Cube cube = SelectCube(Cubes, select);
                var(cubeA, cubeB) = SplitCube(cube, split);
                if (cubeA.Pixels.Length == 0 || cubeB.Pixels.Length == 0)
                {
                    //分割できなかったCubeを隔離用リストに移動
                    confirmCubes.Add(cube);
                    Cubes.Remove(cube);
                    //分割できるCubeが尽きたらループ抜け
                    if (Cubes.Count == 0)
                    {
                        break;
                    }
                }
                else
                {
                    //分割できたCubeをリストから削除して、分割したCubeを追加
                    Cubes.Remove(cube);
                    Cubes.Add(cubeA);
                    Cubes.Add(cubeB);
                }
            }
            //隔離しておいたCubeを戻す
            foreach (var item in confirmCubes)
            {
                Cubes.Add(item);
            }
        }
    //返回总的页数
    public int TotalPage(short star, SplitType type = SplitType.None)
    {
        if (PageSize == 0)
        {
            return(0);
        }
        else
        {
            if (StarOfEquips.ContainsKey(star))
            {
                switch (type)
                {
                case SplitType.Split_If_InCurTeam:
                    return((int)Math.Ceiling((StarOfEquips[star].Count - Core.Data.playerManager.RTData.curTeam.equipSplitByStar(star)) * 1.0f / PageSize));

                case SplitType.Split_If_InTeam:
                    return((int)Math.Ceiling((StarOfEquips[star].Count - Core.Data.playerManager.RTData.EquipSplitByStar(star)) * 1.0f / PageSize));

                case SplitType.None:
                    return((int)Math.Ceiling(StarOfEquips[star].Count * 1.0f / PageSize));

                default:
                    return((int)Math.Ceiling(StarOfEquips[star].Count * 1.0f / PageSize));
                }
            }
            else
            {
                return(0);
            }
        }
    }
Exemple #14
0
 public static String[] SplitBy(this String str, SplitType splitType = SplitType.NewLine)
 {
     return(splitType switch
     {
         SplitType.NewLine => str.Split('\n', StringSplitOptions.RemoveEmptyEntries),
         SplitType.UpperCase => SplitByUpperCase(str),
         _ => throw new NotSupportedException()
     });
Exemple #15
0
        private void splitTypeComboBox_DropDownClosed(object sender, EventArgs e)
        {
            splitType = (SplitType)splitTypeComboBox.SelectedIndex;
            bigEndianCheckbox.Visible = splitType != SplitType.BinDLL && splitType != SplitType.NB;
            bigEndianCheckbox.Enabled = bigEndianCheckbox.Visible;

            SetControls();
        }
Exemple #16
0
 //important to be in start because the camera manager needs the camera scripts before they are deactivated
 void Start()
 {
     //store all presets into array
     SetCameraValuesAfterEnum();
     //init
     SetSplitTypeValues();
     type = Type;
 }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the Split class
 /// </summary>
 /// <param name="symbol">The symbol</param>
 /// <param name="date">The date</param>
 /// <param name="price">The price at the time of the split</param>
 /// <param name="splitFactor">The split factor to be applied to current holdings</param>
 /// <param name="type">The type of split event, warning or split occurred</param>
 public Split(Symbol symbol, DateTime date, decimal price, decimal splitFactor, SplitType type)
     : this()
 {
     Type           = type;
     Time           = date;
     Symbol         = symbol;
     ReferencePrice = price;
     SplitFactor    = splitFactor;
 }
Exemple #18
0
 // Update is called once per frame
 void Update()
 {
     //set in update for testing!!!! ONLY !!!!
     if (type != Type)
     {
         SetSplitTypeValues();
         type = Type;
     }
 }
Exemple #19
0
        private (Cube cubeA, Cube cubeB) SplitCube(Cube cube, SplitType split)
        {
            var  pixA = new List <byte>();
            var  pixB = new List <byte>();
            Cube cuA  = null;
            Cube cuB  = null;

            if (split == SplitType.SideCenter)
            {
                if (cube.IsCalcMinMax == false)
                {
                    CalcMinMax(cube);
                }
                int mid = (int)((cube.Max + cube.Min) / 2.0);
                foreach (var item in cube.Pixels)
                {
                    if (item > mid)
                    {
                        pixA.Add(item);
                    }
                    else
                    {
                        pixB.Add(item);
                    }
                }
                cuA = new Cube(pixA.ToArray());
                cuB = new Cube(pixB.ToArray());
            }
            else if (split == SplitType.Median)
            {
                if (cube.IsPixelsSorted == false)
                {
                    //Array.Sort(cube.Pixels);
                    cube.SortedPixels = new byte[cube.Pixels.Length];
                    Array.Copy(cube.Pixels, cube.SortedPixels, cube.Pixels.Length);
                    Array.Sort(cube.SortedPixels);
                    IsPixelsSorted = true;
                }
                int mid = cube.SortedPixels[cube.SortedPixels.Length / 2];

                foreach (var item in cube.Pixels)
                {
                    if (item > mid)
                    {
                        pixA.Add(item);
                    }
                    else
                    {
                        pixB.Add(item);
                    }
                }
                cuA = new Cube(pixA.ToArray());
                cuB = new Cube(pixB.ToArray());
            }
            return(cuA, cuB);
        }
        public string[] GetTableNames(SplitType splitType)
        {
            List <string> result = new List <string>();;

            foreach (var item in Items)
            {
                result.Add(Helper.GetTableName(Helper.GetValue(splitType, item)));
            }
            return(result.ToArray());
        }
        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboType.SelectedValue == null || isLoading)
            {
                return;
            }

            SplitType nextControlType = (SplitType)cboType.SelectedValue;

            if (nextControlType == SplitType.ManualSplit || nextControlType == SplitType.GameStart || nextControlType == SplitType.GameEnd || nextControlType == SplitType.SaveStone)
            {
                txtValue.Visible = false;
                cboValue.Visible = false;
                UserSplit.Value  = string.Empty;
            }
            else if (nextControlType == SplitType.Level)
            {
                if (nextControlType != UserSplit.Type)
                {
                    UserSplit.Value = "1";
                }
                txtValue.Visible = true;
                cboValue.Visible = false;
            }
            else
            {
                if (nextControlType != UserSplit.Type)
                {
                    switch (nextControlType)
                    {
                    case SplitType.AreaEnter:
                    case SplitType.AreaExit: DefaultValue = SplitArea.Overworld; break;

                    case SplitType.Chest: DefaultValue = SplitChest.BraveCaveNormal; break;

                    case SplitType.DungeonComplete: DefaultValue = SplitDungeon.BraveCave; break;

                    case SplitType.Key: DefaultValue = SplitKey.ArcaneHeadpawters; break;

                    case SplitType.QuestStart:
                    case SplitType.QuestComplete: DefaultValue = SplitQuest.Tutorial; break;

                    case SplitType.RoyalArt: DefaultValue = SplitRoyalArt.RollAttack; break;

                    case SplitType.Spell: DefaultValue = SplitSpell.Flamepurr; break;
                    }
                    UserSplit.Value = DefaultValue.ToString();
                }
                txtValue.Visible = false;
                cboValue.Visible = true;
            }
            UserSplit.Type = nextControlType;

            UpdateControls();
        }
Exemple #22
0
        //減色パレット作成
        private void MakePaletteColor(int colorCount)
        {
            if (MyOriginPixels == null)
            {
                return;
            }

            var sw = new Stopwatch();

            sw.Start();

            SelectType selecter = (SelectType)ComboBoxSelectType.SelectedItem;
            SplitType  splitter = (SplitType)ComboBoxSplitType.SelectedItem;
            var        cube     = new Cube(MyOriginPixels);

            cube.Split(colorCount, selecter, splitter);//分割数指定でCube分割

            //Cubeから色取得して、色データ作成
            List <Color> colors = cube.GetColors((ColorSelectType)ComboBoxColorSelectType.SelectedItem);

            //Palette作成して表示
            Palette palette = new Palette(colors);

            MyPalettes.Add(palette);

            var button = new Button()
            {
                Content = "減色"
            };

            button.Click += ButtonGensyoku_Click;
            var panel = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            panel.Children.Add(button);
            panel.Children.Add(palette);
            MyStackPanel.Children.Add(panel);

            MyDictionary.Add(button, palette);

            sw.Stop();
            //TextBlockTime.Text = $"{sw.Elapsed.TotalSeconds.ToString("F3")}";
            //↑は↓と同じ、F3は小数点以下3桁まで表示の意味
            //TextBlockTime.Text = $"{sw.Elapsed.TotalSeconds:F3}";
            TextBlockTime.Text = $"{sw.Elapsed.TotalSeconds:F3}(パレット作成時間)";

            ////色データ表示用のlistboxを作成して表示
            //ListBox list = CreateListBox();
            //list.DataContext = data;
            ////MyStackPanel.Children.Add(list);
            //MyStackPanel.Children.Add(MakePanelPalette(list, colors.Count));
        }
Exemple #23
0
 public static Splitter CreateSplitter(SplitType type, Filter filter)
 {
     switch (type)
     {
     case SplitType.Character:
         return new CharacterSplitter(filter);
     case SplitType.Line:
         return new LineSplitter(filter);
     }
     return null;
 }
Exemple #24
0
        private void PrepareReceipts(decimal amount, int splitnumber, SplitType stype)
        {
            switch (stype)
            {
            case SplitType.Evenly:

                decimal splitamount = (decimal)amount / splitnumber;

                var evenlylist = Enumerable
                                 .Range(1, splitnumber)
                                 .Select(n => new ReceiptSplitVM {
                    Amount = splitamount, Title = string.Format("Receipt #{0}", n)
                })
                                 .ToList();

                if (evenlylist.Any())
                {
                    evenlylist[0].IsActive = true;
                }


                ReceiptSplits = evenlylist;
                _activeSplit  = evenlylist[0];
                break;

            case SplitType.ByItems:

                ReceiptSplits = new List <ReceiptSplitVM>();
                _activeSplit  = null;
                break;

            case SplitType.ByAmount:

                Func <decimal, bool> validateamount = (enteredamount) => {
                    return(enteredamount <= RemainedAmount);
                };

                var byamountlist = Enumerable
                                   .Range(1, splitnumber)
                                   .Select(n => new ReceiptSplitVM {
                    Amount = 0.00m, ValidateAmount = validateamount, IsCustomValue = true, Title = string.Format("Receipt #{0}", n)
                })
                                   .ToList();

                if (byamountlist.Any())
                {
                    byamountlist[0].IsActive = true;
                }

                ReceiptSplits = byamountlist;
                _activeSplit  = byamountlist[0];
                break;
            }
        }
 public void AddSplit(SplitType type, string previous = "", string next = "")
 {
     if (type == SplitType.User)
     {
         Transitions.Add(new SplitEvent(type, previous, previous));
     }
     else
     {
         Transitions.Add(new SplitEvent(type, previous, next));
         HasJustAutoSplit = true;
     }
 }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (ProgressDialog progress = new ProgressDialog("Splitting", splitControls.Count, false, true))
            {
                foreach (SplitUIControl splitControl in splitControls)
                {
                    string shortName = Path.GetFileName(splitControl.GetFilePath());

                    progress.SetStep(shortName);

                    string outputFolder = splitControl.GetOutputFolder();

                    SplitType splitType = splitControl.GetSplitType();

                    switch (splitType)
                    {
                    case SplitType.BinDLL:
                        // do our normal split
                        SplitData splitData = new SplitData()
                        {
                            dataFile = splitControl.GetFilePath(),
                            iniFile  = splitControl.GetDataMappingPath()
                        };

                        string oldEnvironment = Environment.CurrentDirectory;

                        Environment.CurrentDirectory = Path.GetDirectoryName(splitData.dataFile);
                        BinSplitData_Sub(splitData, outputFolder);

                        break;

                    case SplitType.MDL:
                        SA_Tools.SAArc.sa2MDL.Split(splitControl.IsBigEndian(), splitControl.GetFilePath(),
                                                    outputFolder, splitControl.AnimFiles);
                        break;

                    case SplitType.MTN:
                        // use the command line split
                        break;

                    case SplitType.NB:
                        // use the command line split
                        break;

                    default:
                        break;
                    }

                    progress.StepProgress();
                }
            }
        }
        //指定色数に分割したCube作成
        private Cube MakeSplittedCube(int colorCount)
        {
            if (MyOriginBitmap == null)
            {
                return(null);
            }
            SelectType selecter = (SelectType)ComboBoxSelectType.SelectedItem;
            SplitType  splitter = (SplitType)ComboBoxSplitType.SelectedItem;
            var        cube     = new Cube(MyOriginBitmap);

            cube.Split(colorCount, selecter, splitter);//分割数指定でCube分割
            return(cube);
        }
Exemple #28
0
        /// <summary>
        /// 获取下个表名
        /// </summary>
        /// <param name="type">分表类型</param>
        /// <param name="format">分表模板</param>
        /// <returns>结果</returns>
        private string GetNextTableName(SplitType type, string format)
        {
            switch (type)
            {
            case SplitType.Day: return(DateTime.Now.AddDays(1).ToString(format));

            case SplitType.Month: return(DateTime.Now.AddMonths(1).ToString(format));

            case SplitType.Year: return(DateTime.Now.AddYears(1).ToString(format));

            default: return(string.Empty);
            }
        }
        /// <summary>
        /// Generates pages from a string, and puts them in message embeds.
        /// </summary>
        /// <param name="input">Input string.</param>
        /// <param name="splittype">How to split input string.</param>
        /// <param name="embedbase">Base embed for output embeds.</param>
        /// <returns></returns>
        public Page[] GeneratePagesInEmbed(string input, SplitType splittype = SplitType.Character, DiscordEmbedBuilder embedbase = null)
        {
            if (String.IsNullOrEmpty(input))
            {
                throw new ArgumentException("You must provide a string that is not null or empty!");
            }

            var embed = embedbase ?? new DiscordEmbedBuilder();

            List <Page>   result = new List <Page>();
            List <string> split;

            switch (splittype)
            {
            default:
            case SplitType.Character:
                split = SplitString(input, 500).ToList();
                break;

            case SplitType.Line:
                var subsplit = input.Split('\n');

                split = new List <string>();
                string s = "";

                for (int i = 0; i < subsplit.Length; i++)
                {
                    s += $"{subsplit[i]}\n";
                    if (i % 15 == 0 && i != 0)
                    {
                        split.Add(s);
                        s = "";
                    }
                }
                if (!split.Any(x => x == s))
                {
                    split.Add(s);
                }
                break;
            }

            int page = 1;

            foreach (string s in split)
            {
                result.Add(new Page("", new DiscordEmbedBuilder(embed).WithDescription(s).WithFooter($"Page {page}/{split.Count}")));
                page++;
            }

            return(result.ToArray());
        }
Exemple #30
0
        /// <summary>
        /// ファクトリメソッド
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static DiffLogic CreateDiff(DiffLogicType diffType, SplitType splitType, string fileName)
        {
            var filter = Filter.CreteFilter(fileName);
            var splitter = Splitter.CreateSplitter(splitType, filter);
            if (splitter == null)
                return null;

            switch (diffType)
            {
            case DiffLogicType.Simple:
                return new SimpleDiffLogic(splitter);
            }
            return null;
        }
        public static Rectangle[] SplitInParts(Rectangle xRec, int Parts, SplitType xSplitType)
        {
            Rectangle[] xOutput = null;
            switch (xSplitType)
            {
            case SplitType.Horizontal:
                xOutput = MyRectangle.SplitHorizontalInParts(xRec, Parts);
                break;

            case SplitType.Vertical:
                break;
            }
            return(xOutput);
        }
        public static Rectangle[] SplitByPercent(Rectangle xRec, int[] Percents, SplitType xSplitType)
        {
            Rectangle[] xOutput = null;
            switch (xSplitType)
            {
            case SplitType.Horizontal:
                xOutput = MyRectangle.SplitHorizontalByPercent(xRec, Percents);
                break;

            case SplitType.Vertical:
                break;
            }
            return(xOutput);
        }
Exemple #33
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="savePath"></param>
        /// <param name="splitType"></param>
        public FileLogWriter(string savePath, SplitType splitType = SplitType.StNone)
        {
            _savePath = Directory.Exists(savePath)
                ? savePath
                : Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            _splitType = splitType;

            _filePath = FileNameHelper.GenerateFileNameFromSplitType(savePath, splitType);
            bool loadSuccess = false;
            if (File.Exists(_filePath))
                loadSuccess = Load();

            if (!loadSuccess)
                Logs = new List<LogInfo>();
        }
Exemple #34
0
        /// <summary>
        /// Generaet file name by given split type
        /// 
        /// we have multipile SplitType that define strategy of save log in FileLogWriter class
        /// such as Daily, Weekly and monthly log file sepration
        /// </summary>
        /// <param name="savePath">Base file path</param>
        /// <param name="splitType">split type wich file name must generate according it</param>
        /// <returns>Generated file path</returns>
        public static string GenerateFileNameFromSplitType(string savePath, SplitType splitType)
        {
            string fileName;

            switch (splitType)
            {
                // Daily file name
                case SplitType.StDaily:
                    {
                        string dayName = DateTime.Now.ToString("dd_MM_yyyy");
                        fileName = Path.Combine(savePath, dayName);
                        break;
                    }

                // Weekly file name
                case SplitType.StWeekly:
                    {
                        string weekName = string.Format("Week {0} of {1}", GetWeekNumberOfMonth(DateTime.Now), DateTime.Now.ToString("MM_yyyy"));
                        fileName = Path.Combine(savePath, weekName);
                        break;
                    }

                // Monthly file name
                case SplitType.StMonthly:
                    {
                        string monthName = DateTime.Now.ToString("MM_yyyy");
                        fileName = Path.Combine(savePath, monthName);
                        break;
                    }

                // Default file name
                default:
                    fileName = Path.Combine(savePath, Resources.DefaultLogFileName);
                    break;
            }

            // Add file extension to name and return it to caller
            return fileName + Resources.QuickLogFileExtension;
        }
        public static EquationSegment SplitEquation(string equation, int splitIndex, SplitType sideToGet)
        {
            var retStruct = new EquationSegment();
            char beginningBracket;
            char endingBracket;
            int increment;
            int limitValue;

            if (splitIndex == 0 && (sideToGet == SplitType.LeftSide || sideToGet == SplitType.ExponentLeft)){
                retStruct.EndIndex = 0;
                retStruct.StartIndex = 0;
                retStruct.Segment = "";
                return retStruct;
            }

            if (sideToGet == SplitType.LeftSide || sideToGet == SplitType.ExponentLeft){
                beginningBracket = ')';
                endingBracket = '(';
                increment = -1;
                limitValue = -1;
            }
            else{
                beginningBracket = '(';
                endingBracket = ')';
                increment = 1;
                limitValue = equation.Count();
            }

            //the left side is enclosed with brackets, so the only way to terminate the left side is with an opening bracket
            if (equation[splitIndex + increment] == beginningBracket){
                int totalBrackets = 1;
                int index = splitIndex + increment;
                while (totalBrackets != 0){
                    index += increment;
                    if (index == limitValue)
                        throw new Exception("formatting error, brackets not set up properly");

                    if (equation[index] == beginningBracket){
                        totalBrackets++;
                    }
                    if (equation[index] == endingBracket){
                        totalBrackets--;
                    }
                }

                if (sideToGet == SplitType.LeftSide || sideToGet == SplitType.ExponentLeft){
                    retStruct.EndIndex = splitIndex;
                    retStruct.StartIndex = index;
                    retStruct.Segment = equation.Substring(retStruct.StartIndex, retStruct.EndIndex - retStruct.StartIndex);
                }
                else{
                    retStruct.EndIndex = index + 1;
                    retStruct.StartIndex = splitIndex + 1;
                    retStruct.Segment = equation.Substring(retStruct.StartIndex, retStruct.EndIndex - retStruct.StartIndex);
                }
                return retStruct;
            }
            else{
                //for this case, order of operations must be respected because of lack of brackets
                //there are two ways for a termination to occur, either one of the terminating characters is reached
                //or an unexpected endingbracket is reached, such as in the case (x/y)

                int index = splitIndex + increment;

                char[] terminatingChars = new char[0];
                bool ignoreCharacterTermination = false;
                bool ignoreBracketTermination = false;
                if (sideToGet == SplitType.LeftSide){
                    terminatingChars = new[]{'=', '+', '-'};
                }
                if (sideToGet == SplitType.RightSide){
                    terminatingChars = new[]{'=', '+', '-', '*', '/'};
                }
                if (sideToGet == SplitType.ExponentRight){
                    terminatingChars = new[]{'=', '+', '-', '*', '/'};
                    if (equation[index] == beginningBracket){ //this expression may be always false
                        ignoreCharacterTermination = true;
                    }
                    else{
                        index++; //we want to completely ignore the first character because of negatives
                        ignoreBracketTermination = true;
                    }
                }
                if (sideToGet == SplitType.ExponentLeft){
                    terminatingChars = new[]{'=', '+', '-', '*', '/'};
                }

                int totalBrackets = 0;
                if (index < equation.Count()){
                    while (true){
                        //first try character based termination
                        if (terminatingChars.Contains(equation[index])){
                            if (!ignoreCharacterTermination){
                                break;
                            }
                        }

                        //now try bracket based termination
                        if (equation[index] == beginningBracket){
                            if (!ignoreBracketTermination){
                                totalBrackets++;
                            }
                        }

                        if (equation[index] == endingBracket){
                            if (!ignoreBracketTermination){
                                totalBrackets--;
                            }
                        }

                        if (totalBrackets < 0){
                            //index -= increment;
                            break;
                        }

                        //nothing interesting, loop again
                        if (index == limitValue - increment){
                            index += increment;
                            break;
                        }
                        //firstCharacterException = false;
                        index += increment;
                    }
                }
                if (sideToGet == SplitType.LeftSide || sideToGet == SplitType.ExponentLeft){
                    retStruct.EndIndex = splitIndex;
                    retStruct.StartIndex = index + 1;
                    retStruct.Segment = equation.Substring(retStruct.StartIndex, retStruct.EndIndex - retStruct.StartIndex);
                }
                else{
                    retStruct.EndIndex = index;
                    retStruct.StartIndex = splitIndex + 1;
                    retStruct.Segment = equation.Substring(retStruct.StartIndex, retStruct.EndIndex - retStruct.StartIndex);
                }
                return retStruct;
            }
        }
        private void EvaluteHeader(string line)
        {
            headerLine = line;
            SplitTypeCount c = headerCount = CountChars(line);

            if (QuoteChar != QuoteChar.None)
                c.spaces = 0;

            if (c.tabs >= c.kommas && c.tabs >= c.semikolons && c.tabs >= c.spaces)
                UsedSplitType = SplitType.Tab;
            else if (c.kommas >= c.tabs && c.kommas >= c.semikolons && c.kommas >= c.spaces)
                UsedSplitType = SplitType.Komma;
            else if (c.semikolons >= c.spaces)
                UsedSplitType = SplitType.Semikolon;
            else if (c.spaces > 0)
                UsedSplitType = SplitType.Space;
            else
                throw new IOException("unable to determine CSV-dialect");
        }
        public void Feed(string line, int lineNo)
        {
            if (lineNo == 0)
            {
                EvaluteHeader(line);
                return;
            }

            if (lineNo == 1)
            {
                //int curColCount = splitter.Split(line).Length;

                if (splitType == SplitType.Space)
                {
                    // Resurrect on wrong counted spaces in header
                    SplitTypeCount c = CountChars(line);
                    if (c.spaces == 0)
                    {
                        c = headerCount;
                        if (c.tabs >= c.kommas && c.tabs >= c.semikolons)
                            UsedSplitType = SplitType.Tab;
                        else if (c.kommas >= c.tabs && c.kommas >= c.semikolons)
                            UsedSplitType = SplitType.Komma;
                        else if (c.semikolons > 0)
                            UsedSplitType = SplitType.Semikolon;
                    }
                }
                //// allow wired files with space delimiter on all but first line,
                //// there tab.
                //if (splitter.Split(line).Length <= 1)
                //{
                //    splitType = SplitType.TabAndSpace;
                //    splitter = new Regex("[ \t]+");
                //}
            }
        }
        public void Split()
        {
            Random rand = MapGeneratorBSP.rand;
            split = SplitType.Vertical;

            //Long thin areas are more likely to be split widthways and vice versa
            if(rand.Next(width + height) < width) {
                split = SplitType.Horizontal;
            }

            if (split == SplitType.Horizontal)
            {
                //Small chance that we don't recurse any further
                int chanceNoSplitHoriz = mustSplitSize - (width / minBSPSquareWidth);
                if (rand.Next(noSplitChance) < chanceNoSplitHoriz)
                {
                    childLeft = null;
                    childRight = null;
                    return;
                }

                int minSplit = (int)(width * minimumSplit);
                int maxSplit = (int)(width * maximumSplit);

                actualSplit = minSplit + rand.Next(maxSplit - minSplit + 1);

                //Define the two child areas, make objects and then recursively split them

                if (actualSplit < minBSPSquareWidth)
                {
                    childLeft = null;
                }
                else
                {
                    childLeft = new MapNode(parentGenerator, x, y, actualSplit, height);
                    childLeft.Split();
                }

                if (width - actualSplit < minBSPSquareWidth)
                {
                    childRight = null;
                }
                else
                {
                    childRight = new MapNode(parentGenerator, x + actualSplit, y, width - actualSplit, height);
                    childRight.Split();
                }
            }
            else {
                //SplitType.Vertical

                //Small chance that we don't recurse any further
                int chanceNoSplitVert = mustSplitSize - (height / minBSPSquareHeight);
                if (rand.Next(noSplitChance) < chanceNoSplitVert)
                {
                    childLeft = null;
                    childRight = null;
                }

                int minSplit = (int)(height * minimumSplit);
                int maxSplit = (int)(height * maximumSplit);

                actualSplit = minSplit + rand.Next(maxSplit - minSplit + 1);

                //Define the two child areas, make objects and then recursively split them

                if (actualSplit < minBSPSquareHeight)
                {
                    childLeft = null;
                }
                else
                {
                    childLeft = new MapNode(parentGenerator, x, y, width, actualSplit);
                    childLeft.Split();
                }

                if (height - actualSplit < minBSPSquareHeight)
                {
                    childRight = null;
                }
                else
                {
                    childRight = new MapNode(parentGenerator, x, y + actualSplit, width, height - actualSplit);
                    childRight.Split();
                }
            }
        }
 public SplitFile()
 {
     InitializeComponent();
     FileSize = 1;
     type = SplitType.AllInOne;
 }
 private void radioSplitFile_CheckedChanged(object sender, EventArgs e)
 {
     cmbSplitFileSize.Enabled = true;
     type = SplitType.Split;
 }
 private void radioSplitOne_CheckedChanged(object sender, EventArgs e)
 {
     cmbSplitFileSize.Enabled = false;
     type = SplitType.AllInOne;
 }