예제 #1
0
        /// <summary>メニュー クリックイベント</summary>
        /// <param name="sender">発生元オブジェクト</param>
        /// <param name="e">イベントデータ</param>
        private void SyncBaseFolderMenuItem_Click(object sender, EventArgs e)
        {
            // ベースフォルダのチェック
            var workFolders = new List <string> {
                Path.GetDirectoryName(this.shelf.FilePath)
            };

            // ベースフォルダの確認
            var failedBaseFolders = workFolders.Where(b => Directory.Exists(b) == false);

            if (failedBaseFolders.Count() > 0)
            {
                string message = string.Join(Environment.NewLine, failedBaseFolders);
                string.Format(Resources.ErrorBookListBaseFolderNotFound, message);

                MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return;
            }

            // 同期直前のデータ保存
            this.shelf.Columns = this.DetailList.GetColumns();
            this.shelf.WriteJson();

            this.shelf        = null;
            this.DialogResult = DialogResult.Retry;
            this.Close();

            using (var form = new SyncForm())
            {
                form.Owner   = this;
                this.Enabled = false;
                form.Show(workFolders[0]);
                this.Enabled = true;
            }
        }
예제 #2
0
        public static void SyncDocumentWithOnenote(Document document)
        {
            SyncForm syncForm = new SyncForm();

            syncForm.Show();
            try
            {
                //todo: don't know what filter is used for
                IEnumerator enumerator = document.Range(MmRange.mmRangeAllTopics, false).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var topic = enumerator.Current as Topic;
                    if (topic.HasHyperlink)
                    {
                        SyncTopicWithOnenote(topic, ref syncForm);

                        /*topic.Hyperlinks.AsEnumerable()
                         *  .ToList()
                         *  .ForEach(x => sb.AppendLine("topic.text " + topic.Text + "-----link: " + x.Address));*/
                    }
                }
            }
            catch (Exception ex)
            {
                throw new OneMapException("Error syncing document", ex);
            }
            finally
            {
                syncForm.Close();
                syncForm.Dispose();
            }
        }
 static SynchronizationDispatcher()
 {
     form.Show();
     TaskScheduler = form.GetTaskScheduler();
     Context       = form.GetContext();
     MainThreadId  = Thread.CurrentThread.ManagedThreadId;
 }
예제 #4
0
        private void syncToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SyncForm syncForm = new SyncForm();

            syncForm.Show();
            syncForm.MdiParent = this;
        }
        private async Task AnnotatePackage()
        {
            var package = this.dataGridView1.CurrentRow?.DataBoundItem as AnnotationPackage;

            if (package == null)
            {
                return;
            }

            if (!package.Extracted)
            {
                MessageBox.Show("Please extract package first", "Package is not available");
                return;
            }

            var yoloMarkPath = @"yolomark\yolo_mark.exe";

            if (!File.Exists(yoloMarkPath))
            {
                MessageBox.Show("Please download yolo mark first", "YoloMark missing");
                return;
            }

            // Turn our indices to Yolo Mark indices
            this.ChangeObjectClassIndices(package, true);

            // Start Yolo Mark
            var arguments = $@"""{package.PackagePath}"" yolomark\data\output.txt yolomark\data\obj.names";
            var process   = Process.Start(yoloMarkPath, arguments);

            await process.WaitForExitAsync();

            // Turn Yolo Mark indices to our indices
            this.ChangeObjectClassIndices(package, false);

            package.Images = null;
            this.FolderSelected?.Invoke(package);

            if (package.Info.IsAnnotated)
            {
                var dialogResult = MessageBox.Show("Do you want to sync the package now?", "Sync", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    var syncForm = new SyncForm(this._annotationPackageProvider);
                    syncForm.Show();

                    await syncForm.Sync(new AnnotationPackage[] { package });
                }
            }
        }
예제 #6
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            foreach (Control control in this.Controls)
            {
                MdiClient client = control as MdiClient;
                if (!(client == null))
                {
                    client.BackColor = Color.FromArgb(209, 237, 242);
                    break;
                }
            }

            foreach (ToolStripMenuItem item in menuStrip1.Items)
            {
                item.BackColor = Color.FromArgb(73, 173, 252);
                item.ForeColor = Color.FromArgb(32, 32, 32);
                foreach (ToolStripMenuItem children in item.DropDownItems)
                {
                    children.BackColor = Color.FromArgb(73, 173, 252);
                    children.ForeColor = Color.FromArgb(32, 32, 32);
                    foreach (ToolStripMenuItem child in children.DropDownItems)
                    {
                        child.BackColor = Color.FromArgb(73, 173, 252);
                        child.ForeColor = Color.FromArgb(32, 32, 32);
                        foreach (ToolStripMenuItem InnerChild in child.DropDownItems)
                        {
                            InnerChild.BackColor = Color.FromArgb(73, 173, 252);
                            InnerChild.ForeColor = Color.FromArgb(32, 32, 32);
                        }
                    }
                }
            }

            ToolStripLabel toolStripLabel = new ToolStripLabel();

            toolStripLabel.Text      = "Project ID: ";
            toolStripLabel.BackColor = Color.FromArgb(73, 173, 252);
            menuStrip1.Items.Add(toolStripLabel);

            ToolStripTextBox txtProjectID = new ToolStripTextBox();

            txtProjectID.Text     = Settings.Default.ProjectID;
            txtProjectID.AutoSize = false;
            Size size = TextRenderer.MeasureText(txtProjectID.Text, txtProjectID.Font);

            txtProjectID.Width    = size.Width + 10;
            txtProjectID.ReadOnly = true;
            txtProjectID.Padding  = new Padding(5);
            menuStrip1.Items.Add(txtProjectID);

            string json = JsonHelper.loadProjectInfo(Settings.Default.Username);
            List <ProjectModel> projectListModel = JsonConvert.DeserializeObject <List <ProjectModel> >(json);
            ProjectModel        projectModel     = new ProjectModel();

            projectModel = projectModel.getProjectModel(Settings.Default.ProjectID, projectListModel);
            DialogResult result;

            if (projectModel.LastDateTimeSynced.Year == 1)
            {
                result = MessageBox.Show("Do you want to sync with the server for the first time?", "Sync Now", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    SyncForm syncForm = new SyncForm();
                    syncForm.Show();
                    syncForm.MdiParent = this;
                    projectModel.LastDateTimeSynced = DateTime.Now;
                    projectListModel = projectModel.updateProjectList(projectListModel, projectModel);
                    json             = JsonConvert.SerializeObject(projectListModel);
                    JsonHelper.saveProjectInfo(json, Settings.Default.Username);
                }
            }
            else
            {
                if (projectModel.LastDateTimeSynced < DateTime.Today)
                {
                    result = MessageBox.Show("Do you want to sync with server now?", "Sync Now", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        //add sync method here
                        SyncForm syncForm = new SyncForm();
                        syncForm.Show();
                        syncForm.MdiParent = this;
                        projectModel.LastDateTimeSynced = DateTime.Now;
                        projectListModel = projectModel.updateProjectList(projectListModel, projectModel);
                        json             = JsonConvert.SerializeObject(projectListModel);
                        JsonHelper.saveProjectInfo(json, Settings.Default.Username);
                    }
                }
            }
        }