コード例 #1
0
ファイル: WorkflowManager.cs プロジェクト: koppor/motionEAP
        public bool loadWorkflow(string path)
        {
            UtilitiesIO.GetObjectFromJson(ref m_LoadedWorkflow, path);
            m_LoadedWorkflowFilename = path.Split(Path.DirectorySeparatorChar).Last <String>();

            // set all layouts
            BoxManager.Instance.SetNewLayout(m_LoadedWorkflow.BoxLayout);
            ObjectDetectionManager.Instance.SetNewLayout(m_LoadedWorkflow.ObjectZoneLayout);
            AssemblyZoneManager.Instance.SetNewLayout(m_LoadedWorkflow.AssemblyZoneLayout);

            BackendControl.Instance.refreshGUI();

            m_CurrentWorkingStepNumber = 0;
            StateManager.Instance.SetNewState(this, AllEnums.State.WORKFLOW_LOADED);

            // log that we loaded the workflow
            StudyLogger.Instance.logWorkflowLoaded(m_LoadedWorkflow.Id, m_LoadedWorkflow.Name);


            // remove feedback artifacts from previous stuff
            SceneManager.Instance.DisplayTempFeedback = false;
            SceneManager.Instance.TemporaryFeedbackScene.Clear();

            StatsManager.Instance.initialize();

            OnWorkflowLoaded();

            return(true);
        }
コード例 #2
0
ファイル: SettingsManager.cs プロジェクト: koppor/motionEAP
        public void load()
        {
            // Get Values from XML and set these values to the fields
            Boolean isOkay = UtilitiesIO.GetObjectFromJson(ref m_Settings, ProjectConstants.SETTINGS_FILE);

            m_Settings.PropertyChanged += m_Settings_PropertyChanged;
        }
コード例 #3
0
        public static void saveAssemblyZoneLayoutToFile(AssemblyZoneLayout pLayout)
        {
            // check if scnes dir exists
            if (!Directory.Exists(ProjectConstants.ASSEMBLYZONES_DIR))
            {
                // if not create it
                Directory.CreateDirectory(ProjectConstants.ASSEMBLYZONES_DIR);
            }

            System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.ASSEMBLYZONES_DIR;
            dlg.Filter           = "zone files (*.zone)|*.zone";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string filename = dlg.FileName;

            if (!filename.EndsWith(ProjectConstants.ASSEMBLYZONE_FILE_ENDING))
            {
                filename = filename + ProjectConstants.ASSEMBLYZONE_FILE_ENDING;
            }

            UtilitiesIO.SaveObjectToJson(pLayout, filename);
        }
コード例 #4
0
        public void SaveCurrentWorkflow(bool showFileSaveDialog)
        {
            // check if workflow dir exists
            if (!Directory.Exists(ProjectConstants.WORKFLOW_DIR))
            {
                // if not create it
                Directory.CreateDirectory(ProjectConstants.WORKFLOW_DIR);
            }

            string filename;

            if (showFileSaveDialog)
            {
                System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();

                dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.WORKFLOW_DIR;
                dlg.ShowDialog();

                filename = dlg.FileName;
                if (!filename.EndsWith(ProjectConstants.WORKFLOW_FILE_ENDING))
                {
                    filename = filename + ProjectConstants.WORKFLOW_FILE_ENDING;
                }
            }
            else
            {
                filename = ProjectConstants.WORKFLOW_DIR + "\\" + CurrentWorkflow.Name + ProjectConstants.WORKFLOW_FILE_ENDING;
            }

            UtilitiesIO.SaveObjectToJson(m_CurrentWorkflow, filename);
        }
コード例 #5
0
        public void SaveSceneToFile()
        {
            // check if scnes dir exists
            if (!Directory.Exists(ProjectConstants.SCENES_DIR))
            {
                // if not create it
                Directory.CreateDirectory(ProjectConstants.SCENES_DIR);
            }

            System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.SCENES_DIR;
            dlg.Filter           = "scene files (*.scene)|*.scene";

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string filename = dlg.FileName;

            if (!filename.EndsWith(ProjectConstants.SCENE_FILE_ENDING))
            {
                filename = filename + ProjectConstants.SCENE_FILE_ENDING;
            }

            UtilitiesIO.SaveObjectToJson(CurrentScene, filename);
        }
コード例 #6
0
ファイル: PBDManager.cs プロジェクト: koppor/motionEAP
        public void loadPBDWorkFlow()
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.WORKFLOW_DIR;
            dlg.Filter           = "workflow files (*.work)|*.work";
            dlg.FilterIndex      = 2;
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Workflow w      = new Workflow();
            bool     isOkay = UtilitiesIO.GetObjectFromJson(ref w, dlg.FileName);

            if (!isOkay)
            {
                return;
            }

            EditWorkflowManager.Instance.CurrentWorkflow = w;
            //AdminView.Instance.SetWorkflowTextBlockDescription(EditWorkflowManager.Instance.CurrentWorkflow.Description);

            // set the databinding
            BackendControl.Instance.refreshGUI();
            EditWorkflowManager.Instance.CurrentWorkingStepNumber = EditWorkflowManager.Instance.HighestWorkingStepNumber;
        }
コード例 #7
0
        public void CopyToClipboard()
        {
            var format = System.Windows.Forms.DataFormats.GetFormat(this.GetType().FullName);

            System.Windows.Forms.IDataObject dataObject = new System.Windows.Forms.DataObject();
            dataObject.SetData(format.Name, false, UtilitiesIO.SaveObjectToJsonString <SceneItem>(this));
            Clipboard.SetDataObject(dataObject, false);
        }
コード例 #8
0
        public static Scene GetFromClipboard()
        {
            Scene       scene      = null;
            String      jsonString = "";
            IDataObject dataObject = Clipboard.GetDataObject();
            string      format     = typeof(Scene).FullName;

            if (dataObject.GetDataPresent(format))
            {
                jsonString = dataObject.GetData(format) as String;
                UtilitiesIO.GetObjectFromJsonString <Scene>(ref scene, jsonString);
            }
            scene.Id = new Scene().Id;
            return(scene);
        }
コード例 #9
0
        public static ObjectDetectionZonesLayout loadObjectDetectionZoneLayout()
        {
            // filechooser
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.OBJECTDETECTIONZONES_DIR;
            dlg.Filter = "ozone files (*.ozone)|*.ozone";
            dlg.FilterIndex = 2;
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ObjectDetectionZonesLayout ret = null;
                bool isOkay = UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName);
                if (!isOkay)
                    return null;
                else
                    return ret;
            }

            return null;
        }
コード例 #10
0
        public static BoxLayout loadBoxLayoutFromFile()
        {
            BoxLayout ret = null;

            // filechooser
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.BOXES_DIR;
            dlg.Filter           = "box files (*.box)|*.box";
            dlg.FilterIndex      = 2;
            dlg.RestoreDirectory = true;

            DialogResult res = dlg.ShowDialog();

            //Nullable<bool> result = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName);
            }

            return(ret);
        }
コード例 #11
0
        public static void saveBoxLayoutToFile(BoxLayout pCurrentLayout)
        {
            // check if scnes dir exists
            if (!Directory.Exists(ProjectConstants.BOXES_DIR))
            {
                // if not create it
                Directory.CreateDirectory(ProjectConstants.BOXES_DIR);
            }

            System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
            dlg.Filter           = "Box files (*" + ProjectConstants.BOX_FILE_ENDING + ")|*" + ProjectConstants.BOX_FILE_ENDING + "|All files (*.*)|*.*";
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.BOXES_DIR;
            dlg.ShowDialog();

            string filename = dlg.FileName;

            if (!filename.EndsWith(ProjectConstants.BOX_FILE_ENDING))
            {
                filename = filename + ProjectConstants.BOX_FILE_ENDING;
            }
            UtilitiesIO.SaveObjectToJson(pCurrentLayout, filename);
        }
コード例 #12
0
        public static void saveObjectDetectionZoneLayoutToFile(ObjectDetectionZonesLayout pCurrentLayout)
        {
            // check if scnes OBJECTDETECTIONZONES_DIR exists
            if (!Directory.Exists(ProjectConstants.OBJECTDETECTIONZONES_DIR))
            {
                Directory.CreateDirectory(ProjectConstants.OBJECTDETECTIONZONES_DIR);
            }

            System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.OBJECTDETECTIONZONES_DIR;
            dlg.Filter = "ozone files (*.ozone)|*.ozone";

            if (dlg.ShowDialog() != DialogResult.OK)
                return;

            string filename = dlg.FileName;
            if (!filename.EndsWith(ProjectConstants.OBJECTDETECTIONZONES_FILE_ENDING))
            {
                filename = filename + ProjectConstants.OBJECTDETECTIONZONES_FILE_ENDING;
            }

            UtilitiesIO.SaveObjectToJson(pCurrentLayout, filename);
        }
コード例 #13
0
        public static AssemblyZoneLayout loadAssemblyZoneLayoutFromFile()
        {
            AssemblyZoneLayout ret = null;

            // filechooser
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.ASSEMBLYZONES_DIR;
            dlg.Filter           = "zone files (*.zone)|*.zone";
            dlg.FilterIndex      = 2;
            dlg.RestoreDirectory = true;

            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                bool isOkay = UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName);
                if (!isOkay)
                {
                    return(null);
                }
            }

            return(ret);
        }
コード例 #14
0
        public Scene.Scene LoadSceneFromFile()
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\" + ProjectConstants.SCENES_DIR;
            dlg.Filter           = "scene files (*.scene)|*.scene";
            dlg.FilterIndex      = 2;
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            Scene.Scene ret = null;

            bool isOkay = UtilitiesIO.GetObjectFromJson(ref ret, dlg.FileName);

            if (!isOkay)
            {
                return(null);
            }

            return(ret);
        }
コード例 #15
0
ファイル: SettingsManager.cs プロジェクト: koppor/motionEAP
 public void save()
 {
     bool successful = UtilitiesIO.SaveObjectToJson(m_Settings, ProjectConstants.SETTINGS_FILE);
 }
コード例 #16
0
        private void ParseEventProperties()
        {
            XmlDocument doc = new XmlDocument();

            lock (_syncObject)
            {
                try
                {
                    List <string> propertiesToRemove = _events.Keys.ToList();

                    UtilitiesIO.WaitForReadAccess(_filePath, new TimeSpan(0, 0, 15), new TimeSpan(0, 0, 0, 0, 500));

                    doc.Load(_filePath);
                    XmlNode paramsNode = doc.SelectSingleNode(Consts.EventProperties.Root);

                    if (paramsNode == null)
                    {
                        throw new Exception("Root param have not child nodes.");
                    }

                    foreach (XmlNode node in paramsNode.ChildNodes)
                    {
                        if (node.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        if (node.Name != Consts.EventProperties.Element)
                        {
                            continue;
                        }

                        string        key           = null;
                        EventProperty eventProperty = new EventProperty();

                        try
                        {
                            key = node.Attributes[Consts.EventProperties.KeyAttribute].Value;

                            RecurringEvent    recurring;
                            List <TimeSpan>   times      = new List <TimeSpan>();
                            List <DaysOfWeek> daysOfWeek = new List <DaysOfWeek>();

                            if (!Enum.TryParse(node.Attributes[Consts.EventProperties.RecurringEventAttribute].Value, out recurring))
                            {
                                throw new Exception("Recurring is not enum");
                            }

                            foreach (string day in node
                                     .Attributes[Consts.EventProperties.DaysOfWeekAttribute].Value.Split(',').Select(d => d.Trim()))
                            {
                                DaysOfWeek dayEnum;

                                if (!Enum.TryParse(day, out dayEnum))
                                {
                                    throw new Exception("DayOfWeek is not enum");
                                }

                                daysOfWeek.Add(dayEnum);
                            }

                            foreach (string time in node
                                     .Attributes[Consts.EventProperties.TimeAttribute].Value.Split(',').Select(t => t.Trim()))
                            {
                                TimeSpan timeEnum;

                                if (!Enum.TryParse(time, out timeEnum))
                                {
                                    throw new Exception("Times is not enum");
                                }

                                times.Add(timeEnum);
                            }

                            eventProperty.Name        = key;
                            eventProperty.Recurring   = recurring;
                            eventProperty.Times       = times.ToArray();
                            eventProperty.DaysOfWeeks = daysOfWeek.ToArray();

                            if (_events.ContainsKey(key))
                            {
                                propertiesToRemove.Remove(key);

                                _events.Remove(key);
                                _events.Add(key, eventProperty);
                            }
                            else
                            {
                                _events.Add(key, eventProperty);
                            }
                        }
                        catch { }
                    }

                    if (propertiesToRemove.Count > 0)
                    {
                        foreach (string pName in propertiesToRemove)
                        {
                            _events.Remove(pName);
                        }
                    }

                    if (!_initialized)
                    {
                        _initialized = true;
                    }
                }
                catch { }
            }
        }
コード例 #17
0
        private void ParseExternalProperties()
        {
            XmlDocument doc = new XmlDocument();

            lock (_syncObject)
            {
                try
                {
                    List <string> propertiesToRemove = _currentProperties.Keys.ToList();

                    UtilitiesIO.WaitForReadAccess(_filePath, new TimeSpan(0, 0, 15), new TimeSpan(0, 0, 0, 0, 500));

                    doc.Load(_filePath);
                    XmlNode paramsNode = doc.SelectSingleNode(Consts.ServiceProperties.Root);

                    if (paramsNode == null)
                    {
                        throw new Exception("Root param have not child nodes.");
                    }

                    foreach (XmlNode node in paramsNode.ChildNodes)
                    {
                        if (node.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        if (node.Name != Consts.ServiceProperties.Element)
                        {
                            continue;
                        }

                        string name  = null;
                        string value = null;
                        string type  = null;

                        try
                        {
                            name  = node.Attributes[Consts.ServiceProperties.KeyAttribute].Value;
                            value = node.Attributes[Consts.ServiceProperties.ValueAttribute].Value;
                            type  = node.Attributes[Consts.ServiceProperties.TypeAttribute].Value;

                            if (!Consts.ServicePropertyTypes.Types.Contains(type))
                            {
                                continue;
                            }

                            if (_currentProperties.ContainsKey(name))
                            {
                                propertiesToRemove.Remove(name);

                                _currentProperties.Remove(name);
                                _currentProperties.Add(name, new Tuple <string, string>(value, type));
                            }
                            else
                            {
                                _currentProperties.Add(name, new Tuple <string, string>(value, type));
                            }
                        }
                        catch { }
                    }

                    if (propertiesToRemove.Count > 0)
                    {
                        foreach (string pName in propertiesToRemove)
                        {
                            _currentProperties.Remove(pName);
                        }
                    }

                    if (!_initialized)
                    {
                        _initialized = true;
                    }
                }
                finally
                {
                }
            }
        }