public JobSubmissionForm(ILabsRequestHandler labsRequestHandler, IMaxRequestHandler maxRequestHandler, IMaxLogger logger)
        {
            _logger             = logger;
            _labsRequestHandler = labsRequestHandler;
            _maxRequestHandler  = maxRequestHandler;

            InitializeComponent();
            DataContext = this;

            SetWindowColor();
            SetControlColors();

            Templates        = TemplateHelper.GetApplicationTemplates(logger);
            SelectedTemplate = TemplateHelper.TemplateStandard;

            Renderers = new ObservableCollection <KeyValuePair <string, string> >();
            Renderers.AddRange(TemplateHelper.GetRenderers(TemplateHelper.TemplateStandard));
            // todo: read this from the scene
            SelectedRenderer = GetSelectedRenderer(TemplateHelper.TemplateStandard);

            MissingAssets = new ObservableCollection <IAssetFile>();
            MissingAssets.CollectionChanged += OnMissingCollectionChanged;
            MissingSpinnerVisibility         = Visibility.Collapsed;

            AssetDirectories = new ObservableCollection <AssetFolder>();
            AssetDirectories.CollectionChanged += OnDirectoryCollectionChanged;
            AssetSpinnerVisibility              = Visibility.Collapsed;

            // only load assets if we have a current scene
            if (HasSceneFile)
            {
                _logger.Debug($"Current renrder is set to: '{_maxRequestHandler.CurrentRenderer}'");

                _maxFileFolderPath = Path.GetDirectoryName(_maxRequestHandler.CurrentSceneFilePath);
                AssetDirectories.Add(new AssetFolder(_maxFileFolderPath, true));

                SceneFile.Text = _maxRequestHandler.CurrentSceneFileName;
                JobId.Text     = Utils.ContainerizeMaxFile(SceneFile.Text);

                FrameWidth.Text  = _maxRequestHandler.RenderWidth.ToString();
                FrameHeight.Text = _maxRequestHandler.RenderHeight.ToString();

                SetAssetCollection();
            }
            else
            {
                SetButtonState(false);
                Status.Text = "No scene loaded, unable to submit a job.";
                RenderTemplates.IsEnabled = false;
                RendererType.IsEnabled    = false;
            }
        }
Exemple #2
0
        public ColorPalette(IMaxRequestHandler maxRequestHandler, IMaxLogger logger)
        {
            InitializeComponent();
            DataContext = this;

            Brushes = new ObservableCollection <MaxColorBrush>();
            var uiColors = maxRequestHandler.GetAllColorBrushes();

            foreach (Tuple <string, Brush> color in uiColors)
            {
                logger.Debug($"case GuiColors.{color.Item1}: return ColorTranslator.FromHtml(\"{ color.Item2.ToString()}\");");
                Brushes.Add(new MaxColorBrush(color.Item1, color.Item2));
            }
        }
Exemple #3
0
        /// <summary>
        /// Read the collection of 3ds Max application templates from our GitHub repo. They
        /// are all listed in a file called index.json.
        /// </summary>
        /// <returns></returns>
        public static List <KeyValuePair <string, string> > GetApplicationTemplates(IMaxLogger logger)
        {
            var templates = new List <KeyValuePair <string, string> >();

            try
            {
                var request = WebRequest.Create(AppIndexJsonUrl);
                using (var response = (HttpWebResponse)request.GetResponse())
                {
                    using (var responseSteam = response.GetResponseStream())
                    {
                        // in the unlkely event, just return an empty collection
                        if (responseSteam == null)
                        {
                            return(templates);
                        }

                        // deserialize the json response into a collection of application templates
                        var jsonSerializer = new DataContractJsonSerializer(new List <ApplicationTemplate>().GetType());
                        var templateList   = jsonSerializer.ReadObject(responseSteam) as List <ApplicationTemplate>;
                        if (templateList != null)
                        {
                            foreach (var template in templateList)
                            {
                                logger.Debug($"Got template: {template.Id}, with name: {template.Name} ");
                                templates.Add(new KeyValuePair <string, string>(template.Id, template.Name));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error($"{ex.Message}\n{ex}", "Failed to get 3ds Max templates", true);
            }

            return(templates);
        }
 public BatchLabsRequestHandler(IMaxLogger logger)
 {
     _logger = logger;
 }