private void CreateFloatingWindow(WindowPlacement placement) { var window = new Window(new WindowOptions { FixedSize = false, MacWindowTabbingMode = MacWindowTabbingMode.Disallowed, #if WIN Icon = new System.Drawing.Icon(new EmbeddedResource(AppIconPath, "Tangerine").GetResourceStream()), #endif Type = WindowType.Tool, }); window.UnhandledExceptionOnUpdate += e => UnhandledExceptionOccurred?.Invoke(e); SetDropHandler(window); window.Closing += reason => { if (reason == CloseReason.MainWindowClosing) { return(true); } var windowPlacement = Model.WindowPlacements.FirstOrDefault(p => p.WindowWidget?.Window == window); if (windowPlacement != null) { windowPlacement.WindowWidget = null; DockHierarchy.HideWindowPanels(windowPlacement); } return(true); }; window.ClientSize = placement.Size; var windowWidget = new ThemedInvalidableWindowWidget(window) { Layout = new StackLayout(), }; windowWidget.CompoundPostPresenter.Add(new WidgetBoundsPresenter(ColorTheme.Current.Docking.PanelTitleSeparator, 1)); windowWidget.WidgetContext.GestureManager = new HelpModeGestureManager(windowWidget.WidgetContext); windowWidget.Components.Add(new RequestedDockingComponent()); windowWidget.CompoundPostPresenter.Add(new DockingPresenter()); windowWidget.AddChangeWatcher(() => windowWidget.Window.State, value => placement.State = value); placement.WindowWidget = windowWidget; window.ClientPosition = placement.Position; window.Moved += () => placement.Position = window.ClientPosition; window.Resized += (deviceRotated) => placement.Size = window.ClientSize; }
public Result Show(Marker marker, bool canDelete) { Widget buttonsPanel; Button deleteButton; Button okButton; Button cancelButton; DropDownList actionSelector; EditBox markerIdEditor; ThemedDropDownList jumpToSelector; Result result; var window = new Window(new WindowOptions { FixedSize = true, Title = "Marker properties", Visible = false, Style = WindowStyle.Dialog }); jumpToSelector = new ThemedDropDownList(); foreach (var m in Document.Current.Container.Markers) { jumpToSelector.Items.Add(new ThemedDropDownList.Item(m.Id, m)); } jumpToSelector.Text = marker.JumpTo; var rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { new Widget { Layout = new TableLayout{ ColCount = 2, RowCount = 3, Spacing = 8, ColDefaults = { new LayoutCell(Alignment.RightCenter, 0.5f, 0), new LayoutCell(Alignment.LeftCenter, 1, 0) } }, Nodes = { new ThemedSimpleText("Marker Id"), (markerIdEditor = new ThemedEditBox{ Text = marker.Id, MinSize= Theme.Metrics.DefaultEditBoxSize * new Vector2(2, 1) }), new ThemedSimpleText("Action"), (actionSelector = new ThemedDropDownList{ Items = { new DropDownList.Item("Play", MarkerAction.Play), new DropDownList.Item("Jump", MarkerAction.Jump), new DropDownList.Item("Stop", MarkerAction.Stop), new DropDownList.Item("Destroy", MarkerAction.Destroy), }, Value = marker.Action }), new ThemedSimpleText("Jump to"), jumpToSelector, } }, (buttonsPanel = new Widget{ Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton("Ok")), (cancelButton = new ThemedButton("Cancel")), } }) } }; if (canDelete) { deleteButton = new ThemedButton("Delete"); buttonsPanel.AddNode(deleteButton); deleteButton.Clicked += () => { result = Result.Delete; window.Close(); }; } rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.Add(new KeyPressHandler(Key.Escape, (input, key) => { input.ConsumeKey(key); window.Close(); })); okButton.Clicked += () => { result = Result.Ok; window.Close(); }; cancelButton.Clicked += window.Close; okButton.SetFocus(); result = Result.Cancel; window.ShowModal(); if (result == Result.Ok) { marker.Id = markerIdEditor.Text; marker.Action = (MarkerAction)actionSelector.Value; marker.JumpTo = jumpToSelector.Text; } return(result); }
public static void ShowFor(Model3D source) { // Do not show others attachment dialogs if one is already present if (history != null) { return; } history = new DocumentHistory(); Button cancelButton; var attachment = new Model3DAttachmentParser().Parse(source.ContentsPath) ?? new Model3DAttachment { ScaleFactor = 1 }; var window = new Window(new WindowOptions { ClientSize = new Vector2(700, 400), FixedSize = false, Title = "Attachment3D", MinimumDecoratedSize = new Vector2(500, 300), }); var content = new TabbedWidget(); content.AddTab("General", CreateGeneralPane(attachment), true); content.AddTab("Material Effects", CreateMaterialEffectsPane(attachment)); content.AddTab("Components", CreateComponentsPane(attachment)); content.AddTab("Mesh Options", CreateMeshOptionsPane(attachment)); content.AddTab("Animations", CreateAnimationsPane(attachment)); Button okButton; WindowWidget rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { content, new Widget { Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Padding = new Thickness { Top = 5 }, Nodes = { (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; cancelButton.Clicked += () => { window.Close(); history = null; UserPreferences.Instance.Load(); }; okButton.Clicked += () => { try { CheckErrors(attachment, source); window.Close(); history = null; // Since attachment dialog not present as modal window, document can be rolled back with "undo" // operation to the state when source isn't presented or source content path isn't set. // So check it out before saving. if (source.DescendantOf(Document.Current.RootNode) && source.ContentsPath != null) { Model3DAttachmentParser.Save(attachment, System.IO.Path.Combine(Project.Current.AssetsDirectory, source.ContentsPath)); } } catch (Lime.Exception e) { new AlertDialog(e.Message).Show(); } }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); UserPreferences.Instance.Load(); } }); rootWidget.Tasks.AddLoop(() => { if (!Command.Undo.IsConsumed()) { Command.Undo.Enabled = history.CanUndo(); if (Command.Undo.WasIssued()) { Command.Undo.Consume(); history.Undo(); } } if (!Command.Redo.IsConsumed()) { Command.Redo.Enabled = history.CanRedo(); if (Command.Redo.WasIssued()) { Command.Redo.Consume(); history.Redo(); } } }); }
public SaveRulerDialog(Ruler ruler) { ThemedButton cancelButton; ThemedButton okButton; CheckBox checkBox; EditBox editBox; window = new Window(new WindowOptions { Title = "Save Ruler", Visible = false, Style = WindowStyle.Dialog, }); WindowWidget rootWidget = new ThemedInvalidableWindowWidget(window) { LayoutBasedWindowSize = true, Padding = new Thickness(8), Layout = new VBoxLayout { Spacing = 16 }, Nodes = { new Widget { Layout = new TableLayout{ ColumnCount = 2, RowCount = 2, Spacing = 8, ColumnDefaults = { new DefaultLayoutCell(Alignment.RightCenter, 0.5f, 0), new DefaultLayoutCell(Alignment.LeftCenter, 1, 0) } }, Nodes = { new ThemedSimpleText("Ruler name"), (editBox = new ThemedEditBox{ MinWidth = 150 }), new ThemedSimpleText("Anchor to root"), (checkBox = new ThemedCheckBox()) } }, new Widget { Layout = new HBoxLayout{ Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton("Ok")), (cancelButton = new ThemedButton("Cancel")), } } } }; cancelButton.Clicked += window.Close; okButton.AddChangeWatcher(() => editBox.Text, (text) => okButton.Enabled = !string.IsNullOrEmpty(text)); okButton.Clicked += () => { ruler.Name = editBox.Text; ruler.AnchorToRoot = checkBox.Checked; result = true; window.Close(); }; rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); editBox.SetFocus(); }
public ManageRulersDialog() { Button cancelButton; Button okButton; var window = new Window(new WindowOptions { Title = "Manage Rulers", Style = WindowStyle.Dialog, ClientSize = new Vector2(300, 200), Visible = false }); var collection = new ObservableCollection <Ruler>(ProjectUserPreferences.Instance.Rulers); var lines = new List <RulerLine>(); ThemedScrollView container; WindowWidget rootWidget = new ThemedInvalidableWindowWidget(window) { Padding = new Thickness(8), Layout = new VBoxLayout(), Nodes = { (container = new ThemedScrollView { Padding = new Thickness { Right = 10 }, }), new Widget { Padding = new Thickness { Top = 10 }, Layout = new HBoxLayout { Spacing = 8 }, LayoutCell = new LayoutCell(Alignment.RightCenter), Nodes = { (okButton = new ThemedButton { Text = "Ok" }), (cancelButton = new ThemedButton { Text = "Cancel" }), } } } }; container.CompoundPresenter.Add(new SyncDelegatePresenter <Widget>( w => { if (w.Parent == null) { return; } var listView = (ThemedScrollView)w; w.PrepareRendererState(); var i = (int)(listView.ScrollPosition / RowHeight); var start = 0f; while (true) { float height; if (start == 0f) { height = RowHeight - listView.ScrollPosition % RowHeight; } else { height = start + RowHeight <= w.Size.Y ? RowHeight : w.Size.Y - start; } var color = i % 2 == 0 ? ColorTheme.Current.Inspector.StripeBackground2 : ColorTheme.Current.Inspector.StripeBackground1; Renderer.DrawRect(new Vector2(0, start), new Vector2(w.Size.X, start + height), color); start += height; i++; if (start >= w.Size.Y) { break; } } })); container.Content.Layout = new VBoxLayout { Spacing = 4 }; var list = new Widget { Layout = new VBoxLayout(), }; container.Content.AddNode(list); list.Components.Add(new WidgetFactoryComponent <Ruler>(ruler => new RulerRowView(ruler, // Delete button clicked () => { collection.Remove(ruler); container.ScrollPosition = container.ScrollPosition > RowHeight ? container.ScrollPosition - RowHeight : 0; }, // Edit button clicked () => { if (ruler.AnchorToRoot) { var size = Document.Current.Container.AsWidget.Size / 2; foreach (var line in ruler.Lines) { line.Value += (line.RulerOrientation == RulerOrientation.Horizontal ? size.Y : size.X); } } collection.Remove(ruler); lines.AddRange(ruler.Lines); }), collection)); okButton.Clicked += () => { var temp = ProjectUserPreferences.Instance.Rulers.ToList(); foreach (var ruler in temp.Except(collection)) { ProjectUserPreferences.Instance.Rulers.Remove(ruler); } ProjectUserPreferences.Instance.ActiveRuler.Lines.AddRange(lines); if (!ProjectUserPreferences.Instance.RulerVisible && lines.Count != 0) { (SceneViewCommands.ToggleDisplayRuler as Command)?.Issue(); } Core.UserPreferences.Instance.Save(); Application.InvalidateWindows(); window.Close(); }; cancelButton.Clicked += () => window.Close(); rootWidget.FocusScope = new KeyboardFocusScope(rootWidget); rootWidget.LateTasks.AddLoop(() => { if (rootWidget.Input.ConsumeKeyPress(Key.Escape)) { window.Close(); UserPreferences.Instance.Load(); } }); okButton.SetFocus(); window.ShowModal(); }