示例#1
0
        private void CreateRunningTimeToolbar(ToolbarView toolbar)
        {
            EntityGraph graph = Graph as EntityGraph;
            //查看所有节点
            ToolbarButton btnSelEntity = new ToolbarButton()
            {
                text    = graph.RunningTimeEntity == null ? "选择实体" : graph.RunningTimeEntity.Go.name,
                tooltip = "选择实体"
            };

            btnSelEntity.clicked += () =>
            {
                SelRunningTimeEntity(btnSelEntity);
            };
            toolbar.AddButtonToLeft(btnSelEntity);
        }
        public void FocusSearchBar()
        {
            IdeApp.Workbench.Present();
            var text   = lastSearchText;
            var actDoc = IdeApp.Workbench.ActiveDocument;

            if (actDoc != null && actDoc.Editor != null && actDoc.Editor.IsSomethingSelected)
            {
                string selected        = actDoc.Editor.SelectedText;
                int    whitespaceIndex = selected.TakeWhile(c => !char.IsWhiteSpace(c)).Count();
                text = selected.Substring(0, whitespaceIndex);
            }

            ToolbarView.FocusSearchBar();
            ToolbarView.SearchText = text;
        }
        void RebuildToolbar()
        {
            var bars = AddinManager.GetExtensionNodes <ItemSetCodon> (ToolbarExtensionPath)
                       .Where(n => visibleBars.Contains(n.Id))
                       .Select(b => b.ChildNodes.OfType <CommandItemCodon> ().Select(n => n.Id));

            buttonBarButtons.Clear();
            foreach (var bar in bars)
            {
                foreach (string commandId in bar)
                {
                    buttonBarButtons.Add(new ButtonBarButton(this, commandId));
                }
                buttonBarButtons.Add(new ButtonBarButton(this));
            }

            ToolbarView.RebuildToolbar(buttonBarButtons);
        }
        void HandleSearchEntryChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty (ToolbarView.SearchText))
                lastSearchText = ToolbarView.SearchText;

            if (string.IsNullOrEmpty (ToolbarView.SearchText)){
                DestroyPopup ();
                return;
            }
            var pattern = SearchPopupSearchPattern.ParsePattern (ToolbarView.SearchText);
            if (pattern.Pattern == null && pattern.LineNumber > 0 || pattern == emptyColonPattern) {
                if (popup != null) {
                    popup.Hide ();
                }
                return;
            } else {
                if (popup != null && !popup.Visible)
                    popup.Show ();
            }

            if (popup == null) {
                popup = new SearchPopupWindow ();
                popup.SearchForMembers = SearchForMembers;
                popup.Disposed += delegate {
                    popup = null;
                    ToolbarView.SearchText = "";
                };
                popup.SelectedItemChanged += delegate {
                    var si = popup?.Content?.SelectedItem;
                    if (si == null || si.Item < 0 || si.Item >= si.DataSource.Count)
                        return;
                    var text = si.DataSource [si.Item].AccessibilityMessage;
                    if (string.IsNullOrEmpty (text))
                        return;

                    ToolbarView.ShowAccessibilityAnnouncement (text);
                };
                PositionPopup ();
                popup.Show ();
            }
            popup.Update (pattern);
        }
        void RebuildToolbar()
        {
            var bars = AddinManager.GetExtensionNodes<ItemSetCodon> (ToolbarExtensionPath)
                .Where (n => visibleBars.Contains (n.Id))
                .Select (b => new { Label = b.Label, Buttons = b.ChildNodes.OfType<CommandItemCodon> ().Select (n => n.Id) });

            var buttonGroups = new List<ButtonBarGroup> ();
            buttonBarButtons.Clear ();
            foreach (var bar in bars) {
                var group = new ButtonBarGroup (bar.Label);

                buttonGroups.Add (group);
                foreach (string commandId in bar.Buttons) {
                    var button = new ButtonBarButton (this, commandId);
                    group.Buttons.Add (button);
                    buttonBarButtons.Add (button);
                }
            }

            ToolbarView.RebuildToolbar (buttonGroups);
        }
示例#6
0
        public void Init(IQFrameworkContainer container)
        {
// view
            mRootLayout = new VerticalLayout();
            var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout);

            var verticalLayout = new VerticalLayout("box");

            treeNode.Add2Spread(verticalLayout);


            mCategoriesSelectorView = new ToolbarView(0)
                                      .AddTo(verticalLayout);

            mCategoriesSelectorView.Index.Bind(newIndex =>
            {
                TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerSelectCategoryCommand()
                {
                    CategoryIndex = newIndex
                });
            });

            new HeaderView()
            .AddTo(verticalLayout);

            var packageList = new VerticalLayout("box")
                              .AddTo(verticalLayout);

            mScrollLayout = new ScrollLayout()
                            .Height(240)
                            .AddTo(packageList);

            TypeEventSystem.Register <PackageManagerViewUpdate>(OnRefresh);

            // 执行
            TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerStartUpCommand());

            var bindingSet = BindKit.CreateBindingSet(this, new PackageManagerViewModel());
        }
示例#7
0
        private void ToolbarButtonAdded(ObservableCollection <CommandInfo> commandInfos)
        {
            if ((commandInfos != null) && (commandInfos.Count > 0))
            {
                ToolbarView view = _serviceLocator.GetInstance <ToolbarView>();
                foreach (CommandInfo info in commandInfos)
                {
                    if (!info.Anchor.HasFlag(CommandAnchor.Toolbar))
                    {
                        continue;
                    }

                    if (info.CommandBinding != null)
                    {
                        view.CommandBindings.Add(info.CommandBinding);
                    }

                    ToolbarItems.Add(new ToolbarCommand(info.Command, info.Icon, info.Text));
                }

                this.RaisePropertyChanged("ToolbarItems");
            }
        }
示例#8
0
        public Inspector(Widget panelWidget)
        {
            PanelWidget = panelWidget;
            RootWidget  = new ThemedScrollView();
            var toolbarArea = new Widget {
                Layout = new StackLayout(), Padding = new Thickness(4, 0)
            };

            contentWidget = new Widget();
            RootWidget.Content.AddNode(toolbarArea);
            RootWidget.Content.AddNode(contentWidget);
            RootWidget.Content.Layout = new VBoxLayout();
            Toolbar = new ToolbarView(toolbarArea, GetToolbarLayout());
            contentWidget.Layout = new VBoxLayout();
            Objects = new List <object>();
            content = new InspectorContent(contentWidget)
            {
                Footer = new Widget {
                    MinHeight = 300.0f
                },
                History = Document.Current.History
            };
            CreateWatchersToRebuild();
        }
示例#9
0
        private TangerineApp(string[] args)
        {
            ChangeTangerineSettingsFolderIfNeed();
            Orange.UserInterface.Instance = new OrangeInterface();
            Orange.UserInterface.Instance.Initialize();
            Widget.EnableViewCulling = false;
            WidgetInput.AcceptMouseBeyondWidgetByDefault = false;

            if (!UserPreferences.Initialize())
            {
                UserPreferences.Instance.Clear();
                UserPreferences.Instance.Add(new AppUserPreferences());
                UserPreferences.Instance.Add(new UI.SceneView.SceneUserPreferences());
                UserPreferences.Instance.Add(new UI.Timeline.TimelineUserPreferences());
                UserPreferences.Instance.Add(new UI.FilesystemView.FilesystemUserPreferences());
                UserPreferences.Instance.Add(new CoreUserPreferences());
            }
#if WIN
            TangerineSingleInstanceKeeper.Initialize(args);
            TangerineSingleInstanceKeeper.AnotherInstanceArgsRecieved += OpenDocumentsFromArgs;
            Application.Exited += () => {
                TangerineSingleInstanceKeeper.Instance.ReleaseInstance();
            };
#endif
            switch (AppUserPreferences.Instance.ColorThemeKind)
            {
            case ColorTheme.ColorThemeKind.Light:
                SetColorTheme(ColorTheme.CreateLightTheme(), Theme.ColorTheme.CreateLightTheme());
                break;

            case ColorTheme.ColorThemeKind.Dark:
                SetColorTheme(ColorTheme.CreateDarkTheme(), Theme.ColorTheme.CreateDarkTheme());
                break;

            case ColorTheme.ColorThemeKind.Custom: {
                bool       isDark = AppUserPreferences.Instance.ColorTheme.IsDark;
                ColorTheme theme  = null;
                var        flags  =
                    BindingFlags.Public |
                    BindingFlags.GetProperty |
                    BindingFlags.SetProperty |
                    BindingFlags.Instance;
                foreach (var category in typeof(ColorTheme).GetProperties(flags))
                {
                    var categoryValue = category.GetValue(AppUserPreferences.Instance.ColorTheme);
                    if (categoryValue == null)
                    {
                        if (theme == null)
                        {
                            theme = isDark ? ColorTheme.CreateDarkTheme() : ColorTheme.CreateLightTheme();
                        }
                        category.SetValue(AppUserPreferences.Instance.ColorTheme, category.GetValue(theme));
                        category.SetValue(theme, null);
                    }
                }
                SetColorTheme(AppUserPreferences.Instance.ColorTheme, AppUserPreferences.Instance.LimeColorTheme);
                break;
            }
            }
            Application.InvalidateWindows();

            LoadFont();

            DockManager.Initialize(new Vector2(1024, 768));
            DockManager.Instance.DocumentAreaDropFilesGesture.Recognized += new ScenesDropHandler {
                ShouldCreateContextMenu = false
            }.Handle;
            TangerineMenu.Create();
            var mainWidget = DockManager.Instance.MainWindowWidget;
            mainWidget.Window.AllowDropFiles = true;
            mainWidget.AddChangeWatcher(() => Project.Current, _ => {
                SetupMainWindowTitle(mainWidget);
                TangerineMenu.RebuildCreateImportedTypeMenu();
            });
            mainWidget.AddChangeWatcher(() => CoreUserPreferences.Instance.AnimationMode, _ => Document.Current?.ForceAnimationUpdate());
            mainWidget.AddChangeWatcher(() => Document.Current?.Container, _ => Document.Current?.ForceAnimationUpdate());
            Application.Exiting += () => Project.Current.Close();
            Application.Exited  += () => {
                AppUserPreferences.Instance.DockState             = DockManager.Instance.ExportState();
                SceneUserPreferences.Instance.VisualHintsRegistry = VisualHintsRegistry.Instance;
                Core.UserPreferences.Instance.Save();
                Orange.The.Workspace.Save();
            };

            var timelinePanel      = new Panel("Timeline");
            var inspectorPanel     = new Panel("Inspector");
            var searchPanel        = new Panel("Hierarchy");
            var animationsPanel    = new Panel("Animations");
            var filesystemPanel    = new Panel("Filesystem");
            var consolePanel       = new Panel("Console");
            var backupHistoryPanel = new Panel("Backups");
            var documentPanel      = new Panel(DockManager.DocumentAreaId, undockable: false);
            documentPanel.PanelWidget = documentPanel.ContentWidget;
            var visualHintsPanel     = new Panel("Visual Hints");
            var attachmentPanel      = new Panel("Model3D Attachment");
            var remoteScriptingPanel = new Panel("Remote Scripting");
            var dockManager          = DockManager.Instance;
            new UI.Console(consolePanel);
            var root      = dockManager.Model.WindowPlacements.First();
            var placement = new LinearPlacement(LinearPlacementDirection.Horizontal);
            dockManager.AddPanel(timelinePanel, root, DockSite.Top, 0.3f);
            dockManager.DockPlacementTo(placement, root, DockSite.Bottom, 0.6f);
            dockManager.AppendPanelTo(documentPanel, placement, 0.5f);
            var commandHandlerList = CommandHandlerList.Global;
            var commandsDictionary = new Dictionary <string, Command> {
                { animationsPanel.Id, new Command(animationsPanel.Title) },
                { timelinePanel.Id, new Command(timelinePanel.Title) },
                { inspectorPanel.Id, new Command(inspectorPanel.Title) },
                { searchPanel.Id, new Command(searchPanel.Title) },
                { filesystemPanel.Id, new Command(filesystemPanel.Title) },
                { consolePanel.Id, new Command(consolePanel.Title) },
                { backupHistoryPanel.Id, new Command(backupHistoryPanel.Title) },
                { visualHintsPanel.Id, new Command(visualHintsPanel.Title) },
                { attachmentPanel.Id, new Command(attachmentPanel.Title) },
                { remoteScriptingPanel.Id, new Command(remoteScriptingPanel.Title) },
            };
            foreach (var pair in commandsDictionary)
            {
                commandHandlerList.Connect(pair.Value, new PanelCommandHandler(pair.Key));
                TangerineMenu.PanelsMenu.Add(pair.Value);
            }
            dockManager.AddPanel(inspectorPanel, placement, DockSite.Left);
            var filesystemPlacement = dockManager.AddPanel(filesystemPanel, placement, DockSite.Right);
            dockManager.AddPanel(searchPanel, filesystemPlacement, DockSite.Fill);
            dockManager.AddPanel(animationsPanel, filesystemPlacement, DockSite.Fill);
            dockManager.AddPanel(backupHistoryPanel, filesystemPlacement, DockSite.Fill);
            dockManager.AddPanel(consolePanel, filesystemPlacement, DockSite.Bottom, 0.3f);
            dockManager.AddPanel(visualHintsPanel, placement, DockSite.Right, 0.3f).Hidden     = true;
            dockManager.AddPanel(attachmentPanel, placement, DockSite.Bottom, 0.3f).Hidden     = true;
            dockManager.AddPanel(remoteScriptingPanel, placement, DockSite.Right, 0.3f).Hidden = true;
            DockManagerInitialState = dockManager.ExportState();
            var documentViewContainer = InitializeDocumentArea(dockManager);
            documentPanel.ContentWidget.Nodes.Add(dockManager.DocumentArea);
            dockManager.ImportState(AppUserPreferences.Instance.DockState);
            Document.CloseConfirmation += doc => {
                var alert = new AlertDialog($"Save the changes to document '{doc.Path}' before closing?", "Yes", "No", "Cancel");
                switch (alert.Show())
                {
                case 0: return(Document.CloseAction.SaveChanges);

                case 1: return(Document.CloseAction.DiscardChanges);

                case -1:
                default: return(Document.CloseAction.Cancel);
                }
            };
            mainWidget.Tasks.Add(HandleMissingDocumentsTask);
            Project.HandleMissingDocuments += missingDocuments => {
                foreach (var d in missingDocuments)
                {
                    missingDocumentsList.Add(d);
                }
            };
            Project.DocumentReloadConfirmation += doc => {
                if (doc.IsModified)
                {
                    var modifiedAlert = new AlertDialog($"{doc.Path}\n\nThis file has been modified by another program and has unsaved changes.\nDo you want to reload it from disk? ", "Yes", "No");
                    var res           = modifiedAlert.Show();
                    if (res == 1 || res == -1)
                    {
                        doc.History.ExternalModification();
                        return(false);
                    }
                    return(true);
                }
                if (CoreUserPreferences.Instance.ReloadModifiedFiles)
                {
                    return(true);
                }
                var alert = new AlertDialog($"{doc.Path}\n\nThis file has been modified by another program.\nDo you want to reload it from disk? ", "Yes, always", "Yes", "No");
                var r     = alert.Show();
                if (r == 0)
                {
                    CoreUserPreferences.Instance.ReloadModifiedFiles = true;
                    return(true);
                }
                if (r == 2)
                {
                    doc.History.ExternalModification();
                    return(false);
                }
                return(true);
            };

            Project.TempFileLoadConfirmation += path => {
                var alert = new AlertDialog($"Do you want to load autosaved version of '{path}'?", "Yes", "No");
                return(alert.Show() == 0);
            };

            Project.OpenFileOutsideProjectAttempt += (string filePath) => {
                var projectFilePath = SearhForCitproj(filePath);
                if (projectFilePath != null && Project.Current.CitprojPath != projectFilePath)
                {
                    var alert = new AlertDialog($"You're trying to open a document outside the project directory. Change the current project to '{Path.GetFileName(projectFilePath)}'?", "Yes", "No");
                    if (alert.Show() == 0)
                    {
                        if (FileOpenProject.Execute(projectFilePath))
                        {
                            Project.Current.OpenDocument(filePath, true);
                        }
                        return;
                    }
                }
                else if (projectFilePath == null)
                {
                    AlertDialog.Show("Can't open a document outside the project directory");
                }
            };
            Project.Tasks = dockManager.MainWindowWidget.Tasks;
            Project.Tasks.Add(new AutosaveProcessor(() => AppUserPreferences.Instance.AutosaveDelay));
            BackupManager.Instance.Activate(Project.Tasks);
            Document.NodeDecorators.AddFor <Spline>(n => n.CompoundPostPresenter.Add(new UI.SceneView.SplinePresenter()));
            Document.NodeDecorators.AddFor <Viewport3D>(n => n.CompoundPostPresenter.Add(new UI.SceneView.Spline3DPresenter()));
            Document.NodeDecorators.AddFor <Viewport3D>(n => n.CompoundPostPresenter.Add(new UI.SceneView.Animation3DPathPresenter()));
            Document.NodeDecorators.AddFor <Widget>(n => {
                if (n.AsWidget.SkinningWeights == null)
                {
                    n.AsWidget.SkinningWeights = new SkinningWeights();
                }
            });
            Document.NodeDecorators.AddFor <PointObject>(n => {
                if ((n as PointObject).SkinningWeights == null)
                {
                    (n as PointObject).SkinningWeights = new SkinningWeights();
                }
            });
            Animation.EasingEnabledChecker = (animation) => {
                var doc = Document.Current;
                return(doc == null || doc.PreviewScene || animation != doc.Animation);
            };
            if (SceneUserPreferences.Instance.VisualHintsRegistry != null)
            {
                VisualHintsRegistry.Instance = SceneUserPreferences.Instance.VisualHintsRegistry;
            }
            VisualHintsRegistry.Instance.RegisterDefaultHints();

            Document.NodeDecorators.AddFor <Node>(n => n.SetTangerineFlag(TangerineFlags.SceneNode, true));
            dockManager.UnhandledExceptionOccurred += e => {
                AlertDialog.Show(e.Message + "\n" + e.StackTrace);
                var doc = Document.Current;
                if (doc != null)
                {
                    while (doc.History.IsTransactionActive)
                    {
                        doc.History.EndTransaction();
                    }
                    var closeConfirmation = Document.CloseConfirmation;
                    try {
                        Document.CloseConfirmation = d => {
                            var alert = new AlertDialog($"Save the changes to document '{d.Path}' before closing?", "Yes", "No");
                            switch (alert.Show())
                            {
                            case 0: return(Document.CloseAction.SaveChanges);

                            default: return(Document.CloseAction.DiscardChanges);
                            }
                        };
                        var fullPath = doc.FullPath;

                        if (!File.Exists(fullPath))
                        {
                            doc.Save();
                        }
                        var path = doc.Path;
                        Project.Current.CloseDocument(doc);
                        Project.Current.OpenDocument(path);
                    } finally {
                        Document.CloseConfirmation = closeConfirmation;
                    }
                }
            };

            Document.NodeDecorators.AddFor <ParticleEmitter>(n => n.CompoundPostPresenter.Add(new UI.SceneView.ParticleEmitterPresenter()));
            DocumentHistory.AddOperationProcessorTypes(new[] {
                typeof(Core.Operations.TimelineHorizontalShift.Processor),
                typeof(Core.Operations.TimelineColumnRemove.Processor),
                typeof(Core.Operations.RemoveKeyframeRange.Processor),
                typeof(Core.Operations.SelectRow.Processor),
                typeof(Core.Operations.RenameAnimationProcessor),
                typeof(Core.Operations.SetProperty.Processor),
                typeof(Core.Operations.SetIndexedProperty.Processor),
                typeof(Core.Operations.RemoveKeyframe.Processor),
                typeof(Core.Operations.SetKeyframe.Processor),
                typeof(Core.Operations.InsertFolderItem.Processor),
                typeof(Core.Operations.AddIntoCollection <,> .Processor),
                typeof(Core.Operations.RemoveFromCollection <,> .Processor),
                typeof(Core.Operations.InsertIntoList.Processor),
                typeof(Core.Operations.RemoveFromList.Processor),
                typeof(Core.Operations.InsertIntoList <,> .Processor),
                typeof(Core.Operations.RemoveFromList <,> .Processor),
                typeof(Core.Operations.UnlinkFolderItem.Processor),
                typeof(Core.Operations.MoveNodes.Processor),
                typeof(Core.Operations.SetMarker.Processor),
                typeof(Core.Operations.DeleteMarker.Processor),
                typeof(Core.Operations.SetComponent.Processor),
                typeof(Core.Operations.DeleteComponent.Processor),
                typeof(Core.Operations.DistortionMeshProcessor),
                typeof(Core.Operations.SyncFolderDescriptorsProcessor),
                typeof(UI.SceneView.ResolutionPreviewOperation.Processor),
                typeof(UI.Timeline.Operations.SelectGridSpan.Processor),
                typeof(UI.Timeline.Operations.DeselectGridSpan.Processor),
                typeof(UI.Timeline.Operations.ClearGridSelection.Processor),
                typeof(UI.Timeline.Operations.ShiftGridSelection.Processor),
                typeof(UI.Timeline.Operations.SetCurrentColumn.Processor),
                typeof(UI.Timeline.Operations.SelectCurveKey.Processor),
                typeof(TriggersValidatorOnSetProperty),
                typeof(TriggersValidatorOnSetKeyframe),
                typeof(UpdateNodesAndApplyAnimatorsProcessor),
                typeof(RowsSynchronizer),
                typeof(Core.Operations.ReplaceContents.Processor),
                typeof(Core.Operations.DeleteRuler.Processor),
                typeof(Core.Operations.CreateRuler.Processor),
            });
            DocumentHistory.AddOperationProcessorTypes(UI.Timeline.Timeline.GetOperationProcessorTypes());

            RegisterCommands();
            InitializeHotkeys();

            AppUserPreferences.Instance.ToolbarModel.RefreshAfterLoad();
            Toolbar = new ToolbarView(dockManager.ToolbarArea, AppUserPreferences.Instance.ToolbarModel);
            RefreshCreateNodeCommands();
            Document.AttachingViews += doc => {
                if (doc.Views.Count == 0)
                {
                    doc.Views.AddRange(new IDocumentView[] {
                        new UI.Inspector.Inspector(inspectorPanel.ContentWidget),
                        new UI.Timeline.Timeline(timelinePanel),
                        new UI.SceneView.SceneView(documentViewContainer),
                        new Panels.HierarchyPanel(searchPanel.ContentWidget),
                        new Panels.BackupHistoryPanel(backupHistoryPanel.ContentWidget),
                        new Panels.AnimationsPanel(animationsPanel.ContentWidget),
                        // Use VisualHintsPanel sigleton because we need preserve its state between documents.
                        VisualHintsPanel.Instance ?? VisualHintsPanel.Initialize(visualHintsPanel),
                        new AttachmentPanel(attachmentPanel),
                    });
                    UI.SceneView.SceneView.ShowNodeDecorationsPanelButton.Clicked = () => dockManager.TogglePanel(visualHintsPanel);
                }
            };
            var proj = AppUserPreferences.Instance.CurrentProject;
            if (proj != null)
            {
                try {
                    new Project(proj).Open();
                } catch {
                    AlertDialog.Show($"Cannot open project '{proj}'. It may be deleted or be otherwise unavailable.");
                }
            }
            OpenDocumentsFromArgs(args);
            WidgetContext.Current.Root.AddChangeWatcher(() => Project.Current, project => TangerineMenu.OnProjectChanged(project));

            WidgetContext.Current.Root.AddChangeWatcher(() => ProjectUserPreferences.Instance.RecentDocuments.Count == 0 ?
                                                        null : ProjectUserPreferences.Instance.RecentDocuments[0], document => TangerineMenu.RebuildRecentDocumentsMenu());

            WidgetContext.Current.Root.AddChangeWatcher(() => AppUserPreferences.Instance.RecentProjects.Count == 0 ?
                                                        null : AppUserPreferences.Instance.RecentProjects[0], document => TangerineMenu.RebuildRecentProjectsMenu());

            new UI.FilesystemView.FilesystemPane(filesystemPanel);
            new UI.RemoteScripting.RemoteScriptingPane(remoteScriptingPanel);
            RegisterGlobalCommands();

            Documentation.Init();
            DocumentationComponent.Clicked = page => Documentation.ShowHelp(page);
        }
示例#10
0
        public void Init(IQFrameworkContainer container)
        {
            Container = container;

            PackageManagerApp.Send <PackageManagerInitCommand>();

            mRootLayout = new VerticalLayout();
            var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout);

            var verticalLayout = new VerticalLayout("box");

            treeNode.Add2Spread(verticalLayout);

            var searchView = new HorizontalLayout("box")
                             .AddTo(verticalLayout);

            searchView.AddChild(new LabelView("搜索:")
                                .FontBold()
                                .FontSize(12)
                                .Width(40));

            searchView.AddChild(
                new TextView().Height(20)
                .Do(search =>
            {
                search.Content
                .Bind(key => { PackageManagerApp.Send(new SearchCommand(key)); }).AddTo(mDisposableList);
            })
                );

            mAccessRightView = new ToolbarView()
                               .Menus(new List <string>()
            {
                "all", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString()
            })
                               .AddTo(verticalLayout)
                               .Do(self =>
            {
                self.Index.Bind(value =>
                {
                    PackageManagerState.AccessRightIndex.Value = value;
                    PackageManagerApp.Send(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddTo(mDisposableList);
            });

            mCategoriesSelectorView = new ToolbarView()
                                      .AddTo(verticalLayout)
                                      .Do(self =>
            {
                self.Index.Bind(value =>
                {
                    PackageManagerState.CategoryIndex.Value = value;
                    PackageManagerApp.Send(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddTo(mDisposableList);
            });

            new PackageListHeaderView()
            .AddTo(verticalLayout);

            var packageList = new VerticalLayout("box")
                              .AddTo(verticalLayout);

            mRepositoryList = new ScrollLayout()
                              .Height(240)
                              .AddTo(packageList);

            PackageManagerState.Categories.Bind(value => { Categories = value; }).AddTo(mDisposableList);

            PackageManagerState.PackageRepositories
            .Bind(list => { this.PackageRepositories = list; }).AddTo(mDisposableList);
        }
示例#11
0
 public void FocusSearchBar()
 {
     IdeApp.Workbench.Present();
     ToolbarView.FocusSearchBar();
 }
 public void FocusSearchBar()
 {
     ToolbarView.FocusSearchBar();
 }
示例#13
0
        public void Init(IQFrameworkContainer container)
        {
            var bindingSet = BindKit.CreateBindingSet(this, new PackageManagerViewModel()
                                                      .InjectSelfWithContainer(mPackageManagerApp.Container)
                                                      .Init());

            mRootLayout = new VerticalLayout();
            var treeNode = new TreeNode(true, LocaleText.FrameworkPackages).AddTo(mRootLayout);

            var verticalLayout = new VerticalLayout("box");

            treeNode.Add2Spread(verticalLayout);


            var searchView = new HorizontalLayout("box")
                             .AddTo(verticalLayout);

            searchView.AddChild(new LabelView("搜索:")
                                .FontBold()
                                .FontSize(12)
                                .Width(40));

            searchView.AddChild(
                new TextView().Height(20)
                .Do(search =>
            {
                bindingSet.Bind(search.Content)
                .For(v => v.OnValueChanged)
                .To(vm => vm.Search)
                .CommandParameter(search.Content);
            })
                );

            mAccessRightView = new ToolbarView()
                               .Menus(new List <string>()
            {
                "all", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString()
            })
                               .AddTo(verticalLayout)
                               .Do(self =>
            {
                bindingSet.Bind(self.Index).For(v => v.Value, v => v.OnValueChanged)
                .To(vm => vm.AccessRightIndex);
            });

            mCategoriesSelectorView = new ToolbarView()
                                      .AddTo(verticalLayout)
                                      .Do(self =>
            {
                bindingSet.Bind(self.Index).For(v => v.Value, v => v.OnValueChanged)
                .To(vm => vm.CategoryIndex);
            });

            new HeaderView()
            .AddTo(verticalLayout);

            var packageList = new VerticalLayout("box")
                              .AddTo(verticalLayout);

            mScrollLayout = new ScrollLayout()
                            .Height(240)
                            .AddTo(packageList);

            // 执行
            TypeEventSystem.Send <IEditorStrangeMVCCommand>(new PackageManagerStartUpCommand());

            bindingSet.Bind().For((v) => v.PackageDatas)
            .To(vm => vm.PackageDatas);

            bindingSet.Bind().For(v => v.Categories)
            .To(vm => vm.Categories);

            bindingSet.Build();
        }
示例#14
0
		void BuildUI (Bundle savedInstanceState)
		{
			var hMargin = 20;

			RequestWindowFeature (WindowFeatures.NoTitle);

			Title = state.Service.ShareTitle;

			layout = new LinearLayout (this) {
				Orientation = Orientation.Vertical,
			};
			layout.SetBackgroundColor (Color.White);
			SetContentView (layout);

			//
			// Toolbar
			//
			toolbar = new ToolbarView (this, Title);
			toolbar.IsProgressing = state.IsSending;
			toolbar.Clicked += (sender, args) => StartSending();
			layout.AddView (toolbar);

			//
			// Scroll content
			//
			var scroller = new ScrollView (this) {
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) {
				},
			};
			var scrollContent = new LinearLayout (this) {
				Orientation = Orientation.Vertical,
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) {
				},
			};
			scroller.ScrollbarFadingEnabled = true;
			scroller.AddView (scrollContent);
			layout.AddView (scroller);

			//
			// Account
			//
			var acctLabel = new TextView (this) {
				Text = "From",
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent) {
					RightMargin = 12,
				},
			};
			acctLabel.SetTextColor (Color.DarkGray);
			acctLabel.SetTextSize (ComplexUnitType.Sp, LabelTextSize);

			acctPicker = new TextView (this) {
				Typeface = Typeface.DefaultFromStyle (TypefaceStyle.Bold),
				Clickable = true,
			};
			acctPicker.SetTextColor (Color.Black);
			acctPicker.SetTextSize (ComplexUnitType.Sp, LabelTextSize);
			acctPicker.Click += PickAccount;
			UpdateAccountUI ();

			var acctLayout = new LinearLayout (this) {
				Orientation = Orientation.Horizontal,
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) {
					TopMargin = 24,
					LeftMargin = hMargin,
					RightMargin = hMargin,
				},
			};
			acctLayout.SetGravity (GravityFlags.Left);
			acctLayout.AddView (acctLabel);
			acctLayout.AddView (acctPicker);

			scrollContent.AddView (acctLayout);

			//
			// Attachments
			//
			var attachLayout = new LinearLayout (this) {
				Orientation = Orientation.Vertical,
				Visibility = state.Item.HasAttachments ? ViewStates.Visible : ViewStates.Gone,
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) {
					TopMargin = 30,
					LeftMargin = hMargin,
					RightMargin = hMargin,
				},
			};

			foreach (var x in state.Item.Links) {
				attachLayout.AddView (new AttachmentView (this, x.AbsoluteUri));
			}
			foreach (var x in state.Item.Images) {
				attachLayout.AddView (new AttachmentView (this, x.Filename, x.Length));
			}
			foreach (var x in state.Item.Files) {
				attachLayout.AddView (new AttachmentView (this, x.Filename, x.Length));
			}

			scrollContent.AddView (attachLayout);

			//
			// Composer
			//
			composer = new EditText (this) {
				Id = 301,
				Text = savedInstanceState != null ? savedInstanceState.GetString ("ComposerText") : state.Item.Text,
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) {
					TopMargin = 24,
					LeftMargin = hMargin - 14,
					RightMargin = hMargin - 14,
				},
			};
			composer.SetTextSize (ComplexUnitType.Sp, ComposeTextSize);
			composer.SetTextColor (Color.Black);
			composer.SetBackgroundColor (Color.White);
			composer.AfterTextChanged += delegate {
				UpdateRemainingTextUI ();
			};
			scrollContent.AddView (composer);

			remaining = new TextView (this) {
				LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent) {
					TopMargin = 2,
					LeftMargin = hMargin,
					RightMargin = hMargin,
				},
			};
			remaining.SetTextSize (ComplexUnitType.Sp, ComposeTextSize);
			UpdateRemainingTextUI ();
			scrollContent.AddView (remaining);
		}