private void MakeTree()
        {
            PlugInManager compManager = new PlugInManager();

            if (_type == RendererType.featureRenderer)
            {
                foreach (var pluginType in compManager.GetPlugins(Plugins.Type.IFeatureRenderer))
                {
                    IFeatureRenderer renderer = compManager.CreateInstance <IFeatureRenderer>(pluginType);
                    if (renderer == null || !renderer.CanRender(_layer, null))
                    {
                        continue;
                    }

                    TreeNode parent = null;
                    foreach (TreeNode cat in tvRenderer.Nodes)
                    {
                        if (cat.Text == renderer.Category)
                        {
                            parent = cat;
                            break;
                        }
                    }
                    if (parent == null)
                    {
                        parent = new TreeNode(renderer.Category);
                        tvRenderer.Nodes.Add(parent);
                    }

                    TreeNode rNode = new RendererNode(renderer);
                    parent.Nodes.Add(rNode);
                }
            }
            else if (_type == RendererType.labelRenderer)
            {
                TreeNode parent = new TreeNode("Label Renderers");
                foreach (var pluginType in compManager.GetPlugins(Plugins.Type.ILabelRenderer))
                {
                    ILabelRenderer renderer = compManager.CreateInstance <ILabelRenderer>(pluginType);
                    if (renderer == null || !renderer.CanRender(_layer, null))
                    {
                        continue;
                    }

                    parent.Nodes.Add(new LabelRendererNode(renderer));
                }
                tvRenderer.Nodes.Add(parent);
            }

            foreach (TreeNode parent in tvRenderer.Nodes)
            {
                parent.Expand();
            }
        }
        static public void Init(string rootPath, int port = 80)
        {
            var mapServerConfig = JsonConvert.DeserializeObject <MapServerConfig>(File.ReadAllText(rootPath + "/_config/mapserver.json"));

            OutputPath     = mapServerConfig.OuputPath.ToPlattformPath();
            OutputUrl      = mapServerConfig.OutputUrl;
            OnlineResource = mapServerConfig.OnlineResourceUrl;

            Instance = new MapServerInstance(port);

            ServicesPath = mapServerConfig.ServiceFolder;
            foreach (var mapFileInfo in new DirectoryInfo(ServicesPath.ToPlattformPath()).GetFiles("*.mxl"))
            {
                try
                {
                    MapService service = new MapService(mapFileInfo.FullName, MapServiceType.MXL);
                    mapServices.Add(service);
                    Console.WriteLine("service " + service.Name + " added");
                }
                catch (Exception ex)
                {
                    Logger.Log(loggingMethod.error, "LoadConfig - " + mapFileInfo.Name + ": " + ex.Message);
                }
            }

            var pluginMananger = new PlugInManager();

            foreach (Type interpreterType in pluginMananger.GetPlugins(typeof(IServiceRequestInterpreter)))
            {
                Interpreters.Add(interpreterType);
            }

            ThreadQueue = new ThreadQueue <IServiceRequestContext>(Globals.MaxThreads, Globals.QueueLength);
        }
        public NetworkEdgeWeightsControl(IFeatureDataset dataset, SelectFeatureclassesControl selected)
        {
            InitializeComponent();

            if (dataset != null)
            {
                _database = dataset.Database as IFeatureDatabase3;
            }

            if (_database == null)
            {
                throw new ArgumentException();
            }

            _selected = selected;

            PlugInManager pluginMan = new PlugInManager();

            foreach (var calcType in pluginMan.GetPlugins(Plugins.Type.ISimpleNumberCalculation))
            {
                ISimpleNumberCalculation calc = pluginMan.CreateInstance <ISimpleNumberCalculation>(calcType);
                if (calc == null)
                {
                    continue;
                }

                _calculators.Add(calc);
            }
        }
        public AdditionalFieldsControl()
        {
            InitializeComponent();

            PlugInManager compMan    = new PlugInManager();
            var           autoFields = compMan.GetPlugins(Plugins.Type.IAutoField);

            if (autoFields != null)
            {
                tablePanel.RowCount = autoFields.Count();
                tablePanel.Height   = autoFields.Count() * 25;
                tablePanel.Resize  += new EventHandler(tablePanel_Resize);

                int row = 0;
                foreach (var compType in autoFields)
                {
                    IAutoField aField = compMan.CreateInstance <IAutoField>(compType);
                    if (aField == null)
                    {
                        continue;
                    }

                    TextBox           box      = new TextBox();
                    AutoFieldCheckBox checkBox = new AutoFieldCheckBox(aField, box);

                    box.Text = aField.AutoFieldPrimayName;

                    tablePanel.Controls.Add(checkBox, 0, row);
                    tablePanel.Controls.Add(box, 1, row++);
                }
            }
        }
Beispiel #5
0
        private void FormDomains_Load(object sender, EventArgs e)
        {
            PlugInManager compMan = new PlugInManager();

            cmbDomains.Items.Add(new DomainItem(null));
            cmbDomains.SelectedIndex = 0;

            foreach (var domainType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IFieldDomain))
            {
                IFieldDomain fDomain = compMan.CreateInstance <IFieldDomain>(domainType);
                if (fDomain == null)
                {
                    continue;
                }

                if (_domain != null && fDomain.GetType().Equals(_domain.GetType()))
                {
                    cmbDomains.Items.Add(new DomainItem(_domain));
                    cmbDomains.SelectedIndex = cmbDomains.Items.Count - 1;
                }
                else
                {
                    cmbDomains.Items.Add(new DomainItem(fDomain));
                }
            }
        }
Beispiel #6
0
        public FormExplorerOptions(IMapDocument document)
        {
            InitializeComponent();

            _document = document;

            PlugInManager compMan = new PlugInManager();

            foreach (var pageTypes in compMan.GetPlugins(Plugins.Type.IExplorerOptionPage))
            {
                IExplorerOptionPage page = compMan.CreateInstance <IExplorerOptionPage>(pageTypes);
                if (page == null)
                {
                    continue;
                }

                Panel pagePanel = page.OptionPage();
                if (pagePanel == null)
                {
                    continue;
                }

                TabPage tabPage = new TabPage(page.Title);
                tabPage.Controls.Add(pagePanel);

                if (page.Image != null)
                {
                    imageList1.Images.Add(page.Image);
                    tabPage.ImageIndex = imageList1.Images.Count - 1;
                }

                tabControl.TabPages.Add(tabPage);
                _optionPages.Add(page);
            }
        }
Beispiel #7
0
        public MapServiceManager(
            IServiceProvider serviceProvider,
            IOptionsMonitor <MapServerManagerOptions> optionsMonitor,
            ILogger <MapServiceManager> logger = null)
        {
            _serviceProvider = serviceProvider;
            Options          = optionsMonitor.CurrentValue;
            _logger          = logger ?? new ConsoleLogger <MapServiceManager>();

            if (Options.IsValid)
            {
                foreach (string createDirectroy in new string[] {
                    Options.ServicesPath,
                    Options.LoginManagerRootPath,
                    $"{ Options.LoginManagerRootPath }/manage",
                    $"{ Options.LoginManagerRootPath }/token",
                    Options.LoggingRootPath
                })
                {
                    if (!new DirectoryInfo(createDirectroy).Exists)
                    {
                        new DirectoryInfo(createDirectroy).Create();
                    }
                }

                AddServices(String.Empty);

                var pluginMananger = new PlugInManager();
                Interpreters = pluginMananger.GetPlugins(typeof(IServiceRequestInterpreter))
                               .OrderByDescending(t => ((IServiceRequestInterpreter)Activator.CreateInstance(t)).Priority)
                               .ToArray();

                TaskQueue = new TaskQueue <IServiceRequestContext>(Options.TaskQueue_MaxThreads, Options.TaskQueue_QueueLength);
            }
        }
Beispiel #8
0
        static public void AppendMenuItems(ContextMenuStrip strip, IExplorerObject ExplorerObject)
        {
            if (ExplorerObject == null)
            {
                return;
            }

            Guid          ExplorerObjectGUID = PlugInManager.PlugInID(ExplorerObject);
            PlugInManager compManager        = new PlugInManager();

            var commands = compManager.GetPlugins(Plugins.Type.IExplorerCommand);

            if (commands == null)
            {
                return;
            }

            foreach (var commandType in commands)
            {
                try
                {
                    IExplorerCommand command = compManager.CreateInstance <IExplorerCommand>(commandType);
                    if (command == null ||
                        (command.ExplorerObjectGUID != ExplorerObjectGUID && command.ExplorerObjectGUID != KnownExplorerObjectIDs.Any))
                    {
                        continue;
                    }

                    foreach (XmlNode node in command.CommandDefs)
                    {
                        if (node.Attributes["name"] == null)
                        {
                            continue;
                        }

                        ToolStripItem item = new CommandToolStripItem(ExplorerObject, node);
                        item.Click += new EventHandler(CommandItem_Click);

                        if (strip.Items.Count == 0)
                        {
                            strip.Items.Add(new ToolStripSeparator());
                        }

                        strip.Items.Add(item);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #9
0
        async virtual public Task WriteMetadata(IPersistStream stream)
        {
            PlugInManager plugins = new PlugInManager();

            if (_providers != null)
            {
                foreach (IMetadataProvider provider in _providers)
                {
                    if (provider == null)
                    {
                        continue;
                    }

                    // mit ApplyTo noch einmal das this Objekt auf den Provider
                    // setzen, damit beim speichern immer das aktuelle Object gesetzt wird...
                    await provider.ApplyTo(this);

                    stream.Save("IMetadataProvider", provider);
                }
            }
            else
            {
                _providers = new ConcurrentBag <IMetadataProvider>();
            }

            foreach (Type providerType in plugins.GetPlugins(typeof(IMetadataProvider)))
            {
                IMetadataProvider provider = plugins.CreateInstance(providerType) as IMetadataProvider;
                if (provider == null)
                {
                    continue;
                }

                // nach bereits vorhanden suchen...
                IMetadataProvider provider2 = this.MetadataProvider(PlugInManager.PlugInID(provider));
                if (provider2 != null)
                {
                    continue;
                }

                if (await provider.ApplyTo(this))
                {
                    stream.Save("IMetadataProvider", provider);
                    _providers.Add(provider);
                }
            }
        }
Beispiel #10
0
        private void MakeGUI()
        {
            cmbSymbolTypes.Items.Clear();

            if (PlugInManager.IsPlugin(_symbol))
            {
                PlugInManager compManager = new PlugInManager();

                foreach (var symbolType in compManager.GetPlugins(Plugins.Type.ISymbol))
                {
                    ISymbol symbol = compManager.CreateInstance <ISymbol>(symbolType);
                    if (symbol is SymbolCollection)
                    {
                        continue;
                    }

                    if (_symbol.GetType().Equals(symbol.GetType()))
                    {
                        symbol = _symbol;
                    }

                    if (_symbol is IPointSymbol && symbol is IPointSymbol)
                    {
                        cmbSymbolTypes.Items.Add(new SymbolItem(symbol));
                    }
                    if (_symbol is ILineSymbol && symbol is ILineSymbol)
                    {
                        cmbSymbolTypes.Items.Add(new SymbolItem(symbol));
                    }
                    if (_symbol is IFillSymbol && symbol is IFillSymbol)
                    {
                        cmbSymbolTypes.Items.Add(new SymbolItem(symbol));
                    }
                    if (_symbol is ITextSymbol && symbol is ITextSymbol)
                    {
                        ((ITextSymbol)symbol).Text = "Label";
                        cmbSymbolTypes.Items.Add(new SymbolItem(symbol));
                    }
                    if (_symbol.GetType().Equals(symbol.GetType()) &&
                        cmbSymbolTypes.Items.Count > 0)
                    {
                        cmbSymbolTypes.SelectedItem = cmbSymbolTypes.Items[cmbSymbolTypes.Items.Count - 1];
                    }
                }
            }
        }
Beispiel #11
0
        private void FormAddDataset_Load(object sender, System.EventArgs e)
        {
            //if(_map==null) this.Close();

            listView1.Items.Clear();
            PlugInManager compManager = new PlugInManager();

            foreach (var type in compManager.GetPlugins(Plugins.Type.IDataset))
            {
                IDataset dataset = compManager.CreateInstance <IDataset>(type);
                if (dataset == null)
                {
                    continue;
                }
                listView1.Items.Add(new DatasetProviderItem(dataset));
            }
        }
Beispiel #12
0
        public void Save(IPersistStream stream)
        {
            if (_application == null)
            {
                return;
            }

            PlugInManager compMan = new PlugInManager();

            foreach (Type compType in compMan.GetPlugins(Plugins.Type.IMapApplicationModule))
            {
                IMapApplicationModule module = _application.IMapApplicationModule(PlugInManager.PluginIDFromType(compType));
                if (module is IPersistable)
                {
                    stream.Save("Module", new ModulePersist(module));
                }
            }
        }
Beispiel #13
0
        async public override Task <bool> Refresh()
        {
            await base.Refresh();

            PlugInManager compMan = new PlugInManager();

            foreach (var compType in compMan.GetPlugins(Plugins.Type.IExplorerObject))
            {
                IExplorerObject exObject = compMan.CreateInstance <IExplorerObject>(compType);
                if (!(exObject is IOgcGroupExplorerObject))
                {
                    continue;
                }

                base.AddChildObject(exObject);
            }

            return(true);
        }
        public MapServerConnectionExplorerObject(IExplorerObject parent)
            : base(parent, null, 0)
        {
            List <ToolStripItem> contextItems = new List <ToolStripItem>();

            ToolStripMenuItem importItem = new ToolStripMenuItem(LocalizedResources.GetResString("Menu.Import", "Import"));

            contextItems.Add(importItem);
            ToolStripMenuItem newService = new ToolStripMenuItem(LocalizedResources.GetResString("Menu.NewServiceFromMap", "New Service From gView Map..."));

            newService.Click += new EventHandler(newService_Click);
            newService.Image  = (new MapServiceIcon()).Image;
            importItem.DropDownItems.Add(newService);

            //ToolStripMenuItem newServiceColl = new ToolStripMenuItem("New Map Service Collection ...");
            //newServiceColl.Click += new EventHandler(newServiceColl_Click);
            //importItem.DropDownItems.Add(newServiceColl);

            PlugInManager compMan = new PlugInManager();

            foreach (Type serviceableType in compMan
                     .GetPlugins(Plugins.Type.IServiceableDataset))
            {
                IServiceableDataset ds = compMan.CreateInstance(serviceableType) as IServiceableDataset;
                if (ds == null)
                {
                    return;
                }

                if (importItem.DropDownItems.Count == 1)
                {
                    importItem.DropDownItems.Add(new ToolStripSeparator());
                }

                ToolStripItem item = new ServiceableDatasetItem(this, ds);
                item.Image = (new MapServiceIcon2()).Image;
                importItem.DropDownItems.Add(item);
            }

            _contextItems = contextItems.ToArray();
        }
Beispiel #15
0
        async public override Task <bool> Refresh()
        {
            await base.Refresh();

            string[] drives = System.IO.Directory.GetLogicalDrives();

            foreach (string drive in drives)
            {
                System.IO.DriveInfo info = new System.IO.DriveInfo(drive);

                DriveObject exObject = new DriveObject(this, info.Name.Replace("\\", ""), (uint)info.DriveType);
                base.AddChildObject(exObject);
            }

            ConfigConnections           configStream       = new ConfigConnections("directories");
            Dictionary <string, string> networkDirectories = configStream.Connections;

            if (networkDirectories != null)
            {
                foreach (string dir in networkDirectories.Keys)
                {
                    MappedDriveObject exObject = new MappedDriveObject(this, networkDirectories[dir]);
                    base.AddChildObject(exObject);
                }
            }

            PlugInManager compMan = new PlugInManager();

            foreach (var exObjectType in compMan.GetPlugins(Plugins.Type.IExplorerObject))
            {
                var exObject = compMan.CreateInstance <IExplorerObject>(exObjectType);
                if (!(exObject is IExplorerGroupObject))
                {
                    continue;
                }

                base.AddChildObject(exObject);
            }

            return(true);
        }
Beispiel #16
0
        public void Content_DragEnter(DragEventArgs e, IUserData userdata)
        {
            PlugInManager compMan = new PlugInManager();
            bool          found   = false;

            foreach (var dbType in compMan.GetPlugins(Plugins.Type.IFileFeatureDatabase))
            {
                IFileFeatureDatabase db = compMan.CreateInstance(dbType) as IFileFeatureDatabase;
                if (db == null)
                {
                    continue;
                }

                found = true;
            }
            if (!found)
            {
                return;
            }

            foreach (string format in e.Data.GetFormats())
            {
                object ob = e.Data.GetData(format);

                if (ob is List <IExplorerObjectSerialization> )
                {
                    foreach (IExplorerObjectSerialization ser in (List <IExplorerObjectSerialization>)ob)
                    {
                        if (ser.ObjectTypes.Contains(typeof(IFeatureDataset)) ||
                            ser.ObjectTypes.Contains(typeof(IFeatureClass)))
                        {
                            e.Effect = DragDropEffects.Copy;
                            return;
                        }
                    }
                }
            }
        }
        private void FillFormatList()
        {
            PlugInManager compMan = new PlugInManager();

            foreach (var dsType in compMan.GetPlugins(Plugins.Type.IDataset))
            {
                IRasterFileDataset rds = compMan.CreateInstance <IDataset>(dsType) as IRasterFileDataset;
                if (rds == null)
                {
                    continue;
                }

                foreach (string format in rds.SupportedFileFilter.Split('|'))
                {
                    if (format == String.Empty)
                    {
                        continue;
                    }

                    int priority = rds.SupportsFormat(format.Replace("*", ""));
                    //FormatListItem item = FindFormatItem(format);
                    //if (item != null)
                    //{
                    //    if (item.Priority < priority)
                    //    {
                    //        item.Provider = rds.ToString();
                    //        item.Priority = priority;
                    //    }
                    //}
                    //else
                    //{
                    //    lstFormats.Items.Add(new FormatListItem(format, rds.ToString(), priority));
                    //}
                    lstFormats.Items.Add(new FormatListItem(format, rds.ToString(), priority, PlugInManager.PlugInID(rds)));
                }
            }
        }
        public void OnCreate(object hook)
        {
            if (hook is IMapDocument)
            {
                _doc    = (IMapDocument)hook;
                _module = Module.GetModule(_doc);

                PlugInManager pluginMan = new PlugInManager();
                foreach (var tracerType in pluginMan.GetPlugins(gView.Framework.system.Plugins.Type.INetworkTracer))
                {
                    INetworkTracer tracer = pluginMan.CreateInstance <INetworkTracer>(tracerType);
                    if (tracer == null)
                    {
                        continue;
                    }

                    _combo.Items.Add(new NetworkTracerItem(tracer));
                }
                if (_combo.Items.Count > 0)
                {
                    _combo.SelectedIndex = 0;
                }
            }
        }
Beispiel #19
0
        public void OnShowControl(object hook)
        {
            if (hook is IMapDocument)
            {
                tabControl.TabPages.Clear();
                _document = (IMapDocument)hook;

                PlugInManager compMan = new PlugInManager();
                foreach (var pageType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IMapOptionPage))
                {
                    IMapOptionPage page = compMan.CreateInstance <IMapOptionPage>(pageType);
                    if (page == null)
                    {
                        continue;
                    }

                    Panel pagePanel = page.OptionPage(_document);
                    if (pagePanel == null)
                    {
                        continue;
                    }

                    TabPage tabPage = new TabPage(page.Title);
                    tabPage.Controls.Add(pagePanel);

                    if (page.Image != null)
                    {
                        imageList1.Images.Add(page.Image);
                        tabPage.ImageIndex = imageList1.Images.Count - 1;
                    }

                    tabControl.TabPages.Add(tabPage);
                    _optionPages.Add(page);
                }
            }
        }
Beispiel #20
0
        public void AppendContextMenuItems(global::System.Windows.Forms.ContextMenuStrip strip, object context)
        {
            PlugInManager compMan = new PlugInManager();

            List <IOrder> items = new List <IOrder>();

            foreach (var toolType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IExTool))
            {
                IContextMenuItem item = compMan.TryCreateInstance <IContextMenuItem>(toolType);
                if (item == null || !item.ShowWith(context) || !(item is IExTool))
                {
                    continue;
                }
                ((IExTool)item).OnCreate(_application);
                items.Add(item);
            }

            items.Sort(new SortByIOrder());

            int l = -1;

            foreach (IContextMenuItem item in items)
            {
                if (Math.Abs(l - item.SortOrder / 10) != 0)
                {
                    l = item.SortOrder / 10;
                    if (strip.Items.Count > 0)
                    {
                        strip.Items.Add(new global::System.Windows.Forms.ToolStripSeparator());
                    }
                }
                ToolMenuItem toolItem = new ToolMenuItem(item as IExTool);
                toolItem.Click += new EventHandler(ToolButton_Click);
                strip.Items.Add(toolItem);
            }
        }
        async private Task <bool> InsertImage(IFeatureUpdater fdb, IFeatureClass rasterFC, FileInfo fi, Dictionary <string, Guid> providers)
        {
            if (!_cancelTracker.Continue)
            {
                _errMsg = "Canceled by user...";
                return(false);
            }

            if (ReportAction != null)
            {
                ReportAction(this, "Insert Image: " + fi.FullName);
            }

            if (ReportProgress != null)
            {
                ReportProgress(this, 1);
            }

            System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg;
            switch (fi.Extension.ToLower())
            {
            case ".png":
                format = System.Drawing.Imaging.ImageFormat.Png;
                break;

            case ".tif":
            case ".tiff":
                format = System.Drawing.Imaging.ImageFormat.Tiff;
                break;
            }

            #region RasterFileDataset bestimmen
            List <IRasterFileDataset> rFileDatasets = new List <IRasterFileDataset>();
            IRasterFileDataset        rFileDataset  = null;
            IRasterLayer  rasterLayer = null;
            PlugInManager compMan     = new PlugInManager();
            foreach (var dsType in compMan.GetPlugins(Plugins.Type.IDataset))
            {
                IRasterFileDataset rds = compMan.CreateInstance <IDataset>(dsType) as IRasterFileDataset;
                if (rds == null)
                {
                    continue;
                }

                if (rds.SupportsFormat(fi.Extension) < 0)
                {
                    continue;
                }

                if (providers != null && providers.ContainsKey(fi.Extension.ToLower()))
                {
                    if (!providers[fi.Extension.ToLower()].Equals(PlugInManager.PlugInID(rds)))
                    {
                        continue;
                    }
                }
                rFileDatasets.Add(rds);
            }
            if (rFileDatasets.Count == 0)
            {
                _errMsg = "No Rasterfile Provider for " + fi.Extension;
                return(false);
            }

            // RasterFileDataset nach priorität sortieren
            rFileDatasets.Sort(new RasterFileDatasetComparer(fi.Extension));

            // RasterFileDataset suchen, mit dem sich Bild öffnen läßt
            foreach (IRasterFileDataset rfd in rFileDatasets)
            {
                rfd.AddRasterFile(fi.FullName);

                if ((await rfd.Elements()).Count == 0)
                {
                    //Console.WriteLine(_errMsg = fi.FullName + " is not a valid Raster File...");
                    continue;
                }
                IDatasetElement element = (await rfd.Elements())[0];
                if (!(element is IRasterLayer))
                {
                    //Console.WriteLine(_errMsg = fi.FullName + " is not a valid Raster Layer...");
                    rFileDataset.Dispose();
                    continue;
                }

                // gefunden...
                rasterLayer  = (IRasterLayer)element;
                rFileDataset = rfd;
                break;
            }
            if (rasterLayer == null || rFileDataset == null)
            {
                Console.WriteLine(_errMsg = fi.FullName + " is not a valid Raster Layer...");
                return(false);
            }
            #endregion

            FileInfo fiWorld = null;
            double   cellX   = 1;
            double   cellY   = 1;

            IRasterFile rasterFile = null;
            if (rasterLayer is IRasterFile)
            {
                rasterFile = (IRasterFile)rasterLayer;
            }
            if (rasterLayer.RasterClass != null)
            {
                if (rasterLayer.RasterClass is IRasterFile &&
                    ((IRasterFile)rasterLayer.RasterClass).WorldFile != null)
                {
                    rasterFile = (IRasterFile)rasterLayer.RasterClass;
                }
                else
                {
                    IRasterClass c = rasterLayer.RasterClass;
                    cellX = Math.Sqrt(c.dx1 * c.dx1 + c.dx2 * c.dx2);
                    cellY = Math.Sqrt(c.dy1 * c.dy1 + c.dy2 * c.dy2);
                }
            }
            if (rasterFile != null)
            {
                try
                {
                    IRasterWorldFile world = rasterFile.WorldFile;
                    if (world != null)
                    {
                        if (!world.isGeoReferenced)
                        {
                            if (handleNonGeorefAsError)
                            {
                                _errMsg = "Can't add non georeferenced images: " + fi.FullName;
                                return(false);
                            }
                            else
                            {
                                return(true);
                            }
                        }

                        cellX = Math.Sqrt(world.dx_X * world.dx_X + world.dx_Y * world.dx_Y);
                        cellY = Math.Sqrt(world.dy_X * world.dy_X + world.dy_Y * world.dy_Y);

                        fiWorld = new FileInfo(rasterFile.WorldFile.Filename);
                        if (!fiWorld.Exists)
                        {
                            fiWorld = null;
                        }
                    }
                }
                catch
                {
                    fiWorld = null;
                }
            }

            #region Check if already Exits
            //
            // Suchen, ob Image mit gleichen Pfad schon vorhanden ist, wenn ja
            // nur weitermachen, wenn sich das änderungsdatum unterscheidet...
            //

            QueryFilter filter = new QueryFilter();
            filter.AddField("FDB_OID");
            filter.AddField("PATH");
            filter.AddField("LAST_MODIFIED");
            filter.AddField("PATH2");
            filter.AddField("LAST_MODIFIED2");

            if (_fdb is AccessFDB)
            {
                filter.WhereClause = ((AccessFDB)_fdb).DbColName("PATH") + "='" + ((AccessFDB)_fdb).EscapeQueryValue(fi.FullName) + "'";
            }
            else
            {
                filter.WhereClause = "PATH='" + fi.FullName.Replace(@"\", @"\\") + "'";
            }

            int deleteOID = -1;
            using (IFeatureCursor cursor = await rasterFC.GetFeatures(filter))
            {
                IFeature existingFeature = await cursor.NextFeature();

                if (existingFeature != null)
                {
                    DateTime dt1 = (DateTime)existingFeature["LAST_MODIFIED"];

                    if (!fi.LastWriteTimeUtc.IsEqual2(dt1, 1))
                    {
                        deleteOID = existingFeature.OID;
                    }
                    else if (fiWorld != null &&
                             existingFeature["PATH2"] != System.DBNull.Value &&
                             existingFeature["PATH2"].ToString() != String.Empty)
                    {
                        DateTime dt2 = (DateTime)existingFeature["LAST_MODIFIED2"];
                        if (existingFeature["PATH2"].ToString().ToLower() != fiWorld.FullName.ToLower() ||
                            Math.Abs((dt2 - fiWorld.LastWriteTimeUtc).TotalSeconds) > 1.0)
                        {
                            deleteOID = existingFeature.OID;
                        }
                    }

                    if (deleteOID == -1)
                    {
                        Console.Write(".");
                        //Console.WriteLine(fi.FullName + " already exists...");
                        return(true);
                    }
                }
            }
            if (deleteOID != -1)
            {
                if (!await fdb.Delete(rasterFC, deleteOID))
                {
                    Console.WriteLine(_errMsg = "Can't delete old record " + fi.FullName + "\n" + fdb.LastErrorMessage);
                    return(false);
                }
            }
            //
            ///////////////////////////////////////////////////////////////////
            //
            #endregion

            Feature feature = new Feature();
            feature.Shape = rasterLayer.RasterClass.Polygon;
            feature.Fields.Add(new FieldValue("PATH", fi.FullName));
            feature.Fields.Add(new FieldValue("LAST_MODIFIED", fi.LastWriteTimeUtc));
            if (fiWorld != null)
            {
                feature.Fields.Add(new FieldValue("PATH2", fiWorld.FullName));
                feature.Fields.Add(new FieldValue("LAST_MODIFIED2", fiWorld.LastWriteTimeUtc));
            }
            else
            {
                feature.Fields.Add(new FieldValue("PATH2", ""));
            }
            feature.Fields.Add(new FieldValue("RF_PROVIDER", PlugInManager.PlugInID(rFileDataset).ToString()));
            feature.Fields.Add(new FieldValue("MANAGED", _managed && (rasterLayer is IRasterFileBitmap)));
            feature.Fields.Add(new FieldValue("FORMAT", fi.Extension.Replace(".", "")));
            feature.Fields.Add(new FieldValue("CELLX", cellX));
            feature.Fields.Add(new FieldValue("CELLY", cellY));
            feature.Fields.Add(new FieldValue("LEVELS", (_managed) ? Math.Max(_levels, 1) : 0));

            if (!await fdb.Insert(rasterFC, feature))
            {
                Console.WriteLine("\nERROR@" + fi.FullName + ": " + fdb.LastErrorMessage);
            }
            else
            {
                //if (_managed && (rasterLayer is IBitmap) && (fdb is SqlFDB))
                //{
                //    QueryFilter qfilter = new QueryFilter();
                //    qfilter.SubFields = "FDB_OID";
                //    if (_fdb is AccessFDB)
                //    {
                //        filter.WhereClause = ((AccessFDB)_fdb).DbColName("PATH") + "='" + fi.FullName + "'";
                //    }
                //    else
                //    {
                //        qfilter.WhereClause = "PATH='" + fi.FullName + "'";
                //    }

                //    IFeatureCursor cursor = await ((SqlFDB)fdb).Query(rasterFC, qfilter);
                //    if (cursor != null)
                //    {
                //        IFeature feat = await cursor.NextFeature();
                //        if (feat != null)
                //        {
                //            await InsertImageDatasetBitmap(feat.OID, rasterLayer, _levels, format);
                //        }
                //        cursor.Dispose();
                //    }
                //}

                Console.WriteLine(">" + fi.FullName + " added...");
            }

            rFileDataset.Dispose();
            return(true);
        }
Beispiel #22
0
        async public void Content_DragDrop(DragEventArgs e, IUserData userdata)
        {
            PlugInManager compMan = new PlugInManager();
            List <IFileFeatureDatabase> databases = new List <IFileFeatureDatabase>();

            foreach (var dbType in compMan.GetPlugins(Plugins.Type.IFileFeatureDatabase))
            {
                var db = compMan.CreateInstance <IFileFeatureDatabase>(dbType);
                if (db == null)
                {
                    continue;
                }

                databases.Add(db);
            }
            if (databases.Count == 0)
            {
                return;
            }

            bool schemaOnly = false;

            if (userdata != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema") != null &&
                userdata.GetUserData("gView.Framework.UI.BaseTools.PasteSchema").Equals(true))
            {
                schemaOnly = true;
            }

            foreach (string format in e.Data.GetFormats())
            {
                object ob = e.Data.GetData(format);
                if (ob is IEnumerable <IExplorerObjectSerialization> )
                {
                    ExplorerObjectManager exObjectManager = new ExplorerObjectManager();

                    List <IExplorerObject> exObjects = new List <IExplorerObject>(await exObjectManager.DeserializeExplorerObject((IEnumerable <IExplorerObjectSerialization>)ob));
                    if (exObjects == null)
                    {
                        return;
                    }

                    foreach (IExplorerObject exObject in ListOperations <IExplorerObject> .Clone(exObjects))
                    {
                        IFeatureClass fc = await exObject.GetInstanceAsync() as IFeatureClass;

                        if (fc == null)
                        {
                            continue;
                        }
                    }
                    if (exObjects.Count == 0)
                    {
                        return;
                    }

                    FormFeatureclassCopy dlg = await FormFeatureclassCopy.Create(exObjects, databases, this.FullName);

                    dlg.SchemaOnly = schemaOnly;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        continue;
                    }

                    if (dlg.SelectedFeatureDatabase == null)
                    {
                        return;
                    }
                    IFileFeatureDatabase fileDB = dlg.SelectedFeatureDatabase;
                    _dataset = await fileDB.GetDataset(this.FullName);

                    if (_dataset == null)
                    {
                        return;
                    }

                    //_dataset = new ImportFeatureDataset(dlg.SelectedFeatureDatabase);

                    foreach (FeatureClassListViewItem fcItem in dlg.FeatureClassItems)
                    {
                        await ImportDatasetObject(fcItem, schemaOnly);
                    }

                    exObjectManager.Dispose(); // alle ExplorerObjects wieder löschen...
                }
            }
        }
Beispiel #23
0
        async private Task <ContextMenuStrip> BuildContextMenu(IExplorerObject exObject, List <IExplorerObject> context, bool emptyContentsClick)
        {
            if (_strip != null && _strip.Visible == true)
            {
                _strip.Close();
            }

            _strip = contextStrip;
            for (int i = _strip.Items.Count - 1; i >= _contextItemCount; i--)
            {
                _strip.Items.RemoveAt(i);
            }

            toolStripMenuItemNew.DropDownItems.Clear();
            PlugInManager compMan = new PlugInManager();

            foreach (var compType in compMan.GetPlugins(Plugins.Type.IExplorerObject))
            {
                IExplorerObject ex = compMan.CreateInstance <IExplorerObject>(compType);
                if (ex is IExplorerObjectCreatable)
                {
                    if (!((IExplorerObjectCreatable)ex).CanCreate(_exObject))
                    {
                        continue;
                    }
                    ToolStripItem createNewItem = new CreateNewToolStripItem(ex);
                    createNewItem.Click += new EventHandler(createNewItem_Click);
                    toolStripMenuItemNew.DropDownItems.Add(createNewItem);
                }
            }
            toolStripMenuItemNew.Enabled = (toolStripMenuItemNew.DropDownItems.Count != 0);

            if (_app != null)
            {
                _app.AppendContextMenuItems(_strip, emptyContentsClick ? null : context /*this.SelectedExplorerObjects*/);
            }
            CommandInterpreter.AppendMenuItems(_strip, exObject);

            if (!emptyContentsClick)
            {
                //if (exObject is IExplorerObjectRenamable)
                //{
                //    if (_strip.Items.Count > 0) _strip.Items.Add(new ToolStripSeparator());
                //    _strip.Items.Add(_renameMenuItem);
                //}
                //if (exObject is IExplorerObjectDeletable)
                //{
                //    _strip.Items.Add(_deleteMenuItem);
                //}
            }

            if (exObject is IExplorerObjectContextMenu)
            {
                ToolStripItem[] contextItems = ((IExplorerObjectContextMenu)exObject).ContextMenuItems;
                if (contextItems != null && contextItems.Length > 0)
                {
                    _strip.Items.Add(new ToolStripSeparator());
                    foreach (ToolStripItem contextItem in contextItems)
                    {
                        _strip.Items.Add(contextItem);
                    }
                }
            }
            if (exObject is IExplorerObjectContextMenu2)
            {
                ToolStripItem[] contextItems = ((IExplorerObjectContextMenu2)exObject).ContextMenuItems(RefreshContents);
                if (contextItems != null && contextItems.Length > 0)
                {
                    _strip.Items.Add(new ToolStripSeparator());
                    foreach (ToolStripItem contextItem in contextItems)
                    {
                        _strip.Items.Add(contextItem);
                    }
                }
            }

            var exObjectInstance = await exObject.GetInstanceAsync();

            if (exObject != null && exObjectInstance is IFeatureClass)
            {
                IFeatureClass fc = (IFeatureClass)exObjectInstance;
                if (fc.Dataset != null && fc.Dataset.Database is IFeatureDatabaseReplication)
                {
                    _strip.Items.Add(new ToolStripSeparator());
                    _strip.Items.Add(_replicationMenuItem);

                    _appendReplicationIDMenuItem.Enabled = !await Replication.FeatureClassHasRelicationID(fc);

                    _checkoutMenuItem.Enabled = await Replication.FeatureClassCanReplicate(fc);

                    _checkinMenuItem.Enabled = (await Replication.FeatureClassGeneration(fc) > 0);
                }
            }

            if (exObject is IMetadata)
            {
                _strip.Items.Add(new ToolStripSeparator());
                _strip.Items.Add(_metadataMenuItem);
            }

            _contextObject = exObject;
            return(_strip);
        }
Beispiel #24
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                _application = new ExplorerApplication(this);
                _application.DockWindowAdded      += new DockWindowAddedEvent(_application_DockWindowAdded);
                _application.OnShowDockableWindow += new OnShowDockableWindowEvent(_application_OnShowDockableWindow);

                #region Windows Forms Control Disign

                _toolStripAddress              = new System.Windows.Forms.ToolStrip();
                _toolStripAddress.Stretch      = true;
                _toolStripAddress.GripMargin   = new System.Windows.Forms.Padding(1);
                _toolStripAddress.LayoutStyle  = System.Windows.Forms.ToolStripLayoutStyle.Flow;
                _toolStripAddress.BackColor    = System.Drawing.Color.White;
                winFormsHostStripAddress.Child = _toolStripAddress;
                #endregion

                _tree = new gView.Framework.UI.Dialogs.FormCatalogTree(_application, false);
                _tree.NodeSelected += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeClickedEvent(tree_NodeSelected);
                _tree.NodeRenamed  += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeRenamedEvent(tree_NodeRenamed);
                _tree.NodeDeleted  += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeDeletedEvent(tree_NodeDeleted);
                //winFormsHostExplorerTree.Child = _tree;

                PlugInManager compMan = new PlugInManager();
                foreach (var tabType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerTabPage))
                {
                    IExplorerTabPage page = compMan.CreateInstance <IExplorerTabPage>(tabType);
                    if (page == null || page.Control == null)
                    {
                        continue;
                    }

                    page.OnCreate(_application);

                    LayoutDocument layoutDoc = new LayoutDocument();
                    layoutDoc.Title    = layoutDoc.ContentId = page.Title;
                    layoutDoc.CanClose = false;
                    layoutDoc.CanFloat = false;
                    layoutDoc.Content  = new WindowsFormsHost();
                    ((WindowsFormsHost)layoutDoc.Content).Child = page.Control;
                    _tabPages.Add(new TabPage(page, layoutDoc));
                    if (page is gView.Framework.UI.Controls.ContentsList)
                    {
                        ((gView.Framework.UI.Controls.ContentsList)page).ItemSelected += new gView.Framework.UI.Controls.ContentsList.ItemClickedEvent(ContentsList_ItemSelected);
                        _content = (gView.Framework.UI.Controls.ContentsList)page;
                    }
                }
                explorerDocPane.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(explorerDocPane_PropertyChanged);

                anchorPaneRight.Children[0].Hide();
                _application.AddDockableWindow(_tree, DockWindowState.left);

                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load("menu.explorer.xml");

                    MakeMainMenuBar(doc.SelectSingleNode("//Menubar"));
                }
                catch { }

                MakeRibbon();
                ValidateButtons();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
Beispiel #25
0
        public void MakeRibbon()
        {
            PlugInManager pm = new PlugInManager();

            foreach (IExplorerRibbonTab exRibbonTab in OrderedPluginList <IExplorerRibbonTab> .Sort(
                         pm.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerRibbonTab).Select(p => pm.CreateInstance <IExplorerRibbonTab>(p))))
            {
                Fluent.RibbonTabItem tabItem = new Fluent.RibbonTabItem();
                tabItem.Header = exRibbonTab.Header;
                ribbon.Tabs.Add(tabItem);
                tabItem.DataContext = exRibbonTab;

                foreach (RibbonGroupBox exGroupBox in exRibbonTab.Groups)
                {
                    Fluent.RibbonGroupBox groupBox = new Fluent.RibbonGroupBox();
                    groupBox.Header = exGroupBox.Header;
                    tabItem.Groups.Add(groupBox);

                    foreach (RibbonItem cartoRibbonItem in exGroupBox.Items)
                    {
                        Guid toolGUID = cartoRibbonItem.Guid;
                        if (toolGUID == new Guid("00000000-0000-0000-0000-000000000000"))
                        {
                            groupBox.Items.Add(new Separator());
                            continue;
                        }

                        object tool = pm.CreateInstance(toolGUID);
                        if (tool == null)
                        {
                            continue;
                        }

                        #region IToolItem
                        if (tool is IToolItem)
                        {
                            if (((IToolItem)tool).ToolItem != null)
                            {
                                if (((IToolItem)tool).ToolItem is global::System.Windows.Forms.ToolStripItem)
                                {
                                    StackPanel panel = new StackPanel();
                                    panel.Margin = new Thickness(0, 32, 0, 0);

                                    global::System.Windows.Forms.ToolStripItem stripItem = ((IToolItem)tool).ToolItem;

                                    global::System.Windows.Forms.MenuStrip bar = new global::System.Windows.Forms.MenuStrip();
                                    bar.BackColor = global::System.Drawing.Color.Transparent; //.FromArgb(223, 234, 246);

                                    bar.Items.Add(stripItem);

                                    WindowsFormsHost host = new WindowsFormsHost();
                                    host.Background = new SolidColorBrush(Color.FromRgb(223, 234, 246));
                                    host.Child      = bar;

                                    if (tool is IToolItemLabel)
                                    {
                                        IToolItemLabel label = (IToolItemLabel)tool;
                                        panel.Orientation = label.LabelPosition == ToolItemLabelPosition.top ||
                                                            label.LabelPosition == ToolItemLabelPosition.bottom ? Orientation.Vertical : Orientation.Horizontal;

                                        if (panel.Orientation == Orientation.Vertical)
                                        {
                                            panel.Margin = new Thickness(0, 13, 0, 0);
                                        }

                                        TextBlock text = new TextBlock();
                                        text.Text    = label.Label;
                                        text.Padding = new Thickness(3);

                                        if (label.LabelPosition == ToolItemLabelPosition.top || label.LabelPosition == ToolItemLabelPosition.left)
                                        {
                                            panel.Children.Insert(0, text);
                                        }
                                        else
                                        {
                                            panel.Children.Add(text);
                                        }
                                    }

                                    panel.Children.Add(host);

                                    groupBox.Items.Add(panel);
                                }
                            }
                        }
                        #endregion

                        #region IToolMenu
                        else if (tool is IExToolMenu)
                        {
                            DropDownToolButton button = new DropDownToolButton(tool as IExToolMenu);
                            button.Click += new RoutedEventHandler(ToolButton_Click);
                            groupBox.Items.Add(button);
                        }
                        #endregion

                        #region ITool
                        else if (tool is IExTool)
                        {
                            ((IExTool)tool).OnCreate(_application);
                            ToolButton button = new ToolButton(tool as IExTool);
                            button.SizeDefinition = cartoRibbonItem.SizeDefinition;

                            groupBox.Items.Add(button);
                            button.Click += new RoutedEventHandler(ToolButton_Click);
                        }
                        #endregion
                    }
                }

                if (ribbon.Tabs.Count == 1)
                {
                    #region Favorites
                    Fluent.RibbonGroupBox favBox = new Fluent.RibbonGroupBox();
                    favBox.Header             = String.Empty;
                    _favDropDownButton        = new Fluent.DropDownButton();
                    _favDropDownButton.Header = "Favorites";
                    _favDropDownButton.Icon   = _favDropDownButton.LargeIcon = ImageFactory.FromBitmap(global::gView.Win.DataExplorer.Properties.Resources.folder_heart);

                    Fluent.MenuItem add2fav = new Fluent.MenuItem();
                    add2fav.Header = "Add to favorites...";
                    add2fav.Icon   = ImageFactory.FromBitmap(global::gView.Win.DataExplorer.Properties.Resources.folder_heart);
                    add2fav.Click += new RoutedEventHandler(Add2Favorites_Click);
                    _favDropDownButton.Items.Add(add2fav);

                    bool first = true;
                    foreach (MyFavorites.Favorite fav in (new MyFavorites().Favorites))
                    {
                        if (fav == null)
                        {
                            continue;
                        }

                        WpfFavoriteMenuItem fItem = new WpfFavoriteMenuItem(fav);
                        fItem.Click += new RoutedEventHandler(MenuItem_Favorite_Click);

                        if (first)
                        {
                            first = false;
                            _favDropDownButton.Items.Add(new Separator());
                        }
                        _favDropDownButton.Items.Add(fItem);
                    }

                    favBox.Items.Add(_favDropDownButton);
                    ribbon.Tabs[0].Groups.Add(favBox);
                    #endregion

                    _createNewRibbonGroupBox            = new Fluent.RibbonGroupBox();
                    _createNewRibbonGroupBox.Header     = "Create New";
                    _createNewRibbonGroupBox.Visibility = Visibility.Visible;
                    _createNewRibbonGroupBox.Background = new SolidColorBrush(Colors.GreenYellow);

                    ribbon.Tabs[0].Groups.Add(_createNewRibbonGroupBox);
                }
            }

            #region Options
            Fluent.RibbonTabItem optionsTab = new Fluent.RibbonTabItem()
            {
                Header = "Options"
            };
            Fluent.RibbonGroupBox optionsBox = new Fluent.RibbonGroupBox()
            {
                Header = String.Empty
            };
            optionsTab.Groups.Add(optionsBox);

            foreach (var pageType in pm.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerOptionPage))
            {
                IExplorerOptionPage page = pm.CreateInstance <IExplorerOptionPage>(pageType);
                if (page == null)
                {
                    continue;
                }

                OptionsButton button = new OptionsButton(page);
                button.Click += new RoutedEventHandler(OptoinButton_Click);
                optionsBox.Items.Add(button);
            }
            ribbon.Tabs.Add(optionsTab);
            #endregion
        }
Beispiel #26
0
        async private Task tree_NodeSelected(global::System.Windows.Forms.TreeNode node)
        {
            if (_toolStripAddress == null)
            {
                return;
            }

            if (node is ExplorerObjectNode && ((ExplorerObjectNode)node).ExplorerObject != null)
            {
                RemovePathButtons();

                IExplorerObject pathObject = ((ExplorerObjectNode)node).ExplorerObject;
                while (pathObject != null)
                {
                    if (pathObject is IExplorerParentObject)
                    {
                        try
                        {
                            _toolStripAddress.Items.Insert(0, await SubPathParentToolStripItem.Create(this, (IExplorerParentObject)pathObject));
                        }
                        catch (Exception ex)
                        {
                            string msg = ex.Message;
                            MessageBox.Show(ex.Message);
                        }
                    }

                    SubPathToolStripItem item = new SubPathToolStripItem(pathObject);
                    item.Click += new EventHandler(SubPathItem_Click);
                    _toolStripAddress.Items.Insert(0, item);

                    pathObject = pathObject.ParentExplorerObject;
                }

                _selected.Clear();
                _selected.Add(_exObject = ((ExplorerObjectNode)node).ExplorerObject);

                await ViewTabPages(_exObject);

                if (_createNewRibbonGroupBox != null)
                {
                    RemoveCreateNewButtons();
                    PlugInManager compMan = new PlugInManager();
                    foreach (var compType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerObject))
                    {
                        IExplorerObject ex = compMan.CreateInstance <IExplorerObject>(compType);
                        if (ex is IExplorerObjectCreatable)
                        {
                            if (!((IExplorerObjectCreatable)ex).CanCreate(_exObject))
                            {
                                continue;
                            }

                            //if (_toolStripCreateNew.Items.Count == 0)
                            //{
                            //    _toolStripCreateNew.Items.Add(new System.Windows.Forms.ToolStripLabel(gView.Framework.Globalisation.LocalizedResources.GetResString("Create.New", "Create new") + ":"));
                            //}

                            CreateNewToolStripItem createNewItem = new CreateNewToolStripItem(ex);
                            createNewItem.Click += createNewItem_Click;
                            _createNewRibbonGroupBox.Items.Add(createNewItem);
                        }
                    }
                    if (_createNewRibbonGroupBox.Items.Count > 0)
                    {
                        _createNewRibbonGroupBox.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                RemovePathButtons();
                await ViewTabPages(null);
            }

            ValidateButtons();
        }