예제 #1
0
        void resourceProfileCombo_EventComboChangePosition(Widget source, EventArgs e)
        {
            if (allowResourceProfileSelectedIndexChanged)
            {
                if (resourceProfileCombo.SelectedIndex == resourceProfileCombo.ItemCount - 1) //New item
                {
                    InputBox.GetInput("New Resource Profile", "Enter the name of the new resource profile.", true, delegate(String result, ref String message)
                    {
                        resourceProfileCombo.insertItemAt(resourceProfileCombo.SelectedIndex, result);
                        allowResourceProfileSelectedIndexChanged = false;
                        resourceProfileCombo.SelectedIndex       = resourceProfileCombo.findItemIndexWith(result);
                        allowResourceProfileSelectedIndexChanged = true;
                        archiveNameText.OnlyText = result;

                        return(true);
                    });
                }
                else if (resourceProfileCombo.SelectedIndex == 0)
                {
                    scanResources(null);
                    archiveNameText.OnlyText = "";
                }
                else
                {
                    scanResources(resourceProfileCombo.SelectedItemName);
                    archiveNameText.OnlyText = resourceProfileCombo.SelectedItemName;
                }
            }
        }
예제 #2
0
        internal void saveMaterials()
        {
            HashSet <String> writtenFiles = new HashSet <string>();

            bool wroteSomething = false;

            foreach (var desc in currentDescriptions)
            {
                currentOutputFile = desc.SourceFile;
                if (currentOutputFile != null && !writtenFiles.Contains(currentOutputFile))
                {
                    writtenFiles.Add(currentOutputFile);
                    String outputFile = Path.Combine(currentDir, desc.SourceFile);

                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Formatting = Formatting.Indented;
                    using (StreamWriter textWriter = new StreamWriter(outputFile, false))
                    {
                        serializer.Serialize(textWriter, this);
                    }
                    wroteSomething = true;
                    Logging.Log.ImportantInfo("Saved material file {0}", outputFile);
                }
            }
            if (!wroteSomething && currentDescriptions.Count > 0)
            {
                InputBox.GetInput("Save Materials", "Enter a name for the material file.", true, nameMaterialResult);
            }
        }
 void addButton_MouseButtonClick(Widget source, EventArgs e)
 {
     InputBox.GetInput("Add Preset", "Enter a name for this preset.", true, delegate(String result, ref string errorPrompt)
     {
         presets.addItem(result, new RenderPreset(result, renderDialog.RenderWidth, renderDialog.RenderHeight));
         return(true);
     });
 }
예제 #4
0
        public override void FKeyUpEvent(int nIdx)
        {
            switch (nIdx)
            {
            case 1:
                break;

            case 4:
                tcRecipe1.InsertRow();
                MainApp.GetDoc().tcFKey1.FKeyBackColor(10, Color.DarkGray);
                hasChanged = true;
                break;

            case 5:
                tcRecipe1.DeleteRow();
                MainApp.GetDoc().tcFKey1.FKeyBackColor(10, Color.DarkGray);
                hasChanged = true;
                break;

            case 7:                        // Recipe löschen
                if (textBoxAuftrag.Text != "")
                {
                    if (askDeleteRecipe(textBoxAuftrag.Text))
                    {
                        System.IO.File.Delete(rootdir + "\\" + textBoxAuftrag.Text + ending);
                        if (treeView2.SelectedNode != null)
                        {
                            treeView2.Nodes.Remove(treeView2.SelectedNode);
                        }
                        // ein anderes Element selektieren
                        if (treeView2.Nodes.Count != 0)
                        {
                            treeView2.SelectedNode = treeView2.Nodes[0];
                        }
                        else
                        {
                            textBoxAuftrag.Text = "";
                            recipeFilename      = "";
                        }
                    }
                }
                break;

            case 8:
                InputBox box = new InputBox(GetText("New", "Neu anlegen"), GetText("FileName", "Dateiname:"));
                box.ShowDialog();
                if (box.DialogResult == DialogResult.OK && !box.GetInput().Equals(""))
                {
                    string fileName = box.GetInput();
                    recipeFilename = rootdir + "\\" + fileName + ending;
                    tcRecipe1.NewFile(recipeFilename);
                    tcRecipe1.WriteData();
                    treeView2.Nodes.Add(fileName, fileName);
                    textBoxAuftrag.Text = fileName;
                }
                break;

            case 9:
                tcRecipe1.ReadData();
                break;

            case 10:
                tcRecipe1.WriteData();
                MainApp.GetDoc().tcFKey1.FKeyBackColor(10, oldButtonColor);
                hasChanged = false;
                break;

            case 11:
                try
                {
                    // Get recipe data and write to the Plc
                    System.IO.MemoryStream memStream;
                    tcRecipe1.WriteDataToMemory(out memStream);
                    TwinCAT.Ads.AdsStream adsStream = new TwinCAT.Ads.AdsStream((int)memStream.Capacity);
                    adsStream.Write(memStream.GetBuffer(), 0, (int)memStream.Length);
                    adsServer.PlcClient.Write(".RecipeData", adsStream);
                    memStream = null;
                }
                catch (Exception ex)
                {
                    string tmp = this.Name + " Error writing recipe data to the PLC!";
                    MainApp.log.Error(tmp, ex);
                    MessageBox.Show(tmp);
                }
                break;

            case 12:
                timerListbox.Enabled = false;
                break;
            }
        }
예제 #5
0
        void fileBrowser_NodeContextEvent(FileBrowserTree tree, string path, bool isDirectory, bool isTopLevel)
        {
            ContextMenu contextMenu = new ContextMenu();

            if (isDirectory)
            {
                contextMenu.add(new ContextMenuItem("Create Directory", path, delegate(ContextMenuItem item)
                {
                    InputBox.GetInput("Directory Name", "Please enter a name for the directory.", true, delegate(String result, ref String errorPrompt)
                    {
                        editorController.ResourceProvider.createDirectory(item.UserObject.ToString(), result);
                        return(true);
                    });
                }));

                contextMenu.add(new ContextMenuItem("Add Item", path, delegate(ContextMenuItem item)
                {
                    AddItemDialog.AddItem(editorController.ItemTemplates, (itemTemplate) =>
                    {
                        try
                        {
                            ((ProjectItemTemplate)itemTemplate).createItem(path, editorController);
                        }
                        catch (Exception e)
                        {
                            MessageBox.show(String.Format("Error creating item.\n{0}", e.Message), "Error Creating Item", MessageBoxStyle.IconError | MessageBoxStyle.Ok);
                        }
                    });
                }));

                contextMenu.add(new ContextMenuItem("Import Files", path, delegate(ContextMenuItem item)
                {
                    FileOpenDialog fileDialog = new FileOpenDialog(MainWindow.Instance, "Choose files to import.", "", "", "", true);
                    fileDialog.showModal((result, paths) =>
                    {
                        if (result == NativeDialogResult.OK)
                        {
                            editorController.importFiles(paths, item.UserObject.ToString());
                        }
                    });
                }));

                contextMenu.add(new ContextMenuItem("Explore To", path, item =>
                {
                    OtherProcessManager.openLocalURL(editorController.ResourceProvider.getFullFilePath(item.UserObject.ToString()));
                }));
            }
            if (!isTopLevel)
            {
                contextMenu.add(new ContextMenuItem("Rename", path, delegate(ContextMenuItem item)
                {
                    InputBox.GetInput("Rename", String.Format("Please enter a new name for {0}.", item.UserObject.ToString()), true, delegate(String result, ref String errorPrompt)
                    {
                        String originalExtension = Path.GetExtension(item.UserObject.ToString());
                        String targetName        = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(item.UserObject.ToString()), result), originalExtension);
                        if (editorController.ResourceProvider.exists(targetName))
                        {
                            errorPrompt = String.Format("A file named {0} already exists. Please enter another name.", targetName);
                            return(false);
                        }

                        editorController.ResourceProvider.move(path, targetName);
                        return(true);
                    });
                }));
                contextMenu.add(new ContextMenuItem("Delete", path, delegate(ContextMenuItem item)
                {
                    MessageBox.show(String.Format("Are you sure you want to delete {0}?", item.UserObject.ToString()), "Delete?", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, delegate(MessageBoxStyle result)
                    {
                        if (result == MessageBoxStyle.Yes)
                        {
                            editorController.ResourceProvider.delete(item.UserObject.ToString());
                        }
                    });
                }));
            }
            tree.showContextMenu(contextMenu);
        }
 public void getInputString(string prompt, SendResult <string> resultCallback)
 {
     InputBox.GetInput("Enter value", prompt, true, resultCallback);
 }