Ejemplo n.º 1
0
        /// <summary>
        /// おじゃまスライムの変換を行います。
        /// </summary>
        /// <param name="value">おじゃまスライムの文字列</param>
        /// <returns>変換したおじゃまスライム情報</returns>
        private static Dictionary <ObstructionSlime, int>[] ParseObstructionSlime(string value)
        {
            var result = new Dictionary <ObstructionSlime, int> [Player.Length];

            Func <char[], Dictionary <ObstructionSlime, int> > parse = (vals) =>
            {
                var dic = new Dictionary <ObstructionSlime, int>();
                foreach (var ob in Enum.GetValues(typeof(ObstructionSlime)))
                {
                    dic.Add((ObstructionSlime)ob, 0);
                }

                foreach (var val in vals)
                {
                    var key = SimpleText.ConvertObstructionSlime(val);
                    dic[key] += 1;
                }
                return(dic);
            };

            var values = value.Split(SimpleText.Separator.Player);

            result[(int)Player.Index.First]  = parse(values[(int)Player.Index.First].ToCharArray());
            result[(int)Player.Index.Second] = parse(values[(int)Player.Index.Second].ToCharArray());

            return(result);
        }
Ejemplo n.º 2
0
 public CommonPropertyEditor(IPropertyEditorParams editorParams)
 {
     EditorParams    = editorParams;
     ContainerWidget = new Widget {
         Layout = new HBoxLayout {
             IgnoreHidden = false
         },
         LayoutCell = new LayoutCell {
             StretchY = 0
         },
     };
     editorParams.InspectorPane.AddNode(ContainerWidget);
     if (editorParams.ShowLabel)
     {
         PropertyLabel = new ThemedSimpleText {
             Text           = editorParams.DisplayName ?? editorParams.PropertyName,
             VAlignment     = VAlignment.Center,
             LayoutCell     = new LayoutCell(Alignment.LeftCenter, stretchX: 0),
             ForceUncutText = false,
             MinWidth       = 120,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = true,
             TabTravesable  = new TabTraversable()
         };
         PropertyLabel.Tasks.Add(ManageLabelTask());
         ContainerWidget.AddNode(PropertyLabel);
     }
 }
Ejemplo n.º 3
0
 private void Previous()
 {
     for (int i = 0; i < menuEntries.Count; i++)
     {
         if (menuEntries[i] is ColoredText)
         {
             if (i == 0)
             {
                 menuEntries[0] = new SimpleText(Game, menuEntries[0].Text, false, menuEntries[0].Name);
                 menuEntries[menuEntries.Count - 1] = new ColoredText(Game,
                                                                      menuEntries[menuEntries.Count - 1].Text,
                                                                      false,
                                                                      menuEntries[menuEntries.Count - 1].Name);
             }
             else
             {
                 menuEntries[i]     = new SimpleText(Game, menuEntries[i].Text, false, menuEntries[i].Name);
                 menuEntries[i - 1] = new ColoredText(Game, menuEntries[i - 1].Text, false,
                                                      menuEntries[i - 1].Name);
             }
             SetPositionsAfterEntarence();
             return;
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// NEXTスライムの変換を行います。
        /// </summary>
        /// <param name="value">フィールドを示す文字列</param>
        /// <returns>NEXTスライムの情報</returns>
        private static Slime[][][] ParseNextSlimes(string value)
        {
            var nextSlimes = new Slime[Player.Length][][];
            Action <Player.Index> initialize = (player) =>
            {
                nextSlimes[(int)player] = new Slime[NextSlime.Length][];
                nextSlimes[(int)player][(int)NextSlime.Index.First]  = new Slime[MovableSlime.Length];
                nextSlimes[(int)player][(int)NextSlime.Index.Second] = new Slime[MovableSlime.Length];
            };

            initialize(Player.Index.First);
            initialize(Player.Index.Second);

            var values = SplitNewLine(value);

            for (var i = 0; i < values.Length; i++)
            {
                if (!SimpleText.ContainsNextSlimeInfo(i))
                {
                    // NEXTスライム情報が存在しない行なのでスキップ
                    continue;
                }

                var nextSlimeLine = values[i].Split(SimpleText.Separator.Player)[(int)FieldIndex.NextSlime].ToCharArray();
                Debug.Assert(nextSlimeLine.Length == NextSlime.Length, "NEXTスライムの数が不正です。数:" + nextSlimeLine.Length);
                var nextSlimeIndex        = SimpleText.ConvertNextSlimeIndex(i);
                var movableSlimeUnitIndex = SimpleText.ConvertMovableSlimeUnitIndex(i);
                nextSlimes[(int)Player.Index.First][(int)nextSlimeIndex][(int)movableSlimeUnitIndex]  = SimpleText.ConvertSlime(nextSlimeLine[(int)Player.Index.First]);
                nextSlimes[(int)Player.Index.Second][(int)nextSlimeIndex][(int)movableSlimeUnitIndex] = SimpleText.ConvertSlime(nextSlimeLine[(int)Player.Index.Second]);
            }

            return(nextSlimes);
        }
Ejemplo n.º 5
0
        public void LoadReplayAndStart(SoundodgerLevel level, Replay replay,
                                       LevelSettings settings)
        {
            player    = new ReplayingPlayer(replay);
            Replay    = replay;
            ActiveMod = replay.Mod;

            hitIterator = new TimeIter <TsVal <InvincibilityType> >(
                replay.Hits, x => x.Time, OnNewHit);
            slomoIterator = new TimeIter <TsVal <bool> >(
                replay.SlomoToggles, x => x.Time, OnNewSlomo);

            BurstShot.InitRandom(replay.BurstSeed);

            watchingReplayText = new SimpleText
            {
                Text     = $"[ replay ]",
                Font     = Fonts.Content.Orkney13,
                Color    = new Color(Color.Gray, 0.8f),
                Position = new Vector2(NoisEvader.ScreenBounds.Width * 0.5f,
                                       NoisEvader.ScreenBounds.Height * 0.95f),
                YOrigin = YOrigin.Center,
                XOrigin = XOrigin.Center
            };

            InitAndStart(level, ActiveMod, settings);
        }
Ejemplo n.º 6
0
        public void TabstopTest()
        {
            //Create new document
            TextDocument document = new TextDocument();

            document.New();
            //Create new paragraph
            Paragraph par = new Paragraph(document, "P1");
            //Create a new TabStopStyle collection
            TabStopStyleCollection tsc = new TabStopStyleCollection(document);
            //Create TabStopStyles
            TabStopStyle ts = new TabStopStyle(document, 4.98);

            ts.LeaderStyle = TabStopLeaderStyles.Dotted;
            ts.LeaderText  = ".";
            ts.Type        = TabStopTypes.Center;
            //Add the tabstop
            tsc.Add(ts);
            //Append the TabStopStyleCollection
            ((ParagraphStyle)par.Style).Properties.TabStopStyleCollection = tsc;
            //Add some text, use @ qualifier when ever you use control chars!
            string     mytebstoptext = @"Hello\tHello again";
            SimpleText stext         = new SimpleText(par, mytebstoptext);

            //the simple text
            par.TextContent.Add(stext);
            //Add the paragraph to the content container
            document.Content.Add(par);
            //Save
            document.SaveTo("tabstop.odt");
        }
Ejemplo n.º 7
0
        public void GetLatex_CorrectLatexCode()
        {
            var element = new SimpleText("Simple text test!");
            var latex   = element.GetLatex();

            Assert.Equal("Simple text test!", latex);
        }
Ejemplo n.º 8
0
            public PanelTab()
            {
                MinSize    = new Vector2(TabMinWidth, TabHeight);
                MaxSize    = new Vector2(TabMaxWidth, TabHeight);
                LayoutCell = new LayoutCell(Alignment.LeftTop);
                Size       = MinSize;
                Layout     = new HBoxLayout();
                var caption = new SimpleText {
                    Id             = "TextPresenter",
                    Padding        = Theme.Metrics.ControlsPadding,
                    ForceUncutText = false,
                    FontHeight     = Theme.Metrics.TextHeight,
                    HAlignment     = HAlignment.Center,
                    VAlignment     = VAlignment.Center,
                    OverflowMode   = TextOverflowMode.Ellipsis,
                    LayoutCell     = new LayoutCell(Alignment.Center),
                };
                var presenter = new TabPresenter(caption);

                CompoundPresenter.Add(presenter);
                DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                    OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                        presenter.SetState(markerId);
                        return(true);
                    }
                };
                AddNode(caption);
                HitTestTarget = true;
                LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
                this.AddChangeWatcher(() => Active,
                                      isActive => Padding = isActive ? new Thickness {
                    Top = -1f, Bottom = 1f
                } : new Thickness());
            }
Ejemplo n.º 9
0
        public void AppendComplexText()
        {
            var text   = "abc";
            var head   = new SimpleText(text, 0, 1);
            var tail   = new ComplexText(new[] { new SimpleText(text, 2, 1) });
            var result = head.AppendComplexText(tail);

            Assert.IsTrue(result == "ac");
            Assert.IsFalse(result is SimpleText);

            text   = "abc";
            head   = new SimpleText(text, 0, 2);
            tail   = new ComplexText(new[] { new SimpleText(text, 1, 2) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abbc");
            Assert.IsFalse(result is SimpleText);

            text   = "abc";
            head   = new SimpleText(text, 0, 1);
            tail   = new ComplexText(new[] { new SimpleText(text, 1, 2) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);

            text   = "abc";
            head   = new SimpleText(text, 0, 2);
            tail   = new ComplexText(new[] { new SimpleText(text, 2, 1) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);
        }
Ejemplo n.º 10
0
        public KeyboardButton(Key key) : base()
        {
            Presenter     = new KeyboardButtonPresenter();
            TabTravesable = null;
            var caption = Nodes.First(i => i.Id == "TextPresenter") as SimpleText;

            caption.VAlignment = VAlignment.Bottom;
            caption.HAlignment = HAlignment.Left;
            caption.Padding    = new Thickness(5, 2);
            caption.TextColor  = ColorTheme.Current.Keyboard.GrayText;
            commandName        = new SimpleText {
                TextColor    = ColorTheme.Current.Keyboard.BlackText,
                FontHeight   = Theme.Metrics.TextHeight,
                HAlignment   = HAlignment.Left,
                VAlignment   = VAlignment.Top,
                OverflowMode = TextOverflowMode.Ellipsis,
                Padding      = new Thickness(5, 2)
            };
            Nodes.Add(commandName);
            commandName.ExpandToContainerWithAnchors();
            commandName.Height -= caption.FontHeight;

            Key = key;
            (Presenter as KeyboardButtonPresenter).IsModifier = Key.IsModifier();
            State = KeyboardButtonState.None;
        }
Ejemplo n.º 11
0
        public void AppendSimpleText()
        {
            var text   = "abc";
            var head   = new ComplexText(new SimpleText(text, 0, 1));
            var tail   = new SimpleText(text, 2, 1);
            var result = head.AppendSimpleText(tail);

            Assert.IsTrue(result == "ac");
            Assert.IsTrue((result as ComplexText).texts.Count == 2);

            text   = "abc";
            head   = new ComplexText(new SimpleText(text, 0, 2));
            tail   = new SimpleText(text, 1, 2);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abbc");
            Assert.IsTrue((result as ComplexText).texts.Count == 2);

            text   = "abc";
            head   = new ComplexText(new SimpleText(text, 0, 1));
            tail   = new SimpleText(text, 1, 2);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);

            text   = "abc";
            head   = new ComplexText(new SimpleText(text, 0, 2));
            tail   = new SimpleText(text, 2, 1);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);
        }
Ejemplo n.º 12
0
        public IActionResult DeleteConfirmed(int id)
        {
            SimpleText simpleText = _simpleTextService.GetById(id);

            _simpleTextService.Delete(simpleText);
            _simpleTextService.Commit();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        private void UpdateVolume()
        {
            SimpleText  vol_info_text    = App.GetElemByName("Volume_Progress_Text") as SimpleText;
            ProgressBar vol_progress_bar = App.GetElemByName("Volume_Bar") as ProgressBar;

            vol_info_text.String   = Convert.ToInt32(Volume) + "%";
            vol_progress_bar.Value = Volume;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Преобразования объекта типв <see cref="StyleType"/> в html
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static string ToHtml(this StyleType item)
 {
     return(item switch {
         SimpleText text => text.ToHtml(),
         InternalLinkItem link => link.ToHtml(),
         InlineImageItem image => image.ToHtml(),
         _ => item.ToString()
     });
Ejemplo n.º 15
0
 public static SimpleText getInstance()
 {
     if (inst == null)
     {
         inst = new SimpleText();
     }
     return(inst);
 }
Ejemplo n.º 16
0
        public void Split()
        {
            var text = new SimpleText("", 0, 0);

            var split = text.Split(0);

            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(1));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("a", 0, 1);

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "a");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(2));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("__a__", 2, 1);
            Assert.IsTrue(text.ToString() == "a");

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "a");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(2));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("__abc__", 2, 3);
            Assert.IsTrue(text.ToString() == "abc");

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "abc");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "bc");

            split = text.Split(2);
            Assert.IsTrue(split.Head.ToString() == "ab");
            Assert.IsTrue(split.Tail.ToString() == "c");

            split = text.Split(3);
            Assert.IsTrue(split.Head.ToString() == "abc");
            Assert.IsTrue(split.Tail.ToString() == "");
        }
        /// <summary>
        /// Create a text with Capital Drop
        /// </summary>
        /// <param name="parent">parent container insert into</param>
        /// <param name="text">text to insert</param>
        private void AddAsDrop(List <IHTMLItem> parent, SimpleText text)
        {
            var span1 = new Span(HTMLElementType.XHTML11);

            SetClassType(span1, ElementStylesV2.CapitalDrop);
            int dropEnd = 0;

            // "pad" the white spaces so drop starts from visible character
            while (dropEnd < text.Text.Length && UnicodeHelpers.IsSpaceLike(text.Text[dropEnd]))
            {
                dropEnd++;
            }
            if (dropEnd >= text.Text.Length) // in case the text is too short for drop
            {
                parent.Add(new SimpleHTML5Text(HTMLElementType.XHTML11)
                {
                    Text = text.Text
                });
                return;
            }
            // calculate the initial drop part
            string dropPart = text.Text.Substring(0, dropEnd + 1);
            // non-drop part starts from the next character
            int nondropPosition = dropEnd + 1;

            // If first character is dash/hyphen like we need to add character to
            // capital drop so it looks better with next character
            if (UnicodeHelpers.IsNeedToBeJoinInDrop(dropPart[dropEnd]))
            {
                // we need to add to capital drop all spaces if any
                while (nondropPosition < text.Text.Length && UnicodeHelpers.IsSpaceLike(text.Text[nondropPosition]))
                {
                    nondropPosition++;
                }
                // we need to advance to include one following nonspace character , unless
                // we already at last character of the text
                if (nondropPosition < text.Text.Length)
                {
                    nondropPosition++;
                }
                // update drop part with the "string" we calculated
                dropPart += text.Text.Substring(dropEnd + 1, nondropPosition - dropEnd - 1);
            }
            span1.Add(new SimpleHTML5Text(HTMLElementType.XHTML11)
            {
                Text = dropPart
            });
            parent.Add(span1);
            string substring = text.Text.Substring(nondropPosition);

            if (substring.Length > 0)
            {
                parent.Add(new SimpleHTML5Text(HTMLElementType.XHTML11)
                {
                    Text = substring
                });
            }
        }
Ejemplo n.º 18
0
 public override void Dispose()
 {
     if (!base._isDisposed)
     {
         _value = null;
         GC.SuppressFinalize(this);
         base._isDisposed = !base._isDisposed;
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 情報の辞書を作成します。
        /// </summary>
        /// <param name="lines">標準テキストファイルの行配列</param>
        /// <returns>情報の辞書</returns>
        private static Dictionary <string, string> buildInfoDictionary(string[] lines)
        {
            var dic           = new Dictionary <string, string>();
            var infoIndex     = 0;
            var infoLength    = -1;
            var isInfoReading = false;
            var sb            = new StringBuilder();

            string[] keyValue = null;

            foreach (var line in lines)
            {
                // 情報行読み取り中ではないか?
                if (!isInfoReading)
                {
                    keyValue   = line.Split(SimpleText.Separator.KeyValue);
                    infoLength = SimpleText.GetInfoLength(keyValue[0]);

                    if (infoLength == SimpleText.Length.Default)
                    {
                        // 通常は1行にKeyValueがセットされている
                        dic.Add(keyValue[0], keyValue[1]);
                    }
                    else
                    {
                        // 複数行情報
                        isInfoReading = true;
                        infoIndex     = 1;
                        sb            = new StringBuilder();
                    }
                }
                else
                {
                    if (infoIndex >= infoLength - 1)
                    {
                        // 最終行
                        sb.Append(line);
                    }
                    else
                    {
                        // 最終行以外
                        sb.AppendLine(line);
                    }

                    infoIndex++;
                    if (infoIndex >= infoLength)
                    {
                        // 情報を終端まで読み込んだので、辞書に追加
                        dic.Add(keyValue[0], sb.ToString());
                        isInfoReading = false;
                    }
                }
            }

            return(dic);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var dte = (DTE2)ServiceProvider.GetService(typeof(DTE));

            var docFile      = dte.ActiveDocument.FullName;
            var selectedText = dte.Selection().Text;
            var imageText    = SimpleText.Parse(selectedText) as ImageText;

            if (imageText == null)
            {
                var docType = Path.GetExtension(docFile).ToLower();

                switch (docType)
                {
                case ".md":
                    imageText = MarkdownImageText.Parse(selectedText);
                    break;

                case ".js":
                case ".html":
                    imageText = HtmlImgText.Parse(selectedText);
                    break;
                }
            }

            if (imageText == null)
            {
                imageText = new SimpleText()
                {
                    Text = selectedText
                }
            }
            ;

            imageText.ParentWindow = new SimpleWindow(dte.MainWindow.HWnd);
            imageText.FullFilename = docFile;

            var newText = imageText.PasteFromClipboard();

            if (newText == null)
            {
                return;
            }

            if (newText.Length == 0)
            {
                dte.Selection().CharRight();
                return;
            }

            dte.BeginUpdate("paste image");

            dte.Selection().DestructiveInsert(newText);

            dte.EndUpdate();
        }
Ejemplo n.º 21
0
        public override void InitializeGame()
        {
            int size = 50000;

            // Setup world
            World.WorldSize.X   = size;
            World.WorldSize.Y   = size;
            World.WorldBoundary = new Rectangle {
                X = 0, Y = 0, Height = size, Width = size
            };
            // Call core Initialzation of game engine
            base.InitializeGame();

            // Create the Universe factory
            UniverseFactory.Instance.AssetPath      = AssetsPath;
            UniverseFactory.Instance.PhysicsFactory = PhysicsFactory;

            float playerX = (float)RandomManager.Instance.Next(1000, (int)World.WorldSize.X - 1000);
            float playerY = (float)RandomManager.Instance.Next(1000, (int)World.WorldSize.Y - 1000);
            //playerX = 5000;
            //playerY = 4000;

            SpriteShip player = UniverseFactory.Instance.CreatePlayer(playerX, playerY);

            player.Controller     = KeyboardController.Instance;
            World.WorldPosition.X = playerX - ((World.ScreenSize.X / 2) - (player.Width * player.Scale.X) / 2);
            World.WorldPosition.Y = playerY - ((World.ScreenSize.Y / 2) - (player.Height * player.Scale.Y) / 2);
            PlayerUI pui = new PlayerUI(ref player.PlayerStats);

            //*
            // Create the universe
            _theUniverse = new UniverseMaster
            {
                BlockSize = new Math.Vector2D {
                    X = World.ScreenSize.X, Y = World.ScreenSize.Y
                }
            };

            // Build player control object
            PlayerController pc = new PlayerController(KeyboardController.Instance);

            KeyboardController.Instance.Map(Input.RightShift, Keys.RShiftKey);
            pc.Player          = player;
            pc.Universe        = _theUniverse;
            player.DebugObject = _theUniverse.DebugObj;
            //*/
            _debug            = new SimpleText("");
            _debug.Position.X = World.ScreenSize.X - 200;
            _debug.Position.Y = 10;

            Add(pc, PLAYERLAYER);
            Add(pui, GUILAYER);
            Add(_debug, GUILAYER);
            InDebugMode = true;
            //Add(player, PLAYERLAYER);
        }
Ejemplo n.º 22
0
    public void ShowHighScore()
    {
        panelMainMenu.SetActive(false);
        panelHighScore.SetActive(true);

        gm.ClearMap();
        SimpleText.getInstance().SetDisplayText(strHighScore);

        m_gameState = GameState.HighScore;
    }
Ejemplo n.º 23
0
 public IActionResult Edit(SimpleText simpleText)
 {
     if (ModelState.IsValid)
     {
         _simpleTextService.Update(simpleText);
         _simpleTextService.Commit();
         return(RedirectToAction("Index"));
     }
     return(View(simpleText));
 }
Ejemplo n.º 24
0
 void WriteSimpleTextProperties(SimpleText node)
 {
     WriteWidgetProperties(node);
     WriteProperty("FontName", node.Font, null);
     WriteProperty("FontSize", node.FontHeight, 0f);
     WriteProperty("LineIndent", node.Spacing, 0f);
     WriteProperty("Text", node.Text, null);
     WriteProperty("TextColor", node.TextColor, new Color4(0));
     WriteProperty("HAlign", (int)node.HAlignment, (int)HAlignment.Left);
     WriteProperty("VAlign", (int)node.VAlignment, (int)VAlignment.Top);
     WriteProperty("LetterSpacing", node.LetterSpacing, 0f);
 }
Ejemplo n.º 25
0
        public RollFolderView(Row row)
        {
            this.row = row;
            folder   = row.Components.Get <FolderRow>().Folder;
            label    = new ThemedSimpleText();
            editBox  = new ThemedEditBox {
                LayoutCell = new LayoutCell(Alignment.Center, stretchX: float.MaxValue)
            };
            nodeIcon = new Image(IconPool.GetTexture("Tools.NewFolder"))
            {
                HitTestTarget = true,
                MinMaxSize    = new Vector2(16, 16)
            };
            expandButton = CreateExpandButton();
            var expandButtonContainer = new Widget {
                Layout = new StackLayout {
                    IgnoreHidden = false
                },
                LayoutCell = new LayoutCell(Alignment.Center),
                Visible    = true,
                Nodes      = { expandButton }
            };

            eyeButton  = CreateEyeButton();
            lockButton = CreateLockButton();
            widget     = new Widget {
                Padding = new Thickness {
                    Left = 4, Right = 2
                },
                MinHeight = TimelineMetrics.DefaultRowHeight,
                Layout    = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center)
                },
                HitTestTarget = true,
                Nodes         =
                {
                    (spacer = new Widget()),
                    expandButtonContainer,
                    nodeIcon,
                    Spacer.HSpacer(3),
                    label,
                    editBox,
                    new Widget(),
                    eyeButton,
                    lockButton,
                },
            };
            widget.Components.Add(new AwakeBehavior());
            label.AddChangeWatcher(() => folder.Id, s => label.Text = folder.Id);
            widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground));
            editBox.Visible = false;
            widget.Tasks.Add(HandleDobleClickTask());
        }
Ejemplo n.º 26
0
        public FilesystemItem(string path)
        {
            FilesystemPath = path;
            this.Input.AcceptMouseThroughDescendants = true;
            SimpleText text = null;

            MinMaxSize = new Vector2(ItemWidth, IconSize);
            Layout     = new HBoxLayout {
                Spacing = Spacing
            };
            Padding       = new Thickness(2);
            HitTestTarget = true;
            var isRoot = false;

            if (new DirectoryInfo(FilesystemPath).Parent == null)
            {
                isRoot = true;
            }

            Nodes.AddRange(
                new Image {
                LayoutCell = new LayoutCell {
                    Stretch   = Vector2.Zero,
                    Alignment = new Alignment {
                        X = HAlignment.Right, Y = VAlignment.Center
                    }
                },
                MinMaxSize = new Vector2(IconSize, IconSize),
                Texture    = SystemIconTextureProvider.Instance.GetTexture(FilesystemPath),
            },
                (text = new ThemedSimpleText {
                ForceUncutText = false,
                OverflowMode = TextOverflowMode.Ellipsis,
                Text =
                    isRoot ?
                    FilesystemPath.Remove(FilesystemPath.Length - 1) :
                    Path.GetFileName(FilesystemPath),
                LayoutCell = new LayoutCell {
                    Alignment = new Alignment {
                        X = HAlignment.Right, Y = VAlignment.Bottom
                    }
                }
            }),
                new Widget {
                LayoutCell = new LayoutCell {
                    StretchX = float.MaxValue
                },
                MinWidth      = 0,
                HitTestTarget = true
            }
                );
            text.Width = text.MinMaxWidth = Mathf.Min(ItemWidth - (IconSize + ItemPadding * 2 + Spacing + 2), text.MeasureUncutText().X);
        }
Ejemplo n.º 27
0
        public SliderThumb(Func <int> getter, Func <int, string> format = null)
        {
            On <HoverEvent>(e => _frame.State = ButtonState.Hover);
            On <BlurEvent>(e => _frame.State  = ButtonState.Normal);

            _getter = getter;
            _format = format;
            _text   = new SimpleText("").Center();
            _frame  = new ButtonFrame(_text)
            {
                Theme = ButtonTheme.SliderThumb
            };
            AttachChild(_frame);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 使用スライムの変換を行います。
        /// </summary>
        /// <param name="value">使用スライム情報の文字列</param>
        /// <returns>使用スライム</returns>
        private static Slime[] ParseUsingSlimes(string value)
        {
            var result = new Slime[FieldContextConfig.UsingSlimeCount];
            var slimes = value.ToCharArray();

            Debug.Assert(slimes.Count() == FieldContextConfig.UsingSlimeCount, "使用スライムの数が不正です。数:" + slimes.Count());

            for (var i = 0; i < slimes.Count(); i++)
            {
                result[i] = SimpleText.ConvertSlime(slimes[i]);
            }

            return(result);
        }
Ejemplo n.º 29
0
        public void HeaderContentsTest1()
        {
            string       file         = AARunMeFirstAndOnce.inPutFolder + "pagestyles.odt";
            TextDocument textDocument = new TextDocument();

            using (IPackageReader reader = new OnDiskPackageReader())
            {
                textDocument.Load(file, new OpenDocumentImporter(reader));

                TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
                txtMP.ActivatePageHeaderAndFooter();
                txtMP.TextPageHeader.MarginLeft = "4cm";
                foreach (IContent iContent in txtMP.TextPageHeader.ContentCollection)
                {
                    if (iContent is Paragraph)
                    {
                        Assert.IsNotNull(((Paragraph)iContent).MixedContent, "Must be mixed content available.");
                        Assert.IsTrue(((Paragraph)iContent).MixedContent.Count > 0,
                                      "Must be mixed contents object inside.");
                        Assert.IsTrue(((Paragraph)iContent).MixedContent[0] is SimpleText,
                                      "First IContent has to be type of SimpleText.");
                        Assert.IsTrue(((Paragraph)iContent).MixedContent[1] is FormatedText,
                                      "Second IContent has to be type of FormatedText.");
                        // Change the simple text
                        string     changeText = "Has changed ";
                        SimpleText simpleText = ((Paragraph)iContent).MixedContent[0] as SimpleText;
                        simpleText.Text = changeText;
                    }
                    else
                    {
                        Console.WriteLine(iContent.GetType().FullName);
                    }
                }

                Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument);
                // add one extra Paragraph
                SimpleText extraText = new SimpleText(textDocument, "Some extra text...");
                paragraph.TextContent.Add(extraText);
                txtMP.TextPageHeader.ContentCollection.Add(paragraph);

                textDocument.DocumentStyles.Styles.Save(AARunMeFirstAndOnce.outPutFolder + "pagestyles_changed.xml");

                using (IPackageWriter writer = new OnDiskPackageWriter())
                {
                    textDocument.Save(AARunMeFirstAndOnce.outPutFolder + "pagestyles_changed.odt",
                                      new OpenDocumentTextExporter(writer));
                }
            }
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            SimpleText preset = new SimpleText();

            // Set watermark text
            preset.Text = "Bytescout Watermarking";

            // Set watermark font
            preset.Font = new WatermarkFont("Tahoma", FontStyle.Regular, FontSizeType.Points, 30);

            // Set watermark text color
            preset.TextColor = Color.Black;

            // Set text transparency
            preset.Transparency = 40;

            // Set watermark placement
            preset.Placement = WatermarkPlacement.MiddleCenter;

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Set output format
            waterMarker.OutputOptions.ImageFormat = OutputFormats.JPEG;

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Ejemplo n.º 31
0
 void Example12()
 {
     //Create new TextDocument
     TextDocument document = new TextDocument();
     document.New();
     //Create a new Paragraph
     Paragraph para = new Paragraph(document, "P1");
     //Create some simple text
     SimpleText stext = new SimpleText(document, "Some simple text ");
     //Create a XLink
     XLink xlink = new XLink(document, "http://www.OpenOffice.org", "OpenOffice.org");
     //Add the textcontent
     para.TextContent.Add(stext);
     para.TextContent.Add(xlink);
     //Add paragraph to the document content
     document.Content.Add(para);
     //Save
     document.SaveTo("example12_XLink.odt");
 }
        public void GetEnumerator()
        {
            var text = new SimpleText("", 0, 0);
            var characters = text.ToArray();
            Assert.IsTrue(characters.Length == 0);

            text = new SimpleText("abc", 0, 3);
            characters = text.ToArray();
            Assert.IsTrue(characters.Length == 3);
            Assert.IsTrue(characters[0] == 'a');
            Assert.IsTrue(characters[1] == 'b');
            Assert.IsTrue(characters[2] == 'c');

            text = new SimpleText("__abc__", 2, 3);
            characters = text.ToArray();
            Assert.IsTrue(characters.Length == 3);
            Assert.IsTrue(characters[0] == 'a');
            Assert.IsTrue(characters[1] == 'b');
            Assert.IsTrue(characters[2] == 'c');
        }
        public new void ToString()
        {
            var text = new SimpleText("", 0, 0);
            Assert.IsTrue(text.ToString() == "");

            text = new SimpleText("a", 0, 0);
            Assert.IsTrue(text.ToString() == "");

            text = new SimpleText("a", 0, 1);
            Assert.IsTrue(text.ToString() == "a");

            text = new SimpleText("ab", 0, 0);
            Assert.IsTrue(text.ToString() == "");

            text = new SimpleText("ab", 1, 0);
            Assert.IsTrue(text.ToString() == "");

            text = new SimpleText("ab", 0, 1);
            Assert.IsTrue(text.ToString() == "a");

            text = new SimpleText("ab", 1, 1);
            Assert.IsTrue(text.ToString() == "b");
        }
        public void AppendSimpleText()
        {
            var text = "abc";
            var head = new ComplexText(new SimpleText(text, 0, 1));
            var tail = new SimpleText(text, 2, 1);
            var result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "ac");
            Assert.IsTrue((result as ComplexText).texts.Count == 2);

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 2));
            tail = new SimpleText(text, 1, 2);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abbc");
            Assert.IsTrue((result as ComplexText).texts.Count == 2);

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 1));
            tail = new SimpleText(text, 1, 2);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 2));
            tail = new SimpleText(text, 2, 1);
            result = head.AppendSimpleText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);
        }
        public void AppendComplexText()
        {
            var text = "abc";
            var head = new SimpleText(text, 0, 1);
            var tail = new ComplexText(new[] { new SimpleText(text, 2, 1) });
            var result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "ac");
            Assert.IsFalse(result is SimpleText);

            text = "abc";
            head = new SimpleText(text, 0, 2);
            tail = new ComplexText(new[] { new SimpleText(text, 1, 2) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abbc");
            Assert.IsFalse(result is SimpleText);

            text = "abc";
            head = new SimpleText(text, 0, 1);
            tail = new ComplexText(new[] { new SimpleText(text, 1, 2) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);

            text = "abc";
            head = new SimpleText(text, 0, 2);
            tail = new ComplexText(new[] { new SimpleText(text, 2, 1) });
            result = head.AppendComplexText(tail);
            Assert.IsTrue(result == "abc");
            Assert.IsTrue(result is SimpleText);
        }
Ejemplo n.º 36
0
		public void WhiteSpaceTest()
		{
			//Create new TextDocument
			TextDocument document		= new TextDocument();
			document.New();
			//Create a new Paragraph
			Paragraph para				= new Paragraph(document, "P1");
			//Create some simple text with whitespaces
			SimpleText stext			= new SimpleText(para, "Some simple text add 12 whitespace         \"and go on.");			
			//Add the textcontent
			para.TextContent.Add(stext);
			//Add paragraph to the document content
			document.Content.Add(para);
			//Save
			document.SaveTo("Whitespaces.odt");
		}
Ejemplo n.º 37
0
		public void FootnoteText()
		{
			//Create new TextDocument
			TextDocument document		= new TextDocument();
			document.New();
			//Create a new Paragph
			Paragraph para				= new Paragraph(document, "P1");
			//Create some simple Text
			SimpleText stext			= new SimpleText(para, "Some simple text. And I have a footnode");
			//Create a Footnote
			Footnote fnote				= new Footnote(para, "Footer \"     Text", "1", FootnoteType.footnode);
			//Add the text content
			para.TextContent.Add(stext);
			para.TextContent.Add(fnote);
			//Add the paragraph
			document.Content.Add(para);
			//Save
			document.SaveTo("footnote.odt");
		}
Ejemplo n.º 38
0
		public void TabstopTest()
		{
			//Create new document
			TextDocument document		= new TextDocument();
			document.New();
			//Create new paragraph
			Paragraph par				= new Paragraph(document, "P1");
			//Create a new TabStopStyle collection
			TabStopStyleCollection tsc	= new TabStopStyleCollection(document);
			//Create TabStopStyles
			TabStopStyle ts				= new TabStopStyle(document, 4.98);
			ts.LeaderStyle				= TabStopLeaderStyles.Dotted;
			ts.LeaderText				= ".";
			ts.Type						= TabStopTypes.Center;
			//Add the tabstop
			tsc.Add(ts);
			//Append the TabStopStyleCollection
			((ParagraphStyle)par.Style).Properties.TabStopStyleCollection = tsc;
			//Add some text, use @ qualifier when ever you use control chars!
			string mytebstoptext		= @"Hello\tHello again";
			SimpleText stext			= new SimpleText(par, mytebstoptext);
			//the simple text
			par.TextContent.Add(stext);
			//Add the paragraph to the content container
			document.Content.Add(par);
			//Save
			document.SaveTo("tabstop.odt");
		}
        public void Split()
        {
            var text = new SimpleText("", 0, 0);

            var split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(1));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("a", 0, 1);

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "a");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(2));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("__a__", 2, 1);
            Assert.IsTrue(text.ToString() == "a");

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "a");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "");

            AssertThrows(() => text.Split(2));
            AssertThrows(() => text.Split(-1));

            text = new SimpleText("__abc__", 2, 3);
            Assert.IsTrue(text.ToString() == "abc");

            split = text.Split(0);
            Assert.IsTrue(split.Head.ToString() == "");
            Assert.IsTrue(split.Tail.ToString() == "abc");

            split = text.Split(1);
            Assert.IsTrue(split.Head.ToString() == "a");
            Assert.IsTrue(split.Tail.ToString() == "bc");

            split = text.Split(2);
            Assert.IsTrue(split.Head.ToString() == "ab");
            Assert.IsTrue(split.Tail.ToString() == "c");

            split = text.Split(3);
            Assert.IsTrue(split.Head.ToString() == "abc");
            Assert.IsTrue(split.Tail.ToString() == "");
        }
Ejemplo n.º 40
0
		public void XLinkTest()
		{
			//Create new TextDocument
			TextDocument document		= new TextDocument();
			document.New();
			//Create a new Paragraph
			Paragraph para				= new Paragraph(document, "P1");
			//Create some simple text
			SimpleText stext			= new SimpleText(para, "Some simple text");
			//Create a XLink
			XLink xlink					= new XLink(para, "http://www.sourceforge.net", "Sourceforge");
			//Add the textcontent
			para.TextContent.Add(stext);
			para.TextContent.Add(xlink);
			//Add paragraph to the document content
			document.Content.Add(para);
			//Save
			document.SaveTo("XLink.odt");
		}
        public void IsSimpleTextAppendableTo()
        {
            var text = "abc";
            var head = new ComplexText(new SimpleText(text, 0, 1));
            var tail = new SimpleText(text, 2, 1);
            Assert.IsFalse(head.IsSimpleTextAppendableTo(tail));

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 2));
            tail = new SimpleText(text, 1, 2);
            Assert.IsFalse(head.IsSimpleTextAppendableTo(tail));

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 1));
            tail = new SimpleText(text, 1, 2);
            Assert.IsTrue(head.IsSimpleTextAppendableTo(tail));

            text = "abc";
            head = new ComplexText(new SimpleText(text, 0, 2));
            tail = new SimpleText(text, 2, 1);
            Assert.IsTrue(head.IsSimpleTextAppendableTo(tail));
        }
Ejemplo n.º 42
0
		public void BookmarkTest()
		{
			//Create a new TextDocument
			TextDocument document		= new TextDocument();
			document.New();
			//Create a new Paragraph
			Paragraph para				= new Paragraph(document, "P1");
			//Create simple text
			SimpleText stext			= new SimpleText(para, "Some text here");
			//add the simple text
			para.TextContent.Add(stext);
			//add the paragraph
			document.Content.Add(para);
			//add a blank paragraph
			document.Content.Add(new Paragraph(document, ParentStyles.Standard.ToString()));
			//Create a new Paragraph
			para						= new Paragraph(document, "P2");
			//add some simple text
			para.TextContent.Add(new SimpleText(para, "some simple text"));
			//create a new standard bookmark
			Bookmark bookmark			= new Bookmark(para, BookmarkType.Standard, "address");
			//add bookmark to the paragraph
			para.TextContent.Add(bookmark);
			//add the paragraph to the document
			document.Content.Add(para);

			//create a paragraph, with a bookmark range Start -> End
			para						= new Paragraph(document, "P3");
			bookmark					= new Bookmark(para, BookmarkType.Start, "address2");
			//add bookmark to the paragraph
			para.TextContent.Add(bookmark);
			//add some simple text
			para.TextContent.Add(new SimpleText(para, "more text"));
			//create a new end bookmark
			bookmark			= new Bookmark(para, BookmarkType.End, "address2");
			//add bookmark to the paragraph, so the encapsulated bookmark text is "more text"
			para.TextContent.Add(bookmark);
			//add the paragraph to the document content
			document.Content.Add(para);
			//save
			document.SaveTo("bookmark.odt");
		}