private void AddObject_Click(object sender, System.EventArgs e) { Point3D basePoint = new Point3D( (double)PositionX.Value, (double)PositionY.Value, (double)PositionZ.Value ); if (mainForm.Scene.GetObjectByName(ObjectName.Text) == null) { var radio = new TelescopeObject(ObjectName.Text); radio.BasePoint = basePoint; radio.AngleX = (int)RotateX.Value; radio.AngleY = (int)RotateY.Value; radio.AngleZ = (int)RotateZ.Value; radio.SetScale((double)ScaleX.Value, (double)ScaleY.Value, (double)ScaleZ.Value); mainForm.Scene.AddObject(radio); int index = mainForm.ObjectsList.Items.Add(ObjectName.Text); mainForm.ObjectsList.SelectedIndex = index; mainForm.ObjectPanButton.Enabled = true; Close(); } else { MessageBox.Show("Объект с таким именем уже существует, переименуйте объект.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); ObjectName.Clear(); ObjectName.Focus(); } }
// Pop up Menu to create a new Object void PopUpCreateObjectMenu(object sender, EventArgs args) { // default: create Folder isFolder = true; FolderButton.TextColor = Color.Black; FileButton.TextColor = Color.LightGray; PopUpMenu.IsVisible = true; // Pop up Create-Folder-Menu // Set Entry "ObjectName" Keyboard // Plain: No Characterize and Spell Check ObjectName.Keyboard = Keyboard.Plain; ObjectName.Focus(); // Set cursor on Entry "ObjectName" }
private void SaveButton_Click(object sender, EventArgs e) { if (ObjectName.Text.Trim() == "") { MessageBoxMx.ShowError("You must supply a name"); ObjectName.Focus(); return; } if (ProjectName.Text.Trim() == "") { ProjectTarget.Text = ""; if (Lex.Ne(ObjectName.Text.Trim(), "Current")) // blank project not allowed unless saving current { MessageBoxMx.ShowError("You must supply a folder name"); ProjectName.Focus(); return; } } string txt = ProjectTarget.Text; if (txt.ToLower().IndexOf("project ") == 0 && txt.Length > 8) { txt = txt.Substring(8); } else if (txt.ToLower().IndexOf("folder ") == 0 && txt.Length > 7) { txt = txt.Substring(7).ToUpper(); } else if (txt.ToLower().IndexOf("submenu ") == 0 && txt.Length > 8) { txt = txt.Substring(8).ToUpper(); } MetaTreeNode mtn = MetaTree.GetNode(txt); if (mtn == null && UserObjectTree.FolderNodes.ContainsKey(txt)) { mtn = UserObjectTree.FolderNodes[txt]; } UserObject uo2 = new UserObject(Uo.Type); uo2.Owner = SS.I.UserName; // we will be the new owner uo2.Description = Uo.Description; // copy any description uo2.Name = ObjectName.Text; uo2.AccessLevel = Uo.AccessLevel; uo2.ACL = Uo.ACL; //reassigning the folder id to the object type folder happens in the "Save" if (mtn != null) { uo2.ParentFolder = mtn.Target.ToUpper(); uo2.ParentFolderType = mtn.GetUserObjectFolderType(); } UserObject uo3 = UserObjectDao.ReadHeader(uo2); // see if already exists if (uo3 != null) { string objectTypeName = UserObject.GetTypeLabel(Uo.Type); DialogResult dr = MessageBoxMx.Show( objectTypeName + " " + uo2.Name + " already exists. Do you want to replace it?", UmlautMobius.String, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } else if (dr == DialogResult.Cancel) { DialogResult = DialogResult.Cancel; return; } else { uo2.Id = uo3.Id; // keep the id when overwriting } } Uo = uo2; // info on object to save DialogResult = DialogResult.OK; return; }
private void UserObjectSaveDialog_Activated(object sender, EventArgs e) { ObjectName.Focus(); }
// OK Button pressed, and create a new Object void OKCreateObject(object sender, EventArgs e) { Object newObject = new Object { Name = ObjectName.Text, IsFolder = isFolder, IsExpanded = false, Parent = CurrentFolder, Depth = CurrentFolder.Depth + 1 }; // Create a new Object with the random name, if no Object's name input if (newObject.Name == "") { newObject.Name = Guid.NewGuid().ToString("N").Substring(0, 3); } // Check the existence of newObject foreach (Object o in CurrentDisplayObjects) { if (o.Parent == CurrentFolder) // Has the same Parent? { if (o.IsFolder == isFolder) // Folder or File? { if (o.Name == ObjectName.Text) { DisplayAlert("", o.NameWithExtension + " already exists!", "OK"); return; } } } } // Update Path name newObject.Path = newObject.Parent.Path + newObject.Name + ">"; if (newObject.Path.Length > 50) // If Path name is too long, shorten it. { string p = newObject.Path.Substring(newObject.Path.Length - 45); newObject.Path = "..." + p; } newObject.Parent.NoChildren++; // Increment the number of children // Add newObject to the both of the displayed Objecs and all Objects CurrentDisplayObjects.Add(newObject); AllObjects.Add(newObject); UpdateFinder(CurrentDisplayObjects); // Clear the text in ObjectName Entry and focus it again ObjectName.Text = ""; ObjectName.Focus(); // PCL Storage: Create a new IFolder/IFile corresponding to the newObject if (isFolder) { ICreateFolder(newObject, CurrentFolder.iFolder); } else { ICreateFile(newObject, CurrentFolder.iFolder); } }