Esempio n. 1
0
        private void LoadLegacy()
        {
            using (StreamReader file = File.OpenText(configPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                var            data       = (Tuple <Dictionary <int, List <GUITask> >, List <GUIUser>, bool, int>)serializer.Deserialize(file, typeof(Tuple <Dictionary <int, List <GUITask> >, List <GUIUser>, bool, int>));

                var  tasks        = data.Item1;
                var  users        = data.Item2;
                bool overlayTasks = data.Item3;
                int  canvasId     = data.Item4;

                //load images and push tasks
                foreach (KeyValuePair <int, List <GUITask> > canvas in tasks)
                {
                    foreach (GUITask task in canvas.Value)
                    {
                        Bitmap original, converted, dithered;
                        try
                        {
                            original  = LoadBitmap(Path.Combine(folderPath, "original", task.InternalId + ".png"));
                            converted = LoadBitmap(Path.Combine(folderPath, "converted", task.InternalId + ".png"));
                            dithered  = LoadBitmap(Path.Combine(folderPath, "dithered", task.InternalId + ".png"));
                        }
                        catch (FileNotFoundException)
                        {
                            return;
                        }
                        GUITask newTask = new GUITask(task.InternalId, task.Name, task.Enabled, task.X, task.Y, task.Dithering, task.KeepRepairing, original, converted, dithered);
                        dataExchange.PushNewTask(newTask, canvas.Key);
                    }
                }

                //push users
                foreach (GUIUser user in users)
                {
                    dataExchange.PushNewUser(user);
                }

                dataExchange.PushSettings(overlayTasks, false, false, 0.5, canvasId, PlacementMode.TOPDOWN, 11.2);
                dataExchange.PushWindowState(1350, 950, System.Windows.WindowState.Normal);
            }
        }
Esempio n. 2
0
 public void PushNewTask(GUITask task, int taskCanvasId)
 {
     taskPanel.AddTask(task, taskCanvasId);
 }
Esempio n. 3
0
        private void LoadV0or1(bool v1)
        {
            using (StreamReader file = File.OpenText(configPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                List <object>  data       = serializer.Deserialize(file, typeof(List <object>)) as List <object>;

                string version = data[0] as string;
                Dictionary <int, List <GUITask> > tasks = (data[1] as JObject).ToObject(typeof(Dictionary <int, List <GUITask> >)) as Dictionary <int, List <GUITask> >;
                List <GUIUser> users = (data[2] as JArray).ToObject(typeof(List <GUIUser>)) as List <GUIUser>;;
                Dictionary <string, string> dataExchangeData = (data[3] as JObject).ToObject(typeof(Dictionary <string, string>)) as Dictionary <string, string>;

                //load images and push tasks
                foreach (KeyValuePair <int, List <GUITask> > canvas in tasks)
                {
                    foreach (GUITask task in canvas.Value)
                    {
                        Bitmap original, converted, dithered;
                        try
                        {
                            original  = LoadBitmap(Path.Combine(folderPath, "original", task.InternalId + ".png"));
                            converted = LoadBitmap(Path.Combine(folderPath, "converted", task.InternalId + ".png"));
                            dithered  = LoadBitmap(Path.Combine(folderPath, "dithered", task.InternalId + ".png"));
                        }
                        catch (FileNotFoundException)
                        {
                            return;
                        }
                        GUITask newTask = new GUITask(task.InternalId, task.Name, task.Enabled, task.X, task.Y, task.Dithering, task.KeepRepairing, original, converted, dithered);
                        dataExchange.PushNewTask(newTask, canvas.Key);
                    }
                }

                //push users
                foreach (GUIUser user in users)
                {
                    dataExchange.PushNewUser(user);
                }

                //parse parameters
                bool          overlayTasks        = bool.Parse(dataExchangeData["overlayTasks"]);
                bool          overlayAllTasks     = bool.Parse(dataExchangeData["overlayAllTasks"]);
                bool          overlaySelectedTask = bool.Parse(dataExchangeData["overlaySelectedTasks"]);
                double        overlayTranslucency = double.Parse(dataExchangeData["overlayTranslucency"], CultureInfo.InvariantCulture);
                int           canvasId            = int.Parse(dataExchangeData["canvasId"]);
                PlacementMode placementMode       = (PlacementMode)Enum.Parse(typeof(PlacementMode), dataExchangeData["placementMode"]);

                double placementSpeed = 11.2;
                if (v1)
                {
                    placementSpeed = double.Parse(dataExchangeData["placementSpeed"], CultureInfo.InvariantCulture);
                }

                double windowWidth  = double.Parse(dataExchangeData["windowWidth"], CultureInfo.InvariantCulture);
                double windowHeight = double.Parse(dataExchangeData["windowHeight"], CultureInfo.InvariantCulture);
                System.Windows.WindowState windowState = (System.Windows.WindowState)Enum.Parse(typeof(System.Windows.WindowState), dataExchangeData["windowState"]);

                dataExchange.PushSettings(overlayTasks, overlayAllTasks, overlaySelectedTask, overlayTranslucency, canvasId, placementMode, placementSpeed);
                dataExchange.PushWindowState(windowWidth, windowHeight, windowState);
            }
        }