コード例 #1
0
            public static FunctionAddrLoader Load(LibraryConfig config)
            {
                LibraryContent[] libToLoad = null;
                var pt = GetPlatform(out var loader);

                switch (pt)
                {
                case LibraryLoaderPlatform.Win32: libToLoad = config.Win32; break;

                case LibraryLoaderPlatform.Win64: libToLoad = config.Win64; break;

                case LibraryLoaderPlatform.Linux32: libToLoad = config.Linux32; break;

                case LibraryLoaderPlatform.Linux64: libToLoad = config.Linux64; break;

                case LibraryLoaderPlatform.Mac64: libToLoad = config.Mac64; break;

                default:
                    throw new Exception("unknow platform");
                }

                return(GetFunctionAddrLoader(libToLoad ?? throw new Exception("un set the platform native on " + pt), loader));
            }
コード例 #2
0
 public GetMaxLoanDaysForPieceQueryHandler(GlobalConfig globalConfig, LibraryConfig libraryConfig)
 {
     this._connectionString = globalConfig.QueryConnectionString;
     this._globalLimit      = libraryConfig.MaxLoanDays;
 }
コード例 #3
0
        /// <summary>
        /// Add keywords from specified assembly and type
        /// </summary>
        public void AddLibrary(LibraryConfig config)
        {
            try
            {
                //check and record inputs
                if (String.IsNullOrEmpty(config.Assembly))
                {
                    throw new Exception("No keyword library specified");
                }
                if (String.IsNullOrEmpty(config.TypeName))
                {
                    throw new Exception("No keyword class type specified");
                }
                //check if already loaded type
                if (_loadedKeywords.ContainsKey(config.TypeName))
                {
                    Log.Debug(String.Format("Type {0} is already loaded", config.TypeName));
                    return;
                }
                Log.Debug(String.Format("Loading keywords from type : {0}", config.TypeName));

                //get instance
                var kwinstance = Activator.CreateInstance(config.Assembly, config.TypeName).Unwrap();
                var kwtype     = kwinstance.GetType();

                //load xml documentation
                XDocument kwdocumentation = null;
                if (!String.IsNullOrEmpty(config.Documentation))
                {
                    if (File.Exists(config.Documentation))
                    {
                        kwdocumentation = XDocument.Load(config.Documentation);
                    }
                    else
                    {
                        throw new Exception(String.Format("Xml documentation file not found : {0}", config.Documentation));
                    }
                }

                //build the list of available keywords
                var methods  = kwtype.GetMethods().Where(mi => mi.DeclaringType != typeof(object));
                var keywords = new List <Keyword>();
                foreach (var method in methods)
                {
                    if (HasValidSignature(method))
                    {
                        var keyword = new Keyword(kwinstance, method, kwdocumentation);
                        if (_loadedKeywords.ContainsKey(keyword.FriendlyName))
                        {
                            throw new Exception(String.Format("{0} keyword is duplicated", keyword.FriendlyName));
                        }
                        keywords.Add(keyword);
                    }
                }
                _loadedKeywords.Add(config.TypeName, keywords);
                Log.Debug(String.Format("Loaded keywords : {0}", String.Join(",", keywords.Select(k => k.FriendlyName).ToArray())));
            }
            catch (Exception e)
            {
                Log.Error(String.Format("Unable to load keyword library, {0}", e));
                throw new KeywordLoadingException("Unable to load keyword library", e);
            }
        }
コード例 #4
0
ファイル: PartTabPage.cs プロジェクト: will8886/MatterControl
        public PartTabPage(PartWorkspace workspace, ThemeConfig theme, string tabTitle)
            : base(tabTitle)
        {
            this.sceneContext    = workspace.SceneContext;
            this.theme           = theme;
            this.BackgroundColor = theme.BackgroundColor;
            this.Padding         = 0;
            this.printer         = workspace.Printer;
            this.workspace       = workspace;

            bool isPrinterType = this is PrinterTabPage;

            var favoritesBarAndView3DWidget = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            viewControls3D = new ViewControls3D(workspace, theme, sceneContext.Scene.UndoBuffer, isPrinterType, !(this is PrinterTabPage))
            {
                VAnchor = VAnchor.Top | VAnchor.Fit,
                HAnchor = HAnchor.Left | HAnchor.Stretch,
                Visible = true,
            };
            theme.ApplyBottomBorder(viewControls3D, shadedBorder: (this is PrinterTabPage));             // Shade border if toolbar is secondary rather than primary

            viewControls3D.ResetView += (sender, e) =>
            {
                if (view3DWidget.Visible)
                {
                    this.view3DWidget.ResetView();
                }
            };
            viewControls3D.ExtendOverflowMenu  = this.GetViewControls3DOverflowMenu;
            viewControls3D.OverflowButton.Name = "View3D Overflow Menu";

            // The 3D model view
            view3DWidget = new View3DWidget(
                printer,
                sceneContext,
                viewControls3D,
                theme,
                this,
                editorType: (isPrinterType) ? InteractionLayer.EditorType.Printer : InteractionLayer.EditorType.Part);

            viewControls3D.SetView3DWidget(view3DWidget);

            this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            topToBottom.AddChild(leftToRight = new FlowLayoutWidget()
            {
                Name    = "View3DContainerParent",
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            view3DContainer = new GuiWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            toolbarAndView3DWidget.AddChild(viewControls3D);

            var favoritesBarContext = new LibraryConfig()
            {
                ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer
            };

            var leftBar = new GuiWidget()
            {
                VAnchor     = VAnchor.Stretch,
                HAnchor     = HAnchor.Fit,
                Border      = new BorderDouble(top: 1, right: 1),
                BorderColor = theme.BorderColor20,
            };

            favoritesBarAndView3DWidget.AddChild(leftBar);

            bool expanded = UserSettings.Instance.get(UserSettingsKey.FavoritesBarExpansion) != "0";

            favoritesBar = new LibraryListView(favoritesBarContext, theme)
            {
                Name = "LibraryView",
                // Drop containers
                ContainerFilter  = (container) => false,
                HAnchor          = HAnchor.Absolute,
                VAnchor          = VAnchor.Stretch,
                AllowContextMenu = false,

                // restore to state for favorites bar size
                Width           = expanded ? 55 : 33,
                ListContentView = new IconView(theme, expanded ? 48 : 24)
                {
                    VAnchor = VAnchor.Fit | VAnchor.Top
                },
            };
            leftBar.AddChild(favoritesBar);

            favoritesBar.ScrollArea.VAnchor = VAnchor.Fit;

            var expandedImage  = AggContext.StaticData.LoadIcon("expand.png", 16, 16, theme.InvertIcons);
            var collapsedImage = AggContext.StaticData.LoadIcon("collapse.png", 16, 16, theme.InvertIcons);

            var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme)
            {
                HAnchor = HAnchor.Center,
                VAnchor = VAnchor.Absolute | VAnchor.Bottom,
                Margin  = new BorderDouble(bottom: 3, top: 3),
                Height  = theme.ButtonHeight - 6,
                Width   = theme.ButtonHeight - 6
            };

            expandBarButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                expanded = !expanded;

                UserSettings.Instance.set(UserSettingsKey.FavoritesBarExpansion, expanded ? "1" : "0");

                favoritesBar.ListContentView = new IconView(theme, expanded ? 48 : 24);
                favoritesBar.Width           = expanded ? 55 : 33;
                expandBarButton.SetIcon(expanded ? collapsedImage : expandedImage);
                expandBarButton.Invalidate();

                favoritesBar.Reload().ConfigureAwait(false);
            });
            leftBar.AddChild(expandBarButton);

            favoritesBar.Margin = new BorderDouble(bottom: expandBarButton.Height + expandBarButton.Margin.Height);

            favoritesBarAndView3DWidget.AddChild(view3DWidget);
            toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget);

            view3DContainer.AddChild(toolbarAndView3DWidget);

            leftToRight.AddChild(view3DContainer);

            if (sceneContext.World.RotationMatrix == Matrix4X4.Identity)
            {
                this.view3DWidget.ResetView();
            }

            this.AnchorAll();
        }
コード例 #5
0
        public PartTabPage(PartWorkspace workspace, ThemeConfig theme, string tabTitle)
            : base(tabTitle)
        {
            this.sceneContext    = workspace.SceneContext;
            this.theme           = theme;
            this.BackgroundColor = theme.BackgroundColor;
            this.Padding         = 0;
            this.Workspace       = workspace;

            bool isPrinterType = this is PrinterTabPage;

            var favoritesBarAndView3DWidget = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            viewControls3D = new ViewControls3D(workspace, theme, sceneContext.Scene.UndoBuffer, isPrinterType, !(this is PrinterTabPage))
            {
                VAnchor = VAnchor.Top | VAnchor.Fit,
                HAnchor = HAnchor.Left | HAnchor.Stretch,
                Visible = true,
            };

            // Shade border if toolbar is secondary rather than primary
            theme.ApplyBottomBorder(viewControls3D, shadedBorder: this is PrinterTabPage);

            viewControls3D.ResetView += (sender, e) =>
            {
                if (view3DWidget.Visible)
                {
                    this.view3DWidget.ResetView();
                }
            };
            viewControls3D.ExtendOverflowMenu  = this.GetViewControls3DOverflowMenu;
            viewControls3D.OverflowButton.Name = "View3D Overflow Menu";

            // The 3D model view
            view3DWidget = new View3DWidget(
                Printer,
                sceneContext,
                viewControls3D,
                theme,
                this,
                editorType: isPrinterType ? Object3DControlsLayer.EditorType.Printer : Object3DControlsLayer.EditorType.Part);

            viewControls3D.SetView3DWidget(view3DWidget);

            this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            topToBottom.AddChild(leftToRight = new FlowLayoutWidget()
            {
                Name    = "View3DContainerParent",
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            view3DContainer = new GuiWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            toolbarAndView3DWidget.AddChild(viewControls3D);

            var favoritesBarContext = new LibraryConfig()
            {
                ActiveContainer = ApplicationController.Instance.Library.RootLibaryContainer
            };

            var leftBar = new GuiWidget()
            {
                VAnchor     = VAnchor.Stretch,
                HAnchor     = HAnchor.Fit,
                Border      = new BorderDouble(top: 1, right: 1),
                BorderColor = theme.BorderColor20,
            };

            favoritesBarAndView3DWidget.AddChild(leftBar);

            bool expanded = UserSettings.Instance.get(UserSettingsKey.FavoritesBarExpansion) != "0";

            favoritesBar = new LibraryListView(favoritesBarContext, theme)
            {
                Name = "LibraryView",
                // Drop containers
                ContainerFilter = (container) => false,
                // HAnchor = HAnchor.Fit,
                HAnchor          = HAnchor.Absolute,
                VAnchor          = VAnchor.Stretch,
                AllowContextMenu = false,
                ActiveSort       = SortKey.ModifiedDate,
                Ascending        = true,
                // restore to state for favorites bar size
                Width           = expanded ? 55 * GuiWidget.DeviceScale : 33 * GuiWidget.DeviceScale,
                ListContentView = new IconView(theme, expanded ? 48 * GuiWidget.DeviceScale : 24 * GuiWidget.DeviceScale)
                {
                    VAnchor = VAnchor.Fit | VAnchor.Top
                },
            };

            // favoritesBar.ScrollArea.HAnchor = HAnchor.Fit;
            favoritesBar.ListContentView.HAnchor = HAnchor.Fit;
            leftBar.AddChild(favoritesBar);

            void UpdateWidth(object s, EventArgs e)
            {
                if (s is GuiWidget widget)
                {
                    favoritesBar.Width = widget.Width;
                }
            }

            favoritesBar.ListContentView.BoundsChanged += UpdateWidth;

            favoritesBar.ScrollArea.VAnchor = VAnchor.Fit;

            favoritesBar.VerticalScrollBar.Show = ScrollBar.ShowState.Never;

            var expandedImage  = StaticData.Instance.LoadIcon("expand.png", 16, 16).SetToColor(theme.TextColor);
            var collapsedImage = StaticData.Instance.LoadIcon("collapse.png", 16, 16).SetToColor(theme.TextColor);

            var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme)
            {
                HAnchor     = HAnchor.Center,
                VAnchor     = VAnchor.Absolute | VAnchor.Bottom,
                Margin      = new BorderDouble(bottom: 3, top: 3),
                Height      = theme.ButtonHeight - 6 * GuiWidget.DeviceScale,
                Width       = theme.ButtonHeight - 6 * GuiWidget.DeviceScale,
                ToolTipText = expanded ? "Reduced Width".Localize() : "Expand Width".Localize(),
            };

            expandBarButton.Click += (s, e) => UiThread.RunOnIdle(async() =>
            {
                expanded = !expanded;

                // remove from the one we are deleting
                favoritesBar.ListContentView.BoundsChanged -= UpdateWidth;
                UserSettings.Instance.set(UserSettingsKey.FavoritesBarExpansion, expanded ? "1" : "0");
                favoritesBar.ListContentView         = new IconView(theme, expanded ? 48 * GuiWidget.DeviceScale : 24 * GuiWidget.DeviceScale);
                favoritesBar.ListContentView.HAnchor = HAnchor.Fit;
                // add to the one we created
                favoritesBar.ListContentView.BoundsChanged += UpdateWidth;
                expandBarButton.SetIcon(expanded ? collapsedImage : expandedImage);
                expandBarButton.Invalidate();
                expandBarButton.ToolTipText = expanded ? "Reduced Width".Localize() : "Expand Width".Localize();

                await favoritesBar.Reload();
                UpdateWidth(favoritesBar.ListContentView, null);
            });
            leftBar.AddChild(expandBarButton);

            favoritesBar.Margin = new BorderDouble(bottom: expandBarButton.Height + expandBarButton.Margin.Height);

            favoritesBarAndView3DWidget.AddChild(view3DWidget);
            toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget);

            view3DContainer.AddChild(toolbarAndView3DWidget);

            leftToRight.AddChild(view3DContainer);

            if (sceneContext.World.RotationMatrix == Matrix4X4.Identity)
            {
                this.view3DWidget.ResetView();
            }

            this.AnchorAll();
        }
コード例 #6
0
        // private List<IObject3DEditor> _IObject3DEditorProviders = new List<IObject3DEditor>()
        // {
        //  new IntersectionEditor(),
        //  new SubtractEditor(),
        //  new SubtractAndReplace()
        // };

        public ExtensionsConfig(LibraryConfig libraryConfig)
        {
            this.libraryConfig = libraryConfig;

            objectEditorsByType = new Dictionary <Type, HashSet <IObject3DEditor> >();
        }
コード例 #7
0
        public PartTabPage(PrinterConfig printer, BedConfig sceneContext, ThemeConfig theme, string tabTitle)
            : base(tabTitle)
        {
            this.sceneContext    = sceneContext;
            this.theme           = theme;
            this.BackgroundColor = theme.ActiveTabColor;
            this.Padding         = 0;
            this.printer         = printer;

            bool isPrinterType = this is PrinterTabPage;

            var favoritesBarAndView3DWidget = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            viewControls3D = new ViewControls3D(sceneContext, theme, sceneContext.Scene.UndoBuffer, isPrinterType, !(this is PrinterTabPage))
            {
                VAnchor = VAnchor.Top | VAnchor.Fit,
                HAnchor = HAnchor.Left | HAnchor.Stretch,
                Visible = true,
            };
            theme.ApplyBottomBorder(viewControls3D, shadedBorder: (this is PrinterTabPage));             // Shade border if toolbar is secondary rather than primary

            viewControls3D.ResetView += (sender, e) =>
            {
                if (view3DWidget.Visible)
                {
                    this.view3DWidget.ResetView();
                }
            };
            viewControls3D.ExtendOverflowMenu  = this.GetViewControls3DOverflowMenu;
            viewControls3D.OverflowButton.Name = "View3D Overflow Menu";

            // The 3D model view
            view3DWidget = new View3DWidget(
                printer,
                sceneContext,
                viewControls3D,
                theme,
                this,
                editorType: (isPrinterType) ? MeshViewerWidget.EditorType.Printer : MeshViewerWidget.EditorType.Part);

            viewControls3D.SetView3DWidget(view3DWidget);

            // Construct and store dictionary of menu actions accessible at workspace level
            view3DWidget.WorkspaceActions = viewControls3D.MenuActions.Where(o => !string.IsNullOrEmpty(o.ID)).ToDictionary(o => o.ID, o => o);

            this.AddChild(topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            topToBottom.AddChild(leftToRight = new FlowLayoutWidget()
            {
                Name    = "View3DContainerParent",
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            });

            view3DContainer = new GuiWidget()
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            var toolbarAndView3DWidget = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch
            };

            toolbarAndView3DWidget.AddChild(viewControls3D);

            var dummyContext = new LibraryConfig()
            {
                ActiveContainer = ApplicationController.Instance.Library.ActiveContainer
            };

            var favoritesBar = new ListView(dummyContext, theme)
            {
                Name = "LibraryView",
                // Drop containers
                ContainerFilter  = (container) => false,
                BackgroundColor  = theme.ActiveTabColor,
                ListContentView  = new IconListView(theme, 22),
                Border           = new BorderDouble(top: 1, right: 1),
                BorderColor      = theme.GetBorderColor(15),
                HAnchor          = HAnchor.Absolute,
                Width            = 33,
                AllowContextMenu = false
            };

            favoritesBarAndView3DWidget.AddChild(favoritesBar);
            favoritesBarAndView3DWidget.AddChild(view3DWidget);
            toolbarAndView3DWidget.AddChild(favoritesBarAndView3DWidget);

            view3DContainer.AddChild(toolbarAndView3DWidget);

            leftToRight.AddChild(view3DContainer);

            if (sceneContext.World.RotationMatrix == Matrix4X4.Identity)
            {
                this.view3DWidget.ResetView();
            }

            this.AnchorAll();
        }