public void SetUp() { Debug.Listeners.Clear(); TextWriterTraceListener t = new TextWriterTraceListener("log.txt"); Debug.Listeners.Add(t); Debug.AutoFlush = true; Debug.WriteLine("starting projectManager..."); ProjectManagerOptions options = new ProjectManagerOptions(); options.StartIceGridLocaly = true; options.StopIceGridLocaly = true; options.IceGridAsService = false; options.LocalePrefs = new string[]{"en-US","cs-CZ"}; options.SentenceForWait = "[ icegridnode: Server: changed server `0' state to `Inactive' ]"; projectManager = new ProjectManager(new string[0], options); }
///////// METHODS /////// /// <summary> /// Construction of one FEplugin data source. /// </summary> /// <param name="path">Path to file with Ferda project</param> public CFEsource(string path) { // initialization of SourcePath SourcePath = path; // initialization of PM try { // changing current directory to Ferda FrontEnd directory DirManager.SetHomeFerdaFrontEnd_dir(); // initialization of PM PM = new ProjectManager(new string[0], FEplugin_globals.IceConfig.ProjectManagerOptions); DirManager.SetHomePrevious_dir(); // loading the project DirManager.SetHomeLMRA_dir(); if (LoadProject() == false) throw new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: project can't be loaded"); } catch (FE_error) { throw; } catch (System.Exception e) { DestroyPM(); FE_error err = new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: " + e.Message); throw (err); } finally { // changing actual directory to previous DirManager.SetHomePrevious_dir(); } }
///<summary> /// Default constructor for FerdaArchive class. ///</summary> public FerdaArchive(Menu.ILocalizationManager locManager, Menu.IMenuDisplayer menuDisp, IFerdaClipboard clipboard, ProjectManager.Archive arch, IIconProvider iconProvider, Menu.IMenuDisplayer toolBar, ProjectManager.ProjectManager projManager) : base() { //setting the icon naIcon = iconProvider.GetIcon("NAIcon"); this.iconProvider = iconProvider; //setting the localization localizationManager = locManager; ResManager = localizationManager.ResManager; //setting the menu displayer menuDisplayer = menuDisp; this.toolBar = toolBar; //setting the archive Archive = arch; //setting the projectManager projectManager = projManager; InitializeComponent(); //Setting the texts of the radiobuttons RBAlong.Text = ResManager.GetString("ArchiveAlongText"); RBAgainst.Text = ResManager.GetString("ArchiveAgainstText"); RBAlong.Checked = true; //Setting the clipboard this.Clipboard = clipboard; //events GotFocus += new EventHandler(FerdaArchive_GotFocus); TVArchive.GotFocus += new EventHandler(FerdaArchive_GotFocus); TVArchive.MouseDown += new MouseEventHandler(TVArchive_MouseDown); TVArchive.MouseMove += new MouseEventHandler(TVArchive_MouseMove); //the labelEdit property TVArchive.LabelEdit = true; TVArchive.AfterLabelEdit += new NodeLabelEditEventHandler(TVArchive_AfterLabelEdit); CBCategories.SelectedIndexChanged += new EventHandler(CBArchive_SelectedIndexChanged); CBTypes.SelectedIndexChanged += new EventHandler(CBTypes_SelectedIndexChanged); RBAlong.CheckedChanged += new EventHandler(RBAlong_CheckedChanged); TVArchive.AfterSelect += new TreeViewEventHandler(TVArchive_AfterSelect); ArchiveSetupAfterLoadProject(); }
/// <summary> /// This method should be always called after the constructor, because /// without this method FerdaForm wont work at all. It contains all the /// necessary setup for the form. /// </summary> /// <param name="pm">Project Manager of the application</param> /// <param name="prescreen">Prescreen where text about application /// loading is displayed</param> public void RightAfterConstructor(ProjectManager.ProjectManager pm, FerdaPrescreen prescreen) { projectManager = pm; //fills the projectManager with some stuff FillPM(); SizeChanged += new EventHandler(FormSizeChanged); Closing += new CancelEventHandler(FerdaForm_Closing); //loading the recent projects LoadRecentProjects(); prescreen.DisplayText(ResManager.GetString("LoadingIcons")); LoadIcons(); this.Icon = iconProvider["FerdaIcon"]; prescreen.DisplayText(ResManager.GetString("LoadingSVG")); SetupSVG(); prescreen.DisplayText(ResManager.GetString("LoadingMenus")); SetupStripes(); prescreen.DisplayText(ResManager.GetString("LoadingContextHelp")); SetupContextHelp(); prescreen.DisplayText(ResManager.GetString("LoadingProperties")); SetupProperties(); prescreen.DisplayText(ResManager.GetString("LoadingArchive")); SetupArchive(); prescreen.DisplayText(ResManager.GetString("LoadingNewBox")); SetupNewBox(); SetupUserNote(); prescreen.DisplayText(ResManager.GetString("LoadingDesktop")); SetupDesktop(); //Because when the program is setting up the menu, all the views(desktops) //are closed. Thus it would put all the views into the open group. After //the inicialization of the desktops, all the dekstops are open - and //the behaviour is correct. menu.SetupDesktop(); prescreen.DisplayText(ResManager.GetString("LoadingDocking")); SetupDocking(); //Name and title of the application Name = "FerdaForm"; Text = "Ferda DataMiner"; //this command should be the last one, otherwise the window is not //maximized correctly WindowState = FormWindowState.Maximized; }
/// <summary> /// Constructor that sets the Box property /// </summary> /// <param name="box">box that will be represented by this node</param> /// <param name="alongDirection">the direction of expanding</param> /// <param name="arch">Archive where this box belongs</param> /// <param name="parent">Parent component of the archive</param> /// <param name="iconDictionary">Icon dictionary containing all the icons /// for the box visualization</param> /// <param name="list">Some image list</param> /// <param name="provider">Control providing access to all the icons</param> /// <param name="projManager">Project manager of the application</param> public FerdaTreeNode(ModulesManager.IBoxModule box, bool alongDirection, ProjectManager.Archive arch, FerdaArchive parent, Dictionary<string, int> iconDictionary, ImageList list, IIconProvider provider, ProjectManager.ProjectManager projManager) : base() { Box = box; Text = box.UserName; AlongDirection = alongDirection; Archive = arch; ParentTreeView = parent; //icon provider for the menu this.provider = provider; //setting the projectManager projectManager = projManager; //setting the icon if (box.MadeInCreator.Icon.Length == 0) { this.ImageIndex = iconDictionary["naIcon"]; this.SelectedImageIndex = iconDictionary["naIcon"]; } else { string label = box.MadeInCreator.Label; if (iconDictionary.ContainsKey(label)) { this.ImageIndex = iconDictionary[label]; this.SelectedImageIndex = iconDictionary[label]; } else { MemoryStream stream = new MemoryStream(box.MadeInCreator.Icon); Icon icon = new Icon(stream); int count = list.Images.Count; list.Images.Add(icon); iconDictionary.Add(label, count); this.ImageIndex = count; this.SelectedImageIndex = count; } } //sets the child nodes for this node if (AlongDirection) { //sets the boxes as ConnectionTo foreach(ModulesManager.IBoxModule b in Archive.ConnectedTo(Box)) { Nodes.Add(new FerdaTreeNode(b, AlongDirection, Archive, ParentTreeView, iconDictionary, list, provider, projectManager)); } } else { //sets the boxes as ConnectionFrom foreach(ModulesManager.IBoxModule b in Archive.ConnectionsFrom(Box)) { Nodes.Add(new FerdaTreeNode(b, AlongDirection, Archive, ParentTreeView, iconDictionary, list, provider, projectManager)); } } }
/// <summary> /// Default constructor for the class /// </summary> /// <remarks> /// Parametrem by se mohlo predavat jmeno vystupniho konektoru. /// Problem bude s resenim vystupniho konenktoru, pro ktery vlastne /// neni socket ale pozaduje SVG (bud kreslit natvrdo, nebo udelat /// v IBoxModule pro to nejaky zvlastni socket /// </remarks> /// <param name="site">Interface of a graph site (control) /// </param> /// <param name="box">Box that is connected with this node</param> /// <param name="resM">Resource manager of the application</param> /// <param name="svgman">Provider of svg images</param> /// <param name="view">View where this box is located</param> public BoxNode(IGraphSite site, ModulesManager.IBoxModule box, SVGManager svgman, ProjectManager.View view, ResourceManager resM) : base(site) { FerdaConstants constants = new FerdaConstants(); //filling the node this.box = box; this.svgManager = svgman; this.ResManager = resM; //determining the size Rectangle = new RectangleF(0, 0, constants.KrabickaWidth, constants.KrabickaHeight); //adding the output connector //it is not a FerdaConnector, because the box has no socket defined outputConnector = new Connector(this, ResManager.GetString("PropertiesOutputConnector"), true); Connectors.Add(outputConnector); outputConnector.ConnectorLocation = ConnectorLocations.East; //adding the input connectors inputConnectors = new ConnectorCollection(); for (int i = 0; i < box.Sockets.Length; i++) { bool packed = view.IsAnyBoxPackedIn(box, box.Sockets[i].name); inputConnectors.Add( new FerdaConnector(this, svgManager, box.Sockets[i], packed)); Connectors.Add(inputConnectors[i]); inputConnectors[i].ConnectorLocation = ConnectorLocations.West; } //getting the bitmap bitmap = svgManager.GetBoxBitmap(box); //setting the view this.view = view; //adding the moving handler OnMouseDown += new MouseEventHandler(BoxNode_OnMouseDown); OnMouseUp += new MouseEventHandler(BoxNode_OnMouseUp); Resizable = false; this.Text = box.UserName; //using a smaller font - we have big labels mFont = new Font(mFontFamily, 7, FontStyle.Regular, GraphicsUnit.Point); }
///<summary> /// Default constructor for FerdaArchive class. Initializes all menu controls /// and adds them to the menu. ///</summary> public FerdaMenu( IDockingManager dockManager, ILocalizationManager lockManager, ProjectManager.ProjectManager pm, IControlsManager contMan, IIconProvider provider) : base() { //setting the iconProvider iconProvider = provider; //filling the private fields dockingManager = dockManager; localizationManager = lockManager; ResManager = localizationManager.ResManager; projectManager = pm; controlsManager = contMan; //adding the main group of the menu SetupMainMenuGroup(); //adding the file group of the menu SetupFile(); //adding the edit group of the menu SetupEdit(); //adding the view group of the menu SetupView(); //SetupDesktop(); //adding the actions group of the menu, will be done dynamically //probably calling some function SetupTools(); SetupHelp(); }
/// <summary> /// Loads the project and writes the information about the project File /// </summary> /// <param name="fileName">Name of the xpf file from where the project is loaded</param> /// <param name="parent">Control which cursor should be changed to wait cursor</param> /// <param name="resManager">Resource Manager of the application</param> /// <param name="projectManager">Project Manager class</param> /// <param name="controlsManager">Controls manager that takes care of the controls</param> public static void LoadProject(string fileName, Control parent, ResourceManager resManager, ref ProjectManager.ProjectManager projectManager, IControlsManager controlsManager) { string loadErrors = string.Empty; if (fileName != "") { FileStream fs = null; try { fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open); } catch(FileNotFoundException) { MessageBox.Show(resManager.GetString("ProjectLoadFileNotFound"), resManager.GetString("ProjectLoadErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Cursor previosCursor = parent.Cursor; parent.Cursor = Cursors.WaitCursor; parent.Refresh(); loadErrors = projectManager.LoadProject(fs); controlsManager.ProjectName = fileName; controlsManager.GlobalAdapt(); parent.Cursor = previosCursor; } catch (InvalidOperationException) { MessageBox.Show(resManager.GetString("ProjectLoadInvalidFormat"), resManager.GetString("ProjectLoadErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { fs.Close(); } } //displaying what has happened while loading the project if (loadErrors != string.Empty) { MessageBox.Show(loadErrors, resManager.GetString("ProjectLoadErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
///<summary> /// Default constructor for FerdaView class. ///</summary> ///<param name="locManager"> /// Interface that takes care of the ///localizacion in the application /// </param> ///<param name="svgMan"> /// Interface for providing SVG graphics ///</param> ///<param name="menuDisp">Menu displayer</param> ///<param name="view">The view thath should be connected to this desktop</param> ///<param name="pm">The project manager of the application</param> ///<param name="arch">Control that displays the archive</param> ///<param name="provider">Provider of the icons</param> ///<param name="toolBar">Toolbar control</param> public FerdaDesktop(Menu.ILocalizationManager locManager, SVGManager svgMan, IMenuDisplayer menuDisp, ProjectManager.View view, ProjectManager.ProjectManager pm, Archive.IArchiveDisplayer arch, IIconProvider provider, IMenuDisplayer toolBar) : base() { //setting the icon this.provider = provider; //adding the localization localizationManager = locManager; ResManager = localizationManager.ResManager; //adding the svgManager svgManager = svgMan; //setting the menu displayer menuDisplayer = menuDisp; archiveDisplayer = arch; this.toolBar = toolBar; //Current view this.view = view; projectManager = pm; //name of the desktop Name = view.Name; //properties od the GraphControl to work propertly AllowMoveShape = true; AllowAddConnection = true; AllowAddShape = true; AllowDeleteShape = true; AllowDrop = true; AutoScroll = true; EnableContextMenu = true; EnableLayout = false; ShowGrid = false; Zoom = 1; RestrictToCanvas = false; this.ImeMode = System.Windows.Forms.ImeMode.On; //for now trial stuff BackgroundType = Netron.GraphLib.CanvasBackgroundTypes.Gradient; GradientTop = System.Drawing.Color.SkyBlue; //EventHandlers GotFocus += new EventHandler(FerdaDesktop_GotFocus); OnContextMenu += new MouseEventHandler(FerdaDesktop_ContextMenu); OnNewConnection += new NewConnection(FerdaDesktop_OnNewConnection); KeyPress += new KeyPressEventHandler(FerdaDesktop_KeyPress); OnFerdaMouseUp += new MouseEventHandler(FerdaDesktop_OnFerdaMouseUp); OnFerdaDeleteConnection += new FerdaConnection(FerdaDesktop_OnFerdaDeleteConnection); OnShapeRemoved += new NewShape(FerdaDesktop_OnShapeRemoved); //Setting the arrow for connections DefaultLineEnd = ConnectionEnds.RightFilledArrow; //Creation of the boxes and connections Adapt(); }