Esempio n. 1
0
        /*public void Serialize()
         * {
         *  foreach (var data in _savedIems)
         *  {
         *      string sv = Serialize(data.Value);
         *      if (TryRead(data.Key))
         *          _addNewResource(data.Key, sv);
         *      else
         *          Write(data.Key, sv);
         *  }
         * }*/

        protected virtual void On_ValueSaved(KeyValueEventArgs e)
        {
            if (ValueSaved != null)
            {
                ValueSaved(this, e);
            }
        }
        public void Create_KeyValueCancelEventArgs <T, U>(T key, U value, bool cancel)
        {
            var args = KeyValueEventArgs.Create(key, value, cancel);

            Assert.That(args.Key, Is.EqualTo(key));
            Assert.That(args.Value, Is.EqualTo(value));
        }
Esempio n. 3
0
        /// <summary>
        /// 水平步进方法
        /// /// 2015-04-16
        /// 吴海龙
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SetHorizontalStep(object sender, KeyValueEventArgs e)
        {
            if ("" == KeyValueEventArgs.Key)
            {
                return;
            }

            int TempCenterOfTheCircleX = CenterOfTheCircleX;

            using (Graphics g = this.CreateGraphics())
            {
                g.SmoothingMode      = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿
                g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                g.CompositingQuality = CompositingQuality.HighQuality;
                foreach (var item in sdict.Keys)
                {
                    g.DrawLine(p2, new Point(CenterOfTheCircleX, CenterOfTheCircleY), new Point(TempCenterOfTheCircleX, CenterOfTheCircleY));
                    g.DrawString(sdict[item], f1, Brushes.Green, new PointF(TempCenterOfTheCircleX + ItemFixX, CenterOfTheCircleY + ItemFixY));
                    //g.FillEllipse(Brushes.White, TempCenterOfTheCircleX, CenterOfTheCircleY, CircleRadius * 2, CircleRadius * 2);
                    g.DrawEllipse(p3, TempCenterOfTheCircleX - CircleRadius, CenterOfTheCircleY - CircleRadius, CircleRadius * 2, CircleRadius * 2);
                    g.FillEllipse(Brushes.Green, TempCenterOfTheCircleX - PieRadius, CenterOfTheCircleY - PieRadius, PieRadius * 2, PieRadius * 2);
                    if (item == KeyValueEventArgs.Key)
                    {
                        break;
                    }
                    TempCenterOfTheCircleX = TempCenterOfTheCircleX + CircleSpace;
                }
            }
        }
Esempio n. 4
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnSaved
 ///
 /// <summary>
 /// 設定の保存時に実行されます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected override void OnSaved(KeyValueEventArgs <Format, string> e)
 {
     if (!Lock.IsReadOnly)
     {
         Shared.Save(DataDirectory, IO);
     }
     base.OnSaved(e);
 }
Esempio n. 5
0
    void OnPlayerRemove(object sender, KeyValueEventArgs <Player, string> item)
    {
        GameObject cube;

        players.TryGetValue(item.Value, out cube);
        Destroy(cube);

        players.Remove(item.Value);
    }
    void OnEntityRemove(object sender, KeyValueEventArgs <Entity, string> item)
    {
        GameObject cube;

        entities.TryGetValue(item.Value, out cube);
        Destroy(cube);

        entities.Remove(item.Value);
    }
    void OnEntityMove(object sender, KeyValueEventArgs <Entity, string> item)
    {
        GameObject cube;

        entities.TryGetValue(item.Value, out cube);

        Debug.Log(item.Value.x);

        cube.transform.Translate(new Vector3(item.Value.x, item.Value.y, 0));
    }
    void OnEntityAdd(object sender, KeyValueEventArgs <Entity, string> item)
    {
        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

        Debug.Log("Player add! x => " + item.Value.x + ", y => " + item.Value.y);

        cube.transform.position = new Vector3(item.Value.x, item.Value.y, 0);

        // add "player" to map of players
        entities.Add(item.Value, cube);
    }
    void OnEntityMove(object sender, KeyValueEventArgs <Entity, string> item)
    {
        GameObject cube;

        entities.TryGetValue(item.Value, out cube);

        Debug.Log("Movement! x: " + item.Value.x + ", y: " + item.Value.y);

        cube.transform.position = new Vector3(item.Value.x, item.Value.y, 0);
        // cube.transform.Translate (new Vector3 (item.Value.x, item.Value.y, 0));
    }
Esempio n. 10
0
        /// <summary>
        /// 垂直步进方法
        /// /// 2015-04-16
        /// 吴海龙
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SetVerticalStep(object sender, KeyValueEventArgs e)
        {
            int TempCenterOfThePieY = CenterOfTheCircleY;

            if ("" == KeyValueEventArgs.Key)
            {
                return;
            }
            using (Graphics g = this.CreateGraphics())
            {
                g.SmoothingMode      = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿
                g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                g.CompositingQuality = CompositingQuality.HighQuality;
                foreach (var item in sdict.Keys)
                {
                    g.DrawString(sdict[item], f1, Brushes.Green, ItemStartX, TempCenterOfThePieY - ItemFixY);
                    g.DrawEllipse(Pens.Green, CenterOfTheCircleX - CircleRadius, TempCenterOfThePieY - CircleRadius, CircleRadius * 2, CircleRadius * 2);
                    g.DrawLine(p2, new Point(LineStartX, LineStartY), new Point(LineStartX, TempCenterOfThePieY));
                    g.FillEllipse(Brushes.Green, CenterOfTheCircleX - PieRadius, TempCenterOfThePieY - PieRadius, PieRadius * 2, PieRadius * 2);
                    if (item == KeyValueEventArgs.Key)
                    {
                        break;
                    }
                    TempCenterOfThePieY = TempCenterOfThePieY + CircleSpace;
                }
            }
            //----------------------------------
            //if ("" == KeyValueEventArgs.Key)
            //{
            //    return;
            //}
            //int x = 20;
            //int y = 20;
            //using (Graphics g = this.CreateGraphics())
            //{
            //    g.SmoothingMode = SmoothingMode.HighQuality;  //使绘图质量最高,即消除锯齿
            //    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            //    g.CompositingQuality = CompositingQuality.HighQuality;
            //    foreach (var item in sdict.Keys)
            //    {
            //        g.DrawString(sdict[item], f1, Brushes.Green, new PointF(45, y + 20));
            //        g.DrawEllipse(Pens.Green, 25, y + 20, 18, 18);
            //        g.DrawLine(p2, new Point(34, 20), new Point(34, y + 25));
            //        g.FillEllipse(Brushes.Green, 28, y + 23, 12, 12);
            //        if (item == KeyValueEventArgs.Key)
            //        {
            //            break;
            //        }
            //        y = y + 80;
            //    }
            //}
        }
Esempio n. 11
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnSaved
 ///
 /// <summary>
 /// 保存時に実行されます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
 {
     try
     {
         var exe = IO.Combine(Assembly.DirectoryName, "CubeChecker.exe");
         new Startup("cubeice-checker")
         {
             Command = $"{exe.Quote()} CubeICE",
             Enabled = Value?.CheckUpdate ?? false,
         }.Save();
     }
     finally { base.OnSaved(e); }
 }
Esempio n. 12
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnDragDrop
        ///
        /// <summary>
        /// ファイルがドロップされた時に実行されます。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);

            var files = e.Data.GetData(DataFormats.FileDrop, false) as string[];

            if (files == null)
            {
                return;
            }

            foreach (var path in files)
            {
                var args = KeyValueEventArgs.Create(0, path);
                Aggregator.Get().Import.Publish(args);
            }
        }
Esempio n. 13
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// 保存時に実行されます。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                new Startup(IO.Get(UpdateProgram).NameWithoutExtension)
                {
                    Command = $"{UpdateProgram.Quote()} {Assembly.Product}",
                    Enabled = Value.CheckUpdate,
                }.Save();
            }
            finally { base.OnSaved(e); }
        }
Esempio n. 14
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// Occurs when the settings are saved.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                new Startup("cubepdf-checker")
                {
                    Command = $"{UpdateChecker.Quote()} {Assembly.Product}",
                    Enabled = Value.CheckUpdate,
                }.Save();
            }
            finally { base.OnSaved(e); }
        }
        /* ----------------------------------------------------------------- */
        ///
        /// Import_Handle
        ///
        /// <summary>
        /// ページのインポート時に実行されるハンドラです。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private async void Import_Handle(KeyValueEventArgs <int, string> e)
        {
            var path = !string.IsNullOrEmpty(e.Value) ? e.Value : GetImportFile();

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var index = GetInsertIndex(e.Key);

            await Async(() => Model.Import(
                            Settings.Current.Tag,
                            index,
                            path,
                            Settings.MaxAbstractLength
                            ));
        }
Esempio n. 16
0
 /* ----------------------------------------------------------------- */
 ///
 /// InitializeEvents
 ///
 /// <summary>
 /// 項目のイベントを初期化します。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private void InitializeEvents()
 {
     NewPageMenu.Click += (s, e)
                          => Aggregator.Get()?.NewPage.Publish(EventAggregator.Selected);
     ImportMenu.Click += (s, e)
                         => Aggregator.Get()?.Import.Publish(KeyValueEventArgs.Create(-1, ""));
     ExportMenu.Click += (s, e)
                         => Aggregator.Get()?.Export.Publish(EventAggregator.Selected);
     DuplicateMenu.Click += (s, e)
                            => Aggregator.Get()?.Duplicate.Publish(EventAggregator.Selected);
     RemoveMenu.Click += (s, e)
                         => Aggregator.Get()?.Remove.Publish(EventAggregator.Selected);
     UpMenu.Click += (s, e)
                     => Aggregator.Get()?.Move.Publish(ValueEventArgs.Create(-1));
     DownMenu.Click += (s, e)
                       => Aggregator.Get()?.Move.Publish(ValueEventArgs.Create(1));
     PropertyMenu.Click += (s, e)
                           => Aggregator.Get()?.Property.Publish(EventAggregator.Selected);
 }
Esempio n. 17
0
        /* ----------------------------------------------------------------- */
        ///
        /// View_PropertyChanged
        ///
        /// <summary>
        /// View の内容が変化した時に実行されるハンドラです。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void View_PropertyChanged(object sender, KeyValueEventArgs <string, object> e)
        => this.LogWarn(() =>
        {
            switch (e.Key)
            {
            case nameof(Model.Font):
                var font = e.Value as Font;
                if (font == null)
                {
                    break;
                }
                Model.FontName  = font.Name;
                Model.FontSize  = font.Size;
                Model.FontStyle = font.Style;
                break;

            case nameof(Model.AutoSaveTime):
                Model.AutoSaveTime = TimeSpan.FromSeconds((int)((decimal)e.Value));
                break;

            case nameof(Model.PrintMargin):
            case "PrintLeftMargin":
                Model.PrintMargin.Left = (int)((decimal)e.Value);
                break;

            case "PrintRightMargin":
                Model.PrintMargin.Right = (int)((decimal)e.Value);
                break;

            case "PrintTopMargin":
                Model.PrintMargin.Top = (int)((decimal)e.Value);
                break;

            case "PrintBottomMargin":
                Model.PrintMargin.Bottom = (int)((decimal)e.Value);
                break;

            default:
                SetValue(e.Key, e.Value);
                break;
            }
        });
Esempio n. 18
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// Occurs when the Saved event is fired.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                var exe = IO.Combine(Assembly.DirectoryName, $"CubeChecker.exe");
                var sk  = "CubePDF Utility2";

                new Startup($"cubepdf-utility-checker")
                {
                    Command = $"{exe.Quote()} {Assembly.Product.Quote()} /subkey {sk.Quote()}",
                    Enabled = Value.CheckUpdate,
                }.Save();
            }
            finally { base.OnSaved(e); }
        }
Esempio n. 19
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// 保存時に実行されます。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                var name = "cubeice-checker";
                var dir  = IO.Get(Assembly.Location).DirectoryName;

                new Startup(name)
                {
                    Command = IO.Combine(dir, $"{name}.exe").Quote(),
                    Enabled = Value.CheckUpdate,
                }.Save();
            }
            finally { base.OnSaved(e); }
        }
Esempio n. 20
0
        /* ----------------------------------------------------------------- */
        ///
        /// Search_Handle
        ///
        /// <summary>
        /// 検索画面を表示します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void Search_Handle(KeyValueEventArgs <int, string> e)
        => Sync(() =>
        {
            ResetSearchRange();
            View.Show();

            var count = View.SearchRange.Items.Count;
            if (count <= 0)
            {
                return;
            }

            var index = Math.Max(Math.Min(e.Key, count - 1), 0);
            View.SearchRange.SelectedIndex = index;

            if (!string.IsNullOrEmpty(e.Value))
            {
                View.Keyword = e.Value;
            }
            View.SelectKeyword();
        });
Esempio n. 21
0
        /* ----------------------------------------------------------------- */
        ///
        /// Create
        ///
        /// <summary>
        /// Creates the item associated with the specified key.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void Create(TKey src)
        {
            if (_created.ContainsKey(src) || !_creating.TryAdd(src, 0))
            {
                return;
            }

            try
            {
                var dest = _creator(src);
                if (_creating.ContainsKey(src) && _created.TryAdd(src, dest))
                {
                    OnCreated(KeyValueEventArgs.Create(src, dest));
                }
                else
                {
                    _disposer?.Invoke(src, dest);
                }
            }
            catch (Exception err) { OnFailed(KeyValueEventArgs.Create(src, err)); }
            finally { _creating.TryRemove(src, out var _); }
        }
Esempio n. 22
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// Occurs when the Saved event is fired.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                var name = "cubepdf-utility-checker";
                var exe  = IO.Combine(Assembly.GetDirectoryName(), "CubeChecker.exe");
                var sk   = "CubePDF Utility2";
                var args = $"{Assembly.GetNameString().Quote()} /subkey {sk.Quote()}";

                new Startup(name)
                {
                    Command = $"{exe.Quote()} {args}",
                    Enabled = Value.CheckUpdate && IO.Exists(exe),
                }.Save();
            }
            finally { base.OnSaved(e); }
        }
Esempio n. 23
0
        /* ----------------------------------------------------------------- */
        ///
        /// OnSaved
        ///
        /// <summary>
        /// Occurs when the settings are saved.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        protected override void OnSaved(KeyValueEventArgs <Cube.DataContract.Format, string> e)
        {
            try
            {
                if (Value == null)
                {
                    return;
                }

                var name = "cubepdf-checker";
                var exe  = IO.Combine(Assembly.GetDirectoryName(), "CubeChecker.exe");
                var args = Assembly.GetProduct().Quote();
                var dest = new Startup(name)
                {
                    Command = $"{exe.Quote()} {args}",
                    Enabled = Value.CheckUpdate && IO.Exists(exe),
                };

                dest.Save();
            }
            finally { base.OnSaved(e); }
        }
Esempio n. 24
0
        /* ----------------------------------------------------------------- */
        ///
        /// InitializeTextMenu
        ///
        /// <summary>
        /// コンテキストメニューを初期化します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void InitializeTextMenu()
        {
            var menu = TextMenu;

            if (menu == null)
            {
                return;
            }

            Settings.Current.PropertyChanged += Settings_CurrentChanged;

            var enabled = View.GetSelectedTextLength() > 0;

            menu.SearchMenu.Click += (s, e) =>
                                     Events.Search.Publish(KeyValueEventArgs.Create(0, View.GetSelectedText()));

            menu.GoogleMenu.Enabled = enabled;
            menu.GoogleMenu.Click  += (s, e)
                                      => Events.Google.Publish(ValueEventArgs.Create(View.GetSelectedText()));

            menu.UndoMenu.Enabled = View.CanUndo;
            menu.UndoMenu.Click  += (s, e) => Events.Undo.Publish();

            menu.RedoMenu.Enabled = View.CanRedo;
            menu.RedoMenu.Click  += (s, e) => Events.Redo.Publish();

            menu.CutMenu.Enabled = enabled;
            menu.CutMenu.Click  += (s, e) => View.Cut();

            menu.CopyMenu.Enabled = enabled;
            menu.CopyMenu.Click  += (s, e) => View.Copy();

            menu.PasteMenu.Enabled = View.CanPaste;
            menu.PasteMenu.Click  += (s, e) => View.Paste();

            menu.SelectAllMenu.Click += (s, e) => View.SelectAll();
        }
 /* ----------------------------------------------------------------- */
 ///
 /// ShowExplorerView
 ///
 /// <summary>
 /// エクスプローラ画面を表示します。
 /// </summary>
 ///
 /// <param name="e">情報を保持するオブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void ShowExplorerView(KeyValueEventArgs <string, string> e) =>
 _factory.ShowExplorerView(e);
        /* ----------------------------------------------------------------- */
        ///
        /// ShowExplorerView
        ///
        /// <summary>
        /// エクスプローラ画面を表示します。
        /// </summary>
        ///
        /// <param name="e">情報を保持するオブジェクト</param>
        ///
        /* ----------------------------------------------------------------- */
        public virtual void ShowExplorerView(KeyValueEventArgs <string, string> e)
        {
            var proc = System.Diagnostics.Process.Start(e.Key, e.Value.Quote());

            proc.Activate();
        }
Esempio n. 27
0
 /* ----------------------------------------------------------------- */
 ///
 /// RaiseUriClick
 ///
 /// <summary>
 /// UriClick イベントを発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected void RaiseUriClick()
 => OnUriClick(KeyValueEventArgs.Create(Uri, Message));
Esempio n. 28
0
 /* ----------------------------------------------------------------- */
 ///
 /// OnUriClick
 ///
 /// <summary>
 /// UriClick を発生させます。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 protected virtual void OnUriClick(KeyValueEventArgs <Uri, string> e)
 => UriClick?.Invoke(this, e);
Esempio n. 29
0
 /* ----------------------------------------------------------------- */
 ///
 /// WhenOpenDirectoryRequested
 ///
 /// <summary>
 /// ディレクトリを開く時に実行されるハンドラです。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private void WhenOpenDirectoryRequested(object s, KeyValueEventArgs <string, string> e) =>
 Views.ShowExplorerView(e);
Esempio n. 30
0
 /* ----------------------------------------------------------------- */
 ///
 /// ShowExplorerView
 ///
 /// <summary>
 /// エクスプローラ画面を表示します。
 /// </summary>
 ///
 /// <param name="e">情報を保持するオブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public override void ShowExplorerView(KeyValueEventArgs <string, string> e)
 {
     Assert.That(e.Key, Is.Not.Null.And.Not.Empty);
     Assert.That(System.IO.Directory.Exists(e.Value), Is.True);
 }