Beispiel #1
0
 public MarkdownList(MarkdownBar bar)
 {
     Style     = SharedDictionaryManager.VirtualList.Get <Style>(typeof(VirtualList));
     Container = bar.ListContainer;
     Header    = new StackPanel {
         Margin   = WpfHelper.MenuItemMargin,
         Children =
         {
             new Separator  {
                 Tag = new ThemedMenuText(R.CMD_SearchTitles)
             },
             new StackPanel {
                 Orientation = Orientation.Horizontal,
                 Children    =
                 {
                     ThemeHelper.GetImage(IconIds.Search).WrapMargin(WpfHelper.GlyphMargin),
                     (_FinderBox = new ThemedTextBox{
                         MinWidth = 150
                     }),
                     new ThemedButton(IconIds.ClearFilter,                                  R.CMD_ClearFilter, ClearFilter)
                 }
             },
         }
     };
     Footer = new TextBlock {
         Margin = WpfHelper.MenuItemMargin
     }
     .ReferenceProperty(TextBlock.ForegroundProperty, Microsoft.VisualStudio.PlatformUI.EnvironmentColors.SystemGrayTextBrushKey)
     .Append(ThemeHelper.GetImage(IconIds.LineOfCode))
     .Append(bar.View.TextSnapshot.LineCount);
     _FinderBox.TextChanged += SearchCriteriaChanged;
     _FinderBox.SetOnVisibleSelectAll();
     _Bar = bar;
 }
Beispiel #2
0
        public static IControl Create(IProject project, ElementContext elementContext)
        {
            var m = Spacer.Medium.DesiredSize.Width;
            var s = Spacer.Small.DesiredSize.Width;

            var hasClasses   = project.Classes.Select(x => x.Any());
            var searchString = Property.Create("");

            return(Layout.Dock()
                   .Top(Layout.Dock()
                        .Top(Separator.Medium)
                        .Bottom(Separator.Weak)
                        .Bottom(Separator.Medium)
                        .Left(Spacer.Medium)
                        .Left(Icons.ClassesSmall())
                        .Left(Spacer.Small)
                        .Left(Theme.Header("Your classes"))
                        .Fill()
                        .WithHeight(26))
                   .Top(ThemedTextBox
                        .Create(searchString)
                        .WithPlaceholderText(searchString.Select(str => str != ""), "Search your classes")
                        .WithMediumPadding()
                        .ShowWhen(hasClasses))
                   .Top(
                       Layout.StackFromLeft(
                           Icons.DragIconSmall(),
                           Spacer.Small,
                           Label.Create(
                               "Drag classes into the hierarchy \nto insert instances of them",
                               font: Theme.DefaultFont,
                               textAlignment: TextAlignment.Left,
                               color: Theme.DescriptorText),
                           Spacer.Medium)
                       .ShowWhen(hasClasses)
                       .CenterHorizontally())
                   .Top(
                       Layout.StackFromLeft(
                           Icons.ExtractClass(hasClasses),
                           Spacer.Small,
                           Label.Create(
                               "Create a class from elements in the \nhierarchy and it will appear here",
                               font: Theme.DefaultFont,
                               textAlignment: TextAlignment.Left,
                               color: Theme.DescriptorText),
                           Spacer.Medium)
                       .WithMediumPadding()
                       .HideWhen(hasClasses)
                       .CenterHorizontally())
                   .Fill(
                       project.Classes
                       .CachePerElement(e => CreateClassItem(e, project.Context, elementContext, searchString))
                       .StackFromTop()
                       .WithPadding(left: m, top: s, right: m, bottom: s)
                       .MakeScrollable(darkTheme: Theme.IsDark))
                   .MakeResizable(RectangleEdge.Top, "MyClassesHeight"));
        }
        public static void Create()
        {
            var lightTheme = new OriginalLightTheme();
            var darkTheme  = new OriginalDarkTheme();

            var path    = new BehaviorSubject <string>(string.Empty);
            var refresh = new BehaviorSubject <Unit>(Unit.Default);
            var image   = path
                          .CombineLatest(refresh, ((p, _) => p))
                          .Select(p => AbsoluteFilePath.TryParse(p)
                                  .Where(f => File.Exists(f.NativePath))
                                  .Select(
                                      absPath => absPath.NativePath.EndsWith(".svg")
                                                        ? (IImage) new SvgImage(() => File.OpenRead(absPath.NativePath))
                                                        : new MultiResolutionImage(
                                          new[] { new ImageStream(new Ratio <Pixels, Points>(1), () => File.OpenRead(absPath.NativePath)) }))
                                  .Or(() => (IImage) new SvgImage(() => new MemoryStream(FallbackImage))));

            var content =
                Layout.Dock().Top(
                    Layout.Dock()
                    .Left(Label.Create("Path: ", font: Theme.DefaultFont, color: Theme.DefaultText).CenterVertically())
                    .Right(Buttons.DefaultButton("Refresh", Command.Enabled(() => refresh.OnNext(Unit.Default))))
                    .Fill(ThemedTextBox.Create(path.AsProperty())))
                .Fill(Layout.SubdivideHorizontally(ImageVersionsRowForTheme(image, darkTheme), ImageVersionsRowForTheme(image, lightTheme)))
                .WithBackground(Theme.PanelBackground);

            Application.Desktop.CreateSingletonWindow(
                Observable.Return(true),
                dialog => new Window
            {
                Title      = Observable.Return("Icon preview"),
                Size       = Property.Create <Optional <Size <Points> > >(new Size <Points>(600, 600)).ToOptional(),
                Content    = content,
                Background = Theme.PanelBackground,
                Foreground = Theme.DefaultText,
                Border     = Separator.MediumStroke
            });
        }
Beispiel #4
0
        public static void OpenDialog(
            IModalHost modalHost,
            IExtractClassViewModel viewModel)
        {
            var toggleCreateInNewFile = viewModel.CreateInNewFile.Toggle();

            var errorMsg = Label.Create(
                text: viewModel.UserInfo.AsText(),
                font: Theme.DescriptorFont,
                color: Theme.ErrorColor,
                lineBreakMode: LineBreakMode.TruncateTail)
                           .CenterVertically()
                           .WithHeight(26);

            var optionsPart =
                Layout.StackFromTop(
                    Layout.Dock()
                    .Left(CheckBox.Create(viewModel.CreateInNewFile, toggleCreateInNewFile)
                          .CenterVertically()
                          .WithPadding(right: new Points(4), top: new Points(1)))
                    .Fill(
                        Label.Create(
                            "Extract to new file",
                            Theme.DefaultFont,
                            color: Theme.DefaultText)
                        .OnMouse(pressed: toggleCreateInNewFile)
                        .CenterVertically())
                    .WithHeight(22),
                    Layout.Dock()
                    .Left(Control.Empty.WithWidth(21))
                    .Fill(
                        Label.Create(
                            "Create a new .ux file for the class",
                            Theme.DefaultFont,
                            color: Theme.DescriptorText,
                            lineBreakMode: LineBreakMode.TruncateTail))
                    .CenterVertically()
                    .WithHeight(21),
                    Layout.Dock()
                    .Left(Control.Empty.WithWidth(21))
                    .Fill(ThemedTextBox.Create(viewModel.NewFileName))
                    .WithPadding(top: new Points(6), bottom: new Points(3))
                    );

            var content =
                Layout.StackFromTop(
                    Layout.Dock()
                    .Left(
                        Label.Create("ux:Class", Theme.DefaultFont, color: Theme.DefaultText)
                        .CenterVertically().WithPadding(right: new Points(4)))
                    .Fill(ThemedTextBox.Create(viewModel.ClassName))
                    .WithPadding(bottom: new Points(23)),
                    optionsPart,
                    errorMsg)
                .WithPadding(left: new Points(15), top: new Points(15), right: new Points(15));

            modalHost.Open(
                confirm: viewModel.CreateCommand,
                fill: Layout.Dock()
                .Top(
                    // Just use button as header for dialog
                    CreateButton(Command.Enabled(() => {}), hoverColor: Theme.DefaultText))
                .Fill(content),
                confirmText: "Create class",
                confirmTooltip: "Creates new UX class based on selected element");
        }