// static string Translate(string text) { return(EditorLocalization.Translate("CSharpScript", text)); }
string Translate(string text) { return(EditorLocalization.Translate("PackagesWindow", text)); }
private void kryptonButtonUninstall_Click(object sender, EventArgs e) { var filesToDelete = new List <string>(); bool mustRestart = false; //get list of files to delete if (File.Exists(selectedPackage.FullFilePath)) { //get list of files from the package archive var info = PackageManager.ReadPackageArchiveInfo(selectedPackage.FullFilePath, out var error); if (info == null) { ScreenNotifications.Show("Could not read the package info.", true); Log.Warning(error); return; } foreach (var file in info.Files) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); if (File.Exists(fullName)) { filesToDelete.Add(file); } } mustRestart = info.MustRestart; } else { //get list of files from selectedPackage.Files in case when the archive file is not exists var str = selectedPackage.Files.Trim(new char[] { ' ', '\r', '\n' }); var files = str.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var file in files) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); if (File.Exists(fullName)) { filesToDelete.Add(file); } } //!!!!mustRestart mustRestart = true; } if (filesToDelete.Count == 0) { return; } var text = string.Format(Translate("Uninstall {0}?\n\n{1} files will deleted."), selectedPackage.GetDisplayName(), filesToDelete.Count); if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) != EDialogResult.Yes) { return; } var filesToDeletionAtStartup = new List <string>(); try { //remove cs files from Project.csproj try { var toRemove = new List <string>(); foreach (var file in filesToDelete) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); if (Path.GetExtension(fullName).ToLower() == ".cs") { toRemove.Add(VirtualPathUtility.NormalizePath(fullName)); } } if (toRemove.Count != 0) { CSharpProjectFileUtility.UpdateProjectFile(null, toRemove, out _); } } catch { } //delete files foreach (var file in filesToDelete) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); try { File.Delete(fullName); } catch (UnauthorizedAccessException) { filesToDeletionAtStartup.Add(file); } catch (IOException) { filesToDeletionAtStartup.Add(file); } } //delete empty folders { var allFolders = new ESet <string>(); foreach (var file in filesToDelete) { var f = Path.GetDirectoryName(file); while (!string.IsNullOrEmpty(f)) { allFolders.AddWithCheckAlreadyContained(f); f = Path.GetDirectoryName(f); } } var list = allFolders.ToArray(); CollectionUtility.MergeSort(list, delegate(string f1, string f2) { var levels1 = f1.Split(new char[] { '\\' }).Length; var levels2 = f2.Split(new char[] { '\\' }).Length; return(levels2 - levels1); }); foreach (var folder in list) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, folder); if (Directory.Exists(fullName) && IsDirectoryEmpty(fullName)) { Directory.Delete(fullName); } } } PackageManager.ChangeInstalledState(selectedPackage.Name, false); } catch (Exception e2) { EditorMessageBox.ShowWarning(e2.Message); return; } if (filesToDeletionAtStartup.Count != 0) { PackageManager.AddFilesToDeletionAtStartup(filesToDeletionAtStartup); } needUpdateList = true; if (mustRestart) { ShowRestartLabel(); } ScreenNotifications.Show(EditorLocalization.Translate("General", "The package has been successfully uninstalled.")); }
// string Translate(string text) { return(EditorLocalization.Translate("GroupOfObjects", text)); }
string Translate(string text) { return(EditorLocalization.Translate("Backstage", text)); }
string Translate(string text) { return(EditorLocalization.Translate("MeshInSpace", text)); }
private void HierarchicalContainer1_PropertyDisplayNameOverride(HierarchicalContainer sender, HCItemProperty property, ref string displayName) { displayName = EditorLocalization.Translate("ContentBrowser.Options", displayName); }
public static void ShowRenameComponentDialog(Component component) { var document = GetDocumentByComponent(component); var form = new OKCancelTextBoxForm(EditorLocalization.TranslateLabel("General", "Name:"), component.Name, EditorLocalization.Translate("General", "Rename"), delegate(string text, ref string error) { if (!ComponentUtility.IsValidComponentName(text, out string error2)) { error = error2; return(false); } return(true); }, delegate(string text, ref string error) { if (text != component.Name) { var oldValue = component.Name; //change Name component.Name = text; //undo var undoItems = new List <UndoActionPropertiesChange.Item>(); var property = (Metadata.Property)MetadataManager.GetTypeOfNetType( typeof(Component)).MetadataGetMemberBySignature("property:Name"); undoItems.Add(new UndoActionPropertiesChange.Item(component, property, oldValue, new object[0])); var action = new UndoActionPropertiesChange(undoItems.ToArray()); document.UndoSystem.CommitAction(action); document.Modified = true; } return(true); } ); form.ShowDialog(); }
static string Translate(string text) { return(EditorLocalization.Translate("MaterialDocumentWindow", text)); }
string Translate(string text) { return(EditorLocalization.Translate("ImportWindow", text)); }
// static string Translate(string text) { return(EditorLocalization.Translate("Import3D", text)); }
public static string Translate(string text) { return(EditorLocalization.Translate("ContextMenu", text)); }
//!!!!тут? public static void AddNewObjectItem(IList <KryptonContextMenuItemBase> items, bool enabled, TryNewObjectDelegate select) { //New object { var newObjectItem = new KryptonContextMenuItem(Translate("New Object"), EditorResourcesCache.New, null); newObjectItem.Enabled = enabled; // CanNewObject( out _ ); var items2 = new List <KryptonContextMenuItemBase>(); //Select { var item2 = new KryptonContextMenuItem(Translate("Select..."), null, delegate(object s, EventArgs e2) { select(null); //TryNewObject( mouse, null ); }); items2.Add(item2); } //separator items2.Add(new KryptonContextMenuSeparator()); //ResourcesWindowItems { ResourcesWindowItems.PrepareItems(); var menuItems = new Dictionary <string, KryptonContextMenuItem>(); KryptonContextMenuItem GetBrowserItemByPath(string path) { menuItems.TryGetValue(path, out var item); return(item); } foreach (var item in ResourcesWindowItems.Items) { //custom filtering if (!EditorUtility.PerformResourcesWindowItemVisibleFilter(item)) { continue; } //skip if (!typeof(Component).IsAssignableFrom(item.Type)) { continue; } //remove Base prefix from items var itemPathFixed = item.Path; { var prefix = "Base\\"; if (itemPathFixed.Length > prefix.Length && itemPathFixed.Substring(0, prefix.Length) == prefix) { itemPathFixed = itemPathFixed.Substring(prefix.Length); } } var strings = itemPathFixed.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); string path = ""; for (int n = 0; n < strings.Length; n++) { path = Path.Combine(path, strings[n]); //get parent item KryptonContextMenuItem parentItem = null; if (n != 0) { parentItem = GetBrowserItemByPath(Path.GetDirectoryName(path)); } if (GetBrowserItemByPath(path) == null) { //add item KryptonContextMenuItem menuItem = null; //is folder bool isFolder = n < strings.Length - 1; if (isFolder) { var text = EditorLocalization.Translate("ContentBrowser.Group", strings[n]); menuItem = new KryptonContextMenuItem(text, null, null); //ResourcesWindowItems.GroupDescriptions.TryGetValue( path, out var description ); //if( !string.IsNullOrEmpty( description ) ) // menuItem2.Description = description; } else { var type = MetadataManager.GetTypeOfNetType(item.Type); menuItem = new KryptonContextMenuItem(strings[n], EditorResourcesCache.Type, delegate(object s, EventArgs e2) { var type2 = (Metadata.TypeInfo)((KryptonContextMenuItem)s).Tag; select(type2); //TryNewObject( mouse, type2 ); }); menuItem.Tag = type; //menuItem2.imageKey = GetTypeImageKey( type ); menuItem.Enabled = !item.Disabled; } if (parentItem != null) { if (parentItem.Items.Count == 0) { parentItem.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[0])); } var list = (KryptonContextMenuItems)parentItem.Items[0]; list.Items.Add(menuItem); //parentItem.children.Add( menuItem ); } menuItems.Add(path, menuItem); if (n == 0) { items2.Add(menuItem); } } } } } //Favorites if (EditorFavorites.AllowFavorites) { var favoritesItem = new KryptonContextMenuItem(EditorLocalization.Translate("ContentBrowser.Group", "Favorites"), null, null); var types = new List <Metadata.TypeInfo>(); foreach (var typeName in EditorFavorites.Favorites.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { var type = MetadataManager.GetType(typeName); if (type != null) { types.Add(type); } } foreach (var type in types) { var menuItem = new KryptonContextMenuItem(type.DisplayName, EditorResourcesCache.Type, delegate(object s, EventArgs e2) { var type2 = (Metadata.TypeInfo)((KryptonContextMenuItem)s).Tag; select(type2); }); menuItem.Tag = type; if (favoritesItem.Items.Count == 0) { favoritesItem.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[0])); } var list = (KryptonContextMenuItems)favoritesItem.Items[0]; list.Items.Add(menuItem); } items2.Add(favoritesItem); } newObjectItem.Items.Add(new KryptonContextMenuItems(items2.ToArray())); items.Add(newObjectItem); //KryptonContextMenuItem item = new KryptonContextMenuItem( Translate( "New object" ), Properties.Resources.New_16, delegate ( object s, EventArgs e2 ) //{ // TryNewObject( mouse, null ); //} ); //item.Enabled = CanNewObject( out _ ); //items.Add( item ); } }
string Translate(string text) { return(EditorLocalization.Translate("ProjectShortcuts", text)); }
void UpdateInfoControls() { string text1; string text2; var objs = SettingsPanel.selectedObjects; if (objs.Length == 1) { var obj = objs[0]; var component = obj as Component; if (component != null) { if (!string.IsNullOrEmpty(component.Name)) { text1 = component.Name; text2 = component.BaseType.ToString(); } else { text1 = component.BaseType.ToString(); text2 = text1; } } else { text1 = obj.ToString(); text2 = ""; } } else { text1 = string.Format(EditorLocalization.Translate("SettingsWindow", "{0} objects"), objs.Length); text2 = ""; } if (kryptonLabel1.Text != text1) { kryptonLabel1.Text = text1; } if (kryptonLabel2.Text != text2) { kryptonLabel2.Text = text2; } //var box = richTextBox1; //var objs = SettingsPanel.selectedObjects; //if( objs.Length == 1 ) //{ // var obj = objs[ 0 ]; // box.Text = ""; // box.SelectionStart = box.TextLength; // box.SelectionLength = 0; // var originalFont = box.SelectionFont; // //!!!!так ли // var titleFont = new System.Drawing.Font( "Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, // System.Drawing.GraphicsUnit.Point, ( (byte)( 204 ) ) ); // box.SelectionFont = titleFont;// new Font( box.SelectionFont, FontStyle.Bold ); // box.AppendText( obj.ToString() ); // box.SelectionFont = originalFont; // //!!!!не так. надо тут уже Component проверять // //box.AppendText( " type" ); // var component = obj as Component; // if( component != null ) // { // box.AppendText( "\r\n" ); // box.AppendText( "type: " + component.BaseType.ToString() ); // if( !string.IsNullOrEmpty( component.Name ) ) // { // box.AppendText( "\r\n" ); // box.AppendText( "name: " + component.Name ); // } // } // //box.SelectionFont = new Font( box.SelectionFont, FontStyle.Bold ); // //box.AppendText( obj.ToString() + "\r\n" ); // //box.SelectionFont = originalFont; // //box.AppendText( "Second line\r\n" ); // //box.AppendText( "\r\n" ); // //box.AppendText( "Third line" ); // //box.SelectionColor = Color.Green; // //box.AppendText( " green" ); // //box.SelectionColor = box.ForeColor; //} //else //{ // //!!!!! // box.Text = string.Format( "{0} objects", objs.Length ); //} //string text; //var objs = Provider.SelectedObjects; //if( objs.Length == 1 ) //{ // xx xx; // text = objs[ 0 ].ToString(); //} //else //{ // text = string.Format( "{0} objects", objs.Length ); //} //labelName.Text = text; }
private void ObjectsBrowser1_OverrideItemText(ContentBrowser sender, ContentBrowser.Item item, ref string text) { text = EditorLocalization.Translate("ProjectSettings.Page", text); }
string Translate(string text) { return(EditorLocalization.Translate("MessageLogOptionsForm", text)); }
void ThreadDownload() { //var fileName = Path.Combine( PackageManager.PackagesFolder, Path.GetFileName( downloadingAddress ) ); var cancelled = false; try { using (WebClient client = new WebClient()) { downloadingClient = client; client.DownloadProgressChanged += MyWebClient_DownloadProgressChanged; client.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) { //releases blocked thread lock (e.UserState) Monitor.Pulse(e.UserState); cancelled = e.Cancelled; }; var syncObject = new object(); lock ( syncObject ) { client.DownloadFileAsync(new Uri(downloadingAddress), downloadingDestinationPath, syncObject); //This would block the thread until download completes Monitor.Wait(syncObject); } downloadingClient = null; } } catch (Exception e) { Log.Warning(e.Message); return; } finally { try { if (!cancelled) { if (File.Exists(downloadingDestinationPath) && new FileInfo(downloadingDestinationPath).Length == 0) { File.Delete(downloadingDestinationPath); cancelled = true; } } if (cancelled) { if (File.Exists(downloadingDestinationPath)) { File.Delete(downloadingDestinationPath); } } } catch { } downloadingPackageName = ""; downloadingAddress = ""; downloadingDestinationPath = ""; downloadProgress = 0; downloadingClient = null; } needUpdateList = true; if (!cancelled) { ScreenNotifications.Show(EditorLocalization.Translate("General", "The package has been successfully downloaded.")); } }
void RibbonButtonsCheckForRecreate() { var config = ProjectSettings.Get.RibbonAndToolbarActions; if (ribbonUpdatedForConfiguration == null || !config.Equals(ribbonUpdatedForConfiguration) || needRecreatedRibbonButtons) { ribbonUpdatedForConfiguration = config.Clone(); needRecreatedRibbonButtons = false; ribbonLastSelectedTabTypeByUser_DisableUpdate = true; kryptonRibbon.RibbonTabs.Clear(); foreach (var tabSettings in ProjectSettings.Get.RibbonAndToolbarActions.RibbonTabs) { if (!tabSettings.Enabled) { continue; } //can be null EditorRibbonDefaultConfiguration.Tab tab = null; if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic) { tab = EditorRibbonDefaultConfiguration.GetTab(tabSettings.Name); } var ribbonTab = new KryptonRibbonTab(); ribbonTab.Tag = tab; if (tabSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.TabItem.TypeEnum.Basic) { ribbonTab.Text = EditorLocalization.Translate("Ribbon.Tab", tabSettings.Name); } else { ribbonTab.Text = tabSettings.Name; } ribbonTab.KeyTip = GetTabKeyTip(tabSettings.Name); kryptonRibbon.RibbonTabs.Add(ribbonTab); var usedKeyTips = new ESet <string>(); string GetKeyTip(string name) { foreach (var c in name + alphabetNumbers) { var s = c.ToString().ToUpper(); if (s != " " && !usedKeyTips.Contains(s)) { usedKeyTips.AddWithCheckAlreadyContained(s); return(s); } } return(""); } foreach (var groupSettings in tabSettings.Groups) { if (!groupSettings.Enabled) { continue; } var ribbonGroup = new KryptonRibbonGroup(); if (groupSettings.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.GroupItem.TypeEnum.Basic) { ribbonGroup.TextLine1 = EditorLocalization.Translate("Ribbon.Group", groupSettings.Name); } else { ribbonGroup.TextLine1 = groupSettings.Name; } ribbonGroup.DialogBoxLauncher = false; //!!!!для группы Transform можно было бы в настройки снеппинга переходить ribbonTab.Groups.Add(ribbonGroup); foreach (var groupSettingsChild in groupSettings.Actions) { if (!groupSettingsChild.Enabled) { continue; } //sub group if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.SubGroupOfActions) { EditorRibbonDefaultConfiguration.Group subGroup = null; if (tab != null) { var group = tab.Groups.Find(g => g.Name == groupSettings.Name); if (group != null) { foreach (var child in group.Children) { var g = child as EditorRibbonDefaultConfiguration.Group; if (g != null && g.Name == groupSettingsChild.Name) { subGroup = g; break; } } } } if (subGroup != null) { var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var button = new KryptonRibbonGroupButton(); button.Tag = "SubGroup"; //button.Tag = action; var str = subGroup.DropDownGroupText.Item1; if (subGroup.DropDownGroupText.Item2 != "") { str += "\n" + subGroup.DropDownGroupText.Item2; } var str2 = EditorLocalization.Translate("Ribbon.Action", str); var strs = str2.Split(new char[] { '\n' }); button.TextLine1 = strs[0]; if (strs.Length > 1) { button.TextLine2 = strs[1]; } //button.TextLine1 = subGroup.DropDownGroupText.Item1; //button.TextLine2 = subGroup.DropDownGroupText.Item2; if (subGroup.DropDownGroupImageSmall != null) { button.ImageSmall = subGroup.DropDownGroupImageSmall; } else if (subGroup.DropDownGroupImageLarge != null) { button.ImageSmall = EditorAction.ResizeImage(subGroup.DropDownGroupImageLarge, 16, 16); } button.ImageLarge = subGroup.DropDownGroupImageLarge; //EditorLocalization.Translate( "EditorAction.Description", if (!string.IsNullOrEmpty(subGroup.DropDownGroupDescription)) { button.ToolTipBody = EditorLocalization.Translate("EditorAction.Description", subGroup.DropDownGroupDescription); } else { button.ToolTipBody = subGroup.Name; } button.ButtonType = GroupButtonType.DropDown; button.ShowArrow = subGroup.ShowArrow; button.KryptonContextMenu = new KryptonContextMenu(); RibbonSubGroupAddItemsRecursive(subGroup, button.KryptonContextMenu.Items); tripple.Items.Add(button); } } //action if (groupSettingsChild.Type == Component_ProjectSettings.RibbonAndToolbarActionsClass.ActionItem.TypeEnum.Action) { var action = EditorActions.GetByName(groupSettingsChild.Name); if (action != null) { if (action.ActionType == EditorAction.ActionTypeEnum.Button || action.ActionType == EditorAction.ActionTypeEnum.DropDown) { //Button, DropDown var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupButton(); //!!!! //control.ImageSmall = NeoAxis.Properties.Resources.Android_16; control.Tag = action; var str = action.RibbonText.Item1; if (action.RibbonText.Item2 != "") { str += "\n" + action.RibbonText.Item2; } var str2 = EditorLocalization.Translate("Ribbon.Action", str); var strs = str2.Split(new char[] { '\n' }); control.TextLine1 = strs[0]; if (strs.Length > 1) { control.TextLine2 = strs[1]; } //control.TextLine1 = action.RibbonText.Item1; //control.TextLine2 = action.RibbonText.Item2; control.ImageSmall = action.GetImageSmall(); control.ImageLarge = action.GetImageBig(); control.ToolTipBody = action.ToolTip; control.KeyTip = GetKeyTip(action.Name); //_buttonType = GroupButtonType.Push; //_toolTipImageTransparentColor = Color.Empty; //_toolTipTitle = string.Empty; //_toolTipBody = string.Empty; //_toolTipStyle = LabelStyle.SuperTip; if (action.ActionType == EditorAction.ActionTypeEnum.DropDown) { control.ButtonType = GroupButtonType.DropDown; control.KryptonContextMenu = action.DropDownContextMenu; } control.Click += Button_Click; tripple.Items.Add(control); } else if (action.ActionType == EditorAction.ActionTypeEnum.Slider) { //Slider var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupSlider(); control.Tag = action; control.ToolTipBody = action.ToolTip; control.Control.Size = new System.Drawing.Size((int)((float)control.Control.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer2.Size = new System.Drawing.Size((int)((float)control.Control.kryptonSplitContainer2.Size.Width * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer2.Panel1MinSize = (int)((float)control.Control.kryptonSplitContainer2.Panel1MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.Panel2MinSize = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.SplitterDistance = 10000; control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1); control.Control.Init(action.Slider.Minimum, action.Slider.Maximum, action.Slider.ExponentialPower); control.Control.SetValue(action.Slider.Value); control.Control.Tag = action; control.Control.ValueChanged += Slider_ValueChanged; tripple.Items.Add(control); } //else if( action.ActionType == EditorAction.ActionTypeEnum.ComboBox ) //{ // //ComboBox // var tripple = new KryptonRibbonGroupTriple(); // ribbonGroup.Items.Add( tripple ); // var control = new KryptonRibbonGroupComboBox(); // control.Tag = action; // control.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; // foreach( var item in action.ComboBox.Items ) // control.Items.Add( item ); // if( control.Items.Count != 0 ) // control.SelectedIndex = 0; // //control.MinimumLength = action.Slider.Length; // //control.MaximumLength = action.Slider.Length; // control.SelectedIndexChanged += ComboBox_SelectedIndexChanged; // tripple.Items.Add( control ); //} else if (action.ActionType == EditorAction.ActionTypeEnum.ListBox) { //ListBox var tripple = new KryptonRibbonGroupTriple(); ribbonGroup.Items.Add(tripple); var control = new KryptonRibbonGroupListBox(); control.Tag = action; control.ToolTipBody = action.ToolTip; control.Control.Size = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer1.Size = new System.Drawing.Size((int)((float)action.ListBox.Length * EditorAPI.DPIScale), control.Control.Size.Height); control.Control.kryptonSplitContainer1.Panel2MinSize = (int)((float)control.Control.kryptonSplitContainer1.Panel2MinSize * EditorAPI.DPIScale); control.Control.kryptonSplitContainer1.SplitterDistance = 10000; //if( action.ListBox.Length != 172 ) // control.Control.Size = new System.Drawing.Size( action.ListBox.Length, control.Control.Size.Height ); control.Control.kryptonLabel1.Text = EditorLocalization.Translate("Ribbon.Action", action.RibbonText.Item1); var browser = control.Control.contentBrowser1; if (action.ListBox.Mode == EditorAction.ListBoxSettings.ModeEnum.Tiles) { browser.ListViewModeOverride = new ContentBrowserListModeTilesRibbon(browser); browser.Options.PanelMode = ContentBrowser.PanelModeEnum.List; browser.Options.ListMode = ContentBrowser.ListModeEnum.Tiles; browser.UseSelectedTreeNodeAsRootForList = false; browser.Options.Breadcrumb = false; browser.ListViewBorderDraw = BorderSides.Left | BorderSides.Right | BorderSides.Bottom; browser.Options.TileImageSize = (int)((float)23 * EditorAPI.DPIScale); //browser.Options.TileImageSize = 28;// 32; } else { browser.RemoveTreeViewIconsColumn(); browser.TreeView.RowHeight -= 2; } browser.Tag = action; //update items control.SetItems(action.ListBox.Items); browser.ItemAfterSelect += ListBrowser_ItemAfterSelect; if (browser.Items.Count != 0) { browser.SelectItems(new ContentBrowser.Item[] { browser.Items.ToArray()[0] }); } //browser.ItemAfterSelect += ListBrowser_ItemAfterSelect; tripple.Items.Add(control); } } } } } //select var tabType = ""; if (tab != null) { tabType = tab.Type; } if (ribbonLastSelectedTabTypeByUser != "" && tabType == ribbonLastSelectedTabTypeByUser) { kryptonRibbon.SelectedTab = ribbonTab; } } ribbonLastSelectedTabTypeByUser_DisableUpdate = false; } }
public StartPageWindow() { InitializeComponent(); if (WinFormsUtility.IsDesignerHosted(this)) { return; } if (EditorAPI.DarkTheme) { BackColor = Color.FromArgb(40, 40, 40); } contentBrowserNewScene.Options.PanelMode = ContentBrowser.PanelModeEnum.List; contentBrowserNewScene.Options.ListMode = ContentBrowser.ListModeEnum.Tiles; contentBrowserNewScene.UseSelectedTreeNodeAsRootForList = false; contentBrowserNewScene.Options.Breadcrumb = false; contentBrowserNewScene.Options.TileImageSize = 90; // 100; //add items try { var items = new List <ContentBrowser.Item>(); //scenes foreach (var template in Component_Scene.NewObjectSettingsScene.GetTemplates()) { contentBrowserNewScene.AddImageKey(template.Name, template.Preview); var item = new ContentBrowserItem_Virtual(contentBrowserNewScene, null, template.ToString() + " scene"); item.Tag = template; item.imageKey = template.Name; items.Add(item); } //UI Control { var path = VirtualPathUtility.GetRealPathByVirtual(@"Base\Tools\NewResourceTemplates\UIControl.ui"); if (File.Exists(path)) { var name = Path.GetFileNameWithoutExtension(path); if (previewImageNewUIControl == null) { var previewPath = Path.Combine(Path.GetDirectoryName(path), name + ".png"); previewImageNewUIControl = File.Exists(previewPath) ? Image.FromFile(previewPath) : null; } if (previewImageNewUIControl != null) { contentBrowserNewScene.AddImageKey(name, previewImageNewUIControl); } var item = new ContentBrowserItem_Virtual(contentBrowserNewScene, null, "UI Control"); item.Tag = "UIControl"; if (previewImageNewUIControl != null) { item.imageKey = name; } items.Add(item); } } //Select resource { var name = "SelectResource"; if (previewImageNewResource == null) { var previewPath = VirtualPathUtility.GetRealPathByVirtual(@"Base\Tools\NewResourceTemplates\Resource.png"); previewImageNewResource = File.Exists(previewPath) ? Image.FromFile(previewPath) : null; } if (previewImageNewResource != null) { contentBrowserNewScene.AddImageKey(name, previewImageNewResource); } var item = new ContentBrowserItem_Virtual(contentBrowserNewScene, null, "Select type"); item.Tag = "Resource"; if (previewImageNewResource != null) { item.imageKey = name; } items.Add(item); } ////!!!! //{ // var item = new ContentBrowserItem_Virtual( contentBrowserNewScene, null, "C# Class Library" ); // //!!!! // //item.Tag = template; // item.imageKey = "";//template.Name; // item.ShowDisabled = true; // items.Add( item ); //} ////!!!! //{ // var item = new ContentBrowserItem_Virtual( contentBrowserNewScene, null, "Executable App" ); // //!!!! // //item.Tag = template; // item.imageKey = "";//template.Name; // item.ShowDisabled = true; // items.Add( item ); //} UpdateNewScenes?.Invoke(ref items); if (items.Count != 0) { contentBrowserNewScene.SetData(items, false); contentBrowserNewScene.SelectItems(new ContentBrowser.Item[] { items[0] }); } } catch (Exception exc) { Log.Warning(exc.Message); //contentBrowserNewScene.SetError( "Error: " + exc.Message ); } contentBrowserNewScene.ItemAfterChoose += ContentBrowserNewScene_ItemAfterChoose; contentBrowserOpenScene.Options.PanelMode = ContentBrowser.PanelModeEnum.List; contentBrowserOpenScene.Options.ListMode = ContentBrowser.ListModeEnum.List; contentBrowserOpenScene.UseSelectedTreeNodeAsRootForList = false; contentBrowserOpenScene.Options.Breadcrumb = false; var imageSize = EditorAPI.DPIScale >= 1.25f ? 13 : 16; contentBrowserOpenScene.Options.ListImageSize = imageSize; contentBrowserOpenScene.Options.ListColumnWidth = 10000; contentBrowserOpenScene.ListViewModeOverride = new EngineListView.DefaultListMode(contentBrowserOpenScene.GetListView(), imageSize); contentBrowserOpenScene.PreloadResourceOnSelection = false; UpdateOpenScenes(); WindowTitle = EditorLocalization.Translate("StartPageWindow", WindowTitle); }
private void HierarchicalContainer1_OverridePropertyEnumItem(HierarchicalContainer sender, HCItemEnumDropDown property, ref string displayName, ref string description) { displayName = EditorLocalization.Translate("ContentBrowser.Options", displayName); description = EditorLocalization.Translate("ContentBrowser.Options", description); }
string Translate(string text) { return(EditorLocalization.Translate("NewObjectWindow", text)); }
// string Translate(string text) { return(EditorLocalization.Translate("MeshModifier", text)); }
public virtual bool Creation(NewObjectCell.ObjectCreationContext context) { if (Window.IsFileCreation() && CreateCSharpClass) { context.disableFileCreation = true; GetCreateCSharpClassInfo(out var csharpRealFileName, out var csharpClassName, out var csharpClassNameWithoutNamespace); try { //main file { string className = csharpClassName; //string className = CreateCSharpClass ? csharpClassName : Window.SelectedType.Name; var text = ".component " + className + "\r\n{\r\n}"; File.WriteAllText(context.fileCreationRealFileName, text); } //cs file //if( CreateCSharpClass ) { string code = @"using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using NeoAxis; namespace Project { public class {Name} : {Base} { } }"; code = code.Replace("{Name}", csharpClassNameWithoutNamespace); code = code.Replace("{Base}", Window.SelectedType.Name); File.WriteAllText(csharpRealFileName, code); } } catch (Exception e) { EditorMessageBox.ShowWarning(e.Message); //Log.Warning( e.Message ); return(false); } //if( CreateCSharpClass ) { //add to Project.csproj { var toAdd = new List <string>(); var fileName = Path.Combine("Assets", VirtualPathUtility.GetVirtualPathByReal(csharpRealFileName)); toAdd.Add(fileName); if (CSharpProjectFileUtility.UpdateProjectFile(toAdd, null, out var error)) { if (toAdd.Count > 1) { Log.Info(EditorLocalization.Translate("General", "Items have been added to the Project.csproj.")); } else { Log.Info(EditorLocalization.Translate("General", "The item has been added to the Project.csproj.")); } } else { EditorMessageBox.ShowWarning(error); //Log.Warning( error ); return(false); } } Window.DisableUnableToCreateReason = true; //restart application var text = EditorLocalization.Translate("General", "To apply changes need restart the editor. Restart?\r\n\r\nThe editor must be restarted to compile and enable a new created C# class."); if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) == EDialogResult.Yes) { EditorAPI.BeginRestartApplication(); } Window.DisableUnableToCreateReason = false; } } return(true); }
private void HierarchicalContainer1_OverrideGroupDisplayName(HierarchicalContainer sender, HCItemGroup group, ref string displayName) { displayName = EditorLocalization.Translate("TypeSettingsForm", displayName); }
static string Translate(string text) { return(EditorLocalization.Translate("ImagePreviewControl", text)); }
private void kryptonButtonInstall_Click(object sender, EventArgs e) { var info = PackageManager.ReadPackageArchiveInfo(selectedPackage.FullFilePath, out var error); if (info == null) { return; } var filesToCopy = new List <string>(); foreach (var file in info.Files) { var fullName = Path.Combine(VirtualFileSystem.Directories.Project, file); filesToCopy.Add(fullName); } var text = string.Format(Translate("Install {0}?\n\n{1} files will created."), selectedPackage.GetDisplayName(), filesToCopy.Count); //var text = string.Format( Translate( "Install {0}?\r\n\r\n{1} files will created." ), selectedPackage.Name, filesToCopy.Count ); //var text = $"Install {selectedPackage.Name}?\r\n\r\n{filesToCopy.Count} files will created."; if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) != EDialogResult.Yes) { return; } var notification = ScreenNotifications.ShowSticky("Installing the package..."); try { using (var archive = ZipFile.OpenRead(selectedPackage.FullFilePath)) { foreach (var entry in archive.Entries) { var fileName = entry.FullName; bool directory = fileName[fileName.Length - 1] == '/'; if (fileName != "Package.info" && !directory) { var fullPath = Path.Combine(VirtualFileSystem.Directories.Project, fileName); var directoryName = Path.GetDirectoryName(fullPath); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } entry.ExtractToFile(fullPath, true); } } } PackageManager.ChangeInstalledState(selectedPackage.Name, true); } catch (Exception e2) { EditorMessageBox.ShowWarning(e2.Message); return; } finally { notification.Close(); } if (!string.IsNullOrEmpty(info.AddCSharpFilesToProject)) { var toAdd = new ESet <string>(); var path = Path.Combine(VirtualFileSystem.Directories.Assets, info.AddCSharpFilesToProject); if (Directory.Exists(path)) { var fullPaths = CSharpProjectFileUtility.GetProjectFileCSFiles(false, true); var files = Directory.GetFiles(path, "*.cs", SearchOption.AllDirectories); foreach (var file in files) { if (!fullPaths.Contains(file)) { toAdd.AddWithCheckAlreadyContained(file); } } } // if( !fileItem.IsDirectory && Path.GetExtension( fileItem.FullPath ).ToLower() == ".cs" ) // { // bool added = CSharpProjectFileUtility.GetProjectFileCSFiles( false, true ).Contains( fileItem.FullPath ); // if( !added ) // toAdd.Add( fileItem.FullPath ); // } if (toAdd.Count != 0) { if (CSharpProjectFileUtility.UpdateProjectFile(toAdd, null, out var error2)) { if (toAdd.Count > 1) { Log.Info(EditorLocalization.Translate("General", "Items have been added to the Project.csproj.")); } else { Log.Info(EditorLocalization.Translate("General", "The item has been added to the Project.csproj.")); } } else { Log.Warning(error2); } } } needUpdateList = true; if (info.MustRestart) { ShowRestartLabel(); } if (!string.IsNullOrEmpty(info.OpenAfterInstall)) { var realFileName = VirtualPathUtility.GetRealPathByVirtual(info.OpenAfterInstall); if (info.MustRestart) { EditorSettingsSerialization.OpenFileAtStartup = realFileName; } else { EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { realFileName }, Directory.Exists(realFileName)); EditorAPI.OpenFileAsDocument(realFileName, true, true); } } ScreenNotifications.Show(EditorLocalization.Translate("General", "The package has been successfully installed.")); //restart application if (info.MustRestart) { var text2 = EditorLocalization.Translate("General", "To apply changes need restart the editor. Restart?"); if (EditorMessageBox.ShowQuestion(text2, EMessageBoxButtons.YesNo) == EDialogResult.Yes) { EditorAPI.BeginRestartApplication(); } } }
private void EditorForm_Load(object sender, EventArgs e) { if (WinFormsUtility.IsDesignerHosted(this)) { return; } //hide ribbon to avoid redrawing kryptonRibbon.Visible = false; // create cover coverControl = new Control(); coverControl.BackColor = Color.FromArgb(40, 40, 40); coverControl.Dock = DockStyle.Fill; Controls.Add(coverControl); coverControl.BringToFront(); Application.DoEvents(); ////dpi //try //{ // using( Graphics graphics = CreateGraphics() ) // { // dpi = graphics.DpiX; // } //} //catch( Exception ex ) //{ // dpi = 96; // Log.Warning( "EditorForm: CreateGraphics: Call failed. " + ex.Message ); //} kryptonRibbon.RibbonTabs.Clear(); { EngineApp.InitSettings.UseApplicationWindowHandle = Handle; if (!EngineApp.Create()) { Log.Fatal("EngineApp.Create() failed."); Close(); return; } //эксепшен не генегируется, просто падает //bool created = false; //if( Debugger.IsAttached ) // created = EngineApp.Create(); //else //{ // try // { // //!!!! // Log.Info( "dd" ); // created = EngineApp.Create(); // //!!!! // Log.Info( "tt" ); // } // catch( Exception e2 ) // { // //!!!! // Log.Info( "ee" ); // Log.FatalAsException( e2.ToString() ); // } //} //if( !created ) //{ // Log.Fatal( "EngineApp.Create() failed." ); // Close(); // return; //} } EngineApp.DefaultSoundChannelGroup.Volume = 0; EnableLocalization(); //set theme if (ProjectSettings.Get.Theme.Value == Component_ProjectSettings.ThemeEnum.Dark) { kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlack; } else { kryptonManager.GlobalPaletteMode = PaletteModeManager.NeoAxisBlue; } KryptonDarkThemeUtility.DarkTheme = EditorAPI.DarkTheme; if (EditorAPI.DarkTheme) { EditorAssemblyInterface.Instance.SetDarkTheme(); } Aga.Controls.Tree.NodeControls.BaseTextControl.DarkTheme = EditorAPI.DarkTheme; BackColor = EditorAPI.DarkTheme ? Color.FromArgb(40, 40, 40) : Color.FromArgb(240, 240, 240); //app button kryptonRibbon.RibbonAppButton.AppButtonText = EditorLocalization.Translate("AppButton", kryptonRibbon.RibbonAppButton.AppButtonText); if (DarkTheme) { kryptonRibbon.RibbonAppButton.AppButtonBaseColorDark = Color.FromArgb(40, 40, 40); kryptonRibbon.RibbonAppButton.AppButtonBaseColorLight = Color.FromArgb(54, 54, 54); } //!!!! default editor layout: // IsSystemWindow = true for this: // для этих "системных" окон используется отдельная логика сериализации (окна создаются до загрузки конфига) // и отдельная логика закрытия (hide/remove) workspaceController.AddToDockspaceStack(new DockWindow[] { new ObjectsWindow(), new SettingsWindow() }, DockingEdge.Right); //workspaceController.AddDockspace(new MembersWindow(), "Members", DockingEdge.Right, new Size(300, 300)); workspaceController.AddToDockspaceStack(new DockWindow[] { new ResourcesWindow(), new SolutionExplorer(), new PreviewWindow() }, DockingEdge.Left); workspaceController.AddToDockspace(new DockWindow[] { new MessageLogWindow(), new OutputWindow(), new DebugInfoWindow() }, DockingEdge.Bottom); Log.Info("Use Log.Info(), Log.Warning() methods to write to the window. These methods can be used in the Player. Press '~' to open console of the Player."); OutputWindow.Print("Use OutputWindow.Print() method to write to the window. Unlike Message Log window, this window is not a list. Here you can add text in arbitrary format.\n"); //!!!! //workspaceController.AddDockWindow( new TipsWindow(), true, false ); //!!!!эвент чтобы свои добавлять. и пример //load docking state { string configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileName); //default settings if (!File.Exists(configFile)) { configFile = VirtualPathUtility.GetRealPathByVirtual(dockingConfigFileNameDefault); } if (File.Exists(configFile)) { //try //{ ////!!!! If xml broken, we will not get an exception. //// the exception is swallowed inside the krypton. //// how do I know if an error has occurred? workspaceController.LoadLayoutFromFile(configFile); //} // catch // { // //!!!!TODO: layout broken. fix this! // } } } InitQAT(); InitRibbon(); UpdateText(); //apply editor settings EditorSettingsSerialization.InitAfterFormLoad(); XmlDocumentationFiles.PreloadBaseAssemblies(); EditorAPI.SelectedDocumentWindowChanged += EditorAPI_SelectedDocumentWindowChanged; UpdateRecentProjectsInRegistry(); LoginUtility.RequestFullLicenseInfo(); kryptonRibbon.BeforeMinimizedModeChanged += KryptonRibbon_BeforeMinimizedModeChanged; kryptonRibbon.MinimizedModeChanged += KryptonRibbon_MinimizedModeChanged; KryptonWinFormsUtility.editorFormStartTemporaryLockUpdateAction = delegate() { if (IsHandleCreated && !EditorAPI.ClosingApplication) { KryptonWinFormsUtility.LockFormUpdate(this); unlockFormUpdateInTimer = DateTime.Now + TimeSpan.FromSeconds(0.1); } }; loaded = true; }
void ThreadDownload() { //var fileName = Path.Combine( PackageManager.PackagesFolder, Path.GetFileName( downloadingAddress ) ); var cancelled = false; Exception error = null; try { using (WebClient client = new WebClient()) { downloadingClient = client; var tempFileName = Path.GetTempFileName(); client.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { //check already ended if (cancelled) { return; } if (e.TotalBytesToReceive != 0) { downloadProgress = MathEx.Saturate((float)e.BytesReceived / (float)e.TotalBytesToReceive); } }; client.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) { //check already ended if (cancelled) { return; } //releases blocked thread lock (e.UserState) Monitor.Pulse(e.UserState); cancelled = e.Cancelled; error = e.Error; //copy to destination path if (!cancelled && error == null) { File.Copy(tempFileName, downloadingDestinationPath); } try { File.Delete(tempFileName); } catch { } }; using (var task = client.DownloadFileTaskAsync(new Uri(downloadingAddress), tempFileName)) { while (!string.IsNullOrEmpty(downloadingAddress) && !task.Wait(10)) { } } //var syncObject = new object(); //lock( syncObject ) //{ // client.DownloadFileAsync( new Uri( downloadingAddress ), downloadingDestinationPath, syncObject ); // //This would block the thread until download completes // Monitor.Wait( syncObject ); //} downloadingClient = null; } } catch (Exception e) { Log.Warning(e.Message); return; } finally { try { if (!cancelled) { if (File.Exists(downloadingDestinationPath) && new FileInfo(downloadingDestinationPath).Length == 0) { File.Delete(downloadingDestinationPath); cancelled = true; } } if (!cancelled && !File.Exists(downloadingDestinationPath)) { cancelled = true; } if (cancelled || error != null) { if (File.Exists(downloadingDestinationPath)) { File.Delete(downloadingDestinationPath); } } } catch { } if (error != null && !cancelled) { Log.Warning((error.InnerException ?? error).Message); } downloadingPackageName = ""; downloadingAddress = ""; downloadingDestinationPath = ""; downloadProgress = 0; downloadingClient = null; } needUpdateList = true; if (!cancelled) { if (error != null) { ScreenNotifications.Show(EditorLocalization.Translate("General", "Error downloading the package."), true); } else { ScreenNotifications.Show(EditorLocalization.Translate("General", "The package has been successfully downloaded.")); } } }
static string Translate(string text) { return(EditorLocalization.Translate("ParticleSystemDocumentWindow", text)); }